Skip to content

Commit b91a3bc

Browse files
authored
Revert "dependencies: Update controller-runtime and api machinery (#1558)" (#1562)
1 parent 087a7da commit b91a3bc

File tree

51 files changed

+3583
-3338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3583
-3338
lines changed

Makefile

Lines changed: 31 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ else
2727
GOBIN = $(shell go env GOBIN)
2828
endif
2929

30-
.PHONY: all
3130
all: build
3231

3332
##@ General
@@ -51,7 +50,6 @@ help: ## Display this help.
5150
shellcheck:
5251
@find . -type f -name *.sh -exec docker run --rm -v $(shell pwd):/mnt koalaman/shellcheck:stable {} +
5352

54-
.PHONY: manifests
5553
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
5654
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./apis/fluentbit/..." output:crd:artifacts:config=config/crd/bases
5755
$(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
6058
kubectl kustomize config/crd/bases/ | sed -e '/creationTimestamp/d' > manifests/setup/fluent-operator-crd.yaml
6159
kubectl kustomize manifests/setup/ | sed -e '/creationTimestamp/d' > manifests/setup/setup.yaml
6260

63-
.PHONY: generate
6461
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
6562
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
63+
./hack/update-codegen.sh
6664

67-
PHONY: fmt
6865
fmt: ## Run go fmt against code.
6966
go fmt ./...
7067

71-
PHONY: vet
7268
vet: ## Run go vet against code.
7369
go vet ./...
7470

@@ -85,19 +81,6 @@ setup-envtest: install-setup-envtest ## Download and set up the envtest binary
8581
test: manifests generate fmt vet setup-envtest ## Run tests.
8682
go test ./apis/... -coverprofile cover.out
8783

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-
10184
##@ Build
10285

10386
binary:
@@ -176,148 +159,39 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
176159
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
177160
kubectl delete -f manifests/setup/setup.yaml
178161

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+
}
246191
endef
247192

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-
320193
go-deps: # download go dependencies
194+
go get k8s.io/[email protected]
321195
go mod download
322196

323197
docs-update: # update api docs

charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterfilters.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.15.0
77
name: clusterfilters.fluentbit.fluent.io
88
spec:
99
group: fluentbit.fluent.io
@@ -445,7 +445,9 @@ spec:
445445
This field is effectively required, but due to backwards compatibility is
446446
allowed to be empty. Instances of this type with an empty value here are
447447
almost certainly wrong.
448+
TODO: Add other useful fields. apiVersion, kind, uid?
448449
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
450+
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
449451
type: string
450452
optional:
451453
description: Specify whether the ConfigMap or its key

charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterfluentbitconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.15.0
77
name: clusterfluentbitconfigs.fluentbit.fluent.io
88
spec:
99
group: fluentbit.fluent.io

charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.15.0
77
name: clusterinputs.fluentbit.fluent.io
88
spec:
99
group: fluentbit.fluent.io
@@ -282,7 +282,9 @@ spec:
282282
This field is effectively required, but due to backwards compatibility is
283283
allowed to be empty. Instances of this type with an empty value here are
284284
almost certainly wrong.
285+
TODO: Add other useful fields. apiVersion, kind, uid?
285286
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
287+
TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896.
286288
type: string
287289
optional:
288290
description: Specify whether the Secret or its

charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clustermultilineparsers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.15.0
77
name: clustermultilineparsers.fluentbit.fluent.io
88
spec:
99
group: fluentbit.fluent.io

0 commit comments

Comments
 (0)