f296056360
ci/woodpecker/tag/release Pipeline failed
## Why `node-lookup` output is handy for pivoting to Puppetboard, but there was no quick way to turn a list of hosts into Puppetboard node-page URLs, or to see when each host last ran Puppet. These two small tools close that gap and ship in the **same RPM** so they're available wherever `node-lookup` is. ## Changes - Add **`pburl`**: reads hostnames from args or piped `node-lookup` output (first field of each line, de-duped) and prints `<host> <puppetboard-node-page-url>`. - Add **`pblastreport`**: prints `<host>\t<last-report-time>\t<url>` using `report_timestamp` from the PuppetDB v4 `nodes` endpoint. Supports `--relative`/`-r` (relative age) and `--timezone`/`-z <IANA>` (default: local timezone). - Add **`internal/puppet`** package shared by both tools: config load, PuppetDB `nodes` query, Puppetboard URL construction (`<base>/node/<certname>`), and no-TTY-safe stdin host reading. - Add **`puppetboard_url`** config key (env `NODE_LOOKUP_PUPPETBOARD_URL`, default `https://puppetboard.k8s.syd1.au.unkin.net`) to the shared config so `config init`/`config show` scaffold it for the whole tool family. `node-lookup`'s own query behaviour is unchanged. - Build all three binaries individually (each is its own `main` package — a single `go build ./...` can't emit multiple mains) and generate per-binary bash/zsh/fish completions in the Makefile, `build-rpm.sh`, and nfpm spec. - Cross-compile and attach all three tools per os/arch in the release pipeline; extend `.gitignore`; `go mod tidy` promotes cobra/yaml to direct deps. - Document the tools, config key, and env var in `AGENTS.md`. ## Testing - `go test -race ./...` passes (new tests cover config precedence, `nodes` endpoint derivation, host-page URLs, `LookupNode`, stdin host parsing, and the report-time formatting incl. timezone/relative/edge cases). - Built the RPM locally and confirmed it installs all 3 binaries + 9 completion files. - Smoke-tested both tools end-to-end against a mock PuppetDB (timezone conversion, relative time, and error handling all correct). No cross-repo changes needed: the release reuses the existing `default` ServiceAccount and the artifactapi `rpm-internal` upload. Reviewed-on: #15 Co-authored-by: Ben Vincent <ben@unkin.net> Co-committed-by: Ben Vincent <ben@unkin.net>
142 lines
4.7 KiB
YAML
142 lines
4.7 KiB
YAML
when:
|
|
- event: tag
|
|
|
|
steps:
|
|
- name: test
|
|
image: golang:1.25
|
|
commands:
|
|
- go test -race ./...
|
|
backend_options:
|
|
kubernetes:
|
|
serviceAccountName: default
|
|
resources:
|
|
requests:
|
|
memory: 512Mi
|
|
cpu: 1
|
|
limits:
|
|
memory: 2Gi
|
|
cpu: 2
|
|
|
|
# Build all binaries into dist/ (consumed by the RPM step) plus the
|
|
# cross-platform binaries attached to the Gitea release. Each tool is a
|
|
# separate main package, so they are built individually per os/arch.
|
|
- name: build
|
|
image: git.unkin.net/unkin/almalinux9-gobuilder:20260606
|
|
commands:
|
|
- make build VERSION=${CI_COMMIT_TAG}
|
|
- |
|
|
for entry in "node-lookup:." "pburl:./cmd/pburl" "pblastreport:./cmd/pblastreport"; do
|
|
name="${entry%%:*}"; pkg="${entry##*:}"
|
|
for osarch in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64; do
|
|
GOOS="${osarch%/*}" GOARCH="${osarch#*/}" \
|
|
go build -ldflags="-s -w -X main.version=${CI_COMMIT_TAG}" \
|
|
-o "${name}-${osarch%/*}-${osarch#*/}" "${pkg}"
|
|
done
|
|
done
|
|
depends_on: [test]
|
|
backend_options:
|
|
kubernetes:
|
|
serviceAccountName: default
|
|
resources:
|
|
requests:
|
|
memory: 512Mi
|
|
cpu: 1
|
|
limits:
|
|
memory: 2Gi
|
|
cpu: 2
|
|
|
|
# Package the built binary + generated shell completions into an RPM.
|
|
- name: package
|
|
image: git.unkin.net/unkin/almalinux9-rpmbuilder:latest
|
|
commands:
|
|
- ./scripts/build-rpm.sh ${CI_COMMIT_TAG}
|
|
depends_on: [build]
|
|
backend_options:
|
|
kubernetes:
|
|
serviceAccountName: default
|
|
resources:
|
|
requests:
|
|
memory: 512Mi
|
|
cpu: 1
|
|
limits:
|
|
memory: 2Gi
|
|
cpu: 2
|
|
|
|
# Publish the RPM to the artifactapi local rpm repo (a real yum repo;
|
|
# repodata regenerates automatically).
|
|
- name: upload-rpm
|
|
image: git.unkin.net/unkin/almalinux9-base:20260606
|
|
commands:
|
|
- |
|
|
HOST="https://artifactapi.k8s.syd1.au.unkin.net"
|
|
REPO="rpm-internal"
|
|
for rpm in dist/*.rpm; do
|
|
FILE=$$(basename "$$rpm")
|
|
# artifactapi has no HEAD route (returns 405); probe with GET against
|
|
# the served path (RPMs are stored under Packages/) to avoid re-upload.
|
|
code=$$(curl -s -o /dev/null -w '%{http_code}' "$$HOST/api/v2/remotes/$$REPO/files/Packages/$$FILE" || true)
|
|
if [ "$$code" = "200" ]; then
|
|
echo "$$FILE already exists in $$REPO (HTTP $$code); skipping upload"
|
|
continue
|
|
fi
|
|
echo "Uploading $$FILE to $$REPO (existence probe returned $$code)"
|
|
curl -f -X PUT \
|
|
"$$HOST/api/v2/remotes/$$REPO/files/$$FILE" \
|
|
-H "Content-Type: application/x-rpm" \
|
|
--data-binary @"$$rpm"
|
|
done
|
|
depends_on: [package]
|
|
backend_options:
|
|
kubernetes:
|
|
serviceAccountName: default
|
|
resources:
|
|
requests:
|
|
memory: 128Mi
|
|
cpu: 100m
|
|
limits:
|
|
memory: 512Mi
|
|
cpu: 500m
|
|
|
|
# Cut a Gitea release with the cross-platform binaries attached.
|
|
- name: release
|
|
image: git.unkin.net/unkin/almalinux9-base:20260606
|
|
environment:
|
|
RELEASER_TOKEN:
|
|
from_secret: RELEASER_TOKEN
|
|
commands:
|
|
- |
|
|
curl --output /usr/local/bin/tea https://artifactapi.k8s.syd1.au.unkin.net/api/v1/remote/gitea-dl/tea/0.12.0/tea-0.12.0-linux-amd64 && chmod +x /usr/local/bin/tea
|
|
tea logins add --name gitea --url https://git.unkin.net --token "$${RELEASER_TOKEN}" --no-version-check
|
|
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
|
if [ -n "$PREV_TAG" ]; then
|
|
NOTES=$(git log "${PREV_TAG}..${CI_COMMIT_TAG}" --pretty=format:"- %s")
|
|
else
|
|
NOTES=$(git log --pretty=format:"- %s")
|
|
fi
|
|
tea releases create --tag "${CI_COMMIT_TAG}" --title "${CI_COMMIT_TAG}" --note "${NOTES}" --login gitea --repo "${CI_REPO}"
|
|
tea releases assets create "${CI_COMMIT_TAG}" \
|
|
node-lookup-linux-amd64 \
|
|
node-lookup-linux-arm64 \
|
|
node-lookup-darwin-amd64 \
|
|
node-lookup-darwin-arm64 \
|
|
pburl-linux-amd64 \
|
|
pburl-linux-arm64 \
|
|
pburl-darwin-amd64 \
|
|
pburl-darwin-arm64 \
|
|
pblastreport-linux-amd64 \
|
|
pblastreport-linux-arm64 \
|
|
pblastreport-darwin-amd64 \
|
|
pblastreport-darwin-arm64 \
|
|
--login gitea --repo "${CI_REPO}"
|
|
depends_on: [upload-rpm]
|
|
backend_options:
|
|
kubernetes:
|
|
serviceAccountName: default
|
|
resources:
|
|
requests:
|
|
memory: 128Mi
|
|
cpu: 100m
|
|
limits:
|
|
memory: 512Mi
|
|
cpu: 500m
|