summaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/containerd/continuity/README.md74
-rw-r--r--vendor/github.com/containerd/continuity/vendor.conf12
-rw-r--r--vendor/github.com/containers/image/copy/copy.go102
-rw-r--r--vendor/github.com/containers/image/copy/manifest.go9
-rw-r--r--vendor/github.com/containers/image/directory/directory_dest.go16
-rw-r--r--vendor/github.com/containers/image/directory/directory_src.go6
-rw-r--r--vendor/github.com/containers/image/directory/directory_transport.go15
-rw-r--r--vendor/github.com/containers/image/docker/archive/dest.go7
-rw-r--r--vendor/github.com/containers/image/docker/archive/src.go5
-rw-r--r--vendor/github.com/containers/image/docker/archive/transport.go13
-rw-r--r--vendor/github.com/containers/image/docker/daemon/client.go20
-rw-r--r--vendor/github.com/containers/image/docker/daemon/daemon_dest.go22
-rw-r--r--vendor/github.com/containers/image/docker/daemon/daemon_src.go11
-rw-r--r--vendor/github.com/containers/image/docker/daemon/daemon_transport.go17
-rw-r--r--vendor/github.com/containers/image/docker/docker_client.go50
-rw-r--r--vendor/github.com/containers/image/docker/docker_image.go10
-rw-r--r--vendor/github.com/containers/image/docker/docker_image_dest.go42
-rw-r--r--vendor/github.com/containers/image/docker/docker_image_src.go32
-rw-r--r--vendor/github.com/containers/image/docker/docker_transport.go17
-rw-r--r--vendor/github.com/containers/image/docker/lookaside.go16
-rw-r--r--vendor/github.com/containers/image/docker/tarfile/dest.go19
-rw-r--r--vendor/github.com/containers/image/docker/tarfile/src.go9
-rw-r--r--vendor/github.com/containers/image/image/docker_list.go25
-rw-r--r--vendor/github.com/containers/image/image/docker_schema1.go13
-rw-r--r--vendor/github.com/containers/image/image/docker_schema2.go29
-rw-r--r--vendor/github.com/containers/image/image/manifest.go13
-rw-r--r--vendor/github.com/containers/image/image/memory.go4
-rw-r--r--vendor/github.com/containers/image/image/oci.go17
-rw-r--r--vendor/github.com/containers/image/image/sourced.go17
-rw-r--r--vendor/github.com/containers/image/image/unparsed.go4
-rw-r--r--vendor/github.com/containers/image/oci/archive/oci_dest.go34
-rw-r--r--vendor/github.com/containers/image/oci/archive/oci_src.go14
-rw-r--r--vendor/github.com/containers/image/oci/archive/oci_transport.go18
-rw-r--r--vendor/github.com/containers/image/oci/layout/oci_dest.go29
-rw-r--r--vendor/github.com/containers/image/oci/layout/oci_src.go31
-rw-r--r--vendor/github.com/containers/image/oci/layout/oci_transport.go17
-rw-r--r--vendor/github.com/containers/image/openshift/openshift.go54
-rw-r--r--vendor/github.com/containers/image/openshift/openshift_transport.go17
-rw-r--r--vendor/github.com/containers/image/ostree/ostree_dest.go18
-rw-r--r--vendor/github.com/containers/image/ostree/ostree_src.go12
-rw-r--r--vendor/github.com/containers/image/ostree/ostree_transport.go27
-rw-r--r--vendor/github.com/containers/image/pkg/docker/config/config.go40
-rw-r--r--vendor/github.com/containers/image/pkg/sysregistries/system_registries.go24
-rw-r--r--vendor/github.com/containers/image/signature/policy_config.go18
-rw-r--r--vendor/github.com/containers/image/signature/policy_eval.go14
-rw-r--r--vendor/github.com/containers/image/signature/policy_eval_baselayer.go6
-rw-r--r--vendor/github.com/containers/image/signature/policy_eval_signedby.go10
-rw-r--r--vendor/github.com/containers/image/signature/policy_eval_simple.go9
-rw-r--r--vendor/github.com/containers/image/storage/storage_image.go34
-rw-r--r--vendor/github.com/containers/image/storage/storage_reference.go13
-rw-r--r--vendor/github.com/containers/image/tarball/tarball_reference.go11
-rw-r--r--vendor/github.com/containers/image/tarball/tarball_src.go9
-rw-r--r--vendor/github.com/containers/image/types/types.go40
-rw-r--r--vendor/github.com/containers/image/vendor.conf4
-rw-r--r--vendor/github.com/containers/storage/pkg/archive/example_changes.go97
-rw-r--r--vendor/github.com/containers/storage/store.go14
-rw-r--r--vendor/github.com/cyphar/filepath-securejoin/LICENSE28
-rw-r--r--vendor/github.com/cyphar/filepath-securejoin/README.md65
-rw-r--r--vendor/github.com/cyphar/filepath-securejoin/vendor.conf1
-rw-r--r--vendor/github.com/docker/docker/hack/README.md60
-rw-r--r--vendor/github.com/docker/docker/hack/integration-cli-on-swarm/README.md69
-rw-r--r--vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/vendor.conf2
-rw-r--r--vendor/github.com/docker/docker/profiles/seccomp/generate.go32
-rw-r--r--vendor/github.com/varlink/go/.gitignore0
-rw-r--r--vendor/github.com/varlink/go/.travis.yml13
-rw-r--r--vendor/github.com/varlink/go/LICENSE (renamed from vendor/github.com/containerd/continuity/LICENSE)5
-rw-r--r--vendor/github.com/varlink/go/Makefile3
-rw-r--r--vendor/github.com/varlink/go/README.md7
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/generator_test.go85
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go294
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink-go-type-generator/main.go142
-rw-r--r--vendor/github.com/varlink/go/golang-github-varlink-go.spec44
-rw-r--r--vendor/github.com/varlink/go/varlink/call.go86
-rw-r--r--vendor/github.com/varlink/go/varlink/connection.go197
-rw-r--r--vendor/github.com/varlink/go/varlink/doc.go63
-rw-r--r--vendor/github.com/varlink/go/varlink/external_test.go144
-rw-r--r--vendor/github.com/varlink/go/varlink/idl/idl.go465
-rw-r--r--vendor/github.com/varlink/go/varlink/idl/idl_test.go127
-rw-r--r--vendor/github.com/varlink/go/varlink/orgvarlinkservice.go133
-rw-r--r--vendor/github.com/varlink/go/varlink/resolver.go92
-rw-r--r--vendor/github.com/varlink/go/varlink/service.go350
-rw-r--r--vendor/github.com/varlink/go/varlink/varlink_test.go232
82 files changed, 3049 insertions, 950 deletions
diff --git a/vendor/github.com/containerd/continuity/README.md b/vendor/github.com/containerd/continuity/README.md
deleted file mode 100644
index 0e91ce07b..000000000
--- a/vendor/github.com/containerd/continuity/README.md
+++ /dev/null
@@ -1,74 +0,0 @@
-# continuity
-
-[![GoDoc](https://godoc.org/github.com/containerd/continuity?status.svg)](https://godoc.org/github.com/containerd/continuity)
-[![Build Status](https://travis-ci.org/containerd/continuity.svg?branch=master)](https://travis-ci.org/containerd/continuity)
-
-A transport-agnostic, filesystem metadata manifest system
-
-This project is a staging area for experiments in providing transport agnostic
-metadata storage.
-
-Please see https://github.com/opencontainers/specs/issues/11 for more details.
-
-## Manifest Format
-
-A continuity manifest encodes filesystem metadata in Protocol Buffers.
-Please refer to [proto/manifest.proto](proto/manifest.proto).
-
-## Usage
-
-Build:
-
-```console
-$ make
-```
-
-Create a manifest (of this repo itself):
-
-```console
-$ ./bin/continuity build . > /tmp/a.pb
-```
-
-Dump a manifest:
-
-```console
-$ ./bin/continuity ls /tmp/a.pb
-...
--rw-rw-r-- 270 B /.gitignore
--rw-rw-r-- 88 B /.mailmap
--rw-rw-r-- 187 B /.travis.yml
--rw-rw-r-- 359 B /AUTHORS
--rw-rw-r-- 11 kB /LICENSE
--rw-rw-r-- 1.5 kB /Makefile
-...
--rw-rw-r-- 986 B /testutil_test.go
-drwxrwxr-x 0 B /version
--rw-rw-r-- 478 B /version/version.go
-```
-
-Verify a manifest:
-
-```console
-$ ./bin/continuity verify . /tmp/a.pb
-```
-
-Break the directory and restore using the manifest:
-```console
-$ chmod 777 Makefile
-$ ./bin/continuity verify . /tmp/a.pb
-2017/06/23 08:00:34 error verifying manifest: resource "/Makefile" has incorrect mode: -rwxrwxrwx != -rw-rw-r--
-$ ./bin/continuity apply . /tmp/a.pb
-$ stat -c %a Makefile
-664
-$ ./bin/continuity verify . /tmp/a.pb
-```
-
-
-## Contribution Guide
-### Building Proto Package
-
-If you change the proto file you will need to rebuild the generated Go with `go generate`.
-
-```console
-$ go generate ./proto
-```
diff --git a/vendor/github.com/containerd/continuity/vendor.conf b/vendor/github.com/containerd/continuity/vendor.conf
deleted file mode 100644
index feecf3568..000000000
--- a/vendor/github.com/containerd/continuity/vendor.conf
+++ /dev/null
@@ -1,12 +0,0 @@
-bazil.org/fuse 371fbbdaa8987b715bdd21d6adc4c9b20155f748
-github.com/dustin/go-humanize bb3d318650d48840a39aa21a027c6630e198e626
-github.com/golang/protobuf 1e59b77b52bf8e4b449a57e6f79f21226d571845
-github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
-github.com/opencontainers/go-digest 279bed98673dd5bef374d3b6e4b09e2af76183bf
-github.com/pkg/errors f15c970de5b76fac0b59abb32d62c17cc7bed265
-github.com/sirupsen/logrus 89742aefa4b206dcf400792f3bd35b542998eb3b
-github.com/spf13/cobra 2da4a54c5ceefcee7ca5dd0eea1e18a3b6366489
-github.com/spf13/pflag 4c012f6dcd9546820e378d0bdda4d8fc772cdfea
-golang.org/x/crypto 9f005a07e0d31d45e6656d241bb5c0f2efd4bc94
-golang.org/x/net a337091b0525af65de94df2eb7e98bd9962dcbe2
-golang.org/x/sys 665f6529cca930e27b831a0d1dafffbe1c172924
diff --git a/vendor/github.com/containers/image/copy/copy.go b/vendor/github.com/containers/image/copy/copy.go
index 17f4bcbec..65c3853be 100644
--- a/vendor/github.com/containers/image/copy/copy.go
+++ b/vendor/github.com/containers/image/copy/copy.go
@@ -104,7 +104,7 @@ type Options struct {
// Image copies image from srcRef to destRef, using policyContext to validate
// source image admissibility.
-func Image(policyContext *signature.PolicyContext, destRef, srcRef types.ImageReference, options *Options) (retErr error) {
+func Image(ctx context.Context, policyContext *signature.PolicyContext, destRef, srcRef types.ImageReference, options *Options) (retErr error) {
// NOTE this function uses an output parameter for the error return value.
// Setting this and returning is the ideal way to return an error.
//
@@ -120,7 +120,7 @@ func Image(policyContext *signature.PolicyContext, destRef, srcRef types.ImageRe
reportWriter = options.ReportWriter
}
- dest, err := destRef.NewImageDestination(options.DestinationCtx)
+ dest, err := destRef.NewImageDestination(ctx, options.DestinationCtx)
if err != nil {
return errors.Wrapf(err, "Error initializing destination %s", transports.ImageName(destRef))
}
@@ -130,7 +130,7 @@ func Image(policyContext *signature.PolicyContext, destRef, srcRef types.ImageRe
}
}()
- rawSource, err := srcRef.NewImageSource(options.SourceCtx)
+ rawSource, err := srcRef.NewImageSource(ctx, options.SourceCtx)
if err != nil {
return errors.Wrapf(err, "Error initializing source %s", transports.ImageName(srcRef))
}
@@ -151,32 +151,32 @@ func Image(policyContext *signature.PolicyContext, destRef, srcRef types.ImageRe
}
unparsedToplevel := image.UnparsedInstance(rawSource, nil)
- multiImage, err := isMultiImage(unparsedToplevel)
+ multiImage, err := isMultiImage(ctx, unparsedToplevel)
if err != nil {
return errors.Wrapf(err, "Error determining manifest MIME type for %s", transports.ImageName(srcRef))
}
if !multiImage {
// The simple case: Just copy a single image.
- if err := c.copyOneImage(policyContext, options, unparsedToplevel); err != nil {
+ if err := c.copyOneImage(ctx, policyContext, options, unparsedToplevel); err != nil {
return err
}
} else {
// This is a manifest list. Choose a single image and copy it.
// FIXME: Copy to destinations which support manifest lists, one image at a time.
- instanceDigest, err := image.ChooseManifestInstanceFromManifestList(options.SourceCtx, unparsedToplevel)
+ instanceDigest, err := image.ChooseManifestInstanceFromManifestList(ctx, options.SourceCtx, unparsedToplevel)
if err != nil {
return errors.Wrapf(err, "Error choosing an image from manifest list %s", transports.ImageName(srcRef))
}
logrus.Debugf("Source is a manifest list; copying (only) instance %s", instanceDigest)
unparsedInstance := image.UnparsedInstance(rawSource, &instanceDigest)
- if err := c.copyOneImage(policyContext, options, unparsedInstance); err != nil {
+ if err := c.copyOneImage(ctx, policyContext, options, unparsedInstance); err != nil {
return err
}
}
- if err := c.dest.Commit(); err != nil {
+ if err := c.dest.Commit(ctx); err != nil {
return errors.Wrap(err, "Error committing the finished image")
}
@@ -185,10 +185,10 @@ func Image(policyContext *signature.PolicyContext, destRef, srcRef types.ImageRe
// Image copies a single (on-manifest-list) image unparsedImage, using policyContext to validate
// source image admissibility.
-func (c *copier) copyOneImage(policyContext *signature.PolicyContext, options *Options, unparsedImage *image.UnparsedImage) (retErr error) {
+func (c *copier) copyOneImage(ctx context.Context, policyContext *signature.PolicyContext, options *Options, unparsedImage *image.UnparsedImage) (retErr error) {
// The caller is handling manifest lists; this could happen only if a manifest list contains a manifest list.
// Make sure we fail cleanly in such cases.
- multiImage, err := isMultiImage(unparsedImage)
+ multiImage, err := isMultiImage(ctx, unparsedImage)
if err != nil {
// FIXME FIXME: How to name a reference for the sub-image?
return errors.Wrapf(err, "Error determining manifest MIME type for %s", transports.ImageName(unparsedImage.Reference()))
@@ -200,15 +200,15 @@ func (c *copier) copyOneImage(policyContext *signature.PolicyContext, options *O
// Please keep this policy check BEFORE reading any other information about the image.
// (the multiImage check above only matches the MIME type, which we have received anyway.
// Actual parsing of anything should be deferred.)
- if allowed, err := policyContext.IsRunningImageAllowed(unparsedImage); !allowed || err != nil { // Be paranoid and fail if either return value indicates so.
+ if allowed, err := policyContext.IsRunningImageAllowed(ctx, unparsedImage); !allowed || err != nil { // Be paranoid and fail if either return value indicates so.
return errors.Wrap(err, "Source image rejected")
}
- src, err := image.FromUnparsedImage(options.SourceCtx, unparsedImage)
+ src, err := image.FromUnparsedImage(ctx, options.SourceCtx, unparsedImage)
if err != nil {
return errors.Wrapf(err, "Error initializing image from source %s", transports.ImageName(c.rawSource.Reference()))
}
- if err := checkImageDestinationForCurrentRuntimeOS(options.DestinationCtx, src, c.dest); err != nil {
+ if err := checkImageDestinationForCurrentRuntimeOS(ctx, options.DestinationCtx, src, c.dest); err != nil {
return err
}
@@ -217,7 +217,7 @@ func (c *copier) copyOneImage(policyContext *signature.PolicyContext, options *O
sigs = [][]byte{}
} else {
c.Printf("Getting image source signatures\n")
- s, err := src.Signatures(context.TODO())
+ s, err := src.Signatures(ctx)
if err != nil {
return errors.Wrap(err, "Error reading signatures")
}
@@ -225,7 +225,7 @@ func (c *copier) copyOneImage(policyContext *signature.PolicyContext, options *O
}
if len(sigs) != 0 {
c.Printf("Checking if image destination supports signatures\n")
- if err := c.dest.SupportsSignatures(); err != nil {
+ if err := c.dest.SupportsSignatures(ctx); err != nil {
return errors.Wrap(err, "Can not copy signatures")
}
}
@@ -244,7 +244,7 @@ func (c *copier) copyOneImage(policyContext *signature.PolicyContext, options *O
// We compute preferredManifestMIMEType only to show it in error messages.
// Without having to add this context in an error message, we would be happy enough to know only that no conversion is needed.
- preferredManifestMIMEType, otherManifestMIMETypeCandidates, err := ic.determineManifestConversion(c.dest.SupportedManifestMIMETypes(), options.ForceManifestMIMEType)
+ preferredManifestMIMEType, otherManifestMIMETypeCandidates, err := ic.determineManifestConversion(ctx, c.dest.SupportedManifestMIMETypes(), options.ForceManifestMIMEType)
if err != nil {
return err
}
@@ -252,7 +252,7 @@ func (c *copier) copyOneImage(policyContext *signature.PolicyContext, options *O
// If src.UpdatedImageNeedsLayerDiffIDs(ic.manifestUpdates) will be true, it needs to be true by the time we get here.
ic.diffIDsAreNeeded = src.UpdatedImageNeedsLayerDiffIDs(*ic.manifestUpdates)
- if err := ic.copyLayers(); err != nil {
+ if err := ic.copyLayers(ctx); err != nil {
return err
}
@@ -260,7 +260,7 @@ func (c *copier) copyOneImage(policyContext *signature.PolicyContext, options *O
// and at least with the OpenShift registry "acceptschema2" option, there is no way to detect the support
// without actually trying to upload something and getting a types.ManifestTypeRejectedError.
// So, try the preferred manifest MIME type. If the process succeeds, fine…
- manifest, err := ic.copyUpdatedConfigAndManifest()
+ manifest, err := ic.copyUpdatedConfigAndManifest(ctx)
if err != nil {
logrus.Debugf("Writing manifest using preferred type %s failed: %v", preferredManifestMIMEType, err)
// … if it fails, _and_ the failure is because the manifest is rejected, we may have other options.
@@ -283,7 +283,7 @@ func (c *copier) copyOneImage(policyContext *signature.PolicyContext, options *O
for _, manifestMIMEType := range otherManifestMIMETypeCandidates {
logrus.Debugf("Trying to use manifest type %s…", manifestMIMEType)
ic.manifestUpdates.ManifestMIMEType = manifestMIMEType
- attemptedManifest, err := ic.copyUpdatedConfigAndManifest()
+ attemptedManifest, err := ic.copyUpdatedConfigAndManifest(ctx)
if err != nil {
logrus.Debugf("Upload of manifest type %s failed: %v", manifestMIMEType, err)
errs = append(errs, fmt.Sprintf("%s(%v)", manifestMIMEType, err))
@@ -309,7 +309,7 @@ func (c *copier) copyOneImage(policyContext *signature.PolicyContext, options *O
}
c.Printf("Storing signatures\n")
- if err := c.dest.PutSignatures(sigs); err != nil {
+ if err := c.dest.PutSignatures(ctx, sigs); err != nil {
return errors.Wrap(err, "Error writing signatures")
}
@@ -325,13 +325,13 @@ func (c *copier) Printf(format string, a ...interface{}) {
fmt.Fprintf(c.reportWriter, format, a...)
}
-func checkImageDestinationForCurrentRuntimeOS(ctx *types.SystemContext, src types.Image, dest types.ImageDestination) error {
+func checkImageDestinationForCurrentRuntimeOS(ctx context.Context, sys *types.SystemContext, src types.Image, dest types.ImageDestination) error {
if dest.MustMatchRuntimeOS() {
wantedOS := runtime.GOOS
- if ctx != nil && ctx.OSChoice != "" {
- wantedOS = ctx.OSChoice
+ if sys != nil && sys.OSChoice != "" {
+ wantedOS = sys.OSChoice
}
- c, err := src.OCIConfig()
+ c, err := src.OCIConfig(ctx)
if err != nil {
return errors.Wrapf(err, "Error parsing image configuration")
}
@@ -364,11 +364,11 @@ func (ic *imageCopier) updateEmbeddedDockerReference() error {
}
// copyLayers copies layers from ic.src/ic.c.rawSource to dest, using and updating ic.manifestUpdates if necessary and ic.canModifyManifest.
-func (ic *imageCopier) copyLayers() error {
+func (ic *imageCopier) copyLayers(ctx context.Context) error {
srcInfos := ic.src.LayerInfos()
destInfos := []types.BlobInfo{}
diffIDs := []digest.Digest{}
- updatedSrcInfos, err := ic.src.LayerInfosForCopy()
+ updatedSrcInfos, err := ic.src.LayerInfosForCopy(ctx)
if err != nil {
return err
}
@@ -396,7 +396,7 @@ func (ic *imageCopier) copyLayers() error {
destInfo = srcLayer
ic.c.Printf("Skipping foreign layer %q copy to %s\n", destInfo.Digest, ic.c.dest.Reference().Transport().Name())
} else {
- destInfo, diffID, err = ic.copyLayer(srcLayer)
+ destInfo, diffID, err = ic.copyLayer(ctx, srcLayer)
if err != nil {
return err
}
@@ -429,7 +429,7 @@ func layerDigestsDiffer(a, b []types.BlobInfo) bool {
// copyUpdatedConfigAndManifest updates the image per ic.manifestUpdates, if necessary,
// stores the resulting config and manifest to the destination, and returns the stored manifest.
-func (ic *imageCopier) copyUpdatedConfigAndManifest() ([]byte, error) {
+func (ic *imageCopier) copyUpdatedConfigAndManifest(ctx context.Context) ([]byte, error) {
pendingImage := ic.src
if !reflect.DeepEqual(*ic.manifestUpdates, types.ManifestUpdateOptions{InformationOnly: ic.manifestUpdates.InformationOnly}) {
if !ic.canModifyManifest {
@@ -444,38 +444,38 @@ func (ic *imageCopier) copyUpdatedConfigAndManifest() ([]byte, error) {
// If handling such registries turns out to be necessary, we could compute ic.diffIDsAreNeeded based on the full list of manifest MIME type candidates.
return nil, errors.Errorf("Can not convert image to %s, preparing DiffIDs for this case is not supported", ic.manifestUpdates.ManifestMIMEType)
}
- pi, err := ic.src.UpdatedImage(*ic.manifestUpdates)
+ pi, err := ic.src.UpdatedImage(ctx, *ic.manifestUpdates)
if err != nil {
return nil, errors.Wrap(err, "Error creating an updated image manifest")
}
pendingImage = pi
}
- manifest, _, err := pendingImage.Manifest()
+ manifest, _, err := pendingImage.Manifest(ctx)
if err != nil {
return nil, errors.Wrap(err, "Error reading manifest")
}
- if err := ic.c.copyConfig(pendingImage); err != nil {
+ if err := ic.c.copyConfig(ctx, pendingImage); err != nil {
return nil, err
}
ic.c.Printf("Writing manifest to image destination\n")
- if err := ic.c.dest.PutManifest(manifest); err != nil {
+ if err := ic.c.dest.PutManifest(ctx, manifest); err != nil {
return nil, errors.Wrap(err, "Error writing manifest")
}
return manifest, nil
}
// copyConfig copies config.json, if any, from src to dest.
-func (c *copier) copyConfig(src types.Image) error {
+func (c *copier) copyConfig(ctx context.Context, src types.Image) error {
srcInfo := src.ConfigInfo()
if srcInfo.Digest != "" {
c.Printf("Copying config %s\n", srcInfo.Digest)
- configBlob, err := src.ConfigBlob()
+ configBlob, err := src.ConfigBlob(ctx)
if err != nil {
return errors.Wrapf(err, "Error reading config blob %s", srcInfo.Digest)
}
- destInfo, err := c.copyBlobFromStream(bytes.NewReader(configBlob), srcInfo, nil, false, true)
+ destInfo, err := c.copyBlobFromStream(ctx, bytes.NewReader(configBlob), srcInfo, nil, false, true)
if err != nil {
return err
}
@@ -495,9 +495,9 @@ type diffIDResult struct {
// copyLayer copies a layer with srcInfo (with known Digest and possibly known Size) in src to dest, perhaps compressing it if canCompress,
// and returns a complete blobInfo of the copied layer, and a value for LayerDiffIDs if diffIDIsNeeded
-func (ic *imageCopier) copyLayer(srcInfo types.BlobInfo) (types.BlobInfo, digest.Digest, error) {
+func (ic *imageCopier) copyLayer(ctx context.Context, srcInfo types.BlobInfo) (types.BlobInfo, digest.Digest, error) {
// Check if we already have a blob with this digest
- haveBlob, extantBlobSize, err := ic.c.dest.HasBlob(srcInfo)
+ haveBlob, extantBlobSize, err := ic.c.dest.HasBlob(ctx, srcInfo)
if err != nil {
return types.BlobInfo{}, "", errors.Wrapf(err, "Error checking for blob %s at destination", srcInfo.Digest)
}
@@ -511,7 +511,7 @@ func (ic *imageCopier) copyLayer(srcInfo types.BlobInfo) (types.BlobInfo, digest
}
srcInfo.Size = extantBlobSize
// Tell the image destination that this blob's delta is being applied again. For some image destinations, this can be faster than using GetBlob/PutBlob
- blobinfo, err := ic.c.dest.ReapplyBlob(srcInfo)
+ blobinfo, err := ic.c.dest.ReapplyBlob(ctx, srcInfo)
if err != nil {
return types.BlobInfo{}, "", errors.Wrapf(err, "Error reapplying blob %s at destination", srcInfo.Digest)
}
@@ -521,25 +521,29 @@ func (ic *imageCopier) copyLayer(srcInfo types.BlobInfo) (types.BlobInfo, digest
// Fallback: copy the layer, computing the diffID if we need to do so
ic.c.Printf("Copying blob %s\n", srcInfo.Digest)
- srcStream, srcBlobSize, err := ic.c.rawSource.GetBlob(srcInfo)
+ srcStream, srcBlobSize, err := ic.c.rawSource.GetBlob(ctx, srcInfo)
if err != nil {
return types.BlobInfo{}, "", errors.Wrapf(err, "Error reading blob %s", srcInfo.Digest)
}
defer srcStream.Close()
- blobInfo, diffIDChan, err := ic.copyLayerFromStream(srcStream, types.BlobInfo{Digest: srcInfo.Digest, Size: srcBlobSize},
+ blobInfo, diffIDChan, err := ic.copyLayerFromStream(ctx, srcStream, types.BlobInfo{Digest: srcInfo.Digest, Size: srcBlobSize},
diffIDIsNeeded)
if err != nil {
return types.BlobInfo{}, "", err
}
var diffIDResult diffIDResult // = {digest:""}
if diffIDIsNeeded {
- diffIDResult = <-diffIDChan
- if diffIDResult.err != nil {
- return types.BlobInfo{}, "", errors.Wrap(diffIDResult.err, "Error computing layer DiffID")
+ select {
+ case <-ctx.Done():
+ return types.BlobInfo{}, "", ctx.Err()
+ case diffIDResult = <-diffIDChan:
+ if diffIDResult.err != nil {
+ return types.BlobInfo{}, "", errors.Wrap(diffIDResult.err, "Error computing layer DiffID")
+ }
+ logrus.Debugf("Computed DiffID %s for layer %s", diffIDResult.digest, srcInfo.Digest)
+ ic.c.cachedDiffIDs[srcInfo.Digest] = diffIDResult.digest
}
- logrus.Debugf("Computed DiffID %s for layer %s", diffIDResult.digest, srcInfo.Digest)
- ic.c.cachedDiffIDs[srcInfo.Digest] = diffIDResult.digest
}
return blobInfo, diffIDResult.digest, nil
}
@@ -548,7 +552,7 @@ func (ic *imageCopier) copyLayer(srcInfo types.BlobInfo) (types.BlobInfo, digest
// it copies a blob with srcInfo (with known Digest and possibly known Size) from srcStream to dest,
// perhaps compressing the stream if canCompress,
// and returns a complete blobInfo of the copied blob and perhaps a <-chan diffIDResult if diffIDIsNeeded, to be read by the caller.
-func (ic *imageCopier) copyLayerFromStream(srcStream io.Reader, srcInfo types.BlobInfo,
+func (ic *imageCopier) copyLayerFromStream(ctx context.Context, srcStream io.Reader, srcInfo types.BlobInfo,
diffIDIsNeeded bool) (types.BlobInfo, <-chan diffIDResult, error) {
var getDiffIDRecorder func(compression.DecompressorFunc) io.Writer // = nil
var diffIDChan chan diffIDResult
@@ -573,7 +577,7 @@ func (ic *imageCopier) copyLayerFromStream(srcStream io.Reader, srcInfo types.Bl
return pipeWriter
}
}
- blobInfo, err := ic.c.copyBlobFromStream(srcStream, srcInfo, getDiffIDRecorder, ic.canModifyManifest, false) // Sets err to nil on success
+ blobInfo, err := ic.c.copyBlobFromStream(ctx, srcStream, srcInfo, getDiffIDRecorder, ic.canModifyManifest, false) // Sets err to nil on success
return blobInfo, diffIDChan, err
// We need the defer … pipeWriter.CloseWithError() to happen HERE so that the caller can block on reading from diffIDChan
}
@@ -607,7 +611,7 @@ func computeDiffID(stream io.Reader, decompressor compression.DecompressorFunc)
// perhaps sending a copy to an io.Writer if getOriginalLayerCopyWriter != nil,
// perhaps compressing it if canCompress,
// and returns a complete blobInfo of the copied blob.
-func (c *copier) copyBlobFromStream(srcStream io.Reader, srcInfo types.BlobInfo,
+func (c *copier) copyBlobFromStream(ctx context.Context, srcStream io.Reader, srcInfo types.BlobInfo,
getOriginalLayerCopyWriter func(decompressor compression.DecompressorFunc) io.Writer,
canModifyBlob bool, isConfig bool) (types.BlobInfo, error) {
// The copying happens through a pipeline of connected io.Readers.
@@ -689,7 +693,7 @@ func (c *copier) copyBlobFromStream(srcStream io.Reader, srcInfo types.BlobInfo,
}
// === Finally, send the layer stream to dest.
- uploadedInfo, err := c.dest.PutBlob(destStream, inputInfo, isConfig)
+ uploadedInfo, err := c.dest.PutBlob(ctx, destStream, inputInfo, isConfig)
if err != nil {
return types.BlobInfo{}, errors.Wrap(err, "Error writing blob")
}
diff --git a/vendor/github.com/containers/image/copy/manifest.go b/vendor/github.com/containers/image/copy/manifest.go
index c612c51a3..e8cc8a9e7 100644
--- a/vendor/github.com/containers/image/copy/manifest.go
+++ b/vendor/github.com/containers/image/copy/manifest.go
@@ -1,6 +1,7 @@
package copy
import (
+ "context"
"strings"
"github.com/containers/image/manifest"
@@ -41,8 +42,8 @@ func (os *orderedSet) append(s string) {
// Note that the conversion will only happen later, through ic.src.UpdatedImage
// Returns the preferred manifest MIME type (whether we are converting to it or using it unmodified),
// and a list of other possible alternatives, in order.
-func (ic *imageCopier) determineManifestConversion(destSupportedManifestMIMETypes []string, forceManifestMIMEType string) (string, []string, error) {
- _, srcType, err := ic.src.Manifest()
+func (ic *imageCopier) determineManifestConversion(ctx context.Context, destSupportedManifestMIMETypes []string, forceManifestMIMEType string) (string, []string, error) {
+ _, srcType, err := ic.src.Manifest(ctx)
if err != nil { // This should have been cached?!
return "", nil, errors.Wrap(err, "Error reading manifest")
}
@@ -111,8 +112,8 @@ func (ic *imageCopier) determineManifestConversion(destSupportedManifestMIMEType
}
// isMultiImage returns true if img is a list of images
-func isMultiImage(img types.UnparsedImage) (bool, error) {
- _, mt, err := img.Manifest()
+func isMultiImage(ctx context.Context, img types.UnparsedImage) (bool, error) {
+ _, mt, err := img.Manifest(ctx)
if err != nil {
return false, err
}
diff --git a/vendor/github.com/containers/image/directory/directory_dest.go b/vendor/github.com/containers/image/directory/directory_dest.go
index c448692ed..a38d7d5cf 100644
--- a/vendor/github.com/containers/image/directory/directory_dest.go
+++ b/vendor/github.com/containers/image/directory/directory_dest.go
@@ -1,6 +1,7 @@
package directory
import (
+ "context"
"io"
"io/ioutil"
"os"
@@ -94,7 +95,7 @@ func (d *dirImageDestination) SupportedManifestMIMETypes() []string {
// SupportsSignatures returns an error (to be displayed to the user) if the destination certainly can't store signatures.
// Note: It is still possible for PutSignatures to fail if SupportsSignatures returns nil.
-func (d *dirImageDestination) SupportsSignatures() error {
+func (d *dirImageDestination) SupportsSignatures(ctx context.Context) error {
return nil
}
@@ -122,7 +123,7 @@ func (d *dirImageDestination) MustMatchRuntimeOS() bool {
// WARNING: The contents of stream are being verified on the fly. Until stream.Read() returns io.EOF, the contents of the data SHOULD NOT be available
// to any other readers for download using the supplied digest.
// If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far.
-func (d *dirImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
+func (d *dirImageDestination) PutBlob(ctx context.Context, stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
blobFile, err := ioutil.TempFile(d.ref.path, "dir-put-blob")
if err != nil {
return types.BlobInfo{}, err
@@ -138,6 +139,7 @@ func (d *dirImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobInfo
digester := digest.Canonical.Digester()
tee := io.TeeReader(stream, digester.Hash())
+ // TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().
size, err := io.Copy(blobFile, tee)
if err != nil {
return types.BlobInfo{}, err
@@ -164,7 +166,7 @@ func (d *dirImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobInfo
// Unlike PutBlob, the digest can not be empty. If HasBlob returns true, the size of the blob must also be returned.
// If the destination does not contain the blob, or it is unknown, HasBlob ordinarily returns (false, -1, nil);
// it returns a non-nil error only on an unexpected failure.
-func (d *dirImageDestination) HasBlob(info types.BlobInfo) (bool, int64, error) {
+func (d *dirImageDestination) HasBlob(ctx context.Context, info types.BlobInfo) (bool, int64, error) {
if info.Digest == "" {
return false, -1, errors.Errorf(`"Can not check for a blob with unknown digest`)
}
@@ -179,7 +181,7 @@ func (d *dirImageDestination) HasBlob(info types.BlobInfo) (bool, int64, error)
return true, finfo.Size(), nil
}
-func (d *dirImageDestination) ReapplyBlob(info types.BlobInfo) (types.BlobInfo, error) {
+func (d *dirImageDestination) ReapplyBlob(ctx context.Context, info types.BlobInfo) (types.BlobInfo, error) {
return info, nil
}
@@ -187,11 +189,11 @@ func (d *dirImageDestination) ReapplyBlob(info types.BlobInfo) (types.BlobInfo,
// FIXME? This should also receive a MIME type if known, to differentiate between schema versions.
// If the destination is in principle available, refuses this manifest type (e.g. it does not recognize the schema),
// but may accept a different manifest type, the returned error must be an ManifestTypeRejectedError.
-func (d *dirImageDestination) PutManifest(manifest []byte) error {
+func (d *dirImageDestination) PutManifest(ctx context.Context, manifest []byte) error {
return ioutil.WriteFile(d.ref.manifestPath(), manifest, 0644)
}
-func (d *dirImageDestination) PutSignatures(signatures [][]byte) error {
+func (d *dirImageDestination) PutSignatures(ctx context.Context, signatures [][]byte) error {
for i, sig := range signatures {
if err := ioutil.WriteFile(d.ref.signaturePath(i), sig, 0644); err != nil {
return err
@@ -204,7 +206,7 @@ func (d *dirImageDestination) PutSignatures(signatures [][]byte) error {
// WARNING: This does not have any transactional semantics:
// - Uploaded data MAY be visible to others before Commit() is called
// - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed)
-func (d *dirImageDestination) Commit() error {
+func (d *dirImageDestination) Commit(ctx context.Context) error {
return nil
}
diff --git a/vendor/github.com/containers/image/directory/directory_src.go b/vendor/github.com/containers/image/directory/directory_src.go
index f07089512..5e17c37c0 100644
--- a/vendor/github.com/containers/image/directory/directory_src.go
+++ b/vendor/github.com/containers/image/directory/directory_src.go
@@ -37,7 +37,7 @@ func (s *dirImageSource) Close() error {
// It may use a remote (= slow) service.
// If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve (when the primary manifest is a manifest list);
// this never happens if the primary manifest is not a manifest list (e.g. if the source never returns manifest lists).
-func (s *dirImageSource) GetManifest(instanceDigest *digest.Digest) ([]byte, string, error) {
+func (s *dirImageSource) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error) {
if instanceDigest != nil {
return nil, "", errors.Errorf(`Getting target manifest not supported by "dir:"`)
}
@@ -49,7 +49,7 @@ func (s *dirImageSource) GetManifest(instanceDigest *digest.Digest) ([]byte, str
}
// GetBlob returns a stream for the specified blob, and the blob’s size (or -1 if unknown).
-func (s *dirImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
+func (s *dirImageSource) GetBlob(ctx context.Context, info types.BlobInfo) (io.ReadCloser, int64, error) {
r, err := os.Open(s.ref.layerPath(info.Digest))
if err != nil {
return nil, -1, err
@@ -84,6 +84,6 @@ func (s *dirImageSource) GetSignatures(ctx context.Context, instanceDigest *dige
}
// LayerInfosForCopy() returns updated layer info that should be used when copying, in preference to values in the manifest, if specified.
-func (s *dirImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (s *dirImageSource) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
return nil, nil
}
diff --git a/vendor/github.com/containers/image/directory/directory_transport.go b/vendor/github.com/containers/image/directory/directory_transport.go
index 37174841c..66b9e7258 100644
--- a/vendor/github.com/containers/image/directory/directory_transport.go
+++ b/vendor/github.com/containers/image/directory/directory_transport.go
@@ -1,6 +1,7 @@
package directory
import (
+ "context"
"fmt"
"path/filepath"
"strings"
@@ -138,29 +139,29 @@ func (ref dirReference) PolicyConfigurationNamespaces() []string {
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
-func (ref dirReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
+func (ref dirReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
src := newImageSource(ref)
- return image.FromSource(ctx, src)
+ return image.FromSource(ctx, sys, src)
}
// NewImageSource returns a types.ImageSource for this reference.
// The caller must call .Close() on the returned ImageSource.
-func (ref dirReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
+func (ref dirReference) NewImageSource(ctx context.Context, sys *types.SystemContext) (types.ImageSource, error) {
return newImageSource(ref), nil
}
// NewImageDestination returns a types.ImageDestination for this reference.
// The caller must call .Close() on the returned ImageDestination.
-func (ref dirReference) NewImageDestination(ctx *types.SystemContext) (types.ImageDestination, error) {
+func (ref dirReference) NewImageDestination(ctx context.Context, sys *types.SystemContext) (types.ImageDestination, error) {
compress := false
- if ctx != nil {
- compress = ctx.DirForceCompress
+ if sys != nil {
+ compress = sys.DirForceCompress
}
return newImageDestination(ref, compress)
}
// DeleteImage deletes the named image from the registry, if supported.
-func (ref dirReference) DeleteImage(ctx *types.SystemContext) error {
+func (ref dirReference) DeleteImage(ctx context.Context, sys *types.SystemContext) error {
return errors.Errorf("Deleting images not implemented for dir: images")
}
diff --git a/vendor/github.com/containers/image/docker/archive/dest.go b/vendor/github.com/containers/image/docker/archive/dest.go
index 22152dfaa..12bbfa747 100644
--- a/vendor/github.com/containers/image/docker/archive/dest.go
+++ b/vendor/github.com/containers/image/docker/archive/dest.go
@@ -1,6 +1,7 @@
package archive
import (
+ "context"
"io"
"os"
@@ -15,7 +16,7 @@ type archiveImageDestination struct {
writer io.Closer
}
-func newImageDestination(ctx *types.SystemContext, ref archiveReference) (types.ImageDestination, error) {
+func newImageDestination(ref archiveReference) (types.ImageDestination, error) {
if ref.destinationRef == nil {
return nil, errors.Errorf("docker-archive: destination reference not supplied (must be of form <path>:<reference:tag>)")
}
@@ -66,6 +67,6 @@ func (d *archiveImageDestination) Close() error {
// WARNING: This does not have any transactional semantics:
// - Uploaded data MAY be visible to others before Commit() is called
// - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed)
-func (d *archiveImageDestination) Commit() error {
- return d.Destination.Commit()
+func (d *archiveImageDestination) Commit(ctx context.Context) error {
+ return d.Destination.Commit(ctx)
}
diff --git a/vendor/github.com/containers/image/docker/archive/src.go b/vendor/github.com/containers/image/docker/archive/src.go
index bd5a5e296..e46c9db4a 100644
--- a/vendor/github.com/containers/image/docker/archive/src.go
+++ b/vendor/github.com/containers/image/docker/archive/src.go
@@ -1,6 +1,7 @@
package archive
import (
+ "context"
"github.com/containers/image/docker/tarfile"
"github.com/containers/image/types"
"github.com/sirupsen/logrus"
@@ -13,7 +14,7 @@ type archiveImageSource struct {
// newImageSource returns a types.ImageSource for the specified image reference.
// The caller must call .Close() on the returned ImageSource.
-func newImageSource(ctx *types.SystemContext, ref archiveReference) (types.ImageSource, error) {
+func newImageSource(ctx context.Context, ref archiveReference) (types.ImageSource, error) {
if ref.destinationRef != nil {
logrus.Warnf("docker-archive: references are not supported for sources (ignoring)")
}
@@ -34,6 +35,6 @@ func (s *archiveImageSource) Reference() types.ImageReference {
}
// LayerInfosForCopy() returns updated layer info that should be used when reading, in preference to values in the manifest, if specified.
-func (s *archiveImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (s *archiveImageSource) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
return nil, nil
}
diff --git a/vendor/github.com/containers/image/docker/archive/transport.go b/vendor/github.com/containers/image/docker/archive/transport.go
index ad6a68837..169a2b2e2 100644
--- a/vendor/github.com/containers/image/docker/archive/transport.go
+++ b/vendor/github.com/containers/image/docker/archive/transport.go
@@ -1,6 +1,7 @@
package archive
import (
+ "context"
"fmt"
"strings"
@@ -130,28 +131,28 @@ func (ref archiveReference) PolicyConfigurationNamespaces() []string {
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
-func (ref archiveReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
+func (ref archiveReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
src, err := newImageSource(ctx, ref)
if err != nil {
return nil, err
}
- return ctrImage.FromSource(ctx, src)
+ return ctrImage.FromSource(ctx, sys, src)
}
// NewImageSource returns a types.ImageSource for this reference.
// The caller must call .Close() on the returned ImageSource.
-func (ref archiveReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
+func (ref archiveReference) NewImageSource(ctx context.Context, sys *types.SystemContext) (types.ImageSource, error) {
return newImageSource(ctx, ref)
}
// NewImageDestination returns a types.ImageDestination for this reference.
// The caller must call .Close() on the returned ImageDestination.
-func (ref archiveReference) NewImageDestination(ctx *types.SystemContext) (types.ImageDestination, error) {
- return newImageDestination(ctx, ref)
+func (ref archiveReference) NewImageDestination(ctx context.Context, sys *types.SystemContext) (types.ImageDestination, error) {
+ return newImageDestination(ref)
}
// DeleteImage deletes the named image from the registry, if supported.
-func (ref archiveReference) DeleteImage(ctx *types.SystemContext) error {
+func (ref archiveReference) DeleteImage(ctx context.Context, sys *types.SystemContext) error {
// Not really supported, for safety reasons.
return errors.New("Deleting images not implemented for docker-archive: images")
}
diff --git a/vendor/github.com/containers/image/docker/daemon/client.go b/vendor/github.com/containers/image/docker/daemon/client.go
index 11f8f6420..3d5317a45 100644
--- a/vendor/github.com/containers/image/docker/daemon/client.go
+++ b/vendor/github.com/containers/image/docker/daemon/client.go
@@ -15,10 +15,10 @@ const (
)
// NewDockerClient initializes a new API client based on the passed SystemContext.
-func newDockerClient(ctx *types.SystemContext) (*dockerclient.Client, error) {
+func newDockerClient(sys *types.SystemContext) (*dockerclient.Client, error) {
host := dockerclient.DefaultDockerHost
- if ctx != nil && ctx.DockerDaemonHost != "" {
- host = ctx.DockerDaemonHost
+ if sys != nil && sys.DockerDaemonHost != "" {
+ host = sys.DockerDaemonHost
}
// Sadly, unix:// sockets don't work transparently with dockerclient.NewClient.
@@ -39,7 +39,7 @@ func newDockerClient(ctx *types.SystemContext) (*dockerclient.Client, error) {
if proto == "http" {
httpClient = httpConfig()
} else {
- hc, err := tlsConfig(ctx)
+ hc, err := tlsConfig(sys)
if err != nil {
return nil, err
}
@@ -50,16 +50,16 @@ func newDockerClient(ctx *types.SystemContext) (*dockerclient.Client, error) {
return dockerclient.NewClient(host, defaultAPIVersion, httpClient, nil)
}
-func tlsConfig(ctx *types.SystemContext) (*http.Client, error) {
+func tlsConfig(sys *types.SystemContext) (*http.Client, error) {
options := tlsconfig.Options{}
- if ctx != nil && ctx.DockerDaemonInsecureSkipTLSVerify {
+ if sys != nil && sys.DockerDaemonInsecureSkipTLSVerify {
options.InsecureSkipVerify = true
}
- if ctx != nil && ctx.DockerDaemonCertPath != "" {
- options.CAFile = filepath.Join(ctx.DockerDaemonCertPath, "ca.pem")
- options.CertFile = filepath.Join(ctx.DockerDaemonCertPath, "cert.pem")
- options.KeyFile = filepath.Join(ctx.DockerDaemonCertPath, "key.pem")
+ if sys != nil && sys.DockerDaemonCertPath != "" {
+ options.CAFile = filepath.Join(sys.DockerDaemonCertPath, "ca.pem")
+ options.CertFile = filepath.Join(sys.DockerDaemonCertPath, "cert.pem")
+ options.KeyFile = filepath.Join(sys.DockerDaemonCertPath, "key.pem")
}
tlsc, err := tlsconfig.Client(options)
diff --git a/vendor/github.com/containers/image/docker/daemon/daemon_dest.go b/vendor/github.com/containers/image/docker/daemon/daemon_dest.go
index bfd8ddc7c..663086ff6 100644
--- a/vendor/github.com/containers/image/docker/daemon/daemon_dest.go
+++ b/vendor/github.com/containers/image/docker/daemon/daemon_dest.go
@@ -1,6 +1,7 @@
package daemon
import (
+ "context"
"io"
"github.com/containers/image/docker/reference"
@@ -9,7 +10,6 @@ import (
"github.com/docker/docker/client"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
- "golang.org/x/net/context"
)
type daemonImageDestination struct {
@@ -25,7 +25,7 @@ type daemonImageDestination struct {
}
// newImageDestination returns a types.ImageDestination for the specified image reference.
-func newImageDestination(ctx *types.SystemContext, ref daemonReference) (types.ImageDestination, error) {
+func newImageDestination(ctx context.Context, sys *types.SystemContext, ref daemonReference) (types.ImageDestination, error) {
if ref.ref == nil {
return nil, errors.Errorf("Invalid destination docker-daemon:%s: a destination must be a name:tag", ref.StringWithinTransport())
}
@@ -35,11 +35,11 @@ func newImageDestination(ctx *types.SystemContext, ref daemonReference) (types.I
}
var mustMatchRuntimeOS = true
- if ctx != nil && ctx.DockerDaemonHost != client.DefaultDockerHost {
+ if sys != nil && sys.DockerDaemonHost != client.DefaultDockerHost {
mustMatchRuntimeOS = false
}
- c, err := newDockerClient(ctx)
+ c, err := newDockerClient(sys)
if err != nil {
return nil, errors.Wrap(err, "Error initializing docker engine client")
}
@@ -48,7 +48,7 @@ func newImageDestination(ctx *types.SystemContext, ref daemonReference) (types.I
// Commit() may never be called, so we may never read from this channel; so, make this buffered to allow imageLoadGoroutine to write status and terminate even if we never read it.
statusChannel := make(chan error, 1)
- goroutineContext, goroutineCancel := context.WithCancel(context.Background())
+ goroutineContext, goroutineCancel := context.WithCancel(ctx)
go imageLoadGoroutine(goroutineContext, c, reader, statusChannel)
return &daemonImageDestination{
@@ -124,9 +124,9 @@ func (d *daemonImageDestination) Reference() types.ImageReference {
// WARNING: This does not have any transactional semantics:
// - Uploaded data MAY be visible to others before Commit() is called
// - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed)
-func (d *daemonImageDestination) Commit() error {
+func (d *daemonImageDestination) Commit(ctx context.Context) error {
logrus.Debugf("docker-daemon: Closing tar stream")
- if err := d.Destination.Commit(); err != nil {
+ if err := d.Destination.Commit(ctx); err != nil {
return err
}
if err := d.writer.Close(); err != nil {
@@ -135,6 +135,10 @@ func (d *daemonImageDestination) Commit() error {
d.committed = true // We may still fail, but we are done sending to imageLoadGoroutine.
logrus.Debugf("docker-daemon: Waiting for status")
- err := <-d.statusChannel
- return err
+ select {
+ case <-ctx.Done():
+ return ctx.Err()
+ case err := <-d.statusChannel:
+ return err
+ }
}
diff --git a/vendor/github.com/containers/image/docker/daemon/daemon_src.go b/vendor/github.com/containers/image/docker/daemon/daemon_src.go
index 638962c50..89e66eff8 100644
--- a/vendor/github.com/containers/image/docker/daemon/daemon_src.go
+++ b/vendor/github.com/containers/image/docker/daemon/daemon_src.go
@@ -1,10 +1,11 @@
package daemon
import (
+ "context"
+
"github.com/containers/image/docker/tarfile"
"github.com/containers/image/types"
"github.com/pkg/errors"
- "golang.org/x/net/context"
)
type daemonImageSource struct {
@@ -26,14 +27,14 @@ type layerInfo struct {
// (We could, perhaps, expect an exact sequence, assume that the first plaintext file
// is the config, and that the following len(RootFS) files are the layers, but that feels
// way too brittle.)
-func newImageSource(ctx *types.SystemContext, ref daemonReference) (types.ImageSource, error) {
- c, err := newDockerClient(ctx)
+func newImageSource(ctx context.Context, sys *types.SystemContext, ref daemonReference) (types.ImageSource, error) {
+ c, err := newDockerClient(sys)
if err != nil {
return nil, errors.Wrap(err, "Error initializing docker engine client")
}
// Per NewReference(), ref.StringWithinTransport() is either an image ID (config digest), or a !reference.NameOnly() reference.
// Either way ImageSave should create a tarball with exactly one image.
- inputStream, err := c.ImageSave(context.TODO(), []string{ref.StringWithinTransport()})
+ inputStream, err := c.ImageSave(ctx, []string{ref.StringWithinTransport()})
if err != nil {
return nil, errors.Wrap(err, "Error loading image from docker engine")
}
@@ -56,6 +57,6 @@ func (s *daemonImageSource) Reference() types.ImageReference {
}
// LayerInfosForCopy() returns updated layer info that should be used when reading, in preference to values in the manifest, if specified.
-func (s *daemonImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (s *daemonImageSource) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
return nil, nil
}
diff --git a/vendor/github.com/containers/image/docker/daemon/daemon_transport.go b/vendor/github.com/containers/image/docker/daemon/daemon_transport.go
index 8ad6b521f..b083628ae 100644
--- a/vendor/github.com/containers/image/docker/daemon/daemon_transport.go
+++ b/vendor/github.com/containers/image/docker/daemon/daemon_transport.go
@@ -1,6 +1,7 @@
package daemon
import (
+ "context"
"github.com/pkg/errors"
"github.com/containers/image/docker/reference"
@@ -156,28 +157,28 @@ func (ref daemonReference) PolicyConfigurationNamespaces() []string {
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
-func (ref daemonReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
- src, err := newImageSource(ctx, ref)
+func (ref daemonReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
+ src, err := newImageSource(ctx, sys, ref)
if err != nil {
return nil, err
}
- return image.FromSource(ctx, src)
+ return image.FromSource(ctx, sys, src)
}
// NewImageSource returns a types.ImageSource for this reference.
// The caller must call .Close() on the returned ImageSource.
-func (ref daemonReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
- return newImageSource(ctx, ref)
+func (ref daemonReference) NewImageSource(ctx context.Context, sys *types.SystemContext) (types.ImageSource, error) {
+ return newImageSource(ctx, sys, ref)
}
// NewImageDestination returns a types.ImageDestination for this reference.
// The caller must call .Close() on the returned ImageDestination.
-func (ref daemonReference) NewImageDestination(ctx *types.SystemContext) (types.ImageDestination, error) {
- return newImageDestination(ctx, ref)
+func (ref daemonReference) NewImageDestination(ctx context.Context, sys *types.SystemContext) (types.ImageDestination, error) {
+ return newImageDestination(ctx, sys, ref)
}
// DeleteImage deletes the named image from the registry, if supported.
-func (ref daemonReference) DeleteImage(ctx *types.SystemContext) error {
+func (ref daemonReference) DeleteImage(ctx context.Context, sys *types.SystemContext) error {
// Should this just untag the image? Should this stop running containers?
// The semantics is not quite as clear as for remote repositories.
// The user can run (docker rmi) directly anyway, so, for now(?), punt instead of trying to guess what the user meant.
diff --git a/vendor/github.com/containers/image/docker/docker_client.go b/vendor/github.com/containers/image/docker/docker_client.go
index 47b3e4690..4a1d42149 100644
--- a/vendor/github.com/containers/image/docker/docker_client.go
+++ b/vendor/github.com/containers/image/docker/docker_client.go
@@ -78,7 +78,7 @@ type bearerToken struct {
// dockerClient is configuration for dealing with a single Docker registry.
type dockerClient struct {
// The following members are set by newDockerClient and do not change afterwards.
- ctx *types.SystemContext
+ sys *types.SystemContext
registry string
username string
password string
@@ -131,12 +131,12 @@ func serverDefault() *tls.Config {
}
// dockerCertDir returns a path to a directory to be consumed by tlsclientconfig.SetupCertificates() depending on ctx and hostPort.
-func dockerCertDir(ctx *types.SystemContext, hostPort string) (string, error) {
- if ctx != nil && ctx.DockerCertPath != "" {
- return ctx.DockerCertPath, nil
+func dockerCertDir(sys *types.SystemContext, hostPort string) (string, error) {
+ if sys != nil && sys.DockerCertPath != "" {
+ return sys.DockerCertPath, nil
}
- if ctx != nil && ctx.DockerPerHostCertDirPath != "" {
- return filepath.Join(ctx.DockerPerHostCertDirPath, hostPort), nil
+ if sys != nil && sys.DockerPerHostCertDirPath != "" {
+ return filepath.Join(sys.DockerPerHostCertDirPath, hostPort), nil
}
var (
@@ -144,8 +144,8 @@ func dockerCertDir(ctx *types.SystemContext, hostPort string) (string, error) {
fullCertDirPath string
)
for _, systemPerHostCertDirPath := range systemPerHostCertDirPaths {
- if ctx != nil && ctx.RootForImplicitAbsolutePaths != "" {
- hostCertDir = filepath.Join(ctx.RootForImplicitAbsolutePaths, systemPerHostCertDirPath)
+ if sys != nil && sys.RootForImplicitAbsolutePaths != "" {
+ hostCertDir = filepath.Join(sys.RootForImplicitAbsolutePaths, systemPerHostCertDirPath)
} else {
hostCertDir = systemPerHostCertDirPath
}
@@ -171,23 +171,23 @@ func dockerCertDir(ctx *types.SystemContext, hostPort string) (string, error) {
// newDockerClientFromRef returns a new dockerClient instance for refHostname (a host a specified in the Docker image reference, not canonicalized to dockerRegistry)
// “write” specifies whether the client will be used for "write" access (in particular passed to lookaside.go:toplevelFromSection)
-func newDockerClientFromRef(ctx *types.SystemContext, ref dockerReference, write bool, actions string) (*dockerClient, error) {
+func newDockerClientFromRef(sys *types.SystemContext, ref dockerReference, write bool, actions string) (*dockerClient, error) {
registry := reference.Domain(ref.ref)
- username, password, err := config.GetAuthentication(ctx, reference.Domain(ref.ref))
+ username, password, err := config.GetAuthentication(sys, reference.Domain(ref.ref))
if err != nil {
return nil, errors.Wrapf(err, "error getting username and password")
}
- sigBase, err := configuredSignatureStorageBase(ctx, ref, write)
+ sigBase, err := configuredSignatureStorageBase(sys, ref, write)
if err != nil {
return nil, err
}
remoteName := reference.Path(ref.ref)
- return newDockerClientWithDetails(ctx, registry, username, password, actions, sigBase, remoteName)
+ return newDockerClientWithDetails(sys, registry, username, password, actions, sigBase, remoteName)
}
// newDockerClientWithDetails returns a new dockerClient instance for the given parameters
-func newDockerClientWithDetails(ctx *types.SystemContext, registry, username, password, actions string, sigBase signatureStorageBase, remoteName string) (*dockerClient, error) {
+func newDockerClientWithDetails(sys *types.SystemContext, registry, username, password, actions string, sigBase signatureStorageBase, remoteName string) (*dockerClient, error) {
hostName := registry
if registry == dockerHostname {
registry = dockerRegistry
@@ -200,7 +200,7 @@ func newDockerClientWithDetails(ctx *types.SystemContext, registry, username, pa
// dockerHostname here, because it is more symmetrical to read the configuration in that case as well, and because
// generally the UI hides the existence of the different dockerRegistry. But note that this behavior is
// undocumented and may change if docker/docker changes.
- certDir, err := dockerCertDir(ctx, hostName)
+ certDir, err := dockerCertDir(sys, hostName)
if err != nil {
return nil, err
}
@@ -208,12 +208,12 @@ func newDockerClientWithDetails(ctx *types.SystemContext, registry, username, pa
return nil, err
}
- if ctx != nil && ctx.DockerInsecureSkipTLSVerify {
+ if sys != nil && sys.DockerInsecureSkipTLSVerify {
tr.TLSClientConfig.InsecureSkipVerify = true
}
return &dockerClient{
- ctx: ctx,
+ sys: sys,
registry: registry,
username: username,
password: password,
@@ -228,8 +228,8 @@ func newDockerClientWithDetails(ctx *types.SystemContext, registry, username, pa
// CheckAuth validates the credentials by attempting to log into the registry
// returns an error if an error occcured while making the http request or the status code received was 401
-func CheckAuth(ctx context.Context, sCtx *types.SystemContext, username, password, registry string) error {
- newLoginClient, err := newDockerClientWithDetails(sCtx, registry, username, password, "", nil, "")
+func CheckAuth(ctx context.Context, sys *types.SystemContext, username, password, registry string) error {
+ newLoginClient, err := newDockerClientWithDetails(sys, registry, username, password, "", nil, "")
if err != nil {
return errors.Wrapf(err, "error creating new docker client")
}
@@ -268,7 +268,7 @@ type SearchResult struct {
// The limit is the max number of results desired
// Note: The limit value doesn't work with all registries
// for example registry.access.redhat.com returns all the results without limiting it to the limit value
-func SearchRegistry(ctx context.Context, sCtx *types.SystemContext, registry, image string, limit int) ([]SearchResult, error) {
+func SearchRegistry(ctx context.Context, sys *types.SystemContext, registry, image string, limit int) ([]SearchResult, error) {
type V2Results struct {
// Repositories holds the results returned by the /v2/_catalog endpoint
Repositories []string `json:"repositories"`
@@ -286,7 +286,7 @@ func SearchRegistry(ctx context.Context, sCtx *types.SystemContext, registry, im
registry = dockerV1Hostname
}
- client, err := newDockerClientWithDetails(sCtx, registry, "", "", "", nil, "")
+ client, err := newDockerClientWithDetails(sys, registry, "", "", "", nil, "")
if err != nil {
return nil, errors.Wrapf(err, "error creating new docker client")
}
@@ -374,8 +374,8 @@ func (c *dockerClient) makeRequestToResolvedURL(ctx context.Context, method, url
req.Header.Add(n, hh)
}
}
- if c.ctx != nil && c.ctx.DockerRegistryUserAgent != "" {
- req.Header.Add("User-Agent", c.ctx.DockerRegistryUserAgent)
+ if c.sys != nil && c.sys.DockerRegistryUserAgent != "" {
+ req.Header.Add("User-Agent", c.sys.DockerRegistryUserAgent)
}
if sendAuth {
if err := c.setupRequestAuth(req); err != nil {
@@ -503,12 +503,12 @@ func (c *dockerClient) detectProperties(ctx context.Context) error {
return nil
}
err := ping("https")
- if err != nil && c.ctx != nil && c.ctx.DockerInsecureSkipTLSVerify {
+ if err != nil && c.sys != nil && c.sys.DockerInsecureSkipTLSVerify {
err = ping("http")
}
if err != nil {
err = errors.Wrap(err, "pinging docker registry returned")
- if c.ctx != nil && c.ctx.DockerDisableV1Ping {
+ if c.sys != nil && c.sys.DockerDisableV1Ping {
return err
}
// best effort to understand if we're talking to a V1 registry
@@ -527,7 +527,7 @@ func (c *dockerClient) detectProperties(ctx context.Context) error {
return true
}
isV1 := pingV1("https")
- if !isV1 && c.ctx != nil && c.ctx.DockerInsecureSkipTLSVerify {
+ if !isV1 && c.sys != nil && c.sys.DockerInsecureSkipTLSVerify {
isV1 = pingV1("http")
}
if isV1 {
diff --git a/vendor/github.com/containers/image/docker/docker_image.go b/vendor/github.com/containers/image/docker/docker_image.go
index 2148ed8ba..7f8ad858e 100644
--- a/vendor/github.com/containers/image/docker/docker_image.go
+++ b/vendor/github.com/containers/image/docker/docker_image.go
@@ -22,12 +22,12 @@ type Image struct {
// newImage returns a new Image interface type after setting up
// a client to the registry hosting the given image.
// The caller must call .Close() on the returned Image.
-func newImage(ctx *types.SystemContext, ref dockerReference) (types.ImageCloser, error) {
- s, err := newImageSource(ctx, ref)
+func newImage(ctx context.Context, sys *types.SystemContext, ref dockerReference) (types.ImageCloser, error) {
+ s, err := newImageSource(sys, ref)
if err != nil {
return nil, err
}
- img, err := image.FromSource(ctx, s)
+ img, err := image.FromSource(ctx, sys, s)
if err != nil {
return nil, err
}
@@ -40,10 +40,10 @@ func (i *Image) SourceRefFullName() string {
}
// GetRepositoryTags list all tags available in the repository. Note that this has no connection with the tag(s) used for this specific image, if any.
-func (i *Image) GetRepositoryTags() ([]string, error) {
+func (i *Image) GetRepositoryTags(ctx context.Context) ([]string, error) {
path := fmt.Sprintf(tagsPath, reference.Path(i.src.ref.ref))
// FIXME: Pass the context.Context
- res, err := i.src.c.makeRequest(context.TODO(), "GET", path, nil, nil)
+ res, err := i.src.c.makeRequest(ctx, "GET", path, nil, nil)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/containers/image/docker/docker_image_dest.go b/vendor/github.com/containers/image/docker/docker_image_dest.go
index 17f31dee4..782a048ce 100644
--- a/vendor/github.com/containers/image/docker/docker_image_dest.go
+++ b/vendor/github.com/containers/image/docker/docker_image_dest.go
@@ -33,8 +33,8 @@ type dockerImageDestination struct {
}
// newImageDestination creates a new ImageDestination for the specified image reference.
-func newImageDestination(ctx *types.SystemContext, ref dockerReference) (types.ImageDestination, error) {
- c, err := newDockerClientFromRef(ctx, ref, true, "pull,push")
+func newImageDestination(sys *types.SystemContext, ref dockerReference) (types.ImageDestination, error) {
+ c, err := newDockerClientFromRef(sys, ref, true, "pull,push")
if err != nil {
return nil, err
}
@@ -66,8 +66,8 @@ func (d *dockerImageDestination) SupportedManifestMIMETypes() []string {
// SupportsSignatures returns an error (to be displayed to the user) if the destination certainly can't store signatures.
// Note: It is still possible for PutSignatures to fail if SupportsSignatures returns nil.
-func (d *dockerImageDestination) SupportsSignatures() error {
- if err := d.c.detectProperties(context.TODO()); err != nil {
+func (d *dockerImageDestination) SupportsSignatures(ctx context.Context) error {
+ if err := d.c.detectProperties(ctx); err != nil {
return err
}
switch {
@@ -109,9 +109,9 @@ func (c *sizeCounter) Write(p []byte) (n int, err error) {
// WARNING: The contents of stream are being verified on the fly. Until stream.Read() returns io.EOF, the contents of the data SHOULD NOT be available
// to any other readers for download using the supplied digest.
// If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far.
-func (d *dockerImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
+func (d *dockerImageDestination) PutBlob(ctx context.Context, stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
if inputInfo.Digest.String() != "" {
- haveBlob, size, err := d.HasBlob(inputInfo)
+ haveBlob, size, err := d.HasBlob(ctx, inputInfo)
if err != nil {
return types.BlobInfo{}, err
}
@@ -123,7 +123,7 @@ func (d *dockerImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobI
// FIXME? Chunked upload, progress reporting, etc.
uploadPath := fmt.Sprintf(blobUploadPath, reference.Path(d.ref.ref))
logrus.Debugf("Uploading %s", uploadPath)
- res, err := d.c.makeRequest(context.TODO(), "POST", uploadPath, nil, nil)
+ res, err := d.c.makeRequest(ctx, "POST", uploadPath, nil, nil)
if err != nil {
return types.BlobInfo{}, err
}
@@ -140,7 +140,7 @@ func (d *dockerImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobI
digester := digest.Canonical.Digester()
sizeCounter := &sizeCounter{}
tee := io.TeeReader(stream, io.MultiWriter(digester.Hash(), sizeCounter))
- res, err = d.c.makeRequestToResolvedURL(context.TODO(), "PATCH", uploadLocation.String(), map[string][]string{"Content-Type": {"application/octet-stream"}}, tee, inputInfo.Size, true)
+ res, err = d.c.makeRequestToResolvedURL(ctx, "PATCH", uploadLocation.String(), map[string][]string{"Content-Type": {"application/octet-stream"}}, tee, inputInfo.Size, true)
if err != nil {
logrus.Debugf("Error uploading layer chunked, response %#v", res)
return types.BlobInfo{}, err
@@ -159,7 +159,7 @@ func (d *dockerImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobI
// TODO: check inputInfo.Digest == computedDigest https://github.com/containers/image/pull/70#discussion_r77646717
locationQuery.Set("digest", computedDigest.String())
uploadLocation.RawQuery = locationQuery.Encode()
- res, err = d.c.makeRequestToResolvedURL(context.TODO(), "PUT", uploadLocation.String(), map[string][]string{"Content-Type": {"application/octet-stream"}}, nil, -1, true)
+ res, err = d.c.makeRequestToResolvedURL(ctx, "PUT", uploadLocation.String(), map[string][]string{"Content-Type": {"application/octet-stream"}}, nil, -1, true)
if err != nil {
return types.BlobInfo{}, err
}
@@ -177,14 +177,14 @@ func (d *dockerImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobI
// Unlike PutBlob, the digest can not be empty. If HasBlob returns true, the size of the blob must also be returned.
// If the destination does not contain the blob, or it is unknown, HasBlob ordinarily returns (false, -1, nil);
// it returns a non-nil error only on an unexpected failure.
-func (d *dockerImageDestination) HasBlob(info types.BlobInfo) (bool, int64, error) {
+func (d *dockerImageDestination) HasBlob(ctx context.Context, info types.BlobInfo) (bool, int64, error) {
if info.Digest == "" {
return false, -1, errors.Errorf(`"Can not check for a blob with unknown digest`)
}
checkPath := fmt.Sprintf(blobsPath, reference.Path(d.ref.ref), info.Digest.String())
logrus.Debugf("Checking %s", checkPath)
- res, err := d.c.makeRequest(context.TODO(), "HEAD", checkPath, nil, nil)
+ res, err := d.c.makeRequest(ctx, "HEAD", checkPath, nil, nil)
if err != nil {
return false, -1, err
}
@@ -204,7 +204,7 @@ func (d *dockerImageDestination) HasBlob(info types.BlobInfo) (bool, int64, erro
}
}
-func (d *dockerImageDestination) ReapplyBlob(info types.BlobInfo) (types.BlobInfo, error) {
+func (d *dockerImageDestination) ReapplyBlob(ctx context.Context, info types.BlobInfo) (types.BlobInfo, error) {
return info, nil
}
@@ -212,7 +212,7 @@ func (d *dockerImageDestination) ReapplyBlob(info types.BlobInfo) (types.BlobInf
// FIXME? This should also receive a MIME type if known, to differentiate between schema versions.
// If the destination is in principle available, refuses this manifest type (e.g. it does not recognize the schema),
// but may accept a different manifest type, the returned error must be an ManifestTypeRejectedError.
-func (d *dockerImageDestination) PutManifest(m []byte) error {
+func (d *dockerImageDestination) PutManifest(ctx context.Context, m []byte) error {
digest, err := manifest.Digest(m)
if err != nil {
return err
@@ -230,7 +230,7 @@ func (d *dockerImageDestination) PutManifest(m []byte) error {
if mimeType != "" {
headers["Content-Type"] = []string{mimeType}
}
- res, err := d.c.makeRequest(context.TODO(), "PUT", path, headers, bytes.NewReader(m))
+ res, err := d.c.makeRequest(ctx, "PUT", path, headers, bytes.NewReader(m))
if err != nil {
return err
}
@@ -267,19 +267,19 @@ func isManifestInvalidError(err error) bool {
return ec.ErrorCode() == v2.ErrorCodeManifestInvalid || ec.ErrorCode() == v2.ErrorCodeTagInvalid
}
-func (d *dockerImageDestination) PutSignatures(signatures [][]byte) error {
+func (d *dockerImageDestination) PutSignatures(ctx context.Context, signatures [][]byte) error {
// Do not fail if we don’t really need to support signatures.
if len(signatures) == 0 {
return nil
}
- if err := d.c.detectProperties(context.TODO()); err != nil {
+ if err := d.c.detectProperties(ctx); err != nil {
return err
}
switch {
case d.c.signatureBase != nil:
return d.putSignaturesToLookaside(signatures)
case d.c.supportsSignatures:
- return d.putSignaturesToAPIExtension(signatures)
+ return d.putSignaturesToAPIExtension(ctx, signatures)
default:
return errors.Errorf("X-Registry-Supports-Signatures extension not supported, and lookaside is not configured")
}
@@ -378,7 +378,7 @@ func (c *dockerClient) deleteOneSignature(url *url.URL) (missing bool, err error
}
// putSignaturesToAPIExtension implements PutSignatures() using the X-Registry-Supports-Signatures API extension.
-func (d *dockerImageDestination) putSignaturesToAPIExtension(signatures [][]byte) error {
+func (d *dockerImageDestination) putSignaturesToAPIExtension(ctx context.Context, signatures [][]byte) error {
// Skip dealing with the manifest digest, or reading the old state, if not necessary.
if len(signatures) == 0 {
return nil
@@ -393,7 +393,7 @@ func (d *dockerImageDestination) putSignaturesToAPIExtension(signatures [][]byte
// always adds signatures. Eventually we should also allow removing signatures,
// but the X-Registry-Supports-Signatures API extension does not support that yet.
- existingSignatures, err := d.c.getExtensionsSignatures(context.TODO(), d.ref, d.manifestDigest)
+ existingSignatures, err := d.c.getExtensionsSignatures(ctx, d.ref, d.manifestDigest)
if err != nil {
return err
}
@@ -435,7 +435,7 @@ sigExists:
}
path := fmt.Sprintf(extensionsSignaturePath, reference.Path(d.ref.ref), d.manifestDigest.String())
- res, err := d.c.makeRequest(context.TODO(), "PUT", path, nil, bytes.NewReader(body))
+ res, err := d.c.makeRequest(ctx, "PUT", path, nil, bytes.NewReader(body))
if err != nil {
return err
}
@@ -457,6 +457,6 @@ sigExists:
// WARNING: This does not have any transactional semantics:
// - Uploaded data MAY be visible to others before Commit() is called
// - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed)
-func (d *dockerImageDestination) Commit() error {
+func (d *dockerImageDestination) Commit(ctx context.Context) error {
return nil
}
diff --git a/vendor/github.com/containers/image/docker/docker_image_src.go b/vendor/github.com/containers/image/docker/docker_image_src.go
index 7b96e95e8..98f6067e1 100644
--- a/vendor/github.com/containers/image/docker/docker_image_src.go
+++ b/vendor/github.com/containers/image/docker/docker_image_src.go
@@ -30,8 +30,8 @@ type dockerImageSource struct {
// newImageSource creates a new ImageSource for the specified image reference.
// The caller must call .Close() on the returned ImageSource.
-func newImageSource(ctx *types.SystemContext, ref dockerReference) (*dockerImageSource, error) {
- c, err := newDockerClientFromRef(ctx, ref, false, "pull")
+func newImageSource(sys *types.SystemContext, ref dockerReference) (*dockerImageSource, error) {
+ c, err := newDockerClientFromRef(sys, ref, false, "pull")
if err != nil {
return nil, err
}
@@ -53,7 +53,7 @@ func (s *dockerImageSource) Close() error {
}
// LayerInfosForCopy() returns updated layer info that should be used when reading, in preference to values in the manifest, if specified.
-func (s *dockerImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (s *dockerImageSource) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
return nil, nil
}
@@ -74,11 +74,11 @@ func simplifyContentType(contentType string) string {
// It may use a remote (= slow) service.
// If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve (when the primary manifest is a manifest list);
// this never happens if the primary manifest is not a manifest list (e.g. if the source never returns manifest lists).
-func (s *dockerImageSource) GetManifest(instanceDigest *digest.Digest) ([]byte, string, error) {
+func (s *dockerImageSource) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error) {
if instanceDigest != nil {
- return s.fetchManifest(context.TODO(), instanceDigest.String())
+ return s.fetchManifest(ctx, instanceDigest.String())
}
- err := s.ensureManifestIsLoaded(context.TODO())
+ err := s.ensureManifestIsLoaded(ctx)
if err != nil {
return nil, "", err
}
@@ -108,7 +108,7 @@ func (s *dockerImageSource) fetchManifest(ctx context.Context, tagOrDigest strin
//
// ImageSource implementations are not required or expected to do any caching,
// but because our signatures are “attached” to the manifest digest,
-// we need to ensure that the digest of the manifest returned by GetManifest(nil)
+// we need to ensure that the digest of the manifest returned by GetManifest(ctx, nil)
// and used by GetSignatures(ctx, nil) are consistent, otherwise we would get spurious
// signature verification failures when pulling while a tag is being updated.
func (s *dockerImageSource) ensureManifestIsLoaded(ctx context.Context) error {
@@ -131,13 +131,13 @@ func (s *dockerImageSource) ensureManifestIsLoaded(ctx context.Context) error {
return nil
}
-func (s *dockerImageSource) getExternalBlob(urls []string) (io.ReadCloser, int64, error) {
+func (s *dockerImageSource) getExternalBlob(ctx context.Context, urls []string) (io.ReadCloser, int64, error) {
var (
resp *http.Response
err error
)
for _, url := range urls {
- resp, err = s.c.makeRequestToResolvedURL(context.TODO(), "GET", url, nil, nil, -1, false)
+ resp, err = s.c.makeRequestToResolvedURL(ctx, "GET", url, nil, nil, -1, false)
if err == nil {
if resp.StatusCode != http.StatusOK {
err = errors.Errorf("error fetching external blob from %q: %d", url, resp.StatusCode)
@@ -162,14 +162,14 @@ func getBlobSize(resp *http.Response) int64 {
}
// GetBlob returns a stream for the specified blob, and the blob’s size (or -1 if unknown).
-func (s *dockerImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
+func (s *dockerImageSource) GetBlob(ctx context.Context, info types.BlobInfo) (io.ReadCloser, int64, error) {
if len(info.URLs) != 0 {
- return s.getExternalBlob(info.URLs)
+ return s.getExternalBlob(ctx, info.URLs)
}
path := fmt.Sprintf(blobsPath, reference.Path(s.ref.ref), info.Digest.String())
logrus.Debugf("Downloading %s", path)
- res, err := s.c.makeRequest(context.TODO(), "GET", path, nil, nil)
+ res, err := s.c.makeRequest(ctx, "GET", path, nil, nil)
if err != nil {
return nil, 0, err
}
@@ -309,8 +309,8 @@ func (s *dockerImageSource) getSignaturesFromAPIExtension(ctx context.Context, i
}
// deleteImage deletes the named image from the registry, if supported.
-func deleteImage(ctx *types.SystemContext, ref dockerReference) error {
- c, err := newDockerClientFromRef(ctx, ref, true, "push")
+func deleteImage(ctx context.Context, sys *types.SystemContext, ref dockerReference) error {
+ c, err := newDockerClientFromRef(sys, ref, true, "push")
if err != nil {
return err
}
@@ -325,7 +325,7 @@ func deleteImage(ctx *types.SystemContext, ref dockerReference) error {
return err
}
getPath := fmt.Sprintf(manifestPath, reference.Path(ref.ref), refTail)
- get, err := c.makeRequest(context.TODO(), "GET", getPath, headers, nil)
+ get, err := c.makeRequest(ctx, "GET", getPath, headers, nil)
if err != nil {
return err
}
@@ -347,7 +347,7 @@ func deleteImage(ctx *types.SystemContext, ref dockerReference) error {
// When retrieving the digest from a registry >= 2.3 use the following header:
// "Accept": "application/vnd.docker.distribution.manifest.v2+json"
- delete, err := c.makeRequest(context.TODO(), "DELETE", deletePath, headers, nil)
+ delete, err := c.makeRequest(ctx, "DELETE", deletePath, headers, nil)
if err != nil {
return err
}
diff --git a/vendor/github.com/containers/image/docker/docker_transport.go b/vendor/github.com/containers/image/docker/docker_transport.go
index cc0aa298a..3c67efb4a 100644
--- a/vendor/github.com/containers/image/docker/docker_transport.go
+++ b/vendor/github.com/containers/image/docker/docker_transport.go
@@ -1,6 +1,7 @@
package docker
import (
+ "context"
"fmt"
"strings"
@@ -127,25 +128,25 @@ func (ref dockerReference) PolicyConfigurationNamespaces() []string {
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
-func (ref dockerReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
- return newImage(ctx, ref)
+func (ref dockerReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
+ return newImage(ctx, sys, ref)
}
// NewImageSource returns a types.ImageSource for this reference.
// The caller must call .Close() on the returned ImageSource.
-func (ref dockerReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
- return newImageSource(ctx, ref)
+func (ref dockerReference) NewImageSource(ctx context.Context, sys *types.SystemContext) (types.ImageSource, error) {
+ return newImageSource(sys, ref)
}
// NewImageDestination returns a types.ImageDestination for this reference.
// The caller must call .Close() on the returned ImageDestination.
-func (ref dockerReference) NewImageDestination(ctx *types.SystemContext) (types.ImageDestination, error) {
- return newImageDestination(ctx, ref)
+func (ref dockerReference) NewImageDestination(ctx context.Context, sys *types.SystemContext) (types.ImageDestination, error) {
+ return newImageDestination(sys, ref)
}
// DeleteImage deletes the named image from the registry, if supported.
-func (ref dockerReference) DeleteImage(ctx *types.SystemContext) error {
- return deleteImage(ctx, ref)
+func (ref dockerReference) DeleteImage(ctx context.Context, sys *types.SystemContext) error {
+ return deleteImage(ctx, sys, ref)
}
// tagOrDigest returns a tag or digest from the reference.
diff --git a/vendor/github.com/containers/image/docker/lookaside.go b/vendor/github.com/containers/image/docker/lookaside.go
index 18e7733b9..860f1ad5e 100644
--- a/vendor/github.com/containers/image/docker/lookaside.go
+++ b/vendor/github.com/containers/image/docker/lookaside.go
@@ -45,9 +45,9 @@ type registryNamespace struct {
type signatureStorageBase *url.URL // The only documented value is nil, meaning storage is not supported.
// configuredSignatureStorageBase reads configuration to find an appropriate signature storage URL for ref, for write access if “write”.
-func configuredSignatureStorageBase(ctx *types.SystemContext, ref dockerReference, write bool) (signatureStorageBase, error) {
+func configuredSignatureStorageBase(sys *types.SystemContext, ref dockerReference, write bool) (signatureStorageBase, error) {
// FIXME? Loading and parsing the config could be cached across calls.
- dirPath := registriesDirPath(ctx)
+ dirPath := registriesDirPath(sys)
logrus.Debugf(`Using registries.d directory %s for sigstore configuration`, dirPath)
config, err := loadAndMergeConfig(dirPath)
if err != nil {
@@ -74,13 +74,13 @@ func configuredSignatureStorageBase(ctx *types.SystemContext, ref dockerReferenc
}
// registriesDirPath returns a path to registries.d
-func registriesDirPath(ctx *types.SystemContext) string {
- if ctx != nil {
- if ctx.RegistriesDirPath != "" {
- return ctx.RegistriesDirPath
+func registriesDirPath(sys *types.SystemContext) string {
+ if sys != nil {
+ if sys.RegistriesDirPath != "" {
+ return sys.RegistriesDirPath
}
- if ctx.RootForImplicitAbsolutePaths != "" {
- return filepath.Join(ctx.RootForImplicitAbsolutePaths, systemRegistriesDirPath)
+ if sys.RootForImplicitAbsolutePaths != "" {
+ return filepath.Join(sys.RootForImplicitAbsolutePaths, systemRegistriesDirPath)
}
}
return systemRegistriesDirPath
diff --git a/vendor/github.com/containers/image/docker/tarfile/dest.go b/vendor/github.com/containers/image/docker/tarfile/dest.go
index 1b1cefaea..2bbaf4320 100644
--- a/vendor/github.com/containers/image/docker/tarfile/dest.go
+++ b/vendor/github.com/containers/image/docker/tarfile/dest.go
@@ -3,6 +3,7 @@ package tarfile
import (
"archive/tar"
"bytes"
+ "context"
"encoding/json"
"fmt"
"io"
@@ -50,7 +51,7 @@ func (d *Destination) SupportedManifestMIMETypes() []string {
// SupportsSignatures returns an error (to be displayed to the user) if the destination certainly can't store signatures.
// Note: It is still possible for PutSignatures to fail if SupportsSignatures returns nil.
-func (d *Destination) SupportsSignatures() error {
+func (d *Destination) SupportsSignatures(ctx context.Context) error {
return errors.Errorf("Storing signatures for docker tar files is not supported")
}
@@ -71,7 +72,7 @@ func (d *Destination) MustMatchRuntimeOS() bool {
// WARNING: The contents of stream are being verified on the fly. Until stream.Read() returns io.EOF, the contents of the data SHOULD NOT be available
// to any other readers for download using the supplied digest.
// If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far.
-func (d *Destination) PutBlob(stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
+func (d *Destination) PutBlob(ctx context.Context, stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
// Ouch, we need to stream the blob into a temporary file just to determine the size.
// When the layer is decompressed, we also have to generate the digest on uncompressed datas.
if inputInfo.Size == -1 || inputInfo.Digest.String() == "" {
@@ -85,6 +86,7 @@ func (d *Destination) PutBlob(stream io.Reader, inputInfo types.BlobInfo, isConf
digester := digest.Canonical.Digester()
tee := io.TeeReader(stream, digester.Hash())
+ // TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().
size, err := io.Copy(streamCopy, tee)
if err != nil {
return types.BlobInfo{}, err
@@ -102,7 +104,7 @@ func (d *Destination) PutBlob(stream io.Reader, inputInfo types.BlobInfo, isConf
}
// Maybe the blob has been already sent
- ok, size, err := d.HasBlob(inputInfo)
+ ok, size, err := d.HasBlob(ctx, inputInfo)
if err != nil {
return types.BlobInfo{}, err
}
@@ -139,7 +141,7 @@ func (d *Destination) PutBlob(stream io.Reader, inputInfo types.BlobInfo, isConf
// the blob must also be returned. If the destination does not contain the
// blob, or it is unknown, HasBlob ordinarily returns (false, -1, nil); it
// returns a non-nil error only on an unexpected failure.
-func (d *Destination) HasBlob(info types.BlobInfo) (bool, int64, error) {
+func (d *Destination) HasBlob(ctx context.Context, info types.BlobInfo) (bool, int64, error) {
if info.Digest == "" {
return false, -1, errors.Errorf("Can not check for a blob with unknown digest")
}
@@ -154,7 +156,7 @@ func (d *Destination) HasBlob(info types.BlobInfo) (bool, int64, error) {
// returned false. Like HasBlob and unlike PutBlob, the digest can not be
// empty. If the blob is a filesystem layer, this signifies that the changes
// it describes need to be applied again when composing a filesystem tree.
-func (d *Destination) ReapplyBlob(info types.BlobInfo) (types.BlobInfo, error) {
+func (d *Destination) ReapplyBlob(ctx context.Context, info types.BlobInfo) (types.BlobInfo, error) {
return info, nil
}
@@ -175,7 +177,7 @@ func (d *Destination) createRepositoriesFile(rootLayerID string) error {
// FIXME? This should also receive a MIME type if known, to differentiate between schema versions.
// If the destination is in principle available, refuses this manifest type (e.g. it does not recognize the schema),
// but may accept a different manifest type, the returned error must be an ManifestTypeRejectedError.
-func (d *Destination) PutManifest(m []byte) error {
+func (d *Destination) PutManifest(ctx context.Context, m []byte) error {
// We do not bother with types.ManifestTypeRejectedError; our .SupportedManifestMIMETypes() above is already providing only one alternative,
// so the caller trying a different manifest kind would be pointless.
var man manifest.Schema2
@@ -351,6 +353,7 @@ func (d *Destination) sendFile(path string, expectedSize int64, stream io.Reader
if err := d.tar.WriteHeader(hdr); err != nil {
return err
}
+ // TODO: This can take quite some time, and should ideally be cancellable using a context.Context.
size, err := io.Copy(d.tar, stream)
if err != nil {
return err
@@ -364,7 +367,7 @@ func (d *Destination) sendFile(path string, expectedSize int64, stream io.Reader
// PutSignatures adds the given signatures to the docker tarfile (currently not
// supported). MUST be called after PutManifest (signatures reference manifest
// contents)
-func (d *Destination) PutSignatures(signatures [][]byte) error {
+func (d *Destination) PutSignatures(ctx context.Context, signatures [][]byte) error {
if len(signatures) != 0 {
return errors.Errorf("Storing signatures for docker tar files is not supported")
}
@@ -373,6 +376,6 @@ func (d *Destination) PutSignatures(signatures [][]byte) error {
// Commit finishes writing data to the underlying io.Writer.
// It is the caller's responsibility to close it, if necessary.
-func (d *Destination) Commit() error {
+func (d *Destination) Commit(ctx context.Context) error {
return d.tar.Close()
}
diff --git a/vendor/github.com/containers/image/docker/tarfile/src.go b/vendor/github.com/containers/image/docker/tarfile/src.go
index e7a5231df..2a0d9966e 100644
--- a/vendor/github.com/containers/image/docker/tarfile/src.go
+++ b/vendor/github.com/containers/image/docker/tarfile/src.go
@@ -81,6 +81,7 @@ func NewSourceFromStream(inputStream io.Reader) (*Source, error) {
}
}()
+ // TODO: This can take quite some time, and should ideally be cancellable using a context.Context.
if _, err := io.Copy(tarCopyFile, inputStream); err != nil {
return nil, errors.Wrapf(err, "error copying contents to temporary file %q", tarCopyFile.Name())
}
@@ -306,9 +307,9 @@ func (s *Source) prepareLayerData(tarManifest *ManifestItem, parsedConfig *manif
// It may use a remote (= slow) service.
// If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve (when the primary manifest is a manifest list);
// this never happens if the primary manifest is not a manifest list (e.g. if the source never returns manifest lists).
-func (s *Source) GetManifest(instanceDigest *digest.Digest) ([]byte, string, error) {
+func (s *Source) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error) {
if instanceDigest != nil {
- // How did we even get here? GetManifest(nil) has returned a manifest.DockerV2Schema2MediaType.
+ // How did we even get here? GetManifest(ctx, nil) has returned a manifest.DockerV2Schema2MediaType.
return nil, "", errors.Errorf(`Manifest lists are not supported by "docker-daemon:"`)
}
if s.generatedManifest == nil {
@@ -358,7 +359,7 @@ func (r readCloseWrapper) Close() error {
}
// GetBlob returns a stream for the specified blob, and the blob’s size (or -1 if unknown).
-func (s *Source) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
+func (s *Source) GetBlob(ctx context.Context, info types.BlobInfo) (io.ReadCloser, int64, error) {
if err := s.ensureCachedDataIsPresent(); err != nil {
return nil, 0, err
}
@@ -414,7 +415,7 @@ func (s *Source) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
// (e.g. if the source never returns manifest lists).
func (s *Source) GetSignatures(ctx context.Context, instanceDigest *digest.Digest) ([][]byte, error) {
if instanceDigest != nil {
- // How did we even get here? GetManifest(nil) has returned a manifest.DockerV2Schema2MediaType.
+ // How did we even get here? GetManifest(ctx, nil) has returned a manifest.DockerV2Schema2MediaType.
return nil, errors.Errorf(`Manifest lists are not supported by "docker-daemon:"`)
}
return [][]byte{}, nil
diff --git a/vendor/github.com/containers/image/image/docker_list.go b/vendor/github.com/containers/image/image/docker_list.go
index 412261ddb..1f0faa1ad 100644
--- a/vendor/github.com/containers/image/image/docker_list.go
+++ b/vendor/github.com/containers/image/image/docker_list.go
@@ -1,6 +1,7 @@
package image
import (
+ "context"
"encoding/json"
"fmt"
"runtime"
@@ -34,14 +35,14 @@ type manifestList struct {
// chooseDigestFromManifestList parses blob as a schema2 manifest list,
// and returns the digest of the image appropriate for the current environment.
-func chooseDigestFromManifestList(ctx *types.SystemContext, blob []byte) (digest.Digest, error) {
+func chooseDigestFromManifestList(sys *types.SystemContext, blob []byte) (digest.Digest, error) {
wantedArch := runtime.GOARCH
- if ctx != nil && ctx.ArchitectureChoice != "" {
- wantedArch = ctx.ArchitectureChoice
+ if sys != nil && sys.ArchitectureChoice != "" {
+ wantedArch = sys.ArchitectureChoice
}
wantedOS := runtime.GOOS
- if ctx != nil && ctx.OSChoice != "" {
- wantedOS = ctx.OSChoice
+ if sys != nil && sys.OSChoice != "" {
+ wantedOS = sys.OSChoice
}
list := manifestList{}
@@ -56,12 +57,12 @@ func chooseDigestFromManifestList(ctx *types.SystemContext, blob []byte) (digest
return "", fmt.Errorf("no image found in manifest list for architecture %s, OS %s", wantedArch, wantedOS)
}
-func manifestSchema2FromManifestList(ctx *types.SystemContext, src types.ImageSource, manblob []byte) (genericManifest, error) {
- targetManifestDigest, err := chooseDigestFromManifestList(ctx, manblob)
+func manifestSchema2FromManifestList(ctx context.Context, sys *types.SystemContext, src types.ImageSource, manblob []byte) (genericManifest, error) {
+ targetManifestDigest, err := chooseDigestFromManifestList(sys, manblob)
if err != nil {
return nil, err
}
- manblob, mt, err := src.GetManifest(&targetManifestDigest)
+ manblob, mt, err := src.GetManifest(ctx, &targetManifestDigest)
if err != nil {
return nil, err
}
@@ -74,20 +75,20 @@ func manifestSchema2FromManifestList(ctx *types.SystemContext, src types.ImageSo
return nil, errors.Errorf("Manifest image does not match selected manifest digest %s", targetManifestDigest)
}
- return manifestInstanceFromBlob(ctx, src, manblob, mt)
+ return manifestInstanceFromBlob(ctx, sys, src, manblob, mt)
}
// ChooseManifestInstanceFromManifestList returns a digest of a manifest appropriate
// for the current system from the manifest available from src.
-func ChooseManifestInstanceFromManifestList(ctx *types.SystemContext, src types.UnparsedImage) (digest.Digest, error) {
+func ChooseManifestInstanceFromManifestList(ctx context.Context, sys *types.SystemContext, src types.UnparsedImage) (digest.Digest, error) {
// For now this only handles manifest.DockerV2ListMediaType; we can generalize it later,
// probably along with manifest list editing.
- blob, mt, err := src.Manifest()
+ blob, mt, err := src.Manifest(ctx)
if err != nil {
return "", err
}
if mt != manifest.DockerV2ListMediaType {
return "", fmt.Errorf("Internal error: Trying to select an image from a non-manifest-list manifest type %s", mt)
}
- return chooseDigestFromManifestList(ctx, blob)
+ return chooseDigestFromManifestList(sys, blob)
}
diff --git a/vendor/github.com/containers/image/image/docker_schema1.go b/vendor/github.com/containers/image/image/docker_schema1.go
index f7dc90a3f..929381813 100644
--- a/vendor/github.com/containers/image/image/docker_schema1.go
+++ b/vendor/github.com/containers/image/image/docker_schema1.go
@@ -1,6 +1,7 @@
package image
import (
+ "context"
"encoding/json"
"github.com/containers/image/docker/reference"
@@ -44,19 +45,19 @@ func (m *manifestSchema1) ConfigInfo() types.BlobInfo {
// ConfigBlob returns the blob described by ConfigInfo, iff ConfigInfo().Digest != ""; nil otherwise.
// The result is cached; it is OK to call this however often you need.
-func (m *manifestSchema1) ConfigBlob() ([]byte, error) {
+func (m *manifestSchema1) ConfigBlob(context.Context) ([]byte, error) {
return nil, nil
}
// OCIConfig returns the image configuration as per OCI v1 image-spec. Information about
// layers in the resulting configuration isn't guaranteed to be returned to due how
// old image manifests work (docker v2s1 especially).
-func (m *manifestSchema1) OCIConfig() (*imgspecv1.Image, error) {
+func (m *manifestSchema1) OCIConfig(ctx context.Context) (*imgspecv1.Image, error) {
v2s2, err := m.convertToManifestSchema2(nil, nil)
if err != nil {
return nil, err
}
- return v2s2.OCIConfig()
+ return v2s2.OCIConfig(ctx)
}
// LayerInfos returns a list of BlobInfos of layers referenced by this image, in order (the root layer first, and then successive layered layers).
@@ -88,7 +89,7 @@ func (m *manifestSchema1) EmbeddedDockerReferenceConflicts(ref reference.Named)
}
// Inspect returns various information for (skopeo inspect) parsed from the manifest and configuration.
-func (m *manifestSchema1) Inspect() (*types.ImageInspectInfo, error) {
+func (m *manifestSchema1) Inspect(context.Context) (*types.ImageInspectInfo, error) {
return m.m.Inspect(nil)
}
@@ -101,7 +102,7 @@ func (m *manifestSchema1) UpdatedImageNeedsLayerDiffIDs(options types.ManifestUp
// UpdatedImage returns a types.Image modified according to options.
// This does not change the state of the original Image object.
-func (m *manifestSchema1) UpdatedImage(options types.ManifestUpdateOptions) (types.Image, error) {
+func (m *manifestSchema1) UpdatedImage(ctx context.Context, options types.ManifestUpdateOptions) (types.Image, error) {
copy := manifestSchema1{m: manifest.Schema1Clone(m.m)}
if options.LayerInfos != nil {
if err := copy.m.UpdateLayerInfos(options.LayerInfos); err != nil {
@@ -134,7 +135,7 @@ func (m *manifestSchema1) UpdatedImage(options types.ManifestUpdateOptions) (typ
if err != nil {
return nil, err
}
- return m2.UpdatedImage(types.ManifestUpdateOptions{
+ return m2.UpdatedImage(ctx, types.ManifestUpdateOptions{
ManifestMIMEType: imgspecv1.MediaTypeImageManifest,
InformationOnly: options.InformationOnly,
})
diff --git a/vendor/github.com/containers/image/image/docker_schema2.go b/vendor/github.com/containers/image/image/docker_schema2.go
index 2ef8d4622..95542e4a1 100644
--- a/vendor/github.com/containers/image/image/docker_schema2.go
+++ b/vendor/github.com/containers/image/image/docker_schema2.go
@@ -2,6 +2,7 @@ package image
import (
"bytes"
+ "context"
"crypto/sha256"
"encoding/hex"
"encoding/json"
@@ -72,8 +73,8 @@ func (m *manifestSchema2) ConfigInfo() types.BlobInfo {
// OCIConfig returns the image configuration as per OCI v1 image-spec. Information about
// layers in the resulting configuration isn't guaranteed to be returned to due how
// old image manifests work (docker v2s1 especially).
-func (m *manifestSchema2) OCIConfig() (*imgspecv1.Image, error) {
- configBlob, err := m.ConfigBlob()
+func (m *manifestSchema2) OCIConfig(ctx context.Context) (*imgspecv1.Image, error) {
+ configBlob, err := m.ConfigBlob(ctx)
if err != nil {
return nil, err
}
@@ -89,12 +90,12 @@ func (m *manifestSchema2) OCIConfig() (*imgspecv1.Image, error) {
// ConfigBlob returns the blob described by ConfigInfo, iff ConfigInfo().Digest != ""; nil otherwise.
// The result is cached; it is OK to call this however often you need.
-func (m *manifestSchema2) ConfigBlob() ([]byte, error) {
+func (m *manifestSchema2) ConfigBlob(ctx context.Context) ([]byte, error) {
if m.configBlob == nil {
if m.src == nil {
return nil, errors.Errorf("Internal error: neither src nor configBlob set in manifestSchema2")
}
- stream, _, err := m.src.GetBlob(types.BlobInfo{
+ stream, _, err := m.src.GetBlob(ctx, types.BlobInfo{
Digest: m.m.ConfigDescriptor.Digest,
Size: m.m.ConfigDescriptor.Size,
URLs: m.m.ConfigDescriptor.URLs,
@@ -131,13 +132,13 @@ func (m *manifestSchema2) EmbeddedDockerReferenceConflicts(ref reference.Named)
}
// Inspect returns various information for (skopeo inspect) parsed from the manifest and configuration.
-func (m *manifestSchema2) Inspect() (*types.ImageInspectInfo, error) {
+func (m *manifestSchema2) Inspect(ctx context.Context) (*types.ImageInspectInfo, error) {
getter := func(info types.BlobInfo) ([]byte, error) {
if info.Digest != m.ConfigInfo().Digest {
// Shouldn't ever happen
return nil, errors.New("asked for a different config blob")
}
- config, err := m.ConfigBlob()
+ config, err := m.ConfigBlob(ctx)
if err != nil {
return nil, err
}
@@ -155,7 +156,7 @@ func (m *manifestSchema2) UpdatedImageNeedsLayerDiffIDs(options types.ManifestUp
// UpdatedImage returns a types.Image modified according to options.
// This does not change the state of the original Image object.
-func (m *manifestSchema2) UpdatedImage(options types.ManifestUpdateOptions) (types.Image, error) {
+func (m *manifestSchema2) UpdatedImage(ctx context.Context, options types.ManifestUpdateOptions) (types.Image, error) {
copy := manifestSchema2{ // NOTE: This is not a deep copy, it still shares slices etc.
src: m.src,
configBlob: m.configBlob,
@@ -171,9 +172,9 @@ func (m *manifestSchema2) UpdatedImage(options types.ManifestUpdateOptions) (typ
switch options.ManifestMIMEType {
case "": // No conversion, OK
case manifest.DockerV2Schema1SignedMediaType, manifest.DockerV2Schema1MediaType:
- return copy.convertToManifestSchema1(options.InformationOnly.Destination)
+ return copy.convertToManifestSchema1(ctx, options.InformationOnly.Destination)
case imgspecv1.MediaTypeImageManifest:
- return copy.convertToManifestOCI1()
+ return copy.convertToManifestOCI1(ctx)
default:
return nil, errors.Errorf("Conversion of image manifest from %s to %s is not implemented", manifest.DockerV2Schema2MediaType, options.ManifestMIMEType)
}
@@ -190,8 +191,8 @@ func oci1DescriptorFromSchema2Descriptor(d manifest.Schema2Descriptor) imgspecv1
}
}
-func (m *manifestSchema2) convertToManifestOCI1() (types.Image, error) {
- configOCI, err := m.OCIConfig()
+func (m *manifestSchema2) convertToManifestOCI1(ctx context.Context) (types.Image, error) {
+ configOCI, err := m.OCIConfig(ctx)
if err != nil {
return nil, err
}
@@ -223,8 +224,8 @@ func (m *manifestSchema2) convertToManifestOCI1() (types.Image, error) {
}
// Based on docker/distribution/manifest/schema1/config_builder.go
-func (m *manifestSchema2) convertToManifestSchema1(dest types.ImageDestination) (types.Image, error) {
- configBytes, err := m.ConfigBlob()
+func (m *manifestSchema2) convertToManifestSchema1(ctx context.Context, dest types.ImageDestination) (types.Image, error) {
+ configBytes, err := m.ConfigBlob(ctx)
if err != nil {
return nil, err
}
@@ -252,7 +253,7 @@ func (m *manifestSchema2) convertToManifestSchema1(dest types.ImageDestination)
if historyEntry.EmptyLayer {
if !haveGzippedEmptyLayer {
logrus.Debugf("Uploading empty layer during conversion to schema 1")
- info, err := dest.PutBlob(bytes.NewReader(gzippedEmptyLayer), types.BlobInfo{Digest: gzippedEmptyLayerDigest, Size: int64(len(gzippedEmptyLayer))}, false)
+ info, err := dest.PutBlob(ctx, bytes.NewReader(gzippedEmptyLayer), types.BlobInfo{Digest: gzippedEmptyLayerDigest, Size: int64(len(gzippedEmptyLayer))}, false)
if err != nil {
return nil, errors.Wrap(err, "Error uploading empty layer")
}
diff --git a/vendor/github.com/containers/image/image/manifest.go b/vendor/github.com/containers/image/image/manifest.go
index 4f7d6248f..09d30ff38 100644
--- a/vendor/github.com/containers/image/image/manifest.go
+++ b/vendor/github.com/containers/image/image/manifest.go
@@ -1,6 +1,7 @@
package image
import (
+ "context"
"fmt"
"github.com/containers/image/docker/reference"
@@ -21,11 +22,11 @@ type genericManifest interface {
ConfigInfo() types.BlobInfo
// ConfigBlob returns the blob described by ConfigInfo, iff ConfigInfo().Digest != ""; nil otherwise.
// The result is cached; it is OK to call this however often you need.
- ConfigBlob() ([]byte, error)
+ ConfigBlob(context.Context) ([]byte, error)
// OCIConfig returns the image configuration as per OCI v1 image-spec. Information about
// layers in the resulting configuration isn't guaranteed to be returned to due how
// old image manifests work (docker v2s1 especially).
- OCIConfig() (*imgspecv1.Image, error)
+ OCIConfig(context.Context) (*imgspecv1.Image, error)
// LayerInfos returns a list of BlobInfos of layers referenced by this image, in order (the root layer first, and then successive layered layers).
// The Digest field is guaranteed to be provided; Size may be -1.
// WARNING: The list may contain duplicates, and they are semantically relevant.
@@ -35,19 +36,19 @@ type genericManifest interface {
// (This embedding unfortunately happens for Docker schema1, please do not add support for this in any new formats.)
EmbeddedDockerReferenceConflicts(ref reference.Named) bool
// Inspect returns various information for (skopeo inspect) parsed from the manifest and configuration.
- Inspect() (*types.ImageInspectInfo, error)
+ Inspect(context.Context) (*types.ImageInspectInfo, error)
// UpdatedImageNeedsLayerDiffIDs returns true iff UpdatedImage(options) needs InformationOnly.LayerDiffIDs.
// This is a horribly specific interface, but computing InformationOnly.LayerDiffIDs can be very expensive to compute
// (most importantly it forces us to download the full layers even if they are already present at the destination).
UpdatedImageNeedsLayerDiffIDs(options types.ManifestUpdateOptions) bool
// UpdatedImage returns a types.Image modified according to options.
// This does not change the state of the original Image object.
- UpdatedImage(options types.ManifestUpdateOptions) (types.Image, error)
+ UpdatedImage(ctx context.Context, options types.ManifestUpdateOptions) (types.Image, error)
}
// manifestInstanceFromBlob returns a genericManifest implementation for (manblob, mt) in src.
// If manblob is a manifest list, it implicitly chooses an appropriate image from the list.
-func manifestInstanceFromBlob(ctx *types.SystemContext, src types.ImageSource, manblob []byte, mt string) (genericManifest, error) {
+func manifestInstanceFromBlob(ctx context.Context, sys *types.SystemContext, src types.ImageSource, manblob []byte, mt string) (genericManifest, error) {
switch manifest.NormalizedMIMEType(mt) {
case manifest.DockerV2Schema1MediaType, manifest.DockerV2Schema1SignedMediaType:
return manifestSchema1FromManifest(manblob)
@@ -56,7 +57,7 @@ func manifestInstanceFromBlob(ctx *types.SystemContext, src types.ImageSource, m
case manifest.DockerV2Schema2MediaType:
return manifestSchema2FromManifest(src, manblob)
case manifest.DockerV2ListMediaType:
- return manifestSchema2FromManifestList(ctx, src, manblob)
+ return manifestSchema2FromManifestList(ctx, sys, src, manblob)
default: // Note that this may not be reachable, manifest.NormalizedMIMEType has a default for unknown values.
return nil, fmt.Errorf("Unimplemented manifest MIME type %s", mt)
}
diff --git a/vendor/github.com/containers/image/image/memory.go b/vendor/github.com/containers/image/image/memory.go
index 42b287994..0be69eca4 100644
--- a/vendor/github.com/containers/image/image/memory.go
+++ b/vendor/github.com/containers/image/image/memory.go
@@ -39,7 +39,7 @@ func (i *memoryImage) Size() (int64, error) {
}
// Manifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need.
-func (i *memoryImage) Manifest() ([]byte, string, error) {
+func (i *memoryImage) Manifest(ctx context.Context) ([]byte, string, error) {
if i.serializedManifest == nil {
m, err := i.genericManifest.serialize()
if err != nil {
@@ -60,6 +60,6 @@ func (i *memoryImage) Signatures(ctx context.Context) ([][]byte, error) {
// LayerInfosForCopy returns an updated set of layer blob information which may not match the manifest.
// The Digest field is guaranteed to be provided; Size may be -1.
// WARNING: The list may contain duplicates, and they are semantically relevant.
-func (i *memoryImage) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (i *memoryImage) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
return nil, nil
}
diff --git a/vendor/github.com/containers/image/image/oci.go b/vendor/github.com/containers/image/image/oci.go
index 8569dd0b1..417738753 100644
--- a/vendor/github.com/containers/image/image/oci.go
+++ b/vendor/github.com/containers/image/image/oci.go
@@ -1,6 +1,7 @@
package image
import (
+ "context"
"encoding/json"
"io/ioutil"
@@ -54,12 +55,12 @@ func (m *manifestOCI1) ConfigInfo() types.BlobInfo {
// ConfigBlob returns the blob described by ConfigInfo, iff ConfigInfo().Digest != ""; nil otherwise.
// The result is cached; it is OK to call this however often you need.
-func (m *manifestOCI1) ConfigBlob() ([]byte, error) {
+func (m *manifestOCI1) ConfigBlob(ctx context.Context) ([]byte, error) {
if m.configBlob == nil {
if m.src == nil {
return nil, errors.Errorf("Internal error: neither src nor configBlob set in manifestOCI1")
}
- stream, _, err := m.src.GetBlob(types.BlobInfo{
+ stream, _, err := m.src.GetBlob(ctx, types.BlobInfo{
Digest: m.m.Config.Digest,
Size: m.m.Config.Size,
URLs: m.m.Config.URLs,
@@ -84,8 +85,8 @@ func (m *manifestOCI1) ConfigBlob() ([]byte, error) {
// OCIConfig returns the image configuration as per OCI v1 image-spec. Information about
// layers in the resulting configuration isn't guaranteed to be returned to due how
// old image manifests work (docker v2s1 especially).
-func (m *manifestOCI1) OCIConfig() (*imgspecv1.Image, error) {
- cb, err := m.ConfigBlob()
+func (m *manifestOCI1) OCIConfig(ctx context.Context) (*imgspecv1.Image, error) {
+ cb, err := m.ConfigBlob(ctx)
if err != nil {
return nil, err
}
@@ -111,13 +112,13 @@ func (m *manifestOCI1) EmbeddedDockerReferenceConflicts(ref reference.Named) boo
}
// Inspect returns various information for (skopeo inspect) parsed from the manifest and configuration.
-func (m *manifestOCI1) Inspect() (*types.ImageInspectInfo, error) {
+func (m *manifestOCI1) Inspect(ctx context.Context) (*types.ImageInspectInfo, error) {
getter := func(info types.BlobInfo) ([]byte, error) {
if info.Digest != m.ConfigInfo().Digest {
// Shouldn't ever happen
return nil, errors.New("asked for a different config blob")
}
- config, err := m.ConfigBlob()
+ config, err := m.ConfigBlob(ctx)
if err != nil {
return nil, err
}
@@ -135,7 +136,7 @@ func (m *manifestOCI1) UpdatedImageNeedsLayerDiffIDs(options types.ManifestUpdat
// UpdatedImage returns a types.Image modified according to options.
// This does not change the state of the original Image object.
-func (m *manifestOCI1) UpdatedImage(options types.ManifestUpdateOptions) (types.Image, error) {
+func (m *manifestOCI1) UpdatedImage(ctx context.Context, options types.ManifestUpdateOptions) (types.Image, error) {
copy := manifestOCI1{ // NOTE: This is not a deep copy, it still shares slices etc.
src: m.src,
configBlob: m.configBlob,
@@ -156,7 +157,7 @@ func (m *manifestOCI1) UpdatedImage(options types.ManifestUpdateOptions) (types.
if err != nil {
return nil, err
}
- return m2.UpdatedImage(types.ManifestUpdateOptions{
+ return m2.UpdatedImage(ctx, types.ManifestUpdateOptions{
ManifestMIMEType: options.ManifestMIMEType,
InformationOnly: options.InformationOnly,
})
diff --git a/vendor/github.com/containers/image/image/sourced.go b/vendor/github.com/containers/image/image/sourced.go
index 84fea26e7..01cc28bbd 100644
--- a/vendor/github.com/containers/image/image/sourced.go
+++ b/vendor/github.com/containers/image/image/sourced.go
@@ -4,6 +4,7 @@
package image
import (
+ "context"
"github.com/containers/image/types"
)
@@ -28,8 +29,8 @@ type imageCloser struct {
//
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage instead of calling this function.
-func FromSource(ctx *types.SystemContext, src types.ImageSource) (types.ImageCloser, error) {
- img, err := FromUnparsedImage(ctx, UnparsedInstance(src, nil))
+func FromSource(ctx context.Context, sys *types.SystemContext, src types.ImageSource) (types.ImageCloser, error) {
+ img, err := FromUnparsedImage(ctx, sys, UnparsedInstance(src, nil))
if err != nil {
return nil, err
}
@@ -63,18 +64,18 @@ type sourcedImage struct {
// but other methods transparently return data from an appropriate single image.
//
// The Image must not be used after the underlying ImageSource is Close()d.
-func FromUnparsedImage(ctx *types.SystemContext, unparsed *UnparsedImage) (types.Image, error) {
+func FromUnparsedImage(ctx context.Context, sys *types.SystemContext, unparsed *UnparsedImage) (types.Image, error) {
// Note that the input parameter above is specifically *image.UnparsedImage, not types.UnparsedImage:
// we want to be able to use unparsed.src. We could make that an explicit interface, but, well,
// this is the only UnparsedImage implementation around, anyway.
// NOTE: It is essential for signature verification that all parsing done in this object happens on the same manifest which is returned by unparsed.Manifest().
- manifestBlob, manifestMIMEType, err := unparsed.Manifest()
+ manifestBlob, manifestMIMEType, err := unparsed.Manifest(ctx)
if err != nil {
return nil, err
}
- parsedManifest, err := manifestInstanceFromBlob(ctx, unparsed.src, manifestBlob, manifestMIMEType)
+ parsedManifest, err := manifestInstanceFromBlob(ctx, sys, unparsed.src, manifestBlob, manifestMIMEType)
if err != nil {
return nil, err
}
@@ -93,10 +94,10 @@ func (i *sourcedImage) Size() (int64, error) {
}
// Manifest overrides the UnparsedImage.Manifest to always use the fields which we have already fetched.
-func (i *sourcedImage) Manifest() ([]byte, string, error) {
+func (i *sourcedImage) Manifest(ctx context.Context) ([]byte, string, error) {
return i.manifestBlob, i.manifestMIMEType, nil
}
-func (i *sourcedImage) LayerInfosForCopy() ([]types.BlobInfo, error) {
- return i.UnparsedImage.src.LayerInfosForCopy()
+func (i *sourcedImage) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
+ return i.UnparsedImage.src.LayerInfosForCopy(ctx)
}
diff --git a/vendor/github.com/containers/image/image/unparsed.go b/vendor/github.com/containers/image/image/unparsed.go
index 0a8f78b66..2c9280d35 100644
--- a/vendor/github.com/containers/image/image/unparsed.go
+++ b/vendor/github.com/containers/image/image/unparsed.go
@@ -41,9 +41,9 @@ func (i *UnparsedImage) Reference() types.ImageReference {
}
// Manifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need.
-func (i *UnparsedImage) Manifest() ([]byte, string, error) {
+func (i *UnparsedImage) Manifest(ctx context.Context) ([]byte, string, error) {
if i.cachedManifest == nil {
- m, mt, err := i.src.GetManifest(i.instanceDigest)
+ m, mt, err := i.src.GetManifest(ctx, i.instanceDigest)
if err != nil {
return nil, "", err
}
diff --git a/vendor/github.com/containers/image/oci/archive/oci_dest.go b/vendor/github.com/containers/image/oci/archive/oci_dest.go
index 1cd3927a7..432b310b4 100644
--- a/vendor/github.com/containers/image/oci/archive/oci_dest.go
+++ b/vendor/github.com/containers/image/oci/archive/oci_dest.go
@@ -1,6 +1,7 @@
package archive
import (
+ "context"
"io"
"os"
@@ -16,12 +17,12 @@ type ociArchiveImageDestination struct {
}
// newImageDestination returns an ImageDestination for writing to an existing directory.
-func newImageDestination(ctx *types.SystemContext, ref ociArchiveReference) (types.ImageDestination, error) {
+func newImageDestination(ctx context.Context, sys *types.SystemContext, ref ociArchiveReference) (types.ImageDestination, error) {
tempDirRef, err := createOCIRef(ref.image)
if err != nil {
return nil, errors.Wrapf(err, "error creating oci reference")
}
- unpackedDest, err := tempDirRef.ociRefExtracted.NewImageDestination(ctx)
+ unpackedDest, err := tempDirRef.ociRefExtracted.NewImageDestination(ctx, sys)
if err != nil {
if err := tempDirRef.deleteTempDir(); err != nil {
return nil, errors.Wrapf(err, "error deleting temp directory", tempDirRef.tempDirectory)
@@ -50,8 +51,8 @@ func (d *ociArchiveImageDestination) SupportedManifestMIMETypes() []string {
}
// SupportsSignatures returns an error (to be displayed to the user) if the destination certainly can't store signatures
-func (d *ociArchiveImageDestination) SupportsSignatures() error {
- return d.unpackedDest.SupportsSignatures()
+func (d *ociArchiveImageDestination) SupportsSignatures(ctx context.Context) error {
+ return d.unpackedDest.SupportsSignatures(ctx)
}
func (d *ociArchiveImageDestination) DesiredLayerCompression() types.LayerCompression {
@@ -72,32 +73,32 @@ func (d *ociArchiveImageDestination) MustMatchRuntimeOS() bool {
// PutBlob writes contents of stream and returns data representing the result (with all data filled in).
// inputInfo.Digest can be optionally provided if known; it is not mandatory for the implementation to verify it.
// inputInfo.Size is the expected length of stream, if known.
-func (d *ociArchiveImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
- return d.unpackedDest.PutBlob(stream, inputInfo, isConfig)
+func (d *ociArchiveImageDestination) PutBlob(ctx context.Context, stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
+ return d.unpackedDest.PutBlob(ctx, stream, inputInfo, isConfig)
}
// HasBlob returns true iff the image destination already contains a blob with the matching digest which can be reapplied using ReapplyBlob
-func (d *ociArchiveImageDestination) HasBlob(info types.BlobInfo) (bool, int64, error) {
- return d.unpackedDest.HasBlob(info)
+func (d *ociArchiveImageDestination) HasBlob(ctx context.Context, info types.BlobInfo) (bool, int64, error) {
+ return d.unpackedDest.HasBlob(ctx, info)
}
-func (d *ociArchiveImageDestination) ReapplyBlob(info types.BlobInfo) (types.BlobInfo, error) {
- return d.unpackedDest.ReapplyBlob(info)
+func (d *ociArchiveImageDestination) ReapplyBlob(ctx context.Context, info types.BlobInfo) (types.BlobInfo, error) {
+ return d.unpackedDest.ReapplyBlob(ctx, info)
}
// PutManifest writes manifest to the destination
-func (d *ociArchiveImageDestination) PutManifest(m []byte) error {
- return d.unpackedDest.PutManifest(m)
+func (d *ociArchiveImageDestination) PutManifest(ctx context.Context, m []byte) error {
+ return d.unpackedDest.PutManifest(ctx, m)
}
-func (d *ociArchiveImageDestination) PutSignatures(signatures [][]byte) error {
- return d.unpackedDest.PutSignatures(signatures)
+func (d *ociArchiveImageDestination) PutSignatures(ctx context.Context, signatures [][]byte) error {
+ return d.unpackedDest.PutSignatures(ctx, signatures)
}
// Commit marks the process of storing the image as successful and asks for the image to be persisted
// after the directory is made, it is tarred up into a file and the directory is deleted
-func (d *ociArchiveImageDestination) Commit() error {
- if err := d.unpackedDest.Commit(); err != nil {
+func (d *ociArchiveImageDestination) Commit(ctx context.Context) error {
+ if err := d.unpackedDest.Commit(ctx); err != nil {
return errors.Wrapf(err, "error storing image %q", d.ref.image)
}
@@ -124,6 +125,7 @@ func tarDirectory(src, dst string) error {
defer outFile.Close()
// copies the contents of the directory to the tar file
+ // TODO: This can take quite some time, and should ideally be cancellable using a context.Context.
_, err = io.Copy(outFile, input)
return err
diff --git a/vendor/github.com/containers/image/oci/archive/oci_src.go b/vendor/github.com/containers/image/oci/archive/oci_src.go
index 2015db729..f4d82bbe7 100644
--- a/vendor/github.com/containers/image/oci/archive/oci_src.go
+++ b/vendor/github.com/containers/image/oci/archive/oci_src.go
@@ -19,13 +19,13 @@ type ociArchiveImageSource struct {
// newImageSource returns an ImageSource for reading from an existing directory.
// newImageSource untars the file and saves it in a temp directory
-func newImageSource(ctx *types.SystemContext, ref ociArchiveReference) (types.ImageSource, error) {
+func newImageSource(ctx context.Context, sys *types.SystemContext, ref ociArchiveReference) (types.ImageSource, error) {
tempDirRef, err := createUntarTempDir(ref)
if err != nil {
return nil, errors.Wrap(err, "error creating temp directory")
}
- unpackedSrc, err := tempDirRef.ociRefExtracted.NewImageSource(ctx)
+ unpackedSrc, err := tempDirRef.ociRefExtracted.NewImageSource(ctx, sys)
if err != nil {
if err := tempDirRef.deleteTempDir(); err != nil {
return nil, errors.Wrapf(err, "error deleting temp directory", tempDirRef.tempDirectory)
@@ -72,13 +72,13 @@ func (s *ociArchiveImageSource) Close() error {
// It may use a remote (= slow) service.
// If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve (when the primary manifest is a manifest list);
// this never happens if the primary manifest is not a manifest list (e.g. if the source never returns manifest lists).
-func (s *ociArchiveImageSource) GetManifest(instanceDigest *digest.Digest) ([]byte, string, error) {
- return s.unpackedSrc.GetManifest(instanceDigest)
+func (s *ociArchiveImageSource) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error) {
+ return s.unpackedSrc.GetManifest(ctx, instanceDigest)
}
// GetBlob returns a stream for the specified blob, and the blob's size.
-func (s *ociArchiveImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
- return s.unpackedSrc.GetBlob(info)
+func (s *ociArchiveImageSource) GetBlob(ctx context.Context, info types.BlobInfo) (io.ReadCloser, int64, error) {
+ return s.unpackedSrc.GetBlob(ctx, info)
}
// GetSignatures returns the image's signatures. It may use a remote (= slow) service.
@@ -90,6 +90,6 @@ func (s *ociArchiveImageSource) GetSignatures(ctx context.Context, instanceDiges
}
// LayerInfosForCopy() returns updated layer info that should be used when reading, in preference to values in the manifest, if specified.
-func (s *ociArchiveImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (s *ociArchiveImageSource) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
return nil, nil
}
diff --git a/vendor/github.com/containers/image/oci/archive/oci_transport.go b/vendor/github.com/containers/image/oci/archive/oci_transport.go
index c4a4fa716..7c1d26ba8 100644
--- a/vendor/github.com/containers/image/oci/archive/oci_transport.go
+++ b/vendor/github.com/containers/image/oci/archive/oci_transport.go
@@ -1,6 +1,7 @@
package archive
import (
+ "context"
"fmt"
"io/ioutil"
"os"
@@ -121,28 +122,28 @@ func (ref ociArchiveReference) PolicyConfigurationNamespaces() []string {
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
-func (ref ociArchiveReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
- src, err := newImageSource(ctx, ref)
+func (ref ociArchiveReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
+ src, err := newImageSource(ctx, sys, ref)
if err != nil {
return nil, err
}
- return image.FromSource(ctx, src)
+ return image.FromSource(ctx, sys, src)
}
// NewImageSource returns a types.ImageSource for this reference.
// The caller must call .Close() on the returned ImageSource.
-func (ref ociArchiveReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
- return newImageSource(ctx, ref)
+func (ref ociArchiveReference) NewImageSource(ctx context.Context, sys *types.SystemContext) (types.ImageSource, error) {
+ return newImageSource(ctx, sys, ref)
}
// NewImageDestination returns a types.ImageDestination for this reference.
// The caller must call .Close() on the returned ImageDestination.
-func (ref ociArchiveReference) NewImageDestination(ctx *types.SystemContext) (types.ImageDestination, error) {
- return newImageDestination(ctx, ref)
+func (ref ociArchiveReference) NewImageDestination(ctx context.Context, sys *types.SystemContext) (types.ImageDestination, error) {
+ return newImageDestination(ctx, sys, ref)
}
// DeleteImage deletes the named image from the registry, if supported.
-func (ref ociArchiveReference) DeleteImage(ctx *types.SystemContext) error {
+func (ref ociArchiveReference) DeleteImage(ctx context.Context, sys *types.SystemContext) error {
return errors.Errorf("Deleting images not implemented for oci: images")
}
@@ -180,6 +181,7 @@ func createUntarTempDir(ref ociArchiveReference) (tempDirOCIRef, error) {
}
src := ref.resolvedFile
dst := tempDirRef.tempDirectory
+ // TODO: This can take quite some time, and should ideally be cancellable using a context.Context.
if err := archive.UntarPath(src, dst); err != nil {
if err := tempDirRef.deleteTempDir(); err != nil {
return tempDirOCIRef{}, errors.Wrapf(err, "error deleting temp directory %q", tempDirRef.tempDirectory)
diff --git a/vendor/github.com/containers/image/oci/layout/oci_dest.go b/vendor/github.com/containers/image/oci/layout/oci_dest.go
index ef72b96d4..e0761c693 100644
--- a/vendor/github.com/containers/image/oci/layout/oci_dest.go
+++ b/vendor/github.com/containers/image/oci/layout/oci_dest.go
@@ -1,6 +1,7 @@
package layout
import (
+ "context"
"encoding/json"
"io"
"io/ioutil"
@@ -8,13 +9,12 @@ import (
"path/filepath"
"runtime"
- "github.com/pkg/errors"
-
"github.com/containers/image/manifest"
"github.com/containers/image/types"
- "github.com/opencontainers/go-digest"
+ digest "github.com/opencontainers/go-digest"
imgspec "github.com/opencontainers/image-spec/specs-go"
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
+ "github.com/pkg/errors"
)
type ociImageDestination struct {
@@ -24,9 +24,9 @@ type ociImageDestination struct {
}
// newImageDestination returns an ImageDestination for writing to an existing directory.
-func newImageDestination(ctx *types.SystemContext, ref ociReference) (types.ImageDestination, error) {
+func newImageDestination(sys *types.SystemContext, ref ociReference) (types.ImageDestination, error) {
if ref.image == "" {
- return nil, errors.Errorf("cannot save image with empty image.ref.name")
+ return nil, errors.Errorf("cannot save image with empty reference name (syntax must be of form <transport>:<path>:<reference>)")
}
var index *imgspecv1.Index
@@ -45,8 +45,8 @@ func newImageDestination(ctx *types.SystemContext, ref ociReference) (types.Imag
}
d := &ociImageDestination{ref: ref, index: *index}
- if ctx != nil {
- d.sharedBlobDir = ctx.OCISharedBlobDirPath
+ if sys != nil {
+ d.sharedBlobDir = sys.OCISharedBlobDirPath
}
if err := ensureDirectoryExists(d.ref.dir); err != nil {
@@ -80,7 +80,7 @@ func (d *ociImageDestination) SupportedManifestMIMETypes() []string {
// SupportsSignatures returns an error (to be displayed to the user) if the destination certainly can't store signatures.
// Note: It is still possible for PutSignatures to fail if SupportsSignatures returns nil.
-func (d *ociImageDestination) SupportsSignatures() error {
+func (d *ociImageDestination) SupportsSignatures(ctx context.Context) error {
return errors.Errorf("Pushing signatures for OCI images is not supported")
}
@@ -105,7 +105,7 @@ func (d *ociImageDestination) MustMatchRuntimeOS() bool {
// WARNING: The contents of stream are being verified on the fly. Until stream.Read() returns io.EOF, the contents of the data SHOULD NOT be available
// to any other readers for download using the supplied digest.
// If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far.
-func (d *ociImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
+func (d *ociImageDestination) PutBlob(ctx context.Context, stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
blobFile, err := ioutil.TempFile(d.ref.dir, "oci-put-blob")
if err != nil {
return types.BlobInfo{}, err
@@ -124,6 +124,7 @@ func (d *ociImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobInfo
digester := digest.Canonical.Digester()
tee := io.TeeReader(stream, digester.Hash())
+ // TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().
size, err := io.Copy(blobFile, tee)
if err != nil {
return types.BlobInfo{}, err
@@ -168,7 +169,7 @@ func (d *ociImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobInfo
// Unlike PutBlob, the digest can not be empty. If HasBlob returns true, the size of the blob must also be returned.
// If the destination does not contain the blob, or it is unknown, HasBlob ordinarily returns (false, -1, nil);
// it returns a non-nil error only on an unexpected failure.
-func (d *ociImageDestination) HasBlob(info types.BlobInfo) (bool, int64, error) {
+func (d *ociImageDestination) HasBlob(ctx context.Context, info types.BlobInfo) (bool, int64, error) {
if info.Digest == "" {
return false, -1, errors.Errorf(`"Can not check for a blob with unknown digest`)
}
@@ -186,7 +187,7 @@ func (d *ociImageDestination) HasBlob(info types.BlobInfo) (bool, int64, error)
return true, finfo.Size(), nil
}
-func (d *ociImageDestination) ReapplyBlob(info types.BlobInfo) (types.BlobInfo, error) {
+func (d *ociImageDestination) ReapplyBlob(ctx context.Context, info types.BlobInfo) (types.BlobInfo, error) {
return info, nil
}
@@ -194,7 +195,7 @@ func (d *ociImageDestination) ReapplyBlob(info types.BlobInfo) (types.BlobInfo,
// FIXME? This should also receive a MIME type if known, to differentiate between schema versions.
// If the destination is in principle available, refuses this manifest type (e.g. it does not recognize the schema),
// but may accept a different manifest type, the returned error must be an ManifestTypeRejectedError.
-func (d *ociImageDestination) PutManifest(m []byte) error {
+func (d *ociImageDestination) PutManifest(ctx context.Context, m []byte) error {
digest, err := manifest.Digest(m)
if err != nil {
return err
@@ -243,7 +244,7 @@ func (d *ociImageDestination) addManifest(desc *imgspecv1.Descriptor) {
d.index.Manifests = append(d.index.Manifests, *desc)
}
-func (d *ociImageDestination) PutSignatures(signatures [][]byte) error {
+func (d *ociImageDestination) PutSignatures(ctx context.Context, signatures [][]byte) error {
if len(signatures) != 0 {
return errors.Errorf("Pushing signatures for OCI images is not supported")
}
@@ -254,7 +255,7 @@ func (d *ociImageDestination) PutSignatures(signatures [][]byte) error {
// WARNING: This does not have any transactional semantics:
// - Uploaded data MAY be visible to others before Commit() is called
// - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed)
-func (d *ociImageDestination) Commit() error {
+func (d *ociImageDestination) Commit(ctx context.Context) error {
if err := ioutil.WriteFile(d.ref.ociLayoutPath(), []byte(`{"imageLayoutVersion": "1.0.0"}`), 0644); err != nil {
return err
}
diff --git a/vendor/github.com/containers/image/oci/layout/oci_src.go b/vendor/github.com/containers/image/oci/layout/oci_src.go
index e708eb161..33115c00d 100644
--- a/vendor/github.com/containers/image/oci/layout/oci_src.go
+++ b/vendor/github.com/containers/image/oci/layout/oci_src.go
@@ -24,15 +24,15 @@ type ociImageSource struct {
}
// newImageSource returns an ImageSource for reading from an existing directory.
-func newImageSource(ctx *types.SystemContext, ref ociReference) (types.ImageSource, error) {
+func newImageSource(sys *types.SystemContext, ref ociReference) (types.ImageSource, error) {
tr := tlsclientconfig.NewTransport()
tr.TLSClientConfig = tlsconfig.ServerDefault()
- if ctx != nil && ctx.OCICertPath != "" {
- if err := tlsclientconfig.SetupCertificates(ctx.OCICertPath, tr.TLSClientConfig); err != nil {
+ if sys != nil && sys.OCICertPath != "" {
+ if err := tlsclientconfig.SetupCertificates(sys.OCICertPath, tr.TLSClientConfig); err != nil {
return nil, err
}
- tr.TLSClientConfig.InsecureSkipVerify = ctx.OCIInsecureSkipTLSVerify
+ tr.TLSClientConfig.InsecureSkipVerify = sys.OCIInsecureSkipTLSVerify
}
client := &http.Client{}
@@ -42,9 +42,9 @@ func newImageSource(ctx *types.SystemContext, ref ociReference) (types.ImageSour
return nil, err
}
d := &ociImageSource{ref: ref, descriptor: descriptor, client: client}
- if ctx != nil {
+ if sys != nil {
// TODO(jonboulle): check dir existence?
- d.sharedBlobDir = ctx.OCISharedBlobDirPath
+ d.sharedBlobDir = sys.OCISharedBlobDirPath
}
return d, nil
}
@@ -63,7 +63,7 @@ func (s *ociImageSource) Close() error {
// It may use a remote (= slow) service.
// If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve (when the primary manifest is a manifest list);
// this never happens if the primary manifest is not a manifest list (e.g. if the source never returns manifest lists).
-func (s *ociImageSource) GetManifest(instanceDigest *digest.Digest) ([]byte, string, error) {
+func (s *ociImageSource) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error) {
var dig digest.Digest
var mimeType string
if instanceDigest == nil {
@@ -93,9 +93,9 @@ func (s *ociImageSource) GetManifest(instanceDigest *digest.Digest) ([]byte, str
}
// GetBlob returns a stream for the specified blob, and the blob's size.
-func (s *ociImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
+func (s *ociImageSource) GetBlob(ctx context.Context, info types.BlobInfo) (io.ReadCloser, int64, error) {
if len(info.URLs) != 0 {
- return s.getExternalBlob(info.URLs)
+ return s.getExternalBlob(ctx, info.URLs)
}
path, err := s.ref.blobPath(info.Digest, s.sharedBlobDir)
@@ -122,10 +122,17 @@ func (s *ociImageSource) GetSignatures(ctx context.Context, instanceDigest *dige
return [][]byte{}, nil
}
-func (s *ociImageSource) getExternalBlob(urls []string) (io.ReadCloser, int64, error) {
+func (s *ociImageSource) getExternalBlob(ctx context.Context, urls []string) (io.ReadCloser, int64, error) {
errWrap := errors.New("failed fetching external blob from all urls")
for _, url := range urls {
- resp, err := s.client.Get(url)
+
+ req, err := http.NewRequest("GET", url, nil)
+ if err != nil {
+ errWrap = errors.Wrapf(errWrap, "fetching %s failed %s", url, err.Error())
+ continue
+ }
+
+ resp, err := s.client.Do(req.WithContext(ctx))
if err != nil {
errWrap = errors.Wrapf(errWrap, "fetching %s failed %s", url, err.Error())
continue
@@ -144,7 +151,7 @@ func (s *ociImageSource) getExternalBlob(urls []string) (io.ReadCloser, int64, e
}
// LayerInfosForCopy() returns updated layer info that should be used when reading, in preference to values in the manifest, if specified.
-func (s *ociImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (s *ociImageSource) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
return nil, nil
}
diff --git a/vendor/github.com/containers/image/oci/layout/oci_transport.go b/vendor/github.com/containers/image/oci/layout/oci_transport.go
index c181c4c77..95a9def2c 100644
--- a/vendor/github.com/containers/image/oci/layout/oci_transport.go
+++ b/vendor/github.com/containers/image/oci/layout/oci_transport.go
@@ -1,6 +1,7 @@
package layout
import (
+ "context"
"encoding/json"
"fmt"
"os"
@@ -144,12 +145,12 @@ func (ref ociReference) PolicyConfigurationNamespaces() []string {
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
-func (ref ociReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
- src, err := newImageSource(ctx, ref)
+func (ref ociReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
+ src, err := newImageSource(sys, ref)
if err != nil {
return nil, err
}
- return image.FromSource(ctx, src)
+ return image.FromSource(ctx, sys, src)
}
// getIndex returns a pointer to the index references by this ociReference. If an error occurs opening an index nil is returned together
@@ -217,18 +218,18 @@ func LoadManifestDescriptor(imgRef types.ImageReference) (imgspecv1.Descriptor,
// NewImageSource returns a types.ImageSource for this reference.
// The caller must call .Close() on the returned ImageSource.
-func (ref ociReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
- return newImageSource(ctx, ref)
+func (ref ociReference) NewImageSource(ctx context.Context, sys *types.SystemContext) (types.ImageSource, error) {
+ return newImageSource(sys, ref)
}
// NewImageDestination returns a types.ImageDestination for this reference.
// The caller must call .Close() on the returned ImageDestination.
-func (ref ociReference) NewImageDestination(ctx *types.SystemContext) (types.ImageDestination, error) {
- return newImageDestination(ctx, ref)
+func (ref ociReference) NewImageDestination(ctx context.Context, sys *types.SystemContext) (types.ImageDestination, error) {
+ return newImageDestination(sys, ref)
}
// DeleteImage deletes the named image from the registry, if supported.
-func (ref ociReference) DeleteImage(ctx *types.SystemContext) error {
+func (ref ociReference) DeleteImage(ctx context.Context, sys *types.SystemContext) error {
return errors.Errorf("Deleting images not implemented for oci: images")
}
diff --git a/vendor/github.com/containers/image/openshift/openshift.go b/vendor/github.com/containers/image/openshift/openshift.go
index 75d67abe9..3504d8ce1 100644
--- a/vendor/github.com/containers/image/openshift/openshift.go
+++ b/vendor/github.com/containers/image/openshift/openshift.go
@@ -162,7 +162,7 @@ func (c *openshiftClient) convertDockerImageReference(ref string) (string, error
type openshiftImageSource struct {
client *openshiftClient
// Values specific to this image
- ctx *types.SystemContext
+ sys *types.SystemContext
// State
docker types.ImageSource // The Docker Registry endpoint, or nil if not resolved yet
imageStreamImageName string // Resolved image identifier, or "" if not known yet
@@ -170,7 +170,7 @@ type openshiftImageSource struct {
// newImageSource creates a new ImageSource for the specified reference.
// The caller must call .Close() on the returned ImageSource.
-func newImageSource(ctx *types.SystemContext, ref openshiftReference) (types.ImageSource, error) {
+func newImageSource(sys *types.SystemContext, ref openshiftReference) (types.ImageSource, error) {
client, err := newOpenshiftClient(ref)
if err != nil {
return nil, err
@@ -178,7 +178,7 @@ func newImageSource(ctx *types.SystemContext, ref openshiftReference) (types.Ima
return &openshiftImageSource{
client: client,
- ctx: ctx,
+ sys: sys,
}, nil
}
@@ -204,19 +204,19 @@ func (s *openshiftImageSource) Close() error {
// It may use a remote (= slow) service.
// If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve (when the primary manifest is a manifest list);
// this never happens if the primary manifest is not a manifest list (e.g. if the source never returns manifest lists).
-func (s *openshiftImageSource) GetManifest(instanceDigest *digest.Digest) ([]byte, string, error) {
- if err := s.ensureImageIsResolved(context.TODO()); err != nil {
+func (s *openshiftImageSource) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error) {
+ if err := s.ensureImageIsResolved(ctx); err != nil {
return nil, "", err
}
- return s.docker.GetManifest(instanceDigest)
+ return s.docker.GetManifest(ctx, instanceDigest)
}
// GetBlob returns a stream for the specified blob, and the blob’s size (or -1 if unknown).
-func (s *openshiftImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
- if err := s.ensureImageIsResolved(context.TODO()); err != nil {
+func (s *openshiftImageSource) GetBlob(ctx context.Context, info types.BlobInfo) (io.ReadCloser, int64, error) {
+ if err := s.ensureImageIsResolved(ctx); err != nil {
return nil, 0, err
}
- return s.docker.GetBlob(info)
+ return s.docker.GetBlob(ctx, info)
}
// GetSignatures returns the image's signatures. It may use a remote (= slow) service.
@@ -247,7 +247,7 @@ func (s *openshiftImageSource) GetSignatures(ctx context.Context, instanceDigest
}
// LayerInfosForCopy() returns updated layer info that should be used when reading, in preference to values in the manifest, if specified.
-func (s *openshiftImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (s *openshiftImageSource) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
return nil, nil
}
@@ -291,7 +291,7 @@ func (s *openshiftImageSource) ensureImageIsResolved(ctx context.Context) error
if err != nil {
return err
}
- d, err := dockerRef.NewImageSource(s.ctx)
+ d, err := dockerRef.NewImageSource(ctx, s.sys)
if err != nil {
return err
}
@@ -308,7 +308,7 @@ type openshiftImageDestination struct {
}
// newImageDestination creates a new ImageDestination for the specified reference.
-func newImageDestination(ctx *types.SystemContext, ref openshiftReference) (types.ImageDestination, error) {
+func newImageDestination(ctx context.Context, sys *types.SystemContext, ref openshiftReference) (types.ImageDestination, error) {
client, err := newOpenshiftClient(ref)
if err != nil {
return nil, err
@@ -322,7 +322,7 @@ func newImageDestination(ctx *types.SystemContext, ref openshiftReference) (type
if err != nil {
return nil, err
}
- docker, err := dockerRef.NewImageDestination(ctx)
+ docker, err := dockerRef.NewImageDestination(ctx, sys)
if err != nil {
return nil, err
}
@@ -350,7 +350,7 @@ func (d *openshiftImageDestination) SupportedManifestMIMETypes() []string {
// SupportsSignatures returns an error (to be displayed to the user) if the destination certainly can't store signatures.
// Note: It is still possible for PutSignatures to fail if SupportsSignatures returns nil.
-func (d *openshiftImageDestination) SupportsSignatures() error {
+func (d *openshiftImageDestination) SupportsSignatures(ctx context.Context) error {
return nil
}
@@ -375,37 +375,37 @@ func (d *openshiftImageDestination) MustMatchRuntimeOS() bool {
// WARNING: The contents of stream are being verified on the fly. Until stream.Read() returns io.EOF, the contents of the data SHOULD NOT be available
// to any other readers for download using the supplied digest.
// If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far.
-func (d *openshiftImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
- return d.docker.PutBlob(stream, inputInfo, isConfig)
+func (d *openshiftImageDestination) PutBlob(ctx context.Context, stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
+ return d.docker.PutBlob(ctx, stream, inputInfo, isConfig)
}
// HasBlob returns true iff the image destination already contains a blob with the matching digest which can be reapplied using ReapplyBlob.
// Unlike PutBlob, the digest can not be empty. If HasBlob returns true, the size of the blob must also be returned.
// If the destination does not contain the blob, or it is unknown, HasBlob ordinarily returns (false, -1, nil);
// it returns a non-nil error only on an unexpected failure.
-func (d *openshiftImageDestination) HasBlob(info types.BlobInfo) (bool, int64, error) {
- return d.docker.HasBlob(info)
+func (d *openshiftImageDestination) HasBlob(ctx context.Context, info types.BlobInfo) (bool, int64, error) {
+ return d.docker.HasBlob(ctx, info)
}
-func (d *openshiftImageDestination) ReapplyBlob(info types.BlobInfo) (types.BlobInfo, error) {
- return d.docker.ReapplyBlob(info)
+func (d *openshiftImageDestination) ReapplyBlob(ctx context.Context, info types.BlobInfo) (types.BlobInfo, error) {
+ return d.docker.ReapplyBlob(ctx, info)
}
// PutManifest writes manifest to the destination.
// FIXME? This should also receive a MIME type if known, to differentiate between schema versions.
// If the destination is in principle available, refuses this manifest type (e.g. it does not recognize the schema),
// but may accept a different manifest type, the returned error must be an ManifestTypeRejectedError.
-func (d *openshiftImageDestination) PutManifest(m []byte) error {
+func (d *openshiftImageDestination) PutManifest(ctx context.Context, m []byte) error {
manifestDigest, err := manifest.Digest(m)
if err != nil {
return err
}
d.imageStreamImageName = manifestDigest.String()
- return d.docker.PutManifest(m)
+ return d.docker.PutManifest(ctx, m)
}
-func (d *openshiftImageDestination) PutSignatures(signatures [][]byte) error {
+func (d *openshiftImageDestination) PutSignatures(ctx context.Context, signatures [][]byte) error {
if d.imageStreamImageName == "" {
return errors.Errorf("Internal error: Unknown manifest digest, can't add signatures")
}
@@ -416,7 +416,7 @@ func (d *openshiftImageDestination) PutSignatures(signatures [][]byte) error {
return nil // No need to even read the old state.
}
- image, err := d.client.getImage(context.TODO(), d.imageStreamImageName)
+ image, err := d.client.getImage(ctx, d.imageStreamImageName)
if err != nil {
return err
}
@@ -457,7 +457,7 @@ sigExists:
Content: newSig,
}
body, err := json.Marshal(sig)
- _, err = d.client.doRequest(context.TODO(), "POST", "/oapi/v1/imagesignatures", body)
+ _, err = d.client.doRequest(ctx, "POST", "/oapi/v1/imagesignatures", body)
if err != nil {
return err
}
@@ -470,8 +470,8 @@ sigExists:
// WARNING: This does not have any transactional semantics:
// - Uploaded data MAY be visible to others before Commit() is called
// - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed)
-func (d *openshiftImageDestination) Commit() error {
- return d.docker.Commit()
+func (d *openshiftImageDestination) Commit(ctx context.Context) error {
+ return d.docker.Commit(ctx)
}
// These structs are subsets of github.com/openshift/origin/pkg/image/api/v1 and its dependencies.
diff --git a/vendor/github.com/containers/image/openshift/openshift_transport.go b/vendor/github.com/containers/image/openshift/openshift_transport.go
index 686d806f7..b27867a0d 100644
--- a/vendor/github.com/containers/image/openshift/openshift_transport.go
+++ b/vendor/github.com/containers/image/openshift/openshift_transport.go
@@ -1,6 +1,7 @@
package openshift
import (
+ "context"
"fmt"
"regexp"
"strings"
@@ -130,27 +131,27 @@ func (ref openshiftReference) PolicyConfigurationNamespaces() []string {
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
-func (ref openshiftReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
- src, err := newImageSource(ctx, ref)
+func (ref openshiftReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
+ src, err := newImageSource(sys, ref)
if err != nil {
return nil, err
}
- return genericImage.FromSource(ctx, src)
+ return genericImage.FromSource(ctx, sys, src)
}
// NewImageSource returns a types.ImageSource for this reference.
// The caller must call .Close() on the returned ImageSource.
-func (ref openshiftReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
- return newImageSource(ctx, ref)
+func (ref openshiftReference) NewImageSource(ctx context.Context, sys *types.SystemContext) (types.ImageSource, error) {
+ return newImageSource(sys, ref)
}
// NewImageDestination returns a types.ImageDestination for this reference.
// The caller must call .Close() on the returned ImageDestination.
-func (ref openshiftReference) NewImageDestination(ctx *types.SystemContext) (types.ImageDestination, error) {
- return newImageDestination(ctx, ref)
+func (ref openshiftReference) NewImageDestination(ctx context.Context, sys *types.SystemContext) (types.ImageDestination, error) {
+ return newImageDestination(ctx, sys, ref)
}
// DeleteImage deletes the named image from the registry, if supported.
-func (ref openshiftReference) DeleteImage(ctx *types.SystemContext) error {
+func (ref openshiftReference) DeleteImage(ctx context.Context, sys *types.SystemContext) error {
return errors.Errorf("Deleting images not implemented for atomic: images")
}
diff --git a/vendor/github.com/containers/image/ostree/ostree_dest.go b/vendor/github.com/containers/image/ostree/ostree_dest.go
index 63e4c8228..2e0d7fcff 100644
--- a/vendor/github.com/containers/image/ostree/ostree_dest.go
+++ b/vendor/github.com/containers/image/ostree/ostree_dest.go
@@ -5,6 +5,7 @@ package ostree
import (
"bytes"
"compress/gzip"
+ "context"
"encoding/base64"
"encoding/json"
"fmt"
@@ -103,7 +104,7 @@ func (d *ostreeImageDestination) SupportedManifestMIMETypes() []string {
// SupportsSignatures returns an error (to be displayed to the user) if the destination certainly can't store signatures.
// Note: It is still possible for PutSignatures to fail if SupportsSignatures returns nil.
-func (d *ostreeImageDestination) SupportsSignatures() error {
+func (d *ostreeImageDestination) SupportsSignatures(ctx context.Context) error {
return nil
}
@@ -123,7 +124,7 @@ func (d *ostreeImageDestination) MustMatchRuntimeOS() bool {
return true
}
-func (d *ostreeImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
+func (d *ostreeImageDestination) PutBlob(ctx context.Context, stream io.Reader, inputInfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
tmpDir, err := ioutil.TempDir(d.tmpDirPath, "blob")
if err != nil {
return types.BlobInfo{}, err
@@ -139,6 +140,7 @@ func (d *ostreeImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobI
digester := digest.Canonical.Digester()
tee := io.TeeReader(stream, digester.Hash())
+ // TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().
size, err := io.Copy(blobFile, tee)
if err != nil {
return types.BlobInfo{}, err
@@ -263,6 +265,8 @@ func generateTarSplitMetadata(output *bytes.Buffer, file string) (digest.Digest,
}
func (d *ostreeImageDestination) importBlob(selinuxHnd *C.struct_selabel_handle, repo *otbuiltin.Repo, blob *blobToImport) error {
+ // TODO: This can take quite some time, and should ideally be cancellable using a context.Context.
+
ostreeBranch := fmt.Sprintf("ociimage/%s", blob.Digest.Hex())
destinationPath := filepath.Join(d.tmpDirPath, blob.Digest.Hex(), "root")
if err := ensureDirectoryExists(destinationPath); err != nil {
@@ -310,7 +314,7 @@ func (d *ostreeImageDestination) importConfig(repo *otbuiltin.Repo, blob *blobTo
return d.ostreeCommit(repo, ostreeBranch, destinationPath, []string{fmt.Sprintf("docker.size=%d", blob.Size)})
}
-func (d *ostreeImageDestination) HasBlob(info types.BlobInfo) (bool, int64, error) {
+func (d *ostreeImageDestination) HasBlob(ctx context.Context, info types.BlobInfo) (bool, int64, error) {
if d.repo == nil {
repo, err := openRepo(d.ref.repo)
@@ -344,7 +348,7 @@ func (d *ostreeImageDestination) HasBlob(info types.BlobInfo) (bool, int64, erro
return true, size, nil
}
-func (d *ostreeImageDestination) ReapplyBlob(info types.BlobInfo) (types.BlobInfo, error) {
+func (d *ostreeImageDestination) ReapplyBlob(ctx context.Context, info types.BlobInfo) (types.BlobInfo, error) {
return info, nil
}
@@ -352,7 +356,7 @@ func (d *ostreeImageDestination) ReapplyBlob(info types.BlobInfo) (types.BlobInf
// FIXME? This should also receive a MIME type if known, to differentiate between schema versions.
// If the destination is in principle available, refuses this manifest type (e.g. it does not recognize the schema),
// but may accept a different manifest type, the returned error must be an ManifestTypeRejectedError.
-func (d *ostreeImageDestination) PutManifest(manifestBlob []byte) error {
+func (d *ostreeImageDestination) PutManifest(ctx context.Context, manifestBlob []byte) error {
d.manifest = string(manifestBlob)
if err := json.Unmarshal(manifestBlob, &d.schema); err != nil {
@@ -373,7 +377,7 @@ func (d *ostreeImageDestination) PutManifest(manifestBlob []byte) error {
return ioutil.WriteFile(manifestPath, manifestBlob, 0644)
}
-func (d *ostreeImageDestination) PutSignatures(signatures [][]byte) error {
+func (d *ostreeImageDestination) PutSignatures(ctx context.Context, signatures [][]byte) error {
path := filepath.Join(d.tmpDirPath, d.ref.signaturePath(0))
if err := ensureParentDirectoryExists(path); err != nil {
return err
@@ -389,7 +393,7 @@ func (d *ostreeImageDestination) PutSignatures(signatures [][]byte) error {
return nil
}
-func (d *ostreeImageDestination) Commit() error {
+func (d *ostreeImageDestination) Commit(ctx context.Context) error {
repo, err := otbuiltin.OpenRepo(d.ref.repo)
if err != nil {
return err
diff --git a/vendor/github.com/containers/image/ostree/ostree_src.go b/vendor/github.com/containers/image/ostree/ostree_src.go
index d4c70c33f..1f325b2a7 100644
--- a/vendor/github.com/containers/image/ostree/ostree_src.go
+++ b/vendor/github.com/containers/image/ostree/ostree_src.go
@@ -42,7 +42,7 @@ type ostreeImageSource struct {
}
// newImageSource returns an ImageSource for reading from an existing directory.
-func newImageSource(ctx *types.SystemContext, tmpDir string, ref ostreeReference) (types.ImageSource, error) {
+func newImageSource(tmpDir string, ref ostreeReference) (types.ImageSource, error) {
return &ostreeImageSource{ref: ref, tmpDir: tmpDir, compressed: nil}, nil
}
@@ -92,7 +92,7 @@ func (s *ostreeImageSource) getTarSplitData(blob string) ([]byte, error) {
// GetManifest returns the image's manifest along with its MIME type (which may be empty when it can't be determined but the manifest is available).
// It may use a remote (= slow) service.
-func (s *ostreeImageSource) GetManifest(instanceDigest *digest.Digest) ([]byte, string, error) {
+func (s *ostreeImageSource) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error) {
if instanceDigest != nil {
return nil, "", errors.Errorf(`Manifest lists are not supported by "ostree:"`)
}
@@ -256,13 +256,13 @@ func (s *ostreeImageSource) readSingleFile(commit, path string) (io.ReadCloser,
}
// GetBlob returns a stream for the specified blob, and the blob's size.
-func (s *ostreeImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
+func (s *ostreeImageSource) GetBlob(ctx context.Context, info types.BlobInfo) (io.ReadCloser, int64, error) {
blob := info.Digest.Hex()
// Ensure s.compressed is initialized. It is build by LayerInfosForCopy.
if s.compressed == nil {
- _, err := s.LayerInfosForCopy()
+ _, err := s.LayerInfosForCopy(ctx)
if err != nil {
return nil, -1, err
}
@@ -366,9 +366,9 @@ func (s *ostreeImageSource) GetSignatures(ctx context.Context, instanceDigest *d
// LayerInfosForCopy() returns the list of layer blobs that make up the root filesystem of
// the image, after they've been decompressed.
-func (s *ostreeImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (s *ostreeImageSource) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
updatedBlobInfos := []types.BlobInfo{}
- manifestBlob, manifestType, err := s.GetManifest(nil)
+ manifestBlob, manifestType, err := s.GetManifest(ctx, nil)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/containers/image/ostree/ostree_transport.go b/vendor/github.com/containers/image/ostree/ostree_transport.go
index cc85a43ff..c9856530b 100644
--- a/vendor/github.com/containers/image/ostree/ostree_transport.go
+++ b/vendor/github.com/containers/image/ostree/ostree_transport.go
@@ -4,6 +4,7 @@ package ostree
import (
"bytes"
+ "context"
"fmt"
"os"
"path/filepath"
@@ -181,46 +182,46 @@ func (s *ostreeImageCloser) Size() (int64, error) {
// The caller must call .Close() on the returned ImageCloser.
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
-func (ref ostreeReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
+func (ref ostreeReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
var tmpDir string
- if ctx == nil || ctx.OSTreeTmpDirPath == "" {
+ if sys == nil || sys.OSTreeTmpDirPath == "" {
tmpDir = os.TempDir()
} else {
- tmpDir = ctx.OSTreeTmpDirPath
+ tmpDir = sys.OSTreeTmpDirPath
}
- src, err := newImageSource(ctx, tmpDir, ref)
+ src, err := newImageSource(tmpDir, ref)
if err != nil {
return nil, err
}
- return image.FromSource(ctx, src)
+ return image.FromSource(ctx, sys, src)
}
// NewImageSource returns a types.ImageSource for this reference.
// The caller must call .Close() on the returned ImageSource.
-func (ref ostreeReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
+func (ref ostreeReference) NewImageSource(ctx context.Context, sys *types.SystemContext) (types.ImageSource, error) {
var tmpDir string
- if ctx == nil || ctx.OSTreeTmpDirPath == "" {
+ if sys == nil || sys.OSTreeTmpDirPath == "" {
tmpDir = os.TempDir()
} else {
- tmpDir = ctx.OSTreeTmpDirPath
+ tmpDir = sys.OSTreeTmpDirPath
}
- return newImageSource(ctx, tmpDir, ref)
+ return newImageSource(tmpDir, ref)
}
// NewImageDestination returns a types.ImageDestination for this reference.
// The caller must call .Close() on the returned ImageDestination.
-func (ref ostreeReference) NewImageDestination(ctx *types.SystemContext) (types.ImageDestination, error) {
+func (ref ostreeReference) NewImageDestination(ctx context.Context, sys *types.SystemContext) (types.ImageDestination, error) {
var tmpDir string
- if ctx == nil || ctx.OSTreeTmpDirPath == "" {
+ if sys == nil || sys.OSTreeTmpDirPath == "" {
tmpDir = os.TempDir()
} else {
- tmpDir = ctx.OSTreeTmpDirPath
+ tmpDir = sys.OSTreeTmpDirPath
}
return newImageDestination(ref, tmpDir)
}
// DeleteImage deletes the named image from the registry, if supported.
-func (ref ostreeReference) DeleteImage(ctx *types.SystemContext) error {
+func (ref ostreeReference) DeleteImage(ctx context.Context, sys *types.SystemContext) error {
return errors.Errorf("Deleting images not implemented for ostree: images")
}
diff --git a/vendor/github.com/containers/image/pkg/docker/config/config.go b/vendor/github.com/containers/image/pkg/docker/config/config.go
index 817930f41..1238208fb 100644
--- a/vendor/github.com/containers/image/pkg/docker/config/config.go
+++ b/vendor/github.com/containers/image/pkg/docker/config/config.go
@@ -42,8 +42,8 @@ var (
)
// SetAuthentication stores the username and password in the auth.json file
-func SetAuthentication(ctx *types.SystemContext, registry, username, password string) error {
- return modifyJSON(ctx, func(auths *dockerConfigFile) (bool, error) {
+func SetAuthentication(sys *types.SystemContext, registry, username, password string) error {
+ return modifyJSON(sys, func(auths *dockerConfigFile) (bool, error) {
if ch, exists := auths.CredHelpers[registry]; exists {
return false, setAuthToCredHelper(ch, registry, username, password)
}
@@ -58,13 +58,13 @@ func SetAuthentication(ctx *types.SystemContext, registry, username, password st
// GetAuthentication returns the registry credentials stored in
// either auth.json file or .docker/config.json
// If an entry is not found empty strings are returned for the username and password
-func GetAuthentication(ctx *types.SystemContext, registry string) (string, string, error) {
- if ctx != nil && ctx.DockerAuthConfig != nil {
- return ctx.DockerAuthConfig.Username, ctx.DockerAuthConfig.Password, nil
+func GetAuthentication(sys *types.SystemContext, registry string) (string, string, error) {
+ if sys != nil && sys.DockerAuthConfig != nil {
+ return sys.DockerAuthConfig.Username, sys.DockerAuthConfig.Password, nil
}
dockerLegacyPath := filepath.Join(homedir.Get(), dockerLegacyCfg)
- pathToAuth, err := getPathToAuth(ctx)
+ pathToAuth, err := getPathToAuth(sys)
if err != nil {
return "", "", err
}
@@ -86,8 +86,8 @@ func GetAuthentication(ctx *types.SystemContext, registry string) (string, strin
// GetUserLoggedIn returns the username logged in to registry from either
// auth.json or XDG_RUNTIME_DIR
// Used to tell the user if someone is logged in to the registry when logging in
-func GetUserLoggedIn(ctx *types.SystemContext, registry string) (string, error) {
- path, err := getPathToAuth(ctx)
+func GetUserLoggedIn(sys *types.SystemContext, registry string) (string, error) {
+ path, err := getPathToAuth(sys)
if err != nil {
return "", err
}
@@ -99,8 +99,8 @@ func GetUserLoggedIn(ctx *types.SystemContext, registry string) (string, error)
}
// RemoveAuthentication deletes the credentials stored in auth.json
-func RemoveAuthentication(ctx *types.SystemContext, registry string) error {
- return modifyJSON(ctx, func(auths *dockerConfigFile) (bool, error) {
+func RemoveAuthentication(sys *types.SystemContext, registry string) error {
+ return modifyJSON(sys, func(auths *dockerConfigFile) (bool, error) {
// First try cred helpers.
if ch, exists := auths.CredHelpers[registry]; exists {
return false, deleteAuthFromCredHelper(ch, registry)
@@ -118,8 +118,8 @@ func RemoveAuthentication(ctx *types.SystemContext, registry string) error {
}
// RemoveAllAuthentication deletes all the credentials stored in auth.json
-func RemoveAllAuthentication(ctx *types.SystemContext) error {
- return modifyJSON(ctx, func(auths *dockerConfigFile) (bool, error) {
+func RemoveAllAuthentication(sys *types.SystemContext) error {
+ return modifyJSON(sys, func(auths *dockerConfigFile) (bool, error) {
auths.CredHelpers = make(map[string]string)
auths.AuthConfigs = make(map[string]dockerAuthConfig)
return true, nil
@@ -130,13 +130,13 @@ func RemoveAllAuthentication(ctx *types.SystemContext) error {
// The path can be overriden by the user if the overwrite-path flag is set
// If the flag is not set and XDG_RUNTIME_DIR is ser, the auth.json file is saved in XDG_RUNTIME_DIR/containers
// Otherwise, the auth.json file is stored in /run/user/UID/containers
-func getPathToAuth(ctx *types.SystemContext) (string, error) {
- if ctx != nil {
- if ctx.AuthFilePath != "" {
- return ctx.AuthFilePath, nil
+func getPathToAuth(sys *types.SystemContext) (string, error) {
+ if sys != nil {
+ if sys.AuthFilePath != "" {
+ return sys.AuthFilePath, nil
}
- if ctx.RootForImplicitAbsolutePaths != "" {
- return filepath.Join(ctx.RootForImplicitAbsolutePaths, defaultPath, strconv.Itoa(os.Getuid()), authCfg, authCfgFileName), nil
+ if sys.RootForImplicitAbsolutePaths != "" {
+ return filepath.Join(sys.RootForImplicitAbsolutePaths, defaultPath, strconv.Itoa(os.Getuid()), authCfg, authCfgFileName), nil
}
}
@@ -183,8 +183,8 @@ func readJSONFile(path string, legacyFormat bool) (dockerConfigFile, error) {
}
// modifyJSON writes to auth.json if the dockerConfigFile has been updated
-func modifyJSON(ctx *types.SystemContext, editor func(auths *dockerConfigFile) (bool, error)) error {
- path, err := getPathToAuth(ctx)
+func modifyJSON(sys *types.SystemContext, editor func(auths *dockerConfigFile) (bool, error)) error {
+ path, err := getPathToAuth(sys)
if err != nil {
return err
}
diff --git a/vendor/github.com/containers/image/pkg/sysregistries/system_registries.go b/vendor/github.com/containers/image/pkg/sysregistries/system_registries.go
index c56e32ddd..a0aa6c643 100644
--- a/vendor/github.com/containers/image/pkg/sysregistries/system_registries.go
+++ b/vendor/github.com/containers/image/pkg/sysregistries/system_registries.go
@@ -41,13 +41,13 @@ func normalizeRegistries(regs *registries) {
// Reads the global registry file from the filesystem. Returns
// a byte array
-func readRegistryConf(ctx *types.SystemContext) ([]byte, error) {
+func readRegistryConf(sys *types.SystemContext) ([]byte, error) {
dirPath := systemRegistriesConfPath
- if ctx != nil {
- if ctx.SystemRegistriesConfPath != "" {
- dirPath = ctx.SystemRegistriesConfPath
- } else if ctx.RootForImplicitAbsolutePaths != "" {
- dirPath = filepath.Join(ctx.RootForImplicitAbsolutePaths, systemRegistriesConfPath)
+ if sys != nil {
+ if sys.SystemRegistriesConfPath != "" {
+ dirPath = sys.SystemRegistriesConfPath
+ } else if sys.RootForImplicitAbsolutePaths != "" {
+ dirPath = filepath.Join(sys.RootForImplicitAbsolutePaths, systemRegistriesConfPath)
}
}
configBytes, err := ioutil.ReadFile(dirPath)
@@ -59,10 +59,10 @@ var readConf = readRegistryConf
// Loads the registry configuration file from the filesystem and
// then unmarshals it. Returns the unmarshalled object.
-func loadRegistryConf(ctx *types.SystemContext) (*tomlConfig, error) {
+func loadRegistryConf(sys *types.SystemContext) (*tomlConfig, error) {
config := &tomlConfig{}
- configBytes, err := readConf(ctx)
+ configBytes, err := readConf(sys)
if err != nil {
return nil, err
}
@@ -78,8 +78,8 @@ func loadRegistryConf(ctx *types.SystemContext) (*tomlConfig, error) {
// of the registries as defined in the system-wide
// registries file. it returns an empty array if none are
// defined
-func GetRegistries(ctx *types.SystemContext) ([]string, error) {
- config, err := loadRegistryConf(ctx)
+func GetRegistries(sys *types.SystemContext) ([]string, error) {
+ config, err := loadRegistryConf(sys)
if err != nil {
return nil, err
}
@@ -90,8 +90,8 @@ func GetRegistries(ctx *types.SystemContext) ([]string, error) {
// of the insecure registries as defined in the system-wide
// registries file. it returns an empty array if none are
// defined
-func GetInsecureRegistries(ctx *types.SystemContext) ([]string, error) {
- config, err := loadRegistryConf(ctx)
+func GetInsecureRegistries(sys *types.SystemContext) ([]string, error) {
+ config, err := loadRegistryConf(sys)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/containers/image/signature/policy_config.go b/vendor/github.com/containers/image/signature/policy_config.go
index 42cc12ab1..39c0f2a55 100644
--- a/vendor/github.com/containers/image/signature/policy_config.go
+++ b/vendor/github.com/containers/image/signature/policy_config.go
@@ -44,21 +44,21 @@ func (err InvalidPolicyFormatError) Error() string {
// DefaultPolicy returns the default policy of the system.
// Most applications should be using this method to get the policy configured
// by the system administrator.
-// ctx should usually be nil, can be set to override the default.
+// sys should usually be nil, can be set to override the default.
// NOTE: When this function returns an error, report it to the user and abort.
// DO NOT hard-code fallback policies in your application.
-func DefaultPolicy(ctx *types.SystemContext) (*Policy, error) {
- return NewPolicyFromFile(defaultPolicyPath(ctx))
+func DefaultPolicy(sys *types.SystemContext) (*Policy, error) {
+ return NewPolicyFromFile(defaultPolicyPath(sys))
}
// defaultPolicyPath returns a path to the default policy of the system.
-func defaultPolicyPath(ctx *types.SystemContext) string {
- if ctx != nil {
- if ctx.SignaturePolicyPath != "" {
- return ctx.SignaturePolicyPath
+func defaultPolicyPath(sys *types.SystemContext) string {
+ if sys != nil {
+ if sys.SignaturePolicyPath != "" {
+ return sys.SignaturePolicyPath
}
- if ctx.RootForImplicitAbsolutePaths != "" {
- return filepath.Join(ctx.RootForImplicitAbsolutePaths, systemDefaultPolicyPath)
+ if sys.RootForImplicitAbsolutePaths != "" {
+ return filepath.Join(sys.RootForImplicitAbsolutePaths, systemDefaultPolicyPath)
}
}
return systemDefaultPolicyPath
diff --git a/vendor/github.com/containers/image/signature/policy_eval.go b/vendor/github.com/containers/image/signature/policy_eval.go
index f818eb095..b66ece41c 100644
--- a/vendor/github.com/containers/image/signature/policy_eval.go
+++ b/vendor/github.com/containers/image/signature/policy_eval.go
@@ -55,14 +55,14 @@ type PolicyRequirement interface {
// a container based on this image; use IsRunningImageAllowed instead.
// - Just because a signature is accepted does not automatically mean the contents of the
// signature are authorized to run code as root, or to affect system or cluster configuration.
- isSignatureAuthorAccepted(image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error)
+ isSignatureAuthorAccepted(ctx context.Context, image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error)
// isRunningImageAllowed returns true if the requirement allows running an image.
// If it returns false, err must be non-nil, and should be an PolicyRequirementError if evaluation
// succeeded but the result was rejection.
// WARNING: This validates signatures and the manifest, but does not download or validate the
// layers. Users must validate that the layers match their expected digests.
- isRunningImageAllowed(image types.UnparsedImage) (bool, error)
+ isRunningImageAllowed(ctx context.Context, image types.UnparsedImage) (bool, error)
}
// PolicyReferenceMatch specifies a set of image identities accepted in PolicyRequirement.
@@ -175,7 +175,7 @@ func (pc *PolicyContext) requirementsForImageRef(ref types.ImageReference) Polic
// a container based on this image; use IsRunningImageAllowed instead.
// - Just because a signature is accepted does not automatically mean the contents of the
// signature are authorized to run code as root, or to affect system or cluster configuration.
-func (pc *PolicyContext) GetSignaturesWithAcceptedAuthor(image types.UnparsedImage) (sigs []*Signature, finalErr error) {
+func (pc *PolicyContext) GetSignaturesWithAcceptedAuthor(ctx context.Context, image types.UnparsedImage) (sigs []*Signature, finalErr error) {
if err := pc.changeState(pcReady, pcInUse); err != nil {
return nil, err
}
@@ -191,7 +191,7 @@ func (pc *PolicyContext) GetSignaturesWithAcceptedAuthor(image types.UnparsedIma
// FIXME: rename Signatures to UnverifiedSignatures
// FIXME: pass context.Context
- unverifiedSignatures, err := image.Signatures(context.TODO())
+ unverifiedSignatures, err := image.Signatures(ctx)
if err != nil {
return nil, err
}
@@ -206,7 +206,7 @@ func (pc *PolicyContext) GetSignaturesWithAcceptedAuthor(image types.UnparsedIma
for reqNumber, req := range reqs {
// FIXME: Log the requirement itself? For now, we use just the number.
// FIXME: supply state
- switch res, as, err := req.isSignatureAuthorAccepted(image, sig); res {
+ switch res, as, err := req.isSignatureAuthorAccepted(ctx, image, sig); res {
case sarAccepted:
if as == nil { // Coverage: this should never happen
logrus.Debugf(" Requirement %d: internal inconsistency: sarAccepted but no parsed contents", reqNumber)
@@ -256,7 +256,7 @@ func (pc *PolicyContext) GetSignaturesWithAcceptedAuthor(image types.UnparsedIma
// succeeded but the result was rejection.
// WARNING: This validates signatures and the manifest, but does not download or validate the
// layers. Users must validate that the layers match their expected digests.
-func (pc *PolicyContext) IsRunningImageAllowed(image types.UnparsedImage) (res bool, finalErr error) {
+func (pc *PolicyContext) IsRunningImageAllowed(ctx context.Context, image types.UnparsedImage) (res bool, finalErr error) {
if err := pc.changeState(pcReady, pcInUse); err != nil {
return false, err
}
@@ -276,7 +276,7 @@ func (pc *PolicyContext) IsRunningImageAllowed(image types.UnparsedImage) (res b
for reqNumber, req := range reqs {
// FIXME: supply state
- allowed, err := req.isRunningImageAllowed(image)
+ allowed, err := req.isRunningImageAllowed(ctx, image)
if !allowed {
logrus.Debugf("Requirement %d: denied, done", reqNumber)
return false, err
diff --git a/vendor/github.com/containers/image/signature/policy_eval_baselayer.go b/vendor/github.com/containers/image/signature/policy_eval_baselayer.go
index 898958012..54c6dc124 100644
--- a/vendor/github.com/containers/image/signature/policy_eval_baselayer.go
+++ b/vendor/github.com/containers/image/signature/policy_eval_baselayer.go
@@ -3,15 +3,17 @@
package signature
import (
+ "context"
+
"github.com/containers/image/types"
"github.com/sirupsen/logrus"
)
-func (pr *prSignedBaseLayer) isSignatureAuthorAccepted(image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error) {
+func (pr *prSignedBaseLayer) isSignatureAuthorAccepted(ctx context.Context, image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error) {
return sarUnknown, nil, nil
}
-func (pr *prSignedBaseLayer) isRunningImageAllowed(image types.UnparsedImage) (bool, error) {
+func (pr *prSignedBaseLayer) isRunningImageAllowed(ctx context.Context, image types.UnparsedImage) (bool, error) {
// FIXME? Reject this at policy parsing time already?
logrus.Errorf("signedBaseLayer not implemented yet!")
return false, PolicyRequirementError("signedBaseLayer not implemented yet!")
diff --git a/vendor/github.com/containers/image/signature/policy_eval_signedby.go b/vendor/github.com/containers/image/signature/policy_eval_signedby.go
index 56665124c..d59ffa18b 100644
--- a/vendor/github.com/containers/image/signature/policy_eval_signedby.go
+++ b/vendor/github.com/containers/image/signature/policy_eval_signedby.go
@@ -15,7 +15,7 @@ import (
"github.com/opencontainers/go-digest"
)
-func (pr *prSignedBy) isSignatureAuthorAccepted(image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error) {
+func (pr *prSignedBy) isSignatureAuthorAccepted(ctx context.Context, image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error) {
switch pr.KeyType {
case SBKeyTypeGPGKeys:
case SBKeyTypeSignedByGPGKeys, SBKeyTypeX509Certificates, SBKeyTypeSignedByX509CAs:
@@ -69,7 +69,7 @@ func (pr *prSignedBy) isSignatureAuthorAccepted(image types.UnparsedImage, sig [
return nil
},
validateSignedDockerManifestDigest: func(digest digest.Digest) error {
- m, _, err := image.Manifest()
+ m, _, err := image.Manifest(ctx)
if err != nil {
return err
}
@@ -90,16 +90,16 @@ func (pr *prSignedBy) isSignatureAuthorAccepted(image types.UnparsedImage, sig [
return sarAccepted, signature, nil
}
-func (pr *prSignedBy) isRunningImageAllowed(image types.UnparsedImage) (bool, error) {
+func (pr *prSignedBy) isRunningImageAllowed(ctx context.Context, image types.UnparsedImage) (bool, error) {
// FIXME: pass context.Context
- sigs, err := image.Signatures(context.TODO())
+ sigs, err := image.Signatures(ctx)
if err != nil {
return false, err
}
var rejections []error
for _, s := range sigs {
var reason error
- switch res, _, err := pr.isSignatureAuthorAccepted(image, s); res {
+ switch res, _, err := pr.isSignatureAuthorAccepted(ctx, image, s); res {
case sarAccepted:
// One accepted signature is enough.
return true, nil
diff --git a/vendor/github.com/containers/image/signature/policy_eval_simple.go b/vendor/github.com/containers/image/signature/policy_eval_simple.go
index 19a71e6d9..b0f2fff20 100644
--- a/vendor/github.com/containers/image/signature/policy_eval_simple.go
+++ b/vendor/github.com/containers/image/signature/policy_eval_simple.go
@@ -3,26 +3,27 @@
package signature
import (
+ "context"
"fmt"
"github.com/containers/image/transports"
"github.com/containers/image/types"
)
-func (pr *prInsecureAcceptAnything) isSignatureAuthorAccepted(image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error) {
+func (pr *prInsecureAcceptAnything) isSignatureAuthorAccepted(ctx context.Context, image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error) {
// prInsecureAcceptAnything semantics: Every image is allowed to run,
// but this does not consider the signature as verified.
return sarUnknown, nil, nil
}
-func (pr *prInsecureAcceptAnything) isRunningImageAllowed(image types.UnparsedImage) (bool, error) {
+func (pr *prInsecureAcceptAnything) isRunningImageAllowed(ctx context.Context, image types.UnparsedImage) (bool, error) {
return true, nil
}
-func (pr *prReject) isSignatureAuthorAccepted(image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error) {
+func (pr *prReject) isSignatureAuthorAccepted(ctx context.Context, image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error) {
return sarRejected, nil, PolicyRequirementError(fmt.Sprintf("Any signatures for image %s are rejected by policy.", transports.ImageName(image.Reference())))
}
-func (pr *prReject) isRunningImageAllowed(image types.UnparsedImage) (bool, error) {
+func (pr *prReject) isRunningImageAllowed(ctx context.Context, image types.UnparsedImage) (bool, error) {
return false, PolicyRequirementError(fmt.Sprintf("Running image %s is rejected by policy.", transports.ImageName(image.Reference())))
}
diff --git a/vendor/github.com/containers/image/storage/storage_image.go b/vendor/github.com/containers/image/storage/storage_image.go
index 0823b7ed9..e6e759456 100644
--- a/vendor/github.com/containers/image/storage/storage_image.go
+++ b/vendor/github.com/containers/image/storage/storage_image.go
@@ -102,7 +102,7 @@ func (s storageImageSource) Close() error {
}
// GetBlob reads the data blob or filesystem layer which matches the digest and size, if given.
-func (s *storageImageSource) GetBlob(info types.BlobInfo) (rc io.ReadCloser, n int64, err error) {
+func (s *storageImageSource) GetBlob(ctx context.Context, info types.BlobInfo) (rc io.ReadCloser, n int64, err error) {
rc, n, _, err = s.getBlobAndLayerID(info)
return rc, n, err
}
@@ -158,7 +158,7 @@ func (s *storageImageSource) getBlobAndLayerID(info types.BlobInfo) (rc io.ReadC
}
// GetManifest() reads the image's manifest.
-func (s *storageImageSource) GetManifest(instanceDigest *digest.Digest) (manifestBlob []byte, MIMEType string, err error) {
+func (s *storageImageSource) GetManifest(ctx context.Context, instanceDigest *digest.Digest) (manifestBlob []byte, MIMEType string, err error) {
if instanceDigest != nil {
return nil, "", ErrNoManifestLists
}
@@ -175,9 +175,9 @@ func (s *storageImageSource) GetManifest(instanceDigest *digest.Digest) (manifes
// LayerInfosForCopy() returns the list of layer blobs that make up the root filesystem of
// the image, after they've been decompressed.
-func (s *storageImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (s *storageImageSource) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
updatedBlobInfos := []types.BlobInfo{}
- _, manifestType, err := s.GetManifest(nil)
+ _, manifestType, err := s.GetManifest(ctx, nil)
if err != nil {
return nil, errors.Wrapf(err, "error reading image manifest for %q", s.image.ID)
}
@@ -239,7 +239,7 @@ func (s *storageImageSource) GetSignatures(ctx context.Context, instanceDigest *
// newImageDestination sets us up to write a new image, caching blobs in a temporary directory until
// it's time to Commit() the image
-func newImageDestination(ctx *types.SystemContext, imageRef storageReference) (*storageImageDestination, error) {
+func newImageDestination(imageRef storageReference) (*storageImageDestination, error) {
directory, err := ioutil.TempDir(temporaryDirectoryForBigFiles, "storage")
if err != nil {
return nil, errors.Wrapf(err, "error creating a temporary directory")
@@ -283,7 +283,7 @@ func (s storageImageDestination) DesiredLayerCompression() types.LayerCompressio
// PutBlob stores a layer or data blob in our temporary directory, checking that any information
// in the blobinfo matches the incoming data.
-func (s *storageImageDestination) PutBlob(stream io.Reader, blobinfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
+func (s *storageImageDestination) PutBlob(ctx context.Context, stream io.Reader, blobinfo types.BlobInfo, isConfig bool) (types.BlobInfo, error) {
errorBlobInfo := types.BlobInfo{
Digest: "",
Size: -1,
@@ -309,6 +309,7 @@ func (s *storageImageDestination) PutBlob(stream io.Reader, blobinfo types.BlobI
return errorBlobInfo, errors.Wrap(err, "error setting up to decompress blob")
}
// Copy the data to the file.
+ // TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().
_, err = io.Copy(diffID.Hash(), decompressed)
decompressed.Close()
if err != nil {
@@ -346,7 +347,7 @@ func (s *storageImageDestination) PutBlob(stream io.Reader, blobinfo types.BlobI
// Unlike PutBlob, the digest can not be empty. If HasBlob returns true, the size of the blob must also be returned.
// If the destination does not contain the blob, or it is unknown, HasBlob ordinarily returns (false, -1, nil);
// it returns a non-nil error only on an unexpected failure.
-func (s *storageImageDestination) HasBlob(blobinfo types.BlobInfo) (bool, int64, error) {
+func (s *storageImageDestination) HasBlob(ctx context.Context, blobinfo types.BlobInfo) (bool, int64, error) {
if blobinfo.Digest == "" {
return false, -1, errors.Errorf(`Can not check for a blob with unknown digest`)
}
@@ -383,8 +384,8 @@ func (s *storageImageDestination) HasBlob(blobinfo types.BlobInfo) (bool, int64,
// ReapplyBlob is now a no-op, assuming HasBlob() says we already have it, since Commit() can just apply the
// same one when it walks the list in the manifest.
-func (s *storageImageDestination) ReapplyBlob(blobinfo types.BlobInfo) (types.BlobInfo, error) {
- present, size, err := s.HasBlob(blobinfo)
+func (s *storageImageDestination) ReapplyBlob(ctx context.Context, blobinfo types.BlobInfo) (types.BlobInfo, error) {
+ present, size, err := s.HasBlob(ctx, blobinfo)
if !present {
return types.BlobInfo{}, errors.Errorf("error reapplying blob %+v: blob was not previously applied", blobinfo)
}
@@ -459,7 +460,7 @@ func (s *storageImageDestination) getConfigBlob(info types.BlobInfo) ([]byte, er
return nil, errors.New("blob not found")
}
-func (s *storageImageDestination) Commit() error {
+func (s *storageImageDestination) Commit(ctx context.Context) error {
// Find the list of layer blobs.
if len(s.manifest) == 0 {
return errors.New("Internal error: storageImageDestination.Commit() called without PutManifest()")
@@ -481,7 +482,7 @@ func (s *storageImageDestination) Commit() error {
// Check if it's elsewhere and the caller just forgot to pass it to us in a PutBlob(),
// or to even check if we had it.
logrus.Debugf("looking for diffID for blob %+v", blob.Digest)
- has, _, err := s.HasBlob(blob)
+ has, _, err := s.HasBlob(ctx, blob)
if err != nil {
return errors.Wrapf(err, "error checking for a layer based on blob %q", blob.Digest.String())
}
@@ -544,6 +545,7 @@ func (s *storageImageDestination) Commit() error {
return errors.Errorf("error applying blob %q: content not found", blob.Digest)
}
// Build the new layer using the diff, regardless of where it came from.
+ // TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().
layer, _, err := s.imageRef.transport.store.PutLayer(id, lastLayer, nil, "", false, nil, diff)
if err != nil {
return errors.Wrapf(err, "error adding layer with blob %q", blob.Digest)
@@ -679,7 +681,7 @@ func (s *storageImageDestination) SupportedManifestMIMETypes() []string {
}
// PutManifest writes the manifest to the destination.
-func (s *storageImageDestination) PutManifest(manifest []byte) error {
+func (s *storageImageDestination) PutManifest(ctx context.Context, manifest []byte) error {
s.manifest = make([]byte, len(manifest))
copy(s.manifest, manifest)
return nil
@@ -687,7 +689,7 @@ func (s *storageImageDestination) PutManifest(manifest []byte) error {
// SupportsSignatures returns an error if we can't expect GetSignatures() to return data that was
// previously supplied to PutSignatures().
-func (s *storageImageDestination) SupportsSignatures() error {
+func (s *storageImageDestination) SupportsSignatures(ctx context.Context) error {
return nil
}
@@ -703,7 +705,7 @@ func (s *storageImageDestination) MustMatchRuntimeOS() bool {
}
// PutSignatures records the image's signatures for committing as a single data blob.
-func (s *storageImageDestination) PutSignatures(signatures [][]byte) error {
+func (s *storageImageDestination) PutSignatures(ctx context.Context, signatures [][]byte) error {
sizes := []int{}
sigblob := []byte{}
for _, sig := range signatures {
@@ -769,12 +771,12 @@ func (s *storageImageCloser) Size() (int64, error) {
}
// newImage creates an image that also knows its size
-func newImage(ctx *types.SystemContext, s storageReference) (types.ImageCloser, error) {
+func newImage(ctx context.Context, sys *types.SystemContext, s storageReference) (types.ImageCloser, error) {
src, err := newImageSource(s)
if err != nil {
return nil, err
}
- img, err := image.FromSource(ctx, src)
+ img, err := image.FromSource(ctx, sys, src)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/containers/image/storage/storage_reference.go b/vendor/github.com/containers/image/storage/storage_reference.go
index bcb00f60e..532716941 100644
--- a/vendor/github.com/containers/image/storage/storage_reference.go
+++ b/vendor/github.com/containers/image/storage/storage_reference.go
@@ -3,6 +3,7 @@
package storage
import (
+ "context"
"strings"
"github.com/containers/image/docker/reference"
@@ -181,11 +182,11 @@ func (s storageReference) PolicyConfigurationNamespaces() []string {
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
-func (s storageReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
- return newImage(ctx, s)
+func (s storageReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
+ return newImage(ctx, sys, s)
}
-func (s storageReference) DeleteImage(ctx *types.SystemContext) error {
+func (s storageReference) DeleteImage(ctx context.Context, sys *types.SystemContext) error {
img, err := s.resolveImage()
if err != nil {
return err
@@ -200,10 +201,10 @@ func (s storageReference) DeleteImage(ctx *types.SystemContext) error {
return err
}
-func (s storageReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
+func (s storageReference) NewImageSource(ctx context.Context, sys *types.SystemContext) (types.ImageSource, error) {
return newImageSource(s)
}
-func (s storageReference) NewImageDestination(ctx *types.SystemContext) (types.ImageDestination, error) {
- return newImageDestination(ctx, s)
+func (s storageReference) NewImageDestination(ctx context.Context, sys *types.SystemContext) (types.ImageDestination, error) {
+ return newImageDestination(s)
}
diff --git a/vendor/github.com/containers/image/tarball/tarball_reference.go b/vendor/github.com/containers/image/tarball/tarball_reference.go
index a0819ac58..fc1230a89 100644
--- a/vendor/github.com/containers/image/tarball/tarball_reference.go
+++ b/vendor/github.com/containers/image/tarball/tarball_reference.go
@@ -1,6 +1,7 @@
package tarball
import (
+ "context"
"fmt"
"os"
"strings"
@@ -66,12 +67,12 @@ func (r *tarballReference) PolicyConfigurationNamespaces() []string {
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
-func (r *tarballReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
- src, err := r.NewImageSource(ctx)
+func (r *tarballReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) {
+ src, err := r.NewImageSource(ctx, sys)
if err != nil {
return nil, err
}
- img, err := image.FromSource(ctx, src)
+ img, err := image.FromSource(ctx, sys, src)
if err != nil {
src.Close()
return nil, err
@@ -79,7 +80,7 @@ func (r *tarballReference) NewImage(ctx *types.SystemContext) (types.ImageCloser
return img, nil
}
-func (r *tarballReference) DeleteImage(ctx *types.SystemContext) error {
+func (r *tarballReference) DeleteImage(ctx context.Context, sys *types.SystemContext) error {
for _, filename := range r.filenames {
if err := os.Remove(filename); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("error removing %q: %v", filename, err)
@@ -88,6 +89,6 @@ func (r *tarballReference) DeleteImage(ctx *types.SystemContext) error {
return nil
}
-func (r *tarballReference) NewImageDestination(ctx *types.SystemContext) (types.ImageDestination, error) {
+func (r *tarballReference) NewImageDestination(ctx context.Context, sys *types.SystemContext) (types.ImageDestination, error) {
return nil, fmt.Errorf(`"tarball:" locations can only be read from, not written to`)
}
diff --git a/vendor/github.com/containers/image/tarball/tarball_src.go b/vendor/github.com/containers/image/tarball/tarball_src.go
index f44a1b7d5..17af60b30 100644
--- a/vendor/github.com/containers/image/tarball/tarball_src.go
+++ b/vendor/github.com/containers/image/tarball/tarball_src.go
@@ -34,7 +34,7 @@ type tarballImageSource struct {
manifest []byte
}
-func (r *tarballReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
+func (r *tarballReference) NewImageSource(ctx context.Context, sys *types.SystemContext) (types.ImageSource, error) {
// Gather up the digests, sizes, and date information for all of the files.
filenames := []string{}
diffIDs := []digest.Digest{}
@@ -87,6 +87,7 @@ func (r *tarballReference) NewImageSource(ctx *types.SystemContext) (types.Image
layerType = imgspecv1.MediaTypeImageLayer
uncompressed = nil
}
+ // TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().
n, err := io.Copy(ioutil.Discard, reader)
if err != nil {
return nil, fmt.Errorf("error reading %q: %v", filename, err)
@@ -206,7 +207,7 @@ func (is *tarballImageSource) Close() error {
return nil
}
-func (is *tarballImageSource) GetBlob(blobinfo types.BlobInfo) (io.ReadCloser, int64, error) {
+func (is *tarballImageSource) GetBlob(ctx context.Context, blobinfo types.BlobInfo) (io.ReadCloser, int64, error) {
// We should only be asked about things in the manifest. Maybe the configuration blob.
if blobinfo.Digest == is.configID {
return ioutil.NopCloser(bytes.NewBuffer(is.config)), is.configSize, nil
@@ -232,7 +233,7 @@ func (is *tarballImageSource) GetBlob(blobinfo types.BlobInfo) (io.ReadCloser, i
// It may use a remote (= slow) service.
// If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve (when the primary manifest is a manifest list);
// this never happens if the primary manifest is not a manifest list (e.g. if the source never returns manifest lists).
-func (is *tarballImageSource) GetManifest(instanceDigest *digest.Digest) ([]byte, string, error) {
+func (is *tarballImageSource) GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error) {
if instanceDigest != nil {
return nil, "", fmt.Errorf("manifest lists are not supported by the %q transport", transportName)
}
@@ -255,6 +256,6 @@ func (is *tarballImageSource) Reference() types.ImageReference {
}
// LayerInfosForCopy() returns updated layer info that should be used when reading, in preference to values in the manifest, if specified.
-func (*tarballImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
+func (*tarballImageSource) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) {
return nil, nil
}
diff --git a/vendor/github.com/containers/image/types/types.go b/vendor/github.com/containers/image/types/types.go
index 7b4681b8f..62aa78ddd 100644
--- a/vendor/github.com/containers/image/types/types.go
+++ b/vendor/github.com/containers/image/types/types.go
@@ -78,16 +78,16 @@ type ImageReference interface {
// NOTE: If any kind of signature verification should happen, build an UnparsedImage from the value returned by NewImageSource,
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
- NewImage(ctx *SystemContext) (ImageCloser, error)
+ NewImage(ctx context.Context, sys *SystemContext) (ImageCloser, error)
// NewImageSource returns a types.ImageSource for this reference.
// The caller must call .Close() on the returned ImageSource.
- NewImageSource(ctx *SystemContext) (ImageSource, error)
+ NewImageSource(ctx context.Context, sys *SystemContext) (ImageSource, error)
// NewImageDestination returns a types.ImageDestination for this reference.
// The caller must call .Close() on the returned ImageDestination.
- NewImageDestination(ctx *SystemContext) (ImageDestination, error)
+ NewImageDestination(ctx context.Context, sys *SystemContext) (ImageDestination, error)
// DeleteImage deletes the named image from the registry, if supported.
- DeleteImage(ctx *SystemContext) error
+ DeleteImage(ctx context.Context, sys *SystemContext) error
}
// BlobInfo collects known information about a blob (layer/config).
@@ -117,10 +117,10 @@ type ImageSource interface {
// It may use a remote (= slow) service.
// If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve (when the primary manifest is a manifest list);
// this never happens if the primary manifest is not a manifest list (e.g. if the source never returns manifest lists).
- GetManifest(instanceDigest *digest.Digest) ([]byte, string, error)
+ GetManifest(ctx context.Context, instanceDigest *digest.Digest) ([]byte, string, error)
// GetBlob returns a stream for the specified blob, and the blob’s size (or -1 if unknown).
// The Digest field in BlobInfo is guaranteed to be provided, Size may be -1 and MediaType may be optionally provided.
- GetBlob(BlobInfo) (io.ReadCloser, int64, error)
+ GetBlob(context.Context, BlobInfo) (io.ReadCloser, int64, error)
// GetSignatures returns the image's signatures. It may use a remote (= slow) service.
// If instanceDigest is not nil, it contains a digest of the specific manifest instance to retrieve signatures for
// (when the primary manifest is a manifest list); this never happens if the primary manifest is not a manifest list
@@ -129,7 +129,7 @@ type ImageSource interface {
// LayerInfosForCopy returns either nil (meaning the values in the manifest are fine), or updated values for the layer blobsums that are listed in the image's manifest.
// The Digest field is guaranteed to be provided; Size may be -1.
// WARNING: The list may contain duplicates, and they are semantically relevant.
- LayerInfosForCopy() ([]BlobInfo, error)
+ LayerInfosForCopy(ctx context.Context) ([]BlobInfo, error)
}
// LayerCompression indicates if layers must be compressed, decompressed or preserved
@@ -166,7 +166,7 @@ type ImageDestination interface {
SupportedManifestMIMETypes() []string
// SupportsSignatures returns an error (to be displayed to the user) if the destination certainly can't store signatures.
// Note: It is still possible for PutSignatures to fail if SupportsSignatures returns nil.
- SupportsSignatures() error
+ SupportsSignatures(ctx context.Context) error
// DesiredLayerCompression indicates the kind of compression to apply on layers
DesiredLayerCompression() LayerCompression
// AcceptsForeignLayerURLs returns false iff foreign layers in manifest should be actually
@@ -181,25 +181,25 @@ type ImageDestination interface {
// WARNING: The contents of stream are being verified on the fly. Until stream.Read() returns io.EOF, the contents of the data SHOULD NOT be available
// to any other readers for download using the supplied digest.
// If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far.
- PutBlob(stream io.Reader, inputInfo BlobInfo, isConfig bool) (BlobInfo, error)
+ PutBlob(ctx context.Context, stream io.Reader, inputInfo BlobInfo, isConfig bool) (BlobInfo, error)
// HasBlob returns true iff the image destination already contains a blob with the matching digest which can be reapplied using ReapplyBlob.
// Unlike PutBlob, the digest can not be empty. If HasBlob returns true, the size of the blob must also be returned.
// If the destination does not contain the blob, or it is unknown, HasBlob ordinarily returns (false, -1, nil);
// it returns a non-nil error only on an unexpected failure.
- HasBlob(info BlobInfo) (bool, int64, error)
+ HasBlob(ctx context.Context, info BlobInfo) (bool, int64, error)
// ReapplyBlob informs the image destination that a blob for which HasBlob previously returned true would have been passed to PutBlob if it had returned false. Like HasBlob and unlike PutBlob, the digest can not be empty. If the blob is a filesystem layer, this signifies that the changes it describes need to be applied again when composing a filesystem tree.
- ReapplyBlob(info BlobInfo) (BlobInfo, error)
+ ReapplyBlob(ctx context.Context, info BlobInfo) (BlobInfo, error)
// PutManifest writes manifest to the destination.
// FIXME? This should also receive a MIME type if known, to differentiate between schema versions.
// If the destination is in principle available, refuses this manifest type (e.g. it does not recognize the schema),
// but may accept a different manifest type, the returned error must be an ManifestTypeRejectedError.
- PutManifest(manifest []byte) error
- PutSignatures(signatures [][]byte) error
+ PutManifest(ctx context.Context, manifest []byte) error
+ PutSignatures(ctx context.Context, signatures [][]byte) error
// Commit marks the process of storing the image as successful and asks for the image to be persisted.
// WARNING: This does not have any transactional semantics:
// - Uploaded data MAY be visible to others before Commit() is called
// - Uploaded data MAY be removed or MAY remain around if Close() is called without Commit() (i.e. rollback is allowed but not guaranteed)
- Commit() error
+ Commit(ctx context.Context) error
}
// ManifestTypeRejectedError is returned by ImageDestination.PutManifest if the destination is in principle available,
@@ -225,7 +225,7 @@ type UnparsedImage interface {
// (not as the image itself, or its underlying storage, claims). This can be used e.g. to determine which public keys are trusted for this image.
Reference() ImageReference
// Manifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need.
- Manifest() ([]byte, string, error)
+ Manifest(ctx context.Context) ([]byte, string, error)
// Signatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need.
Signatures(ctx context.Context) ([][]byte, error)
}
@@ -242,11 +242,11 @@ type Image interface {
ConfigInfo() BlobInfo
// ConfigBlob returns the blob described by ConfigInfo, if ConfigInfo().Digest != ""; nil otherwise.
// The result is cached; it is OK to call this however often you need.
- ConfigBlob() ([]byte, error)
+ ConfigBlob(context.Context) ([]byte, error)
// OCIConfig returns the image configuration as per OCI v1 image-spec. Information about
// layers in the resulting configuration isn't guaranteed to be returned to due how
// old image manifests work (docker v2s1 especially).
- OCIConfig() (*v1.Image, error)
+ OCIConfig(context.Context) (*v1.Image, error)
// LayerInfos returns a list of BlobInfos of layers referenced by this image, in order (the root layer first, and then successive layered layers).
// The Digest field is guaranteed to be provided, Size may be -1 and MediaType may be optionally provided.
// WARNING: The list may contain duplicates, and they are semantically relevant.
@@ -254,13 +254,13 @@ type Image interface {
// LayerInfosForCopy returns either nil (meaning the values in the manifest are fine), or updated values for the layer blobsums that are listed in the image's manifest.
// The Digest field is guaranteed to be provided, Size may be -1 and MediaType may be optionally provided.
// WARNING: The list may contain duplicates, and they are semantically relevant.
- LayerInfosForCopy() ([]BlobInfo, error)
+ LayerInfosForCopy(context.Context) ([]BlobInfo, error)
// EmbeddedDockerReferenceConflicts whether a Docker reference embedded in the manifest, if any, conflicts with destination ref.
// It returns false if the manifest does not embed a Docker reference.
// (This embedding unfortunately happens for Docker schema1, please do not add support for this in any new formats.)
EmbeddedDockerReferenceConflicts(ref reference.Named) bool
// Inspect returns various information for (skopeo inspect) parsed from the manifest and configuration.
- Inspect() (*ImageInspectInfo, error)
+ Inspect(context.Context) (*ImageInspectInfo, error)
// UpdatedImageNeedsLayerDiffIDs returns true iff UpdatedImage(options) needs InformationOnly.LayerDiffIDs.
// This is a horribly specific interface, but computing InformationOnly.LayerDiffIDs can be very expensive to compute
// (most importantly it forces us to download the full layers even if they are already present at the destination).
@@ -268,7 +268,7 @@ type Image interface {
// UpdatedImage returns a types.Image modified according to options.
// Everything in options.InformationOnly should be provided, other fields should be set only if a modification is desired.
// This does not change the state of the original Image object.
- UpdatedImage(options ManifestUpdateOptions) (Image, error)
+ UpdatedImage(ctx context.Context, options ManifestUpdateOptions) (Image, error)
// Size returns an approximation of the amount of disk space which is consumed by the image in its current
// location. If the size is not known, -1 will be returned.
Size() (int64, error)
diff --git a/vendor/github.com/containers/image/vendor.conf b/vendor/github.com/containers/image/vendor.conf
index f3634b38e..f2e69e903 100644
--- a/vendor/github.com/containers/image/vendor.conf
+++ b/vendor/github.com/containers/image/vendor.conf
@@ -1,3 +1,5 @@
+github.com/containers/image
+
github.com/sirupsen/logrus v1.0.0
github.com/containers/storage master
github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76
@@ -8,11 +10,9 @@ github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d
github.com/docker/go-units 0dadbb0345b35ec7ef35e228dabb8de89a65bf52
github.com/docker/libtrust aabc10ec26b754e797f9028f4589c5b7bd90dc20
github.com/ghodss/yaml 04f313413ffd65ce25f2541bfd2b2ceec5c0908c
-github.com/gorilla/context 08b5f424b9271eedf6f9f0ce86cb9396ed337a42
github.com/gorilla/mux 94e7d24fd285520f3d12ae998f7fdd6b5393d453
github.com/imdario/mergo 50d4dbd4eb0e84778abe37cefef140271d96fade
github.com/mattn/go-runewidth 14207d285c6c197daabb5c9793d63e7af9ab2d50
-github.com/mattn/go-shellwords 005a0944d84452842197c2108bd9168ced206f78
github.com/mistifyio/go-zfs c0224de804d438efd11ea6e52ada8014537d6062
github.com/mtrmac/gpgme b2432428689ca58c2b8e8dea9449d3295cf96fc9
github.com/opencontainers/go-digest aa2ec055abd10d26d539eb630a92241b781ce4bc
diff --git a/vendor/github.com/containers/storage/pkg/archive/example_changes.go b/vendor/github.com/containers/storage/pkg/archive/example_changes.go
deleted file mode 100644
index 70f9c5564..000000000
--- a/vendor/github.com/containers/storage/pkg/archive/example_changes.go
+++ /dev/null
@@ -1,97 +0,0 @@
-// +build ignore
-
-// Simple tool to create an archive stream from an old and new directory
-//
-// By default it will stream the comparison of two temporary directories with junk files
-package main
-
-import (
- "flag"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "path"
-
- "github.com/containers/storage/pkg/archive"
- "github.com/sirupsen/logrus"
-)
-
-var (
- flDebug = flag.Bool("D", false, "debugging output")
- flNewDir = flag.String("newdir", "", "")
- flOldDir = flag.String("olddir", "", "")
- log = logrus.New()
-)
-
-func main() {
- flag.Usage = func() {
- fmt.Println("Produce a tar from comparing two directory paths. By default a demo tar is created of around 200 files (including hardlinks)")
- fmt.Printf("%s [OPTIONS]\n", os.Args[0])
- flag.PrintDefaults()
- }
- flag.Parse()
- log.Out = os.Stderr
- if (len(os.Getenv("DEBUG")) > 0) || *flDebug {
- logrus.SetLevel(logrus.DebugLevel)
- }
- var newDir, oldDir string
-
- if len(*flNewDir) == 0 {
- var err error
- newDir, err = ioutil.TempDir("", "storage-test-newDir")
- if err != nil {
- log.Fatal(err)
- }
- defer os.RemoveAll(newDir)
- if _, err := prepareUntarSourceDirectory(100, newDir, true); err != nil {
- log.Fatal(err)
- }
- } else {
- newDir = *flNewDir
- }
-
- if len(*flOldDir) == 0 {
- oldDir, err := ioutil.TempDir("", "storage-test-oldDir")
- if err != nil {
- log.Fatal(err)
- }
- defer os.RemoveAll(oldDir)
- } else {
- oldDir = *flOldDir
- }
-
- changes, err := archive.ChangesDirs(newDir, oldDir)
- if err != nil {
- log.Fatal(err)
- }
-
- a, err := archive.ExportChanges(newDir, changes)
- if err != nil {
- log.Fatal(err)
- }
- defer a.Close()
-
- i, err := io.Copy(os.Stdout, a)
- if err != nil && err != io.EOF {
- log.Fatal(err)
- }
- fmt.Fprintf(os.Stderr, "wrote archive of %d bytes", i)
-}
-
-func prepareUntarSourceDirectory(numberOfFiles int, targetPath string, makeLinks bool) (int, error) {
- fileData := []byte("fooo")
- for n := 0; n < numberOfFiles; n++ {
- fileName := fmt.Sprintf("file-%d", n)
- if err := ioutil.WriteFile(path.Join(targetPath, fileName), fileData, 0700); err != nil {
- return 0, err
- }
- if makeLinks {
- if err := os.Link(path.Join(targetPath, fileName), path.Join(targetPath, fileName+"-link")); err != nil {
- return 0, err
- }
- }
- }
- totalSize := numberOfFiles * len(fileData)
- return totalSize, nil
-}
diff --git a/vendor/github.com/containers/storage/store.go b/vendor/github.com/containers/storage/store.go
index 407dda872..359a00bb2 100644
--- a/vendor/github.com/containers/storage/store.go
+++ b/vendor/github.com/containers/storage/store.go
@@ -173,7 +173,7 @@ type Store interface {
// process's main() function needs to import our pkg/reexec package and
// should begin with something like this in order to allow us to
// properly start that child process:
- // if reexec.Init {
+ // if reexec.Init() {
// return
// }
PutLayer(id, parent string, names []string, mountLabel string, writeable bool, options *LayerOptions, diff io.Reader) (*Layer, int64, error)
@@ -253,7 +253,7 @@ type Store interface {
// process's main() function needs to import our pkg/reexec package and
// should begin with something like this in order to allow us to
// properly start that child process:
- // if reexec.Init {
+ // if reexec.Init() {
// return
// }
Mount(id, mountLabel string) (string, error)
@@ -288,7 +288,7 @@ type Store interface {
// process's main() function needs to import our pkg/reexec package and
// should begin with something like this in order to allow us to
// properly start that child process:
- // if reexec.Init {
+ // if reexec.Init() {
// return
// }
ApplyDiff(to string, diff io.Reader) (int64, error)
@@ -512,6 +512,14 @@ type store struct {
// These defaults observe environment variables:
// * `STORAGE_DRIVER` for the name of the storage driver to attempt to use
// * `STORAGE_OPTS` for the string of options to pass to the driver
+//
+// Note that we do some of this work in a child process. The calling process's
+// main() function needs to import our pkg/reexec package and should begin with
+// something like this in order to allow us to properly start that child
+// process:
+// if reexec.Init() {
+// return
+// }
func GetStore(options StoreOptions) (Store, error) {
if options.RunRoot == "" && options.GraphRoot == "" && options.GraphDriverName == "" && len(options.GraphDriverOptions) == 0 {
options = DefaultStoreOptions
diff --git a/vendor/github.com/cyphar/filepath-securejoin/LICENSE b/vendor/github.com/cyphar/filepath-securejoin/LICENSE
deleted file mode 100644
index bec842f29..000000000
--- a/vendor/github.com/cyphar/filepath-securejoin/LICENSE
+++ /dev/null
@@ -1,28 +0,0 @@
-Copyright (C) 2014-2015 Docker Inc & Go Authors. All rights reserved.
-Copyright (C) 2017 SUSE LLC. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
- * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/github.com/cyphar/filepath-securejoin/README.md b/vendor/github.com/cyphar/filepath-securejoin/README.md
deleted file mode 100644
index 49b2baa9f..000000000
--- a/vendor/github.com/cyphar/filepath-securejoin/README.md
+++ /dev/null
@@ -1,65 +0,0 @@
-## `filepath-securejoin` ##
-
-[![Build Status](https://travis-ci.org/cyphar/filepath-securejoin.svg?branch=master)](https://travis-ci.org/cyphar/filepath-securejoin)
-
-An implementation of `SecureJoin`, a [candidate for inclusion in the Go
-standard library][go#20126]. The purpose of this function is to be a "secure"
-alternative to `filepath.Join`, and in particular it provides certain
-guarantees that are not provided by `filepath.Join`.
-
-This is the function prototype:
-
-```go
-func SecureJoin(root, unsafePath string) (string, error)
-```
-
-This library **guarantees** the following:
-
-* If no error is set, the resulting string **must** be a child path of
- `SecureJoin` and will not contain any symlink path components (they will all
- be expanded).
-
-* When expanding symlinks, all symlink path components **must** be resolved
- relative to the provided root. In particular, this can be considered a
- userspace implementation of how `chroot(2)` operates on file paths. Note that
- these symlinks will **not** be expanded lexically (`filepath.Clean` is not
- called on the input before processing).
-
-* Non-existant path components are unaffected by `SecureJoin` (similar to
- `filepath.EvalSymlinks`'s semantics).
-
-* The returned path will always be `filepath.Clean`ed and thus not contain any
- `..` components.
-
-A (trivial) implementation of this function on GNU/Linux systems could be done
-with the following (note that this requires root privileges and is far more
-opaque than the implementation in this library, and also requires that
-`readlink` is inside the `root` path):
-
-```go
-package securejoin
-
-import (
- "os/exec"
- "path/filepath"
-)
-
-func SecureJoin(root, unsafePath string) (string, error) {
- unsafePath = string(filepath.Separator) + unsafePath
- cmd := exec.Command("chroot", root,
- "readlink", "--canonicalize-missing", "--no-newline", unsafePath)
- output, err := cmd.CombinedOutput()
- if err != nil {
- return "", err
- }
- expanded := string(output)
- return filepath.Join(root, expanded), nil
-}
-```
-
-[go#20126]: https://github.com/golang/go/issues/20126
-
-### License ###
-
-The license of this project is the same as Go, which is a BSD 3-clause license
-available in the `LICENSE` file.
diff --git a/vendor/github.com/cyphar/filepath-securejoin/vendor.conf b/vendor/github.com/cyphar/filepath-securejoin/vendor.conf
deleted file mode 100644
index 66bb574b9..000000000
--- a/vendor/github.com/cyphar/filepath-securejoin/vendor.conf
+++ /dev/null
@@ -1 +0,0 @@
-github.com/pkg/errors v0.8.0
diff --git a/vendor/github.com/docker/docker/hack/README.md b/vendor/github.com/docker/docker/hack/README.md
deleted file mode 100644
index 802395d53..000000000
--- a/vendor/github.com/docker/docker/hack/README.md
+++ /dev/null
@@ -1,60 +0,0 @@
-## About
-
-This directory contains a collection of scripts used to build and manage this
-repository. If there are any issues regarding the intention of a particular
-script (or even part of a certain script), please reach out to us.
-It may help us either refine our current scripts, or add on new ones
-that are appropriate for a given use case.
-
-## DinD (dind.sh)
-
-DinD is a wrapper script which allows Docker to be run inside a Docker
-container. DinD requires the container to
-be run with privileged mode enabled.
-
-## Generate Authors (generate-authors.sh)
-
-Generates AUTHORS; a file with all the names and corresponding emails of
-individual contributors. AUTHORS can be found in the home directory of
-this repository.
-
-## Make
-
-There are two make files, each with different extensions. Neither are supposed
-to be called directly; only invoke `make`. Both scripts run inside a Docker
-container.
-
-### make.ps1
-
-- The Windows native build script that uses PowerShell semantics; it is limited
-unlike `hack\make.sh` since it does not provide support for the full set of
-operations provided by the Linux counterpart, `make.sh`. However, `make.ps1`
-does provide support for local Windows development and Windows to Windows CI.
-More information is found within `make.ps1` by the author, @jhowardmsft
-
-### make.sh
-
-- Referenced via `make test` when running tests on a local machine,
-or directly referenced when running tests inside a Docker development container.
-- When running on a local machine, `make test` to run all tests found in
-`test`, `test-unit`, `test-integration-cli`, and `test-docker-py` on
-your local machine. The default timeout is set in `make.sh` to 60 minutes
-(`${TIMEOUT:=60m}`), since it currently takes up to an hour to run
-all of the tests.
-- When running inside a Docker development container, `hack/make.sh` does
-not have a single target that runs all the tests. You need to provide a
-single command line with multiple targets that performs the same thing.
-An example referenced from [Run targets inside a development container](https://docs.docker.com/opensource/project/test-and-docs/#run-targets-inside-a-development-container): `root@5f8630b873fe:/go/src/github.com/moby/moby# hack/make.sh dynbinary binary cross test-unit test-integration-cli test-docker-py`
-- For more information related to testing outside the scope of this README,
-refer to
-[Run tests and test documentation](https://docs.docker.com/opensource/project/test-and-docs/)
-
-## Release (release.sh)
-
-Releases any bundles built by `make` on a public AWS S3 bucket.
-For information regarding configuration, please view `release.sh`.
-
-## Vendor (vendor.sh)
-
-A shell script that is a wrapper around Vndr. For information on how to use
-this, please refer to [vndr's README](https://github.com/LK4D4/vndr/blob/master/README.md)
diff --git a/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/README.md b/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/README.md
deleted file mode 100644
index 1cea52526..000000000
--- a/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/README.md
+++ /dev/null
@@ -1,69 +0,0 @@
-# Integration Testing on Swarm
-
-IT on Swarm allows you to execute integration test in parallel across a Docker Swarm cluster
-
-## Architecture
-
-### Master service
-
- - Works as a funker caller
- - Calls a worker funker (`-worker-service`) with a chunk of `-check.f` filter strings (passed as a file via `-input` flag, typically `/mnt/input`)
-
-### Worker service
-
- - Works as a funker callee
- - Executes an equivalent of `TESTFLAGS=-check.f TestFoo|TestBar|TestBaz ... make test-integration-cli` using the bind-mounted API socket (`docker.sock`)
-
-### Client
-
- - Controls master and workers via `docker stack`
- - No need to have a local daemon
-
-Typically, the master and workers are supposed to be running on a cloud environment,
-while the client is supposed to be running on a laptop, e.g. Docker for Mac/Windows.
-
-## Requirement
-
- - Docker daemon 1.13 or later
- - Private registry for distributed execution with multiple nodes
-
-## Usage
-
-### Step 1: Prepare images
-
- $ make build-integration-cli-on-swarm
-
-Following environment variables are known to work in this step:
-
- - `BUILDFLAGS`
- - `DOCKER_INCREMENTAL_BINARY`
-
-Note: during the transition into Moby Project, you might need to create a symbolic link `$GOPATH/src/github.com/docker/docker` to `$GOPATH/src/github.com/moby/moby`.
-
-### Step 2: Execute tests
-
- $ ./hack/integration-cli-on-swarm/integration-cli-on-swarm -replicas 40 -push-worker-image YOUR_REGISTRY.EXAMPLE.COM/integration-cli-worker:latest
-
-Following environment variables are known to work in this step:
-
- - `DOCKER_GRAPHDRIVER`
- - `DOCKER_EXPERIMENTAL`
-
-#### Flags
-
-Basic flags:
-
- - `-replicas N`: the number of worker service replicas. i.e. degree of parallelism.
- - `-chunks N`: the number of chunks. By default, `chunks` == `replicas`.
- - `-push-worker-image REGISTRY/IMAGE:TAG`: push the worker image to the registry. Note that if you have only single node and hence you do not need a private registry, you do not need to specify `-push-worker-image`.
-
-Experimental flags for mitigating makespan nonuniformity:
-
- - `-shuffle`: Shuffle the test filter strings
-
-Flags for debugging IT on Swarm itself:
-
- - `-rand-seed N`: the random seed. This flag is useful for deterministic replaying. By default(0), the timestamp is used.
- - `-filters-file FILE`: the file contains `-check.f` strings. By default, the file is automatically generated.
- - `-dry-run`: skip the actual workload
- - `keep-executor`: do not auto-remove executor containers, which is used for running privileged programs on Swarm
diff --git a/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/vendor.conf b/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/vendor.conf
deleted file mode 100644
index efd6d6d04..000000000
--- a/vendor/github.com/docker/docker/hack/integration-cli-on-swarm/agent/vendor.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-# dependencies specific to worker (i.e. github.com/docker/docker/...) are not vendored here
-github.com/bfirsh/funker-go eaa0a2e06f30e72c9a0b7f858951e581e26ef773
diff --git a/vendor/github.com/docker/docker/profiles/seccomp/generate.go b/vendor/github.com/docker/docker/profiles/seccomp/generate.go
deleted file mode 100644
index 32f22bb37..000000000
--- a/vendor/github.com/docker/docker/profiles/seccomp/generate.go
+++ /dev/null
@@ -1,32 +0,0 @@
-// +build ignore
-
-package main
-
-import (
- "encoding/json"
- "io/ioutil"
- "os"
- "path/filepath"
-
- "github.com/docker/docker/profiles/seccomp"
-)
-
-// saves the default seccomp profile as a json file so people can use it as a
-// base for their own custom profiles
-func main() {
- wd, err := os.Getwd()
- if err != nil {
- panic(err)
- }
- f := filepath.Join(wd, "default.json")
-
- // write the default profile to the file
- b, err := json.MarshalIndent(seccomp.DefaultProfile(), "", "\t")
- if err != nil {
- panic(err)
- }
-
- if err := ioutil.WriteFile(f, b, 0644); err != nil {
- panic(err)
- }
-}
diff --git a/vendor/github.com/varlink/go/.gitignore b/vendor/github.com/varlink/go/.gitignore
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/github.com/varlink/go/.gitignore
diff --git a/vendor/github.com/varlink/go/.travis.yml b/vendor/github.com/varlink/go/.travis.yml
new file mode 100644
index 000000000..990f12e0a
--- /dev/null
+++ b/vendor/github.com/varlink/go/.travis.yml
@@ -0,0 +1,13 @@
+language: go
+sudo: false
+go:
+- '1.9'
+- 1.10.x
+install:
+- go get golang.org/x/tools/cmd/cover
+- go get github.com/mattn/goveralls
+script:
+- '"$HOME/gopath/bin/goveralls" -show -service=travis-ci -repotoken "$COVERALLS_TOKEN"'
+env:
+ global:
+ - secure: bjxOSgBfB+YooxNTkIDHAD+/X6g56qBWoYpB1JinuS5kmt3vSjfRSuXui71sGuha7jO2FOJja8HcpjOv3UP+qmmej9276o5VWrjS1AwnI95hSQQ4JHm293Z1QeojjRaxmoKrgn7i82Hn4qNdVLQA142s+SIdqOxtN6LDs7i0Yb4IuXoiMQHbd6kAAL95o9IUFPpYAdsXoQ6xnx+TXNiSwPPeh4m5CNKuTtmGTuMGaj8tXxttFKJhZcRzvOpDuh7luc9PSVnQgYmKE/3S9ehzGV8Lk4T8eC7587DY1GdYQKt1egJSE72L+PVnmoalWROaAGHZvYWsSAeNi1UIvcFwGbXBRpq7kz3DVfIULM8V67UAaF3dGYDN3Ae825mDjN5JDfml17AoEjMjI0LlBImZLX2EWIEN225JIREHdpG9seJkaN1ClcpvEIeYuThF2MiivP1EE8/w8S80yoO5nW76Py/th16OuaEiP9LdLsbXimObUPsS9Sr8qquf/PiVqRMMpVW88oOEG5HVn4Ra5B/xVC6nPEF88tE6p9+7RSz4rOWih8QmW+6SX6eo0BI9di4L779f/WfUrddN0JLIvEnRFZZ+pVF/oo+N2INNeIMsZBvG3FVo+Zxzo6SExXnSSpuf1bp140ZdinUMACq6BqK+9gj1C9vNRmqQJaEefrqutws=
diff --git a/vendor/github.com/containerd/continuity/LICENSE b/vendor/github.com/varlink/go/LICENSE
index 8f71f43fe..261eeb9e9 100644
--- a/vendor/github.com/containerd/continuity/LICENSE
+++ b/vendor/github.com/varlink/go/LICENSE
@@ -178,7 +178,7 @@
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
+ boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright {yyyy} {name of copyright owner}
+ Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -199,4 +199,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
diff --git a/vendor/github.com/varlink/go/Makefile b/vendor/github.com/varlink/go/Makefile
new file mode 100644
index 000000000..3f1c0e6d6
--- /dev/null
+++ b/vendor/github.com/varlink/go/Makefile
@@ -0,0 +1,3 @@
+all:
+ go test -v ./...
+.PHONY: all
diff --git a/vendor/github.com/varlink/go/README.md b/vendor/github.com/varlink/go/README.md
new file mode 100644
index 000000000..926a82bdd
--- /dev/null
+++ b/vendor/github.com/varlink/go/README.md
@@ -0,0 +1,7 @@
+[![Build Status](https://travis-ci.org/varlink/go.svg?branch=master)](https://travis-ci.org/varlink/go)
+[![Go Report Card](https://goreportcard.com/badge/github.com/varlink/go)](https://goreportcard.com/report/github.com/varlink/go)
+[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/varlink/go/varlink)
+[![Coverage Status](https://coveralls.io/repos/github/varlink/go/badge.svg?branch=master)](https://coveralls.io/github/varlink/go?branch=master)
+[![Release](https://img.shields.io/github/release/golang-standards/project-layout.svg?style=flat-square)](https://github.com/varlink/go/varlink/releases/latest)
+
+# go/varlink
diff --git a/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/generator_test.go b/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/generator_test.go
new file mode 100644
index 000000000..aa3a8565f
--- /dev/null
+++ b/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/generator_test.go
@@ -0,0 +1,85 @@
+package main
+
+import (
+ "strings"
+ "testing"
+)
+
+func expect(t *testing.T, expected string, returned string) {
+ if strings.Compare(returned, expected) != 0 {
+ t.Fatalf("Expected(%d): `%s`\nGot(%d): `%s`\n",
+ len(expected), expected,
+ len(returned), returned)
+ }
+}
+
+func TestIDLParser(t *testing.T) {
+ pkgname, b, err := generateTemplate(`
+# Interface to jump a spacecraft to another point in space. The
+# FTL Drive is the propulsion system to achieve faster-than-light
+# travel through space. A ship making a properly calculated
+# jump can arrive safely in planetary orbit, or alongside other
+# ships or spaceborne objects.
+interface org.example.ftl
+
+# The current state of the FTL drive and the amount of fuel
+# available to jump.
+type DriveCondition (
+ state: (idle, spooling, busy),
+ booster: bool,
+ active_engines: [](id: int, state: bool),
+ tylium_level: int
+)
+
+# Speed, trajectory and jump duration is calculated prior to
+# activating the FTL drive.
+type DriveConfiguration (
+ speed: int,
+ trajectory: int,
+ duration: int
+)
+
+# The galactic coordinates use the Sun as the origin. Galactic
+# longitude is measured with primary direction from the Sun to
+# the center of the galaxy in the galactic plane, while the
+# galactic latitude measures the angle of the object above the
+# galactic plane.
+type Coordinate (
+ longitude: float,
+ latitude: float,
+ distance: int
+)
+
+# Monitor the drive. The method will reply with an update whenever
+# the drive's state changes
+method Monitor() -> (condition: DriveCondition)
+
+# Calculate the drive's jump parameters from the current
+# position to the target position in the galaxy
+method CalculateConfiguration(
+ current: Coordinate,
+ target: Coordinate
+) -> (configuration: DriveConfiguration)
+
+# Jump to the calculated point in space
+method Jump(configuration: DriveConfiguration) -> ()
+
+# There is not enough tylium to jump with the given parameters
+error NotEnoughEnergy ()
+
+# The supplied parameters are outside the supported range
+error ParameterOutOfRange (field: string)
+
+# some more coverage
+method Foo(interface: string) -> (ret: (go: string, switch: bool, more: (t:bool, f:bool)))
+ `)
+
+ if err != nil {
+ t.Fatalf("Error parsing %v", err)
+ }
+ expect(t, "orgexampleftl", pkgname)
+ if len(b) <= 0 {
+ t.Fatal("No generated go source")
+ }
+ // FIXME: compare b.String() against expected output
+}
diff --git a/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go b/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go
new file mode 100644
index 000000000..1bcdb78de
--- /dev/null
+++ b/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go
@@ -0,0 +1,294 @@
+package main
+
+import (
+ "bytes"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path"
+ "strings"
+
+ "github.com/varlink/go/varlink/idl"
+)
+
+var goKeywords = map[string]struct{}{
+ "break": {},
+ "case": {},
+ "chan": {},
+ "const": {},
+ "continue": {},
+ "default": {},
+ "defer": {},
+ "else": {},
+ "fallthrough": {},
+ "for": {},
+ "func": {},
+ "go": {},
+ "goto": {},
+ "if": {},
+ "import": {},
+ "interface": {},
+ "map": {},
+ "package": {},
+ "range": {},
+ "return": {},
+ "select": {},
+ "struct": {},
+ "switch": {},
+ "type": {},
+ "var": {},
+}
+
+func sanitizeGoName(name string) string {
+ if _, ok := goKeywords[name]; !ok {
+ return name
+ }
+ return name + "_"
+}
+
+func writeType(b *bytes.Buffer, t *idl.Type, json bool, ident int) {
+ switch t.Kind {
+ case idl.TypeBool:
+ b.WriteString("bool")
+
+ case idl.TypeInt:
+ b.WriteString("int64")
+
+ case idl.TypeFloat:
+ b.WriteString("float64")
+
+ case idl.TypeString, idl.TypeEnum:
+ b.WriteString("string")
+
+ case idl.TypeArray:
+ b.WriteString("[]")
+ writeType(b, t.ElementType, json, ident)
+
+ case idl.TypeMaybe:
+ b.WriteString("*")
+ writeType(b, t.ElementType, json, ident)
+
+ case idl.TypeAlias:
+ b.WriteString(t.Alias)
+
+ case idl.TypeStruct:
+ b.WriteString("struct{\n")
+ for _, field := range t.Fields {
+ for i := 0; i < ident+1; i++ {
+ b.WriteString("\t")
+ }
+
+ b.WriteString(strings.Title(field.Name) + " ")
+ writeType(b, field.Type, json, ident+1)
+ if json {
+ b.WriteString(" `json:\"" + field.Name + "\"`")
+ }
+ b.WriteString("\n")
+ }
+ for i := 0; i < ident; i++ {
+ b.WriteString("\t")
+ }
+ b.WriteString("}")
+ }
+}
+
+func generateTemplate(description string) (string, []byte, error) {
+ description = strings.TrimRight(description, "\n")
+
+ midl, err := idl.New(description)
+ if err != nil {
+ return "", nil, err
+ }
+
+ pkgname := strings.Replace(midl.Name, ".", "", -1)
+
+ var b bytes.Buffer
+ b.WriteString("// Generated with github.com/varlink/go/cmd/varlink-go-interface-generator\n")
+ b.WriteString("package " + pkgname + "\n\n")
+ b.WriteString(`import "github.com/varlink/go/varlink"` + "\n\n")
+
+ // Type declarations
+ for _, a := range midl.Aliases {
+ b.WriteString("type " + a.Name + " ")
+ writeType(&b, a.Type, true, 0)
+ b.WriteString("\n\n")
+ }
+
+ // Local interface with all methods
+ b.WriteString("type " + pkgname + "Interface interface {\n")
+ for _, m := range midl.Methods {
+ b.WriteString("\t" + m.Name + "(c VarlinkCall")
+ for _, field := range m.In.Fields {
+ b.WriteString(", " + strings.Title(field.Name) + " ")
+ writeType(&b, field.Type, false, 1)
+ }
+ b.WriteString(") error\n")
+ }
+ b.WriteString("}\n\n")
+
+ // Local object with all methods
+ b.WriteString("type VarlinkCall struct{ varlink.Call }\n\n")
+
+ // Reply methods for all varlink errors
+ for _, e := range midl.Errors {
+ b.WriteString("func (c *VarlinkCall) Reply" + e.Name + "(")
+ for i, field := range e.Type.Fields {
+ if i > 0 {
+ b.WriteString(", ")
+ }
+ b.WriteString(sanitizeGoName(field.Name) + " ")
+ writeType(&b, field.Type, false, 1)
+ }
+ b.WriteString(") error {\n")
+ if len(e.Type.Fields) > 0 {
+ b.WriteString("\tvar out ")
+ writeType(&b, e.Type, true, 1)
+ b.WriteString("\n")
+ for _, field := range e.Type.Fields {
+ switch field.Type.Kind {
+ case idl.TypeStruct, idl.TypeArray:
+ b.WriteString("\tout." + strings.Title(field.Name) + " = ")
+ writeType(&b, field.Type, true, 1)
+ b.WriteString("(" + sanitizeGoName(field.Name) + ")\n")
+
+ default:
+ b.WriteString("\tout." + strings.Title(field.Name) + " = " + sanitizeGoName(field.Name) + "\n")
+ }
+ }
+ b.WriteString("\treturn c.ReplyError(\"" + midl.Name + "." + e.Name + "\", &out)\n")
+ } else {
+ b.WriteString("\treturn c.ReplyError(\"" + midl.Name + "." + e.Name + "\", nil)\n")
+ }
+ b.WriteString("}\n\n")
+ }
+
+ // Reply methods for all varlink methods
+ for _, m := range midl.Methods {
+ b.WriteString("func (c *VarlinkCall) Reply" + m.Name + "(")
+ for i, field := range m.Out.Fields {
+ if i > 0 {
+ b.WriteString(", ")
+ }
+ b.WriteString(sanitizeGoName(field.Name) + " ")
+ writeType(&b, field.Type, false, 1)
+ }
+ b.WriteString(") error {\n")
+ if len(m.Out.Fields) > 0 {
+ b.WriteString("\tvar out ")
+ writeType(&b, m.Out, true, 1)
+ b.WriteString("\n")
+ for _, field := range m.Out.Fields {
+ switch field.Type.Kind {
+ case idl.TypeStruct, idl.TypeArray:
+ b.WriteString("\tout." + strings.Title(field.Name) + " = ")
+ writeType(&b, field.Type, true, 1)
+ b.WriteString("(" + sanitizeGoName(field.Name) + ")\n")
+
+ default:
+ b.WriteString("\tout." + strings.Title(field.Name) + " = " + sanitizeGoName(field.Name) + "\n")
+ }
+ }
+ b.WriteString("\treturn c.Reply(&out)\n")
+ } else {
+ b.WriteString("\treturn c.Reply(nil)\n")
+ }
+ b.WriteString("}\n\n")
+ }
+
+ // Dummy methods for all varlink methods
+ for _, m := range midl.Methods {
+ b.WriteString("func (s *VarlinkInterface) " + m.Name + "(c VarlinkCall")
+ for _, field := range m.In.Fields {
+ b.WriteString(", " + sanitizeGoName(field.Name) + " ")
+ writeType(&b, field.Type, false, 1)
+ }
+ b.WriteString(") error {\n" +
+ "\treturn c.ReplyMethodNotImplemented(\"" + m.Name + "\")\n" +
+ "}\n\n")
+ }
+
+ // Method call dispatcher
+ b.WriteString("func (s *VarlinkInterface) VarlinkDispatch(call varlink.Call, methodname string) error {\n" +
+ "\tswitch methodname {\n")
+ for _, m := range midl.Methods {
+ b.WriteString("\tcase \"" + m.Name + "\":\n")
+ if len(m.In.Fields) > 0 {
+ b.WriteString("\t\tvar in ")
+ writeType(&b, m.In, true, 2)
+ b.WriteString("\n")
+ b.WriteString("\t\terr := call.GetParameters(&in)\n" +
+ "\t\tif err != nil {\n" +
+ "\t\t\treturn call.ReplyInvalidParameter(\"parameters\")\n" +
+ "\t\t}\n")
+ b.WriteString("\t\treturn s." + pkgname + "Interface." + m.Name + "(VarlinkCall{call}")
+ if len(m.In.Fields) > 0 {
+ for _, field := range m.In.Fields {
+ switch field.Type.Kind {
+ case idl.TypeStruct, idl.TypeArray:
+ b.WriteString(", ")
+ writeType(&b, field.Type, false, 2)
+ b.WriteString("(in." + strings.Title(field.Name) + ")")
+
+ default:
+ b.WriteString(", in." + strings.Title(field.Name))
+ }
+ }
+ }
+ b.WriteString(")\n")
+ } else {
+ b.WriteString("\t\treturn s." + pkgname + "Interface." + m.Name + "(VarlinkCall{call})\n")
+ }
+ b.WriteString("\n")
+ }
+ b.WriteString("\tdefault:\n" +
+ "\t\treturn call.ReplyMethodNotFound(methodname)\n" +
+ "\t}\n" +
+ "}\n")
+
+ // Varlink interface name
+ b.WriteString("func (s *VarlinkInterface) VarlinkGetName() string {\n" +
+ "\treturn `" + midl.Name + "`\n" + "}\n\n")
+
+ // Varlink interface description
+ b.WriteString("func (s *VarlinkInterface) VarlinkGetDescription() string {\n" +
+ "\treturn `" + midl.Description + "\n`\n}\n\n")
+
+ b.WriteString("type VarlinkInterface struct {\n" +
+ "\t" + pkgname + "Interface\n" +
+ "}\n\n")
+
+ b.WriteString("func VarlinkNew(m " + pkgname + "Interface) *VarlinkInterface {\n" +
+ "\treturn &VarlinkInterface{m}\n" +
+ "}\n")
+
+ return pkgname, b.Bytes(), nil
+}
+
+func generateFile(varlinkFile string) {
+ file, err := ioutil.ReadFile(varlinkFile)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Error reading file '%s': %s\n", varlinkFile, err)
+ os.Exit(1)
+ }
+
+ pkgname, b, err := generateTemplate(string(file))
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Error parsing file '%s': %s\n", varlinkFile, err)
+ os.Exit(1)
+ }
+
+ filename := path.Dir(varlinkFile) + "/" + pkgname + ".go"
+ err = ioutil.WriteFile(filename, b, 0660)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Error writing file '%s': %s\n", filename, err)
+ os.Exit(1)
+ }
+}
+
+func main() {
+ if len(os.Args) != 2 {
+ fmt.Printf("Usage: %s <file>\n", os.Args[0])
+ os.Exit(1)
+ }
+ generateFile(os.Args[1])
+}
diff --git a/vendor/github.com/varlink/go/cmd/varlink-go-type-generator/main.go b/vendor/github.com/varlink/go/cmd/varlink-go-type-generator/main.go
new file mode 100644
index 000000000..dfbec5fb2
--- /dev/null
+++ b/vendor/github.com/varlink/go/cmd/varlink-go-type-generator/main.go
@@ -0,0 +1,142 @@
+package main
+
+import (
+ "fmt"
+ "go/ast"
+ "go/importer"
+ "go/parser"
+ "go/token"
+ "go/types"
+ "log"
+ "os"
+)
+
+func GoToVarlinkType(t types.Type) string {
+ switch u := t.(type) {
+ case *types.Basic:
+ if u.Info()&types.IsBoolean != 0 {
+ return "bool"
+ }
+ if u.Info()&types.IsInteger != 0 {
+ return "int"
+ }
+ if u.Info()&types.IsFloat != 0 {
+ return "float"
+ }
+ if u.Info()&types.IsString != 0 {
+ return "string"
+ }
+ return fmt.Sprintf("<<<%s>>>", t.String())
+
+ case *types.Named:
+ return u.Obj().Name()
+
+ case *types.Map:
+ return fmt.Sprintf("<<<%s>>>", u.String())
+
+ case *types.Interface:
+ return fmt.Sprintf("<<<%s>>>", u.String())
+
+ case *types.Pointer:
+ return fmt.Sprintf("?%s", GoToVarlinkType(u.Elem()))
+
+ case *types.Array:
+ return fmt.Sprintf("[]%s", GoToVarlinkType(u.Elem()))
+
+ case *types.Slice:
+ return fmt.Sprintf("[]%s", GoToVarlinkType(u.Elem()))
+
+ default:
+ return fmt.Sprintf("<<<%T %s>>>", t, u)
+ }
+
+ return t.String()
+}
+
+func PrintDefsUses(name string, fset *token.FileSet, files []*ast.File) error {
+ conf := types.Config{
+ Importer: importer.Default(),
+ FakeImportC: true,
+ }
+
+ info := &types.Info{
+ Defs: make(map[*ast.Ident]types.Object),
+ }
+
+ _, err := conf.Check(name, fset, files, info)
+ if err != nil {
+ return err // type error
+ }
+
+ seen := map[string]interface{}{}
+
+ for id, obj := range info.Defs {
+ if obj == nil {
+ continue
+ }
+
+ if _, ok := seen[id.Name]; ok {
+ continue
+ }
+
+ /*
+ if !obj.Exported() || obj.Pkg().Name() != name {
+ continue
+ }
+ */
+ switch f := obj.Type().Underlying().(type) {
+ case *types.Struct:
+ if f.NumFields() > 0 {
+ fmt.Printf("type %s (\n", id.Name)
+ fmt.Printf("\t%s: %s",
+ f.Field(0).Name(), GoToVarlinkType(f.Field(0).Type()))
+ for i := 1; i < f.NumFields(); i++ {
+ fmt.Printf(",\n\t%s: %s",
+ f.Field(i).Name(), GoToVarlinkType(f.Field(i).Type()))
+ }
+ fmt.Printf("\n)\n\n")
+ }
+ }
+ seen[id.Name] = nil
+ }
+
+ return nil
+}
+
+func main() {
+
+ path := os.Args[1]
+ fs := token.NewFileSet()
+
+ if stat, err := os.Stat(path); err == nil && stat.IsDir() {
+ pkgs, err := parser.ParseDir(fs, path, nil, 0)
+ if err != nil {
+ fmt.Printf("parsing dir '%s': %s", path, err)
+ }
+ for name, pkg := range pkgs {
+ log.Println("Found package:", name)
+
+ fset := make([]*ast.File, len(pkg.Files), len(pkg.Files))
+ idx := 0
+ for _, value := range pkg.Files {
+ fset[idx] = value
+ idx++
+ }
+
+ if err := PrintDefsUses(name, fs, fset); err != nil {
+ log.Print(err) // type error
+ }
+ }
+ } else {
+
+ fset, err := parser.ParseFile(fs, path, nil, 0)
+
+ if err != nil {
+ fmt.Printf("parsing file '%s': %s", path, err)
+ }
+ name := fset.Name.String()
+ if err := PrintDefsUses(name, fs, []*ast.File{fset}); err != nil {
+ log.Print(err) // type error
+ }
+ }
+}
diff --git a/vendor/github.com/varlink/go/golang-github-varlink-go.spec b/vendor/github.com/varlink/go/golang-github-varlink-go.spec
new file mode 100644
index 000000000..85f5d1788
--- /dev/null
+++ b/vendor/github.com/varlink/go/golang-github-varlink-go.spec
@@ -0,0 +1,44 @@
+%global goipath github.com/varlink/go
+Version: 0
+%gometa
+
+Name: %{goname}
+Release: 1%{?dist}
+Summary: Go bindings for varlink
+License: ASL 2.0
+URL: %{gourl}
+Source0: %{gosource}
+
+%description
+Native Go bindings for the varlink protocol.
+
+%package devel
+Summary: %{summary}
+BuildArch: noarch
+
+%description devel
+%{summary}
+
+This package contains library source intended for
+building other packages which use import path with
+%{gobaseipath} prefix.
+
+%prep
+%forgesetup
+
+%build
+%gobuildroot
+
+%install
+gofiles=$(find . %{gofindfilter} -print)
+%goinstall $gofiles
+
+%check
+
+%files devel -f devel.file-list
+%license LICENSE
+%doc README.md
+
+%changelog
+* Tue Mar 20 2018 <info@varlink.org> 0-1
+- Version 0
diff --git a/vendor/github.com/varlink/go/varlink/call.go b/vendor/github.com/varlink/go/varlink/call.go
new file mode 100644
index 000000000..c5d7cf7fd
--- /dev/null
+++ b/vendor/github.com/varlink/go/varlink/call.go
@@ -0,0 +1,86 @@
+package varlink
+
+import (
+ "bufio"
+ "encoding/json"
+ "fmt"
+ "strings"
+)
+
+// Call is a method call retrieved by a Service. The connection from the
+// client can be terminated by returning an error from the call instead
+// of sending a reply or error reply.
+type Call struct {
+ writer *bufio.Writer
+ in *serviceCall
+ Continues bool
+}
+
+// WantsMore indicates if the calling client accepts more than one reply to this method call.
+func (c *Call) WantsMore() bool {
+ return c.in.More
+}
+
+// IsOneShot indicate that the calling client does not expect a reply.
+func (c *Call) IsOneShot() bool {
+ return c.in.OneShot
+}
+
+// GetParameters retrieves the method call parameters.
+func (c *Call) GetParameters(p interface{}) error {
+ if c.in.Parameters == nil {
+ return fmt.Errorf("empty parameters")
+ }
+ return json.Unmarshal(*c.in.Parameters, p)
+}
+
+func (c *Call) sendMessage(r *serviceReply) error {
+ if c.in.OneShot {
+ return nil
+ }
+
+ b, e := json.Marshal(r)
+ if e != nil {
+ return e
+ }
+
+ b = append(b, 0)
+ _, e = c.writer.Write(b)
+ if e != nil {
+ return e
+ }
+ return c.writer.Flush()
+}
+
+// Reply sends a reply to this method call.
+func (c *Call) Reply(parameters interface{}) error {
+ if !c.Continues {
+ return c.sendMessage(&serviceReply{
+ Parameters: parameters,
+ })
+ }
+
+ if !c.in.More {
+ return fmt.Errorf("call did not set more, it does not expect continues")
+ }
+
+ return c.sendMessage(&serviceReply{
+ Continues: true,
+ Parameters: parameters,
+ })
+}
+
+// ReplyError sends an error reply to this method call.
+func (c *Call) ReplyError(name string, parameters interface{}) error {
+ r := strings.LastIndex(name, ".")
+ if r <= 0 {
+ return fmt.Errorf("invalid error name")
+ }
+ if name[:r] == "org.varlink.service" {
+ return fmt.Errorf("refused to send org.varlink.service errors")
+ }
+ return c.sendMessage(&serviceReply{
+ Error: name,
+ Parameters: parameters,
+ })
+}
diff --git a/vendor/github.com/varlink/go/varlink/connection.go b/vendor/github.com/varlink/go/varlink/connection.go
new file mode 100644
index 000000000..2445072b6
--- /dev/null
+++ b/vendor/github.com/varlink/go/varlink/connection.go
@@ -0,0 +1,197 @@
+package varlink
+
+import (
+ "bufio"
+ "encoding/json"
+ "net"
+ "strings"
+)
+
+// Error is a varlink error returned from a method call.
+type Error struct {
+ Name string
+ Parameters interface{}
+}
+
+// Error returns the fully-qualified varlink error name.
+func (e *Error) Error() string {
+ return e.Name
+}
+
+// Connection is a connection from a client to a service.
+type Connection struct {
+ address string
+ conn net.Conn
+ reader *bufio.Reader
+ writer *bufio.Writer
+}
+
+// Send sends a method call.
+func (c *Connection) Send(method string, parameters interface{}, more bool) error {
+ type call struct {
+ Method string `json:"method"`
+ Parameters interface{} `json:"parameters,omitempty"`
+ More bool `json:"more,omitempty"`
+ OneShot bool `json:"oneshot,omitempty"`
+ }
+ m := call{
+ Method: method,
+ Parameters: parameters,
+ More: more,
+ }
+ b, err := json.Marshal(m)
+ if err != nil {
+ return err
+ }
+
+ b = append(b, 0)
+ _, err = c.writer.Write(b)
+ if err != nil {
+ return err
+ }
+
+ return c.writer.Flush()
+}
+
+// Receive receives a method reply.
+func (c *Connection) Receive(parameters interface{}, continues *bool, oneshot *bool) error {
+ type reply struct {
+ Parameters *json.RawMessage `json:"parameters"`
+ Continues bool `json:"continues"`
+ Oneshot bool `json:"oneshot"`
+ Error string `json:"error"`
+ }
+
+ out, err := c.reader.ReadBytes('\x00')
+ if err != nil {
+ return err
+ }
+
+ var m reply
+ err = json.Unmarshal(out[:len(out)-1], &m)
+ if err != nil {
+ return err
+ }
+
+ if m.Error != "" {
+ return &Error{
+ Name: m.Error,
+ Parameters: m.Parameters,
+ }
+ }
+
+ if continues != nil {
+ *continues = m.Continues
+ }
+ if oneshot != nil {
+ *oneshot = m.Oneshot
+ }
+ if parameters != nil && m.Parameters != nil {
+ return json.Unmarshal(*m.Parameters, parameters)
+ }
+
+ return nil
+}
+
+// Call sends a method call and returns the result of the call.
+func (c *Connection) Call(method string, parameters interface{}, result interface{}) error {
+ err := c.Send(method, &parameters, false)
+ if err != nil {
+ return err
+ }
+
+ return c.Receive(result, nil, nil)
+}
+
+// GetInterfaceDescription requests the interface description string from the service.
+func (c *Connection) GetInterfaceDescription(name string) (string, error) {
+ type request struct {
+ Interface string `json:"interface"`
+ }
+ type reply struct {
+ Description string `json:"description"`
+ }
+
+ var r reply
+ err := c.Call("org.varlink.service.GetInterfaceDescription", request{Interface: name}, &r)
+ if err != nil {
+ return "", err
+ }
+
+ return r.Description, nil
+}
+
+// GetInfo requests information about the service.
+func (c *Connection) GetInfo(vendor *string, product *string, version *string, url *string, interfaces *[]string) error {
+ type reply struct {
+ Vendor string `json:"vendor"`
+ Product string `json:"product"`
+ Version string `json:"version"`
+ URL string `json:"url"`
+ Interfaces []string `json:"interfaces"`
+ }
+
+ var r reply
+ err := c.Call("org.varlink.service.GetInfo", nil, &r)
+ if err != nil {
+ return err
+ }
+
+ if vendor != nil {
+ *vendor = r.Vendor
+ }
+ if product != nil {
+ *product = r.Product
+ }
+ if version != nil {
+ *version = r.Version
+ }
+ if url != nil {
+ *url = r.URL
+ }
+ if interfaces != nil {
+ *interfaces = r.Interfaces
+ }
+
+ return nil
+}
+
+// Close terminates the connection.
+func (c *Connection) Close() error {
+ return c.conn.Close()
+}
+
+// NewConnection returns a new connection to the given address.
+func NewConnection(address string) (*Connection, error) {
+ var err error
+
+ words := strings.SplitN(address, ":", 2)
+ protocol := words[0]
+ addr := words[1]
+
+ // Ignore parameters after ';'
+ words = strings.SplitN(addr, ";", 2)
+ if words != nil {
+ addr = words[0]
+ }
+
+ switch protocol {
+ case "unix":
+ break
+
+ case "tcp":
+ break
+ }
+
+ c := Connection{}
+ c.conn, err = net.Dial(protocol, addr)
+ if err != nil {
+ return nil, err
+ }
+
+ c.address = address
+ c.reader = bufio.NewReader(c.conn)
+ c.writer = bufio.NewWriter(c.conn)
+
+ return &c, nil
+}
diff --git a/vendor/github.com/varlink/go/varlink/doc.go b/vendor/github.com/varlink/go/varlink/doc.go
new file mode 100644
index 000000000..de1ed2380
--- /dev/null
+++ b/vendor/github.com/varlink/go/varlink/doc.go
@@ -0,0 +1,63 @@
+/*
+Package varlink provides varlink client and server implementations. See http://varlink.org
+for more information about varlink.
+
+Example varlink interface definition in a org.example.this.varlink file:
+ interface org.example.this
+
+ method Ping(in: string) -> (out: string)
+
+Generated Go module in a orgexamplethis/orgexamplethis.go file. The generated module
+provides reply methods for all methods specified in the varlink interface description.
+The stub implementations return a MethodNotImplemented error; the service implementation
+using this module will override the methods with its own implementation.
+ // Generated with github.com/varlink/go/cmd/varlink-go-interface-generator
+ package orgexamplethis
+
+ import "github.com/varlink/go/varlink"
+
+ type orgexamplethisInterface interface {
+ Ping(c VarlinkCall, in string) error
+ }
+
+ type VarlinkCall struct{ varlink.Call }
+
+ func (c *VarlinkCall) ReplyPing(out string) error {
+ var out struct {
+ Out string `json:"out,omitempty"`
+ }
+ out.Out = out
+ return c.Reply(&out)
+ }
+
+ func (s *VarlinkInterface) Ping(c VarlinkCall, in string) error {
+ return c.ReplyMethodNotImplemented("Ping")
+ }
+
+ [...]
+
+Service implementing the interface and its method:
+ import ("orgexamplethis")
+
+ type Data struct {
+ orgexamplethis.VarlinkInterface
+ data string
+ }
+
+ data := Data{data: "test"}
+
+ func (d *Data) Ping(call orgexamplethis.VarlinkCall, ping string) error {
+ return call.ReplyPing(ping)
+ }
+
+ service, _ = varlink.NewService(
+ "Example",
+ "This",
+ "1",
+ "https://example.org/this",
+ )
+
+ service.RegisterInterface(orgexamplethis.VarlinkNew(&data))
+ err := service.Listen("unix:/run/org.example.this", 0)
+*/
+package varlink
diff --git a/vendor/github.com/varlink/go/varlink/external_test.go b/vendor/github.com/varlink/go/varlink/external_test.go
new file mode 100644
index 000000000..dbe4290e6
--- /dev/null
+++ b/vendor/github.com/varlink/go/varlink/external_test.go
@@ -0,0 +1,144 @@
+package varlink_test
+
+// test with no internal access
+
+import (
+ "github.com/varlink/go/varlink"
+ "os"
+ "testing"
+ "time"
+)
+
+type VarlinkInterface struct{}
+
+func (s *VarlinkInterface) VarlinkDispatch(call varlink.Call, methodname string) error {
+ return call.ReplyMethodNotImplemented(methodname)
+}
+func (s *VarlinkInterface) VarlinkGetName() string {
+ return `org.example.test`
+}
+
+func (s *VarlinkInterface) VarlinkGetDescription() string {
+ return "#"
+}
+
+type VarlinkInterface2 struct{}
+
+func (s *VarlinkInterface2) VarlinkDispatch(call varlink.Call, methodname string) error {
+ return call.ReplyMethodNotImplemented(methodname)
+}
+func (s *VarlinkInterface2) VarlinkGetName() string {
+ return `org.example.test2`
+}
+
+func (s *VarlinkInterface2) VarlinkGetDescription() string {
+ return "#"
+}
+
+func TestRegisterService(t *testing.T) {
+ newTestInterface := new(VarlinkInterface)
+ service, err := varlink.NewService(
+ "Varlink",
+ "Varlink Test",
+ "1",
+ "https://github.com/varlink/go/varlink",
+ )
+ if err != nil {
+ t.Fatalf("NewService(): %v", err)
+ }
+
+ if err := service.RegisterInterface(newTestInterface); err != nil {
+ t.Fatalf("Couldn't register service: %v", err)
+ }
+
+ if err := service.RegisterInterface(newTestInterface); err == nil {
+ t.Fatal("Could register service twice")
+ }
+
+ defer func() { service.Shutdown() }()
+
+ servererror := make(chan error)
+
+ go func() {
+ servererror <- service.Listen("unix:@varlinkexternal_TestRegisterService", 0)
+ }()
+
+ time.Sleep(time.Second / 5)
+
+ n := new(VarlinkInterface2)
+
+ if err := service.RegisterInterface(n); err == nil {
+ t.Fatal("Could register service while running")
+ }
+ time.Sleep(time.Second / 5)
+ service.Shutdown()
+
+ if err := <-servererror; err != nil {
+ t.Fatalf("service.Listen(): %v", err)
+ }
+}
+
+func TestUnix(t *testing.T) {
+ newTestInterface := new(VarlinkInterface)
+ service, err := varlink.NewService(
+ "Varlink",
+ "Varlink Test",
+ "1",
+ "https://github.com/varlink/go/varlink",
+ )
+
+ if err != nil {
+ t.Fatalf("NewService(): %v", err)
+ }
+
+ if err := service.RegisterInterface(newTestInterface); err != nil {
+ t.Fatalf("RegisterInterface(): %v", err)
+ }
+
+ servererror := make(chan error)
+
+ go func() {
+ servererror <- service.Listen("unix:varlinkexternal_TestUnix", 0)
+ }()
+
+ time.Sleep(time.Second / 5)
+ service.Shutdown()
+
+ if err := <-servererror; err != nil {
+ t.Fatalf("service.Listen(): %v", err)
+ }
+}
+
+func TestListenFDSNotInt(t *testing.T) {
+ newTestInterface := new(VarlinkInterface)
+ service, err := varlink.NewService(
+ "Varlink",
+ "Varlink Test",
+ "1",
+ "https://github.com/varlink/go/varlink",
+ )
+
+ if err != nil {
+ t.Fatalf("NewService(): %v", err)
+ }
+
+ if err := service.RegisterInterface(newTestInterface); err != nil {
+ t.Fatalf("Couldn't register service: %v", err)
+ }
+ os.Setenv("LISTEN_FDS", "foo")
+
+ servererror := make(chan error)
+
+ go func() {
+ servererror <- service.Listen("unix:varlinkexternal_TestListenFDSNotInt", 0)
+ }()
+
+ time.Sleep(time.Second / 5)
+ service.Shutdown()
+
+ err = <-servererror
+
+ if err != nil {
+ t.Fatalf("service.Run(): %v", err)
+ }
+}
diff --git a/vendor/github.com/varlink/go/varlink/idl/idl.go b/vendor/github.com/varlink/go/varlink/idl/idl.go
new file mode 100644
index 000000000..27f21a759
--- /dev/null
+++ b/vendor/github.com/varlink/go/varlink/idl/idl.go
@@ -0,0 +1,465 @@
+// Package idl provides a varlink interface description parser.
+package idl
+
+import (
+ "bytes"
+ "fmt"
+ "regexp"
+)
+
+// Valid TypeKind values.
+const (
+ TypeBool = iota
+ TypeInt
+ TypeFloat
+ TypeString
+ TypeArray
+ TypeMaybe
+ TypeStruct
+ TypeEnum
+ TypeAlias
+)
+
+// TypeKind specifies the type of an Type.
+type TypeKind uint
+
+// Type represents a varlink type. Types are method input and output parameters,
+// error output parameters, or custom defined types in the interface description.
+type Type struct {
+ Kind TypeKind
+ ElementType *Type
+ Alias string
+ Fields []TypeField
+}
+
+// TypeField is a named member of a TypeStruct.
+type TypeField struct {
+ Name string
+ Type *Type
+}
+
+// Alias represents a named Type in the interface description.
+type Alias struct {
+ Name string
+ Doc string
+ Type *Type
+}
+
+// Method represents a method defined in the interface description.
+type Method struct {
+ Name string
+ Doc string
+ In *Type
+ Out *Type
+}
+
+// Error represents an error defined in the interface description.
+type Error struct {
+ Name string
+ Type *Type
+}
+
+// IDL represents a parsed varlink interface description with types, methods, errors and
+// documentation.
+type IDL struct {
+ Name string
+ Doc string
+ Description string
+ Members []interface{}
+ Aliases map[string]*Alias
+ Methods map[string]*Method
+ Errors map[string]*Error
+}
+
+type parser struct {
+ input string
+ position int
+ lineStart int
+ lastComment bytes.Buffer
+}
+
+func (p *parser) next() int {
+ r := -1
+
+ if p.position < len(p.input) {
+ r = int(p.input[p.position])
+ }
+
+ p.position++
+ return r
+}
+
+func (p *parser) backup() {
+ p.position--
+}
+
+func (p *parser) advance() bool {
+ for {
+ char := p.next()
+
+ if char == '\n' {
+ p.lineStart = p.position
+ p.lastComment.Reset()
+
+ } else if char == ' ' || char == '\t' {
+ // ignore
+
+ } else if char == '#' {
+ p.next()
+ start := p.position
+ for {
+ c := p.next()
+ if c < 0 || c == '\n' {
+ p.backup()
+ break
+ }
+ }
+ if p.lastComment.Len() > 0 {
+ p.lastComment.WriteByte('\n')
+ }
+ p.lastComment.WriteString(p.input[start:p.position])
+ p.next()
+
+ } else {
+ p.backup()
+ break
+ }
+ }
+
+ return p.position < len(p.input)
+}
+
+func (p *parser) advanceOnLine() {
+ for {
+ char := p.next()
+ if char != ' ' {
+ p.backup()
+ return
+ }
+ }
+}
+
+func (p *parser) readKeyword() string {
+ start := p.position
+
+ for {
+ char := p.next()
+ if char < 'a' || char > 'z' {
+ p.backup()
+ break
+ }
+ }
+
+ return p.input[start:p.position]
+}
+
+func (p *parser) readInterfaceName() string {
+ start := p.position
+ dnrx := regexp.MustCompile(`^[a-z]+(\.[a-z0-9]+([-][a-z0-9]+)*)+`)
+ name := dnrx.FindString(p.input[start:])
+ if name != "" {
+ if len(name) > 255 {
+ return ""
+ }
+ p.position += len(name)
+ return name
+ }
+ xdnrx := regexp.MustCompile(`^xn--[a-z0-9]+(\.[a-z0-9]+([-][a-z0-9]+)*)+`)
+ name = xdnrx.FindString(p.input[start:])
+ if name != "" {
+ if len(name) > 255 {
+ return ""
+ }
+ p.position += len(name)
+ return name
+ }
+ return ""
+}
+
+func (p *parser) readFieldName() string {
+ start := p.position
+
+ char := p.next()
+ if char < 'a' || char > 'z' {
+ p.backup()
+ return ""
+ }
+
+ for {
+ char := p.next()
+ if (char < 'A' || char > 'Z') && (char < 'a' || char > 'z') && (char < '0' || char > '9') && char != '_' {
+ p.backup()
+ break
+ }
+ }
+
+ return p.input[start:p.position]
+}
+
+func (p *parser) readTypeName() string {
+ start := p.position
+
+ for {
+ char := p.next()
+ if (char < 'A' || char > 'Z') && (char < 'a' || char > 'z') && (char < '0' || char > '9') {
+ p.backup()
+ break
+ }
+ }
+
+ return p.input[start:p.position]
+}
+
+func (p *parser) readStructType() *Type {
+ if p.next() != '(' {
+ p.backup()
+ return nil
+ }
+
+ t := &Type{Kind: TypeStruct}
+ t.Fields = make([]TypeField, 0)
+
+ char := p.next()
+ if char != ')' {
+ p.backup()
+
+ for {
+ field := TypeField{}
+
+ p.advance()
+ field.Name = p.readFieldName()
+ if field.Name == "" {
+ return nil
+ }
+
+ p.advance()
+
+ // Enums have no types, they are just a list of names
+ if p.next() == ':' {
+ if t.Kind == TypeEnum {
+ return nil
+ }
+
+ p.advance()
+ field.Type = p.readType()
+ if field.Type == nil {
+ return nil
+ }
+
+ } else {
+ t.Kind = TypeEnum
+ p.backup()
+ }
+
+ t.Fields = append(t.Fields, field)
+
+ p.advance()
+ char = p.next()
+ if char != ',' {
+ break
+ }
+ }
+
+ if char != ')' {
+ return nil
+ }
+ }
+
+ return t
+}
+
+func (p *parser) readType() *Type {
+ var t *Type
+
+ switch p.next() {
+ case '?':
+ e := p.readType()
+ if e == nil {
+ return nil
+ }
+ t = &Type{Kind: TypeMaybe, ElementType: e}
+
+ case '[':
+ if p.next() != ']' {
+ return nil
+ }
+ e := p.readType()
+ if e == nil {
+ return nil
+ }
+ t = &Type{Kind: TypeArray, ElementType: e}
+
+ default:
+ p.backup()
+ if keyword := p.readKeyword(); keyword != "" {
+ switch keyword {
+ case "bool":
+ t = &Type{Kind: TypeBool}
+
+ case "int":
+ t = &Type{Kind: TypeInt}
+
+ case "float":
+ t = &Type{Kind: TypeFloat}
+
+ case "string":
+ t = &Type{Kind: TypeString}
+ }
+
+ } else if name := p.readTypeName(); name != "" {
+ t = &Type{Kind: TypeAlias, Alias: name}
+
+ } else if t = p.readStructType(); t == nil {
+ return nil
+ }
+ }
+
+ return t
+}
+
+func (p *parser) readAlias(idl *IDL) (*Alias, error) {
+ a := &Alias{}
+
+ p.advance()
+ a.Doc = p.lastComment.String()
+ a.Name = p.readTypeName()
+ if a.Name == "" {
+ return nil, fmt.Errorf("missing type name")
+ }
+
+ p.advance()
+ a.Type = p.readType()
+ if a.Type == nil {
+ return nil, fmt.Errorf("missing type declaration")
+ }
+
+ return a, nil
+}
+
+func (p *parser) readMethod(idl *IDL) (*Method, error) {
+ m := &Method{}
+
+ p.advance()
+ m.Doc = p.lastComment.String()
+ m.Name = p.readTypeName()
+ if m.Name == "" {
+ return nil, fmt.Errorf("missing method type")
+ }
+
+ p.advance()
+ m.In = p.readType()
+ if m.In == nil {
+ return nil, fmt.Errorf("missing method input")
+ }
+
+ p.advance()
+ one := p.next()
+ two := p.next()
+ if (one != '-') || two != '>' {
+ return nil, fmt.Errorf("missing method '->' operator")
+ }
+
+ p.advance()
+ m.Out = p.readType()
+ if m.Out == nil {
+ return nil, fmt.Errorf("missing method output")
+ }
+
+ return m, nil
+}
+
+func (p *parser) readError(idl *IDL) (*Error, error) {
+ e := &Error{}
+
+ p.advance()
+ e.Name = p.readTypeName()
+ if e.Name == "" {
+ return nil, fmt.Errorf("missing error name")
+ }
+
+ p.advanceOnLine()
+ e.Type = p.readType()
+
+ return e, nil
+}
+
+func (p *parser) readIDL() (*IDL, error) {
+ if keyword := p.readKeyword(); keyword != "interface" {
+ return nil, fmt.Errorf("missing interface keyword")
+ }
+
+ idl := &IDL{
+ Members: make([]interface{}, 0),
+ Aliases: make(map[string]*Alias),
+ Methods: make(map[string]*Method),
+ Errors: make(map[string]*Error),
+ }
+
+ p.advance()
+ idl.Doc = p.lastComment.String()
+ idl.Name = p.readInterfaceName()
+ if idl.Name == "" {
+ return nil, fmt.Errorf("interface name")
+ }
+
+ for {
+ if !p.advance() {
+ break
+ }
+
+ switch keyword := p.readKeyword(); keyword {
+ case "type":
+ a, err := p.readAlias(idl)
+ if err != nil {
+ return nil, err
+ }
+
+ idl.Members = append(idl.Members, a)
+ idl.Aliases[a.Name] = a
+
+ case "method":
+ m, err := p.readMethod(idl)
+ if err != nil {
+ return nil, err
+ }
+
+ idl.Members = append(idl.Members, m)
+ if _, ok := idl.Methods[m.Name]; ok {
+ return nil, fmt.Errorf("method `%s` already defined", m.Name)
+ }
+ idl.Methods[m.Name] = m
+
+ case "error":
+ e, err := p.readError(idl)
+ if err != nil {
+ return nil, err
+ }
+
+ idl.Members = append(idl.Members, e)
+ idl.Errors[e.Name] = e
+
+ default:
+ return nil, fmt.Errorf("unknown keyword '%s'", keyword)
+ }
+ }
+
+ return idl, nil
+}
+
+// New parses a varlink interface description.
+func New(description string) (*IDL, error) {
+ p := &parser{input: description}
+
+ p.advance()
+ idl, err := p.readIDL()
+ if err != nil {
+ return nil, err
+ }
+
+ if len(idl.Methods) == 0 {
+ return nil, fmt.Errorf("no methods defined")
+ }
+
+ idl.Description = description
+ return idl, nil
+}
diff --git a/vendor/github.com/varlink/go/varlink/idl/idl_test.go b/vendor/github.com/varlink/go/varlink/idl/idl_test.go
new file mode 100644
index 000000000..5d83d5890
--- /dev/null
+++ b/vendor/github.com/varlink/go/varlink/idl/idl_test.go
@@ -0,0 +1,127 @@
+package idl
+
+import (
+ "fmt"
+ "runtime"
+ "testing"
+)
+
+/*
+func expect(t *testing.T, expected string, returned string) {
+ if strings.Compare(returned, expected) != 0 {
+ t.Fatalf("Expected(%d): `%s`\nGot(%d): `%s`\n",
+ len(expected), expected,
+ len(returned), returned)
+ }
+}
+*/
+
+func testParse(t *testing.T, pass bool, description string) {
+ _, _, line, _ := runtime.Caller(1)
+
+ t.Run(fmt.Sprintf("Line-%d", line), func(t *testing.T) {
+ midl, err := New(description)
+ if pass {
+ if err != nil {
+ t.Fatalf("generateTemplate(`%s`): %v", description, err)
+ }
+ if len(midl.Name) <= 0 {
+ t.Fatalf("generateTemplate(`%s`): returned no pkgname", description)
+ }
+ }
+ if !pass && (err == nil) {
+ t.Fatalf("generateTemplate(`%s`): did not fail", description)
+ }
+ })
+}
+
+func TestOneMethod(t *testing.T) {
+ testParse(t, true, "interface foo.bar\nmethod Foo()->()")
+}
+
+func TestOneMethodNoType(t *testing.T) {
+ testParse(t, false, "interface foo.bar\nmethod Foo()->(b:)")
+}
+
+func TestDomainNames(t *testing.T) {
+ testParse(t, true, "interface org.varlink.service\nmethod F()->()")
+ testParse(t, true, "interface com.example.0example\nmethod F()->()")
+ testParse(t, true, "interface com.example.example-dash\nmethod F()->()")
+ testParse(t, true, "interface xn--lgbbat1ad8j.example.algeria\nmethod F()->()")
+ testParse(t, false, "interface com.-example.leadinghyphen\nmethod F()->()")
+ testParse(t, false, "interface com.example-.danglinghyphen-\nmethod F()->()")
+ testParse(t, false, "interface Com.example.uppercase-toplevel\nmethod F()->()")
+ testParse(t, false, "interface Co9.example.number-toplevel\nmethod F()->()")
+ testParse(t, false, "interface 1om.example.number-toplevel\nmethod F()->()")
+ testParse(t, false, "interface com.Example\nmethod F()->()")
+ var name string
+ for i := 0; i < 255; i++ {
+ name += "a"
+ }
+ testParse(t, false, "interface com.example.toolong"+name+"\nmethod F()->()")
+ testParse(t, false, "interface xn--example.toolong"+name+"\nmethod F()->()")
+}
+
+func TestNoMethod(t *testing.T) {
+ testParse(t, false, `
+interface org.varlink.service
+ type Interface (name: string, types: []Type, methods: []Method)
+ type Property (key: string, value: string)
+`)
+}
+
+func TestTypeNoArgs(t *testing.T) {
+ testParse(t, true, "interface foo.bar\n type I ()\nmethod F()->()")
+}
+
+func TestTypeOneArg(t *testing.T) {
+ testParse(t, true, "interface foo.bar\n type I (b:bool)\nmethod F()->()")
+}
+
+func TestTypeOneArray(t *testing.T) {
+ testParse(t, true, "interface foo.bar\n type I (b:[]bool)\nmethod F()->()")
+ testParse(t, false, "interface foo.bar\n type I (b:bool[ ])\nmethod F()->()")
+ testParse(t, false, "interface foo.bar\n type I (b:bool[1])\nmethod F()->()")
+ testParse(t, false, "interface foo.bar\n type I (b:bool[ 1 ])\nmethod F()->()")
+ testParse(t, false, "interface foo.bar\n type I (b:bool[ 1 1 ])\nmethod F()->()")
+}
+
+func TestFieldnames(t *testing.T) {
+ testParse(t, false, "interface foo.bar\n type I (Test:[]bool)\nmethod F()->()")
+ testParse(t, false, "interface foo.bar\n type I (_test:[]bool)\nmethod F()->()")
+ testParse(t, false, "interface foo.bar\n type I (Äest:[]bool)\nmethod F()->()")
+}
+func TestNestedStructs(t *testing.T) {
+ testParse(t, true, "interface foo.bar\n type I ( b: [](foo: bool, bar: bool, baz: int) )\nmethod F()->()")
+}
+
+func TestEnum(t *testing.T) {
+ testParse(t, true, "interface foo.bar\n type I (b:(foo, bar, baz))\nmethod F()->()")
+ testParse(t, false, "interface foo.bar\n type I (foo, bar, baz : bool)\nmethod F()->()")
+}
+
+func TestIncomplete(t *testing.T) {
+ testParse(t, false, "interfacef foo.bar\nmethod F()->()")
+ testParse(t, false, "interface foo.bar\nmethod F()->()\ntype I (b: bool")
+ testParse(t, false, "interface foo.bar\nmethod F()->(")
+ testParse(t, false, "interface foo.bar\nmethod F(")
+ testParse(t, false, "interface foo.bar\nmethod ()->()")
+ testParse(t, false, "interface foo.bar\nmethod F->()\n")
+ testParse(t, false, "interface foo.bar\nmethod F()->\n")
+ testParse(t, false, "interface foo.bar\nmethod F()>()\n")
+ testParse(t, false, "interface foo.bar\nmethod F()->()\ntype (b: bool)")
+ testParse(t, false, "interface foo.bar\nmethod F()->()\nerror (b: bool)")
+ testParse(t, false, "interface foo.bar\nmethod F()->()\n dfghdrg")
+}
+
+func TestDuplicate(t *testing.T) {
+ testParse(t, false, `
+interface foo.example
+ type Device()
+ type Device()
+ type T()
+ type T()
+ method F() -> ()
+ method F() -> ()
+`)
+}
diff --git a/vendor/github.com/varlink/go/varlink/orgvarlinkservice.go b/vendor/github.com/varlink/go/varlink/orgvarlinkservice.go
new file mode 100644
index 000000000..39f843c31
--- /dev/null
+++ b/vendor/github.com/varlink/go/varlink/orgvarlinkservice.go
@@ -0,0 +1,133 @@
+package varlink
+
+func doReplyError(c *Call, name string, parameters interface{}) error {
+ return c.sendMessage(&serviceReply{
+ Error: name,
+ Parameters: parameters,
+ })
+}
+
+// ReplyInterfaceNotFound sends a org.varlink.service errror reply to this method call
+func (c *Call) ReplyInterfaceNotFound(interfaceA string) error {
+ var out struct {
+ Interface string `json:"interface,omitempty"`
+ }
+ out.Interface = interfaceA
+ return doReplyError(c, "org.varlink.service.InterfaceNotFound", &out)
+}
+
+// ReplyMethodNotFound sends a org.varlink.service errror reply to this method call
+func (c *Call) ReplyMethodNotFound(method string) error {
+ var out struct {
+ Method string `json:"method,omitempty"`
+ }
+ out.Method = method
+ return doReplyError(c, "org.varlink.service.MethodNotFound", &out)
+}
+
+// ReplyMethodNotImplemented sends a org.varlink.service errror reply to this method call
+func (c *Call) ReplyMethodNotImplemented(method string) error {
+ var out struct {
+ Method string `json:"method,omitempty"`
+ }
+ out.Method = method
+ return doReplyError(c, "org.varlink.service.MethodNotImplemented", &out)
+}
+
+// ReplyInvalidParameter sends a org.varlink.service errror reply to this method call
+func (c *Call) ReplyInvalidParameter(parameter string) error {
+ var out struct {
+ Parameter string `json:"parameter,omitempty"`
+ }
+ out.Parameter = parameter
+ return doReplyError(c, "org.varlink.service.InvalidParameter", &out)
+}
+
+func (c *Call) replyGetInfo(vendor string, product string, version string, url string, interfaces []string) error {
+ var out struct {
+ Vendor string `json:"vendor,omitempty"`
+ Product string `json:"product,omitempty"`
+ Version string `json:"version,omitempty"`
+ URL string `json:"url,omitempty"`
+ Interfaces []string `json:"interfaces,omitempty"`
+ }
+ out.Vendor = vendor
+ out.Product = product
+ out.Version = version
+ out.URL = url
+ out.Interfaces = interfaces
+ return c.Reply(&out)
+}
+
+func (c *Call) replyGetInterfaceDescription(description string) error {
+ var out struct {
+ Description string `json:"description,omitempty"`
+ }
+ out.Description = description
+ return c.Reply(&out)
+}
+
+func (s *Service) orgvarlinkserviceDispatch(c Call, methodname string) error {
+ switch methodname {
+ case "GetInfo":
+ return s.getInfo(c)
+ case "GetInterfaceDescription":
+ var in struct {
+ Interface string `json:"interface"`
+ }
+ err := c.GetParameters(&in)
+ if err != nil {
+ return c.ReplyInvalidParameter("parameters")
+ }
+ return s.getInterfaceDescription(c, in.Interface)
+
+ default:
+ return c.ReplyMethodNotFound(methodname)
+ }
+}
+
+func (s *orgvarlinkserviceInterface) VarlinkDispatch(call Call, methodname string) error {
+ return nil
+}
+
+func (s *orgvarlinkserviceInterface) VarlinkGetName() string {
+ return `org.varlink.service`
+}
+
+func (s *orgvarlinkserviceInterface) VarlinkGetDescription() string {
+ return `# The Varlink Service Interface is provided by every varlink service. It
+# describes the service and the interfaces it implements.
+interface org.varlink.service
+
+# Get a list of all the interfaces a service provides and information
+# about the implementation.
+method GetInfo() -> (
+ vendor: string,
+ product: string,
+ version: string,
+ url: string,
+ interfaces: []string
+)
+
+# Get the description of an interface that is implemented by this service.
+method GetInterfaceDescription(interface: string) -> (description: string)
+
+# The requested interface was not found.
+error InterfaceNotFound (interface: string)
+
+# The requested method was not found
+error MethodNotFound (method: string)
+
+# The interface defines the requested method, but the service does not
+# implement it.
+error MethodNotImplemented (method: string)
+
+# One of the passed parameters is invalid.
+error InvalidParameter (parameter: string)`
+}
+
+type orgvarlinkserviceInterface struct{}
+
+func orgvarlinkserviceNew() *orgvarlinkserviceInterface {
+ return &orgvarlinkserviceInterface{}
+}
diff --git a/vendor/github.com/varlink/go/varlink/resolver.go b/vendor/github.com/varlink/go/varlink/resolver.go
new file mode 100644
index 000000000..f0f4487d2
--- /dev/null
+++ b/vendor/github.com/varlink/go/varlink/resolver.go
@@ -0,0 +1,92 @@
+package varlink
+
+// ResolverAddress is the well-known address of the varlink interface resolver,
+// it translates varlink interface names to varlink service addresses.
+const ResolverAddress = "unix:/run/org.varlink.resolver"
+
+// Resolver resolves varlink interface names to varlink addresses
+type Resolver struct {
+ address string
+ conn *Connection
+}
+
+// Resolve resolves a varlink interface name to a varlink address.
+func (r *Resolver) Resolve(iface string) (string, error) {
+ type request struct {
+ Interface string `json:"interface"`
+ }
+ type reply struct {
+ Address string `json:"address"`
+ }
+
+ /* don't ask the resolver for itself */
+ if iface == "org.varlink.resolver" {
+ return r.address, nil
+ }
+
+ var rep reply
+ err := r.conn.Call("org.varlink.resolver.Resolve", &request{Interface: iface}, &rep)
+ if err != nil {
+ return "", err
+ }
+
+ return rep.Address, nil
+}
+
+// GetInfo requests information about the resolver.
+func (r *Resolver) GetInfo(vendor *string, product *string, version *string, url *string, interfaces *[]string) error {
+ type reply struct {
+ Vendor string
+ Product string
+ Version string
+ URL string
+ Interfaces []string
+ }
+
+ var rep reply
+ err := r.conn.Call("org.varlink.resolver.GetInfo", nil, &rep)
+ if err != nil {
+ return err
+ }
+
+ if vendor != nil {
+ *vendor = rep.Vendor
+ }
+ if product != nil {
+ *product = rep.Product
+ }
+ if version != nil {
+ *version = rep.Version
+ }
+ if url != nil {
+ *url = rep.URL
+ }
+ if interfaces != nil {
+ *interfaces = rep.Interfaces
+ }
+
+ return nil
+}
+
+// Close terminates the resolver.
+func (r *Resolver) Close() error {
+ return r.conn.Close()
+}
+
+// NewResolver returns a new resolver connected to the given address.
+func NewResolver(address string) (*Resolver, error) {
+ if address == "" {
+ address = ResolverAddress
+ }
+
+ c, err := NewConnection(address)
+ if err != nil {
+ return nil, err
+ }
+ r := Resolver{
+ address: address,
+ conn: c,
+ }
+
+ return &r, nil
+}
diff --git a/vendor/github.com/varlink/go/varlink/service.go b/vendor/github.com/varlink/go/varlink/service.go
new file mode 100644
index 000000000..eb110e503
--- /dev/null
+++ b/vendor/github.com/varlink/go/varlink/service.go
@@ -0,0 +1,350 @@
+package varlink
+
+import (
+ "bufio"
+ "encoding/json"
+ "fmt"
+ "net"
+ "os"
+ "strconv"
+ "strings"
+ "sync"
+ "syscall"
+ "time"
+)
+
+type dispatcher interface {
+ VarlinkDispatch(c Call, methodname string) error
+ VarlinkGetName() string
+ VarlinkGetDescription() string
+}
+
+type serviceCall struct {
+ Method string `json:"method"`
+ Parameters *json.RawMessage `json:"parameters,omitempty"`
+ More bool `json:"more,omitempty"`
+ OneShot bool `json:"oneshot,omitempty"`
+}
+
+type serviceReply struct {
+ Parameters interface{} `json:"parameters,omitempty"`
+ Continues bool `json:"continues,omitempty"`
+ Error string `json:"error,omitempty"`
+}
+
+// Service represents an active varlink service. In addition to the registered custom varlink Interfaces, every service
+// implements the org.varlink.service interface which allows clients to retrieve information about the
+// running service.
+type Service struct {
+ vendor string
+ product string
+ version string
+ url string
+ interfaces map[string]dispatcher
+ names []string
+ descriptions map[string]string
+ running bool
+ listener net.Listener
+ conncounter int64
+ mutex sync.Mutex
+ protocol string
+ address string
+}
+
+func (s *Service) getInfo(c Call) error {
+ return c.replyGetInfo(s.vendor, s.product, s.version, s.url, s.names)
+}
+
+func (s *Service) getInterfaceDescription(c Call, name string) error {
+ if name == "" {
+ return c.ReplyInvalidParameter("interface")
+ }
+
+ description, ok := s.descriptions[name]
+ if !ok {
+ return c.ReplyInvalidParameter("interface")
+ }
+
+ return c.replyGetInterfaceDescription(description)
+}
+
+func (s *Service) handleMessage(writer *bufio.Writer, request []byte) error {
+ var in serviceCall
+
+ err := json.Unmarshal(request, &in)
+
+ if err != nil {
+ return err
+ }
+
+ c := Call{
+ writer: writer,
+ in: &in,
+ }
+
+ r := strings.LastIndex(in.Method, ".")
+ if r <= 0 {
+ return c.ReplyInvalidParameter("method")
+ }
+
+ interfacename := in.Method[:r]
+ methodname := in.Method[r+1:]
+
+ if interfacename == "org.varlink.service" {
+ return s.orgvarlinkserviceDispatch(c, methodname)
+ }
+
+ // Find the interface and method in our service
+ iface, ok := s.interfaces[interfacename]
+ if !ok {
+ return c.ReplyInterfaceNotFound(interfacename)
+ }
+
+ return iface.VarlinkDispatch(c, methodname)
+}
+
+func activationListener() net.Listener {
+ pid, err := strconv.Atoi(os.Getenv("LISTEN_PID"))
+ if err != nil || pid != os.Getpid() {
+ return nil
+ }
+
+ nfds, err := strconv.Atoi(os.Getenv("LISTEN_FDS"))
+ if err != nil || nfds < 1 {
+ return nil
+ }
+
+ fd := -1
+
+ // If more than one file descriptor is passed, find the
+ // "varlink" tag. The first file descriptor is always 3.
+ if nfds > 1 {
+ fdnames, set := os.LookupEnv("LISTEN_FDNAMES")
+ if !set {
+ return nil
+ }
+
+ names := strings.Split(fdnames, ":")
+ if len(names) != nfds {
+ return nil
+ }
+
+ for i, name := range names {
+ if name == "varlink" {
+ fd = 3 + i
+ break
+ }
+ }
+
+ if fd < 0 {
+ return nil
+ }
+
+ } else {
+ fd = 3
+ }
+
+ syscall.CloseOnExec(fd)
+
+ file := os.NewFile(uintptr(fd), "varlink")
+ listener, err := net.FileListener(file)
+ if err != nil {
+ return nil
+ }
+
+ os.Unsetenv("LISTEN_PID")
+ os.Unsetenv("LISTEN_FDS")
+ os.Unsetenv("LISTEN_FDNAMES")
+
+ return listener
+}
+
+// Shutdown shuts down the listener of a running service.
+func (s *Service) Shutdown() {
+ s.running = false
+ s.mutex.Lock()
+ if s.listener != nil {
+ s.listener.Close()
+ }
+ s.mutex.Unlock()
+}
+
+func (s *Service) handleConnection(conn net.Conn, wg *sync.WaitGroup) {
+ defer func() { s.mutex.Lock(); s.conncounter--; s.mutex.Unlock(); wg.Done() }()
+ reader := bufio.NewReader(conn)
+ writer := bufio.NewWriter(conn)
+
+ for {
+ request, err := reader.ReadBytes('\x00')
+ if err != nil {
+ break
+ }
+
+ err = s.handleMessage(writer, request[:len(request)-1])
+ if err != nil {
+ // FIXME: report error
+ //fmt.Fprintf(os.Stderr, "handleMessage: %v", err)
+ break
+ }
+ }
+
+ conn.Close()
+}
+
+func (s *Service) teardown() {
+ s.mutex.Lock()
+ s.listener = nil
+ s.running = false
+ s.protocol = ""
+ s.address = ""
+ s.mutex.Unlock()
+}
+
+func (s *Service) parseAddress(address string) error {
+ words := strings.SplitN(address, ":", 2)
+ s.protocol = words[0]
+ s.address = words[1]
+
+ // Ignore parameters after ';'
+ words = strings.SplitN(s.address, ";", 2)
+ if words != nil {
+ s.address = words[0]
+ }
+
+ switch s.protocol {
+ case "unix":
+ break
+ case "tcp":
+ break
+
+ default:
+ return fmt.Errorf("Unknown protocol")
+ }
+
+ return nil
+}
+
+func getListener(protocol string, address string) (net.Listener, error) {
+ l := activationListener()
+ if l == nil {
+ if protocol == "unix" && address[0] != '@' {
+ os.Remove(address)
+ }
+
+ var err error
+ l, err = net.Listen(protocol, address)
+ if err != nil {
+ return nil, err
+ }
+
+ if protocol == "unix" && address[0] != '@' {
+ l.(*net.UnixListener).SetUnlinkOnClose(true)
+ }
+ }
+
+ return l, nil
+}
+
+func (s *Service) refreshTimeout(timeout time.Duration) error {
+ switch s.protocol {
+ case "unix":
+ if err := s.listener.(*net.UnixListener).SetDeadline(time.Now().Add(timeout)); err != nil {
+ return err
+ }
+
+ case "tcp":
+ if err := s.listener.(*net.TCPListener).SetDeadline(time.Now().Add(timeout)); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// Listen starts a Service.
+func (s *Service) Listen(address string, timeout time.Duration) error {
+ var wg sync.WaitGroup
+ defer func() { s.teardown(); wg.Wait() }()
+
+ s.mutex.Lock()
+ if s.running {
+ s.mutex.Unlock()
+ return fmt.Errorf("Listen(): already running")
+ }
+ s.mutex.Unlock()
+
+ s.parseAddress(address)
+
+ l, err := getListener(s.protocol, s.address)
+ if err != nil {
+ return err
+ }
+
+ s.mutex.Lock()
+ s.listener = l
+ s.running = true
+ s.mutex.Unlock()
+
+ for s.running {
+ if timeout != 0 {
+ if err := s.refreshTimeout(timeout); err != nil {
+ return err
+ }
+ }
+ conn, err := l.Accept()
+ if err != nil {
+ if err.(net.Error).Timeout() {
+ s.mutex.Lock()
+ if s.conncounter == 0 {
+ s.mutex.Unlock()
+ return nil
+ }
+ s.mutex.Unlock()
+ continue
+ }
+ if !s.running {
+ return nil
+ }
+ return err
+ }
+ s.mutex.Lock()
+ s.conncounter++
+ s.mutex.Unlock()
+ wg.Add(1)
+ go s.handleConnection(conn, &wg)
+ }
+
+ return nil
+}
+
+// RegisterInterface registers a varlink.Interface containing struct to the Service
+func (s *Service) RegisterInterface(iface dispatcher) error {
+ name := iface.VarlinkGetName()
+ if _, ok := s.interfaces[name]; ok {
+ return fmt.Errorf("interface '%s' already registered", name)
+ }
+
+ if s.running {
+ return fmt.Errorf("service is already running")
+ }
+ s.interfaces[name] = iface
+ s.descriptions[name] = iface.VarlinkGetDescription()
+ s.names = append(s.names, name)
+
+ return nil
+}
+
+// NewService creates a new Service which implements the list of given varlink interfaces.
+func NewService(vendor string, product string, version string, url string) (*Service, error) {
+ s := Service{
+ vendor: vendor,
+ product: product,
+ version: version,
+ url: url,
+ interfaces: make(map[string]dispatcher),
+ descriptions: make(map[string]string),
+ }
+ err := s.RegisterInterface(orgvarlinkserviceNew())
+
+ return &s, err
+}
diff --git a/vendor/github.com/varlink/go/varlink/varlink_test.go b/vendor/github.com/varlink/go/varlink/varlink_test.go
new file mode 100644
index 000000000..e19e768a2
--- /dev/null
+++ b/vendor/github.com/varlink/go/varlink/varlink_test.go
@@ -0,0 +1,232 @@
+package varlink
+
+// tests with access to internals
+
+import (
+ "bufio"
+ "bytes"
+ "fmt"
+ "strings"
+ "testing"
+)
+
+func expect(t *testing.T, expected string, returned string) {
+ if strings.Compare(returned, expected) != 0 {
+ t.Fatalf("Expected(%d): `%s`\nGot(%d): `%s`\n",
+ len(expected), expected,
+ len(returned), strings.Replace(returned, "\000", "`+\"\\000\"+`", -1))
+ }
+}
+
+func TestService(t *testing.T) {
+ service, _ := NewService(
+ "Varlink",
+ "Varlink Test",
+ "1",
+ "https://github.com/varlink/go/varlink",
+ )
+
+ t.Run("ZeroMessage", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ if err := service.handleMessage(w, []byte{0}); err == nil {
+ t.Fatal("HandleMessage returned non-error")
+ }
+ })
+
+ t.Run("InvalidJson", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"foo.GetInterfaceDescription" fdgdfg}`)
+ if err := service.handleMessage(w, msg); err == nil {
+ t.Fatal("HandleMessage returned no error on invalid json")
+ }
+ })
+
+ t.Run("WrongInterface", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"foo.GetInterfaceDescription"}`)
+ if err := service.handleMessage(w, msg); err != nil {
+ t.Fatal("HandleMessage returned error on wrong interface")
+ }
+ expect(t, `{"parameters":{"interface":"foo"},"error":"org.varlink.service.InterfaceNotFound"}`+"\000",
+ b.String())
+ })
+
+ t.Run("InvalidMethod", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"InvalidMethod"}`)
+ if err := service.handleMessage(w, msg); err != nil {
+ t.Fatal("HandleMessage returned error on invalid method")
+ }
+ expect(t, `{"parameters":{"parameter":"method"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
+ b.String())
+ })
+
+ t.Run("WrongMethod", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"org.varlink.service.WrongMethod"}`)
+ if err := service.handleMessage(w, msg); err != nil {
+ t.Fatal("HandleMessage returned error on wrong method")
+ }
+ expect(t, `{"parameters":{"method":"WrongMethod"},"error":"org.varlink.service.MethodNotFound"}`+"\000",
+ b.String())
+ })
+
+ t.Run("GetInterfaceDescriptionNullParameters", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters": null}`)
+ if err := service.handleMessage(w, msg); err != nil {
+ t.Fatalf("HandleMessage returned error: %v", err)
+ }
+ expect(t, `{"parameters":{"parameter":"parameters"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
+ b.String())
+ })
+
+ t.Run("GetInterfaceDescriptionNoInterface", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters":{}}`)
+ if err := service.handleMessage(w, msg); err != nil {
+ t.Fatalf("HandleMessage returned error: %v", err)
+ }
+ expect(t, `{"parameters":{"parameter":"interface"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
+ b.String())
+ })
+
+ t.Run("GetInterfaceDescriptionWrongInterface", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters":{"interface":"foo"}}`)
+ if err := service.handleMessage(w, msg); err != nil {
+ t.Fatalf("HandleMessage returned error: %v", err)
+ }
+ expect(t, `{"parameters":{"parameter":"interface"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
+ b.String())
+ })
+
+ t.Run("GetInterfaceDescription", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters":{"interface":"org.varlink.service"}}`)
+ if err := service.handleMessage(w, msg); err != nil {
+ t.Fatalf("HandleMessage returned error: %v", err)
+ }
+ expect(t, `{"parameters":{"description":"# The Varlink Service Interface is provided by every varlink service. It\n# describes the service and the interfaces it implements.\ninterface org.varlink.service\n\n# Get a list of all the interfaces a service provides and information\n# about the implementation.\nmethod GetInfo() -\u003e (\n vendor: string,\n product: string,\n version: string,\n url: string,\n interfaces: []string\n)\n\n# Get the description of an interface that is implemented by this service.\nmethod GetInterfaceDescription(interface: string) -\u003e (description: string)\n\n# The requested interface was not found.\nerror InterfaceNotFound (interface: string)\n\n# The requested method was not found\nerror MethodNotFound (method: string)\n\n# The interface defines the requested method, but the service does not\n# implement it.\nerror MethodNotImplemented (method: string)\n\n# One of the passed parameters is invalid.\nerror InvalidParameter (parameter: string)"}}`+"\000",
+ b.String())
+ })
+
+ t.Run("GetInfo", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"org.varlink.service.GetInfo"}`)
+ if err := service.handleMessage(w, msg); err != nil {
+ t.Fatalf("HandleMessage returned error: %v", err)
+ }
+ expect(t, `{"parameters":{"vendor":"Varlink","product":"Varlink Test","version":"1","url":"https://github.com/varlink/go/varlink","interfaces":["org.varlink.service"]}}`+"\000",
+ b.String())
+ })
+}
+
+type VarlinkInterface struct{}
+
+func (s *VarlinkInterface) VarlinkDispatch(call Call, methodname string) error {
+ switch methodname {
+ case "Ping":
+ if !call.WantsMore() {
+ return fmt.Errorf("More flag not passed")
+ }
+ if call.IsOneShot() {
+ return fmt.Errorf("OneShot flag set")
+ }
+ call.Continues = true
+ if err := call.Reply(nil); err != nil {
+ return err
+ }
+ if err := call.Reply(nil); err != nil {
+ return err
+ }
+ call.Continues = false
+ if err := call.Reply(nil); err != nil {
+ return err
+ }
+ return nil
+
+ case "PingError":
+ return call.ReplyError("org.example.test.PingError", nil)
+ }
+
+ call.Continues = true
+ if err := call.Reply(nil); err == nil {
+ return fmt.Errorf("call.Reply did not fail for Continues/More mismatch")
+ }
+ call.Continues = false
+
+ if err := call.ReplyError("WrongName", nil); err == nil {
+ return fmt.Errorf("call.ReplyError accepted invalid error name")
+ }
+
+ if err := call.ReplyError("org.varlink.service.MethodNotImplemented", nil); err == nil {
+ return fmt.Errorf("call.ReplyError accepted org.varlink.service error")
+ }
+
+ return call.ReplyMethodNotImplemented(methodname)
+}
+func (s *VarlinkInterface) VarlinkGetName() string {
+ return `org.example.test`
+}
+
+func (s *VarlinkInterface) VarlinkGetDescription() string {
+ return "#"
+}
+
+func TestMoreService(t *testing.T) {
+ newTestInterface := new(VarlinkInterface)
+
+ service, _ := NewService(
+ "Varlink",
+ "Varlink Test",
+ "1",
+ "https://github.com/varlink/go/varlink",
+ )
+
+ if err := service.RegisterInterface(newTestInterface); err != nil {
+ t.Fatalf("Couldn't register service: %v", err)
+ }
+
+ t.Run("MethodNotImplemented", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"org.example.test.Pingf"}`)
+ if err := service.handleMessage(w, msg); err != nil {
+ t.Fatalf("HandleMessage returned error: %v", err)
+ }
+ expect(t, `{"parameters":{"method":"Pingf"},"error":"org.varlink.service.MethodNotImplemented"}`+"\000",
+ b.String())
+ })
+
+ t.Run("PingError", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"org.example.test.PingError", "more" : true}`)
+ if err := service.handleMessage(w, msg); err != nil {
+ t.Fatalf("HandleMessage returned error: %v", err)
+ }
+ expect(t, `{"error":"org.example.test.PingError"}`+"\000",
+ b.String())
+ })
+ t.Run("MoreTest", func(t *testing.T) {
+ var b bytes.Buffer
+ w := bufio.NewWriter(&b)
+ msg := []byte(`{"method":"org.example.test.Ping", "more" : true}`)
+ if err := service.handleMessage(w, msg); err != nil {
+ t.Fatalf("HandleMessage returned error: %v", err)
+ }
+ expect(t, `{"continues":true}`+"\000"+`{"continues":true}`+"\000"+`{}`+"\000",
+ b.String())
+ })
+}