Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
| ... | ... |
@@ -72,12 +72,12 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui |
| 72 | 72 |
options.RemoteContext = r.FormValue("remote")
|
| 73 | 73 |
if versions.GreaterThanOrEqualTo(version, "1.32") {
|
| 74 | 74 |
apiPlatform := r.FormValue("platform")
|
| 75 |
- if len(strings.TrimSpace(apiPlatform)) != 0 {
|
|
| 75 |
+ if apiPlatform != "" {
|
|
| 76 | 76 |
sp, err := platforms.Parse(apiPlatform) |
| 77 | 77 |
if err != nil {
|
| 78 | 78 |
return nil, err |
| 79 | 79 |
} |
| 80 |
- options.Platform = sp |
|
| 80 |
+ options.Platform = &sp |
|
| 81 | 81 |
} |
| 82 | 82 |
} |
| 83 | 83 |
|
| ... | ... |
@@ -44,7 +44,7 @@ func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite |
| 44 | 44 |
version := httputils.VersionFromContext(ctx) |
| 45 | 45 |
if versions.GreaterThanOrEqualTo(version, "1.32") {
|
| 46 | 46 |
apiPlatform := r.FormValue("platform")
|
| 47 |
- if len(strings.TrimSpace(apiPlatform)) != 0 {
|
|
| 47 |
+ if apiPlatform != "" {
|
|
| 48 | 48 |
sp, err := platforms.Parse(apiPlatform) |
| 49 | 49 |
if err != nil {
|
| 50 | 50 |
return err |
| ... | ... |
@@ -181,7 +181,7 @@ type ImageBuildOptions struct {
|
| 181 | 181 |
ExtraHosts []string // List of extra hosts |
| 182 | 182 |
Target string |
| 183 | 183 |
SessionID string |
| 184 |
- Platform specs.Platform |
|
| 184 |
+ Platform *specs.Platform |
|
| 185 | 185 |
// Version specifies the version of the unerlying builder to use |
| 186 | 186 |
Version BuilderVersion |
| 187 | 187 |
// BuildID is an optional identifier that can be passed together with the |
| ... | ... |
@@ -73,7 +73,7 @@ type copier struct {
|
| 73 | 73 |
source builder.Source |
| 74 | 74 |
pathCache pathCache |
| 75 | 75 |
download sourceDownloader |
| 76 |
- platform specs.Platform |
|
| 76 |
+ platform *specs.Platform |
|
| 77 | 77 |
// for cleanup. TODO: having copier.cleanup() is error prone and hard to |
| 78 | 78 |
// follow. Code calling performCopy should manage the lifecycle of its params. |
| 79 | 79 |
// Copier should take override source as input, not imageMount. |
| ... | ... |
@@ -8,8 +8,8 @@ import ( |
| 8 | 8 |
"net/http" |
| 9 | 9 |
"net/url" |
| 10 | 10 |
"strconv" |
| 11 |
- "strings" |
|
| 12 | 11 |
|
| 12 |
+ "github.com/containerd/containerd/platforms" |
|
| 13 | 13 |
"github.com/docker/docker/api/types" |
| 14 | 14 |
"github.com/docker/docker/api/types/container" |
| 15 | 15 |
) |
| ... | ... |
@@ -30,11 +30,11 @@ func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, optio |
| 30 | 30 |
} |
| 31 | 31 |
headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf))
|
| 32 | 32 |
|
| 33 |
- if options.Platform != "" {
|
|
| 33 |
+ if options.Platform != nil {
|
|
| 34 | 34 |
if err := cli.NewVersionError("1.32", "platform"); err != nil {
|
| 35 | 35 |
return types.ImageBuildResponse{}, err
|
| 36 | 36 |
} |
| 37 |
- query.Set("platform", options.Platform)
|
|
| 37 |
+ query.Set("platform", platforms.Format(*options.Platform))
|
|
| 38 | 38 |
} |
| 39 | 39 |
headers.Set("Content-Type", "application/x-tar")
|
| 40 | 40 |
|
| ... | ... |
@@ -130,8 +130,8 @@ func (cli *Client) imageBuildOptionsToQuery(options types.ImageBuildOptions) (ur |
| 130 | 130 |
if options.SessionID != "" {
|
| 131 | 131 |
query.Set("session", options.SessionID)
|
| 132 | 132 |
} |
| 133 |
- if options.Platform != "" {
|
|
| 134 |
- query.Set("platform", strings.ToLower(options.Platform))
|
|
| 133 |
+ if options.Platform != nil {
|
|
| 134 |
+ query.Set("platform", platforms.Format(*options.Platform))
|
|
| 135 | 135 |
} |
| 136 | 136 |
if options.BuildID != "" {
|
| 137 | 137 |
query.Set("buildid", options.BuildID)
|