Use native pipeline discovery and independent secrets bootstrap

This commit is contained in:
2026-11-17 22:06:29 +00:00
parent 341fe93e3b
commit 6593ccbeaf
21 changed files with 208 additions and 270 deletions

View File

@@ -11,8 +11,8 @@ import (
"strings"
"testing"
configkit "go.maximumdirect.net/configkit"
"gitea.maximumdirect.net/eric/narratio/internal/config"
configkit "go.maximumdirect.net/configkit"
)
func TestConfigCommandHelpAndDispatch(t *testing.T) {
@@ -339,6 +339,7 @@ func TestConfigDiffBootstrapsSecretsOnceForBothOverlays(t *testing.T) {
}
mustWriteSecretFile(t, filepath.Join(secretsDir, secretName), "diff-secret-must-not-appear\n")
bootstrapCalls := 0
var loadedPaths []string
var diagnostics bytes.Buffer
deps := commandDependencies{loadSecretsDir: func(got string) (*configkit.SecretsReport, error) {
bootstrapCalls++
@@ -347,15 +348,24 @@ func TestConfigDiffBootstrapsSecretsOnceForBothOverlays(t *testing.T) {
}
return configkit.LoadSecretsIntoEnvironment(got)
}, diagnostics: &diagnostics}
search := configkit.SearchPaths(pipelinePath)
deps.pipelineSearch = &search
deps.loadPipelineConfig = func(path string, opts config.PipelineLoadOptions) (*config.PipelineConfig, error) {
loadedPaths = append(loadedPaths, path)
return config.LoadPipelineWithOptions(path, opts)
}
if err := configDiffWithDependencies(context.Background(), []string{
"production", "testing", "--config", pipelinePath, "--secrets-dir", secretsDir,
"production", "testing", "--secrets-dir", secretsDir,
}, io.Discard, deps); err != nil {
t.Fatalf("config diff: %v", err)
}
if bootstrapCalls != 1 {
t.Fatalf("bootstrap calls = %d, want 1", bootstrapCalls)
}
if len(loadedPaths) != 2 || loadedPaths[0] != "" || loadedPaths[1] != pipelinePath {
t.Fatalf("pipeline load paths = %q, want discovery then selected root %q", loadedPaths, pipelinePath)
}
if got := diagnostics.String(); strings.Count(got, `name="`+secretName+`"`) != 1 {
t.Fatalf("bootstrap report count = %d, want 1; diagnostics = %q", strings.Count(got, `name="`+secretName+`"`), got)
}