Prepare configuration scope metadata
This commit is contained in:
16
sources.go
16
sources.go
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user