Skip to content

Commit 09c254b

Browse files
author
Mikalai Radchuk
committed
Manage tools with Go native tooling
Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent e51c0c2 commit 09c254b

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

Makefile

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ ifeq ($(shell [[ $$HOME == "" || $$HOME == "/" ]] && [[ $$XDG_DATA_HOME == "" ]]
3737
SETUP_ENVTEST_BIN_DIR_OVERRIDE += --bin-dir /tmp/envtest-binaries
3838
endif
3939

40-
# bingo manages consistent tooling versions for things like kind, kustomize, etc.
41-
include .bingo/Variables.mk
40+
include tools/Variables.mk
4241

4342
ifeq ($(origin KIND_CLUSTER_NAME), undefined)
4443
KIND_CLUSTER_NAME := operator-controller
@@ -91,7 +90,7 @@ help-extended: #HELP Display extended help.
9190
#SECTION Development
9291

9392
.PHONY: lint
94-
lint: $(GOLANGCI_LINT) #HELP Run golangci linter.
93+
lint: #HELP Run golangci linter.
9594
$(GOLANGCI_LINT) run --build-tags $(GO_BUILD_TAGS) $(GOLANGCI_LINT_ARGS)
9695

9796
.PHONY: tidy
@@ -100,19 +99,19 @@ tidy: #HELP Update dependencies.
10099
$(Q)go mod tidy -go=$(GOLANG_VERSION)
101100

102101
.PHONY: manifests
103-
manifests: $(CONTROLLER_GEN) #EXHELP Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
102+
manifests: #EXHELP Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
104103
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/base/crd/bases output:rbac:artifacts:config=config/base/rbac
105104

106105
.PHONY: generate
107-
generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
106+
generate: #EXHELP Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
108107
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
109108

110109
.PHONY: verify
111110
verify: tidy fmt vet generate manifests crd-ref-docs #HELP Verify all generated code is up-to-date.
112111
git diff --exit-code
113112

114113
.PHONY: fix-lint
115-
fix-lint: $(GOLANGCI_LINT) #EXHELP Fix lint issues
114+
fix-lint: #EXHELP Fix lint issues
116115
$(GOLANGCI_LINT) run --fix --build-tags $(GO_BUILD_TAGS) $(GOLANGCI_LINT_ARGS)
117116

118117
.PHONY: fmt
@@ -123,18 +122,11 @@ fmt: #EXHELP Formats code
123122
vet: #EXHELP Run go vet against code.
124123
go vet -tags '$(GO_BUILD_TAGS)' ./...
125124

126-
.PHONY: bingo-upgrade
127-
bingo-upgrade: $(BINGO) #EXHELP Upgrade tools
128-
@for pkg in $$($(BINGO) list | awk '{ print $$1 }' | tail -n +3); do \
129-
echo "Upgrading $$pkg to latest..."; \
130-
$(BINGO) get "$$pkg@latest"; \
131-
done
132-
133125
.PHONY: verify-crd-compatibility
134126
CRD_DIFF_ORIGINAL_REF := main
135127
CRD_DIFF_UPDATED_SOURCE := file://config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml
136128
CRD_DIFF_CONFIG := crd-diff-config.yaml
137-
verify-crd-compatibility: $(CRD_DIFF) manifests
129+
verify-crd-compatibility: manifests
138130
$(CRD_DIFF) --config="${CRD_DIFF_CONFIG}" "git://${CRD_DIFF_ORIGINAL_REF}?path=config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml" ${CRD_DIFF_UPDATED_SOURCE}
139131

140132
.PHONY: test
@@ -154,15 +146,15 @@ export E2E_TEST_CATALOG_V1 := e2e/test-catalog:v1
154146
export E2E_TEST_CATALOG_V2 := e2e/test-catalog:v2
155147
export CATALOG_IMG := $(LOCAL_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V1)
156148
.PHONY: test-ext-dev-e2e
157-
test-ext-dev-e2e: $(OPERATOR_SDK) $(KUSTOMIZE) $(KIND) #HELP Run extension create, upgrade and delete tests.
149+
test-ext-dev-e2e: #HELP Run extension create, upgrade and delete tests.
158150
test/extension-developer-e2e/setup.sh $(OPERATOR_SDK) $(CONTAINER_RUNTIME) $(KUSTOMIZE) $(KIND) $(KIND_CLUSTER_NAME) $(E2E_REGISTRY_NAMESPACE)
159151
go test -count=1 -v ./test/extension-developer-e2e/...
160152

161153
.PHONY: test-unit
162154
ENVTEST_VERSION := $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.x/')
163155
UNIT_TEST_DIRS := $(shell go list ./... | grep -v /test/)
164156
COVERAGE_UNIT_DIR := $(ROOT_DIR)/coverage/unit
165-
test-unit: $(SETUP_ENVTEST) #HELP Run the unit tests
157+
test-unit: #HELP Run the unit tests
166158
rm -rf $(COVERAGE_UNIT_DIR) && mkdir -p $(COVERAGE_UNIT_DIR)
167159
eval $$($(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE)) && \
168160
CGO_ENABLED=1 go test \
@@ -223,23 +215,23 @@ e2e-coverage:
223215
COVERAGE_OUTPUT=./coverage/e2e.out ./hack/test/e2e-coverage.sh
224216

225217
.PHONY: kind-load
226-
kind-load: $(KIND) #EXHELP Loads the currently constructed image onto the cluster.
218+
kind-load: #EXHELP Loads the currently constructed image onto the cluster.
227219
$(CONTAINER_RUNTIME) save $(IMG) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME)
228220

229221
.PHONY: kind-deploy
230222
kind-deploy: export MANIFEST="./operator-controller.yaml"
231-
kind-deploy: manifests $(KUSTOMIZE) #EXHELP Install controller and dependencies onto the kind cluster.
223+
kind-deploy: manifests #EXHELP Install controller and dependencies onto the kind cluster.
232224
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) > operator-controller.yaml
233225
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$INSTALL_DEFAULT_CATALOGS,$$MANIFEST' < scripts/install.tpl.sh | bash -s
234226

