Skip to content

Commit 6b4570a

Browse files
Merge pull request #1702 from marcofranssen/bump-operator-sdk
Update operator-sdk to v1.41.1 according to migrations
2 parents b6b4052 + 193ada9 commit 6b4570a

File tree

91 files changed

+3772
-1323
lines changed

Some content is hidden

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

91 files changed

+3772
-1323
lines changed

.devcontainer/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "Kubebuilder DevContainer",
3+
"image": "docker.io/golang:1.23",
4+
"features": {
5+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
6+
"ghcr.io/devcontainers/features/git:1": {}
7+
},
8+
9+
"runArgs": ["--network=host"],
10+
11+
"customizations": {
12+
"vscode": {
13+
"settings": {
14+
"terminal.integrated.shell.linux": "/bin/bash"
15+
},
16+
"extensions": [
17+
"ms-kubernetes-tools.vscode-kubernetes-tools",
18+
"ms-azuretools.vscode-docker"
19+
]
20+
}
21+
},
22+
23+
"onCreateCommand": "bash .devcontainer/post-install.sh"
24+
}
25+

.devcontainer/post-install.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -x
3+
4+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
5+
chmod +x ./kind
6+
mv ./kind /usr/local/bin/kind
7+
8+
curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/linux/amd64
9+
chmod +x kubebuilder
10+
mv kubebuilder /usr/local/bin/
11+
12+
KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
13+
curl -LO "https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl"
14+
chmod +x kubectl
15+
mv kubectl /usr/local/bin/kubectl
16+
17+
docker network create -d=bridge --subnet=172.19.0.0/24 kind
18+
19+
kind version
20+
kubebuilder version
21+
docker --version
22+
go version
23+
kubectl version --client

.github/workflows/test-e2e.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test-e2e:
9+
name: Run on Ubuntu
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone the code
13+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
17+
with:
18+
go-version-file: go.mod
19+
20+
- name: Install the latest version of kind
21+
run: |
22+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
23+
chmod +x ./kind
24+
sudo mv ./kind /usr/local/bin/kind
25+
26+
- name: Verify kind installation
27+
run: kind version
28+
29+
- name: Running Test e2e
30+
run: |
31+
go mod tidy
32+
make test-e2e

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
name: Run on Ubuntu
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone the code
13+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
17+
with:
18+
go-version-file: go.mod
19+
20+
- name: Running Tests
21+
run: |
22+
go mod tidy
23+
make test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ testbin/
2525

2626
.DS_Store
2727
.envrc
28+
charts/fluent-operator.tgz

Makefile

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ARCH ?= arm64
1919

2020
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
2121
CRD_OPTIONS ?= crd:generateEmbeddedObjectMeta=true,allowDangerousTypes=true
22+
OPERATOR_SDK_VERSION ?= v1.41.1
2223

2324
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
2425
ifeq (,$(shell go env GOBIN))
@@ -72,23 +73,13 @@ PHONY: vet
7273
vet: ## Run go vet against code.
7374
go vet ./...
7475

75-
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
76-
77-
install-setup-envtest: ## Install the setup-envtest tool if it is not already installed
78-
if ! command -v setup-envtest &> /dev/null; then \
79-
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest; \
80-
fi
81-
82-
setup-envtest: install-setup-envtest ## Download and set up the envtest binary
83-
source <(setup-envtest use -p env)
84-
8576
test: manifests generate fmt vet setup-envtest ## Run tests.
86-
go test ./apis/... -coverprofile cover.out
77+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
8778

8879
# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors.
8980
.PHONY: test-e2e # Run the e2e tests against a Kind k8s instance that is spun up.
9081
test-e2e:
91-
go test ./test/e2e/ -v -ginkgo.v
82+
go test ./tests/e2e/ -v -ginkgo.v
9283

9384
.PHONY: lint
9485
lint: golangci-lint ## Run golangci-lint linter
@@ -199,9 +190,12 @@ KIND = $(LOCALBIN)/kind
199190

