| 321 | } |
| 322 | |
| 323 | func 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 | |
| 356 | func readContainer(container *containers.Container, bkt *bolt.Bucket) error { |
| 357 | labels, err := boltutil.ReadLabels(bkt) |