Skip to content

Commit

Permalink
feat: add platform parameter to container create (#1017)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Cooper <[email protected]>
  • Loading branch information
coopernetes authored Oct 6, 2023
1 parent de9a655 commit 928b5d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var ErrContainerAlreadyExists = errors.New("container already exists")
// See https://goo.gl/tyzwVM for more details.
type CreateContainerOptions struct {
Name string
Platform string
Config *Config `qs:"-"`
HostConfig *HostConfig `qs:"-"`
NetworkingConfig *NetworkingConfig `qs:"-"`
Expand Down
17 changes: 17 additions & 0 deletions container_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,20 @@ func TestPassingNameOptToCreateContainerReturnsItInContainer(t *testing.T) {
t.Errorf("Container name expected to be TestCreateContainer, was %s", container.Name)
}
}

func TestPassingPlatformOpt(t *testing.T) {
t.Parallel()
fakeRT := &FakeRoundTripper{message: "{}", status: http.StatusOK}
client := newTestClient(fakeRT)
config := Config{}
opts := CreateContainerOptions{Name: "TestCreateContainerWithPlatform", Platform: "darwin/arm64", Config: &config}
_, err := client.CreateContainer(opts)
if err != nil {
t.Fatal(err)
}
req := fakeRT.requests[0]
gotQs := req.URL.Query().Get("platform")
if gotQs != "darwin/arm64" {
t.Errorf("CreateContainer: missing expected platform query string (%v)", req.URL.RequestURI())
}
}

0 comments on commit 928b5d0

Please sign in to comment.