-
-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update makefile and various tooling dependencies (#1102)
* update controller-gen to fix make manifests, update Makefile Signed-off-by: Nash Luffman <[email protected]> * update envtest version Signed-off-by: Nash Luffman <[email protected]> * fix path Signed-off-by: Nash Luffman <[email protected]> * add kind as dependency Signed-off-by: Nash Luffman <[email protected]> --------- Signed-off-by: Nash Luffman <[email protected]>
- Loading branch information
Showing
9 changed files
with
17,129 additions
and
18,213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
VERSION ?= 0.18.0 | ||
# Default bundle image tag | ||
BUNDLE_IMG ?= controller-bundle:$(VERSION) | ||
# Kubernetes version to use for envtest | ||
ENVTEST_K8S_VERSION=1.31.0 | ||
|
||
# Options for 'bundle-build' | ||
ifneq ($(origin CHANNELS), undefined) | ||
BUNDLE_CHANNELS := --channels=$(CHANNELS) | ||
|
@@ -13,8 +16,6 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) | |
|
||
# Image URL to use all building/pushing image targets | ||
IMG ?= quay.io/opstree/redis-operator:v$(VERSION) | ||
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) | ||
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false" | ||
|
||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) | ||
ifeq (,$(shell go env GOBIN)) | ||
|
@@ -28,11 +29,9 @@ CONTAINER_ENGINE ?= docker | |
all: manager | ||
|
||
# Run tests | ||
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin | ||
test: generate fmt vet manifests | ||
mkdir -p ${ENVTEST_ASSETS_DIR} | ||
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.0/hack/setup-envtest.sh | ||
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; ENVTEST_K8S_VERSION=1.24.1 fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out | ||
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out | ||
|
||
|
||
# Build manager binary | ||
manager: generate fmt vet | ||
|
@@ -61,7 +60,7 @@ undeploy: | |
|
||
# Generate manifests e.g. CRD, RBAC etc. | ||
manifests: controller-gen | ||
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
$(CONTROLLER_GEN) crd rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
|
||
# Run go fmt against code | ||
fmt: | ||
|
@@ -86,27 +85,18 @@ docker-build: | |
docker-push: | ||
${CONTAINER_ENGINE} buildx build --push --platform="linux/arm64,linux/amd64" -t ${IMG} . | ||
|
||
# Download controller-gen locally if necessary | ||
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen | ||
controller-gen: | ||
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected]) | ||
|
||
# Download kustomize locally if necessary | ||
KUSTOMIZE = $(shell pwd)/bin/kustomize | ||
kustomize: | ||
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected]) | ||
|
||
# go-install-tool will 'go install' any package $2 and install it to $1. | ||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist | ||
# $1 - target path with name of binary (ideally with version) | ||
# $2 - package url which can be installed | ||
# $3 - specific version of package | ||
define go-install-tool | ||
@[ -f $(1) ] || { \ | ||
set -e ;\ | ||
TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
echo "Downloading $(2)" ;\ | ||
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\ | ||
rm -rf $$TMP_DIR ;\ | ||
set -e; \ | ||
package=$(2)@$(3) ;\ | ||
echo "Downloading $${package}" ;\ | ||
GOBIN=$(LOCALBIN) go install $${package} ;\ | ||
mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\ | ||
} | ||
endef | ||
|
||
|
@@ -151,22 +141,76 @@ unit-tests: | |
@go tool cover -html=coverage.out | ||
|
||
.PHONY: e2e-test | ||
e2e-test: e2e-kind-setup install-kuttl | ||
$(shell pwd)/bin/kuttl test --config tests/_config/kuttl-test.yaml | ||
e2e-test: e2e-kind-setup kuttl | ||
$(LOCALBIN)/kuttl test --config tests/_config/kuttl-test.yaml | ||
|
||
.PHONY: integration-test-setup | ||
integration-test-setup: | ||
./hack/integrationSetup.sh | ||
|
||
|
||
.PHONY: install-kuttl | ||
install-kuttl: | ||
curl -L https://github.com/kudobuilder/kuttl/releases/download/v0.15.0/kubectl-kuttl_0.15.0_linux_x86_64 -o $(shell pwd)/bin/kuttl | ||
chmod +x $(shell pwd)/bin/kuttl | ||
|
||
.PHONY: e2e-kind-setup | ||
e2e-kind-setup: | ||
${CONTAINER_ENGINE} build -t redis-operator:e2e -f Dockerfile . | ||
kind create cluster --config tests/_config/kind-config.yaml | ||
kind load docker-image redis-operator:e2e --name kind | ||
$(KIND) create cluster --config tests/_config/kind-config.yaml | ||
$(KIND) load docker-image redis-operator:e2e --name kind | ||
make deploy IMG=redis-operator:e2e | ||
|
||
|
||
##@ Dependencies | ||
|
||
## Location to install dependencies to | ||
LOCALBIN ?= $(shell pwd)/bin | ||
$(LOCALBIN): | ||
mkdir -p $(LOCALBIN) | ||
|
||
## Tool Binaries | ||
KUBECTL ?= kubectl | ||
KUSTOMIZE ?= $(LOCALBIN)/kustomize-$(KUSTOMIZE_VERSION) | ||
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION) | ||
ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION) | ||
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) | ||
KUTTL=$(LOCALBIN)/kuttl-$(KUTTL_VERSION) | ||
KIND=$(LOCALBIN)/kind-$(KIND_VERSION) | ||
|
||
## Tool Versions | ||
KUSTOMIZE_VERSION ?= v5.3.0 | ||
CONTROLLER_TOOLS_VERSION ?= v0.14.0 | ||
ENVTEST_VERSION ?= release-0.17 | ||
GOLANGCI_LINT_VERSION ?= v1.57.2 | ||
KUTTL_VERSION ?= 0.15.0 | ||
KIND_VERSION ?= v0.24.0 | ||
|
||
|
||
.PHONY: kustomize | ||
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. | ||
$(KUSTOMIZE): $(LOCALBIN) | ||
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION)) | ||
|
||
.PHONY: controller-gen | ||
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. | ||
$(CONTROLLER_GEN): $(LOCALBIN) | ||
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION)) | ||
|
||
.PHONY: envtest | ||
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary. | ||
$(ENVTEST): $(LOCALBIN) | ||
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION)) | ||
|
||
.PHONY: golangci-lint | ||
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. | ||
$(GOLANGCI_LINT): $(LOCALBIN) | ||
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,${GOLANGCI_LINT_VERSION}) | ||
|
||
.PHONY: kind | ||
kind: $(KIND) ## Download golangci-lint locally if necessary. | ||
$(KIND): $(LOCALBIN) | ||
$(call go-install-tool,$(KIND),sigs.k8s.io/kind,${KIND_VERSION}) | ||
|
||
|
||
|
||
.PHONY: kuttl | ||
kuttl: $(KUTTL) ## Download kuttl locally if necessary. | ||
$(KUTTL): $(LOCALBIN) | ||
curl -L https://github.com/kudobuilder/kuttl/releases/download/v$(KUTTL_VERSION)/kubectl-kuttl_$(KUTTL_VERSION)_linux_x86_64 -o $(LOCALBIN)/kuttl | ||
chmod +x $(LOCALBIN)/kuttl |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.