Share typed publication completion evidence
This commit is contained in:
@@ -43,38 +43,12 @@ func committedPublishOutputOutcomes(m *manifest.Manifest) map[string]string {
|
||||
if m == nil || m.Stages["publish"] == nil {
|
||||
return out
|
||||
}
|
||||
raw := m.Stages["publish"].Metadata["publish_output_outcomes"]
|
||||
appendOutcome := func(item map[string]any) {
|
||||
source, sourceOK := item["source"].(string)
|
||||
status, statusOK := item["status"].(string)
|
||||
if sourceOK && statusOK && isPublishOutputOutcome(status) {
|
||||
out[source] = status
|
||||
}
|
||||
}
|
||||
switch items := raw.(type) {
|
||||
case []any:
|
||||
for _, rawItem := range items {
|
||||
if item, ok := rawItem.(map[string]any); ok {
|
||||
appendOutcome(item)
|
||||
}
|
||||
}
|
||||
case []map[string]any:
|
||||
for _, item := range items {
|
||||
appendOutcome(item)
|
||||
}
|
||||
for _, outcome := range artifacts.DecodePublicationOutcomes(m.Stages["publish"].Metadata) {
|
||||
out[outcome.Source] = string(outcome.Status)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func isPublishOutputOutcome(status string) bool {
|
||||
switch status {
|
||||
case "published", "carried_locked", "locked_unpublished", "optional_missing", "unselected":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func committedPublishedOutputs(commit *artifacts.RemoteCommitManifest) map[string]artifacts.RemoteArtifact {
|
||||
out := map[string]artifacts.RemoteArtifact{}
|
||||
if commit == nil {
|
||||
|
||||
@@ -208,11 +208,15 @@ func TestCommittedPublishOutputOutcomesRecognizesAllStates(t *testing.T) {
|
||||
for _, status := range statuses {
|
||||
items = append(items, map[string]any{"source": "source." + status, "status": status})
|
||||
}
|
||||
items = append(items, "malformed", map[string]any{"source": "invalid", "status": "unknown"})
|
||||
m := &manifest.Manifest{Stages: map[string]*manifest.StageRecord{
|
||||
"publish": {Metadata: map[string]any{"publish_output_outcomes": items}},
|
||||
}}
|
||||
|
||||
got := committedPublishOutputOutcomes(m)
|
||||
if len(got) != len(statuses) {
|
||||
t.Fatalf("unexpected outcomes = %#v", got)
|
||||
}
|
||||
for _, status := range statuses {
|
||||
if got["source."+status] != status {
|
||||
t.Fatalf("outcomes = %#v, missing %q", got, status)
|
||||
|
||||
Reference in New Issue
Block a user