github.com/containerd/containerd@v22.0.0-20200918172823-438c87b8e050+incompatible/runtime/runtime.go (about) 1 /* 2 Copyright The containerd Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package runtime 18 19 import ( 20 "context" 21 "time" 22 23 "github.com/containerd/containerd/mount" 24 "github.com/gogo/protobuf/types" 25 ) 26 27 // IO holds process IO information 28 type IO struct { 29 Stdin string 30 Stdout string 31 Stderr string 32 Terminal bool 33 } 34 35 // CreateOpts contains task creation data 36 type CreateOpts struct { 37 // Spec is the OCI runtime spec 38 Spec *types.Any 39 // Rootfs mounts to perform to gain access to the container's filesystem 40 Rootfs []mount.Mount 41 // IO for the container's main process 42 IO IO 43 // Checkpoint digest to restore container state 44 Checkpoint string 45 // RuntimeOptions for the runtime 46 RuntimeOptions *types.Any 47 // TaskOptions received for the task 48 TaskOptions *types.Any 49 // Runtime to use 50 Runtime string 51 } 52 53 // Exit information for a process 54 type Exit struct { 55 Pid uint32 56 Status uint32 57 Timestamp time.Time 58 } 59 60 // PlatformRuntime is responsible for the creation and management of 61 // tasks and processes for a platform. 62 type PlatformRuntime interface { 63 // ID of the runtime 64 ID() string 65 // Create creates a task with the provided id and options. 66 Create(ctx context.Context, id string, opts CreateOpts) (Task, error) 67 // Get returns a task. 68 Get(context.Context, string) (Task, error) 69 // Tasks returns all the current tasks for the runtime. 70 // Any container runs at most one task at a time. 71 Tasks(context.Context, bool) ([]Task, error) 72 // Add adds a task into runtime. 73 Add(context.Context, Task) error 74 // Delete remove a task. 75 Delete(context.Context, string) 76 }