summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat
diff options
context:
space:
mode:
authorcdoern <cbdoer23@g.holycross.edu>2021-06-01 18:05:18 -0400
committercdoern <cbdoer23@g.holycross.edu>2021-06-04 09:50:42 -0400
commitce01b4f095f6d1a55952e03f919ba73d4c9d8eae (patch)
tree3f45532b845e03a8af82e9e55b4edded58f0cdc5 /pkg/api/handlers/compat
parent2cc4535e1fb8d6a18a4992e395ace21fefe22efe (diff)
downloadpodman-ce01b4f095f6d1a55952e03f919ba73d4c9d8eae.tar.gz
podman-ce01b4f095f6d1a55952e03f919ba73d4c9d8eae.tar.bz2
podman-ce01b4f095f6d1a55952e03f919ba73d4c9d8eae.zip
made requested changes, fixed api tests
Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r--pkg/api/handlers/compat/images.go34
1 files changed, 30 insertions, 4 deletions
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go
index 3f4320efa..6c8af66c3 100644
--- a/pkg/api/handlers/compat/images.go
+++ b/pkg/api/handlers/compat/images.go
@@ -169,6 +169,8 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
query := struct {
FromSrc string `schema:"fromSrc"`
Changes []string `schema:"changes"`
+ Message string `schema:"message"`
+ Repo string `shchema:"repo"`
}{
// This is where you can override the golang default value for one of fields
}
@@ -185,14 +187,15 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to create tempfile"))
return
}
+
source = f.Name()
if err := SaveFromBody(f, r); err != nil {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to write temporary file"))
}
}
-
imageEngine := abi.ImageEngine{Libpod: runtime}
- report, err := imageEngine.Import(r.Context(), entities.ImageImportOptions{Source: source, Changes: query.Changes})
+ // 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})
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to import tarball"))
return
@@ -220,10 +223,10 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) {
query := struct {
FromImage string `schema:"fromImage"`
Tag string `schema:"tag"`
+ Platform string `schema:"platform"`
}{
// This is where you can override the golang default value for one of fields
}
-
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
@@ -238,12 +241,36 @@ 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
@@ -295,7 +322,6 @@ loop: // break out of for/select infinite loop
Error string `json:"error,omitempty"`
Id string `json:"id,omitempty"` // nolint
}
-
select {
case e := <-progress:
switch e.Event {