Share immutable backend defaults during profile capture
This commit is contained in:
@@ -26,7 +26,7 @@ func (state *loaded) buildExecutionProfiles(config *settings.Settings) error {
|
||||
state.indexedProfiles = make(map[string]domain.ExecutionProfile, len(profileConfigs))
|
||||
for _, id := range sortedKeys(profileConfigs) {
|
||||
config := profileConfigs[id]
|
||||
profile, err := captureExecutionProfile(id, config, state.registry)
|
||||
profile, err := captureExecutionProfile(id, config, definitions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -65,12 +65,14 @@ func captureBackend(id string, config backendConfig) domain.Backend {
|
||||
return definition
|
||||
}
|
||||
|
||||
func captureExecutionProfile(id string, config profileConfig, registry *backend.Registry) (domain.ExecutionProfile, error) {
|
||||
func captureExecutionProfile(id string, config profileConfig, backends map[string]domain.Backend) (domain.ExecutionProfile, error) {
|
||||
target := defaults.ExecutionTargetDefault()
|
||||
if config.Backend != nil && *config.Backend != "" {
|
||||
selected, err := registry.GetBackend(*config.Backend)
|
||||
if err != nil {
|
||||
return domain.ExecutionProfile{}, fmt.Errorf("profile %q backend: %w", id, err)
|
||||
// These defaults are capture-owned and immutable. Public and runtime
|
||||
// lookups still detach mutable values; profile overlays copy before merging.
|
||||
selected, found := backends[*config.Backend]
|
||||
if !found {
|
||||
return domain.ExecutionProfile{}, fmt.Errorf("profile %q backend: %w: %q", id, backend.ErrBackendNotFound, *config.Backend)
|
||||
}
|
||||
target.BackendID = selected.ID
|
||||
target.Endpoint = selected.Endpoint
|
||||
|
||||
Reference in New Issue
Block a user