Adopt ConfigKit overlays for pipeline selection
This commit is contained in:
@@ -16,7 +16,7 @@ type pipelineResolutionMetadata struct {
|
||||
rootPath string
|
||||
imports []string
|
||||
sources []string
|
||||
selectedProfile *pipelineProfileSelection
|
||||
selectedOverlay *pipelineOverlaySelection
|
||||
effectiveDigest string
|
||||
logicalNotariusConfig string
|
||||
logicalNotariusWorking string
|
||||
@@ -29,7 +29,7 @@ type pipelineResolutionMetadata struct {
|
||||
configkitSources []configkit.SourceInfo
|
||||
}
|
||||
|
||||
type pipelineProfileSelection struct {
|
||||
type pipelineOverlaySelection struct {
|
||||
name string
|
||||
source string
|
||||
overlayPath string
|
||||
@@ -41,8 +41,8 @@ type pipelineFieldOwnership struct {
|
||||
}
|
||||
|
||||
func loadPipelineWithConfigKit(path string, opts PipelineLoadOptions) (*PipelineConfig, error) {
|
||||
profile := selectedPipelineProfileName(opts)
|
||||
result, err := loadPipelineConfigKitResult(path, profile)
|
||||
overlay := selectedPipelineOverlayName(opts)
|
||||
result, err := loadPipelineConfigKitResult(path, overlay)
|
||||
if err != nil {
|
||||
return nil, describePipelineLoadError(err)
|
||||
}
|
||||
@@ -55,10 +55,10 @@ func loadPipelineWithConfigKit(path string, opts PipelineLoadOptions) (*Pipeline
|
||||
return &cfg, nil
|
||||
}
|
||||
|
||||
func loadPipelineConfigKitResult(path, profile string) (*configkit.Result[PipelineConfig], error) {
|
||||
func loadPipelineConfigKitResult(path, overlay string) (*configkit.Result[PipelineConfig], error) {
|
||||
return configkit.Load(configkit.File(path), configkit.Options[PipelineConfig]{
|
||||
Imports: true,
|
||||
Profile: profile,
|
||||
Overlay: overlay,
|
||||
Definition: configkit.Definition[PipelineConfig]{
|
||||
Defaults: pipelineConfigDefaults,
|
||||
Resolve: resolvePipelineConfig,
|
||||
@@ -104,11 +104,11 @@ func describeConfigKitLoadError(kind string, err error) error {
|
||||
return fmt.Errorf("load %s config: strict decode failed or validation failed: %w: %s", kind, err, strings.TrimSpace(diagnostics.String()))
|
||||
}
|
||||
|
||||
func selectedPipelineProfileName(opts PipelineLoadOptions) string {
|
||||
if opts.Profile == nil || *opts.Profile == "" || *opts.Profile == "default" {
|
||||
func selectedPipelineOverlayName(opts PipelineLoadOptions) string {
|
||||
if opts.Overlay == nil || *opts.Overlay == "" || *opts.Overlay == "default" {
|
||||
return ""
|
||||
}
|
||||
return *opts.Profile
|
||||
return *opts.Overlay
|
||||
}
|
||||
|
||||
func pipelineConfigDefaults() PipelineConfig {
|
||||
@@ -282,8 +282,8 @@ func pipelineMetadataFromConfigKit(cfg *PipelineConfig, result *configkit.Result
|
||||
} else if source.Layer == configkit.LayerBase {
|
||||
resolved.imports = append(resolved.imports, path)
|
||||
}
|
||||
if source.Layer == configkit.LayerProfile {
|
||||
resolved.selectedProfile = &pipelineProfileSelection{name: selectedPipelineProfileName(opts), source: "explicit", overlayPath: path}
|
||||
if source.Layer == configkit.LayerOverlay {
|
||||
resolved.selectedOverlay = &pipelineOverlaySelection{name: selectedPipelineOverlayName(opts), source: "explicit", overlayPath: path}
|
||||
}
|
||||
}
|
||||
detailed, err := pipelineMetadataPaths(cfg)
|
||||
@@ -347,7 +347,7 @@ func rejectDuplicateBaseDefinitions(metadata configkit.Metadata, sources []confi
|
||||
pathsByID[source.ID] = source.Path
|
||||
}
|
||||
// Enumerate retained declarations, not just surviving effective keys. Loading
|
||||
// the base separately would also resolve credentials removed by the profile.
|
||||
// the base separately would also resolve credentials removed by the overlay.
|
||||
// ConfigKit returns canonical JSON Pointers in deterministic order.
|
||||
for _, path := range metadata.HistoricalPaths() {
|
||||
parts := strings.Split(path.String(), "/")
|
||||
|
||||
Reference in New Issue
Block a user