Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ linters:
- linters:
- goconst
path: (.+)_test\.go
- linters:
- unused
path: tests/e2e/
- linters:
- goheader
path: third_party/
paths:
- third_party$
- builtin$
Expand Down
98 changes: 89 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ MOCKGEN_VERSION := 0.6.0 # renovate: datasource=github-releases depName=uber-go/

GOPROXY=https://proxy.golang.org

# Directories to run golangci-lint in
LINT_DIRS := . api properties tests/e2e \
third_party/github.com/banzaicloud/operator-tools \
third_party/github.com/banzaicloud/k8s-objectmatcher \
third_party/github.com/banzaicloud/go-cruise-control

# Directories to run licensei check/cache in
LICENSE_CHECK_DIRS := . \
third_party/github.com/banzaicloud/operator-tools \
third_party/github.com/banzaicloud/k8s-objectmatcher \
third_party/github.com/banzaicloud/go-cruise-control

# Directories to run licensei header in
LICENSE_HEADER_DIRS := \
third_party/github.com/banzaicloud/k8s-objectmatcher \
third_party/github.com/banzaicloud/go-cruise-control

# Use BIN_DIR to form an absolute, stable path regardless of `cd` usage
CONTROLLER_GEN = $(BIN_DIR)/controller-gen

Expand Down Expand Up @@ -62,6 +79,16 @@ clean: ## Clean build artifacts and test binaries
fi
@rm -f cover.out
@rm -f manager_image_patch.yaml
@echo "Cleaning third_party/github.com/banzaicloud/operator-tools..."
@if [ -d "third_party/github.com/banzaicloud/operator-tools/bin" ]; then \
chmod -R u+w third_party/github.com/banzaicloud/operator-tools/bin/ 2>/dev/null || true; \
rm -rf third_party/github.com/banzaicloud/operator-tools/bin/; \
fi
@echo "Cleaning third_party/github.com/banzaicloud/k8s-objectmatcher..."
@if [ -d "third_party/github.com/banzaicloud/k8s-objectmatcher/bin" ]; then \
chmod -R u+w third_party/github.com/banzaicloud/k8s-objectmatcher/bin/ 2>/dev/null || true; \
rm -rf third_party/github.com/banzaicloud/k8s-objectmatcher/bin/; \
fi

bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION} ## Symlink golangi-lint-<version> into versionless golangci-lint.
@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
Expand All @@ -72,14 +99,22 @@ bin/golangci-lint-${GOLANGCI_VERSION}: ## Download versioned golangci-lint.

.PHONY: lint
lint: bin/golangci-lint ## Run linter analysis.
bin/golangci-lint run -c ./.golangci.yml --timeout=5m
cd api && ../bin/golangci-lint run -c ../.golangci.yml --timeout=5m
cd properties && ../bin/golangci-lint run -c ../.golangci.yml --timeout=5m
cd tests/e2e && ../../bin/golangci-lint run -c .golangci.yml --timeout=5m
@for dir in $(LINT_DIRS); do \
echo "Running lint in $$dir"; \
(cd $$dir && $(CURDIR)/bin/golangci-lint run -c $(CURDIR)/.golangci.yml --timeout=5m) || exit 1; \
done

.PHONY: lint-fix
lint-fix: bin/golangci-lint ## Run linter with automatic fixes.
@for dir in $(LINT_DIRS); do \
echo "Running lint-fix in $$dir"; \
(cd $$dir && $(CURDIR)/bin/golangci-lint run -c $(CURDIR)/.golangci.yml --fix --timeout=5m) || exit 1; \
done

.PHONY: lint-fix ## Run linter with automatic fixes.
lint-fix: bin/golangci-lint ## Run linter
@bin/golangci-lint run -v --fix
.PHONY: lint-clean
lint-clean: bin/golangci-lint ## Clean linter cache.
@echo "Cleaning golangci-lint cache..."
bin/golangci-lint cache clean

bin/licensei: bin/licensei-${LICENSEI_VERSION} ## Symlink licensei-<version> into versionless licensei.
@ln -sf licensei-${LICENSEI_VERSION} bin/licensei
Expand All @@ -90,11 +125,24 @@ bin/licensei-${LICENSEI_VERSION}: ## Download versioned licensei.

