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

@@ -6,10 +6,21 @@ import (
"path/filepath"
"testing"
configkit "go.maximumdirect.net/configkit"
"gitea.maximumdirect.net/eric/narratio/internal/config"
configkit "go.maximumdirect.net/configkit"
)
func TestMain(m *testing.M) {
dir, err := os.MkdirTemp("", "narratio-app-test-*")
if err != nil {
panic(err)
}
conventionalSecretsDirectory = filepath.Join(dir, "secrets")
code := m.Run()
_ = os.RemoveAll(dir)
os.Exit(code)
}
// restoreEnvAfterTest clears names for a test and restores both their prior
// values and their set/unset state during cleanup.
func restoreEnvAfterTest(t *testing.T, names ...string) {
@@ -51,24 +62,14 @@ func mustWriteSecretFile(t *testing.T, path, value string) {
}
func commandDependenciesForPipelineCandidates(candidates ...string) commandDependencies {
ownedCandidates := append([]string(nil), candidates...)
return commandDependencies{resolvePipelineConfigPath: func(flagValue string) (string, error) {
return resolvePipelineConfigPathWithCandidates(flagValue, ownedCandidates)
}}
search := configkit.SearchPaths(candidates...)
return commandDependencies{pipelineSearch: &search}
}
func guardedMissingPipelineDiscovery(t *testing.T) (commandDependencies, string, pipelineExecutor) {
t.Helper()
candidate := filepath.Join(t.TempDir(), "missing-pipeline.yml")
deps := commandDependenciesForPipelineCandidates(candidate)
deps.loadSecretsDir = func(string) (*configkit.SecretsReport, error) {
t.Fatal("secret bootstrap continued after pipeline discovery failed")
return nil, nil
}
deps.loadPipelineConfig = func(string, config.PipelineLoadOptions) (*config.PipelineConfig, error) {
t.Fatal("typed pipeline loading continued after pipeline discovery failed")
return nil, nil
}
executor := func(context.Context, *config.Config, BoundedPlan, RunOptions) (*RunSummary, error) {
t.Fatal("pipeline execution continued after pipeline discovery failed")
return nil, nil