summaryrefslogtreecommitdiff
path: root/libpod/buildah
diff options
context:
space:
mode:
authorumohnani8 <umohnani@redhat.com>2018-04-18 16:48:35 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-19 14:08:47 +0000
commit27107fdac1d75f97caab47cd13efb1d9900cf350 (patch)
treef5edafbb52505829b15e19ea6a9e66f4440e862b /libpod/buildah
parent6a9dbf3305e93e5e1c3bff09402a9b801c935fbd (diff)
downloadpodman-27107fdac1d75f97caab47cd13efb1d9900cf350.tar.gz
podman-27107fdac1d75f97caab47cd13efb1d9900cf350.tar.bz2
podman-27107fdac1d75f97caab47cd13efb1d9900cf350.zip
Vendor in latest containers/image and contaners/storage
Made necessary changes to functions to include contex.Context wherever needed Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #640 Approved by: baude
Diffstat (limited to 'libpod/buildah')
-rw-r--r--libpod/buildah/buildah.go17
-rw-r--r--libpod/buildah/commit.go9
-rw-r--r--libpod/buildah/image.go18
3 files changed, 23 insertions, 21 deletions
diff --git a/libpod/buildah/buildah.go b/libpod/buildah/buildah.go
index b560f99a1..8f4b95ac8 100644
--- a/libpod/buildah/buildah.go
+++ b/libpod/buildah/buildah.go
@@ -1,6 +1,7 @@
package buildah
import (
+ "context"
"encoding/json"
"path/filepath"
@@ -128,11 +129,11 @@ type ImportOptions struct {
// ImportBuilder creates a new build configuration using an already-present
// container.
-func ImportBuilder(store storage.Store, options ImportOptions) (*Builder, error) {
- return importBuilder(store, options)
+func ImportBuilder(ctx context.Context, store storage.Store, options ImportOptions) (*Builder, error) {
+ return importBuilder(ctx, store, options)
}
-func importBuilder(store storage.Store, options ImportOptions) (*Builder, error) {
+func importBuilder(ctx context.Context, store storage.Store, options ImportOptions) (*Builder, error) {
if options.Container == "" {
return nil, errors.Errorf("container name must be specified")
}
@@ -144,7 +145,7 @@ func importBuilder(store storage.Store, options ImportOptions) (*Builder, error)
systemContext := getSystemContext(&types.SystemContext{}, options.SignaturePolicyPath)
- builder, err := importBuilderDataFromImage(store, systemContext, c.ImageID, options.Container, c.ID)
+ builder, err := importBuilderDataFromImage(ctx, store, systemContext, c.ImageID, options.Container, c.ID)
if err != nil {
return nil, err
}
@@ -168,7 +169,7 @@ func importBuilder(store storage.Store, options ImportOptions) (*Builder, error)
return builder, nil
}
-func importBuilderDataFromImage(store storage.Store, systemContext *types.SystemContext, imageID, containerName, containerID string) (*Builder, error) {
+func importBuilderDataFromImage(ctx context.Context, store storage.Store, systemContext *types.SystemContext, imageID, containerName, containerID string) (*Builder, error) {
manifest := []byte{}
config := []byte{}
imageName := ""
@@ -178,16 +179,16 @@ func importBuilderDataFromImage(store storage.Store, systemContext *types.System
if err != nil {
return nil, errors.Wrapf(err, "no such image %q", imageID)
}
- src, err2 := ref.NewImage(systemContext)
+ src, err2 := ref.NewImage(ctx, systemContext)
if err2 != nil {
return nil, errors.Wrapf(err2, "error instantiating image")
}
defer src.Close()
- config, err = src.ConfigBlob()
+ config, err = src.ConfigBlob(ctx)
if err != nil {
return nil, errors.Wrapf(err, "error reading image configuration")
}
- manifest, _, err = src.Manifest()
+ manifest, _, err = src.Manifest(ctx)
if err != nil {
return nil, errors.Wrapf(err, "error reading image manifest")
}
diff --git a/libpod/buildah/commit.go b/libpod/buildah/commit.go
index b862031d2..537f9edbf 100644
--- a/libpod/buildah/commit.go
+++ b/libpod/buildah/commit.go
@@ -1,6 +1,7 @@
package buildah
import (
+ "context"
"fmt"
"io"
"time"
@@ -74,7 +75,7 @@ type PushOptions struct {
// Commit writes the contents of the container, along with its updated
// configuration, to a new image in the specified location, and if we know how,
// add any additional tags that were specified.
-func (b *Builder) Commit(dest types.ImageReference, options CommitOptions) error {
+func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options CommitOptions) error {
policy, err := signature.DefaultPolicy(getSystemContext(options.SystemContext, options.SignaturePolicyPath))
if err != nil {
return errors.Wrapf(err, "error obtaining default signature policy")
@@ -96,7 +97,7 @@ func (b *Builder) Commit(dest types.ImageReference, options CommitOptions) error
return errors.Wrapf(err, "error computing layer digests and building metadata")
}
// "Copy" our image to where it needs to be.
- err = cp.Image(policyContext, dest, src, getCopyOptions(options.ReportWriter, nil, options.SystemContext, ""))
+ err = cp.Image(ctx, policyContext, dest, src, getCopyOptions(options.ReportWriter, nil, options.SystemContext, ""))
if err != nil {
return errors.Wrapf(err, "error copying layers and metadata")
}
@@ -120,7 +121,7 @@ func (b *Builder) Commit(dest types.ImageReference, options CommitOptions) error
}
// Push copies the contents of the image to a new location.
-func Push(image string, dest types.ImageReference, options PushOptions) error {
+func Push(ctx context.Context, image string, dest types.ImageReference, options PushOptions) error {
systemContext := getSystemContext(options.SystemContext, options.SignaturePolicyPath)
policy, err := signature.DefaultPolicy(systemContext)
if err != nil {
@@ -136,7 +137,7 @@ func Push(image string, dest types.ImageReference, options PushOptions) error {
return errors.Wrapf(err, "error parsing reference to image %q", image)
}
// Copy everything.
- err = cp.Image(policyContext, dest, src, getCopyOptions(options.ReportWriter, nil, options.SystemContext, options.ManifestType))
+ err = cp.Image(ctx, policyContext, dest, src, getCopyOptions(options.ReportWriter, nil, options.SystemContext, options.ManifestType))
if err != nil {
return errors.Wrapf(err, "error copying layers and metadata")
}
diff --git a/libpod/buildah/image.go b/libpod/buildah/image.go
index 656c39201..7232d53ad 100644
--- a/libpod/buildah/image.go
+++ b/libpod/buildah/image.go
@@ -65,12 +65,12 @@ type containerImageSource struct {
exporting bool
}
-func (i *containerImageRef) NewImage(sc *types.SystemContext) (types.ImageCloser, error) {
- src, err := i.NewImageSource(sc)
+func (i *containerImageRef) NewImage(ctx context.Context, sc *types.SystemContext) (types.ImageCloser, error) {
+ src, err := i.NewImageSource(ctx, sc)
if err != nil {
return nil, err
}
- return image.FromSource(sc, src)
+ return image.FromSource(ctx, sc, src)
}
func expectedOCIDiffIDs(image v1.Image) int {
@@ -93,7 +93,7 @@ func expectedDockerDiffIDs(image docker.V2Image) int {
return expected
}
-func (i *containerImageRef) NewImageSource(sc *types.SystemContext) (src types.ImageSource, err error) {
+func (i *containerImageRef) NewImageSource(ctx context.Context, sc *types.SystemContext) (src types.ImageSource, err error) {
// Decide which type of manifest and configuration output we're going to provide.
manifestType := i.preferredManifestType
// If it's not a format we support, return an error.
@@ -392,7 +392,7 @@ func (i *containerImageRef) NewImageSource(sc *types.SystemContext) (src types.I
return src, nil
}
-func (i *containerImageRef) NewImageDestination(sc *types.SystemContext) (types.ImageDestination, error) {
+func (i *containerImageRef) NewImageDestination(ctx context.Context, sc *types.SystemContext) (types.ImageDestination, error) {
return nil, errors.Errorf("can't write to a container")
}
@@ -407,7 +407,7 @@ func (i *containerImageRef) StringWithinTransport() string {
return ""
}
-func (i *containerImageRef) DeleteImage(*types.SystemContext) error {
+func (i *containerImageRef) DeleteImage(context.Context, *types.SystemContext) error {
// we were never here
return nil
}
@@ -443,18 +443,18 @@ func (i *containerImageSource) GetSignatures(ctx context.Context, instanceDigest
return nil, nil
}
-func (i *containerImageSource) GetManifest(instanceDigest *digest.Digest) ([]byte, string, error) {
+func (i *containerImageSource) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error) {
if instanceDigest != nil && *instanceDigest != digest.FromBytes(i.manifest) {
return nil, "", errors.Errorf("TODO")
}
return i.manifest, i.manifestType, nil
}
-func (i *containerImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (i *containerImageSource) LayerInfosForCopy(context.Context) ([]types.BlobInfo, error) {
return nil, nil
}
-func (i *containerImageSource) GetBlob(blob types.BlobInfo) (reader io.ReadCloser, size int64, err error) {
+func (i *containerImageSource) GetBlob(ctx context.Context, blob types.BlobInfo) (reader io.ReadCloser, size int64, err error) {
if blob.Digest == i.configDigest {
logrus.Debugf("start reading config")
reader := bytes.NewReader(i.config)