.PHONY: license-check
license-check: bin/licensei ## Run license check.
bin/licensei check
@for dir in $(LICENSE_CHECK_DIRS); do \
echo "Running license check in $$dir..."; \
(cd $$dir && $(CURDIR)/bin/licensei check) || exit 1; \
done

.PHONY: license-cache
license-cache: bin/licensei ## Generate license cache.
bin/licensei cache
@for dir in $(LICENSE_CHECK_DIRS); do \
echo "Generating license cache in $$dir..."; \
(cd $$dir && $(CURDIR)/bin/licensei cache) || exit 1; \
done

.PHONY: license
license: bin/licensei ## Add license headers to source files.
@for dir in $(LICENSE_HEADER_DIRS); do \
echo "Adding license headers in $$dir..."; \
(cd $$dir && $(CURDIR)/bin/licensei header) || exit 1; \
done

install-kustomize: ## Install kustomize.
@ if ! which bin/kustomize &>/dev/null; then\
Expand All @@ -113,6 +161,15 @@ test: generate fmt vet bin/setup-envtest
-test.paniconexit0 \
-timeout 1h
cd properties && go test -coverprofile cover.out -cover -failfast -v -covermode=count ./pkg/... ./internal/...
@echo "Running tests in third_party/github.com/banzaicloud/operator-tools..."
cd third_party/github.com/banzaicloud/operator-tools && \
KUBEBUILDER_ASSETS=$$($(BIN_DIR)/setup-envtest --print path --bin-dir $(BIN_DIR) use $(ENVTEST_K8S_VERSION)) \
go test ./... -v -failfast
@echo "Running tests in third_party/github.com/banzaicloud/k8s-objectmatcher..."
cd third_party/github.com/banzaicloud/k8s-objectmatcher && go test ./...
@echo "Running tests in third_party/github.com/banzaicloud/go-cruise-control..."
cd third_party/github.com/banzaicloud/go-cruise-control && \
go test -v -parallel 2 -failfast ./... -cover -covermode=count -coverprofile cover.out -test.v -test.paniconexit0

# Run e2e tests
test-e2e:
Expand Down Expand Up @@ -158,15 +215,38 @@ fmt: ## Run go fmt against code.
cd api && go fmt ./...
cd properties && go fmt ./...
cd tests/e2e && go fmt ./...
@echo "Running fmt in third_party/github.com/banzaicloud/k8s-objectmatcher..."
cd third_party/github.com/banzaicloud/k8s-objectmatcher && go fmt ./...
@echo "Running fmt in third_party/github.com/banzaicloud/go-cruise-control..."
cd third_party/github.com/banzaicloud/go-cruise-control && go fmt ./...

vet: ## Run go vet against code.
go vet ./...
cd api && go fmt ./...
cd properties && go vet ./...
cd tests/e2e && go vet ./...
@echo "Running vet in third_party/github.com/banzaicloud/k8s-objectmatcher..."
cd third_party/github.com/banzaicloud/k8s-objectmatcher && go vet ./...
@echo "Running vet in third_party/github.com/banzaicloud/go-cruise-control..."
cd third_party/github.com/banzaicloud/go-cruise-control && go vet ./...

generate: bin/controller-gen gen-license-header ## Generate source code for APIs, Mocks, etc.
cd api && $(CONTROLLER_GEN) object:headerFile=$(BOILERPLATE_DIR)/header.go.generated.txt paths="./..."
@echo "Running generate in third_party/github.com/banzaicloud/operator-tools..."
cd third_party/github.com/banzaicloud/operator-tools && \
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./pkg/secret/... && \
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./pkg/volume/... && \
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./pkg/prometheus/... && \
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./pkg/types/... && \
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./pkg/typeoverride/... && \
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./pkg/helm/...
@echo "Generating type documentation for operator-tools..."
cd third_party/github.com/banzaicloud/operator-tools && go run cmd/docs.go

.PHONY: check-diff
check-diff: generate ## Check for uncommitted changes
@echo "Checking for uncommitted changes ..."
git diff --exit-code

