Add collection input helper
This commit is contained in:
@@ -8,9 +8,25 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"gitea.maximumdirect.net/eric/ConfigKit"
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/domain"
|
||||
"gitea.maximumdirect.net/eric/promptkit/internal/filecatalog"
|
||||
)
|
||||
|
||||
// CollectionInput mounts source at the selected collection's configuration
|
||||
// destination and enables ConfigKit imports for that input. The source is not
|
||||
// read or validated until ConfigKit loads it. Callers may adjust the returned
|
||||
// input, including its filesystem context or imports setting.
|
||||
func CollectionInput(namespace string, source configkit.Source) (configkit.Input, error) {
|
||||
if !domain.IsValidResourceNamespace(namespace) {
|
||||
return configkit.Input{}, fmt.Errorf("%w: invalid collection namespace %q", ErrInvalidConfig, namespace)
|
||||
}
|
||||
return configkit.Input{
|
||||
Source: source,
|
||||
Destination: configkit.Keys("collections", namespace),
|
||||
Imports: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DirectoryInputs selects the YAML files beneath an explicitly chosen host
|
||||
// directory as one strict-composition group. The returned order is deterministic;
|
||||
// it does not assign precedence among those files. Discovery is recursive over
|
||||
|
||||
Reference in New Issue
Block a user