Skip to content

Commit

Permalink
specify envtest branch according to controller-runtime version
Browse files Browse the repository at this point in the history
Signed-off-by: Yuji Ito <llamerada.jp@gmail.com>
  • Loading branch information
llamerada-jp committed Apr 23, 2024
1 parent 77de94a commit febc867
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion admission/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ GRAFANA_OPERATOR_V4_VERSION = 4.10.1
GRAFANA_OPERATOR_VERSION = 5.8.1
ENVTEST_K8S_VERSION = 1.27.1

# Specify envtest branch according to controller-runtime version
CONTROLLER_RUNTIME_VERSION := $(shell awk '/sigs\.k8s\.io\/controller-runtime/ {print substr($$2, 2)}' go.mod)
ENVTEST_BRANCH := release-$(shell echo $(CONTROLLER_RUNTIME_VERSION) | cut -d "." -f 1-2)

# Set the shell used to bash for better error handling.
SHELL = /bin/bash
.SHELLFLAGS = -e -o pipefail -c
Expand Down Expand Up @@ -79,7 +83,7 @@ kustomize:
SETUP_ENVTEST = $(PROJECT_DIR)/bin/setup-envtest
.PHONY: setup-envtest
setup-envtest:
$(call go-install-tool,$(SETUP_ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
$(call go-install-tool,$(SETUP_ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@$(ENVTEST_BRANCH))

# Download staticcheck locally if necessary
STATICCHECK = $(PROJECT_DIR)/bin/staticcheck
Expand Down
8 changes: 7 additions & 1 deletion local-pv-provisioner/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# Makefile for local-pv-provisioner

# Image version
IMAGE_VERSION = `cat ./TAG`
IMAGE_TAG = ghcr.io/cybozu/local-pv-provisioner:$(IMAGE_VERSION)

CONTROLLER_TOOLS_VERSION = 0.13.0
ENVTEST_K8S_VERSION = 1.28.3

# Specify envtest branch according to controller-runtime version
CONTROLLER_RUNTIME_VERSION := $(shell awk '/sigs\.k8s\.io\/controller-runtime/ {print substr($$2, 2)}' go.mod)
ENVTEST_BRANCH := release-$(shell echo $(CONTROLLER_RUNTIME_VERSION) | cut -d "." -f 1-2)

# Set the shell used to bash for better error handling.
SHELL = /bin/bash
.SHELLFLAGS = -e -o pipefail -c
Expand Down Expand Up @@ -58,7 +64,7 @@ controller-gen:
SETUP_ENVTEST = $(CURDIR)/bin/setup-envtest
.PHONY: setup-envtest
setup-envtest:
$(call go-install-tool,$(SETUP_ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
$(call go-install-tool,$(SETUP_ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@$(ENVTEST_BRANCH))

.PHONY: docker
docker: build
Expand Down
6 changes: 5 additions & 1 deletion pod-delete-rate-limiter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.27.1

# Specify envtest branch according to controller-runtime version
CONTROLLER_RUNTIME_VERSION := $(shell awk '/sigs\.k8s\.io\/controller-runtime/ {print substr($$2, 2)}' go.mod)
ENVTEST_BRANCH := release-$(shell echo $(CONTROLLER_RUNTIME_VERSION) | cut -d "." -f 1-2)

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand Down Expand Up @@ -160,4 +164,4 @@ $(CONTROLLER_GEN): $(LOCALBIN)
.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$(ENVTEST_BRANCH)

0 comments on commit febc867

Please sign in to comment.