Expose configuration metadata and findings

This commit is contained in:
2026-11-07 04:32:24 +00:00
parent 0183022a28
commit da120c2dd4
15 changed files with 179 additions and 35 deletions

View File

@@ -15,6 +15,7 @@ import (
type scopeMetadata struct {
Name string `json:"name"`
Operations []Operation `json:"operations"`
Features []string `json:"features,omitempty"`
}
type scopeInventory struct {
@@ -188,6 +189,7 @@ func captureSuite[I, S any](suite Suite[I, S]) *preparedSuite[I, S] {
prepared.inventory.Scopes = append(prepared.inventory.Scopes, scopeMetadata{
Name: scope.scope.Name,
Operations: append([]Operation(nil), scope.scope.Operations...),
Features: featureNames(scope.scope.Features),
})
}
return prepared
@@ -253,12 +255,32 @@ func joinNames(names []string) string {
return strings.Join(ordered, ", ")
}
var scopeInventoryTemplate = template.Must(commandkit.ParseTextTemplate("scopes", `{{range .Scopes}}{{.Name}}: {{range $index, $operation := .Operations}}{{if $index}}, {{end}}{{$operation}}{{end}}
func featureNames(features ScopeFeatures) []string {
var names []string
if features.PathDiscovery {
names = append(names, "path_discovery")
}
if features.PathShow {
names = append(names, "path_show")
}
if features.Overrides {
names = append(names, "overrides")
}
return names
}
var scopeInventoryTemplate = template.Must(commandkit.ParseTextTemplate("scopes", `{{range .Scopes}}{{.Name}}: {{range $index, $operation := .Operations}}{{if $index}}, {{end}}{{$operation}}{{end}}{{if .Features}} (features: {{range $index, $feature := .Features}}{{if $index}}, {{end}}{{$feature}}{{end}}){{end}}
{{end}}`, nil))
func newConfigScopesCommand[I, S any](prepared *preparedSuite[I, S]) commandkit.Command {
var description strings.Builder
for _, scope := range prepared.inventory.Scopes {
if len(scope.Features) > 0 {
fmt.Fprintf(&description, "%s: %s\n", scope.Name, strings.Join(scope.Features, ", "))
}
}
return commandkit.NewCommand(commandkit.CommandSpec[struct{}]{
Name: "scopes", Summary: "List configuration scopes and supported operations.",
Name: "scopes", Summary: "List configuration scopes, operations, and supported features.", Description: description.String(),
Run: func(invocation commandkit.Invocation, _ struct{}) commandkit.Outcome {
_ = invocation.Reporter().Report(commandkit.Report{Value: prepared.inventory, TextTemplate: scopeInventoryTemplate})
return commandkit.Success()