MCPcopy
hub / github.com/containerd/containerd / WithNewSpec

Function WithNewSpec

client/container_opts.go:316–328  ·  view source on GitHub ↗

WithNewSpec generates a new spec for a new container

(opts ...oci.SpecOpts)

Source from the content-addressed store, hash-verified

314
315// WithNewSpec generates a new spec for a new container
316func WithNewSpec(opts ...oci.SpecOpts) NewContainerOpts {
317 return func(ctx context.Context, client *Client, c *containers.Container) error {
318 if _, ok := namespaces.Namespace(ctx); !ok {
319 ctx = namespaces.WithNamespace(ctx, client.DefaultNamespace())
320 }
321 s, err := oci.GenerateSpec(ctx, client, c, opts...)
322 if err != nil {
323 return err
324 }
325 c.Spec, err = typeurl.MarshalAny(s)
326 return err
327 }
328}
329
330// WithSpec sets the provided spec on the container
331func WithSpec(s *oci.Spec, opts ...oci.SpecOpts) NewContainerOpts {

Callers 15

testExportImportFunction · 0.85
TestNewContainerFunction · 0.85
TestContainerStartFunction · 0.85
TestContainerOutputFunction · 0.85
TestContainerWaitFunction · 0.85
TestContainerExecFunction · 0.85
TestContainerPidsFunction · 0.85
TestContainerCloseIOFunction · 0.85
TestContainerKillFunction · 0.85

Calls 5

NamespaceFunction · 0.92
WithNamespaceFunction · 0.92
GenerateSpecFunction · 0.92
DefaultNamespaceMethod · 0.80
MarshalAnyMethod · 0.65

Tested by 15

testExportImportFunction · 0.68
TestNewContainerFunction · 0.68
TestContainerStartFunction · 0.68
TestContainerOutputFunction · 0.68
TestContainerWaitFunction · 0.68
TestContainerExecFunction · 0.68
TestContainerPidsFunction · 0.68
TestContainerCloseIOFunction · 0.68
TestContainerKillFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…