Begin evolving the existing infra/cli into the agent-facing "homelab" CLI decided in the design/grilling session: one composable, JSON-capable surface for the operations agents run over and over (mined from 51k commands across 2,225 past sessions; the infra inner-loop is ~29% of them). v0.1 targets that loop — work/tf/claim — and ships here, in place, in infra/cli. This first slice: - command registry + dispatcher (longest-prefix verb matching) and a `manifest`/`manifest --json` progressive-discovery entrypoint; every verb declares a read|write tier so write-gating can be added later (everything is allowed for now). - claim/release verbs wrapping the existing presence script (not reimplemented), with label-taxonomy validation. - main() front-dispatches the homelab verb surface but falls through to the legacy webhook -use-case path verbatim, so the in-cluster infra-cli image is unaffected. - fix a pre-existing vet error (glog.Infof missing format directive) that blocked `go test`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
24 lines
625 B
Go
24 lines
625 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestValidateLabelAcceptsTaxonomy(t *testing.T) {
|
|
good := []string{
|
|
"stack:vault", "service:health", "node:k8s-node1", "db:pg-cluster",
|
|
"infra:gpu-operator", "host:proxmox-1", "pvc:dbaas/data",
|
|
}
|
|
for _, l := range good {
|
|
if err := validateLabel(l); err != nil {
|
|
t.Errorf("validateLabel(%q) = %v, want nil", l, err)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestValidateLabelRejectsBadLabels(t *testing.T) {
|
|
bad := []string{"vault", "stack:", "bogus:x", ":x", "stack", ""}
|
|
for _, l := range bad {
|
|
if err := validateLabel(l); err == nil {
|
|
t.Errorf("validateLabel(%q) = nil, want error", l)
|
|
}
|
|
}
|
|
}
|