diff --git a/go/catalogue/artifacts.go b/go/catalogue/artifacts.go index 2a4c7d5..714b7de 100644 --- a/go/catalogue/artifacts.go +++ b/go/catalogue/artifacts.go @@ -60,6 +60,13 @@ func InArtifactStore(reference string) (path string, kept bool) { // (novox/hq ADR 0605 §1, §9). var RegistrySeats = []string{contractseats.ContainerImageRegistry, contractseats.OciArtifactRegistry} +// SeatReference is the reference a build names an image, bundle, archive or upstream copy by once it published it +// through a registry seat (novox/hq ADR 0605 §9): `//@sha256:`, as InRegistrySeat reads +// it back. The store's address is left out, as in the older form: a reader routes it (Routed). +func SeatReference(seat, module, artifact, digest string) string { + return seat + "/" + module + "/" + artifact + "@" + digest +} + // InRegistrySeat reads a reference in the form a registry seat answers, `//@sha256:`: // the seat it came through and the rest. A seat's name holds no dot or port, so no image of an outside registry reads // as one, and a kept `artifact-store://` reference is not one. diff --git a/go/catalogue/artifacts_test.go b/go/catalogue/artifacts_test.go index a59c2e2..9ff124e 100644 --- a/go/catalogue/artifacts_test.go +++ b/go/catalogue/artifacts_test.go @@ -42,4 +42,11 @@ func TestAReferenceIsRecordedWithoutTheStoresAddress(t *testing.T) { t.Errorf("Routed(%q) = %q, want %q", reference, got, want) } } + // A build module names what it published in the seat's form, and reads it back as the seat it came through. + for _, seat := range RegistrySeats { + ref := SeatReference(seat, "gitea", "config", digest) + if got, path, ok := InRegistrySeat(ref); !ok || got != seat || path != "gitea/config@"+digest { + t.Errorf("SeatReference(%s) = %q, read back as %q %q %v", seat, ref, got, path, ok) + } + } }