@@ -20,16 +20,16 @@ import (
2020
2121// ContainerCommitOptions is a struct used to commit a container to an image
2222// It uses buildah's CommitOptions as a base. Long-term we might wish to
23- // add these to the buildah struct once buildah is more integrated with
24- // libpod
23+ // decouple these because it includes duplicates of fields that are in, or
24+ // could later be added, to buildah's CommitOptions, which gets confusing
2525type ContainerCommitOptions struct {
2626 buildah.CommitOptions
2727 Pause bool
2828 IncludeVolumes bool
2929 Author string
3030 Message string
31- Changes []string
32- Squash bool
31+ Changes []string // gets merged with CommitOptions.OverrideChanges
32+ Squash bool // always used instead of CommitOptions.Squash
3333}
3434
3535// Commit commits the changes between a container and its image, creating a new
@@ -69,6 +69,8 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
6969 Squash : options .Squash ,
7070 SystemContext : c .runtime .imageContext ,
7171 PreferredManifestType : options .PreferredManifestType ,
72+ OverrideChanges : append (append ([]string {}, options .Changes ... ), options .CommitOptions .OverrideChanges ... ),
73+ OverrideConfig : options .CommitOptions .OverrideConfig ,
7274 }
7375 importBuilder , err := buildah .ImportBuilder (ctx , c .runtime .store , builderOptions )
7476 importBuilder .Format = options .PreferredManifestType
@@ -150,51 +152,6 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
150152 // Workdir
151153 importBuilder .SetWorkDir (c .config .Spec .Process .Cwd )
152154
153- // Process user changes
154- newImageConfig , err := libimage .ImageConfigFromChanges (options .Changes )
155- if err != nil {
156- return nil , err
157- }
158- if newImageConfig .User != "" {
159- importBuilder .SetUser (newImageConfig .User )
160- }
161- // EXPOSE only appends
162- for port := range newImageConfig .ExposedPorts {
163- importBuilder .SetPort (port )
164- }
165- // ENV only appends
166- for _ , env := range newImageConfig .Env {
167- splitEnv := strings .SplitN (env , "=" , 2 )
168- key := splitEnv [0 ]
169- value := ""
170- if len (splitEnv ) == 2 {
171- value = splitEnv [1 ]
172- }
173- importBuilder .SetEnv (key , value )
174- }
175- if newImageConfig .Entrypoint != nil {
176- importBuilder .SetEntrypoint (newImageConfig .Entrypoint )
177- }
178- if newImageConfig .Cmd != nil {
179- importBuilder .SetCmd (newImageConfig .Cmd )
180- }
181- // VOLUME only appends
182- for vol := range newImageConfig .Volumes {
183- importBuilder .AddVolume (vol )
184- }
185- if newImageConfig .WorkingDir != "" {
186- importBuilder .SetWorkDir (newImageConfig .WorkingDir )
187- }
188- for k , v := range newImageConfig .Labels {
189- importBuilder .SetLabel (k , v )
190- }
191- if newImageConfig .StopSignal != "" {
192- importBuilder .SetStopSignal (newImageConfig .StopSignal )
193- }
194- for _ , onbuild := range newImageConfig .OnBuild {
195- importBuilder .SetOnBuild (onbuild )
196- }
197-
198155 var commitRef types.ImageReference
199156 if destImage != "" {
200157 // Now resolve the name.
0 commit comments