-
Notifications
You must be signed in to change notification settings - Fork 100
THREESCALE-12323 Upgrade operator envtest and controller-runtime used in CI #1141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
urbanikb
wants to merge
3
commits into
3scale:master
Choose a base branch
from
urbanikb:THREESCALE-12323
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -94,7 +94,4 @@ _output | |
| *.swo | ||
| *~ | ||
|
|
||
| # controller-runtime testenv binaries | ||
| testbin/* | ||
|
|
||
| 3scale-operator | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -82,12 +82,9 @@ test-manifests-version: | |
| # Run e2e tests | ||
| TEST_E2E_PKGS_APPS = $(shell $(GO) list ./... | grep 'github.com/3scale/3scale-operator/controllers/apps') | ||
| TEST_E2E_PKGS_CAPABILITIES = $(shell $(GO) list ./... | grep 'github.com/3scale/3scale-operator/controllers/capabilities') | ||
| ENVTEST_ASSETS_DIR=$(PROJECT_PATH)/testbin | ||
| test-e2e: 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.8.0/hack/setup-envtest.sh | ||
| source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); USE_EXISTING_CLUSTER=true $(GO) test $(TEST_E2E_PKGS_APPS) -coverprofile cover.out -ginkgo.v -v -timeout 0 | ||
| source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); USE_EXISTING_CLUSTER=true $(GO) test $(TEST_E2E_PKGS_CAPABILITIES) -coverprofile cover.out -v -timeout 0 | ||
| test-e2e: generate fmt vet manifests setup-envtest | ||
| KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" USE_EXISTING_CLUSTER=true $(GO) test $(TEST_E2E_PKGS_APPS) -coverprofile cover.out -ginkgo.v -v -timeout 0 | ||
| KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" USE_EXISTING_CLUSTER=true $(GO) test $(TEST_E2E_PKGS_CAPABILITIES) -coverprofile cover.out -v -timeout 0 | ||
|
|
||
|
|
||
| # Build manager binary | ||
|
|
@@ -102,14 +99,13 @@ run: generate fmt vet manifests | |
| @-oc process THREESCALE_VERSION=$(THREESCALE_VERSION) -f config/requirements/operator-requirements.yaml | oc apply -f - -n $(WATCH_NAMESPACE) | ||
| $(GO) run ./main.go --zap-devel | ||
|
|
||
| # find or download controller-gen | ||
| # download controller-gen if necessary | ||
| CONTROLLER_GEN=$(PROJECT_PATH)/bin/controller-gen | ||
| $(CONTROLLER_GEN): | ||
| $(call go-bin-install,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0) | ||
| CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen | ||
| CONTROLLER_TOOLS_VERSION ?= v0.16.5 | ||
|
|
||
| .PHONY: controller-gen | ||
| controller-gen: $(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: cluster/prepare/local | ||
| cluster/prepare/local: kustomize cluster/prepare/project install cluster/create/system-redis cluster/create/backend-redis cluster/create/provision-database | ||
|
|
@@ -160,6 +156,46 @@ $(KUSTOMIZE): | |
| .PHONY: kustomize | ||
| kustomize: $(KUSTOMIZE) | ||
|
|
||
| ## Location to install dependencies to | ||
| LOCALBIN ?= $(PROJECT_PATH)/bin | ||
| $(LOCALBIN): | ||
| mkdir -p $(LOCALBIN) | ||
|
|
||
| ENVTEST ?= $(LOCALBIN)/setup-envtest | ||
| #ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20) | ||
| ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}') | ||
| #ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31) | ||
| ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}') | ||
|
|
||
| .PHONY: setup-envtest | ||
| setup-envtest: envtest ## Download the binaries required for ENVTEST in the local bin directory. | ||
| @echo "Setting up envtest binaries for Kubernetes version $(ENVTEST_K8S_VERSION)..." | ||
| @$(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path || { \ | ||
| echo "Error: Failed to set up envtest binaries for version $(ENVTEST_K8S_VERSION)."; \ | ||
| exit 1; \ | ||
| } | ||
|
|
||
| .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)) | ||
|
|
||
| # 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 | ||
| # $2 - package url which can be installed | ||
| # $3 - specific version of package | ||
| define go-install-tool | ||
| @[ -f "$(1)-$(3)" ] || { \ | ||
| set -e; \ | ||
| package=$(2)@$(3) ;\ | ||
| echo "Downloading $${package}" ;\ | ||
| rm -f $(1) || true ;\ | ||
| GOBIN=$(LOCALBIN) go install $${package} ;\ | ||
| mv $(1) $(1)-$(3) ;\ | ||
| } ;\ | ||
| ln -sf $(1)-$(3) $(1) | ||
| endef | ||
|
Comment on lines
+183
to
+197
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get rid of |
||
|
|
||
| OPERATOR_SDK = $(PROJECT_PATH)/bin/operator-sdk | ||
| # Note: release file patterns changed after v1.2.0 | ||
| # More info https://sdk.operatorframework.io/docs/installation/ | ||
|
|
@@ -192,7 +228,7 @@ deploy: manifests $(KUSTOMIZE) | |
| $(KUSTOMIZE) build config/default | $(KUBECTL) apply -f - | ||
|
|
||
| # Generate manifests e.g. CRD, RBAC etc. | ||
| manifests: $(CONTROLLER_GEN) | ||
| manifests: controller-gen | ||
| $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
|
|
||
| # Run go fmt against code | ||
|
|
@@ -216,7 +252,7 @@ lint: $(GOLANGCI-LINT) ## Run lint tests | |
| $(GOLANGCI-LINT) run | ||
|
|
||
| # Generate code | ||
| generate: $(CONTROLLER_GEN) $(GO_BINDATA) | ||
| generate: controller-gen $(GO_BINDATA) | ||
| $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." | ||
| @echo Generate Go embedded assets files by processing source | ||
| export PATH=$(PROJECT_PATH)/bin:$$PATH; $(GO) generate github.com/3scale/3scale-operator/pkg/assets | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to line 47