Rename variables holding a task from c
to t
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user