docker-build: ## Build the operator docker image.
docker build . -t ${IMG}
Expand Down
31 changes: 13 additions & 18 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,38 @@ require (
emperror.dev/errors v0.8.1
github.com/banzaicloud/istio-client-go v0.0.17
github.com/cert-manager/cert-manager v1.18.2
golang.org/x/exp v0.0.0-20250911091902-df9299821621
gotest.tools v2.2.0+incompatible
k8s.io/api v0.34.1
k8s.io/apimachinery v0.34.1
sigs.k8s.io/controller-runtime v0.22.1
)

require (
// github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/stretchr/testify v1.11.1
gotest.tools v2.2.0+incompatible
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/pkg/errors v0.9.1 // indirect
// github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
golang.org/x/net v0.44.0 // indirect
golang.org/x/text v0.29.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
// gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d // indirect
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
)

require github.com/stretchr/testify v1.11.1

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
)
10 changes: 4 additions & 6 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20250911091902-df9299821621 h1:2id6c1/gto0kaHYyrixvknJ8tUK/Qs5IsmBtrc+FtgU=
golang.org/x/exp v0.0.0-20250911091902-df9299821621/go.mod h1:TwQYMMnGpvZyc+JpB/UAuTNIsVJifOlSkrZkhcvpVUk=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
Expand Down Expand Up @@ -105,8 +103,8 @@ golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand All @@ -130,8 +128,8 @@ k8s.io/apimachinery v0.34.1/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13l
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d h1:wAhiDyZ4Tdtt7e46e9M5ZSAJ/MnPGPs+Ki1gHw4w1R0=
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck=
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/controller-runtime v0.22.1 h1:Ah1T7I+0A7ize291nJZdS1CabF/lB4E++WizgV24Eqg=
sigs.k8s.io/controller-runtime v0.22.1/go.mod h1:FwiwRjkRPbiN+zp2QRp7wlTCzbUXxZ/D4OzuQUDwBHY=
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/kafkauserspec_annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ package v1alpha1

import (
"fmt"
"maps"
"time"

"emperror.dev/errors"
"golang.org/x/exp/maps"
)

// annotationsWithValidations is a map whose keys are KafkaUserSpec annotation keys, and values are validators
Expand Down
18 changes: 8 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ require (
github.com/envoyproxy/go-control-plane v0.13.4
github.com/envoyproxy/go-control-plane/envoy v1.35.0
github.com/go-logr/logr v1.4.3
github.com/onsi/ginkgo/v2 v2.25.3
github.com/onsi/ginkgo/v2 v2.26.0
github.com/onsi/gomega v1.38.2
github.com/pavlo-v-chernykh/keystore-go/v4 v4.5.0
github.com/projectcontour/contour v1.33.0
github.com/prometheus/common v0.66.1
github.com/stretchr/testify v1.11.1
go.uber.org/mock v0.6.0
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20250911091902-df9299821621
golang.org/x/exp v0.0.0-20251002181428-27f1f14c8bb9
google.golang.org/protobuf v1.36.10
gopkg.in/inf.v0 v0.9.1
gotest.tools v2.2.0+incompatible
Expand Down Expand Up @@ -55,18 +55,18 @@ require (
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/pprof v0.0.0-20250923004556-9e5a51aed1e8 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/google/pprof v0.0.0-20251002213607-436353cc1ee6 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/mod v0.28.0 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/tools v0.37.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250929231259-57b25ae835d4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250929231259-57b25ae835d4 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251002232023-7c0ddcbb5797 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251002232023-7c0ddcbb5797 // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
Expand All @@ -80,7 +80,6 @@ require (
github.com/briandowns/spinner v1.23.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 // indirect
github.com/cppforlife/go-patch v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/eapache/go-resiliency v1.7.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
Expand Down Expand Up @@ -126,7 +125,7 @@ require (
github.com/shopspring/decimal v1.4.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/tidwall/gjson v1.14.4 // indirect
github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/wayneashleyberry/terminal-dimensions v1.1.0 // indirect
Expand All @@ -139,12 +138,11 @@ require (
golang.org/x/text v0.29.0 // indirect
golang.org/x/time v0.13.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
istio.io/api v1.27.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d // indirect
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
sigs.k8s.io/gateway-api v1.3.0 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/yaml v1.6.0
Expand Down
Loading
Loading