summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-06-15 12:43:15 -0400
committerGitHub <noreply@github.com>2021-06-15 12:43:15 -0400
commit463a5a7db5b096f225324d9c2c40e40a47f6e7c2 (patch)
tree11829a61203fdc0304e9aacbebe0cf578e7d1933 /pkg
parent6b517a7e9077330bfe81d84401aa856e2fab380c (diff)
parent3ddadc5326d6f7ba159495f135730ed817ce1989 (diff)
downloadpodman-463a5a7db5b096f225324d9c2c40e40a47f6e7c2.tar.gz
podman-463a5a7db5b096f225324d9c2c40e40a47f6e7c2.tar.bz2
podman-463a5a7db5b096f225324d9c2c40e40a47f6e7c2.zip
Merge pull request #10622 from cdoern/imgImportFeature
compat import imageFromSrc support for platform query parameter
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/images.go25
-rw-r--r--pkg/domain/entities/images.go2
-rw-r--r--pkg/domain/infra/abi/images.go2
3 files changed, 23 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
diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go
index 3cc46ed0a..17b82037e 100644
--- a/pkg/domain/entities/images.go
+++ b/pkg/domain/entities/images.go
@@ -271,8 +271,10 @@ type ImageLoadReport struct {
}
type ImageImportOptions struct {
+ Architecture string
Changes []string
Message string
+ OS string
Quiet bool
Reference string
SignaturePolicy string
diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go
index 083566201..5992181d3 100644
--- a/pkg/domain/infra/abi/images.go
+++ b/pkg/domain/infra/abi/images.go
@@ -388,6 +388,8 @@ func (ir *ImageEngine) Import(ctx context.Context, options entities.ImageImportO
importOptions.CommitMessage = options.Message
importOptions.Tag = options.Reference
importOptions.SignaturePolicyPath = options.SignaturePolicy
+ importOptions.OS = options.OS
+ importOptions.Architecture = options.Architecture
if !options.Quiet {
importOptions.Writer = os.Stderr