Skip to content

Commit

Permalink
refactor: makefile targets (kyverno#142)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly authored Oct 25, 2024
1 parent 6096cc5 commit aefe4d8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ko-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
REGISTRY=ghcr.io \
REGISTRY_USERNAME=${{ github.actor }} \
REGISTRY_PASSWORD=${{ secrets.GITHUB_TOKEN }} \
make publish-ko
make ko-publish
17 changes: 0 additions & 17 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
42 changes: 17 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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)

########
Expand Down
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"os"

"github.com/kyverno/kyverno-envoy-plugin/pkg/commands/root"
Expand All @@ -10,7 +9,6 @@ import (
func main() {
root := root.Command()
if err := root.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

0 comments on commit aefe4d8

Please sign in to comment.