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