@@ -39,6 +39,7 @@ func NewCmdMutate(options *[]crane.Option) *cobra.Command {
39
39
var user string
40
40
var workdir string
41
41
var ports []string
42
+ var newPlatform string
42
43
43
44
mutateCmd := & cobra.Command {
44
45
Use : "mutate" ,
@@ -130,8 +131,20 @@ func NewCmdMutate(options *[]crane.Option) *cobra.Command {
130
131
cfg .Config .ExposedPorts = portMap
131
132
}
132
133
134
+ // Set platform
135
+ if len (newPlatform ) > 0 {
136
+ platform , err := parsePlatform (newPlatform )
137
+ if err != nil {
138
+ return err
139
+ }
140
+ cfg .OS = platform .OS
141
+ cfg .Architecture = platform .Architecture
142
+ cfg .Variant = platform .Variant
143
+ cfg .OSVersion = platform .OSVersion
144
+ }
145
+
133
146
// Mutate and write image.
134
- img , err = mutate .Config (img , cfg . Config )
147
+ img , err = mutate .ConfigFile (img , cfg )
135
148
if err != nil {
136
149
return fmt .Errorf ("mutating config: %w" , err )
137
150
}
@@ -183,6 +196,8 @@ func NewCmdMutate(options *[]crane.Option) *cobra.Command {
183
196
mutateCmd .Flags ().StringVarP (& user , "user" , "u" , "" , "New user to set" )
184
197
mutateCmd .Flags ().StringVarP (& workdir , "workdir" , "w" , "" , "New working dir to set" )
185
198
mutateCmd .Flags ().StringSliceVar (& ports , "exposed-ports" , nil , "New ports to expose" )
199
+ // Using "set-platform" to avoid clobbering "platform" persistent flag.
200
+ mutateCmd .Flags ().StringVar (& newPlatform , "set-platform" , "" , "New platform to set in the form os/arch[/variant][:osversion] (e.g. linux/amd64)" )
186
201
return mutateCmd
187
202
}
188
203
0 commit comments