Compose application assets in one strict group
This commit is contained in:
@@ -101,21 +101,25 @@ func (r *AssetRegistry) FallbackProfileDigest() (string, error) {
|
||||
}
|
||||
|
||||
// PromptKitConfigurationSources returns the registered prompt and fallback
|
||||
// profile assets as native PromptKit underlay groups. Schema assets remain a
|
||||
// profile assets in one strict native PromptKit underlay. Schema assets remain a
|
||||
// separate PromptKit option because they are runtime validation resources.
|
||||
func (r *AssetRegistry) PromptKitConfigurationSources() (promptkit.ConfigurationSources, []promptkit.Option, error) {
|
||||
if r == nil {
|
||||
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("asset registry must not be nil")
|
||||
}
|
||||
underlays, err := promptKitFilesystemUnderlays(r.prompts, "notarius-prompts")
|
||||
inputs, err := promptKitFilesystemInputs(r.prompts, "notarius-prompts")
|
||||
if err != nil {
|
||||
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare prompt configuration sources: %w", err)
|
||||
}
|
||||
profiles, err := promptKitFilesystemUnderlays(r.fallbackProfiles, "notarius-fallback-profiles")
|
||||
profiles, err := promptKitFilesystemInputs(r.fallbackProfiles, "notarius-fallback-profiles")
|
||||
if err != nil {
|
||||
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare fallback profile configuration sources: %w", err)
|
||||
}
|
||||
underlays = append(underlays, profiles...)
|
||||
inputs = append(inputs, profiles...)
|
||||
var underlays []configkit.Underlay
|
||||
if len(inputs) != 0 {
|
||||
underlays = []configkit.Underlay{{Inputs: inputs}}
|
||||
}
|
||||
schemaFS, err := r.SchemaFS()
|
||||
if err != nil {
|
||||
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare schema assets: %w", err)
|
||||
@@ -125,18 +129,16 @@ func (r *AssetRegistry) PromptKitConfigurationSources() (promptkit.Configuration
|
||||
}, nil
|
||||
}
|
||||
|
||||
func promptKitFilesystemUnderlays(sources []AssetSource, label string) ([]configkit.Underlay, error) {
|
||||
underlays := make([]configkit.Underlay, 0, len(sources))
|
||||
func promptKitFilesystemInputs(sources []AssetSource, label string) ([]configkit.Input, error) {
|
||||
var selected []configkit.Input
|
||||
for index, source := range sources {
|
||||
inputs, err := promptkit.FilesystemInputs(fmt.Sprintf("%s-%d", label, index), source.FS, source.Root)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("select filesystem inputs: %w", err)
|
||||
}
|
||||
if len(inputs) != 0 {
|
||||
underlays = append(underlays, configkit.Underlay{Inputs: inputs})
|
||||
}
|
||||
selected = append(selected, inputs...)
|
||||
}
|
||||
return underlays, nil
|
||||
return selected, nil
|
||||
}
|
||||
|
||||
func (r *AssetRegistry) fallbackProfileAssets() (fs.FS, string, bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user