forked from TrueCloudLab/distribution
Remove references to schema1 pacakge from proxy package
schema1 package was deprecated a while ago so we are removing any references to it from the proxy package in preparation to removing it from the codebase altogether. Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
This commit is contained in:
parent
69fe169013
commit
ae0001f54d
2 changed files with 63 additions and 40 deletions
36
testutil/push.go
Normal file
36
testutil/push.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package testutil
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/distribution/distribution/v3"
|
||||
"github.com/opencontainers/go-digest"
|
||||
)
|
||||
|
||||
// PushBlob pushes a blob with the given digest to the given repository.
|
||||
func PushBlob(ctx context.Context, repository distribution.Repository, blobReader io.ReadSeeker, dgst digest.Digest) error {
|
||||
blobs := repository.Blobs(ctx)
|
||||
|
||||
wr, err := blobs.Create(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating layer upload: %v", err)
|
||||
}
|
||||
|
||||
// Use the resumes, as well!
|
||||
wr, err = blobs.Resume(ctx, wr.ID())
|
||||
if err != nil {
|
||||
return fmt.Errorf("error resuming layer upload: %v", err)
|
||||
}
|
||||
|
||||
if _, err := io.Copy(wr, blobReader); err != nil {
|
||||
return fmt.Errorf("unexpected error uploading: %v", err)
|
||||
}
|
||||
|
||||
if _, err := wr.Commit(ctx, distribution.Descriptor{Digest: dgst}); err != nil {
|
||||
return fmt.Errorf("unexpected error finishing upload: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue