Index previous publication selections and missing inputs
This commit is contained in:
@@ -116,10 +116,16 @@ func Resolve(
|
||||
return nil, fmt.Errorf("previous-session current state does not include a committed remote declaration")
|
||||
}
|
||||
|
||||
publishedBySource := make(map[string][]artifacts.RemoteArtifact)
|
||||
for _, artifact := range current.Commit.Artifacts {
|
||||
if artifact.Type == artifacts.RemoteArtifactTypePublishedOutput {
|
||||
publishedBySource[artifact.Source] = append(publishedBySource[artifact.Source], artifact)
|
||||
}
|
||||
}
|
||||
for _, requirement := range orderedRequirements {
|
||||
sourceID := previousArtifactSourceID(requirement.Name)
|
||||
selectedArtifact, ok := committedPublishedArtifactBySource(current.Commit, sourceID)
|
||||
if !ok {
|
||||
candidates := publishedBySource[strings.TrimSpace(sourceID)]
|
||||
if len(candidates) == 0 {
|
||||
if requirement.Required {
|
||||
return nil, fmt.Errorf(
|
||||
"required previous-session artifact %q is not declared by the selected remote commit",
|
||||
@@ -129,6 +135,7 @@ func Resolve(
|
||||
result.SkippedMissing = append(result.SkippedMissing, requirement.Name)
|
||||
continue
|
||||
}
|
||||
selectedArtifact := candidates[0]
|
||||
selectedRel, err := publishedOutputRelativePath(previousSessionPrefix, selectedArtifact.DestinationKey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("resolve declared previous-session artifact %q: %w", requirement.Name, err)
|
||||
@@ -167,22 +174,6 @@ func Resolve(
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func committedPublishedArtifactBySource(commit *artifacts.RemoteCommitManifest, source string) (artifacts.RemoteArtifact, bool) {
|
||||
if commit == nil {
|
||||
return artifacts.RemoteArtifact{}, false
|
||||
}
|
||||
want := strings.TrimSpace(source)
|
||||
if want == "" {
|
||||
return artifacts.RemoteArtifact{}, false
|
||||
}
|
||||
for _, artifact := range commit.Artifacts {
|
||||
if artifact.Type == artifacts.RemoteArtifactTypePublishedOutput && artifact.Source == want {
|
||||
return artifact, true
|
||||
}
|
||||
}
|
||||
return artifacts.RemoteArtifact{}, false
|
||||
}
|
||||
|
||||
func publishedOutputRelativePath(sessionPrefix, destinationKey string) (string, error) {
|
||||
identity, err := artifacts.ParsePublishedOutputObjectKey(sessionPrefix, destinationKey)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user