Remove enumvalue_customname, goproto_enum_prefix and enum_customname
This commit removes gogoproto.enumvalue_customname, gogoproto.goproto_enum_prefix and gogoproto.enum_customname. All of them make proto-generated Go code more idiomatic, but we already don't use these enums in our external-surfacing types and they are anyway not supported by Google's official toolchain (see #6564). Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
@@ -56,6 +56,23 @@ func (p *Process) Kill(ctx context.Context, signal uint32, _ bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func statusFromProto(from task.Status) runtime.Status {
|
||||
var status runtime.Status
|
||||
switch from {
|
||||
case task.Status_CREATED:
|
||||
status = runtime.CreatedStatus
|
||||
case task.Status_RUNNING:
|
||||
status = runtime.RunningStatus
|
||||
case task.Status_STOPPED:
|
||||
status = runtime.StoppedStatus
|
||||
case task.Status_PAUSED:
|
||||
status = runtime.PausedStatus
|
||||
case task.Status_PAUSING:
|
||||
status = runtime.PausingStatus
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
// State of process
|
||||
func (p *Process) State(ctx context.Context) (runtime.State, error) {
|
||||
// use the container status for the status of the process
|
||||
@@ -72,22 +89,9 @@ func (p *Process) State(ctx context.Context) (runtime.State, error) {
|
||||
// the connection differently if this causes problems.
|
||||
return runtime.State{}, errdefs.ErrNotFound
|
||||
}
|
||||
var status runtime.Status
|
||||
switch response.Status {
|
||||
case task.StatusCreated:
|
||||
status = runtime.CreatedStatus
|
||||
case task.StatusRunning:
|
||||
status = runtime.RunningStatus
|
||||
case task.StatusStopped:
|
||||
status = runtime.StoppedStatus
|
||||
case task.StatusPaused:
|
||||
status = runtime.PausedStatus
|
||||
case task.StatusPausing:
|
||||
status = runtime.PausingStatus
|
||||
}
|
||||
return runtime.State{
|
||||
Pid: response.Pid,
|
||||
Status: status,
|
||||
Status: statusFromProto(response.Status),
|
||||
Stdin: response.Stdin,
|
||||
Stdout: response.Stdout,
|
||||
Stderr: response.Stderr,
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
|
||||
"github.com/containerd/cgroups"
|
||||
eventstypes "github.com/containerd/containerd/api/events"
|
||||
"github.com/containerd/containerd/api/types/task"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/events/exchange"
|
||||
"github.com/containerd/containerd/identifiers"
|
||||
@@ -166,22 +165,9 @@ func (t *Task) State(ctx context.Context) (runtime.State, error) {
|
||||
}
|
||||
return runtime.State{}, errdefs.ErrNotFound
|
||||
}
|
||||
var status runtime.Status
|
||||
switch response.Status {
|
||||
case task.StatusCreated:
|
||||
status = runtime.CreatedStatus
|
||||
case task.StatusRunning:
|
||||
status = runtime.RunningStatus
|
||||
case task.StatusStopped:
|
||||
status = runtime.StoppedStatus
|
||||
case task.StatusPaused:
|
||||
status = runtime.PausedStatus
|
||||
case task.StatusPausing:
|
||||
status = runtime.PausingStatus
|
||||
}
|
||||
return runtime.State{
|
||||
Pid: response.Pid,
|
||||
Status: status,
|
||||
Status: statusFromProto(response.Status),
|
||||
Stdin: response.Stdin,
|
||||
Stdout: response.Stdout,
|
||||
Stderr: response.Stderr,
|
||||
|
||||
@@ -314,18 +314,18 @@ func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
status := task.StatusUnknown
|
||||
status := task.Status_UNKNOWN
|
||||
switch st {
|
||||
case "created":
|
||||
status = task.StatusCreated
|
||||
status = task.Status_CREATED
|
||||
case "running":
|
||||
status = task.StatusRunning
|
||||
status = task.Status_RUNNING
|
||||
case "stopped":
|
||||
status = task.StatusStopped
|
||||
status = task.Status_STOPPED
|
||||
case "paused":
|
||||
status = task.StatusPaused
|
||||
status = task.Status_PAUSED
|
||||
case "pausing":
|
||||
status = task.StatusPausing
|
||||
status = task.Status_PAUSING
|
||||
}
|
||||
sio := p.Stdio()
|
||||
return &shimapi.StateResponse{
|
||||
|
||||
@@ -48,6 +48,23 @@ func (p *process) Kill(ctx context.Context, signal uint32, _ bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func statusFromProto(from tasktypes.Status) runtime.Status {
|
||||
var status runtime.Status
|
||||
switch from {
|
||||
case tasktypes.Status_CREATED:
|
||||
status = runtime.CreatedStatus
|
||||
case tasktypes.Status_RUNNING:
|
||||
status = runtime.RunningStatus
|
||||
case tasktypes.Status_STOPPED:
|
||||
status = runtime.StoppedStatus
|
||||
case tasktypes.Status_PAUSED:
|
||||
status = runtime.PausedStatus
|
||||
case tasktypes.Status_PAUSING:
|
||||
status = runtime.PausingStatus
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
func (p *process) State(ctx context.Context) (runtime.State, error) {
|
||||
response, err := p.shim.task.State(ctx, &task.StateRequest{
|
||||
ID: p.shim.ID(),
|
||||
@@ -59,22 +76,9 @@ func (p *process) State(ctx context.Context) (runtime.State, error) {
|
||||
}
|
||||
return runtime.State{}, errdefs.ErrNotFound
|
||||
}
|
||||
var status runtime.Status
|
||||
switch response.Status {
|
||||
case tasktypes.StatusCreated:
|
||||
status = runtime.CreatedStatus
|
||||
case tasktypes.StatusRunning:
|
||||
status = runtime.RunningStatus
|
||||
case tasktypes.StatusStopped:
|
||||
status = runtime.StoppedStatus
|
||||
case tasktypes.StatusPaused:
|
||||
status = runtime.PausedStatus
|
||||
case tasktypes.StatusPausing:
|
||||
status = runtime.PausingStatus
|
||||
}
|
||||
return runtime.State{
|
||||
Pid: response.Pid,
|
||||
Status: status,
|
||||
Status: statusFromProto(response.Status),
|
||||
Stdin: response.Stdin,
|
||||
Stdout: response.Stdout,
|
||||
Stderr: response.Stderr,
|
||||
|
||||
@@ -285,18 +285,18 @@ func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (*taskAPI.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
status := task.StatusUnknown
|
||||
status := task.Status_UNKNOWN
|
||||
switch st {
|
||||
case "created":
|
||||
status = task.StatusCreated
|
||||
status = task.Status_CREATED
|
||||
case "running":
|
||||
status = task.StatusRunning
|
||||
status = task.Status_RUNNING
|
||||
case "stopped":
|
||||
status = task.StatusStopped
|
||||
status = task.Status_STOPPED
|
||||
case "paused":
|
||||
status = task.StatusPaused
|
||||
status = task.Status_PAUSED
|
||||
case "pausing":
|
||||
status = task.StatusPausing
|
||||
status = task.Status_PAUSING
|
||||
}
|
||||
sio := p.Stdio()
|
||||
return &taskAPI.StateResponse{
|
||||
|
||||
@@ -417,18 +417,18 @@ func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (*taskAPI.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
status := task.StatusUnknown
|
||||
status := task.Status_UNKNOWN
|
||||
switch st {
|
||||
case "created":
|
||||
status = task.StatusCreated
|
||||
status = task.Status_CREATED
|
||||
case "running":
|
||||
status = task.StatusRunning
|
||||
status = task.Status_RUNNING
|
||||
case "stopped":
|
||||
status = task.StatusStopped
|
||||
status = task.Status_STOPPED
|
||||
case "paused":
|
||||
status = task.StatusPaused
|
||||
status = task.Status_PAUSED
|
||||
case "pausing":
|
||||
status = task.StatusPausing
|
||||
status = task.Status_PAUSING
|
||||
}
|
||||
sio := p.Stdio()
|
||||
return &taskAPI.StateResponse{
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
|
||||
eventstypes "github.com/containerd/containerd/api/events"
|
||||
"github.com/containerd/containerd/api/types"
|
||||
tasktypes "github.com/containerd/containerd/api/types/task"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/events/exchange"
|
||||
"github.com/containerd/containerd/identifiers"
|
||||
@@ -526,22 +525,9 @@ func (s *shimTask) State(ctx context.Context) (runtime.State, error) {
|
||||
}
|
||||
return runtime.State{}, errdefs.ErrNotFound
|
||||
}
|
||||
var status runtime.Status
|
||||
switch response.Status {
|
||||
case tasktypes.StatusCreated:
|
||||
status = runtime.CreatedStatus
|
||||
case tasktypes.StatusRunning:
|
||||
status = runtime.RunningStatus
|
||||
case tasktypes.StatusStopped:
|
||||
status = runtime.StoppedStatus
|
||||
case tasktypes.StatusPaused:
|
||||
status = runtime.PausedStatus
|
||||
case tasktypes.StatusPausing:
|
||||
status = runtime.PausingStatus
|
||||
}
|
||||
return runtime.State{
|
||||
Pid: response.Pid,
|
||||
Status: status,
|
||||
Status: statusFromProto(response.Status),
|
||||
Stdin: response.Stdin,
|
||||
Stdout: response.Stdout,
|
||||
Stderr: response.Stderr,
|
||||
|
||||
Reference in New Issue
Block a user