200191
## Tool Versions
201192
KUSTOMIZE_VERSION ?= v5.6.0
202-
CONTROLLER_TOOLS_VERSION ?= v0.15.0
203-
ENVTEST_VERSION ?= release-0.19
204-
GOLANGCI_LINT_VERSION ?= v2.0.1
193+
CONTROLLER_TOOLS_VERSION ?= v0.18.0
194+
#ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
195+
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
196+
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
197+
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
198+
GOLANGCI_LINT_VERSION ?= v2.1.0
205199
GINKGO_VERSION ?= v2.23.4
206200
CODE_GENERATOR_VERSION ?= v0.32.3
207201
KIND_VERSION ?= v0.17.0
@@ -216,6 +210,14 @@ controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessar
216210
$(CONTROLLER_GEN): $(LOCALBIN)
217211
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION))
218212

213+
.PHONY: setup-envtest
214+
setup-envtest: envtest ## Download the binaries required for ENVTEST in the local bin directory.
215+
@echo "Setting up envtest binaries for Kubernetes version $(ENVTEST_K8S_VERSION)..."
216+
@$(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path || { \
217+
echo "Error: Failed to set up envtest binaries for version $(ENVTEST_K8S_VERSION)."; \
218+
exit 1; \
219+
}
220+
219221
.PHONY: envtest
220222
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
221223
$(ENVTEST): $(LOCALBIN)
@@ -236,6 +238,26 @@ code-generator: $(CODE_GENERATOR) ## Download code-generator locally if necessar
236238
$(CODE_GENERATOR): $(LOCALBIN)
237239
$(call go-install-tool,$(CODE_GENERATOR),k8s.io/code-generator,$(CODE_GENERATOR_VERSION))
238240

241+
KIND_CLUSTER ?= fluent-operator-test-e2e
242+
243+
.PHONY: setup-test-e2e
244+
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
245+
@command -v $(KIND) >/dev/null 2>&1 || { \
246+
echo "Kind is not installed. Please install Kind manually."; \
247+
exit 1; \
248+
}
249+
@case "$$($(KIND) get clusters)" in \
250+
*"$(KIND_CLUSTER)"*) \
251+
echo "Kind cluster '$(KIND_CLUSTER)' already exists. Skipping creation." ;; \
252+
*) \
253+
echo "Creating Kind cluster '$(KIND_CLUSTER)'..."; \
254+
$(KIND) create cluster --name $(KIND_CLUSTER) ;; \
255+
esac
256+
257+
.PHONY: cleanup-test-e2e
258+
cleanup-test-e2e:
259+
$(KIND) delete cluster --name $(KIND_CLUSTER)
260+
239261
.PHONY: kind
240262
kind: $(KIND) ## Download code-generator locally if necessary.
241263
$(KIND): $(LOCALBIN)
@@ -297,7 +319,7 @@ ifeq (,$(shell which opm 2>/dev/null))
297319
set -e ;\
298320
mkdir -p $(dir $(OPM)) ;\
299321
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
300-
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$${OS}-$${ARCH}-opm ;\
322+
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.55.0/$${OS}-$${ARCH}-opm ;\
301323
chmod +x $(OPM) ;\
302324
}
303325
else

PROJECT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
domain: fluent.io
22
layout:
3-
- go.kubebuilder.io/v3
3+
- go.kubebuilder.io/v4
44
multigroup: true
55
projectName: fluent-operator
66
repo: github.com/fluent/fluent-operator

charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterfilters.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.15.0
6+
controller-gen.kubebuilder.io/version: v0.18.0
77
name: clusterfilters.fluentbit.fluent.io
88
spec:
99
group: fluentbit.fluent.io

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.15.0
6+
controller-gen.kubebuilder.io/version: v0.18.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: 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.15.0
6+
controller-gen.kubebuilder.io/version: v0.18.0
77
name: clusterinputs.fluentbit.fluent.io
88
spec:
99
group: fluentbit.fluent.io

0 commit comments

Comments
 (0)