Update go-containerregistry dep and remove unnecessary Options

This commit is contained in:
Jason Hall 2018-10-01 14:11:26 -04:00
parent 139d372e77
commit 5a0c9b2a13
8 changed files with 17 additions and 50 deletions

4
Gopkg.lock generated
View File

@ -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"

View File

@ -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) {

View File

@ -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))
}
}

View File

@ -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

View File

@ -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()

View File

@ -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 {

View File

@ -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.

View File

@ -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()