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
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"matchPackageNames": [
"/^k8s.io\\//"
],
"allowedVersions": "0.28.x"
"allowedVersions": "0.33.x"
}
],
"prHourlyLimit": 0,
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Run prepare make target
run: make generate
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
uses: golangci/golangci-lint-action@v9
with:
version: latest
- name: Delete pre-installed shellcheck
Expand All @@ -43,13 +43,11 @@ jobs:
- name: Dependency Licenses Review
run: make check-dependency-licenses
- name: Check for spelling errors
uses: reviewdog/action-misspell@v1
with:
exclude: ./vendor/*
fail_on_error: true
github_token: ${{ secrets.GITHUB_TOKEN }}
ignore: importas
reporter: github-check
uses: crate-ci/typos@v1
env:
CLICOLOR: "1"
- name: Delete typos binary
run: rm typos
- name: Check if source code files have license header
run: make check-addlicense
- name: Install govulncheck
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
Expand All @@ -39,13 +39,13 @@ jobs:
run: make build-all
code_coverage:
name: Code coverage report
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && github.base_ref == 'main'
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: Post coverage report
uses: fgrosse/[email protected]
with:
Expand All @@ -62,7 +62,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
Expand All @@ -73,7 +73,7 @@ jobs:
- name: Run tests and generate coverage report
run: make build/cover.out
- name: Archive code coverage results
uses: actions/upload-artifact@v5
uses: actions/upload-artifact@v6
with:
name: code-coverage
path: build/cover.out
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
Expand Down
13 changes: 9 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ linters:
- ineffassign
- intrange
- iotamixing
- misspell
- modernize
- nilerr
- nolintlint
- nosprintfhostport
Expand Down Expand Up @@ -130,8 +130,6 @@ linters:
- github.com/mdlayher/arp
# for github.com/sapcc/vpa_butler
- k8s.io/client-go
# for CVE-2025-22868
- golang.org/x/oauth2
toolchain-forbidden: true
go-version-pattern: 1\.\d+(\.0)?$
gosec:
Expand All @@ -146,6 +144,13 @@ linters:
enable-all: true
nolintlint:
require-specific: true
modernize:
disable:
# omitzero requires removing omitempty tags in kubernetes api struct types which are nested, which is interpreted by controller-gen and breaks the CRDs.
- omitzero
perfsprint:
# modernize generates nicer fix code
concat-loop: false
staticcheck:
dot-import-whitelist:
- github.com/majewsky/gg/option
Expand All @@ -170,13 +175,13 @@ linters:
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- bodyclose
- revive
path: _test\.go
# It is idiomatic Go to reuse the name 'err' with ':=' for subsequent errors.
# Ref: https://go.dev/doc/effective_go#redeclaration
Expand Down
1 change: 1 addition & 0 deletions .license-scan-overrides.jsonl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{"name": "github.com/chzyer/logex", "licenceType": "MIT"}
{"name": "github.com/grpc-ecosystem/go-grpc-middleware/v2", "licenceType": "Apache-2.0"}
{"name": "github.com/hashicorp/vault/api/auth/approle", "licenceType": "MPL-2.0"}
{"name": "github.com/jpillora/longestcommon", "licenceType": "MIT"}
{"name": "github.com/logrusorgru/aurora", "licenceType": "Unlicense"}
Expand Down
18 changes: 18 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-FileCopyrightText: 2026 SAP SE
# SPDX-License-Identifier: Apache-2.0

[default.extend-words]
ser = "ser"
otu = "otu"
# Typo in name used by Cisco NX-OS for a configurable property.
# See: https://pubhub.devnetcloud.com/media/dme-docs-10-4-3/docs/System/snmp%3ACommSecP/#configurable-properties
acess = "acess"
# See: https://github.com/openconfig/public/pull/1423
entitites = "entitites"
mininum = "mininum"
specifc = "specifc"

[files]
extend-exclude = [
"go.mod",
]
44 changes: 15 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,19 @@ install-goimports: FORCE
install-golangci-lint: FORCE
@if ! hash golangci-lint 2>/dev/null; then printf "\e[1;36m>> Installing golangci-lint (this may take a while)...\e[0m\n"; go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest; fi

install-modernize: FORCE
@if ! hash modernize 2>/dev/null; then printf "\e[1;36m>> Installing modernize (this may take a while)...\e[0m\n"; go install golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest; fi

install-shellcheck: FORCE
@if ! hash shellcheck 2>/dev/null; then printf "\e[1;36m>> Installing shellcheck...\e[0m\n"; SHELLCHECK_ARCH=$(shell uname -m); if [[ "$$SHELLCHECK_ARCH" == "arm64" ]]; then SHELLCHECK_ARCH=aarch64; fi; SHELLCHECK_OS=$(shell uname -s | tr '[:upper:]' '[:lower:]'); SHELLCHECK_VERSION="stable"; if command -v curl >/dev/null 2>&1; then GET="curl -sLo-"; elif command -v wget >/dev/null 2>&1; then GET="wget -O-"; else echo "Didn't find curl or wget to download shellcheck"; exit 2; fi; $$GET "https://github.com/koalaman/shellcheck/releases/download/$$SHELLCHECK_VERSION/shellcheck-$$SHELLCHECK_VERSION.$$SHELLCHECK_OS.$$SHELLCHECK_ARCH.tar.xz" | tar -Jxf -; BIN=$$(go env GOBIN); if [[ -z $$BIN ]]; then BIN=$$(go env GOPATH)/bin; fi; install -Dm755 shellcheck-$$SHELLCHECK_VERSION/shellcheck -t "$$BIN"; rm -rf shellcheck-$$SHELLCHECK_VERSION; fi
@set -eou pipefail; if ! hash shellcheck 2>/dev/null; then printf "\e[1;36m>> Installing shellcheck...\e[0m\n"; SHELLCHECK_ARCH=$$(uname -m); if [[ "$$SHELLCHECK_ARCH" == "arm64" ]]; then SHELLCHECK_ARCH=aarch64; fi; SHELLCHECK_OS=$$(uname -s | tr '[:upper:]' '[:lower:]'); SHELLCHECK_VERSION="stable"; if command -v curl >/dev/null 2>&1; then GET="curl -sLo-"; elif command -v wget >/dev/null 2>&1; then GET="wget -O-"; else echo "Didn't find curl or wget to download shellcheck"; exit 2; fi; $$GET "https://github.com/koalaman/shellcheck/releases/download/$$SHELLCHECK_VERSION/shellcheck-$$SHELLCHECK_VERSION.$$SHELLCHECK_OS.$$SHELLCHECK_ARCH.tar.xz" | tar -Jxf -; BIN=$$(go env GOBIN); if [[ -z $$BIN ]]; then BIN=$$(go env GOPATH)/bin; fi; install -Dm755 shellcheck-$$SHELLCHECK_VERSION/shellcheck -t "$$BIN"; rm -rf shellcheck-$$SHELLCHECK_VERSION; fi

install-typos: FORCE
@set -eou pipefail; if ! hash typos 2>/dev/null; then printf "\e[1;36m>> Installing typos...\e[0m\n"; TYPOS_ARCH=$$(uname -m); if [[ "$$TYPOS_ARCH" == "arm64" ]]; then TYPOS_ARCH=aarch64; fi; if command -v curl >/dev/null 2>&1; then GET="curl $${GITHUB_TOKEN:+" -u \":$$GITHUB_TOKEN\""} -sLo-"; elif command -v wget >/dev/null 2>&1; then GET="wget $${GITHUB_TOKEN:+" --password \"$$GITHUB_TOKEN\""} -O-"; else echo "Didn't find curl or wget to download typos"; exit 2; fi; if command -v gh >/dev/null; then TYPOS_GET_RELEASE_JSON="gh api /repos/crate-ci/typos/releases"; else TYPOS_GET_RELEASE_JSON="$$GET https://api.github.com/repos/crate-ci/typos/releases"; fi; TYPOS_VERSION=$$($$TYPOS_GET_RELEASE_JSON | jq -r '.[0].name' ); if [[ $(UNAME_S) == Darwin ]]; then TYPOS_FILE="typos-$$TYPOS_VERSION-$$TYPOS_ARCH-apple-darwin.tar.gz"; elif [[ $(UNAME_S) == Linux ]]; then TYPOS_FILE="typos-$$TYPOS_VERSION-$$TYPOS_ARCH-unknown-linux-musl.tar.gz"; fi; mkdir -p typos; $$GET ""https://github.com/crate-ci/typos/releases/download/$$TYPOS_VERSION/$$TYPOS_FILE"" | tar -C typos -zxf -; BIN=$$(go env GOBIN); if [[ -z $$BIN ]]; then BIN=$$(go env GOPATH)/bin; fi; install -Dm755 typos/typos -t "$$BIN"; rm -rf typos/; fi

install-go-licence-detector: FORCE
@if ! hash go-licence-detector 2>/dev/null; then printf "\e[1;36m>> Installing go-licence-detector (this may take a while)...\e[0m\n"; go install go.elastic.co/go-licence-detector@latest; fi

install-addlicense: FORCE
@if ! hash addlicense 2>/dev/null; then printf "\e[1;36m>> Installing addlicense (this may take a while)...\e[0m\n"; go install github.com/google/addlicense@latest; fi

install-reuse: FORCE
@if ! hash reuse 2>/dev/null; then if ! hash pipx 2>/dev/null; then printf "\e[1;31m>> You are required to manually intervene to install reuse as go-makefile-maker cannot automatically resolve installing reuse on all setups.\e[0m\n"; printf "\e[1;31m>> The preferred way for go-makefile-maker to install python tools after nix-shell is pipx which could not be found. Either install pipx using your package manager or install reuse using your package manager if at least version 6 is available.\e[0m\n"; printf "\e[1;31m>> As your Python was likely installed by your package manager, just doing pip install --user sadly does no longer work as pip issues a warning about breaking your system. Generally running --break-system-packages with --user is safe to do but you should only run this command if you can resolve issues with it yourself: pip3 install --user --break-system-packages reuse\e[0m\n"; else printf "\e[1;36m>> Installing reuse...\e[0m\n"; pipx install reuse; fi; fi

prepare-static-check: FORCE install-golangci-lint install-modernize install-shellcheck install-go-licence-detector install-addlicense install-reuse
prepare-static-check: FORCE install-goimports install-golangci-lint install-shellcheck install-typos install-go-licence-detector install-addlicense

install-controller-gen: FORCE
@if ! hash controller-gen 2>/dev/null; then printf "\e[1;36m>> Installing controller-gen (this may take a while)...\e[0m\n"; go install sigs.k8s.io/controller-tools/cmd/controller-gen@latest; fi
Expand Down Expand Up @@ -216,7 +213,7 @@ build/network-operator: FORCE generate
env $(GO_BUILDENV) go build $(GO_BUILDFLAGS) -ldflags '-s -w -X github.com/sapcc/go-api-declarations/bininfo.binName=network-operator -X github.com/sapcc/go-api-declarations/bininfo.version=$(BININFO_VERSION) -X github.com/sapcc/go-api-declarations/bininfo.commit=$(BININFO_COMMIT_HASH) -X github.com/sapcc/go-api-declarations/bininfo.buildDate=$(BININFO_BUILD_DATE) $(GO_LDFLAGS)' -o build/network-operator ./cmd

DESTDIR =
ifeq ($(shell uname -s),Darwin)
ifeq ($(UNAME_S),Darwin)
PREFIX = /usr/local
else
PREFIX = /usr
Expand Down Expand Up @@ -252,14 +249,14 @@ run-golangci-lint: FORCE install-golangci-lint
@golangci-lint config verify
@golangci-lint run

run-modernize: FORCE install-modernize
@printf "\e[1;36m>> modernize\e[0m\n"
@modernize $(GO_TESTPKGS)

run-shellcheck: FORCE install-shellcheck
@printf "\e[1;36m>> shellcheck\e[0m\n"
@find . -type f \( -name '*.bash' -o -name '*.ksh' -o -name '*.zsh' -o -name '*.sh' -o -name '*.shlib' \) -exec shellcheck {} +

run-typos: FORCE install-typos
@printf "\e[1;36m>> typos\e[0m\n"
@typos

build/cover.out: FORCE generate install-setup-envtest | build
@printf "\e[1;36m>> Running tests\e[0m\n"
KUBEBUILDER_ASSETS=$$(setup-envtest use 1.32 -p path) go run github.com/onsi/ginkgo/v2/ginkgo run --randomize-all -output-dir=build $(GO_BUILDFLAGS) -ldflags '-s -w -X github.com/sapcc/go-api-declarations/bininfo.binName=network-operator -X github.com/sapcc/go-api-declarations/bininfo.version=$(BININFO_VERSION) -X github.com/sapcc/go-api-declarations/bininfo.commit=$(BININFO_COMMIT_HASH) -X github.com/sapcc/go-api-declarations/bininfo.buildDate=$(BININFO_BUILD_DATE) $(GO_LDFLAGS)' -covermode=count -coverpkg=$(subst $(space),$(comma),$(GO_COVERPKGS)) $(GO_TESTFLAGS) $(GO_TESTPKGS)
Expand All @@ -273,13 +270,9 @@ check-addlicense: FORCE install-addlicense
@printf "\e[1;36m>> addlicense --check\e[0m\n"
@addlicense --check -- $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...))

check-reuse: FORCE install-reuse
@printf "\e[1;36m>> reuse lint\e[0m\n"
@if ! reuse lint -q; then reuse lint; fi
check-license-headers: FORCE check-addlicense

check-license-headers: FORCE check-addlicense check-reuse

__static-check: FORCE run-shellcheck run-golangci-lint run-modernize check-dependency-licenses check-license-headers
__static-check: FORCE run-shellcheck run-golangci-lint check-dependency-licenses check-license-headers

static-check: FORCE
@$(MAKE) --keep-going --no-print-directory __static-check
Expand All @@ -291,7 +284,7 @@ tidy-deps: FORCE
go mod tidy
go mod verify

license-headers: FORCE install-addlicense install-reuse
license-headers: FORCE install-addlicense
@printf "\e[1;36m>> addlicense (for license headers on source code files)\e[0m\n"
@printf "%s\0" $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...)) | $(XARGS) -0 -I{} bash -c 'year="$$(grep 'Copyright' {} | head -n1 | grep -E -o '"'"'[0-9]{4}(-[0-9]{4})?'"'"')"; if [[ -z "$$year" ]]; then year=$$(date +%Y); fi; gawk -i inplace '"'"'{if (display) {print} else {!/^\/\*/ && !/^\*/}}; {if (!display && $$0 ~ /^(package |$$)/) {display=1} else { }}'"'"' {}; addlicense -c "SAP SE or an SAP affiliate company" -s=only -y "$$year" -- {}; $(SED) -i '"'"'1s+// Copyright +// SPDX-FileCopyrightText: +'"'"' {}; '
@printf "\e[1;36m>> reuse annotate (for license headers on other files)\e[0m\n"
Expand All @@ -308,10 +301,6 @@ goimports: FORCE install-goimports
@printf "\e[1;36m>> goimports -w -local https://github.com/ironcore-dev/network-operator\e[0m\n"
@goimports -w -local github.com/ironcore-dev/network-operator $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...))

