Merge pull request #1042 from mlaventure/fix-var-names

Rename variables holding a task from `c` to `t`
This commit is contained in:
Michael Crosby 2017-06-21 10:21:18 -07:00 committed by GitHub
commit 3cdd7a9153
2 changed files with 57 additions and 57 deletions

View File

@ -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{ return plugin.TaskInfo{
ID: c.containerID, ID: t.containerID,
ContainerID: c.containerID, ContainerID: t.containerID,
Runtime: pluginID, Runtime: pluginID,
Spec: c.spec, Spec: t.spec,
Namespace: c.namespace, Namespace: t.namespace,
} }
} }
func (c *Task) Start(ctx context.Context) error { func (t *Task) Start(ctx context.Context) error {
_, err := c.shim.Start(ctx, &shim.StartRequest{}) _, err := t.shim.Start(ctx, &shim.StartRequest{})
if err != nil { if err != nil {
err = errors.New(grpc.ErrorDesc(err)) err = errors.New(grpc.ErrorDesc(err))
} }
return err return err
} }
func (c *Task) State(ctx context.Context) (plugin.State, error) { func (t *Task) State(ctx context.Context) (plugin.State, error) {
response, err := c.shim.State(ctx, &shim.StateRequest{}) response, err := t.shim.State(ctx, &shim.StateRequest{})
if err != nil { if err != nil {
return plugin.State{}, errors.New(grpc.ErrorDesc(err)) return plugin.State{}, errors.New(grpc.ErrorDesc(err))
} }
@ -76,24 +76,24 @@ func (c *Task) State(ctx context.Context) (plugin.State, error) {
}, nil }, nil
} }
func (c *Task) Pause(ctx context.Context) error { func (t *Task) Pause(ctx context.Context) error {
_, err := c.shim.Pause(ctx, &shim.PauseRequest{}) _, err := t.shim.Pause(ctx, &shim.PauseRequest{})
if err != nil { if err != nil {
err = errors.New(grpc.ErrorDesc(err)) err = errors.New(grpc.ErrorDesc(err))
} }
return err return err
} }
func (c *Task) Resume(ctx context.Context) error { func (t *Task) Resume(ctx context.Context) error {
_, err := c.shim.Resume(ctx, &shim.ResumeRequest{}) _, err := t.shim.Resume(ctx, &shim.ResumeRequest{})
if err != nil { if err != nil {
err = errors.New(grpc.ErrorDesc(err)) err = errors.New(grpc.ErrorDesc(err))
} }
return err return err
} }
func (c *Task) Kill(ctx context.Context, signal uint32, pid uint32, all bool) error { func (t *Task) Kill(ctx context.Context, signal uint32, pid uint32, all bool) error {
_, err := c.shim.Kill(ctx, &shim.KillRequest{ _, err := t.shim.Kill(ctx, &shim.KillRequest{
Signal: signal, Signal: signal,
Pid: pid, Pid: pid,
All: all, All: all,
@ -104,7 +104,7 @@ func (c *Task) Kill(ctx context.Context, signal uint32, pid uint32, all bool) er
return err 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{ request := &shim.ExecRequest{
Stdin: opts.IO.Stdin, Stdin: opts.IO.Stdin,
Stdout: opts.IO.Stdout, Stdout: opts.IO.Stdout,
@ -115,20 +115,20 @@ func (c *Task) Exec(ctx context.Context, opts plugin.ExecOpts) (plugin.Process,
Value: opts.Spec, Value: opts.Spec,
}, },
} }
resp, err := c.shim.Exec(ctx, request) resp, err := t.shim.Exec(ctx, request)
if err != nil { if err != nil {
return nil, errors.New(grpc.ErrorDesc(err)) return nil, errors.New(grpc.ErrorDesc(err))
} }
return &Process{ return &Process{
pid: int(resp.Pid), pid: int(resp.Pid),
c: c, t: t,
}, nil }, nil
} }
func (c *Task) Processes(ctx context.Context) ([]uint32, error) { func (t *Task) Processes(ctx context.Context) ([]uint32, error) {
resp, err := c.shim.Processes(ctx, &shim.ProcessesRequest{ resp, err := t.shim.Processes(ctx, &shim.ProcessesRequest{
ID: c.containerID, ID: t.containerID,
}) })
if err != nil { if err != nil {
return nil, errors.New(grpc.ErrorDesc(err)) return nil, errors.New(grpc.ErrorDesc(err))
@ -143,8 +143,8 @@ func (c *Task) Processes(ctx context.Context) ([]uint32, error) {
return pids, nil return pids, nil
} }
func (c *Task) Pty(ctx context.Context, pid uint32, size plugin.ConsoleSize) error { func (t *Task) Pty(ctx context.Context, pid uint32, size plugin.ConsoleSize) error {
_, err := c.shim.Pty(ctx, &shim.PtyRequest{ _, err := t.shim.Pty(ctx, &shim.PtyRequest{
Pid: pid, Pid: pid,
Width: size.Width, Width: size.Width,
Height: size.Height, Height: size.Height,
@ -155,8 +155,8 @@ func (c *Task) Pty(ctx context.Context, pid uint32, size plugin.ConsoleSize) err
return err return err
} }
func (c *Task) CloseStdin(ctx context.Context, pid uint32) error { func (t *Task) CloseStdin(ctx context.Context, pid uint32) error {
_, err := c.shim.CloseStdin(ctx, &shim.CloseStdinRequest{ _, err := t.shim.CloseStdin(ctx, &shim.CloseStdinRequest{
Pid: pid, Pid: pid,
}) })
if err != nil { if err != nil {
@ -165,8 +165,8 @@ func (c *Task) CloseStdin(ctx context.Context, pid uint32) error {
return err return err
} }
func (c *Task) Checkpoint(ctx context.Context, opts plugin.CheckpointOpts) error { func (t *Task) Checkpoint(ctx context.Context, opts plugin.CheckpointOpts) error {
_, err := c.shim.Checkpoint(ctx, &shim.CheckpointRequest{ _, err := t.shim.Checkpoint(ctx, &shim.CheckpointRequest{
Exit: opts.Exit, Exit: opts.Exit,
AllowTcp: opts.AllowTCP, AllowTcp: opts.AllowTCP,
AllowUnixSockets: opts.AllowUnixSockets, AllowUnixSockets: opts.AllowUnixSockets,
@ -181,8 +181,8 @@ func (c *Task) Checkpoint(ctx context.Context, opts plugin.CheckpointOpts) error
return err return err
} }
func (c *Task) DeleteProcess(ctx context.Context, pid uint32) (*plugin.Exit, error) { func (t *Task) DeleteProcess(ctx context.Context, pid uint32) (*plugin.Exit, error) {
r, err := c.shim.DeleteProcess(ctx, &shim.DeleteProcessRequest{ r, err := t.shim.DeleteProcess(ctx, &shim.DeleteProcessRequest{
Pid: pid, Pid: pid,
}) })
if err != nil { if err != nil {
@ -196,11 +196,11 @@ func (c *Task) DeleteProcess(ctx context.Context, pid uint32) (*plugin.Exit, err
type Process struct { type Process struct {
pid int pid int
c *Task t *Task
} }
func (p *Process) Kill(ctx context.Context, signal uint32, _ bool) error { 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, Signal: signal,
Pid: uint32(p.pid), 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) { func (p *Process) State(ctx context.Context) (plugin.State, error) {
// use the container status for the status of the process // 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 { if err != nil {
return state, err return state, err
} }

View File

@ -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) { 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 { if err != nil {
return nil, err return nil, err
} }
if err := c.Start(ctx); err != nil { if err := t.Start(ctx); err != nil {
return nil, err 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) { 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 { if err != nil {
return nil, err return nil, err
} }
runtime, err := s.getRuntime(c.Info().Runtime) runtime, err := s.getRuntime(t.Info().Runtime)
if err != nil { if err != nil {
return nil, err return nil, err
} }
exit, err := runtime.Delete(ctx, c) exit, err := runtime.Delete(ctx, t)
if err != nil { if err != nil {
return nil, err 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) { 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 { if err != nil {
return nil, err return nil, err
} }
exit, err := c.DeleteProcess(ctx, r.Pid) exit, err := t.DeleteProcess(ctx, r.Pid)
if err != nil { if err != nil {
return nil, err 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) { 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 { if err != nil {
return nil, err return nil, err
} }
err = c.Pause(ctx) err = t.Pause(ctx)
if err != nil { if err != nil {
return nil, err 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) { 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 { if err != nil {
return nil, err return nil, err
} }
err = c.Resume(ctx) err = t.Resume(ctx)
if err != nil { if err != nil {
return nil, err 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) { 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 { if err != nil {
return nil, err return nil, err
} }
switch v := r.PidOrAll.(type) { switch v := r.PidOrAll.(type) {
case *api.KillRequest_All: 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 return nil, err
} }
case *api.KillRequest_Pid: 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 return nil, err
} }
default: 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) { 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 { if err != nil {
return nil, err return nil, err
} }
pids, err := c.Processes(ctx) pids, err := t.Processes(ctx)
if err != nil { if err != nil {
return nil, err 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) { 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 { if err != nil {
return nil, err return nil, err
} }
process, err := c.Exec(ctx, plugin.ExecOpts{ process, err := t.Exec(ctx, plugin.ExecOpts{
Spec: r.Spec.Value, Spec: r.Spec.Value,
IO: plugin.IO{ IO: plugin.IO{
Stdin: r.Stdin, 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) { 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 { if err != nil {
return nil, err return nil, err
} }
if err := c.Pty(ctx, r.Pid, plugin.ConsoleSize{ if err := t.Pty(ctx, r.Pid, plugin.ConsoleSize{
Width: r.Width, Width: r.Width,
Height: r.Height, Height: r.Height,
}); err != nil { }); 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) { 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 { if err != nil {
return nil, err 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 nil, err
} }
return empty, nil return empty, nil
} }
func (s *Service) Checkpoint(ctx context.Context, r *api.CheckpointRequest) (*api.CheckpointResponse, error) { 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 { if err != nil {
return nil, err return nil, err
} }
@ -441,7 +441,7 @@ func (s *Service) Checkpoint(ctx context.Context, r *api.CheckpointRequest) (*ap
return nil, err return nil, err
} }
defer os.RemoveAll(image) defer os.RemoveAll(image)
if err := c.Checkpoint(ctx, plugin.CheckpointOpts{ if err := t.Checkpoint(ctx, plugin.CheckpointOpts{
Exit: r.Exit, Exit: r.Exit,
AllowTCP: r.AllowTcp, AllowTCP: r.AllowTcp,
AllowTerminal: r.AllowTerminal, AllowTerminal: r.AllowTerminal,
@ -464,7 +464,7 @@ func (s *Service) Checkpoint(ctx context.Context, r *api.CheckpointRequest) (*ap
return nil, err return nil, err
} }
// write the config to the content store // 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) specD, err := s.writeContent(ctx, images.MediaTypeContainerd1CheckpointConfig, filepath.Join(image, "spec"), spec)
if err != nil { if err != nil {
return nil, err return nil, err