GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — client: fix example, and update refs to old modules · moby/moby@30322dd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • client
    • README.md
    • container_create.go
  • vendor/github.com/moby/moby/client
    • README.md
    • container_create.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎client/README.md‎

Copy file name to clipboardExpand all lines: client/README.md
+5-5Lines changed: 5 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The `docker` command uses this package to communicate with the daemon. It can
44
also be used by your own Go applications to do anything the command-line
5-
interface does – running containers, pulling images, managing swarms, etc.
5+
interface does; running containers, pulling or pushing images, etc.
66

77
For example, to list all containers (the equivalent of `docker ps --all`):
88

@@ -13,12 +13,12 @@ import (
1313
"context"
1414
"fmt"
1515

16-
"github.com/docker/docker/api/types/container"
17-
"github.com/docker/docker/client"
16+
"github.com/moby/moby/api/types/container"
17+
"github.com/moby/moby/client"
1818
)
1919

2020
func main() {
21-
apiClient, err := client.NewClientWithOpts(client.FromEnv)
21+
apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
2222
if err != nil {
2323
panic(err)
2424
}
@@ -35,4 +35,4 @@ func main() {
3535
}
3636
```
3737

38-
[Full documentation is available on pkg.go.dev.](https://pkg.go.dev/github.com/docker/docker/client)
38+
[Full documentation is available on pkg.go.dev.](https://pkg.go.dev/github.com/moby/moby/client)
Collapse file

‎client/container_create.go‎

Copy file name to clipboardExpand all lines: client/container_create.go
+16-10Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config
7979
}
8080

8181
query := url.Values{}
82-
if p := formatPlatform(platform); p != "" {
83-
query.Set("platform", p)
82+
if platform != nil {
83+
if p := formatPlatform(*platform); p != "unknown" {
84+
query.Set("platform", p)
85+
}
8486
}
8587

8688
if containerName != "" {
@@ -103,14 +105,16 @@ func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config
103105
return response, err
104106
}
105107

106-
// formatPlatform returns a formatted string representing platform (e.g. linux/arm/v7).
108+
// formatPlatform returns a formatted string representing platform (e.g., "linux/arm/v7").
109+
//
110+
// It is a fork of [platforms.Format], and does not yet support "os.version",
111+
// as [[platforms.FormatAll] does.
107112
//
108-
// Similar to containerd's platforms.Format(), but does allow components to be
109-
// omitted (e.g. pass "architecture" only, without "os":
110-
// https://github.com/containerd/containerd/blob/v1.5.2/platforms/platforms.go#L243-L263
111-
func formatPlatform(platform *ocispec.Platform) string {
112-
if platform == nil {
113-
return ""
113+
// [platforms.Format]: https://github.com/containerd/platforms/blob/v1.0.0-rc.1/platforms.go#L309-L316
114+
// [platforms.FormatAll]: https://github.com/containerd/platforms/blob/v1.0.0-rc.1/platforms.go#L318-L330
115+
func formatPlatform(platform ocispec.Platform) string {
116+
if platform.OS == "" {
117+
return "unknown"
114118
}
115119
return path.Join(platform.OS, platform.Architecture, platform.Variant)
116120
}
@@ -134,8 +138,10 @@ const allCapabilities = "ALL"
134138
// normalizeCapabilities normalizes capabilities to their canonical form,
135139
// removes duplicates, and sorts the results.
136140
//
137-
// It is similar to [github.com/docker/docker/oci/caps.NormalizeLegacyCapabilities],
141+
// It is similar to [caps.NormalizeLegacyCapabilities],
138142
// but performs no validation based on supported capabilities.
143+
//
144+
// [caps.NormalizeLegacyCapabilities]: https://github.com/moby/moby/blob/v28.3.2/oci/caps/utils.go#L56
139145
func normalizeCapabilities(caps []string) []string {
140146
var normalized []string
141147

Collapse file

‎vendor/github.com/moby/moby/client/README.md‎

Copy file name to clipboardExpand all lines: vendor/github.com/moby/moby/client/README.md
+5-5Lines changed: 5 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎vendor/github.com/moby/moby/client/container_create.go‎

Copy file name to clipboardExpand all lines: vendor/github.com/moby/moby/client/container_create.go
+16-10Lines changed: 16 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.