diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-03-20 11:45:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-20 11:45:32 +0100 |
commit | ccc30c606e843d5c98e2c62a3b393a61e60976b2 (patch) | |
tree | dd1696a5da35d21d0b5a2fb1bd384eab630c0738 /cmd/podman | |
parent | d927b43350a079c05f54e984838b851bcc2e5931 (diff) | |
parent | 5efa6dae905c65ea8a73565318e5f274c5eb825c (diff) | |
download | podman-ccc30c606e843d5c98e2c62a3b393a61e60976b2.tar.gz podman-ccc30c606e843d5c98e2c62a3b393a61e60976b2.tar.bz2 podman-ccc30c606e843d5c98e2c62a3b393a61e60976b2.zip |
Merge pull request #5539 from sujil02/issue-5461
Implemented --iidfile for podman commit
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/cliconfig/config.go | 1 | ||||
-rw-r--r-- | cmd/podman/commit.go | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/cmd/podman/cliconfig/config.go b/cmd/podman/cliconfig/config.go index 94a7b2091..3428746a9 100644 --- a/cmd/podman/cliconfig/config.go +++ b/cmd/podman/cliconfig/config.go @@ -115,6 +115,7 @@ type CommitValues struct { Pause bool Quiet bool IncludeVolumes bool + ImageIDFile string } type ContainersPrune struct { 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 } |