summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-05-21 09:46:42 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-21 16:13:16 +0000
commitca1c6ef5beae105f36cc6f27d53eab52b35e4ac7 (patch)
tree4ea300fd7e955d6b7c07ae2812804c5aa42330d2 /libpod
parent31e3a50ddd4be0c126a4c17a4a656d0957613551 (diff)
downloadpodman-ca1c6ef5beae105f36cc6f27d53eab52b35e4ac7.tar.gz
podman-ca1c6ef5beae105f36cc6f27d53eab52b35e4ac7.tar.bz2
podman-ca1c6ef5beae105f36cc6f27d53eab52b35e4ac7.zip
honor multiple change values
In the case where changes are made to Env, Expose, Volumes, or labels, we should honor that multiple values are valid. Resolves: #795 Signed-off-by: baude <bbaude@redhat.com> Closes: #815 Approved by: mheon
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_commit.go24
1 files changed, 20 insertions, 4 deletions
diff --git a/libpod/container_commit.go b/libpod/container_commit.go
index d2f0d9209..9aa5f407f 100644
--- a/libpod/container_commit.go
+++ b/libpod/container_commit.go
@@ -27,6 +27,10 @@ type ContainerCommitOptions struct {
// Commit commits the changes between a container and its image, creating a new
// image
func (c *Container) Commit(ctx context.Context, destImage string, options ContainerCommitOptions) (*image.Image, error) {
+ var (
+ isEnvCleared, isLabelCleared, isExposeCleared, isVolumeCleared bool
+ )
+
if !c.batched {
c.lock.Lock()
defer c.lock.Unlock()
@@ -113,20 +117,32 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
case "ENTRYPOINT":
importBuilder.SetEntrypoint(splitChange[1:])
case "ENV":
- importBuilder.ClearEnv()
+ if !isEnvCleared { // Multiple values are valid, only clear once.
+ importBuilder.ClearEnv()
+ isEnvCleared = true
+ }
importBuilder.SetEnv(splitChange[1], splitChange[2])
case "EXPOSE":
- importBuilder.ClearPorts()
+ if !isExposeCleared { // Multiple values are valid, only clear once
+ importBuilder.ClearPorts()
+ isExposeCleared = true
+ }
importBuilder.SetPort(splitChange[1])
case "LABEL":
- importBuilder.ClearLabels()
+ if !isLabelCleared { // multiple values are valid, only clear once
+ importBuilder.ClearLabels()
+ isLabelCleared = true
+ }
importBuilder.SetLabel(splitChange[1], splitChange[2])
case "STOPSIGNAL":
// No Set StopSignal
case "USER":
importBuilder.SetUser(splitChange[1])
case "VOLUME":
- importBuilder.ClearVolumes()
+ if !isVolumeCleared { // multiple values are valid, only clear once
+ importBuilder.ClearVolumes()
+ isVolumeCleared = true
+ }
importBuilder.AddVolume(splitChange[1])
case "WORKDIR":
importBuilder.SetWorkDir(splitChange[1])