mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
client: remove containerd "platform" dependency
Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit 9d7495c2b3500565986e3ab8d571c57e296a980d) Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
parent
4df345e65d
commit
5f9753ae73
1 changed files with 15 additions and 3 deletions
|
@ -4,8 +4,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path"
|
||||||
|
|
||||||
"github.com/containerd/containerd/platforms"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
|
@ -37,8 +37,8 @@ func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
if platform != nil {
|
if p := formatPlatform(platform); p != "" {
|
||||||
query.Set("platform", platforms.Format(*platform))
|
query.Set("platform", p)
|
||||||
}
|
}
|
||||||
|
|
||||||
if containerName != "" {
|
if containerName != "" {
|
||||||
|
@ -60,3 +60,15 @@ func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config
|
||||||
err = json.NewDecoder(serverResp.body).Decode(&response)
|
err = json.NewDecoder(serverResp.body).Decode(&response)
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// formatPlatform returns a formatted string representing platform (e.g. linux/arm/v7).
|
||||||
|
//
|
||||||
|
// Similar to containerd's platforms.Format(), but does allow components to be
|
||||||
|
// omitted (e.g. pass "architecture" only, without "os":
|
||||||
|
// https://github.com/containerd/containerd/blob/v1.5.2/platforms/platforms.go#L243-L263
|
||||||
|
func formatPlatform(platform *specs.Platform) string {
|
||||||
|
if platform == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return path.Join(platform.OS, platform.Architecture, platform.Variant)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue