27
27
GOBIN = $(shell go env GOBIN)
28
28
endif
29
29
30
- .PHONY : all
31
30
all : build
32
31
33
32
# #@ General
@@ -51,7 +50,6 @@ help: ## Display this help.
51
50
shellcheck :
52
51
@find . -type f -name * .sh -exec docker run --rm -v $(shell pwd) :/mnt koalaman/shellcheck:stable {} +
53
52
54
- .PHONY : manifests
55
53
manifests : controller-gen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
56
54
$(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=manager-role webhook paths=" ./apis/fluentbit/..." output:crd:artifacts:config=config/crd/bases
57
55
$(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=manager-role webhook paths=" ./apis/fluentd/..." output:crd:artifacts:config=config/crd/bases
@@ -60,15 +58,13 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
60
58
kubectl kustomize config/crd/bases/ | sed -e ' /creationTimestamp/d' > manifests/setup/fluent-operator-crd.yaml
61
59
kubectl kustomize manifests/setup/ | sed -e ' /creationTimestamp/d' > manifests/setup/setup.yaml
62
60
63
- .PHONY : generate
64
61
generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
65
62
$(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
63
+ ./hack/update-codegen.sh
66
64
67
- PHONY : fmt
68
65
fmt : # # Run go fmt against code.
69
66
go fmt ./...
70
67
71
- PHONY : vet
72
68
vet : # # Run go vet against code.
73
69
go vet ./...
74
70
@@ -85,19 +81,6 @@ setup-envtest: install-setup-envtest ## Download and set up the envtest binary
85
81
test : manifests generate fmt vet setup-envtest # # Run tests.
86
82
go test ./apis/... -coverprofile cover.out
87
83
88
- # Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
89
- .PHONY : test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
90
- test-e2e :
91
- go test ./test/e2e/ -v -ginkgo.v
92
-
93
- .PHONY : lint
94
- lint : golangci-lint # # Run golangci-lint linter
95
- $(GOLANGCI_LINT ) run
96
-
97
- .PHONY : lint-fix
98
- lint-fix : golangci-lint # # Run golangci-lint linter and perform fixes
99
- $(GOLANGCI_LINT ) run --fix
100
-
101
84
# #@ Build
102
85
103
86
binary :
@@ -176,148 +159,39 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
176
159
undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config.
177
160
kubectl delete -f manifests/setup/setup.yaml
178
161
179
- # #@ Dependencies
180
-
181
- # # Location to install dependencies to
182
- LOCALBIN ?= $(shell pwd) /bin
183
- $(LOCALBIN ) :
184
- mkdir -p $(LOCALBIN )
185
-
186
- # # Tool Binaries
187
- KUBECTL ?= kubectl
188
- KUSTOMIZE ?= $(LOCALBIN ) /kustomize
189
- CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
190
- ENVTEST ?= $(LOCALBIN ) /setup-envtest
191
- GOLANGCI_LINT = $(LOCALBIN ) /golangci-lint
192
- GINKGO = $(LOCALBIN ) /ginkgo
193
- CODE_GENERATOR = $(LOCALBIN ) /code-generator
194
-
195
- # # Tool Versions
196
- KUSTOMIZE_VERSION ?= v5.4.3
197
- CONTROLLER_TOOLS_VERSION ?= v0.16.1
198
- ENVTEST_VERSION ?= release-0.19
199
- GOLANGCI_LINT_VERSION ?= v1.59.1
200
- GINKGO_VERSION ?= v2.23.4
201
- CODE_GENERATOR_VERSION ?= v0.32.3
202
-
203
- .PHONY : kustomize
204
- kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
205
- $(KUSTOMIZE ) : $(LOCALBIN )
206
- $(call go-install-tool,$(KUSTOMIZE ) ,sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION ) )
207
-
208
- .PHONY : controller-gen
209
- controller-gen : $(CONTROLLER_GEN ) # # Download controller-gen locally if necessary.
210
- $(CONTROLLER_GEN ) : $(LOCALBIN )
211
- $(call go-install-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION ) )
212
-
213
- .PHONY : envtest
214
- envtest : $(ENVTEST ) # # Download setup-envtest locally if necessary.
215
- $(ENVTEST ) : $(LOCALBIN )
216
- $(call go-install-tool,$(ENVTEST ) ,sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION ) )
217
-
218
- .PHONY : golangci-lint
219
- golangci-lint : $(GOLANGCI_LINT ) # # Download golangci-lint locally if necessary.
220
- $(GOLANGCI_LINT ) : $(LOCALBIN )
221
- $(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION ) )
222
-
223
- .PHONY : ginkgo
224
- ginkgo : $(GINKGO ) # # Download ginkgo locally if necessary.
225
- $(GINKGO ) : $(LOCALBIN )
226
- $(call go-install-tool,$(GINKGO ) ,github.com/onsi/ginkgo/v2/ginkgo,$(GINKGO_VERSION ) )
227
-
228
- code-generator : $(CODE_GENERATOR ) # # Download code-generator locally if necessary.
229
- $(CODE_GENERATOR ) : $(LOCALBIN )
230
- $(call go-install-tool,$(CODE_GENERATOR ) ,k8s.io/code-generator,$(CODE_GENERATOR_VERSION ) )
231
-
232
- # go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
233
- # $1 - target path with name of binary
234
- # $2 - package url which can be installed
235
- # $3 - specific version of package
236
- define go-install-tool
237
- @[ -f "$(1 ) -$(3 ) " ] || { \
238
- set -e; \
239
- package=$(2 ) @$(3 ) ;\
240
- echo "Downloading $${package}" ;\
241
- rm -f $(1 ) || true ;\
242
- GOBIN=$(LOCALBIN ) go install $${package} ;\
243
- mv $(1 ) $(1 ) -$(3 ) ;\
244
- } ;\
245
- ln -sf $(1 ) -$(3 ) $(1 )
162
+ CONTROLLER_GEN = $(shell pwd) /bin/controller-gen
163
+ controller-gen : go-deps # # Download controller-gen locally if necessary.
164
+ $(call go-get-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/[email protected] )
165
+
166
+ GINKGO = $(shell pwd) /bin/ginkgo
167
+ ginkgo : go-deps # # Download controller-gen locally if necessary.
168
+ $(call go-get-tool,$(GINKGO ) ,github.com/onsi/ginkgo/v2/[email protected] )
169
+
170
+
171
+ KUSTOMIZE = $(shell pwd) /bin/kustomize
172
+ kustomize : go-deps # # Download kustomize locally if necessary.
173
+ $(call go-get-tool,$(KUSTOMIZE ) ,sigs.k8s.io/kustomize/kustomize/[email protected] )
174
+
175
+ CODE_GENERATOR =
$(shell go env GOPATH) /pkg/mod/k8s.io/
[email protected]
176
+ code-generator : go-deps # # Download code-generator locally if necessary
177
+ $(call go-get-tool,$(CODE_GENERATOR ) ,k8s.io/[email protected] )
178
+
179
+ # go-get-tool will 'go get' any package $2 and install it to $1.
180
+ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
181
+ define go-get-tool
182
+ @[ -f $(1 ) ] || { \
183
+ set -e ;\
184
+ TMP_DIR=$$(mktemp -d ) ;\
185
+ cd $$TMP_DIR ;\
186
+ go mod init tmp ;\
187
+ echo "Downloading $(2 ) " ;\
188
+ GOBIN=$(PROJECT_DIR ) /bin go install $(2 ) ;\
189
+ rm -rf $$TMP_DIR ;\
190
+ }
246
191
endef
247
192
248
- .PHONY : operator-sdk
249
- OPERATOR_SDK ?= $(LOCALBIN ) /operator-sdk
250
- operator-sdk : # # Download operator-sdk locally if necessary.
251
- ifeq (,$(wildcard $(OPERATOR_SDK ) ) )
252
- ifeq (, $(shell which operator-sdk 2>/dev/null) )
253
- @{ \
254
- set -e ;\
255
- mkdir -p $(dir $(OPERATOR_SDK)) ;\
256
- OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
257
- curl -sSLo $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$${OS}_$${ARCH} ;\
258
- chmod +x $(OPERATOR_SDK) ;\
259
- }
260
- else
261
- OPERATOR_SDK = $(shell which operator-sdk)
262
- endif
263
- endif
264
- .PHONY : bundle
265
- bundle : manifests kustomize operator-sdk # # Generate bundle manifests and metadata, then validate generated files.
266
- $(OPERATOR_SDK ) generate kustomize manifests -q
267
- cd config/manager && $(KUSTOMIZE ) edit set image controller=$(IMG )
268
- $(KUSTOMIZE ) build config/manifests | $(OPERATOR_SDK ) generate bundle $(BUNDLE_GEN_FLAGS )
269
- $(OPERATOR_SDK ) bundle validate ./bundle
270
-
271
- .PHONY : bundle-build
272
- bundle-build : # # Build the bundle image.
273
- docker build -f bundle.Dockerfile -t $(BUNDLE_IMG ) .
274
-
275
- .PHONY : bundle-push
276
- bundle-push : # # Push the bundle image.
277
- $(MAKE ) docker-push IMG=$(BUNDLE_IMG )
278
-
279
- .PHONY : opm
280
- OPM = $(LOCALBIN ) /opm
281
- opm : # # Download opm locally if necessary.
282
- ifeq (,$(wildcard $(OPM ) ) )
283
- ifeq (,$(shell which opm 2>/dev/null) )
284
- @{ \
285
- set -e ;\
286
- mkdir -p $(dir $(OPM)) ;\
287
- OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
288
- curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$${OS}-$${ARCH}-opm ;\
289
- chmod +x $(OPM) ;\
290
- }
291
- else
292
- OPM = $(shell which opm)
293
- endif
294
- endif
295
-
296
- # A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
297
- # These images MUST exist in a registry and be pull-able.
298
- BUNDLE_IMGS ?= $(BUNDLE_IMG )
299
-
300
- # The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
301
- CATALOG_IMG ?= $(IMAGE_TAG_BASE ) -catalog:v$(VERSION )
302
-
303
- # Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
304
- ifneq ($(origin CATALOG_BASE_IMG ) , undefined)
305
- FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG )
306
- endif
307
-
308
- # Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
309
- # This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
310
- # https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
311
- .PHONY : catalog-build
312
- catalog-build : opm # # Build a catalog image.
313
- $(OPM ) index add --container-tool docker --mode semver --tag $(CATALOG_IMG ) --bundles $(BUNDLE_IMGS ) $(FROM_INDEX_OPT )
314
-
315
- # Push the catalog image.
316
- .PHONY : catalog-push
317
- catalog-push : # # Push a catalog image.
318
- $(MAKE ) docker-push IMG=$(CATALOG_IMG )
319
-
320
193
go-deps : # download go dependencies
194
+
321
195
go mod download
322
196
323
197
docs-update : # update api docs
0 commit comments