From aefe4d8d3c4d7b06aab3179c8e1d963baad9087a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Fri, 25 Oct 2024 16:36:09 +0200 Subject: [PATCH] refactor: makefile targets (#142) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- .github/workflows/ko-publish.yaml | 2 +- .github/workflows/tests.yaml | 17 ------------- Makefile | 42 +++++++++++++------------------ main.go | 2 -- 4 files changed, 18 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ko-publish.yaml b/.github/workflows/ko-publish.yaml index fd8db95..aadc9e8 100644 --- a/.github/workflows/ko-publish.yaml +++ b/.github/workflows/ko-publish.yaml @@ -29,4 +29,4 @@ jobs: REGISTRY=ghcr.io \ REGISTRY_USERNAME=${{ github.actor }} \ REGISTRY_PASSWORD=${{ secrets.GITHUB_TOKEN }} \ - make publish-ko + make ko-publish diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index af1f193..9422036 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -59,23 +59,6 @@ jobs: # env: # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - istio-tests: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Setup Go - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 - with: - go-version-file: go.mod - cache-dependency-path: go.sum - - name: Run tests - run: | - set -e - make kind-create-cluster - make install-istio - make kind-load-image - e2e-tests-chainsaw: runs-on: ubuntu-latest steps: diff --git a/Makefile b/Makefile index 14152f9..0cb7d9b 100644 --- a/Makefile +++ b/Makefile @@ -132,20 +132,20 @@ build: ko-login: $(KO) @$(KO) login $(REGISTRY) --username $(REGISTRY_USERNAME) --password $(REGISTRY_PASSWORD) -.PHONY: build-ko -build-ko: ## Build Docker image with ko -build-ko: fmt -build-ko: vet -build-ko: $(KO) +.PHONY: ko-build +ko-build: ## Build Docker image with ko +ko-build: fmt +ko-build: vet +ko-build: $(KO) @echo "Build Docker image with ko..." >&2 @LD_FLAGS=$(LD_FLAGS) KO_DOCKER_REPO=$(KO_REGISTRY) $(KO) build . --preserve-import-paths --tags=$(KO_TAGS) -.PHONY: publish-ko -publish-ko: ## Publish Docker image with ko -publish-ko: fmt -publish-ko: vet -publish-ko: ko-login -publish-ko: $(KO) +.PHONY: ko-publish +ko-publish: ## Publish Docker image with ko +ko-publish: fmt +ko-publish: vet +ko-publish: ko-login +ko-publish: $(KO) @echo "Publish Docker image with ko..." >&2 @LD_FLAGS=$(LD_FLAGS) KO_DOCKER_REPO=$(REGISTRY)/$(REPO)/$(IMAGE) $(KO) build . --bare --tags=$(KO_TAGS) --platform=$(KO_PLATFORMS) @@ -184,25 +184,17 @@ kind-create-cluster: $(KIND) .PHONY: kind-load-image kind-load-image: ## Build image and load it in kind cluster kind-load-image: $(KIND) -kind-load-image: build-ko +kind-load-image: ko-build @echo Load image in kind... >&2 @$(KIND) load docker-image $(KO_REGISTRY)/$(PACKAGE):$(GIT_SHA) -.PHONY: kind-load-taged-image -kind-load-taged-image: ## Build image and load it in kind cluster -kind-load-taged-image: $(KIND) -kind-load-taged-image: build-ko - @echo Load image in kind... >&2 - docker tag $(KO_REGISTRY)/$(PACKAGE):$(GIT_SHA) $(KO_REGISTRY)/$(PACKAGE):latest - @$(KIND) load docker-image $(KO_REGISTRY)/$(PACKAGE):latest - ######### # ISTIO # ######### -.PHONY: install-istio -install-istio: ## Install ISTIO -install-istio: $(HELM) +.PHONY: istio-install +istio-install: ## Install ISTIO +istio-install: $(HELM) @echo Install istio... >&2 @$(HELM) upgrade --install istio-base --namespace istio-system --create-namespace --wait --repo https://istio-release.storage.googleapis.com/charts base @$(HELM) upgrade --install istiod --namespace istio-system --create-namespace --wait --repo https://istio-release.storage.googleapis.com/charts istiod @@ -217,8 +209,8 @@ chart-install: kind-load-image chart-install: $(HELM) @echo Install helm chart... >&2 @$(HELM) upgrade --install kyverno-envoy-plugin --namespace kyverno --create-namespace --wait ./charts/kyverno-envoy-plugin \ - --set sidecarInjector.containers.injector.image.registry=ko.local \ - --set sidecarInjector.containers.injector.image.repository=github.com/kyverno/kyverno-envoy-plugin \ + --set sidecarInjector.containers.injector.image.registry=$(KO_REGISTRY) \ + --set sidecarInjector.containers.injector.image.repository=$(PACKAGE) \ --set sidecarInjector.containers.injector.image.tag=$(GIT_SHA) ######## diff --git a/main.go b/main.go index 5ae35dd..b008383 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" "github.com/kyverno/kyverno-envoy-plugin/pkg/commands/root" @@ -10,7 +9,6 @@ import ( func main() { root := root.Command() if err := root.Execute(); err != nil { - fmt.Println(err) os.Exit(1) } }