modernize: FORCE install-modernize
@printf "\e[1;36m>> modernize -fix ./...\e[0m\n"
@modernize -fix ./...

clean: FORCE
git clean -dxf build

Expand Down Expand Up @@ -344,11 +333,10 @@ help: FORCE
@printf "\e[1mPrepare\e[0m\n"
@printf " \e[36minstall-goimports\e[0m Install goimports required by goimports/static-check\n"
@printf " \e[36minstall-golangci-lint\e[0m Install golangci-lint required by run-golangci-lint/static-check\n"
@printf " \e[36minstall-modernize\e[0m Install modernize required by run-modernize/static-check\n"
@printf " \e[36minstall-shellcheck\e[0m Install shellcheck required by run-shellcheck/static-check\n"
@printf " \e[36minstall-typos\e[0m Install typos required by run-typos/static-check\n"
@printf " \e[36minstall-go-licence-detector\e[0m Install-go-licence-detector required by check-dependency-licenses/static-check\n"
@printf " \e[36minstall-addlicense\e[0m Install addlicense required by check-license-headers/license-headers/static-check\n"
@printf " \e[36minstall-reuse\e[0m Install reuse required by license-headers/check-reuse\n"
@printf " \e[36mprepare-static-check\e[0m Install any tools required by static-check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf " \e[36minstall-controller-gen\e[0m Install controller-gen required by static-check and build-all. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf " \e[36minstall-setup-envtest\e[0m Install setup-envtest required by check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
Expand All @@ -362,12 +350,11 @@ help: FORCE
@printf " \e[36mcheck\e[0m Run the test suite (unit tests and golangci-lint).\n"
@printf " \e[36mgenerate\e[0m Generate code for Kubernetes CRDs and deepcopy.\n"
@printf " \e[36mrun-golangci-lint\e[0m Install and run golangci-lint. Installing is used in CI, but you should probably install golangci-lint using your package manager.\n"
@printf " \e[36mrun-modernize\e[0m Install and run modernize. Installing is used in CI, but you should probably install modernize using your package manager.\n"
@printf " \e[36mrun-shellcheck\e[0m Install and run shellcheck. Installing is used in CI, but you should probably install shellcheck using your package manager.\n"
@printf " \e[36mrun-typos\e[0m Check for spelling errors using typos.\n"
@printf " \e[36mbuild/cover.out\e[0m Run tests and generate coverage report.\n"
@printf " \e[36mbuild/cover.html\e[0m Generate an HTML file with source code annotations from the coverage report.\n"
@printf " \e[36mcheck-addlicense\e[0m Check license headers in all non-vendored .go files with addlicense.\n"
@printf " \e[36mcheck-reuse\e[0m Check reuse compliance\n"
@printf " \e[36mcheck-license-headers\e[0m Run static code checks\n"
@printf " \e[36mstatic-check\e[0m Run static code checks\n"
@printf "\n"
Expand All @@ -376,7 +363,6 @@ help: FORCE
@printf " \e[36mlicense-headers\e[0m Add (or overwrite) license headers on all non-vendored source code files.\n"
@printf " \e[36mcheck-dependency-licenses\e[0m Check all dependency licenses using go-licence-detector.\n"
@printf " \e[36mgoimports\e[0m Run goimports on all non-vendored .go files\n"
@printf " \e[36mmodernize\e[0m Run modernize on all non-vendored .go files\n"
@printf " \e[36mclean\e[0m Run git clean.\n"

.PHONY: FORCE
2 changes: 1 addition & 1 deletion api/core/v1alpha1/acl_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type AccessControlListSpec struct {
// +optional
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`

// Name is the indentifier of the AccessControlList on the device.
// Name is the identifier of the AccessControlList on the device.
// Immutable.
// +required
// +kubebuilder:validation:MinLength=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ spec:
x-kubernetes-list-type: map
name:
description: |-
Name is the indentifier of the AccessControlList on the device.
Name is the identifier of the AccessControlList on the device.
Immutable.
maxLength: 63
minLength: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ spec:
x-kubernetes-list-type: map
name:
description: |-
Name is the indentifier of the AccessControlList on the device.
Name is the identifier of the AccessControlList on the device.
Immutable.
maxLength: 63
minLength: 1
Expand Down
Loading