9 Commits

Author SHA1 Message Date
benvin 554e2e4f9c Merge pull request 'ci: add buildkit_config CA trust for artifactapi push' (#5) from benvin/buildx-ca-config into main
Reviewed-on: #5
2026-08-15 18:47:15 +10:00
unkin-agent 245a46aa5d ci: add buildkit_config CA trust for artifactapi push
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
2026-08-15 18:31:01 +10:00
benvin e86b24f493 Merge pull request 'ci: use CA-baked plugin-docker-buildx image for artifactapi push' (#4) from benvin/buildx-ca-plugin-image into main
Reviewed-on: #4
2026-08-15 18:21:10 +10:00
unkin-agent 749059d235 ci: use CA-baked plugin-docker-buildx image for artifactapi push
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
The upstream woodpeckerci/plugin-docker-buildx image does not trust the
internal CA, so pushes/pulls against artifactapi.k8s.syd1.au.unkin.net
fail. Swap both the docker.yaml push step (docker-encapi) and the
build.yaml PR dry-run step to the custom CA-baked image published at
artifactapi.k8s.syd1.au.unkin.net/docker-internal/plugin-docker-buildx:latest.
2026-08-15 18:04:16 +10:00
benvin 17f043d856 Merge pull request 'ci: push images to artifactapi registry instead of gitea' (#3) from benvin/push-artifactapi into main
Reviewed-on: #3
2026-07-30 20:56:25 +10:00
unkinben 4d8ec0f54c ci: push images to artifactapi registry instead of gitea
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
Hard switch of the docker push target from the Gitea registry to the
artifactapi local docker registry (docker-internal); the Gitea VM and its
registry are being retired. Drops the droneci/DRONECI_PASSWORD creds since
artifactapi accepts unauthenticated in-cluster pushes. Also updates the README image path.

Claude-Session: https://claude.ai/code/session_015ur3i7D2azsMAWTSVABApv
2026-07-30 00:34:59 +10:00
benvin 1dc02ce5cf Merge pull request 'fix: add missing cmd/ (gitignore excluded source dirs)' (#2) from benvin/fix-missing-cmd into main
ci/woodpecker/tag/release Pipeline was successful
ci/woodpecker/tag/docker Pipeline was successful
Reviewed-on: #2
2026-07-05 17:18:26 +10:00
unkinben 2946db9b49 fix pre-commit go-vet for multi-package layout
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
The dnephin go-vet hook runs 'go vet' at the repo root, which has no Go files
(all live under cmd/, internal/, pkg/), failing with 'no Go files'. Replace it
with a local 'go vet ./...' hook, mirroring artifactapi.
2026-07-05 17:11:55 +10:00
unkinben 7e9fec60d4 fix: add missing cmd/ (gitignore was excluding source dirs)
ci/woodpecker/pr/pre-commit Pipeline failed
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
The initial commit's .gitignore had unanchored 'encapi' and 'encapi-cli'
patterns intended for built binaries; they also matched the cmd/encapi and
cmd/encapi-cli source directories, so those were silently never committed. The
tag build then failed with 'stat /build/cmd/encapi: directory not found'.

- anchor the binary ignores to the repo root (/encapi, /encapi-cli)
- add the cmd/encapi (server) and cmd/encapi-cli (CLI) main packages
2026-07-05 17:04:18 +10:00
7 changed files with 89 additions and 12 deletions
+4 -2
View File
@@ -2,5 +2,7 @@
/dist/
*.rpm
*.zip
encapi
encapi-cli
# Root-level dev binaries only — anchored so cmd/encapi and cmd/encapi-cli
# (the source packages) are NOT ignored.
/encapi
/encapi-cli
+13 -1
View File
@@ -6,10 +6,22 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
- id: go-vet
- id: go-mod-tidy
# encapi has no root-level Go files (all under cmd/, internal/, pkg/), so the
# dnephin go-vet hook (which runs `go vet` at the repo root) fails with
# "no Go files". Vet the whole module instead, mirroring artifactapi.
- repo: local
hooks:
- id: go-vet
name: go vet
entry: go vet ./...
language: system
types: [go]
pass_filenames: false
+2 -2
View File
@@ -3,7 +3,7 @@ when:
steps:
- name: docker-build
image: woodpeckerci/plugin-docker-buildx
image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/plugin-docker-buildx:latest
settings:
repo: git.unkin.net/unkin/encapi
repo: artifactapi.k8s.syd1.au.unkin.net/docker-internal/encapi
dry_run: true
+6 -6
View File
@@ -4,15 +4,15 @@ when:
steps:
- name: docker-encapi
image: woodpeckerci/plugin-docker-buildx
image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/plugin-docker-buildx:latest
settings:
registry: git.unkin.net
repo: git.unkin.net/unkin/encapi
registry: artifactapi.k8s.syd1.au.unkin.net
repo: artifactapi.k8s.syd1.au.unkin.net/docker-internal/encapi
build_args:
VERSION: ${CI_COMMIT_TAG}
username: droneci
password:
from_secret: DRONECI_PASSWORD
buildkit_config: |
[registry."artifactapi.k8s.syd1.au.unkin.net"]
ca = ["/etc/docker/certs.d/artifactapi.k8s.syd1.au.unkin.net/ca.crt"]
tags:
- ${CI_COMMIT_TAG}
- latest
+1 -1
View File
@@ -93,7 +93,7 @@ make test-short # skip container-backed DB tests
## Releases
- **`encapi` server image** — tagging `vX.Y.Z` builds and pushes
`git.unkin.net/unkin/encapi:{tag,latest}` (distroless).
`artifactapi.k8s.syd1.au.unkin.net/docker-internal/encapi:{tag,latest}` (distroless).
- **`encapi-cli` RPM** — the same tag builds an RPM (nfpm) and publishes it to
the ArtifactAPI `rpm-internal` repo. Installs `encapi-cli`, the `encapi-enc`
Puppet wrapper, and `/etc/encapi/enc.conf`.
+13
View File
@@ -0,0 +1,13 @@
// Command encapi-cli manages the Puppet ENC via the encapi HTTP API. Puppet's
// exec node_terminus calls `encapi-cli classify <certname>`.
package main
import (
"os"
"git.unkin.net/unkin/encapi/internal/cli"
)
func main() {
os.Exit(cli.Run(os.Args[1:], cli.LoadEnv(), os.Stdout, os.Stderr))
}
+50
View File
@@ -0,0 +1,50 @@
// Command encapi is the ENC HTTP server: it serves Puppet's node classification
// documents and the read/write API backing the CLI and Terraform provider.
package main
import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"
"git.unkin.net/unkin/encapi/internal/config"
"git.unkin.net/unkin/encapi/internal/database"
"git.unkin.net/unkin/encapi/internal/distro"
"git.unkin.net/unkin/encapi/internal/server"
)
var version = "dev"
func main() {
slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stdout, nil)))
slog.Info("starting encapi", "version", version)
cfg, err := config.Load()
if err != nil {
slog.Error("load config", "err", err)
os.Exit(1)
}
db, err := database.New(cfg.DatabaseDSN())
if err != nil {
slog.Error("connect database", "err", err)
os.Exit(1)
}
defer db.Close()
if cfg.WriteToken == "" {
slog.Warn("ENCAPI_WRITE_TOKEN is not set; write endpoints are disabled")
}
srv := server.New(db, distro.New(cfg.DistroAPIURL), cfg.WriteToken)
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
if err := srv.ListenAndServe(ctx, cfg.ListenAddr); err != nil {
slog.Error("server", "err", err)
os.Exit(1)
}
}