Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore blind-write to remote.Put #1970

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/crane/rebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ some compiler expected by the uppermost app layers, the resulting rebased image
might be invalid.

In general, it's a good practice to tag rebased images to some other tag than
the `original` tag, perform some sanity checks, then tag the image to the
the `original` tag, perform some confidence checks, then tag the image to the
`original` tag once it's determined the image is valid.

There is ongoing work to standardize and advertise base image contract
Expand Down
14 changes: 14 additions & 0 deletions pkg/v1/remote/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ func (p *Pusher) writer(ctx context.Context, repo name.Repository, o *options) (
return rw, rw.init(ctx)
}

func (p *Pusher) Put(ctx context.Context, ref name.Reference, t Taggable) error {
w, err := p.writer(ctx, ref.Context(), p.o)
if err != nil {
return err
}

m, err := taggableToManifest(t)
if err != nil {
return err
}

return w.commitManifest(ctx, ref, m)
}

func (p *Pusher) Push(ctx context.Context, ref name.Reference, t Taggable) error {
w, err := p.writer(ctx, ref.Context(), p.o)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/v1/remote/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,5 +709,5 @@ func Put(ref name.Reference, t Taggable, options ...Option) error {
if err != nil {
return err
}
return newPusher(o).Push(o.context, ref, t)
return newPusher(o).Put(o.context, ref, t)
}
24 changes: 12 additions & 12 deletions pkg/v1/remote/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@
if err != nil {
t.Fatalf("img.Layers() = %v", err)
}
dummyLayer := layers[0]
wokeLayer := layers[0]

testCases := []struct {
name string
Expand All @@ -1122,7 +1122,7 @@
reference: referenceToUpload,
layers: []v1.Layer{
&MountableLayer{
Layer: dummyLayer,
Layer: wokeLayer,
Reference: sameReference,
},
},
Expand All @@ -1135,7 +1135,7 @@
reference: referenceToUpload,
layers: []v1.Layer{
&MountableLayer{
Layer: dummyLayer,
Layer: wokeLayer,
Reference: anotherRepo1,
},
},
Expand All @@ -1149,11 +1149,11 @@
reference: referenceToUpload,
layers: []v1.Layer{
&MountableLayer{
Layer: dummyLayer,
Layer: wokeLayer,
Reference: anotherRepo1,
},
&MountableLayer{
Layer: dummyLayer,
Layer: wokeLayer,
Reference: anotherRepo1,
},
},
Expand All @@ -1167,11 +1167,11 @@
reference: referenceToUpload,
layers: []v1.Layer{
&MountableLayer{
Layer: dummyLayer,
Layer: wokeLayer,
Reference: anotherRepo1,
},
&MountableLayer{
Layer: dummyLayer,
Layer: wokeLayer,
Reference: anotherRepo2,
},
},
Expand All @@ -1186,19 +1186,19 @@
reference: referenceToUpload,
layers: []v1.Layer{
&MountableLayer{
Layer: dummyLayer,
Layer: wokeLayer,
Reference: anotherRepo1,
},
&MountableLayer{
Layer: dummyLayer,
Layer: wokeLayer,
Reference: anotherRepo2,
},
&MountableLayer{
Layer: dummyLayer,
Layer: wokeLayer,
Reference: anotherRepo1,
},
&MountableLayer{
Layer: dummyLayer,
Layer: wokeLayer,
Reference: anotherRepo2,
},
},
Expand All @@ -1213,7 +1213,7 @@
reference: referenceToUpload,
layers: []v1.Layer{
&MountableLayer{
Layer: dummyLayer,
Layer: wokeLayer,
Reference: repoOnOtherRegistry,
},
},
Expand Down Expand Up @@ -1590,7 +1590,7 @@
}

func BenchmarkWrite(b *testing.B) {
// unfortunately the registry _and_ the img have caching behaviour, so we need a new registry

Check failure on line 1593 in pkg/v1/remote/write_test.go

View workflow job for this annotation

GitHub Actions / Lint

[misspell] reported by reviewdog 🐶 "behaviour" is a misspelling of "behavior" Raw Output: ./pkg/v1/remote/write_test.go:1593:58: "behaviour" is a misspelling of "behavior"
// and image every iteration of benchmarking.
for i := 0; i < b.N; i++ {
// set up the registry
Expand Down
Loading