From 78e66a16baba96d18046fe8250887d6e233341b2 Mon Sep 17 00:00:00 2001 From: Jerad C Date: Fri, 15 Apr 2022 08:01:03 -0500 Subject: [PATCH 1/2] generate kodata symlinks --- src/.gitignore | 2 ++ src/Makefile | 12 ++++++++++-- src/cmd/controller/kodata/HEAD | 1 - src/cmd/controller/kodata/refs | 1 - src/cmd/webhook/kodata/HEAD | 1 - src/cmd/webhook/kodata/refs | 1 - 6 files changed, 12 insertions(+), 6 deletions(-) delete mode 120000 src/cmd/controller/kodata/HEAD delete mode 120000 src/cmd/controller/kodata/refs delete mode 120000 src/cmd/webhook/kodata/HEAD delete mode 120000 src/cmd/webhook/kodata/refs diff --git a/src/.gitignore b/src/.gitignore index c0a7a54c..79f1eb0d 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -23,3 +23,5 @@ testbin/* *.swp *.swo *~ +cmd/**/kodata/ + diff --git a/src/Makefile b/src/Makefile index 120c15f5..1a4a453d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,7 +4,11 @@ KO = $(PROJECT_DIR)/bin/ko ENVTEST = $(PROJECT_DIR)/bin/setup-envtest HELM_BASE_OPTS ?= --set serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn=${NTHV2_IAM_ROLE_ARN} GINKGO_BASE_OPTS ?= --coverpkg $(shell head -n 1 $(PROJECT_DIR)/go.mod | cut -s -d ' ' -f 2)/pkg/... - +KODATA = \ + cmd/controller/kodata/HEAD \ + cmd/controller/kodata/refs \ + cmd/webhook/kodata/HEAD \ + cmd/webhook/kodata/refs # Image URL to use all building/pushing image targets IMG ?= controller:latest @@ -69,8 +73,12 @@ run: ## Run a controller from your host. ##@ Deployment +$(KODATA): + mkdir -p $(@D) + cd $(@D) && ln -s `git rev-parse --git-path $(@F)` $(@F) + .PHONY: apply -apply: ## Deploy the controller into the current kubernetes cluster. +apply: $(KODATA) ## Deploy the controller into the current kubernetes cluster. helm upgrade --install dev charts/aws-node-termination-handler-2 --namespace nthv2 --create-namespace \ $(HELM_BASE_OPTS) \ $(HELM_OPTS) \ diff --git a/src/cmd/controller/kodata/HEAD b/src/cmd/controller/kodata/HEAD deleted file mode 120000 index 481bd4ef..00000000 --- a/src/cmd/controller/kodata/HEAD +++ /dev/null @@ -1 +0,0 @@ -../../../../.git/HEAD \ No newline at end of file diff --git a/src/cmd/controller/kodata/refs b/src/cmd/controller/kodata/refs deleted file mode 120000 index fe164fe4..00000000 --- a/src/cmd/controller/kodata/refs +++ /dev/null @@ -1 +0,0 @@ -../../../../.git/refs \ No newline at end of file diff --git a/src/cmd/webhook/kodata/HEAD b/src/cmd/webhook/kodata/HEAD deleted file mode 120000 index 481bd4ef..00000000 --- a/src/cmd/webhook/kodata/HEAD +++ /dev/null @@ -1 +0,0 @@ -../../../../.git/HEAD \ No newline at end of file diff --git a/src/cmd/webhook/kodata/refs b/src/cmd/webhook/kodata/refs deleted file mode 120000 index fe164fe4..00000000 --- a/src/cmd/webhook/kodata/refs +++ /dev/null @@ -1 +0,0 @@ -../../../../.git/refs \ No newline at end of file From 053e2a88624d9cdb82bbd0d004c228327cb3603a Mon Sep 17 00:00:00 2001 From: Jerad C Date: Fri, 15 Apr 2022 08:04:38 -0500 Subject: [PATCH 2/2] download toolchain if not present --- BUILD.md | 6 ------ src/Makefile | 11 +++++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/BUILD.md b/BUILD.md index 55374f49..d35a96b2 100644 --- a/BUILD.md +++ b/BUILD.md @@ -7,12 +7,6 @@ git clone --branch v2 https://github.com/aws/aws-node-termination-handler.git cd aws-node-termination-handler ``` -## Install build tools - -```sh -make toolchain -``` - ## Set environment variables ```sh diff --git a/src/Makefile b/src/Makefile index 1a4a453d..3d2abb79 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,6 +2,10 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) CONTROLLER_GEN = $(PROJECT_DIR)/bin/controller-gen KO = $(PROJECT_DIR)/bin/ko ENVTEST = $(PROJECT_DIR)/bin/setup-envtest +TOOLCHAIN = \ + $(CONTROLLER_GEN) \ + $(KO) \ + $(ENVTEST) HELM_BASE_OPTS ?= --set serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn=${NTHV2_IAM_ROLE_ARN} GINKGO_BASE_OPTS ?= --coverpkg $(shell head -n 1 $(PROJECT_DIR)/go.mod | cut -s -d ' ' -f 2)/pkg/... KODATA = \ @@ -45,14 +49,13 @@ SHELL = /usr/bin/env bash -o pipefail 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) -.PHONY: toolchain -toolchain: ## Download additional tools. +$(TOOLCHAIN) &: @./scripts/toolchain.sh -d "$(PROJECT_DIR)/bin" ##@ Development .PHONY: generate -generate: ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. +generate: $(CONTROLLER_GEN) ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." .PHONY: verify @@ -78,7 +81,7 @@ $(KODATA): cd $(@D) && ln -s `git rev-parse --git-path $(@F)` $(@F) .PHONY: apply -apply: $(KODATA) ## Deploy the controller into the current kubernetes cluster. +apply: $(KO) $(KODATA) ## Deploy the controller into the current kubernetes cluster. helm upgrade --install dev charts/aws-node-termination-handler-2 --namespace nthv2 --create-namespace \ $(HELM_BASE_OPTS) \ $(HELM_OPTS) \