235227
.PHONY: kind-cluster
236-
kind-cluster: $(KIND) #EXHELP Standup a kind cluster.
228+
kind-cluster: #EXHELP Standup a kind cluster.
237229
-$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
238230
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --image $(KIND_CLUSTER_IMAGE) --config ./kind-config.yaml
239231
$(KIND) export kubeconfig --name $(KIND_CLUSTER_NAME)
240232

241233
.PHONY: kind-clean
242-
kind-clean: $(KIND) #EXHELP Delete the kind cluster.
234+
kind-clean: #EXHELP Delete the kind cluster.
243235
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
244236

245237
#SECTION Build
@@ -302,12 +294,12 @@ export ENABLE_RELEASE_PIPELINE
302294
export GORELEASER_ARGS
303295

304296
.PHONY: release
305-
release: $(GORELEASER) #EXHELP Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release.
297+
release: #EXHELP Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release.
306298
$(GORELEASER) $(GORELEASER_ARGS)
307299

308300
.PHONY: quickstart
309301
quickstart: export MANIFEST := https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/operator-controller.yaml
310-
quickstart: $(KUSTOMIZE) manifests #EXHELP Generate the installation release manifests and scripts.
302+
quickstart: manifests #EXHELP Generate the installation release manifests and scripts.
311303
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml
312304
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$INSTALL_DEFAULT_CATALOGS,$$MANIFEST' < scripts/install.tpl.sh > install.sh
313305

@@ -318,7 +310,7 @@ OPERATOR_CONTROLLER_API_REFERENCE_FILENAME := operator-controller-api-reference.
318310
CATALOGD_API_REFERENCE_FILENAME := catalogd-api-reference.md
319311
CATALOGD_TMP_DIR := $(ROOT_DIR)/.catalogd-tmp/
320312
API_REFERENCE_DIR := $(ROOT_DIR)/docs/api-reference
321-
crd-ref-docs: $(CRD_REF_DOCS) #EXHELP Generate the API Reference Documents.
313+
crd-ref-docs: #EXHELP Generate the API Reference Documents.
322314
rm -f $(API_REFERENCE_DIR)/$(OPERATOR_CONTROLLER_API_REFERENCE_FILENAME)
323315
$(CRD_REF_DOCS) --source-path=$(ROOT_DIR)/api \
324316
--config=$(API_REFERENCE_DIR)/crd-ref-docs-gen-config.yaml \

tools/Variables.mk

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
TOOLS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
2+
GO ?= $(shell which go)
3+
4+
5+
CONTROLLER_GEN ?= $(GO) tool -modfile=$(TOOLS_DIR)/controller-gen.mod controller-gen
6+
7+
CRD_DIFF ?= $(GO) tool -modfile=$(TOOLS_DIR)/crd-diff.mod crd-diff
8+
9+
CRD_REF_DOCS ?= $(GO) tool -modfile=$(TOOLS_DIR)/crd-ref-docs.mod crd-ref-docs
10+
11+
GOLANGCI_LINT ?= $(GO) tool -modfile=$(TOOLS_DIR)/golangci-lint.mod golangci-lint
12+
13+
GORELEASER ?= $(GO) tool -modfile=$(TOOLS_DIR)/goreleaser.mod goreleaser
14+
15+
KIND ?= $(GO) tool -modfile=$(TOOLS_DIR)/kind.mod kind
16+
17+
KUSTOMIZE ?= $(GO) tool -modfile=kustomize.mod kustomize
18+
19+
# TODO: Check if we need to use go run instead in order to be able to pass build flags such as -ldflags as go tool doesn't currently support these
20+
# -ldflags=-X=github.com/operator-framework/operator-sdk/internal/version.Version=v1.34.1
21+
OPERATOR_SDK ?= $(GO) tool -modfile=operator-sdk.mod operator-sdk
22+
23+
SETUP_ENVTEST ?= $(GO) tool -modfile=setup-envtest.mod setup-envtest

0 commit comments

Comments
 (0)