diff --git a/modules/mesh-delivery-builder/internal/versions/republish.go b/modules/mesh-delivery-builder/internal/versions/republish.go index b9c50456..cefb74af 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish.go +++ b/modules/mesh-delivery-builder/internal/versions/republish.go @@ -41,6 +41,13 @@ const ( VerbPublish = "publish" ) +// RepublishTransfer is a publish again's transfer name, the builder's own (the registry part's publish: the caller names its +// transfer): safe as a transfer id, which holds none of "/", ".", " ", "*" or ">" (mesh-sdk's parts receiver refuses them), so a +// version's dots are dashes (design 47 G §588). +func RepublishTransfer(module, version, artifact string) string { + return strings.NewReplacer("/", "-", ".", "-", " ", "-", "*", "-", ">", "-", "@", "-").Replace("republish-" + module + "-" + version + "-" + artifact) +} + // RegistrySeats are the four registry seats a version is published to. var RegistrySeats = []string{SeatImages, SeatArtifacts, SeatGoPackages, SeatNPM} @@ -612,7 +619,7 @@ func (r *Republisher) send(ctx context.Context, q QueuedPublish) { kind := art.Kind bound, cancel := context.WithTimeout(ctx, UnreleasedBound) // a context's bound, no timer (ADR 0437 §8) err := r.Send(bound, Publish{Seat: seat, Kind: kind, Name: name, Version: v.Version, Digest: q.Artifacts[ref], Fingerprint: v.Fingerprint, - Commit: v.Commit, Transfer: "republish-" + q.Module + "-" + v.Version + "-" + strings.TrimPrefix(ref, q.Module+":")}) + Commit: v.Commit, Transfer: RepublishTransfer(q.Module, v.Version, strings.TrimPrefix(ref, q.Module+":"))}) cancel() if err == nil { r.logf("publish again: %s %s: %s sent to %s as %s %s, digest %s; the package-published is said when the seat says published", q.Module, q.Version, ref, seat, name, v.Version, q.Artifacts[ref]) diff --git a/modules/mesh-delivery-builder/internal/versions/republish_test.go b/modules/mesh-delivery-builder/internal/versions/republish_test.go index 9f1c1097..62433295 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish_test.go +++ b/modules/mesh-delivery-builder/internal/versions/republish_test.go @@ -105,7 +105,8 @@ func TestRepublish(t *testing.T) { } } p := b.sent[0] - if p.Seat != SeatArtifacts || p.Name != "m/prog" || p.Kind != "bundle" || p.Version != v.Version || p.Digest != "sha256:aa" || p.Fingerprint != "src2:m" { + if p.Seat != SeatArtifacts || p.Name != "m/prog" || p.Kind != "bundle" || p.Version != v.Version || p.Digest != "sha256:aa" || p.Fingerprint != "src2:m" || + p.Transfer != "republish-m-"+strings.ReplaceAll(v.Version, ".", "-")+"-prog" || strings.ContainsAny(p.Transfer, "/. *>") { t.Errorf("sent %+v, want the bundle by digest to the oci seat, the Go package left to its own seat's holder", p) } if _, err := b.Heard(ctx, subject, data, 5); err != nil || len(b.sent) != 1 {