From bb1a7dbe864ebbdb28203adc837da999ad75767a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Valais?= Date: Mon, 9 Oct 2023 17:44:33 +0200 Subject: [PATCH] make: re-add targets since they are used in the "sample" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maƫl Valais --- Makefile | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/Makefile b/Makefile index 25b434c..c599daa 100644 --- a/Makefile +++ b/Makefile @@ -165,6 +165,74 @@ test: test-unit-deps | $(NEEDS_GO) $(NEEDS_GOTESTSUM) ## Run unit tests. test-e2e: test-e2e-deps | $(NEEDS_GOTESTSUM) ## Run e2e tests. This creates a Kind cluster, installs dependencies, deploys the issuer-lib and runs the E2E tests. $(GOTESTSUM) ./internal/testsetups/simple/e2e/... -coverprofile cover.out -timeout 1m +##@ Build + +.PHONY: build +build: generate | $(NEEDS_GO) ## Build manager binary. + $(GOBUILD) -o bin/manager main.go + +.PHONY: run +ARGS ?= # default empty +run: generate | $(NEEDS_GO) ## Run a controller from your host. + $(GO) run ./main.go $(ARGS) + +# Defaults to false to prevent ko from pushing the Docker image to DOCKER_REGISTRY. +# Overridden to true by docker-push. +ko_push = false + +# docker-build can both build the Docker image and push it to a DOCKER_REGISTRY +# depending on the value of ko_push. +# It can also create a local tar archive of the Docker image, but not when +# building multi-arch images. +# ko will automatically upload the Docker image to a Kind cluster when +# DOCKER_REGISTRY=kind.local, as set in test-e2e. +.PHONY: docker-build +docker-build: ## Build the docker image. +docker-build: | $(NEEDS_KO) + KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) \ + KO_DOCKER_REPO=$(DOCKER_REGISTRY) \ + KOCACHE=$(KOCACHE) \ + $(KO) build github.com/cert-manager/issuer-lib/internal/testsetups/simple/cmd/ \ + --platform=$(DOCKER_IMAGE_PLATFORMS) \ + $(if $(DOCKER_IMAGE_PLATFORMS),,--tarball=$(DOCKER_IMAGE_TAR)) \ + --tags=$(DOCKER_TAG) \ + --push=$(ko_push) \ + --base-import-paths + +.PHONY: docker-push +docker-push: ## Push docker image with the manager. +docker-push: ko_push = true +docker-push: docker-build + +##@ Deployment + +ifndef ignore-not-found + ignore-not-found = false +endif + +$(BINDIR)/scratch/yaml/kustomization.yaml: FORCE | $(NEEDS_KUSTOMIZE) + rm -rf $(BINDIR)/scratch/yaml + mkdir -p $(BINDIR)/scratch/yaml + + cd $(BINDIR)/scratch/yaml; \ + $(KUSTOMIZE) create \ + --namespace "my-namespace" \ + --nameprefix "simple-issuer-" \ + --resources ../../../internal/testsetups/simple/deploy/static/ + + cd $(BINDIR)/scratch/yaml; \ + $(KUSTOMIZE) edit set image "controller:latest=$(DOCKER_REGISTRY)/cmd:$(DOCKER_TAG)" + +.PHONY: install +install: generate-manifests $(BINDIR)/scratch/yaml/kustomization.yaml | $(NEEDS_KUBECTL) $(NEEDS_YQ) ## Install CRDs into the K8s cluster specified in ~/.kube/config. + $(KUBECTL) apply -f internal/testsetups/simple/deploy/crds + $(KUBECTL) apply -f internal/testsetups/simple/deploy/rbac + $(KUBECTL) apply -k $(BINDIR)/scratch/yaml/ + +.PHONY: uninstall +uninstall: generate-manifests | $(NEEDS_KUBECTL) ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. + $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f internal/testsetups/simple/deploy/crds + TEMP_DIR := _tmp .PHONY: clean clean: