Skip to content

Commit b7f8f5c

Browse files
committed
go-makefile-maker and fix issues
1 parent 07660fe commit b7f8f5c

File tree

18 files changed

+200
-42
lines changed

18 files changed

+200
-42
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#.git/
99
/.github/
1010
/.goreleaser.yml
11+
/.idea/
1112
/.vscode/
1213
/CONTRIBUTING.md
1314
/Dockerfile

.github/workflows/checks.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ name: Checks
1818
permissions:
1919
checks: write
2020
contents: read
21-
pull-requests: read
2221
jobs:
2322
checks:
2423
name: Checks
@@ -42,13 +41,11 @@ jobs:
4241
- name: Dependency Licenses Review
4342
run: make check-dependency-licenses
4443
- name: Check for spelling errors
45-
uses: reviewdog/action-misspell@v1
46-
with:
47-
exclude: ./vendor/*
48-
fail_on_error: true
49-
github_token: ${{ secrets.GITHUB_TOKEN }}
50-
ignore: importas
51-
reporter: github-check
44+
uses: crate-ci/typos@v1
45+
env:
46+
CLICOLOR: "1"
47+
- name: Delete typos binary
48+
run: rm typos
5249
- name: Check if source code files have license header
5350
run: make check-addlicense
5451
- name: REUSE Compliance Check
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Cleanup GHCR Images
5+
"on":
6+
push:
7+
branches:
8+
- main
9+
workflow_dispatch: {}
10+
permissions:
11+
contents: read
12+
packages: write
13+
jobs:
14+
cleanup:
15+
name: Cleanup old container images in GHCR
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Delete untagged GHCR images
19+
uses: actions/delete-package-versions@v5
20+
with:
21+
package-name: 'openstack-hypervisor-operator'
22+
package-type: 'container'
23+
min-versions-to-keep: 1
24+
delete-only-untagged-versions: 'true'
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
################################################################################
2+
# This file is AUTOGENERATED with <https://github.com/sapcc/go-makefile-maker> #
3+
# Edit Makefile.maker.yaml instead. #
4+
################################################################################
5+
6+
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company
7+
# SPDX-License-Identifier: Apache-2.0
8+
9+
name: Container Registry GHCR
10+
"on":
11+
push:
12+
branches:
13+
- main
14+
workflow_dispatch: {}
15+
permissions:
16+
contents: read
17+
packages: write
18+
jobs:
19+
build-and-push-image:
20+
name: Push container to ghcr.io
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Check out code
24+
uses: actions/checkout@v6
25+
- name: Log in to the Container registry
26+
uses: docker/login-action@v3
27+
with:
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
- name: Extract metadata (tags, labels) for Docker
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: ghcr.io/${{ github.repository }}
36+
tags: |
37+
# https://github.com/docker/metadata-action#typeedge
38+
type=edge
39+
# https://github.com/docker/metadata-action#latest-tag
40+
type=raw,value=latest,enable={{is_default_branch}}
41+
# https://github.com/docker/metadata-action#typesemver
42+
type=semver,pattern={{raw}}
43+
type=semver,pattern=v{{major}}.{{minor}}
44+
type=semver,pattern=v{{major}}
45+
- name: Set up QEMU
46+
uses: docker/setup-qemu-action@v3
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
- name: Build and push Docker image
50+
uses: docker/build-push-action@v6
51+
with:
52+
context: .
53+
labels: ${{ steps.meta.outputs.labels }}
54+
platforms: linux/amd64
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}

.github/workflows/publish-helm.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Publish Helm Chart GHCR
5+
"on":
6+
push:
7+
branches:
8+
- main
9+
paths:
10+
- 'charts/**'
11+
workflow_dispatch: {}
12+
13+
14+
jobs:
15+
publish-chart:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write # Required for pushing the repository
19+
packages: write # Required to push to GHCR
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v5
24+
25+
- name: Install Helm
26+
uses: azure/[email protected]
27+
28+
- name: Bump Helm Chart
29+
uses: pluralsh/[email protected]
30+
with:
31+
path: ./charts/kvm-node-agent/
32+
release: "0.1.0"
33+
branch: main
34+
github-token: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Package Helm chart
37+
run: |
38+
helm package ./charts/kvm-node-agent
39+
40+
- name: Log in to GHCR
41+
run: |
42+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
43+
44+
- name: Push Helm chart to GHCR
45+
run: |
46+
CHART_NAME=kvm-node-agent
47+
CHART_VERSION=$(grep "version:" ./charts/${CHART_NAME}/Chart.yaml | awk '{print $2}')
48+
helm push "${CHART_NAME}-${CHART_VERSION}.tgz" "oci://ghcr.io/${{ github.repository_owner }}/${CHART_NAME}/charts"

.golangci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ linters:
5656
- ineffassign
5757
- intrange
5858
- iotamixing
59-
- misspell
6059
- modernize
6160
- nilerr
6261
- nolintlint
@@ -147,7 +146,7 @@ linters:
147146
require-specific: true
148147
modernize:
149148
disable:
150-
# omitzero requires removing omitempty tags in kubernetes api struct types which are nested, which is intepreted by controller-gen and breaks the CRDs.
149+
# omitzero requires removing omitempty tags in kubernetes api struct types which are nested, which is interpreted by controller-gen and breaks the CRDs.
151150
- omitzero
152151
perfsprint:
153152
# modernize generates nicer fix code

.typos.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-FileCopyrightText: 2025 SAP SE
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
[default.extend-words]
6+
7+
[files]
8+
extend-exclude = [
9+
"go.mod",
10+
]

Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ install-golangci-lint: FORCE
5656
@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
5757

5858
install-shellcheck: FORCE
59-
@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
59+
@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
60+
61+
install-typos: FORCE
62+
@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
6063

6164
install-go-licence-detector: FORCE
6265
@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
@@ -67,7 +70,7 @@ install-addlicense: FORCE
6770
install-reuse: FORCE
6871
@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
6972

70-
prepare-static-check: FORCE install-goimports install-golangci-lint install-shellcheck install-go-licence-detector install-addlicense install-reuse
73+
prepare-static-check: FORCE install-goimports install-golangci-lint install-shellcheck install-typos install-go-licence-detector install-addlicense install-reuse
7174

7275
install-controller-gen: FORCE
7376
@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
@@ -95,7 +98,7 @@ build/manager: FORCE generate
9598
env $(GO_BUILDENV) go build $(GO_BUILDFLAGS) -ldflags '-s -w -X github.com/sapcc/go-api-declarations/bininfo.binName=manager -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/manager ./cmd
9699

97100
DESTDIR =
98-
ifeq ($(shell uname -s),Darwin)
101+
ifeq ($(UNAME_S),Darwin)
99102
PREFIX = /usr/local
100103
else
101104
PREFIX = /usr
@@ -135,6 +138,10 @@ run-shellcheck: FORCE install-shellcheck
135138
@printf "\e[1;36m>> shellcheck\e[0m\n"
136139
@find . -type f \( -name '*.bash' -o -name '*.ksh' -o -name '*.zsh' -o -name '*.sh' -o -name '*.shlib' \) -exec shellcheck {} +
137140

141+
run-typos: FORCE install-typos
142+
@printf "\e[1;36m>> typos\e[0m\n"
143+
@typos
144+
138145
build/cover.out: FORCE generate install-setup-envtest | build
139146
@printf "\e[1;36m>> Running tests\e[0m\n"
140147
KUBEBUILDER_ASSETS=$$(setup-envtest use 1.34 -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=kvm-node-agent -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)
@@ -216,6 +223,7 @@ help: FORCE
216223
@printf " \e[36minstall-goimports\e[0m Install goimports required by goimports/static-check\n"
217224
@printf " \e[36minstall-golangci-lint\e[0m Install golangci-lint required by run-golangci-lint/static-check\n"
218225
@printf " \e[36minstall-shellcheck\e[0m Install shellcheck required by run-shellcheck/static-check\n"
226+
@printf " \e[36minstall-typos\e[0m Install typos required by run-typos/static-check\n"
219227
@printf " \e[36minstall-go-licence-detector\e[0m Install-go-licence-detector required by check-dependency-licenses/static-check\n"
220228
@printf " \e[36minstall-addlicense\e[0m Install addlicense required by check-license-headers/license-headers/static-check\n"
221229
@printf " \e[36minstall-reuse\e[0m Install reuse required by license-headers/check-reuse\n"
@@ -233,6 +241,7 @@ help: FORCE
233241
@printf " \e[36mgenerate\e[0m Generate code for Kubernetes CRDs and deepcopy.\n"
234242
@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"
235243
@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"
244+
@printf " \e[36mrun-typos\e[0m Check for spelling errors using typos.\n"
236245
@printf " \e[36mbuild/cover.out\e[0m Run tests and generate coverage report.\n"
237246
@printf " \e[36mbuild/cover.html\e[0m Generate an HTML file with source code annotations from the coverage report.\n"
238247
@printf " \e[36mcheck-addlicense\e[0m Check license headers in all non-vendored .go files with addlicense.\n"

Makefile.maker.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ githubWorkflow:
3636
securityChecks:
3737
enabled: true
3838
queries: security-extended
39+
pushContainerToGhcr:
40+
enabled: true
41+
platforms: "linux/amd64"
42+
tagStrategy:
43+
- edge
44+
- latest
45+
- semver
46+
license:
47+
enabled: true
3948

4049
metadata:
4150
url: https://github.com/cobaltcore-dev/kvm-node-agent

charts/kvm-node-agent/crds/migration-crd.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
22
kind: CustomResourceDefinition
33
metadata:
44
annotations:
5-
controller-gen.kubebuilder.io/version: v0.17.2
5+
controller-gen.kubebuilder.io/version: v0.19.0
66
name: migrations.kvm.cloud.sap
77
spec:
88
group: kvm.cloud.sap
@@ -141,7 +141,13 @@ spec:
141141
type: string
142142
type:
143143
type: string
144+
required:
145+
- started
144146
type: object
147+
required:
148+
- metadata
149+
- spec
150+
- status
145151
type: object
146152
served: true
147153
storage: true

0 commit comments

Comments
 (0)