(ctx context.Context, namespace, address, platform string, clientOpts ...containerd.Opt)
| 58 | } |
| 59 | |
| 60 | func 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)` |
no test coverage detected
searching dependent graphs…