Rename variables holding a task from c
to t
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
725b4d5803
commit
fb5a3d2989
@ -31,26 +31,26 @@ func newTask(id, namespace string, spec []byte, shim shim.ShimClient) *Task {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Task) Info() plugin.TaskInfo {
|
||||
func (t *Task) Info() plugin.TaskInfo {
|
||||
return plugin.TaskInfo{
|
||||
ID: c.containerID,
|
||||
ContainerID: c.containerID,
|
||||
ID: t.containerID,
|
||||
ContainerID: t.containerID,
|
||||
Runtime: pluginID,
|
||||
Spec: c.spec,
|
||||
Namespace: c.namespace,
|
||||
Spec: t.spec,
|
||||
Namespace: t.namespace,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Task) Start(ctx context.Context) error {
|
||||
_, err := c.shim.Start(ctx, &shim.StartRequest{})
|
||||
func (t *Task) Start(ctx context.Context) error {
|
||||
_, err := t.shim.Start(ctx, &shim.StartRequest{})
|
||||
if err != nil {
|
||||
err = errors.New(grpc.ErrorDesc(err))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Task) State(ctx context.Context) (plugin.State, error) {
|
||||
response, err := c.shim.State(ctx, &shim.StateRequest{})
|
||||
func (t *Task) State(ctx context.Context) (plugin.State, error) {
|
||||
response, err := t.shim.State(ctx, &shim.StateRequest{})
|
||||
if err != nil {
|
||||
return plugin.State{}, errors.New(grpc.ErrorDesc(err))
|
||||
}
|
||||
@ -76,24 +76,24 @@ func (c *Task) State(ctx context.Context) (plugin.State, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Task) Pause(ctx context.Context) error {
|
||||
_, err := c.shim.Pause(ctx, &shim.PauseRequest{})
|
||||
func (t *Task) Pause(ctx context.Context) error {
|
||||
_, err := t.shim.Pause(ctx, &shim.PauseRequest{})
|
||||
if err != nil {
|
||||
err = errors.New(grpc.ErrorDesc(err))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Task) Resume(ctx context.Context) error {
|
||||
_, err := c.shim.Resume(ctx, &shim.ResumeRequest{})
|
||||
func (t *Task) Resume(ctx context.Context) error {
|
||||
_, err := t.shim.Resume(ctx, &shim.ResumeRequest{})
|
||||
if err != nil {
|
||||
err = errors.New(grpc.ErrorDesc(err))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Task) Kill(ctx context.Context, signal uint32, pid uint32, all bool) error {
|
||||
_, err := c.shim.Kill(ctx, &shim.KillRequest{
|
||||
func (t *Task) Kill(ctx context.Context, signal uint32, pid uint32, all bool) error {
|
||||
_, err := t.shim.Kill(ctx, &shim.KillRequest{
|
||||
Signal: signal,
|
||||
Pid: pid,
|
||||
All: all,
|
||||
@ -104,7 +104,7 @@ func (c *Task) Kill(ctx context.Context, signal uint32, pid uint32, all bool) er
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Task) Exec(ctx context.Context, opts plugin.ExecOpts) (plugin.Process, error) {
|
||||
func (t *Task) Exec(ctx context.Context, opts plugin.ExecOpts) (plugin.Process, error) {
|
||||
request := &shim.ExecRequest{
|
||||
Stdin: opts.IO.Stdin,
|
||||
Stdout: opts.IO.Stdout,
|
||||
@ -115,20 +115,20 @@ func (c *Task) Exec(ctx context.Context, opts plugin.ExecOpts) (plugin.Process,
|
||||
Value: opts.Spec,
|
||||
},
|
||||
}
|
||||
resp, err := c.shim.Exec(ctx, request)
|
||||
resp, err := t.shim.Exec(ctx, request)
|
||||
if err != nil {
|
||||
return nil, errors.New(grpc.ErrorDesc(err))
|
||||
|
||||
}
|
||||
return &Process{
|
||||
pid: int(resp.Pid),
|
||||
c: c,
|
||||
t: t,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Task) Processes(ctx context.Context) ([]uint32, error) {
|
||||
resp, err := c.shim.Processes(ctx, &shim.ProcessesRequest{
|
||||
ID: c.containerID,
|
||||
func (t *Task) Processes(ctx context.Context) ([]uint32, error) {
|
||||
resp, err := t.shim.Processes(ctx, &shim.ProcessesRequest{
|
||||
ID: t.containerID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.New(grpc.ErrorDesc(err))
|
||||
@ -143,8 +143,8 @@ func (c *Task) Processes(ctx context.Context) ([]uint32, error) {
|
||||
return pids, nil
|
||||
}
|
||||
|
||||
func (c *Task) Pty(ctx context.Context, pid uint32, size plugin.ConsoleSize) error {
|
||||
_, err := c.shim.Pty(ctx, &shim.PtyRequest{
|
||||
func (t *Task) Pty(ctx context.Context, pid uint32, size plugin.ConsoleSize) error {
|
||||
_, err := t.shim.Pty(ctx, &shim.PtyRequest{
|
||||
Pid: pid,
|
||||
Width: size.Width,
|
||||
Height: size.Height,
|
||||
@ -155,8 +155,8 @@ func (c *Task) Pty(ctx context.Context, pid uint32, size plugin.ConsoleSize) err
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Task) CloseStdin(ctx context.Context, pid uint32) error {
|
||||
_, err := c.shim.CloseStdin(ctx, &shim.CloseStdinRequest{
|
||||
func (t *Task) CloseStdin(ctx context.Context, pid uint32) error {
|
||||
_, err := t.shim.CloseStdin(ctx, &shim.CloseStdinRequest{
|
||||
Pid: pid,
|
||||
})
|
||||
if err != nil {
|
||||
@ -165,8 +165,8 @@ func (c *Task) CloseStdin(ctx context.Context, pid uint32) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Task) Checkpoint(ctx context.Context, opts plugin.CheckpointOpts) error {
|
||||
_, err := c.shim.Checkpoint(ctx, &shim.CheckpointRequest{
|
||||
func (t *Task) Checkpoint(ctx context.Context, opts plugin.CheckpointOpts) error {
|
||||
_, err := t.shim.Checkpoint(ctx, &shim.CheckpointRequest{
|
||||
Exit: opts.Exit,
|
||||
AllowTcp: opts.AllowTCP,
|
||||
AllowUnixSockets: opts.AllowUnixSockets,
|
||||
@ -181,8 +181,8 @@ func (c *Task) Checkpoint(ctx context.Context, opts plugin.CheckpointOpts) error
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Task) DeleteProcess(ctx context.Context, pid uint32) (*plugin.Exit, error) {
|
||||
r, err := c.shim.DeleteProcess(ctx, &shim.DeleteProcessRequest{
|
||||
func (t *Task) DeleteProcess(ctx context.Context, pid uint32) (*plugin.Exit, error) {
|
||||
r, err := t.shim.DeleteProcess(ctx, &shim.DeleteProcessRequest{
|
||||
Pid: pid,
|
||||
})
|
||||
if err != nil {
|
||||
@ -196,11 +196,11 @@ func (c *Task) DeleteProcess(ctx context.Context, pid uint32) (*plugin.Exit, err
|
||||
|
||||
type Process struct {
|
||||
pid int
|
||||
c *Task
|
||||
t *Task
|
||||
}
|
||||
|
||||
func (p *Process) Kill(ctx context.Context, signal uint32, _ bool) error {
|
||||
_, err := p.c.shim.Kill(ctx, &shim.KillRequest{
|
||||
_, err := p.t.shim.Kill(ctx, &shim.KillRequest{
|
||||
Signal: signal,
|
||||
Pid: uint32(p.pid),
|
||||
})
|
||||
@ -212,7 +212,7 @@ func (p *Process) Kill(ctx context.Context, signal uint32, _ bool) error {
|
||||
|
||||
func (p *Process) State(ctx context.Context) (plugin.State, error) {
|
||||
// use the container status for the status of the process
|
||||
state, err := p.c.State(ctx)
|
||||
state, err := p.t.State(ctx)
|
||||
if err != nil {
|
||||
return state, err
|
||||
}
|
||||
|
@ -178,11 +178,11 @@ func (s *Service) Create(ctx context.Context, r *api.CreateRequest) (*api.Create
|
||||
}
|
||||
|
||||
func (s *Service) Start(ctx context.Context, r *api.StartRequest) (*google_protobuf.Empty, error) {
|
||||
c, err := s.getTask(ctx, r.ContainerID)
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := c.Start(ctx); err != nil {
|
||||
if err := t.Start(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -196,15 +196,15 @@ func (s *Service) Start(ctx context.Context, r *api.StartRequest) (*google_proto
|
||||
}
|
||||
|
||||
func (s *Service) Delete(ctx context.Context, r *api.DeleteRequest) (*api.DeleteResponse, error) {
|
||||
c, err := s.getTask(ctx, r.ContainerID)
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
runtime, err := s.getRuntime(c.Info().Runtime)
|
||||
runtime, err := s.getRuntime(t.Info().Runtime)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
exit, err := runtime.Delete(ctx, c)
|
||||
exit, err := runtime.Delete(ctx, t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -222,11 +222,11 @@ func (s *Service) Delete(ctx context.Context, r *api.DeleteRequest) (*api.Delete
|
||||
}
|
||||
|
||||
func (s *Service) DeleteProcess(ctx context.Context, r *api.DeleteProcessRequest) (*api.DeleteResponse, error) {
|
||||
c, err := s.getTask(ctx, r.ContainerID)
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
exit, err := c.DeleteProcess(ctx, r.Pid)
|
||||
exit, err := t.DeleteProcess(ctx, r.Pid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -304,11 +304,11 @@ func (s *Service) List(ctx context.Context, r *api.ListRequest) (*api.ListRespon
|
||||
}
|
||||
|
||||
func (s *Service) Pause(ctx context.Context, r *api.PauseRequest) (*google_protobuf.Empty, error) {
|
||||
c, err := s.getTask(ctx, r.ContainerID)
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = c.Pause(ctx)
|
||||
err = t.Pause(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -316,11 +316,11 @@ func (s *Service) Pause(ctx context.Context, r *api.PauseRequest) (*google_proto
|
||||
}
|
||||
|
||||
func (s *Service) Resume(ctx context.Context, r *api.ResumeRequest) (*google_protobuf.Empty, error) {
|
||||
c, err := s.getTask(ctx, r.ContainerID)
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = c.Resume(ctx)
|
||||
err = t.Resume(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -328,18 +328,18 @@ func (s *Service) Resume(ctx context.Context, r *api.ResumeRequest) (*google_pro
|
||||
}
|
||||
|
||||
func (s *Service) Kill(ctx context.Context, r *api.KillRequest) (*google_protobuf.Empty, error) {
|
||||
c, err := s.getTask(ctx, r.ContainerID)
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch v := r.PidOrAll.(type) {
|
||||
case *api.KillRequest_All:
|
||||
if err := c.Kill(ctx, r.Signal, 0, true); err != nil {
|
||||
if err := t.Kill(ctx, r.Signal, 0, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case *api.KillRequest_Pid:
|
||||
if err := c.Kill(ctx, r.Signal, v.Pid, false); err != nil {
|
||||
if err := t.Kill(ctx, r.Signal, v.Pid, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
@ -349,12 +349,12 @@ func (s *Service) Kill(ctx context.Context, r *api.KillRequest) (*google_protobu
|
||||
}
|
||||
|
||||
func (s *Service) Processes(ctx context.Context, r *api.ProcessesRequest) (*api.ProcessesResponse, error) {
|
||||
c, err := s.getTask(ctx, r.ContainerID)
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pids, err := c.Processes(ctx)
|
||||
pids, err := t.Processes(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -381,11 +381,11 @@ func (s *Service) Events(r *api.EventsRequest, server api.Tasks_EventsServer) er
|
||||
}
|
||||
|
||||
func (s *Service) Exec(ctx context.Context, r *api.ExecRequest) (*api.ExecResponse, error) {
|
||||
c, err := s.getTask(ctx, r.ContainerID)
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
process, err := c.Exec(ctx, plugin.ExecOpts{
|
||||
process, err := t.Exec(ctx, plugin.ExecOpts{
|
||||
Spec: r.Spec.Value,
|
||||
IO: plugin.IO{
|
||||
Stdin: r.Stdin,
|
||||
@ -407,11 +407,11 @@ func (s *Service) Exec(ctx context.Context, r *api.ExecRequest) (*api.ExecRespon
|
||||
}
|
||||
|
||||
func (s *Service) Pty(ctx context.Context, r *api.PtyRequest) (*google_protobuf.Empty, error) {
|
||||
c, err := s.getTask(ctx, r.ContainerID)
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := c.Pty(ctx, r.Pid, plugin.ConsoleSize{
|
||||
if err := t.Pty(ctx, r.Pid, plugin.ConsoleSize{
|
||||
Width: r.Width,
|
||||
Height: r.Height,
|
||||
}); err != nil {
|
||||
@ -421,18 +421,18 @@ func (s *Service) Pty(ctx context.Context, r *api.PtyRequest) (*google_protobuf.
|
||||
}
|
||||
|
||||
func (s *Service) CloseStdin(ctx context.Context, r *api.CloseStdinRequest) (*google_protobuf.Empty, error) {
|
||||
c, err := s.getTask(ctx, r.ContainerID)
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := c.CloseStdin(ctx, r.Pid); err != nil {
|
||||
if err := t.CloseStdin(ctx, r.Pid); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return empty, nil
|
||||
}
|
||||
|
||||
func (s *Service) Checkpoint(ctx context.Context, r *api.CheckpointRequest) (*api.CheckpointResponse, error) {
|
||||
c, err := s.getTask(ctx, r.ContainerID)
|
||||
t, err := s.getTask(ctx, r.ContainerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -441,7 +441,7 @@ func (s *Service) Checkpoint(ctx context.Context, r *api.CheckpointRequest) (*ap
|
||||
return nil, err
|
||||
}
|
||||
defer os.RemoveAll(image)
|
||||
if err := c.Checkpoint(ctx, plugin.CheckpointOpts{
|
||||
if err := t.Checkpoint(ctx, plugin.CheckpointOpts{
|
||||
Exit: r.Exit,
|
||||
AllowTCP: r.AllowTcp,
|
||||
AllowTerminal: r.AllowTerminal,
|
||||
@ -464,7 +464,7 @@ func (s *Service) Checkpoint(ctx context.Context, r *api.CheckpointRequest) (*ap
|
||||
return nil, err
|
||||
}
|
||||
// write the config to the content store
|
||||
spec := bytes.NewReader(c.Info().Spec)
|
||||
spec := bytes.NewReader(t.Info().Spec)
|
||||
specD, err := s.writeContent(ctx, images.MediaTypeContainerd1CheckpointConfig, filepath.Join(image, "spec"), spec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user