Skip to content

Commit 928b5d0

Browse files
authored
feat: add platform parameter to container create (#1017)
Signed-off-by: Thomas Cooper <[email protected]>
1 parent de9a655 commit 928b5d0

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

container_create.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var ErrContainerAlreadyExists = errors.New("container already exists")
1717
// See https://goo.gl/tyzwVM for more details.
1818
type CreateContainerOptions struct {
1919
Name string
20+
Platform string
2021
Config *Config `qs:"-"`
2122
HostConfig *HostConfig `qs:"-"`
2223
NetworkingConfig *NetworkingConfig `qs:"-"`

container_create_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,20 @@ func TestPassingNameOptToCreateContainerReturnsItInContainer(t *testing.T) {
127127
t.Errorf("Container name expected to be TestCreateContainer, was %s", container.Name)
128128
}
129129
}
130+
131+
func TestPassingPlatformOpt(t *testing.T) {
132+
t.Parallel()
133+
fakeRT := &FakeRoundTripper{message: "{}", status: http.StatusOK}
134+
client := newTestClient(fakeRT)
135+
config := Config{}
136+
opts := CreateContainerOptions{Name: "TestCreateContainerWithPlatform", Platform: "darwin/arm64", Config: &config}
137+
_, err := client.CreateContainer(opts)
138+
if err != nil {
139+
t.Fatal(err)
140+
}
141+
req := fakeRT.requests[0]
142+
gotQs := req.URL.Query().Get("platform")
143+
if gotQs != "darwin/arm64" {
144+
t.Errorf("CreateContainer: missing expected platform query string (%v)", req.URL.RequestURI())
145+
}
146+
}

0 commit comments

Comments
 (0)