Skip to content

Commit d4a969f

Browse files
skyerusAlexsJones
andauthored
Upgrade Makefile to use go install. (#78)
Signed-off-by: Skye Gill <[email protected]> Signed-off-by: Skye Gill <[email protected]> Co-authored-by: Alex Jones <[email protected]>
1 parent 38b26af commit d4a969f

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

Makefile

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Image URL to use all building/pushing image targets
33
IMG ?= controller:latest
44
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5-
FLAGD_VERSION=v0.0.7
5+
FLAGD_VERSION=v0.0.9
66
ENVTEST_K8S_VERSION = 1.23
77

88
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
@@ -109,31 +109,34 @@ deploy: generate manifests kustomize ## Deploy controller to the K8s cluster spe
109109
undeploy: generate ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
110110
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
111111

112-
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
113-
.PHONY: controller-gen
114-
controller-gen: ## Download controller-gen locally if necessary.
115-
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])
112+
##@ Build Dependencies
113+
114+
## Location to install dependencies to
115+
LOCALBIN ?= $(shell pwd)/bin
116+
$(LOCALBIN):
117+
mkdir -p $(LOCALBIN)
118+
119+
## Tool Binaries
120+
KUSTOMIZE ?= $(LOCALBIN)/kustomize
121+
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
122+
ENVTEST ?= $(LOCALBIN)/setup-envtest
116123

117-
KUSTOMIZE = $(shell pwd)/bin/kustomize
124+
## Tool Versions
125+
KUSTOMIZE_VERSION ?= v4.5.7
126+
CONTROLLER_TOOLS_VERSION ?= v0.8.0
127+
128+
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
118129
.PHONY: kustomize
119-
kustomize: ## Download kustomize locally if necessary.
120-
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])
130+
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
131+
$(KUSTOMIZE): $(LOCALBIN)
132+
curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN)
133+
134+
.PHONY: controller-gen
135+
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
136+
$(CONTROLLER_GEN): $(LOCALBIN)
137+
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
121138

122-
ENVTEST = $(shell pwd)/bin/setup-envtest
123139
.PHONY: envtest
124-
envtest: ## Download envtest-setup locally if necessary.
125-
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
126-
127-
# go-get-tool will 'go get' any package $2 and install it to $1.
128-
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
129-
define go-get-tool
130-
@[ -f $(1) ] || { \
131-
set -e ;\
132-
TMP_DIR=$$(mktemp -d) ;\
133-
cd $$TMP_DIR ;\
134-
go mod init tmp ;\
135-
echo "Downloading $(2)" ;\
136-
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
137-
rm -rf $$TMP_DIR ;\
138-
}
139-
endef
140+
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
141+
$(ENVTEST): $(LOCALBIN)
142+
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ root@nginx:/# curl -X POST localhost:8013/flags/foo/resolve/string
9191

9292
#### Run the example
9393

94-
1. Apply the end-to-end example: `kubectl apply -f config/samples/end-to-end.yaml`
94+
1. Apply the end-to-end example: `kubectl -n open-feature-operator-system apply -f config/samples/end-to-end.yaml`
9595
1. Visit `http://localhost:30000/`
9696
1. Update the value of the `defaultVariant` field in the custom resource instance in `config/samples/end-to-end.yaml` and re-apply to update the flag value!
9797
1. Visit `http://localhost:30000/` and see the change!

0 commit comments

Comments
 (0)