Share one native application configuration load and captured engine
This commit is contained in:
@@ -70,6 +70,12 @@ func documentDefinition(state *documentLoadState) configkit.Definition[Document]
|
||||
return promptkit.Configure(definition, func(document *Document) *promptkit.Settings { return &document.PromptKit })
|
||||
}
|
||||
|
||||
// Definition supplies the application's native composition rules. The caller
|
||||
// owns source selection and loading; each definition owns its resolution state.
|
||||
func Definition(invocationDirectory string) configkit.Definition[Document] {
|
||||
return documentDefinition(newDocumentLoadState(invocationDirectory))
|
||||
}
|
||||
|
||||
func documentDefaults() Document {
|
||||
return Document{
|
||||
Pipelines: map[string]PipelineDocument{},
|
||||
|
||||
@@ -59,7 +59,7 @@ func loadConfig(path string, options LoadOptions) (*LoadedConfig, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return newLoadedConfig(result)
|
||||
return FromResult(result)
|
||||
}
|
||||
|
||||
// Load reads a version 6 configuration file into runtime configuration and a
|
||||
@@ -74,7 +74,7 @@ func LoadSource(source configkit.Source, options LoadOptions) (*LoadedConfig, er
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return newLoadedConfig(result)
|
||||
return FromResult(result)
|
||||
}
|
||||
|
||||
// MainSourcePath returns the selected main file's recorded path, if any.
|
||||
@@ -95,10 +95,12 @@ func loadConfigSource(source configkit.Source, options LoadOptions) (*LoadedConf
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return newLoadedConfig(result)
|
||||
return FromResult(result)
|
||||
}
|
||||
|
||||
func newLoadedConfig(result *configkit.Result[Document]) (*LoadedConfig, error) {
|
||||
// FromResult derives runtime pipeline settings without loading or serializing
|
||||
// the application result again.
|
||||
func FromResult(result *configkit.Result[Document]) (*LoadedConfig, error) {
|
||||
if result == nil {
|
||||
return nil, fmt.Errorf("configuration result is unavailable")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user