MCPcopy Index your code
hub / github.com/containerd/containerd / validateContainer

Function validateContainer

core/metadata/containers.go:323–354  ·  view source on GitHub ↗
(container *containers.Container)

Source from the content-addressed store, hash-verified

321}
322
323func validateContainer(container *containers.Container) error {
324 if err := identifiers.Validate(container.ID); err != nil {
325 return fmt.Errorf("container.ID: %w", err)
326 }
327
328 for k := range container.Extensions {
329 if k == "" {
330 return fmt.Errorf("container.Extension keys must not be zero-length: %w", errdefs.ErrInvalidArgument)
331 }
332 }
333
334 // image has no validation
335 for k, v := range container.Labels {
336 if err := labels.Validate(k, v); err != nil {
337 return fmt.Errorf("containers.Labels: %w", err)
338 }
339 }
340
341 if container.Runtime.Name == "" {
342 return fmt.Errorf("container.Runtime.Name must be set: %w", errdefs.ErrInvalidArgument)
343 }
344
345 if container.Spec == nil {
346 return fmt.Errorf("container.Spec must be set: %w", errdefs.ErrInvalidArgument)
347 }
348
349 if container.SnapshotKey != "" && container.Snapshotter == "" {
350 return fmt.Errorf("container.Snapshotter must be set if container.SnapshotKey is set: %w", errdefs.ErrInvalidArgument)
351 }
352
353 return nil
354}
355
356func readContainer(container *containers.Container, bkt *bolt.Bucket) error {
357 labels, err := boltutil.ReadLabels(bkt)

Callers 2

CreateMethod · 0.85
UpdateMethod · 0.85

Calls 2

ValidateFunction · 0.92
ValidateFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…