MCPcopy Create free account
hub / github.com/containerd/nerdctl / NewClientWithPlatform

Function NewClientWithPlatform

pkg/clientutil/client.go:60–79  ·  view source on GitHub ↗
(ctx context.Context, namespace, address, platform string, clientOpts ...containerd.Opt)

Source from the content-addressed store, hash-verified

58}
59
60func NewClientWithPlatform(ctx context.Context, namespace, address, platform string, clientOpts ...containerd.Opt) (*containerd.Client, context.Context, context.CancelFunc, error) {
61 if platform != "" {
62 if canExec, canExecErr := platformutil.CanExecProbably(platform); !canExec {
63 warn := fmt.Sprintf("Platform %q seems incompatible with the host platform %q. If you see \"exec format error\", see https://github.com/containerd/nerdctl/blob/main/docs/multi-platform.md",
64 platform, platforms.DefaultString())
65 if canExecErr != nil {
66 log.L.WithError(canExecErr).Warn(warn)
67 } else {
68 log.L.Warn(warn)
69 }
70 }
71 platformParsed, err := platforms.Parse(platform)
72 if err != nil {
73 return nil, nil, nil, err
74 }
75 platformM := platforms.Only(platformParsed)
76 clientOpts = append(clientOpts, containerd.WithDefaultPlatform(platformM))
77 }
78 return NewClient(ctx, namespace, address, clientOpts...)
79}
80
81// DataStore returns a string like "/var/lib/nerdctl/1935db59".
82// "1935db9" is from `$(echo -n "/run/containerd/containerd.sock" | sha256sum | cut -c1-8)`

Callers 3

createActionFunction · 0.92
runActionFunction · 0.92
imageInspectActionFunction · 0.92

Calls 3

CanExecProbablyFunction · 0.92
NewClientFunction · 0.85
ParseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…