Skip to content

Commit

Permalink
Merge branch 'main' into fix-eventmesh-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
muralov authored Dec 18, 2023
2 parents 4f69db8 + 1817db9 commit 71ab869
Show file tree
Hide file tree
Showing 118 changed files with 1,226 additions and 763 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ jobs:
- name: Check image Tag
run: ./scripts/check_tag_info.sh ${{ github.event.inputs.name }}

# run-unit-tests:
# name: Unit tests
# needs: verify-head-status
# uses: "./.github/workflows/run-unit-tests.yaml"

create-draft:
name: Create draft release
needs: verify-head-status
Expand Down Expand Up @@ -69,14 +64,19 @@ jobs:
- name: Verify job status
run: ./scripts/verify-status.sh ${{ github.ref_name }} 600 10 30

- name: Create and upload eventing-manager.yaml and eventing-default-cr.yaml
env:
PULL_BASE_REF: ${{ github.event.inputs.name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMG: "europe-docker.pkg.dev/kyma-project/prod/eventing-manager:${{ github.event.inputs.name }}"
MODULE_REGISTRY: "europe-docker.pkg.dev/kyma-project/prod/unsigned"
KUSTOMIZE_VERSION: "v4.5.6"
run: |
./scripts/render_and_upload_manifests.sh
outputs:
release_id: ${{ steps.create-draft.outputs.release_id }}

# devOps-Insights:
# name: DevOps Insights
# needs: [verify-head-status, create-draft, run-unit-tests]
# uses: "./.github/workflows/metrics.yaml"

publish-release:
name: Publish release
needs: [verify-head-status, create-draft]
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Cache Binaries
id: cache-binaries
uses: actions/cache@v3
with:
path: bin
key: ${{ runner.os }}-bin

- name: Install k3d tools
run: |
make -C hack/ci/ install-k3d-tools
- name: Install Kyma CLI & setup k3d cluster using kyma CLI
run: |
make kyma
Expand Down
6 changes: 0 additions & 6 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ linters:
- varcheck # deprecated (since v1.49.0) and replaced by 'unused'
- wsl # too strict and mostly code is not more readable
### disabled for now... will be enabled 1 by 1
- containedctx
- dupl
- errorlint
- forcetypeassert
Expand All @@ -31,20 +30,16 @@ linters:
- goconst
- gocritic
- godox
- goerr113
- gomnd
- gosec
- inamedparam
- ireturn
- maintidx
- noctx
- nolintlint
- nonamedreturns
- paralleltest
- perfsprint
- prealloc
- stylecheck
- testifylint
- testpackage
- thelper
- tparallel
Expand All @@ -54,7 +49,6 @@ linters:
- wrapcheck
- godot
- tagalign
- whitespace

linters-settings:
stylecheck:
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
## Tool Versions
KUSTOMIZE_VERSION ?= v5.0.0
CONTROLLER_TOOLS_VERSION ?= v0.11.3
GOLANG_CI_LINT_VERSION ?= v1.55.2

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand All @@ -245,8 +246,15 @@ envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

lint:
golangci-lint run --fix --timeout 5m
golangci_lint:
test -s $(LOCALBIN)/golangci-lint && $(LOCALBIN)/golangci-lint version | grep -q $(GOLANG_CI_LINT_VERSION) || \
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANG_CI_LINT_VERSION)

lint: golangci_lint
$(LOCALBIN)/golangci-lint run

lint-fix: golangci_lint
$(LOCALBIN)/golangci-lint run --fix

go-gen:
go generate ./...
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Eventing Manager is a standard Kubernetes [operator](https://kubernetes.io/docs/

This project is scaffolded using [Kubebuilder](https://book.kubebuilder.io), and all the Kubebuilder `makefile` helpers mentioned [here](https://book.kubebuilder.io/reference/makefile-helpers.html) can be used.

## Get started
## Get Started

You need a Kubernetes cluster to run against. You can use [k3d](https://k3d.io/) to get a local cluster for testing, or run against a remote cluster.
> **Note:** Your controller automatically uses the current context in your kubeconfig file, that is, whatever cluster `kubectl cluster-info` shows.
Expand Down Expand Up @@ -42,7 +42,7 @@ You need a Kubernetes cluster to run against. You can use [k3d](https://k3d.io/)
- [kustomize](https://kustomize.io/)
- Access to Kubernetes cluster ([k3d](https://k3d.io/) / k8s)

### Run Eventing Manager locally
### Run Eventing Manager Locally

1. Install the CRDs into the cluster:

Expand All @@ -58,7 +58,7 @@ You need a Kubernetes cluster to run against. You can use [k3d](https://k3d.io/)

> **NOTE:** You can also run this in one step with the command: `make install run`.
### Run tests
### Run Tests

Run the unit and integration tests:

Expand All @@ -76,7 +76,7 @@ make generate-and-test
make lint
```

### Modify the API definitions
### Modify the API Definitions

If you are editing the API definitions, generate the manifests such as CRs or CRDs:

Expand All @@ -88,7 +88,7 @@ make manifests
For more information, see the [Kubebuilder documentation](https://book.kubebuilder.io/introduction.html).

### Build container images
### Build Container Images

Build and push your image to the location specified by `IMG`:

Expand All @@ -107,7 +107,7 @@ make docker-buildx IMG=<container-registry>/eventing-manager:<tag>
You need a Kubernetes cluster to run against. You can use [k3d](https://k3d.io/) to get a local cluster for testing, or run against a remote cluster.
> **Note:** Your controller automatically uses the current context in your kubeconfig file, that is, whatever cluster `kubectl cluster-info` shows.
### Deploy on the cluster
### Deploy on the Cluster

1. Download Go packages:

Expand All @@ -133,14 +133,15 @@ You need a Kubernetes cluster to run against. You can use [k3d](https://k3d.io/)
make deploy IMG=<container-registry>/eventing-manager:<tag>
```

4. [Optional] Install `Eventing` Custom Resource:
5. [Optional] Install `Eventing` Custom Resource:

```sh
kubectl apply -f config/samples/default.yaml
```

5. For EventMesh backend, if the Kyma Kubernetes cluster is managed by Gardener, then the Eventing Manager reads the cluster public domain from the ConfigMap **kube-system/shoot-info**.
6. For EventMesh backend, if the Kyma Kubernetes cluster is managed by Gardener, then the Eventing Manager reads the cluster public domain from the ConfigMap **kube-system/shoot-info**.
Otherwise, set the **spec.backend.config.domain** to the cluster public domain in the `eventing` custom resource; for example:

```yaml
spec:
backend:
Expand All @@ -167,7 +168,7 @@ To delete the CRDs from the cluster:
make uninstall
```

### Deploy Eventing Manager module with [Kyma Lifecycle Manager](https://github.com/kyma-project/lifecycle-manager/tree/main)
### Deploy Eventing Manager Module With [Kyma Lifecycle Manager](https://github.com/kyma-project/lifecycle-manager/tree/main)

1. Deploy the Lifecycle Manager to the Kubernetes cluster:

Expand Down Expand Up @@ -203,7 +204,7 @@ To delete the CRDs from the cluster:
kubectl get -n kyma-system kyma
```

### Uninstall Eventing Manager module with [Kyma Lifecycle Manager](https://github.com/kyma-project/lifecycle-manager/tree/main)
### Uninstall Eventing Manager Module With [Kyma Lifecycle Manager](https://github.com/kyma-project/lifecycle-manager/tree/main)

1. Delete Eventing custom resource (CR) from the Kubernetes cluster (if exists):

Expand Down
4 changes: 2 additions & 2 deletions api/eventing/v1alpha1/fixtures_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1alpha1_test

import (
"fmt"
"strconv"

kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -136,7 +136,7 @@ func newV2DefaultSubscription(opts ...eventingtesting.SubscriptionOpt) *v1alpha2
Sink: defaultSink,
ID: defaultID,
Config: map[string]string{
v1alpha2.MaxInFlightMessages: fmt.Sprint(defaultMaxInFlight),
v1alpha2.MaxInFlightMessages: strconv.Itoa(defaultMaxInFlight),
},
},
Status: v1alpha2.SubscriptionStatus{
Expand Down
4 changes: 2 additions & 2 deletions api/eventing/v1alpha1/subscription_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (src *Subscription) setProtocolSettings(dst *v1alpha2.Subscription) {
dst.Spec.Config[v1alpha2.ProtocolSettingsContentMode] = *src.Spec.ProtocolSettings.ContentMode
}
if src.Spec.ProtocolSettings.ExemptHandshake != nil {
dst.Spec.Config[v1alpha2.ProtocolSettingsExemptHandshake] = fmt.Sprint(*src.Spec.ProtocolSettings.ExemptHandshake)
dst.Spec.Config[v1alpha2.ProtocolSettingsExemptHandshake] = strconv.FormatBool(*src.Spec.ProtocolSettings.ExemptHandshake)
}
if src.Spec.ProtocolSettings.Qos != nil {
dst.Spec.Config[v1alpha2.ProtocolSettingsQos] = *src.Spec.ProtocolSettings.Qos
Expand Down Expand Up @@ -270,7 +270,7 @@ func (src *Subscription) natsSpecConfigToV2(dst *v1alpha2.Subscription) {
if dst.Spec.Config == nil {
dst.Spec.Config = map[string]string{}
}
dst.Spec.Config[v1alpha2.MaxInFlightMessages] = fmt.Sprint(src.Spec.Config.MaxInFlightMessages)
dst.Spec.Config[v1alpha2.MaxInFlightMessages] = strconv.Itoa(src.Spec.Config.MaxInFlightMessages)
}
}

Expand Down
4 changes: 2 additions & 2 deletions api/eventing/v1alpha1/subscription_conversion_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func Test_Conversion(t *testing.T) {
convertedV1Alpha2 := &v1alpha2.Subscription{}
err := v1alpha1.V1ToV2(testCase.alpha1Sub, convertedV1Alpha2)
if err != nil && testCase.wantErrMsgV1toV2 != "" {
require.Equal(t, err.Error(), testCase.wantErrMsgV1toV2)
require.Equal(t, testCase.wantErrMsgV1toV2, err.Error())
} else {
require.NoError(t, err)
v1ToV2Assertions(t, testCase.alpha2Sub, convertedV1Alpha2)
Expand All @@ -224,7 +224,7 @@ func Test_Conversion(t *testing.T) {
convertedV1Alpha1 := &v1alpha1.Subscription{}
err := v1alpha1.V2ToV1(convertedV1Alpha1, testCase.alpha2Sub)
if err != nil && testCase.wantErrMsgV2toV1 != "" {
require.Equal(t, err.Error(), testCase.wantErrMsgV2toV1)
require.Equal(t, testCase.wantErrMsgV2toV1, err.Error())
} else {
require.NoError(t, err)
v2ToV1Assertions(t, testCase.alpha1Sub, convertedV1Alpha1)
Expand Down
4 changes: 2 additions & 2 deletions api/eventing/v1alpha2/subscription_webhook_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func Test_Default(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
tc.givenSub.Default()
require.Equal(t, tc.givenSub, tc.wantSub)
require.Equal(t, tc.wantSub, tc.givenSub)
})
}
}
Expand Down Expand Up @@ -425,7 +425,7 @@ func Test_validateSubscription(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
_, err := tc.givenSub.ValidateSubscription()
require.Equal(t, err, tc.wantErr)
require.Equal(t, tc.wantErr, err)
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions api/operator/v1alpha1/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ func TestClearConditions(t *testing.T) {
},
},
}
require.NotEqual(t, 0, len(givenEventingStatus.Conditions))
require.NotEmpty(t, givenEventingStatus.Conditions)

// when
givenEventingStatus.ClearConditions()

// then
require.Len(t, givenEventingStatus.Conditions, 0)
require.Empty(t, givenEventingStatus.Conditions)
}

func TestClearPublisherService(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/operator/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/assets/evnt-architecture.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 71ab869

Please sign in to comment.