BM publish version (sdk): publishParts refuses a Go package or a bundle that names no version
A publish by its digest alone marks no reservation, so no build module may publish a Go package or a bundle without the version its ask reserved; the refusal is loud and comes before the seat is asked. An archive may still publish by its digest. Builds: design 47 H2 H-A-373, H-A-373 (addendum)
This commit is contained in:
@@ -15,13 +15,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CAT-NR1: a build's publish on a seat says asked, waiting on the seat (on every tick of NarrateEvery while the holder
|
// CAT-NR1: a build's publish on a seat says asked, waiting on the seat (on every tick of NarrateEvery while the holder
|
||||||
// has not answered), and stored or refused, each as the ask's phase written to its running step key.
|
// has not answered), and stored or refused, each as the ask's phase written to its running step key. Design 47 H2
|
||||||
|
// H-A-373: a Go package or a bundle with no version is refused before the seat is asked; an archive publishes by digest.
|
||||||
func TestABuildNarratesItsPublishOnASeat(t *testing.T) {
|
func TestABuildNarratesItsPublishOnASeat(t *testing.T) {
|
||||||
digest := "sha256:" + strings.Repeat("c", 64)
|
digest := "sha256:" + strings.Repeat("c", 64)
|
||||||
for name, c := range map[string]struct {
|
for name, c := range map[string]struct {
|
||||||
answer error
|
answer error
|
||||||
ticks int
|
ticks int
|
||||||
want []string
|
seat, kind, version string
|
||||||
|
want []string
|
||||||
}{
|
}{
|
||||||
"stored": {want: []string{
|
"stored": {want: []string{
|
||||||
"asked go-package-registry: publish of mod 1.2.3 at " + digest,
|
"asked go-package-registry: publish of mod 1.2.3 at " + digest,
|
||||||
@@ -34,6 +36,15 @@ func TestABuildNarratesItsPublishOnASeat(t *testing.T) {
|
|||||||
"waiting on go-package-registry: publish of mod 1.2.3 at " + digest + ", 5m0s since asked",
|
"waiting on go-package-registry: publish of mod 1.2.3 at " + digest + ", 5m0s since asked",
|
||||||
"waiting on go-package-registry: publish of mod 1.2.3 at " + digest + ", 10m0s since asked",
|
"waiting on go-package-registry: publish of mod 1.2.3 at " + digest + ", 10m0s since asked",
|
||||||
"stored on go-package-registry: publish of mod 1.2.3 at " + digest + " (0 of its 1 parts sent, the rest held)"}},
|
"stored on go-package-registry: publish of mod 1.2.3 at " + digest + " (0 of its 1 parts sent, the rest held)"}},
|
||||||
|
"a Go package with no version, refused": {version: "-", answer: errors.New("never asked"), want: []string{
|
||||||
|
"asked go-package-registry: publish of mod at " + digest,
|
||||||
|
"refused by go-package-registry: publish of mod at " + digest + ": go-package-registry's publish of mod (package) names no version: a Go package and every bundle publish under the version the ask reserved"}},
|
||||||
|
"a Node bundle with no version, refused": {seat: NpmSeat, kind: "bundle", version: "-", answer: errors.New("never asked"), want: []string{
|
||||||
|
"asked npm-package-registry: publish of mod at " + digest,
|
||||||
|
"refused by npm-package-registry: publish of mod at " + digest + ": npm-package-registry's publish of mod (bundle) names no version: a Go package and every bundle publish under the version the ask reserved"}},
|
||||||
|
"an archive by its digest, stored": {seat: ArtifactSeat, kind: "archive", version: "-", want: []string{
|
||||||
|
"asked oci-artifact-registry: publish of mod at " + digest,
|
||||||
|
"stored on oci-artifact-registry: publish of mod at " + digest + " (0 of its 1 parts sent, the rest held)"}},
|
||||||
} {
|
} {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
clock := time.Date(2026, 11, 4, 16, 0, 0, 0, time.UTC)
|
clock := time.Date(2026, 11, 4, 16, 0, 0, 0, time.UTC)
|
||||||
@@ -72,7 +83,17 @@ func TestABuildNarratesItsPublishOnASeat(t *testing.T) {
|
|||||||
}
|
}
|
||||||
ctx := context.WithValue(context.Background(), phaseKey{}, ph)
|
ctx := context.WithValue(context.Background(), phaseKey{}, ph)
|
||||||
done := make(chan error, 1)
|
done := make(chan error, 1)
|
||||||
go func() { done <- PublishOne(ctx, call, GoSeat, "mod", "package", "1.2.3", digest, "t", []byte("x")) }()
|
seat, kind, version := GoSeat, "package", "1.2.3"
|
||||||
|
if c.seat != "" {
|
||||||
|
seat = c.seat
|
||||||
|
}
|
||||||
|
if c.kind != "" {
|
||||||
|
kind = c.kind
|
||||||
|
}
|
||||||
|
if c.version == "-" {
|
||||||
|
version = ""
|
||||||
|
}
|
||||||
|
go func() { done <- PublishOne(ctx, call, seat, "mod", kind, version, digest, "t", []byte("x")) }()
|
||||||
line := func() {
|
line := func() {
|
||||||
select {
|
select {
|
||||||
case <-wrote:
|
case <-wrote:
|
||||||
|
|||||||
@@ -96,6 +96,13 @@ func PublishFault(err error) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func publishParts(ctx context.Context, call SeatCall, seat string, in reg.PublishInput, ps []parts.Part) (parts.Sent, error) {
|
func publishParts(ctx context.Context, call SeatCall, seat string, in reg.PublishInput, ps []parts.Part) (parts.Sent, error) {
|
||||||
|
// Design 47 H2 H-A-373: a publish on the Go package registry seat, and every bundle's, names the version the ask
|
||||||
|
// reserved; one by its digest alone marks no reservation, so it is refused before the seat is asked. An archive may
|
||||||
|
// still publish by its digest where no version is reserved for it.
|
||||||
|
if in.Version == "" && (seat == GoSeat || in.Kind == reg.PublishInputKindBundle) {
|
||||||
|
return parts.Sent{}, fmt.Errorf("%s's publish of %s (%s) names no version: a Go package and every bundle publish under the version the ask reserved",
|
||||||
|
seat, in.Name, in.Kind)
|
||||||
|
}
|
||||||
switch seat {
|
switch seat {
|
||||||
case ImageSeat:
|
case ImageSeat:
|
||||||
s, err := imageclient.Publish(ctx, imageclient.Call(call), in, ps)
|
s, err := imageclient.Publish(ctx, imageclient.Call(call), in, ps)
|
||||||
|
|||||||
Reference in New Issue
Block a user