mirror of https://github.com/containers/podman.git
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
This commit is contained in:
parent
31e3a50ddd
commit
ca1c6ef5be
|
@ -27,6 +27,10 @@ type ContainerCommitOptions struct {
|
||||||
// Commit commits the changes between a container and its image, creating a new
|
// Commit commits the changes between a container and its image, creating a new
|
||||||
// image
|
// image
|
||||||
func (c *Container) Commit(ctx context.Context, destImage string, options ContainerCommitOptions) (*image.Image, error) {
|
func (c *Container) Commit(ctx context.Context, destImage string, options ContainerCommitOptions) (*image.Image, error) {
|
||||||
|
var (
|
||||||
|
isEnvCleared, isLabelCleared, isExposeCleared, isVolumeCleared bool
|
||||||
|
)
|
||||||
|
|
||||||
if !c.batched {
|
if !c.batched {
|
||||||
c.lock.Lock()
|
c.lock.Lock()
|
||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
@ -113,20 +117,32 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
|
||||||
case "ENTRYPOINT":
|
case "ENTRYPOINT":
|
||||||
importBuilder.SetEntrypoint(splitChange[1:])
|
importBuilder.SetEntrypoint(splitChange[1:])
|
||||||
case "ENV":
|
case "ENV":
|
||||||
importBuilder.ClearEnv()
|
if !isEnvCleared { // Multiple values are valid, only clear once.
|
||||||
|
importBuilder.ClearEnv()
|
||||||
|
isEnvCleared = true
|
||||||
|
}
|
||||||
importBuilder.SetEnv(splitChange[1], splitChange[2])
|
importBuilder.SetEnv(splitChange[1], splitChange[2])
|
||||||
case "EXPOSE":
|
case "EXPOSE":
|
||||||
importBuilder.ClearPorts()
|
if !isExposeCleared { // Multiple values are valid, only clear once
|
||||||
|
importBuilder.ClearPorts()
|
||||||
|
isExposeCleared = true
|
||||||
|
}
|
||||||
importBuilder.SetPort(splitChange[1])
|
importBuilder.SetPort(splitChange[1])
|
||||||
case "LABEL":
|
case "LABEL":
|
||||||
importBuilder.ClearLabels()
|
if !isLabelCleared { // multiple values are valid, only clear once
|
||||||
|
importBuilder.ClearLabels()
|
||||||
|
isLabelCleared = true
|
||||||
|
}
|
||||||
importBuilder.SetLabel(splitChange[1], splitChange[2])
|
importBuilder.SetLabel(splitChange[1], splitChange[2])
|
||||||
case "STOPSIGNAL":
|
case "STOPSIGNAL":
|
||||||
// No Set StopSignal
|
// No Set StopSignal
|
||||||
case "USER":
|
case "USER":
|
||||||
importBuilder.SetUser(splitChange[1])
|
importBuilder.SetUser(splitChange[1])
|
||||||
case "VOLUME":
|
case "VOLUME":
|
||||||
importBuilder.ClearVolumes()
|
if !isVolumeCleared { // multiple values are valid, only clear once
|
||||||
|
importBuilder.ClearVolumes()
|
||||||
|
isVolumeCleared = true
|
||||||
|
}
|
||||||
importBuilder.AddVolume(splitChange[1])
|
importBuilder.AddVolume(splitChange[1])
|
||||||
case "WORKDIR":
|
case "WORKDIR":
|
||||||
importBuilder.SetWorkDir(splitChange[1])
|
importBuilder.SetWorkDir(splitChange[1])
|
||||||
|
|
Loading…
Reference in New Issue