github.com/demonoid81/containerd@v1.3.4/runtime/v1/shim/local.go (about) 1 // +build !windows 2 3 /* 4 Copyright The containerd Authors. 5 6 Licensed under the Apache License, Version 2.0 (the "License"); 7 you may not use this file except in compliance with the License. 8 You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 See the License for the specific language governing permissions and 16 limitations under the License. 17 */ 18 19 package shim 20 21 import ( 22 "context" 23 "path/filepath" 24 25 "github.com/containerd/containerd/mount" 26 shimapi "github.com/containerd/containerd/runtime/v1/shim/v1" 27 ptypes "github.com/gogo/protobuf/types" 28 ) 29 30 // NewLocal returns a shim client implementation for issue commands to a shim 31 func NewLocal(s *Service) shimapi.ShimService { 32 return &local{ 33 s: s, 34 } 35 } 36 37 type local struct { 38 s *Service 39 } 40 41 func (c *local) Create(ctx context.Context, in *shimapi.CreateTaskRequest) (*shimapi.CreateTaskResponse, error) { 42 return c.s.Create(ctx, in) 43 } 44 45 func (c *local) Start(ctx context.Context, in *shimapi.StartRequest) (*shimapi.StartResponse, error) { 46 return c.s.Start(ctx, in) 47 } 48 49 func (c *local) Delete(ctx context.Context, in *ptypes.Empty) (*shimapi.DeleteResponse, error) { 50 // make sure we unmount the containers rootfs for this local 51 if err := mount.Unmount(filepath.Join(c.s.config.Path, "rootfs"), 0); err != nil { 52 return nil, err 53 } 54 return c.s.Delete(ctx, in) 55 } 56 57 func (c *local) DeleteProcess(ctx context.Context, in *shimapi.DeleteProcessRequest) (*shimapi.DeleteResponse, error) { 58 return c.s.DeleteProcess(ctx, in) 59 } 60 61 func (c *local) Exec(ctx context.Context, in *shimapi.ExecProcessRequest) (*ptypes.Empty, error) { 62 return c.s.Exec(ctx, in) 63 } 64 65 func (c *local) ResizePty(ctx context.Context, in *shimapi.ResizePtyRequest) (*ptypes.Empty, error) { 66 return c.s.ResizePty(ctx, in) 67 } 68 69 func (c *local) State(ctx context.Context, in *shimapi.StateRequest) (*shimapi.StateResponse, error) { 70 return c.s.State(ctx, in) 71 } 72 73 func (c *local) Pause(ctx context.Context, in *ptypes.Empty) (*ptypes.Empty, error) { 74 return c.s.Pause(ctx, in) 75 } 76 77 func (c *local) Resume(ctx context.Context, in *ptypes.Empty) (*ptypes.Empty, error) { 78 return c.s.Resume(ctx, in) 79 } 80 81 func (c *local) Kill(ctx context.Context, in *shimapi.KillRequest) (*ptypes.Empty, error) { 82 return c.s.Kill(ctx, in) 83 } 84 85 func (c *local) ListPids(ctx context.Context, in *shimapi.ListPidsRequest) (*shimapi.ListPidsResponse, error) { 86 return c.s.ListPids(ctx, in) 87 } 88 89 func (c *local) CloseIO(ctx context.Context, in *shimapi.CloseIORequest) (*ptypes.Empty, error) { 90 return c.s.CloseIO(ctx, in) 91 } 92 93 func (c *local) Checkpoint(ctx context.Context, in *shimapi.CheckpointTaskRequest) (*ptypes.Empty, error) { 94 return c.s.Checkpoint(ctx, in) 95 } 96 97 func (c *local) ShimInfo(ctx context.Context, in *ptypes.Empty) (*shimapi.ShimInfoResponse, error) { 98 return c.s.ShimInfo(ctx, in) 99 } 100 101 func (c *local) Update(ctx context.Context, in *shimapi.UpdateTaskRequest) (*ptypes.Empty, error) { 102 return c.s.Update(ctx, in) 103 } 104 105 func (c *local) Wait(ctx context.Context, in *shimapi.WaitRequest) (*shimapi.WaitResponse, error) { 106 return c.s.Wait(ctx, in) 107 }