diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-07-20 05:26:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 05:26:35 -0400 |
commit | f4e81d0b886ba65cf350f101020d398af2f2cc7e (patch) | |
tree | 9b843560bb678a458aabf50a113bd840cb7ce7ef /pkg/api/handlers/compat/images.go | |
parent | 36e47768e6b2b2a78b85535695aa9e7bb7f9c3a8 (diff) | |
parent | eaaca499922c4a322bf61b7d9f288a447b1079ba (diff) | |
download | podman-f4e81d0b886ba65cf350f101020d398af2f2cc7e.tar.gz podman-f4e81d0b886ba65cf350f101020d398af2f2cc7e.tar.bz2 podman-f4e81d0b886ba65cf350f101020d398af2f2cc7e.zip |
Merge pull request #10979 from vrothberg/fix-10977
compat: image create: handle platform correctly
Diffstat (limited to 'pkg/api/handlers/compat/images.go')
-rw-r--r-- | pkg/api/handlers/compat/images.go | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 7baa1145a..6f8fb21f0 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -266,41 +266,26 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) { } defer auth.RemoveAuthfile(authfile) - platformSpecs := strings.Split(query.Platform, "/") // split query into its parts - - addOS := true // default assume true due to structure of if/else below - addArch := false - addVariant := false - - if len(platformSpecs) > 1 { // if we have two arguments then we have os and arch - addArch = true - if len(platformSpecs) > 2 { // if we have 3 arguments then we have os arch and variant - addVariant = true - } - } else if len(platformSpecs) == 0 { - addOS = false - } - pullOptions := &libimage.PullOptions{} pullOptions.AuthFilePath = authfile if authConf != nil { pullOptions.Username = authConf.Username pullOptions.Password = authConf.Password pullOptions.IdentityToken = authConf.IdentityToken - if addOS { // if the len is not 0 - pullOptions.OS = platformSpecs[0] - if addArch { - pullOptions.Architecture = platformSpecs[1] - } - if addVariant { - pullOptions.Variant = platformSpecs[2] - } - } } pullOptions.Writer = os.Stderr // allows for debugging on the server - progress := make(chan types.ProgressProperties) + // Handle the platform. + platformSpecs := strings.Split(query.Platform, "/") + pullOptions.OS = platformSpecs[0] // may be empty + if len(platformSpecs) > 1 { + pullOptions.Architecture = platformSpecs[1] + if len(platformSpecs) > 2 { + pullOptions.Variant = platformSpecs[2] + } + } + progress := make(chan types.ProgressProperties) pullOptions.Progress = progress pullResChan := make(chan pullResult) |