diff options
author | cdoern <cbdoer23@g.holycross.edu> | 2021-06-09 14:26:40 -0400 |
---|---|---|
committer | cdoern <cbdoer23@g.holycross.edu> | 2021-06-14 09:05:01 -0400 |
commit | 3ddadc5326d6f7ba159495f135730ed817ce1989 (patch) | |
tree | 5bdb6d8ac975ad7667a164002562f36df74c5d6c /pkg/api/handlers/compat | |
parent | 2970e3518cc95910444903f572418f5887316e47 (diff) | |
download | podman-3ddadc5326d6f7ba159495f135730ed817ce1989.tar.gz podman-3ddadc5326d6f7ba159495f135730ed817ce1989.tar.bz2 podman-3ddadc5326d6f7ba159495f135730ed817ce1989.zip |
Image import fromSrc now supports OS/Arch
added handling in entities and compat to support passing a specified OS/Arch while importing from SRC.
fixes #10566
Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r-- | pkg/api/handlers/compat/images.go | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index ac212474b..7baa1145a 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -166,10 +166,11 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value("runtime").(*libpod.Runtime) query := struct { - FromSrc string `schema:"fromSrc"` - Changes []string `schema:"changes"` - Message string `schema:"message"` - Repo string `shchema:"repo"` + Changes []string `schema:"changes"` + FromSrc string `schema:"fromSrc"` + Message string `schema:"message"` + Platform string `schema:"platform"` + Repo string `shchema:"repo"` }{ // This is where you can override the golang default value for one of fields } @@ -192,9 +193,21 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) { utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to write temporary file")) } } + + platformSpecs := strings.Split(query.Platform, "/") + opts := entities.ImageImportOptions{ + Source: source, + Changes: query.Changes, + Message: query.Message, + Reference: query.Repo, + OS: platformSpecs[0], + } + if len(platformSpecs) > 1 { + opts.Architecture = platformSpecs[1] + } + imageEngine := abi.ImageEngine{Libpod: runtime} - // TODO: add support for ImageImportOptions to take a platform parameter. Also import https://github.com/opencontainers/image-spec/tree/master/specs-go/v1 either here or within imageEngine.Import to get default platform - report, err := imageEngine.Import(r.Context(), entities.ImageImportOptions{Source: source, Changes: query.Changes, Message: query.Message, Reference: query.Repo}) + report, err := imageEngine.Import(r.Context(), opts) if err != nil { utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to import tarball")) return |