Prepare configuration scope metadata

This commit is contained in:
2026-10-09 01:46:19 +00:00
parent a7960e5e94
commit 62b4a48e4f
8 changed files with 242 additions and 105 deletions

View File

@@ -6,17 +6,17 @@ import (
"strconv"
)
func newConfigSourcesCommand[C any](suite ConfigSuite[C]) (Command, error) {
func newConfigSourcesCommand[C any](prepared *preparedConfigSuite[C]) (Command, error) {
spec := CommandSpec[configInput[C]]{
Name: string(ConfigSources),
Summary: "List configuration sources used by a scope.",
Flags: configInputFlags(suite, "text"),
Flags: configInputFlags(prepared.suite, "text"),
CheckInput: func(input configInput[C]) error {
_, err := preflightConfig(suite, input, ConfigSources)
_, err := preflightConfig(prepared, input, ConfigSources)
return err
},
Run: func(invocation Invocation, input configInput[C]) Outcome {
return runConfigSources(invocation, suite, input)
return runConfigSources(invocation, prepared, input)
},
}
return NewCommand(spec)
@@ -43,17 +43,17 @@ type locationDTO struct {
Column int `yaml:"column"`
}
func runConfigSources[C any](invocation Invocation, suite ConfigSuite[C], input configInput[C]) Outcome {
func runConfigSources[C any](invocation Invocation, prepared *preparedConfigSuite[C], input configInput[C]) Outcome {
if err := invocation.Context.Err(); err != nil {
return Failure(err)
}
scopeNames, err := selectConfigScopes(suite, input, ConfigSources)
scopeNames, err := selectConfigScopes(prepared, input, ConfigSources)
if err != nil {
return Failure(err)
}
contexts := contextsForScopes(suite, input, scopeNames)
contexts := contextsForScopes(prepared, input, scopeNames)
name := scopeNames[0]
scope, ok := findConfigScope(suite.Scopes, name)
scope, ok := findConfigScope(prepared, name)
if !ok || scope.Acquire == nil {
return sourceReportFailure(fmt.Errorf("configuration scope %q has no acquisition callback", name), nil, false)
}