Use unified PromptKit sources for execution and preflight
This commit is contained in:
@@ -75,22 +75,12 @@ func (e *promptKitProfileConfigurationError) Unwrap() error {
|
||||
}
|
||||
|
||||
func NewPromptKitProfileInspector(cfg PromptKitProfileInspectorConfig) (*PromptKitProfileInspector, error) {
|
||||
source, options, err := promptKitProfileSourceEngineOptions(cfg.Source)
|
||||
_, sources, options, err := promptKitEngineConfiguration(cfg.Source, cfg.Assets)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cfg.Assets != nil {
|
||||
fallbackOption, hasFallback, err := cfg.Assets.promptKitFallbackProfileOption()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if hasFallback {
|
||||
options = append(options, fallbackOption)
|
||||
}
|
||||
return nil, &promptKitProfileConfigurationError{err: err}
|
||||
}
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{
|
||||
PromptDir: ".",
|
||||
ProfileDir: source.ProfileDir,
|
||||
Sources: sources,
|
||||
}, options...)
|
||||
if err != nil {
|
||||
return nil, &promptKitProfileConfigurationError{err: err}
|
||||
@@ -122,6 +112,25 @@ func (i *PromptKitProfileInspector) InspectProfile(ctx context.Context, profileI
|
||||
}, nil
|
||||
}
|
||||
|
||||
func promptKitEngineConfiguration(cfg PromptKitProfileSourceConfig, assets *AssetRegistry) (PromptKitProfileSourceConfig, promptkit.ConfigurationSources, []promptkit.Option, error) {
|
||||
profileSource, profileSources, err := promptKitProfileConfigurationSources(cfg)
|
||||
if err != nil {
|
||||
return PromptKitProfileSourceConfig{}, promptkit.ConfigurationSources{}, nil, err
|
||||
}
|
||||
sources := promptkit.ConfigurationSources{}
|
||||
var options []promptkit.Option
|
||||
if assets != nil {
|
||||
maintainedSources, maintainedOptions, err := assets.PromptKitConfigurationSources()
|
||||
if err != nil {
|
||||
return PromptKitProfileSourceConfig{}, promptkit.ConfigurationSources{}, nil, err
|
||||
}
|
||||
sources = maintainedSources
|
||||
options = append(options, maintainedOptions...)
|
||||
}
|
||||
sources.Underlays = append(sources.Underlays, profileSources.Underlays...)
|
||||
return profileSource, sources, options, nil
|
||||
}
|
||||
|
||||
func promptKitProfileConfigurationSources(cfg PromptKitProfileSourceConfig) (PromptKitProfileSourceConfig, promptkit.ConfigurationSources, error) {
|
||||
source := PromptKitProfileSourceConfig{
|
||||
ProfileDir: strings.TrimSpace(cfg.ProfileDir),
|
||||
|
||||
Reference in New Issue
Block a user