Carry collection selections through configuration
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user