homelab: add tf verbs + stack/git-crypt substrate
Adds the tf verb-group and the resolver substrate beneath it, continuing the v0.1 infra-loop build. - substrate: findInfraRoot (walk up to terragrunt.hcl + stacks/), stack→dir resolver, and repo/remote/git-crypt detection (preferRemote forgejo>origin, hasGitCryptAttr, gitCryptFlags) — the last is for `work` next. - tf plan/validate/fmt/force-unlock/apply, resolving the stack from cwd and delegating to scripts/tg (which owns state decrypt/encrypt, the Vault lock, and the ingress auth-comment check) rather than calling terragrunt directly. - tf apply is presence-coupled: claims stack:<name>, ALWAYS releases on exit (normal, error, or SIGINT/SIGTERM via sync.Once + signal handler) — fixing the documented ~200-claim leak — and prints an out-of-band reminder since CI applies canonically on push. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ed6f22fd53
commit
36d562c15c
8 changed files with 362 additions and 0 deletions
27
cli/cmd_tf_test.go
Normal file
27
cli/cmd_tf_test.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFirstPositional(t *testing.T) {
|
||||
cases := []struct {
|
||||
args []string
|
||||
wantName string
|
||||
wantRest []string
|
||||
}{
|
||||
{[]string{"vault"}, "vault", []string{}},
|
||||
{[]string{"--json", "vault"}, "vault", []string{"--json"}},
|
||||
{[]string{"vault", "abc-123"}, "vault", []string{"abc-123"}},
|
||||
{[]string{"--foo", "monitoring", "extra"}, "monitoring", []string{"--foo", "extra"}},
|
||||
{[]string{"--only-flags"}, "", []string{"--only-flags"}},
|
||||
}
|
||||
for _, c := range cases {
|
||||
gotName, gotRest := firstPositional(c.args)
|
||||
if gotName != c.wantName || !reflect.DeepEqual(gotRest, c.wantRest) {
|
||||
t.Errorf("firstPositional(%v) = (%q, %v), want (%q, %v)",
|
||||
c.args, gotName, gotRest, c.wantName, c.wantRest)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue