diff --git a/make/generate.mk b/make/generate.mk index 10dfd847..e1334b25 100644 --- a/make/generate.mk +++ b/make/generate.mk @@ -10,6 +10,7 @@ MEMBER_CLUSTER_CRDS:=useraccounts nstemplatesets memberstatuses idlers toolchain PATH_TO_CRD_BASES=config/crd/bases +PROJECT_DIR := $(shell pwd) # openapi-gen requires the GOPATH env var be set and the codebase be present within it. # Let's not require $GOPATH be set up in the user's environment and the checkout be # placed in it. @@ -114,3 +115,12 @@ dispatch-crds: prepare-host-operator prepare-member-operator .PHONY: copy-reg-service-template copy-reg-service-template: cp ../registration-service/deploy/registration-service.yaml ../host-operator/deploy/registration-service/registration-service.yaml + + +CONTROLLER_GEN = $(PROJECT_DIR)/bin/controller-gen +controller-gen: ## Download controller-gen locally if necessary. + GOBIN=$(PROJECT_DIR)/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen + +OPENAPI_GEN = $(PROJECT_DIR)/bin/openapi-gen +openapi-gen: ## Download openapi-gen locally if necessary. + GOBIN=$(PROJECT_DIR)/bin go install k8s.io/kube-openapi/cmd/openapi-gen diff --git a/make/get-tool.mk b/make/get-tool.mk deleted file mode 100644 index e3fe11d8..00000000 --- a/make/get-tool.mk +++ /dev/null @@ -1,31 +0,0 @@ -# see go.mod -CONTROLLER_GEN_VERSION=v0.10.0 -OPENAPI_GEN_VERSION=67bda5d908f1 - -CONTROLLER_GEN = $(shell pwd)/bin/controller-gen -controller-gen: ## Download controller-gen locally if necessary. - $(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,${CONTROLLER_GEN_VERSION}) - -OPENAPI_GEN = $(shell pwd)/bin/openapi-gen -openapi-gen: ## Download openapi-gen locally if necessary. - $(call go-get-tool,$(OPENAPI_GEN),k8s.io/kube-openapi/cmd/openapi-gen,${OPENAPI_GEN_VERSION}) - -# go-get-tool will 'go get' any package $2 with version $3 and install it to $1. -PROJECT_DIR := $(shell pwd) -VERSIONS_FILE := $(PROJECT_DIR)/bin/version - -define go-get-tool -@if [[ ! -f ${1} ]] || [[ ! -f ${VERSIONS_FILE} ]] || [[ -z $$(grep ${2} ${VERSIONS_FILE} | grep '${3}$$') ]]; then \ - set -e ;\ - TMP_DIR=$$(mktemp -d) ;\ - cd $${TMP_DIR} ;\ - go mod init tmp ;\ - echo "Downloading ${2}" ;\ - GOBIN=$(PROJECT_DIR)/bin go install ${2}@${3} ;\ - touch ${VERSIONS_FILE} ;\ - sed '\|${2}|d' ${VERSIONS_FILE} > $${TMP_DIR}/versions ;\ - mv $${TMP_DIR}/versions ${VERSIONS_FILE} ;\ - echo "${2} ${3}" >> ${VERSIONS_FILE} ;\ - rm -rf $$TMP_DIR ;\ -fi -endef