From 5a0c9b2a13e505e4e46f8644ebd6f2b7aa083ab5 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Mon, 1 Oct 2018 14:11:26 -0400 Subject: [PATCH] Update go-containerregistry dep and remove unnecessary Options --- Gopkg.lock | 4 ++-- pkg/executor/build.go | 2 +- pkg/executor/push.go | 4 ++-- .../pkg/v1/daemon/write.go | 10 ++-------- .../pkg/v1/mutate/rebase.go | 6 +----- .../pkg/v1/remote/delete.go | 9 +-------- .../pkg/v1/remote/write.go | 12 +---------- .../pkg/v1/tarball/write.go | 20 +++++++------------ 8 files changed, 17 insertions(+), 50 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 176d4132aa..2196224921 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -431,7 +431,7 @@ [[projects]] branch = "master" - digest = "1:8ea12d703d8f36fec3db5e0dd85c9d3cc0b8b05ea8f9d090dcd41129cd392fd2" + digest = "1:edf64d541c12aaf4f279642ea9939f035dcc9fc2edf649aba295e9cbca2c28d4" name = "github.com/google/go-containerregistry" packages = [ "pkg/authn", @@ -450,7 +450,7 @@ "pkg/v1/v1util", ] pruneopts = "NUT" - revision = "6cfedf31db7d9e06c5beba68e9e1987a44fd844f" + revision = "03167950e20ac82689f50828811e69cdd9e02af2" [[projects]] branch = "master" diff --git a/pkg/executor/build.go b/pkg/executor/build.go index 5e10d16b54..080d24b8bb 100644 --- a/pkg/executor/build.go +++ b/pkg/executor/build.go @@ -307,7 +307,7 @@ func saveStageAsTarball(stageIndex int, image v1.Image) error { } tarPath := filepath.Join(constants.KanikoIntermediateStagesDir, strconv.Itoa(stageIndex)) logrus.Infof("Storing source image from stage %d at path %s", stageIndex, tarPath) - return tarball.WriteToFile(tarPath, destRef, image, nil) + return tarball.WriteToFile(tarPath, destRef, image) } func getHasher(snapshotMode string) (func(string) (string, error), error) { diff --git a/pkg/executor/push.go b/pkg/executor/push.go index aa68c723c1..6cfd39e9ed 100644 --- a/pkg/executor/push.go +++ b/pkg/executor/push.go @@ -66,7 +66,7 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error { for _, destRef := range destRefs { tagToImage[destRef] = image } - return tarball.MultiWriteToFile(opts.TarPath, tagToImage, nil) + return tarball.MultiWriteToFile(opts.TarPath, tagToImage) } // continue pushing unless an error occurs @@ -98,7 +98,7 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error { } rt := &withUserAgent{t: tr} - if err := remote.Write(destRef, image, pushAuth, rt, remote.WriteOptions{}); err != nil { + if err := remote.Write(destRef, image, pushAuth, rt); err != nil { return errors.Wrap(err, fmt.Sprintf("failed to push to destination %s", destRef)) } } diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/write.go index df61a7de4f..7310b70579 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/write.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/daemon/write.go @@ -44,14 +44,8 @@ var GetImageLoader = func() (ImageLoader, error) { return cli, nil } -// WriteOptions are used to expose optional information to guide or -// control the image write. -type WriteOptions struct { - // TODO(dlorenc): What kinds of knobs does the daemon expose? -} - // Write saves the image into the daemon as the given tag. -func Write(tag name.Tag, img v1.Image, wo WriteOptions) (string, error) { +func Write(tag name.Tag, img v1.Image) (string, error) { cli, err := GetImageLoader() if err != nil { return "", err @@ -59,7 +53,7 @@ func Write(tag name.Tag, img v1.Image, wo WriteOptions) (string, error) { pr, pw := io.Pipe() go func() { - pw.CloseWithError(tarball.Write(tag, img, &tarball.WriteOptions{}, pw)) + pw.CloseWithError(tarball.Write(tag, img, pw)) }() // write the image in docker save format first, then load it diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go index 9a4d4656a0..d6c8a7040d 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/mutate/rebase.go @@ -21,11 +21,7 @@ import ( "github.com/google/go-containerregistry/pkg/v1/empty" ) -type RebaseOptions struct { - // TODO(jasonhall): Rebase seam hint. -} - -func Rebase(orig, oldBase, newBase v1.Image, opts *RebaseOptions) (v1.Image, error) { +func Rebase(orig, oldBase, newBase v1.Image) (v1.Image, error) { // Verify that oldBase's layers are present in orig, otherwise orig is // not based on oldBase at all. origLayers, err := orig.Layers() diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/delete.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/delete.go index 5108a05dea..2032e276ea 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/delete.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/delete.go @@ -25,15 +25,8 @@ import ( "github.com/google/go-containerregistry/pkg/v1/remote/transport" ) -// DeleteOptions are used to expose optional information to guide or -// control the image deletion. -type DeleteOptions struct { - // TODO(mattmoor): Fail on not found? - // TODO(mattmoor): Delete tag and manifest? -} - // Delete removes the specified image reference from the remote registry. -func Delete(ref name.Reference, auth authn.Authenticator, t http.RoundTripper, do DeleteOptions) error { +func Delete(ref name.Reference, auth authn.Authenticator, t http.RoundTripper) error { scopes := []string{ref.Scope(transport.DeleteScope)} tr, err := transport.New(ref.Context().Registry, auth, t, scopes) if err != nil { diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go index af61e361be..1fd633c0d9 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/remote/write.go @@ -28,16 +28,8 @@ import ( "github.com/google/go-containerregistry/pkg/v1/remote/transport" ) -// WriteOptions are used to expose optional information to guide or -// control the image write. -type WriteOptions struct { - // TODO(mattmoor): Expose "threads" to limit parallelism? -} - // Write pushes the provided img to the specified image reference. -func Write(ref name.Reference, img v1.Image, auth authn.Authenticator, t http.RoundTripper, - wo WriteOptions) error { - +func Write(ref name.Reference, img v1.Image, auth authn.Authenticator, t http.RoundTripper) error { ls, err := img.Layers() if err != nil { return err @@ -52,7 +44,6 @@ func Write(ref name.Reference, img v1.Image, auth authn.Authenticator, t http.Ro ref: ref, client: &http.Client{Transport: tr}, img: img, - options: wo, } bs, err := img.BlobSet() @@ -92,7 +83,6 @@ type writer struct { ref name.Reference client *http.Client img v1.Image - options WriteOptions } // url returns a url.Url for the specified path in the context of this remote image reference. diff --git a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go index aa4313f16c..b0d45061eb 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go +++ b/vendor/github.com/google/go-containerregistry/pkg/v1/tarball/write.go @@ -26,39 +26,33 @@ import ( "github.com/google/go-containerregistry/pkg/v1" ) -// WriteOptions are used to expose optional information to guide or -// control the image write. -type WriteOptions struct { - // TODO(mattmoor): Whether to store things compressed? -} - // WriteToFile writes in the compressed format to a tarball, on disk. // This is just syntactic sugar wrapping tarball.Write with a new file. -func WriteToFile(p string, tag name.Tag, img v1.Image, wo *WriteOptions) error { +func WriteToFile(p string, tag name.Tag, img v1.Image) error { w, err := os.Create(p) if err != nil { return err } defer w.Close() - return Write(tag, img, wo, w) + return Write(tag, img, w) } // MultiWriteToFile writes in the compressed format to a tarball, on disk. // This is just syntactic sugar wrapping tarball.MultiWrite with a new file. -func MultiWriteToFile(p string, tagToImage map[name.Tag]v1.Image, wo *WriteOptions) error { +func MultiWriteToFile(p string, tagToImage map[name.Tag]v1.Image) error { w, err := os.Create(p) if err != nil { return err } defer w.Close() - return MultiWrite(tagToImage, wo, w) + return MultiWrite(tagToImage, w) } // Write is a wrapper to write a single image and tag to a tarball. -func Write(tag name.Tag, img v1.Image, wo *WriteOptions, w io.Writer) error { - return MultiWrite(map[name.Tag]v1.Image{tag: img}, wo, w) +func Write(tag name.Tag, img v1.Image, w io.Writer) error { + return MultiWrite(map[name.Tag]v1.Image{tag: img}, w) } // MultiWrite writes the contents of each image to the provided reader, in the compressed format. @@ -66,7 +60,7 @@ func Write(tag name.Tag, img v1.Image, wo *WriteOptions, w io.Writer) error { // One manifest.json file at the top level containing information about several images. // One file for each layer, named after the layer's SHA. // One file for the config blob, named after its SHA. -func MultiWrite(tagToImage map[name.Tag]v1.Image, wo *WriteOptions, w io.Writer) error { +func MultiWrite(tagToImage map[name.Tag]v1.Image, w io.Writer) error { tf := tar.NewWriter(w) defer tf.Close()