From 0a8b44dbf4da0a49bdc1ac7d5f0e4695958625ef Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Thu, 7 Sep 2023 17:39:35 +0200 Subject: [PATCH 01/33] Implement Send And Get Event APIs --- e2e/sink/cmd/main.go | 20 +++++ e2e/sink/go.mod | 17 ++++ e2e/sink/go.sum | 32 ++++++++ e2e/sink/internal/handler/handler.go | 115 +++++++++++++++++++++++++++ 4 files changed, 184 insertions(+) create mode 100644 e2e/sink/cmd/main.go create mode 100644 e2e/sink/go.mod create mode 100644 e2e/sink/go.sum create mode 100644 e2e/sink/internal/handler/handler.go diff --git a/e2e/sink/cmd/main.go b/e2e/sink/cmd/main.go new file mode 100644 index 00000000..5fd6d062 --- /dev/null +++ b/e2e/sink/cmd/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "github.com/kyma-project/eventing-manager/sink/internal/handler" + "go.uber.org/zap" +) + +func main() { + logger, err := zap.NewProduction() + if err != nil { + panic(err) + } + defer logger.Sync() + + sHandler := handler.NewSinkHandler(logger) + err = sHandler.Start() + if err != nil { + logger.Error("failed to start SinkHandler", zap.Error(err)) + } +} diff --git a/e2e/sink/go.mod b/e2e/sink/go.mod new file mode 100644 index 00000000..843b7cc6 --- /dev/null +++ b/e2e/sink/go.mod @@ -0,0 +1,17 @@ +module github.com/kyma-project/eventing-manager/sink + +go 1.20 + +require ( + github.com/cloudevents/sdk-go/v2 v2.14.0 + github.com/gorilla/mux v1.8.0 + go.uber.org/zap v1.10.0 +) + +require ( + github.com/json-iterator/go v1.1.10 // indirect + github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect + go.uber.org/atomic v1.4.0 // indirect + go.uber.org/multierr v1.1.0 // indirect +) diff --git a/e2e/sink/go.sum b/e2e/sink/go.sum new file mode 100644 index 00000000..70a2a099 --- /dev/null +++ b/e2e/sink/go.sum @@ -0,0 +1,32 @@ +github.com/cloudevents/sdk-go/v2 v2.14.0 h1:Nrob4FwVgi5L4tV9lhjzZcjYqFVyJzsA56CwPaPfv6s= +github.com/cloudevents/sdk-go/v2 v2.14.0/go.mod h1:xDmKfzNjM8gBvjaF8ijFjM1VYOVUEeUfapHMUX1T5To= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/e2e/sink/internal/handler/handler.go b/e2e/sink/internal/handler/handler.go new file mode 100644 index 00000000..b7b97ec2 --- /dev/null +++ b/e2e/sink/internal/handler/handler.go @@ -0,0 +1,115 @@ +package handler + +import ( + "context" + "net/http" + + "github.com/cloudevents/sdk-go/v2/binding" + "github.com/gorilla/mux" + "go.uber.org/zap" + + cev2event "github.com/cloudevents/sdk-go/v2/event" + cev2http "github.com/cloudevents/sdk-go/v2/protocol/http" +) + +type Handler interface { + Start() error +} + +type SinkHandler struct { + logger *zap.Logger + events map[string]*cev2event.Event +} + +func NewSinkHandler(logger *zap.Logger) *SinkHandler { + return &SinkHandler{ + logger: logger, + events: make(map[string]*cev2event.Event), + } +} + +func (h *SinkHandler) Start() error { + router := mux.NewRouter() + router.HandleFunc("/event", h.StoreEvent).Methods(http.MethodPost) + router.HandleFunc("/event/{eventID}", h.GetEvent).Methods(http.MethodGet) + + return http.ListenAndServe(":8080", router) +} + +func (h *SinkHandler) StoreEvent(w http.ResponseWriter, r *http.Request) { + event, err := extractCloudEventFromRequest(r) + if err != nil { + h.namedLogger().With().Error("failed to extract CloudEvent from request", zap.Error(err)) + e := writeResponse(w, http.StatusBadRequest, []byte(err.Error())) + if e != nil { + h.namedLogger().Error("failed to write response", zap.Error(e)) + } + return + } + + h.events[event.ID()] = event + err = writeResponse(w, http.StatusNoContent, []byte("")) + if err != nil { + h.namedLogger().Error("failed to write response", zap.Error(err)) + } +} + +func (h *SinkHandler) GetEvent(w http.ResponseWriter, r *http.Request) { + eventID := mux.Vars(r)["eventID"] + event, ok := h.events[eventID] + if !ok { + h.namedLogger().With().Error("event not found", zap.String("eventID", eventID)) + e := writeResponse(w, http.StatusNotFound, []byte("event not found")) + if e != nil { + h.namedLogger().Error("failed to write response", zap.Error(e)) + } + return + } + + respBody, err := event.MarshalJSON() + if err != nil { + h.namedLogger().With().Error("failed to marshal event", zap.Error(err)) + e := writeResponse(w, http.StatusInternalServerError, []byte(err.Error())) + if e != nil { + h.namedLogger().Error("failed to write response", zap.Error(e)) + } + return + } + + err = writeResponse(w, http.StatusOK, respBody) + if err != nil { + h.namedLogger().Error("failed to write response", zap.Error(err)) + } +} + +func (h *SinkHandler) namedLogger() *zap.Logger { + return h.logger.Named("sink-handler") +} + +// extractCloudEventFromRequest converts an incoming CloudEvent request to an Event. +func extractCloudEventFromRequest(r *http.Request) (*cev2event.Event, error) { + message := cev2http.NewMessageFromHttpRequest(r) + defer func() { _ = message.Finish(nil) }() + + event, err := binding.ToEvent(context.Background(), message) + if err != nil { + return nil, err + } + + err = event.Validate() + if err != nil { + return nil, err + } + return event, nil +} + +// writeResponse writes the HTTP response given the status code and response body. +func writeResponse(writer http.ResponseWriter, statusCode int, respBody []byte) error { + writer.WriteHeader(statusCode) + + if respBody == nil { + return nil + } + _, err := writer.Write(respBody) + return err +} From e8e848783da839d121a4fc7911266838e5d37c89 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 09:40:02 +0200 Subject: [PATCH 02/33] Build docker image with GithubAction * Create dockerfile * Create makefile file * Create GithubAction to build image with dockerfile --- .github/workflows/sink.yml | 69 +++++++++++++++++++++- e2e/sink/.dockerignore | 4 ++ e2e/sink/.gitignore | 38 ++++++++++++ e2e/sink/Dockerfile | 34 +++++++++++ e2e/sink/Makefile | 117 +++++++++++++++++++++++++++++++++++++ 5 files changed, 259 insertions(+), 3 deletions(-) create mode 100644 e2e/sink/.dockerignore create mode 100644 e2e/sink/.gitignore create mode 100644 e2e/sink/Dockerfile create mode 100644 e2e/sink/Makefile diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 27196342..66044d18 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -1,11 +1,74 @@ name: E2E Tests Sink +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + E2E_SINK_PATH: e2e/sink -on: [push] +on: + push: + branches: [ "main" ] + tags: [ '*.*.*' ] + paths: + - '${{ env.E2E_SINK_PATH }}/**' + pull_request_target: + branches: [ "main" ] + paths: + - '${{ env.E2E_SINK_PATH }}/**' + +defaults: + run: + working-directory: ${{ env.E2E_SINK_PATH }} jobs: + build: runs-on: ubuntu-latest + permissions: write-all steps: - - name: Say Hello - run: echo "Hello, World!" \ No newline at end of file + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.19 + cache: true + + - name: Build + run: go build -v ./... + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=sha + type=semver,pattern={{version}},event=tag + + - name: Build Docker image + id: build-and-push + uses: docker/build-push-action@v4 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + load: ${{ github.event_name == 'pull_request' }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/e2e/sink/.dockerignore b/e2e/sink/.dockerignore new file mode 100644 index 00000000..0f046820 --- /dev/null +++ b/e2e/sink/.dockerignore @@ -0,0 +1,4 @@ +# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file +# Ignore build and test binaries. +bin/ +testbin/ diff --git a/e2e/sink/.gitignore b/e2e/sink/.gitignore new file mode 100644 index 00000000..e500a855 --- /dev/null +++ b/e2e/sink/.gitignore @@ -0,0 +1,38 @@ + +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib +bin +testbin/* +Dockerfile.cross + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Kubernetes Generated files - skip generated files, except for vendored files + +!vendor/**/zz_generated.* + +# editor and IDE paraphernalia +.idea +*.swp +*.swo +*~ +.DS_Store +# vscode +*.code-workspace +.vscode/* + +# Binaries +bin/* + +# Vendor +vendor/ + +.env.dev diff --git a/e2e/sink/Dockerfile b/e2e/sink/Dockerfile new file mode 100644 index 00000000..d2dcfb4c --- /dev/null +++ b/e2e/sink/Dockerfile @@ -0,0 +1,34 @@ +# Build the sink binary +FROM europe-docker.pkg.dev/kyma-project/prod/external/golang:1.21.0-alpine3.18 as builder +ARG TARGETOS +ARG TARGETARCH + +WORKDIR /workspace +# Copy the Go Modules manifests +COPY go.mod go.mod +COPY go.sum go.sum +# cache deps before building and copying source so that we don't need to re-download as much +# and so that source changes don't invalidate our downloaded layer +RUN go mod download + +# Copy the go source +COPY cmd/main.go cmd/main.go +COPY internal internal + +# Build +# the GOARCH has not a default value to allow the binary be built according to the host where the command +# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO +# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, +# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o sink cmd/main.go + +# Use distroless as minimal base image to package the sink binary +# Refer to https://github.com/GoogleContainerTools/distroless for more details +FROM gcr.io/distroless/static:nonroot +LABEL source = git@github.com:kyma-project/eventing-manager.git + +WORKDIR / +COPY --from=builder /workspace/sink . +USER nonroot:nonroot + +ENTRYPOINT ["/sink"] \ No newline at end of file diff --git a/e2e/sink/Makefile b/e2e/sink/Makefile new file mode 100644 index 00000000..7104214f --- /dev/null +++ b/e2e/sink/Makefile @@ -0,0 +1,117 @@ + +# Image URL to use all building/pushing image targets +IMG ?= sink:latest + +# VERIFY_IGNORE is a grep pattern to exclude files and directories from verification +VERIFY_IGNORE := /vendor\|/automock + +# FILES_TO_CHECK is a command used to determine which files should be verified +FILES_TO_CHECK = find . -type f -name "*.go" | grep -v "$(VERIFY_IGNORE)" +# DIRS_TO_CHECK is a command used to determine which directories should be verified +DIRS_TO_CHECK = go list ./... | grep -v "$(VERIFY_IGNORE)" +# DIRS_TO_IGNORE is a command used to determine which directories should not be verified +DIRS_TO_IGNORE = go list ./... | grep "$(VERIFY_IGNORE)" + +# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) +ifeq (,$(shell go env GOBIN)) +GOBIN=$(shell go env GOPATH)/bin +else +GOBIN=$(shell go env GOBIN) +endif + +# Setting SHELL to bash allows bash commands to be executed by recipes. +# Options are set to exit when a recipe line exits non-zero or a piped command fails. +SHELL = /usr/bin/env bash -o pipefail +.SHELLFLAGS = -ec + +.PHONY: all +all: build + +##@ General + +# The help target prints out all targets with their descriptions organized +# beneath their categories. The categories are represented by '##@' and the +# target descriptions by '##'. The awk commands is responsible for reading the +# entire set of makefiles included in this invocation, looking for lines of the +# file as xyz: ## something, and then pretty-format the target and help. Then, +# if there's a line with ##@ something, that gets pretty-printed as a category. +# More info on the usage of ANSI control characters for terminal formatting: +# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters +# More info on the awk command: +# http://linuxcommand.org/lc3_adv_awk.php + +.PHONY: help +help: ## Display this help. + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + + +##@ Build + +.PHONY: build +build: fmt vet + go build -o bin/sink cmd/main.go + +.PHONY: run +run: fmt vet ## Run a sink from your host. + go run ./cmd/main.go + +# If you wish built the manager image targeting other platforms you can use the --platform flag. +# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# More info: https://docs.docker.com/develop/develop-images/build_enhancements/ +.PHONY: docker-build +docker-build: ## Build docker image with the manager. + docker build -t ${IMG} . + +.PHONY: docker-push +docker-push: ## Push docker image with the manager. + docker push ${IMG} + +# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to: +# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ +# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ +# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) +# To properly provided solutions that supports more than one platform you should use this option. +PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le +.PHONY: docker-buildx +docker-buildx: ## Build and push docker image for the manager for cross-platform support + # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile + sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross + - docker buildx create --name project-v3-builder + docker buildx use project-v3-builder + - docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross . + - docker buildx rm project-v3-builder + rm Dockerfile.cross + +##@ Deployment + +ifndef ignore-not-found + ignore-not-found = false +endif + +##@ Build Dependencies + +## Location to install dependencies to +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + mkdir -p $(LOCALBIN) + +.PHONY: vet +vet: ## Run go vet against code. + go vet ./... + +.PHONY: fmt +fmt: ## Reformat files using `go fmt` + go fmt $$($(DIRS_TO_CHECK)) + +imports: ## Optimize imports + goimports -w -l $$($(FILES_TO_CHECK)) + +lint-thoroughly: + golangci-lint run + +fmt-local: ## Reformat files using `go fmt` + go fmt $$($(DIRS_TO_CHECK)) + +imports-local: ## Optimize imports + goimports -w -l $$($(FILES_TO_CHECK)) From 5fd5a9204958a609cb1c968330e14242f95cdf21 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 10:02:28 +0200 Subject: [PATCH 03/33] Don't trigger Lint and Validation for E2E Test Sink --- .github/workflows/lint.yml | 5 ++++- .github/workflows/sink.yml | 3 ++- .github/workflows/validate.yml | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4fcad9bc..c69d31ac 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,5 +1,8 @@ name: golangci-lint -on: [pull_request] +on: + pull_request: + paths-ignore: + - 'e2e/sink/**' permissions: contents: read # Optional: allow read access to pull request. Use with `only-new-issues` option. diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 66044d18..222e66eb 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -1,4 +1,5 @@ -name: E2E Tests Sink +name: Build E2E Sink + env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 5f0e9b53..6113c29b 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -3,8 +3,12 @@ name: validate on: push: branches: [ "main" ] + paths-ignore: + - 'e2e/sink/**' pull_request: branches: [ "main" ] + paths-ignore: + - 'e2e/sink/**' jobs: unit-tests: From cc9fad01475af925a77fb5157af99ae91fc61cd5 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 10:25:17 +0200 Subject: [PATCH 04/33] Improve API Name and Makefile --- e2e/sink/Makefile | 10 +++++----- e2e/sink/internal/handler/handler.go | 8 ++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/e2e/sink/Makefile b/e2e/sink/Makefile index 7104214f..bcbbcab7 100644 --- a/e2e/sink/Makefile +++ b/e2e/sink/Makefile @@ -55,18 +55,18 @@ build: fmt vet run: fmt vet ## Run a sink from your host. go run ./cmd/main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. +# If you wish built the sink image targeting other platforms you can use the --platform flag. # (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. # More info: https://docs.docker.com/develop/develop-images/build_enhancements/ .PHONY: docker-build -docker-build: ## Build docker image with the manager. +docker-build: ## Build docker image with the sink. docker build -t ${IMG} . .PHONY: docker-push -docker-push: ## Push docker image with the manager. +docker-push: ## Push docker image with the sink. docker push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# PLATFORMS defines the target platforms for the sink image be build to provide support to multiple # architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to: # - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ # - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ @@ -74,7 +74,7 @@ docker-push: ## Push docker image with the manager. # To properly provided solutions that supports more than one platform you should use this option. PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le .PHONY: docker-buildx -docker-buildx: ## Build and push docker image for the manager for cross-platform support +docker-buildx: ## Build and push docker image for the sink for cross-platform support # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross - docker buildx create --name project-v3-builder diff --git a/e2e/sink/internal/handler/handler.go b/e2e/sink/internal/handler/handler.go index b7b97ec2..89fda383 100644 --- a/e2e/sink/internal/handler/handler.go +++ b/e2e/sink/internal/handler/handler.go @@ -30,8 +30,8 @@ func NewSinkHandler(logger *zap.Logger) *SinkHandler { func (h *SinkHandler) Start() error { router := mux.NewRouter() - router.HandleFunc("/event", h.StoreEvent).Methods(http.MethodPost) - router.HandleFunc("/event/{eventID}", h.GetEvent).Methods(http.MethodGet) + router.HandleFunc("/events", h.StoreEvent).Methods(http.MethodPost) + router.HandleFunc("/events/{eventID}", h.GetEvent).Methods(http.MethodGet) return http.ListenAndServe(":8080", router) } @@ -96,10 +96,6 @@ func extractCloudEventFromRequest(r *http.Request) (*cev2event.Event, error) { return nil, err } - err = event.Validate() - if err != nil { - return nil, err - } return event, nil } From fd08ff20e8c7ce8984f2b24c27ca0cd82f86415d Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 12:08:36 +0200 Subject: [PATCH 05/33] Dummy commit to test GH Action Workflow --- e2e/sink/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e/sink/Dockerfile b/e2e/sink/Dockerfile index d2dcfb4c..676d4fae 100644 --- a/e2e/sink/Dockerfile +++ b/e2e/sink/Dockerfile @@ -4,9 +4,11 @@ ARG TARGETOS ARG TARGETARCH WORKDIR /workspace + # Copy the Go Modules manifests COPY go.mod go.mod COPY go.sum go.sum + # cache deps before building and copying source so that we don't need to re-download as much # and so that source changes don't invalidate our downloaded layer RUN go mod download From 65c179599173f8ec951b304450431a7289e3347b Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 13:38:51 +0200 Subject: [PATCH 06/33] Test gh action workflow --- .github/workflows/sink.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 222e66eb..396897df 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -12,15 +12,15 @@ on: branches: [ "main" ] tags: [ '*.*.*' ] paths: - - '${{ env.E2E_SINK_PATH }}/**' + - 'e2e/sink/**' pull_request_target: branches: [ "main" ] paths: - - '${{ env.E2E_SINK_PATH }}/**' + - 'e2e/sink/**' defaults: run: - working-directory: ${{ env.E2E_SINK_PATH }} + working-directory: e2e/sink jobs: From 85bccf4fa18db880cb6e920317eb93fb388d6161 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 13:48:50 +0200 Subject: [PATCH 07/33] Test 2 --- .github/workflows/sink.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 396897df..897e47ec 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -13,10 +13,10 @@ on: tags: [ '*.*.*' ] paths: - 'e2e/sink/**' - pull_request_target: + pull_request: branches: [ "main" ] - paths: - - 'e2e/sink/**' + # paths: + # - 'e2e/sink/**' defaults: run: From ad341274a9276c2b929e129ed4c88a4635da8d1d Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 13:55:01 +0200 Subject: [PATCH 08/33] Test 3 --- .github/workflows/sink.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 897e47ec..396897df 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -13,10 +13,10 @@ on: tags: [ '*.*.*' ] paths: - 'e2e/sink/**' - pull_request: + pull_request_target: branches: [ "main" ] - # paths: - # - 'e2e/sink/**' + paths: + - 'e2e/sink/**' defaults: run: From a8ada48f5cb63423350eb21154aa8703b4849990 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 13:55:46 +0200 Subject: [PATCH 09/33] Test 4 --- e2e/sink/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/e2e/sink/Dockerfile b/e2e/sink/Dockerfile index 676d4fae..d2dcfb4c 100644 --- a/e2e/sink/Dockerfile +++ b/e2e/sink/Dockerfile @@ -4,11 +4,9 @@ ARG TARGETOS ARG TARGETARCH WORKDIR /workspace - # Copy the Go Modules manifests COPY go.mod go.mod COPY go.sum go.sum - # cache deps before building and copying source so that we don't need to re-download as much # and so that source changes don't invalidate our downloaded layer RUN go mod download From 71ba6dd9f61eab9bd6a944c3a692b0a91e6e16d4 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 13:58:03 +0200 Subject: [PATCH 10/33] TEst 5 --- .github/workflows/sink.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 396897df..0f39283b 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -13,7 +13,7 @@ on: tags: [ '*.*.*' ] paths: - 'e2e/sink/**' - pull_request_target: + pull_request: branches: [ "main" ] paths: - 'e2e/sink/**' From 02a10654104b0789458376a3d8825c015fe664ce Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 13:58:57 +0200 Subject: [PATCH 11/33] Test 6 --- e2e/sink/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/e2e/sink/Dockerfile b/e2e/sink/Dockerfile index d2dcfb4c..676d4fae 100644 --- a/e2e/sink/Dockerfile +++ b/e2e/sink/Dockerfile @@ -4,9 +4,11 @@ ARG TARGETOS ARG TARGETARCH WORKDIR /workspace + # Copy the Go Modules manifests COPY go.mod go.mod COPY go.sum go.sum + # cache deps before building and copying source so that we don't need to re-download as much # and so that source changes don't invalidate our downloaded layer RUN go mod download From 1065cf7d5f4036fc41475faa3e6fd645d3b7e84f Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 14:00:20 +0200 Subject: [PATCH 12/33] Test not relevant changes --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index f7e313aa..eb197db9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,11 @@ ARG TARGETOS ARG TARGETARCH WORKDIR /workspace + # Copy the Go Modules manifests COPY go.mod go.mod COPY go.sum go.sum + # cache deps before building and copying source so that we don't need to re-download as much # and so that source changes don't invalidate our downloaded layer RUN go mod download From a64b13875b1748517d5a97369b882f9c8572f198 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 14:15:24 +0200 Subject: [PATCH 13/33] Move working-directory --- .github/workflows/sink.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 0f39283b..0a8a8e88 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -18,16 +18,15 @@ on: paths: - 'e2e/sink/**' -defaults: - run: - working-directory: e2e/sink - jobs: - build: runs-on: ubuntu-latest permissions: write-all + defaults: + run: + working-directory: e2e/sink + steps: - uses: actions/checkout@v3 From 6103350f7aa5ba85561d2fd6fc200125fb753a78 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 14:16:27 +0200 Subject: [PATCH 14/33] test 7 --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index eb197db9..f7e313aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,11 +4,9 @@ ARG TARGETOS ARG TARGETARCH WORKDIR /workspace - # Copy the Go Modules manifests COPY go.mod go.mod COPY go.sum go.sum - # cache deps before building and copying source so that we don't need to re-download as much # and so that source changes don't invalidate our downloaded layer RUN go mod download From 6bf5f23dc491e7355d9c44379149d2c41eb0d02f Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 14:20:55 +0200 Subject: [PATCH 15/33] Test 8 --- pkg/k8s/client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/k8s/client.go b/pkg/k8s/client.go index ee665c7c..2930be30 100644 --- a/pkg/k8s/client.go +++ b/pkg/k8s/client.go @@ -5,9 +5,8 @@ import ( "errors" "strings" - admissionv1 "k8s.io/api/admissionregistration/v1" - natsv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1" + admissionv1 "k8s.io/api/admissionregistration/v1" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" From 4f73043ed0b8bca4ade3dfcce33eecad4a4b0426 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 14:28:32 +0200 Subject: [PATCH 16/33] Improve GH Action --- .github/workflows/sink.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 0a8a8e88..30d2cdf0 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -9,14 +9,16 @@ env: on: push: - branches: [ "main" ] + branches: + - 'main' tags: [ '*.*.*' ] paths: - 'e2e/sink/**' pull_request: - branches: [ "main" ] + branches: + - 'main' paths: - - 'e2e/sink/**' + - 'e2e/sink/**' jobs: build: From 71402642605e0520a97cae10aca41ac8db05c2f2 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 14:29:22 +0200 Subject: [PATCH 17/33] Test 9 --- .github/workflows/sink.yml | 7 +++---- pkg/k8s/client.go | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 30d2cdf0..c4c804e3 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -5,20 +5,19 @@ env: REGISTRY: ghcr.io # github.repository as / IMAGE_NAME: ${{ github.repository }} - E2E_SINK_PATH: e2e/sink on: push: branches: - - 'main' + - 'main' tags: [ '*.*.*' ] paths: - 'e2e/sink/**' pull_request: branches: - - 'main' + - 'main' paths: - - 'e2e/sink/**' + - 'e2e/sink/**' jobs: build: diff --git a/pkg/k8s/client.go b/pkg/k8s/client.go index 2930be30..ee665c7c 100644 --- a/pkg/k8s/client.go +++ b/pkg/k8s/client.go @@ -5,8 +5,9 @@ import ( "errors" "strings" - natsv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1" admissionv1 "k8s.io/api/admissionregistration/v1" + + natsv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" From ec3c4ecc58c3f24bce8c366902062e2a43963c5f Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 14:32:49 +0200 Subject: [PATCH 18/33] Test 10 --- e2e/sink/internal/handler/handler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/sink/internal/handler/handler.go b/e2e/sink/internal/handler/handler.go index 89fda383..914358a7 100644 --- a/e2e/sink/internal/handler/handler.go +++ b/e2e/sink/internal/handler/handler.go @@ -12,6 +12,7 @@ import ( cev2http "github.com/cloudevents/sdk-go/v2/protocol/http" ) +// Handler interface for the SinkHandler. type Handler interface { Start() error } From 9f2912d52b09099ca7cdeafaa97bedfda83617aa Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 14:43:00 +0200 Subject: [PATCH 19/33] Improve GH Action --- .github/workflows/sink.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index c4c804e3..92e54173 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -9,15 +9,15 @@ env: on: push: branches: - - 'main' + - main tags: [ '*.*.*' ] paths: - 'e2e/sink/**' pull_request: branches: - - 'main' + - main paths: - - 'e2e/sink/**' + - 'e2e/sink/**/**' jobs: build: From ed1ca0b0e19dedebf62474709331d45b54fa5d17 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 14:46:23 +0200 Subject: [PATCH 20/33] Improve GH Action --- .github/workflows/sink.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 92e54173..0231a934 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -17,7 +17,7 @@ on: branches: - main paths: - - 'e2e/sink/**/**' + - 'e2e/sink/**' jobs: build: From 1b3cd619debf640645475e8bf7bae6393ac9f9a5 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 15:28:26 +0200 Subject: [PATCH 21/33] Improve GH Action 3 --- .github/workflows/sink.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 0231a934..033f90d9 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -1,4 +1,4 @@ -name: Build E2E Sink +name: E2E Tests Sink env: # Use docker.io for Docker Hub if empty From bb5479070b11995d94e169c489efda7513d95aa7 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 15:35:32 +0200 Subject: [PATCH 22/33] Test 11 --- pkg/k8s/client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/k8s/client.go b/pkg/k8s/client.go index ee665c7c..2930be30 100644 --- a/pkg/k8s/client.go +++ b/pkg/k8s/client.go @@ -5,9 +5,8 @@ import ( "errors" "strings" - admissionv1 "k8s.io/api/admissionregistration/v1" - natsv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1" + admissionv1 "k8s.io/api/admissionregistration/v1" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" From 938331941bca0d3d026a0689de174825e28f173d Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 15:46:05 +0200 Subject: [PATCH 23/33] delete vs code files --- e2e/sink/.vscode/launch.json | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 e2e/sink/.vscode/launch.json diff --git a/e2e/sink/.vscode/launch.json b/e2e/sink/.vscode/launch.json deleted file mode 100644 index 7f452c9a..00000000 --- a/e2e/sink/.vscode/launch.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Launch Package", - "type": "go", - "request": "launch", - "mode": "auto", - "program": "${workspaceFolder}/cmd/main.go", - } - ] -} \ No newline at end of file From f2d952c1914f0043e7bb7ca70a0735dcc80f4d14 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 15:49:38 +0200 Subject: [PATCH 24/33] Test GH Action 4 --- pkg/k8s/client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/k8s/client.go b/pkg/k8s/client.go index 2930be30..ee665c7c 100644 --- a/pkg/k8s/client.go +++ b/pkg/k8s/client.go @@ -5,8 +5,9 @@ import ( "errors" "strings" - natsv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1" admissionv1 "k8s.io/api/admissionregistration/v1" + + natsv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" From cfd5142e164e07c1a722f648504f9f485bef7c9e Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 15:51:32 +0200 Subject: [PATCH 25/33] Rename E2E Test Sink image --- .github/workflows/sink.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 033f90d9..31789caa 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -4,7 +4,7 @@ env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io # github.repository as / - IMAGE_NAME: ${{ github.repository }} + IMAGE_NAME: e2e-tests-sink on: push: From d3df5b42c5870d71288ae5905a9461e69bded2c6 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 18:21:41 +0200 Subject: [PATCH 26/33] Add workflow path and improve path --- .github/workflows/sink.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 31789caa..b6101e5b 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -4,7 +4,7 @@ env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io # github.repository as / - IMAGE_NAME: e2e-tests-sink + IMAGE_NAME: ${{ github.repository }}/e2e-tests-sink on: push: @@ -12,12 +12,14 @@ on: - main tags: [ '*.*.*' ] paths: - - 'e2e/sink/**' + - 'e2e/sink/**/*' + - .github/workflows/sink.yml pull_request: branches: - main paths: - - 'e2e/sink/**' + - 'e2e/sink/**/*' + - .github/workflows/sink.yml jobs: build: From ae8dd51f51fd2d612563122663368b53c15fa840 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 18:27:13 +0200 Subject: [PATCH 27/33] Change Image Name --- .github/workflows/sink.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index b6101e5b..76b55574 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -4,7 +4,7 @@ env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io # github.repository as / - IMAGE_NAME: ${{ github.repository }}/e2e-tests-sink + IMAGE_NAME: 'kyma-project/e2e-tests-sink' on: push: From 5e094185478ff1d0a37cd09e0c351f823ebb26b9 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 18:41:30 +0200 Subject: [PATCH 28/33] dummy change to test image push --- e2e/sink/internal/handler/handler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/sink/internal/handler/handler.go b/e2e/sink/internal/handler/handler.go index 914358a7..acff26bb 100644 --- a/e2e/sink/internal/handler/handler.go +++ b/e2e/sink/internal/handler/handler.go @@ -20,6 +20,7 @@ type Handler interface { type SinkHandler struct { logger *zap.Logger events map[string]*cev2event.Event + cache map[string]*cev2event.Event } func NewSinkHandler(logger *zap.Logger) *SinkHandler { From 7d5a30fb75b16dcc823d4b1fbf9b097c88bc23e4 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 18:45:05 +0200 Subject: [PATCH 29/33] Test outside files change --- pkg/k8s/client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/k8s/client.go b/pkg/k8s/client.go index ee665c7c..2930be30 100644 --- a/pkg/k8s/client.go +++ b/pkg/k8s/client.go @@ -5,9 +5,8 @@ import ( "errors" "strings" - admissionv1 "k8s.io/api/admissionregistration/v1" - natsv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1" + admissionv1 "k8s.io/api/admissionregistration/v1" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" From 94b009abc69c1b50dd6935ee453aa73e95b73b3b Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 18:54:09 +0200 Subject: [PATCH 30/33] set docker build working-directory --- .github/workflows/sink.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 76b55574..7048b8d2 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -75,3 +75,4 @@ jobs: load: ${{ github.event_name == 'pull_request' }} cache-from: type=gha cache-to: type=gha,mode=max + working-directory: e2e/sink From 54dbe1feb6d97444480b7a2e11db159fd0bdbb1b Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 18:59:34 +0200 Subject: [PATCH 31/33] Build only sink docker image --- .github/workflows/sink.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 7048b8d2..79270220 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -68,11 +68,10 @@ jobs: id: build-and-push uses: docker/build-push-action@v4 with: - context: . + context: e2e/sink push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} load: ${{ github.event_name == 'pull_request' }} cache-from: type=gha cache-to: type=gha,mode=max - working-directory: e2e/sink From a9a387c5f9107a0dfee3484cba5ee9c15ba184d6 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 19:14:15 +0200 Subject: [PATCH 32/33] test image push by making true --- .github/workflows/sink.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 79270220..96e1f0e5 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -69,9 +69,9 @@ jobs: uses: docker/build-push-action@v4 with: context: e2e/sink - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - load: ${{ github.event_name == 'pull_request' }} + load: true cache-from: type=gha cache-to: type=gha,mode=max From 712343fb01b3970f39edd289836eb40e39a7fee4 Mon Sep 17 00:00:00 2001 From: Mansur Uralov Date: Fri, 8 Sep 2023 19:17:49 +0200 Subject: [PATCH 33/33] Revert changes --- .github/workflows/sink.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sink.yml b/.github/workflows/sink.yml index 96e1f0e5..79270220 100644 --- a/.github/workflows/sink.yml +++ b/.github/workflows/sink.yml @@ -69,9 +69,9 @@ jobs: uses: docker/build-push-action@v4 with: context: e2e/sink - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - load: true + load: ${{ github.event_name == 'pull_request' }} cache-from: type=gha cache-to: type=gha,mode=max