Skip to content

Commit f9747cd

Browse files
committed
engine: update Go SDK to reflect refactored types pkgs
Signed-off-by: David Karlsson <[email protected]>
1 parent 9cc7001 commit f9747cd

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

content/engine/api/sdk/examples.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import (
3939
"io"
4040
"os"
4141

42-
"github.com/docker/docker/api/types"
4342
"github.com/docker/docker/api/types/container"
43+
"github.com/docker/docker/api/types/image"
4444
"github.com/docker/docker/client"
4545
"github.com/docker/docker/pkg/stdcopy"
4646
)
@@ -53,7 +53,7 @@ func main() {
5353
}
5454
defer cli.Close()
5555

56-
reader, err := cli.ImagePull(ctx, "docker.io/library/alpine", types.ImagePullOptions{})
56+
reader, err := cli.ImagePull(ctx, "docker.io/library/alpine", image.PullOptions{})
5757
if err != nil {
5858
panic(err)
5959
}
@@ -73,7 +73,7 @@ func main() {
7373
panic(err)
7474
}
7575

76-
if err := cli.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}); err != nil {
76+
if err := cli.ContainerStart(ctx, resp.ID, container.StartOptions{}); err != nil {
7777
panic(err)
7878
}
7979

@@ -86,7 +86,7 @@ func main() {
8686
case <-statusCh:
8787
}
8888

89-
out, err := cli.ContainerLogs(ctx, resp.ID, types.ContainerLogsOptions{ShowStdout: true})
89+
out, err := cli.ContainerLogs(ctx, resp.ID, container.LogsOptions{ShowStdout: true})
9090
if err != nil {
9191
panic(err)
9292
}
@@ -155,8 +155,8 @@ import (
155155
"io"
156156
"os"
157157

158-
"github.com/docker/docker/api/types"
159158
"github.com/docker/docker/api/types/container"
159+
"github.com/docker/docker/api/types/image"
160160
"github.com/docker/docker/client"
161161
)
162162

@@ -170,7 +170,7 @@ func main() {
170170

171171
imageName := "bfirsh/reticulate-splines"
172172

173-
out, err := cli.ImagePull(ctx, imageName, types.ImagePullOptions{})
173+
out, err := cli.ImagePull(ctx, imageName, image.PullOptions{})
174174
if err != nil {
175175
panic(err)
176176
}
@@ -184,7 +184,7 @@ func main() {
184184
panic(err)
185185
}
186186

187-
if err := cli.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}); err != nil {
187+
if err := cli.ContainerStart(ctx, resp.ID, container.StartOptions{}); err != nil {
188188
panic(err)
189189
}
190190

@@ -232,7 +232,7 @@ import (
232232
"context"
233233
"fmt"
234234

235-
"github.com/docker/docker/api/types"
235+
containertypes "github.com/docker/docker/api/types/container"
236236
"github.com/docker/docker/client"
237237
)
238238

@@ -244,7 +244,7 @@ func main() {
244244
}
245245
defer cli.Close()
246246

247-
containers, err := cli.ContainerList(ctx, types.ContainerListOptions{})
247+
containers, err := cli.ContainerList(ctx, containertypes.ListOptions{})
248248
if err != nil {
249249
panic(err)
250250
}
@@ -302,7 +302,6 @@ import (
302302
"context"
303303
"fmt"
304304

305-
"github.com/docker/docker/api/types"
306305
containertypes "github.com/docker/docker/api/types/container"
307306
"github.com/docker/docker/client"
308307
)
@@ -315,7 +314,7 @@ func main() {
315314
}
316315
defer cli.Close()
317316

318-
containers, err := cli.ContainerList(ctx, types.ContainerListOptions{})
317+
containers, err := cli.ContainerList(ctx, containertypes.ListOptions{})
319318
if err != nil {
320319
panic(err)
321320
}
@@ -377,7 +376,7 @@ import (
377376
"io"
378377
"os"
379378

380-
"github.com/docker/docker/api/types"
379+
"github.com/docker/docker/api/types/container"
381380
"github.com/docker/docker/client"
382381
)
383382

@@ -389,7 +388,7 @@ func main() {
389388
}
390389
defer cli.Close()
391390

392-
options := types.ContainerLogsOptions{ShowStdout: true}
391+
options := container.LogsOptions{ShowStdout: true}
393392
// Replace this ID with a container that really exists
394393
out, err := cli.ContainerLogs(ctx, "f1064a8a4c82", options)
395394
if err != nil {
@@ -439,7 +438,7 @@ import (
439438
"context"
440439
"fmt"
441440

442-
"github.com/docker/docker/api/types"
441+
"github.com/docker/docker/api/types/image"
443442
"github.com/docker/docker/client"
444443
)
445444

@@ -451,7 +450,7 @@ func main() {
451450
}
452451
defer cli.Close()
453452

454-
images, err := cli.ImageList(ctx, types.ImageListOptions{})
453+
images, err := cli.ImageList(ctx, image.ListOptions{})
455454
if err != nil {
456455
panic(err)
457456
}
@@ -502,7 +501,7 @@ import (
502501
"io"
503502
"os"
504503

505-
"github.com/docker/docker/api/types"
504+
"github.com/docker/docker/api/types/image"
506505
"github.com/docker/docker/client"
507506
)
508507

@@ -514,7 +513,7 @@ func main() {
514513
}
515514
defer cli.Close()
516515

517-
out, err := cli.ImagePull(ctx, "alpine", types.ImagePullOptions{})
516+
out, err := cli.ImagePull(ctx, "alpine", image.PullOptions{})
518517
if err != nil {
519518
panic(err)
520519
}
@@ -572,7 +571,8 @@ import (
572571
"io"
573572
"os"
574573

575-
"github.com/docker/docker/api/types"
574+
"github.com/docker/docker/api/types/image"
575+
"github.com/docker/docker/api/types/registry"
576576
"github.com/docker/docker/client"
577577
)
578578

@@ -584,7 +584,7 @@ func main() {
584584
}
585585
defer cli.Close()
586586

587-
authConfig := types.AuthConfig{
587+
authConfig := registry.AuthConfig{
588588
Username: "username",
589589
Password: "password",
590590
}
@@ -594,7 +594,7 @@ func main() {
594594
}
595595
authStr := base64.URLEncoding.EncodeToString(encodedJSON)
596596

597-
out, err := cli.ImagePull(ctx, "alpine", types.ImagePullOptions{RegistryAuth: authStr})
597+
out, err := cli.ImagePull(ctx, "alpine", image.PullOptions{RegistryAuth: authStr})
598598
if err != nil {
599599
panic(err)
600600
}
@@ -659,7 +659,6 @@ import (
659659
"context"
660660
"fmt"
661661

662-
"github.com/docker/docker/api/types"
663662
"github.com/docker/docker/api/types/container"
664663
"github.com/docker/docker/client"
665664
)
@@ -680,7 +679,7 @@ func main() {
680679
panic(err)
681680
}
682681

683-
if err := cli.ContainerStart(ctx, createResp.ID, types.ContainerStartOptions{}); err != nil {
682+
if err := cli.ContainerStart(ctx, createResp.ID, container.StartOptions{}); err != nil {
684683
panic(err)
685684
}
686685

@@ -693,7 +692,7 @@ func main() {
693692
case <-statusCh:
694693
}
695694

696-
commitResp, err := cli.ContainerCommit(ctx, createResp.ID, types.ContainerCommitOptions{Reference: "helloworld"})
695+
commitResp, err := cli.ContainerCommit(ctx, createResp.ID, container.CommitOptions{Reference: "helloworld"})
697696
if err != nil {
698697
panic(err)
699698
}

0 commit comments

Comments
 (0)