Carry collection selections through configuration

This commit is contained in:
2026-11-29 17:53:36 +00:00
parent a0c5ca8761
commit 10221b0624
10 changed files with 172 additions and 6 deletions

View File

@@ -37,8 +37,9 @@ type ArtifactReference struct {
// ReferenceSource is the discriminated source form used by configured
// reference maps. Exactly one of Path and Artifact is set after resolution.
type ReferenceSource struct {
Path string `json:"path,omitempty"`
Artifact *ArtifactReference `json:"artifact,omitempty"`
Path string `json:"path,omitempty"`
Artifact *ArtifactReference `json:"artifact,omitempty"`
Collections []string `json:"collections,omitempty"`
}
func ExternalReference(path string) ReferenceSource {
@@ -64,10 +65,19 @@ func (source ReferenceSource) MarshalJSON() ([]byte, error) {
return nil, fmt.Errorf("reference source must not contain both an external path and an artifact selector")
}
if source.Artifact != nil {
if source.Collections != nil {
return nil, fmt.Errorf("collection selection requires an external path")
}
return json.Marshal(struct {
Artifact *ArtifactReference `json:"artifact"`
}{Artifact: source.Artifact})
}
if source.Collections != nil {
return json.Marshal(struct {
Path string `json:"path"`
Collections []string `json:"collections"`
}{Path: source.Path, Collections: source.Collections})
}
return json.Marshal(source.Path)
}