diff options
author | umohnani8 <umohnani@redhat.com> | 2018-04-18 16:48:35 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-04-19 14:08:47 +0000 |
commit | 27107fdac1d75f97caab47cd13efb1d9900cf350 (patch) | |
tree | f5edafbb52505829b15e19ea6a9e66f4440e862b /cmd/podman | |
parent | 6a9dbf3305e93e5e1c3bff09402a9b801c935fbd (diff) | |
download | podman-27107fdac1d75f97caab47cd13efb1d9900cf350.tar.gz podman-27107fdac1d75f97caab47cd13efb1d9900cf350.tar.bz2 podman-27107fdac1d75f97caab47cd13efb1d9900cf350.zip |
Vendor in latest containers/image and contaners/storage
Made necessary changes to functions to include contex.Context wherever needed
Signed-off-by: umohnani8 <umohnani@redhat.com>
Closes: #640
Approved by: baude
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/commit.go | 2 | ||||
-rw-r--r-- | cmd/podman/common.go | 6 | ||||
-rw-r--r-- | cmd/podman/create.go | 7 | ||||
-rw-r--r-- | cmd/podman/history.go | 2 | ||||
-rw-r--r-- | cmd/podman/images.go | 25 | ||||
-rw-r--r-- | cmd/podman/import.go | 2 | ||||
-rw-r--r-- | cmd/podman/inspect.go | 9 | ||||
-rw-r--r-- | cmd/podman/load.go | 8 | ||||
-rw-r--r-- | cmd/podman/pull.go | 2 | ||||
-rw-r--r-- | cmd/podman/push.go | 2 | ||||
-rw-r--r-- | cmd/podman/restart.go | 2 | ||||
-rw-r--r-- | cmd/podman/run.go | 10 | ||||
-rw-r--r-- | cmd/podman/save.go | 2 | ||||
-rw-r--r-- | cmd/podman/start.go | 2 | ||||
-rw-r--r-- | cmd/podman/utils.go | 2 |
15 files changed, 49 insertions, 34 deletions
diff --git a/cmd/podman/commit.go b/cmd/podman/commit.go index 57798156b..ef45a9f05 100644 --- a/cmd/podman/commit.go +++ b/cmd/podman/commit.go @@ -100,7 +100,7 @@ func commitCmd(c *cli.Context) error { Changes: c.StringSlice("change"), Author: c.String("author"), } - newImage, err := ctr.Commit(reference, options) + newImage, err := ctr.Commit(getContext(), reference, options) if err != nil { return err } diff --git a/cmd/podman/common.go b/cmd/podman/common.go index 755285c95..9ee99bebc 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -1,6 +1,7 @@ package main import ( + "context" "reflect" "regexp" "strings" @@ -67,6 +68,11 @@ func validateFlags(c *cli.Context, flags []cli.Flag) error { return nil } +// getContext returns a non-nil, empty context +func getContext() context.Context { + return context.TODO() +} + // Common flags shared between commands var createFlags = []cli.Flag{ cli.StringSliceFlag{ diff --git a/cmd/podman/create.go b/cmd/podman/create.go index 97490d6c0..930f90483 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -180,12 +180,13 @@ func createCmd(c *cli.Context) error { defer runtime.Shutdown(false) rtc := runtime.GetConfig() + ctx := getContext() - newImage, err := runtime.ImageRuntime().New(c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false) + newImage, err := runtime.ImageRuntime().New(ctx, c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false) if err != nil { return err } - data, err := newImage.Inspect() + data, err := newImage.Inspect(ctx) createConfig, err := parseCreateOpts(c, runtime, newImage.Names()[0], data) if err != nil { return err @@ -209,7 +210,7 @@ func createCmd(c *cli.Context) error { options = append(options, libpod.WithShmDir(createConfig.ShmDir)) options = append(options, libpod.WithShmSize(createConfig.Resources.ShmSize)) options = append(options, libpod.WithGroups(createConfig.GroupAdd)) - ctr, err := runtime.NewContainer(runtimeSpec, options...) + ctr, err := runtime.NewContainer(ctx, runtimeSpec, options...) if err != nil { return err } diff --git a/cmd/podman/history.go b/cmd/podman/history.go index 0f9698f4f..51ad0edcb 100644 --- a/cmd/podman/history.go +++ b/cmd/podman/history.go @@ -110,7 +110,7 @@ func historyCmd(c *cli.Context) error { format: format, } - history, layers, err := image.History() + history, layers, err := image.History(getContext()) if err != nil { return errors.Wrapf(err, "error getting history of image %q", image.InputName) } diff --git a/cmd/podman/images.go b/cmd/podman/images.go index 4e2114705..076c5956d 100644 --- a/cmd/podman/images.go +++ b/cmd/podman/images.go @@ -1,6 +1,7 @@ package main import ( + "context" "reflect" "strings" "time" @@ -105,8 +106,10 @@ func imagesCmd(c *cli.Context) error { return errors.New("'podman images' requires at most 1 argument") } + ctx := getContext() + if len(c.StringSlice("filter")) > 0 || newImage != nil { - filterFuncs, err = CreateFilterFuncs(runtime, c, newImage) + filterFuncs, err = CreateFilterFuncs(ctx, runtime, c, newImage) if err != nil { return err } @@ -141,7 +144,7 @@ func imagesCmd(c *cli.Context) error { filteredImages = images } - return generateImagesOutput(runtime, filteredImages, opts) + return generateImagesOutput(ctx, runtime, filteredImages, opts) } func (i imagesOptions) setOutputFormat() string { @@ -179,7 +182,7 @@ func imagesToGeneric(templParams []imagesTemplateParams, JSONParams []imagesJSON } // getImagesTemplateOutput returns the images information to be printed in human readable format -func getImagesTemplateOutput(runtime *libpod.Runtime, images []*image.Image, opts imagesOptions) (imagesOutput []imagesTemplateParams) { +func getImagesTemplateOutput(ctx context.Context, runtime *libpod.Runtime, images []*image.Image, opts imagesOptions) (imagesOutput []imagesTemplateParams) { for _, img := range images { createdTime := img.Created() @@ -190,7 +193,7 @@ func getImagesTemplateOutput(runtime *libpod.Runtime, images []*image.Image, opt // get all specified repo:tag pairs and print them separately for repo, tags := range image.ReposToMap(img.Names()) { for _, tag := range tags { - size, err := img.Size() + size, err := img.Size(ctx) if err != nil { size = nil } @@ -210,9 +213,9 @@ func getImagesTemplateOutput(runtime *libpod.Runtime, images []*image.Image, opt } // getImagesJSONOutput returns the images information in its raw form -func getImagesJSONOutput(runtime *libpod.Runtime, images []*image.Image) (imagesOutput []imagesJSONParams) { +func getImagesJSONOutput(ctx context.Context, runtime *libpod.Runtime, images []*image.Image) (imagesOutput []imagesJSONParams) { for _, img := range images { - size, err := img.Size() + size, err := img.Size(ctx) if err != nil { size = nil } @@ -230,7 +233,7 @@ func getImagesJSONOutput(runtime *libpod.Runtime, images []*image.Image) (images // generateImagesOutput generates the images based on the format provided -func generateImagesOutput(runtime *libpod.Runtime, images []*image.Image, opts imagesOptions) error { +func generateImagesOutput(ctx context.Context, runtime *libpod.Runtime, images []*image.Image, opts imagesOptions) error { if len(images) == 0 { return nil } @@ -238,10 +241,10 @@ func generateImagesOutput(runtime *libpod.Runtime, images []*image.Image, opts i switch opts.format { case formats.JSONString: - imagesOutput := getImagesJSONOutput(runtime, images) + imagesOutput := getImagesJSONOutput(ctx, runtime, images) out = formats.JSONStructArray{Output: imagesToGeneric([]imagesTemplateParams{}, imagesOutput)} default: - imagesOutput := getImagesTemplateOutput(runtime, images, opts) + imagesOutput := getImagesTemplateOutput(ctx, runtime, images, opts) out = formats.StdoutTemplateArray{Output: imagesToGeneric(imagesOutput, []imagesJSONParams{}), Template: opts.outputformat, Fields: imagesOutput[0].HeaderMap()} } return formats.Writer(out).Out() @@ -266,7 +269,7 @@ func (i *imagesTemplateParams) HeaderMap() map[string]string { // CreateFilterFuncs returns an array of filter functions based on the user inputs // and is later used to filter images for output -func CreateFilterFuncs(r *libpod.Runtime, c *cli.Context, img *image.Image) ([]image.ResultFilter, error) { +func CreateFilterFuncs(ctx context.Context, r *libpod.Runtime, c *cli.Context, img *image.Image) ([]image.ResultFilter, error) { var filterFuncs []image.ResultFilter for _, filter := range c.StringSlice("filter") { splitFilter := strings.Split(filter, "=") @@ -287,7 +290,7 @@ func CreateFilterFuncs(r *libpod.Runtime, c *cli.Context, img *image.Image) ([]i filterFuncs = append(filterFuncs, image.DanglingFilter()) case "label": labelFilter := strings.Join(splitFilter[1:], "=") - filterFuncs = append(filterFuncs, image.LabelFilter(labelFilter)) + filterFuncs = append(filterFuncs, image.LabelFilter(ctx, labelFilter)) default: return nil, errors.Errorf("invalid filter %s ", splitFilter[0]) } diff --git a/cmd/podman/import.go b/cmd/podman/import.go index bebd4486c..f57d70af0 100644 --- a/cmd/podman/import.go +++ b/cmd/podman/import.go @@ -107,7 +107,7 @@ func importCmd(c *cli.Context) error { source = file } - newImage, err := runtime.ImageRuntime().Import(source, reference, writer, image.SigningOptions{}, config) + newImage, err := runtime.ImageRuntime().Import(getContext(), source, reference, writer, image.SigningOptions{}, config) if err == nil { fmt.Println(newImage.ID()) } diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go index 4c4154d88..ce6ccd77f 100644 --- a/cmd/podman/inspect.go +++ b/cmd/podman/inspect.go @@ -1,6 +1,7 @@ package main import ( + "context" "encoding/json" "strings" @@ -86,7 +87,7 @@ func inspectCmd(c *cli.Context) error { inspectType = inspectTypeContainer } - inspectedObjects, iterateErr := iterateInput(c, args, runtime, inspectType) + inspectedObjects, iterateErr := iterateInput(getContext(), c, args, runtime, inspectType) var out formats.Writer if outputFormat != "" && outputFormat != formats.JSONString { @@ -102,7 +103,7 @@ func inspectCmd(c *cli.Context) error { } // func iterateInput iterates the images|containers the user has requested and returns the inspect data and error -func iterateInput(c *cli.Context, args []string, runtime *libpod.Runtime, inspectType string) ([]interface{}, error) { +func iterateInput(ctx context.Context, c *cli.Context, args []string, runtime *libpod.Runtime, inspectType string) ([]interface{}, error) { var ( data interface{} inspectedItems []interface{} @@ -133,7 +134,7 @@ func iterateInput(c *cli.Context, args []string, runtime *libpod.Runtime, inspec inspectError = errors.Wrapf(err, "error getting image %q", input) break } - data, err = image.Inspect() + data, err = image.Inspect(ctx) if err != nil { inspectError = errors.Wrapf(err, "error parsing image data %q", image.ID()) break @@ -146,7 +147,7 @@ func iterateInput(c *cli.Context, args []string, runtime *libpod.Runtime, inspec inspectError = errors.Wrapf(err, "error getting image %q", input) break } - data, err = image.Inspect() + data, err = image.Inspect(ctx) if err != nil { inspectError = errors.Wrapf(err, "error parsing image data %q", image.ID()) break diff --git a/cmd/podman/load.go b/cmd/podman/load.go index 1fb723750..ec616170c 100644 --- a/cmd/podman/load.go +++ b/cmd/podman/load.go @@ -98,18 +98,20 @@ func loadCmd(c *cli.Context) error { writer = os.Stderr } + ctx := getContext() + src := libpod.DockerArchive + ":" + input - newImage, err := runtime.ImageRuntime().New(src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false) + newImage, err := runtime.ImageRuntime().New(ctx, src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false) if err != nil { // generate full src name with specified image:tag fullSrc := libpod.OCIArchive + ":" + input if image != "" { fullSrc = fullSrc + ":" + image } - newImage, err = runtime.ImageRuntime().New(fullSrc, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false) + newImage, err = runtime.ImageRuntime().New(ctx, fullSrc, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false) if err != nil { src = libpod.DirTransport + ":" + input - newImage, err = runtime.ImageRuntime().New(src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false) + newImage, err = runtime.ImageRuntime().New(ctx, src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false) if err != nil { return errors.Wrapf(err, "error pulling %q", src) } diff --git a/cmd/podman/pull.go b/cmd/podman/pull.go index cab549a02..14e4e9252 100644 --- a/cmd/podman/pull.go +++ b/cmd/podman/pull.go @@ -103,7 +103,7 @@ func pullCmd(c *cli.Context) error { forceSecure = c.Bool("tls-verify") } - newImage, err := runtime.ImageRuntime().New(image, c.String("signature-policy"), c.String("authfile"), writer, &dockerRegistryOptions, image2.SigningOptions{}, true, forceSecure) + newImage, err := runtime.ImageRuntime().New(getContext(), image, c.String("signature-policy"), c.String("authfile"), writer, &dockerRegistryOptions, image2.SigningOptions{}, true, forceSecure) if err != nil { return errors.Wrapf(err, "error pulling image %q", image) } diff --git a/cmd/podman/push.go b/cmd/podman/push.go index 3a39a1a0e..d80af2ef3 100644 --- a/cmd/podman/push.go +++ b/cmd/podman/push.go @@ -151,5 +151,5 @@ func pushCmd(c *cli.Context) error { } //return runtime.PushImage(srcName, destName, options) - return newImage.PushImage(destName, manifestType, c.String("authfile"), c.String("signature-policy"), writer, c.Bool("compress"), so, &dockerRegistryOptions) + return newImage.PushImage(getContext(), destName, manifestType, c.String("authfile"), c.String("signature-policy"), writer, c.Bool("compress"), so, &dockerRegistryOptions) } diff --git a/cmd/podman/restart.go b/cmd/podman/restart.go index 84aa5f830..7eb168743 100644 --- a/cmd/podman/restart.go +++ b/cmd/podman/restart.go @@ -105,7 +105,7 @@ func restartCtr(timeout uint, ctr *libpod.Container) error { } } - if err := ctr.Start(); err != nil { + if err := ctr.Start(getContext()); err != nil { return err } diff --git a/cmd/podman/run.go b/cmd/podman/run.go index ac6361070..abb319a63 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -58,13 +58,15 @@ func runCmd(c *cli.Context) error { return errors.Errorf("image name or ID is required") } + ctx := getContext() + rtc := runtime.GetConfig() - newImage, err := runtime.ImageRuntime().New(c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false) + newImage, err := runtime.ImageRuntime().New(ctx, c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false) if err != nil { return errors.Wrapf(err, "unable to find image") } - data, err := newImage.Inspect() + data, err := newImage.Inspect(ctx) if err != nil { return err } @@ -105,7 +107,7 @@ func runCmd(c *cli.Context) error { options = append(options, libpod.WithCgroupParent(createConfig.CgroupParent)) } - ctr, err := runtime.NewContainer(runtimeSpec, options...) + ctr, err := runtime.NewContainer(ctx, runtimeSpec, options...) if err != nil { return err } @@ -133,7 +135,7 @@ func runCmd(c *cli.Context) error { // Handle detached start if createConfig.Detach { - if err := ctr.Start(); err != nil { + if err := ctr.Start(ctx); err != nil { // This means the command did not exist exitCode = 127 if strings.Index(err.Error(), "permission denied") > -1 { diff --git a/cmd/podman/save.go b/cmd/podman/save.go index 009984640..edf725e6d 100644 --- a/cmd/podman/save.go +++ b/cmd/podman/save.go @@ -117,7 +117,7 @@ func saveCmd(c *cli.Context) error { if err != nil { return err } - if err := newImage.PushImage(dest, manifestType, "", "", writer, c.Bool("compress"), libpodImage.SigningOptions{}, &libpodImage.DockerRegistryOptions{}); err != nil { + if err := newImage.PushImage(getContext(), dest, manifestType, "", "", writer, c.Bool("compress"), libpodImage.SigningOptions{}, &libpodImage.DockerRegistryOptions{}); err != nil { if err2 := os.Remove(output); err2 != nil { logrus.Errorf("error deleting %q: %v", output, err) } diff --git a/cmd/podman/start.go b/cmd/podman/start.go index 06b8f815f..fb16e08cd 100644 --- a/cmd/podman/start.go +++ b/cmd/podman/start.go @@ -121,7 +121,7 @@ func startCmd(c *cli.Context) error { continue } // Handle non-attach start - if err := ctr.Start(); err != nil { + if err := ctr.Start(getContext()); err != nil { if lastError != nil { fmt.Fprintln(os.Stderr, lastError) } diff --git a/cmd/podman/utils.go b/cmd/podman/utils.go index 925674474..bcf4734a9 100644 --- a/cmd/podman/utils.go +++ b/cmd/podman/utils.go @@ -161,7 +161,7 @@ func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detac streams.AttachInput = false } - attachChan, err := ctr.StartAndAttach(streams, detachKeys, resize) + attachChan, err := ctr.StartAndAttach(getContext(), streams, detachKeys, resize) if err != nil { return err } |