Skip to content

Some content is hidden

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

42 files changed

+765
-233
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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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: Create kind cluster
30+
run: kind create cluster
31+
32+
- name: Running Test e2e
33+
run: |
34+
go mod tidy
35+
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: 16 additions & 14 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.40.0
2223

2324
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
2425
ifeq (,$(shell go env GOBIN))
@@ -72,18 +73,8 @@ 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.
@@ -199,8 +190,11 @@ 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
193+
CONTROLLER_TOOLS_VERSION ?= v0.17.2
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}')
204198
GOLANGCI_LINT_VERSION ?= v2.0.1
205199
GINKGO_VERSION ?= v2.23.4
206200
CODE_GENERATOR_VERSION ?= v0.32.3
@@ -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)
@@ -297,7 +299,7 @@ ifeq (,$(shell which opm 2>/dev/null))
297299
set -e ;\
298300
mkdir -p $(dir $(OPM)) ;\
299301
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 ;\
302+
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.55.0/$${OS}-$${ARCH}-opm ;\
301303
chmod +x $(OPM) ;\
302304
}
303305
else

0 commit comments

Comments
 (0)