containers.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. Copyright The containerd Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package containers
  14. import (
  15. "context"
  16. "time"
  17. "github.com/gogo/protobuf/types"
  18. )
  19. // Container represents the set of data pinned by a container. Unless otherwise
  20. // noted, the resources here are considered in use by the container.
  21. //
  22. // The resources specified in this object are used to create tasks from the container.
  23. type Container struct {
  24. // ID uniquely identifies the container in a namespace.
  25. //
  26. // This property is required and cannot be changed after creation.
  27. ID string
  28. // Labels provide metadata extension for a container.
  29. //
  30. // These are optional and fully mutable.
  31. Labels map[string]string
  32. // Image specifies the image reference used for a container.
  33. //
  34. // This property is optional and mutable.
  35. Image string
  36. // Runtime specifies which runtime should be used when launching container
  37. // tasks.
  38. //
  39. // This property is required and immutable.
  40. Runtime RuntimeInfo
  41. // Spec should carry the the runtime specification used to implement the
  42. // container.
  43. //
  44. // This field is required but mutable.
  45. Spec *types.Any
  46. // SnapshotKey specifies the snapshot key to use for the container's root
  47. // filesystem. When starting a task from this container, a caller should
  48. // look up the mounts from the snapshot service and include those on the
  49. // task create request.
  50. //
  51. // This field is not required but mutable.
  52. SnapshotKey string
  53. // Snapshotter specifies the snapshotter name used for rootfs
  54. //
  55. // This field is not required but immutable.
  56. Snapshotter string
  57. // CreatedAt is the time at which the container was created.
  58. CreatedAt time.Time
  59. // UpdatedAt is the time at which the container was updated.
  60. UpdatedAt time.Time
  61. // Extensions stores client-specified metadata
  62. Extensions map[string]types.Any
  63. }
  64. // RuntimeInfo holds runtime specific information
  65. type RuntimeInfo struct {
  66. Name string
  67. Options *types.Any
  68. }
  69. // Store interacts with the underlying container storage
  70. type Store interface {
  71. Get(ctx context.Context, id string) (Container, error)
  72. // List returns containers that match one or more of the provided filters.
  73. List(ctx context.Context, filters ...string) ([]Container, error)
  74. // Create a container in the store from the provided container.
  75. Create(ctx context.Context, container Container) (Container, error)
  76. // Update the container with the provided container object. ID must be set.
  77. //
  78. // If one or more fieldpaths are provided, only the field corresponding to
  79. // the fieldpaths will be mutated.
  80. Update(ctx context.Context, container Container, fieldpaths ...string) (Container, error)
  81. // Delete a container using the id.
  82. //
  83. // nil will be returned on success. If the container is not known to the
  84. // store, ErrNotFound will be returned.
  85. Delete(ctx context.Context, id string) error
  86. }