Validate published output declarations
This commit is contained in:
@@ -117,18 +117,14 @@ func (m RemoteCommitManifest) ValidateForSessionPrefix(sessionPrefix string) err
|
||||
publishedDestinations := make(map[string]struct{})
|
||||
for _, artifact := range m.Artifacts {
|
||||
if artifact.Type == RemoteArtifactTypePublishedOutput {
|
||||
identity, err := ParseImmutableRunObjectKey(sessionPrefix, artifact.DestinationKey)
|
||||
identity, err := ParsePublishedOutputObjectKey(sessionPrefix, artifact.DestinationKey)
|
||||
if err != nil {
|
||||
return fmt.Errorf("remote commit published output destination %q: %w", artifact.DestinationKey, err)
|
||||
}
|
||||
effectiveDestination := strings.TrimPrefix(identity.RelativePath, "published/")
|
||||
if effectiveDestination == "" {
|
||||
return fmt.Errorf("remote commit published output destination %q is empty", artifact.DestinationKey)
|
||||
if _, duplicate := publishedDestinations[identity.Destination]; duplicate {
|
||||
return fmt.Errorf("remote commit declares duplicate published output destination %q", identity.Destination)
|
||||
}
|
||||
if _, duplicate := publishedDestinations[effectiveDestination]; duplicate {
|
||||
return fmt.Errorf("remote commit declares duplicate published output destination %q", effectiveDestination)
|
||||
}
|
||||
publishedDestinations[effectiveDestination] = struct{}{}
|
||||
publishedDestinations[identity.Destination] = struct{}{}
|
||||
continue
|
||||
}
|
||||
if !strings.HasPrefix(artifact.DestinationKey, runPrefix) {
|
||||
@@ -163,6 +159,11 @@ func validateRemoteArtifactIdentity(a RemoteArtifact) error {
|
||||
if strings.TrimSpace(a.Source) == "" {
|
||||
return fmt.Errorf("source is required")
|
||||
}
|
||||
if a.Type == RemoteArtifactTypePublishedOutput {
|
||||
if err := validateCanonicalPublishSource(a.Source); err != nil {
|
||||
return fmt.Errorf("published output %w", err)
|
||||
}
|
||||
}
|
||||
if err := validateRemoteObjectKey(a.DestinationKey); err != nil {
|
||||
return fmt.Errorf("destination key: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user