From 1bbf8c24ed533e7101bf73753f1aebcf682efba9 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Mon, 12 Oct 2026 19:20:43 +0200 Subject: [PATCH 1/6] Use actions-common. --- .github/workflows/build.yaml | 50 +++++++++++++++ .github/workflows/docker.yaml | 113 ---------------------------------- Dockerfile | 3 +- 3 files changed, 52 insertions(+), 114 deletions(-) create mode 100644 .github/workflows/build.yaml delete mode 100644 .github/workflows/docker.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..36a3b0f --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,50 @@ +--- +name: metal-stack component release +on: + pull_request: + branches: + - main + release: + types: + - published + push: + branches: + - main + +jobs: + draft: + uses: metal-stack/actions-common/.github/workflows/release-drafter.yaml@v1 + + go-build: + uses: metal-stack/actions-common/.github/workflows/go-build-multiarch.yaml@v1 + secrets: inherit + with: + platforms: | + [ + {"platform": "linux/amd64", "goos": "linux", "goarch": "amd64", "runner": "ubuntu-latest"}, + {"platform": "linux/arm64", "goos": "linux", "goarch": "arm64", "runner": "ubuntu-26.04-arm"}, + {"platform": "linux/arm/v7", "goos": "linux", "goarch": "arm", "runner": "ubuntu-26.04-arm"}, + {"build_only": true, "goos": "windows", "goarch": "amd64", "runner": "ubuntu-latest"}, + {"build_only": true, "goos": "darwin", "goarch": "amd64", "runner": "ubuntu-latest"} + ] + build-command: make cli GOARCH=$GOARCH GOOS=$GOOS + artifact-files: | + bin/metal* + + release-assets: + uses: metal-stack/actions-common/.github/workflows/release-assets.yaml@v1 + needs: + - go-build + with: + artifact-ids: ${{ needs.go-build.outputs.go-build-artifacts }} + files: | + ./bin/* + + gcp-bucket-push: + uses: metal-stack/actions-common/.github/workflows/gcp-bucket-push.yaml@v1 + secrets: inherit + needs: + - go-build + with: + artifact-ids: ${{ needs.go-build.outputs.go-build-artifacts }} + bucket: images.metal-pod.io diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml deleted file mode 100644 index ea661e5..0000000 --- a/.github/workflows/docker.yaml +++ /dev/null @@ -1,113 +0,0 @@ ---- -name: Docker Build Action -on: - pull_request: - branches: - - main - release: - types: - - published - push: - branches: - - main - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - draft: - uses: metal-stack/actions-common/.github/workflows/release-drafter.yaml@v1 - - go-build: - uses: metal-stack/actions-common/.github/workflows/go-build.yaml@v1 - secrets: inherit - with: - build: false - - build: - runs-on: ubuntu-latest - - strategy: - matrix: - os: - - linux - - windows - - darwin - arch: - - amd64 - - arm64 - exclude: - - os: linux - arch: arm64 - - os: windows - arch: arm64 - - steps: - - name: Checkout code - uses: actions/checkout@v7 - - - name: Setup Go - uses: actions/setup-go@v7 - with: - go-version-file: 'go.mod' - - - name: Make tag - run: | - [ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "TAG_NAME=$(echo $GITHUB_REF | awk -F / '{print $3}')-${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true - [ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "TAG_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV || true - [ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "TAG_NAME=latest" >> $GITHUB_ENV || true - - [ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "TARGET_BINARY_LOCATION=pull-requests/$(echo $GITHUB_REF | awk -F / '{print $3}')-${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true - [ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "TARGET_BINARY_LOCATION=${GITHUB_REF##*/}" >> $GITHUB_ENV || true - [ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "TARGET_BINARY_LOCATION=latest" >> $GITHUB_ENV || true - - - name: Build - run: | - make cli GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} - - - name: Log in to the container registry - uses: docker/login-action@v4 - with: - registry: ${{ env.REGISTRY }} - username: ${{ secrets.DOCKER_REGISTRY_USER }} - password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - if: ${{ matrix.os == 'linux' && matrix.arch == 'amd64' }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v4 - if: ${{ matrix.os == 'linux' && matrix.arch == 'amd64' }} - - - name: Build and push image - uses: docker/build-push-action@v7 - with: - context: . - push: true - sbom: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_NAME }} - if: ${{ matrix.os == 'linux' && matrix.arch == 'amd64' }} - - - name: Generate SBOM - uses: anchore/sbom-action@v0 - env: - SBOM_NAME: sbom-${{ matrix.os }}-${{ matrix.arch }}.json - with: - path: ./bin/ - format: spdx-json - artifact-name: ${{ env.SBOM_NAME }} - output-file: ./bin/${{ env.SBOM_NAME }} - - - name: Prepare upload - run: | - mkdir -p metal/${TARGET_BINARY_LOCATION} - sudo chown -R $(id -u):$(id -g) bin - cp bin/* metal/${TARGET_BINARY_LOCATION}/ - - - name: Upload Release Asset - uses: softprops/action-gh-release@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - files: | - bin/metal-* - bin/sbom-*.json - if: ${{ github.event_name == 'release' }} diff --git a/Dockerfile b/Dockerfile index 7b11f7e..4f311dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM alpine:3.24 +ARG TARGETARCH LABEL maintainer="metal-stack authors " -COPY bin/metalctlv2-linux-amd64 /metalctl +COPY bin/metalctlv2-linux-${TARGETARCH} /metalctl ENTRYPOINT ["/metalctl"] From 84ae8a72f64c57b2d4111f006cab71d51635273c Mon Sep 17 00:00:00 2001 From: Gerrit Date: Mon, 12 Oct 2026 19:37:55 +0200 Subject: [PATCH 2/6] Add darwin arm. --- .github/workflows/build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 36a3b0f..21ead81 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,7 +25,8 @@ jobs: {"platform": "linux/arm64", "goos": "linux", "goarch": "arm64", "runner": "ubuntu-26.04-arm"}, {"platform": "linux/arm/v7", "goos": "linux", "goarch": "arm", "runner": "ubuntu-26.04-arm"}, {"build_only": true, "goos": "windows", "goarch": "amd64", "runner": "ubuntu-latest"}, - {"build_only": true, "goos": "darwin", "goarch": "amd64", "runner": "ubuntu-latest"} + {"build_only": true, "goos": "darwin", "goarch": "amd64", "runner": "ubuntu-latest"}, + {"build_only": true, "goos": "darwin", "goarch": "arm64", "runner": "ubuntu-26.04-arm"} ] build-command: make cli GOARCH=$GOARCH GOOS=$GOOS artifact-files: | From f7d8935b3286d8e0c15e34138869233275ee486c Mon Sep 17 00:00:00 2001 From: Gerrit Date: Mon, 12 Oct 2026 19:43:44 +0200 Subject: [PATCH 3/6] Fix arm build. --- .github/workflows/build.yaml | 2 +- Makefile | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 21ead81..c9acf0b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ jobs: {"build_only": true, "goos": "darwin", "goarch": "amd64", "runner": "ubuntu-latest"}, {"build_only": true, "goos": "darwin", "goarch": "arm64", "runner": "ubuntu-26.04-arm"} ] - build-command: make cli GOARCH=$GOARCH GOOS=$GOOS + build-command: make cli artifact-files: | bin/metal* diff --git a/Makefile b/Makefile index 043a985..5b41c4a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -GOOS := linux -GOARCH := amd64 +GOOS ?= linux +GOARCH ?= amd64 BINARY := metalctlv2-$(GOOS)-$(GOARCH) TAGS := -tags 'netgo' SHA := $(shell git rev-parse --short=8 HEAD) @@ -9,7 +9,7 @@ BUILDDATE := $(shell date --iso-8601=seconds) VERSION := $(or ${VERSION},$(shell git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD || git rev-parse --short HEAD)) ifeq ($(GOOS),linux) - LINKMODE := -linkmode external -extldflags '-static -s -w' + LINKMODE := -s -w TAGS := -tags 'osusergo netgo static_build' endif @@ -23,7 +23,7 @@ all: test cli markdown .PHONY: cli cli: - go build \ + CGO_ENABLED=0 go build \ $(TAGS) \ -ldflags \ "$(LINKMODE)" \ From bf2ed7f530ec3f5ba2707ebd66174fcc2a366905 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Mon, 12 Oct 2026 19:55:42 +0200 Subject: [PATCH 4/6] Attempt fix. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4f311dd..967c112 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM alpine:3.24 ARG TARGETARCH LABEL maintainer="metal-stack authors " -COPY bin/metalctlv2-linux-${TARGETARCH} /metalctl +COPY --chmod=0755 metalctlv2-linux-${TARGETARCH} /metalctl ENTRYPOINT ["/metalctl"] From 6fa65d82c81ca984631f8fe450ba8505c58ead96 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Mon, 12 Oct 2026 20:15:57 +0200 Subject: [PATCH 5/6] Update README. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6c17657..5c9696f 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ This is the official V2 CLI for accessing the API of [metal-stack.io](https://me Download locations: - [metalctlv2-linux-amd64](https://github.com/metal-stack/cli/releases/latest/download/metalctlv2-linux-amd64) +- [metalctlv2-linux-arm64](https://github.com/metal-stack/cli/releases/latest/download/metalctlv2-linux-arm64) +- [metalctlv2-linux-arm](https://github.com/metal-stack/cli/releases/latest/download/metalctlv2-linux-arm) (32-bit ARM, armv7) - [metalctlv2-darwin-amd64](https://github.com/metal-stack/cli/releases/latest/download/metalctlv2-darwin-amd64) - [metalctlv2-darwin-arm64](https://github.com/metal-stack/cli/releases/latest/download/metalctlv2-darwin-arm64) - [metalctlv2-windows-amd64](https://github.com/metal-stack/cli/releases/latest/download/metalctlv2-windows-amd64) @@ -25,6 +27,8 @@ chmod +x metalctlv2-linux-amd64 sudo mv metalctlv2-linux-amd64 /usr/local/bin/metalctlv2 ``` +Choose according to your processor architecture: For ARM systems use `metalctlv2-linux-arm64`, for ARM V7 systems (e.g. Raspberry Pi) use `metalctlv2-linux-arm` instead of `metalctlv2-linux-amd64`. + ### Installation on MacOS For x86 based Macs: From 383bdc25934fd88decc861dd3600a8b2a7bf0835 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Mon, 12 Oct 2026 20:27:28 +0200 Subject: [PATCH 6/6] Add spell check. --- .github/workflows/build.yaml | 3 +++ _typos.toml | 7 +++++++ cmd/tableprinters/switch_test.go | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 _typos.toml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c9acf0b..a41b68e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,6 +15,9 @@ jobs: draft: uses: metal-stack/actions-common/.github/workflows/release-drafter.yaml@v1 + spell-check: + uses: metal-stack/actions-common/.github/workflows/spell-check.yaml@v1 + go-build: uses: metal-stack/actions-common/.github/workflows/go-build-multiarch.yaml@v1 secrets: inherit diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 0000000..5e8d9b2 --- /dev/null +++ b/_typos.toml @@ -0,0 +1,7 @@ +[files] +extend-exclude = ["go.mod", "go.sum"] + +[default.extend-words] +leafs = "leafs" +PN = "PN" +HPE = "HPE" diff --git a/cmd/tableprinters/switch_test.go b/cmd/tableprinters/switch_test.go index 8fdd53c..02ef183 100644 --- a/cmd/tableprinters/switch_test.go +++ b/cmd/tableprinters/switch_test.go @@ -274,7 +274,7 @@ func TestTablePrinter_SwitchTable(t *testing.T) { {"r02leaf01", "partition-a", "rack02", apiv2.SwitchOSVendor_SWITCH_OS_VENDOR_UNSPECIFIED.String(), "", color.RedString(dot), "1h ago"}, // status red because last error came later than last sync {"r02leaf02", "partition-a", "rack02", "", "", color.RedString(dot), "10m ago"}, // status red because last sync is too long ago {"r03leaf01", "partition-a", "rack03", "", "", color.YellowString(dot), "0s ago"}, // status yellow because last sync duration was too long - {"r03leaf02", "partition-a", "rack03", "", "", color.YellowString(dot), ""}, // status yellow because not all connceted ports are up + {"r03leaf02", "partition-a", "rack03", "", "", color.YellowString(dot), ""}, // status yellow because not all connected ports are up }, }, {