Add namespace and collection inventories
This commit is contained in:
@@ -127,6 +127,8 @@ type loaded struct {
|
||||
backendIDs []string
|
||||
profileIDs []string
|
||||
promptIDs []domain.PromptIdentity
|
||||
namespaces map[string][]string
|
||||
collections []CollectionIdentity
|
||||
}
|
||||
|
||||
type resourceBases struct {
|
||||
@@ -266,9 +268,38 @@ func load(main configkit.Input, underlays []configkit.Underlay) (*loaded, error)
|
||||
for _, id := range sortedKeys(state.prompts) {
|
||||
state.promptIDs = append(state.promptIDs, domain.PromptIdentity{ID: id, Version: stringPointerValue(state.prompts[id].definition.Version)})
|
||||
}
|
||||
state.namespaces = map[string][]string{
|
||||
"backend": resourceNamespaces(state.backendIDs),
|
||||
"profile": resourceNamespaces(state.profileIDs),
|
||||
"prompt": promptNamespaces(state.promptIDs),
|
||||
}
|
||||
for _, namespace := range sortedKeys(result.Config.Collections) {
|
||||
collection := result.Config.Collections[namespace]
|
||||
state.collections = append(state.collections, CollectionIdentity{
|
||||
Namespace: namespace, ReleaseVersion: stringPointerValue(collection.ReleaseVersion),
|
||||
})
|
||||
}
|
||||
return state, nil
|
||||
}
|
||||
|
||||
func resourceNamespaces(ids []string) []string {
|
||||
namespaces := make(map[string]struct{})
|
||||
for _, id := range ids {
|
||||
if namespace, _, qualified := strings.Cut(id, "/"); qualified {
|
||||
namespaces[namespace] = struct{}{}
|
||||
}
|
||||
}
|
||||
return sortedKeys(namespaces)
|
||||
}
|
||||
|
||||
func promptNamespaces(prompts []domain.PromptIdentity) []string {
|
||||
ids := make([]string, len(prompts))
|
||||
for index := range prompts {
|
||||
ids[index] = prompts[index].ID
|
||||
}
|
||||
return resourceNamespaces(ids)
|
||||
}
|
||||
|
||||
func checkConfigurationVersion(version configkit.Version, validation *configkit.Validation) error {
|
||||
if !version.Present {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user