summaryrefslogtreecommitdiff
path: root/cmd/podman/commit.go
diff options
context:
space:
mode:
authorSujil02 <sushah@redhat.com>2020-03-12 10:46:44 -0400
committerSujil02 <sushah@redhat.com>2020-03-19 16:32:02 -0400
commit5efa6dae905c65ea8a73565318e5f274c5eb825c (patch)
tree0848b155723236cccc325dc6daa93174a8b0dc73 /cmd/podman/commit.go
parent45e7cbfef65d0379af19264c5fa90e1ae9ccb74a (diff)
downloadpodman-5efa6dae905c65ea8a73565318e5f274c5eb825c.tar.gz
podman-5efa6dae905c65ea8a73565318e5f274c5eb825c.tar.bz2
podman-5efa6dae905c65ea8a73565318e5f274c5eb825c.zip
Implemented --iidfile for podman commit
Added flag to Write the image ID to the file with podman commit command. Fix to issue #5461 Signed-off-by: Sujil02 <sushah@redhat.com>
Diffstat (limited to 'cmd/podman/commit.go')
-rw-r--r--cmd/podman/commit.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/cmd/podman/commit.go b/cmd/podman/commit.go
index 7c35a4832..3ad3bd275 100644
--- a/cmd/podman/commit.go
+++ b/cmd/podman/commit.go
@@ -2,6 +2,7 @@ package main
import (
"fmt"
+ "io/ioutil"
"strings"
"github.com/containers/libpod/cmd/podman/cliconfig"
@@ -41,6 +42,7 @@ func init() {
flags := commitCommand.Flags()
flags.StringArrayVarP(&commitCommand.Change, "change", "c", []string{}, fmt.Sprintf("Apply the following possible instructions to the created image (default []): %s", strings.Join(ChangeCmds, " | ")))
flags.StringVarP(&commitCommand.Format, "format", "f", "oci", "`Format` of the image manifest and metadata")
+ flags.StringVarP(&commitCommand.ImageIDFile, "iidfile", "", "", "`file` to write the image ID to")
flags.StringVarP(&commitCommand.Message, "message", "m", "", "Set commit message for imported image")
flags.StringVarP(&commitCommand.Author, "author", "a", "", "Set the author for the image committed")
flags.BoolVarP(&commitCommand.Pause, "pause", "p", false, "Pause container during commit")
@@ -70,6 +72,11 @@ func commitCmd(c *cliconfig.CommitValues) error {
if err != nil {
return err
}
+ if c.ImageIDFile != "" {
+ if err = ioutil.WriteFile(c.ImageIDFile, []byte(iid), 0644); err != nil {
+ return errors.Wrapf(err, "failed to write image ID to file %q", c.ImageIDFile)
+ }
+ }
fmt.Println(iid)
return nil
}