mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
use status.Errorf instead of Deprecated func grpc.Errorf
This commit is contained in:
parent
3a2fe7b8f9
commit
b48e7b2218
@ -21,6 +21,7 @@ go_library(
|
|||||||
"//vendor/github.com/emicklei/go-restful:go_default_library",
|
"//vendor/github.com/emicklei/go-restful:go_default_library",
|
||||||
"//vendor/google.golang.org/grpc:go_default_library",
|
"//vendor/google.golang.org/grpc:go_default_library",
|
||||||
"//vendor/google.golang.org/grpc/codes:go_default_library",
|
"//vendor/google.golang.org/grpc/codes:go_default_library",
|
||||||
|
"//vendor/google.golang.org/grpc/status:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/clock:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/clock:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/remotecommand:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/remotecommand:go_default_library",
|
||||||
|
@ -23,15 +23,16 @@ import (
|
|||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ErrorStreamingDisabled(method string) error {
|
func ErrorStreamingDisabled(method string) error {
|
||||||
return grpc.Errorf(codes.NotFound, fmt.Sprintf("streaming method %s disabled", method))
|
return status.Errorf(codes.NotFound, fmt.Sprintf("streaming method %s disabled", method))
|
||||||
}
|
}
|
||||||
|
|
||||||
// The error returned when the maximum number of in-flight requests is exceeded.
|
// The error returned when the maximum number of in-flight requests is exceeded.
|
||||||
func ErrorTooManyInFlight() error {
|
func ErrorTooManyInFlight() error {
|
||||||
return grpc.Errorf(codes.ResourceExhausted, "maximum number of in-flight requests exceeded")
|
return status.Errorf(codes.ResourceExhausted, "maximum number of in-flight requests exceeded")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translates a CRI streaming error into an appropriate HTTP response.
|
// Translates a CRI streaming error into an appropriate HTTP response.
|
||||||
|
@ -25,8 +25,8 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
|
||||||
restful "github.com/emicklei/go-restful"
|
restful "github.com/emicklei/go-restful"
|
||||||
|
|
||||||
@ -160,15 +160,15 @@ type server struct {
|
|||||||
|
|
||||||
func validateExecRequest(req *runtimeapi.ExecRequest) error {
|
func validateExecRequest(req *runtimeapi.ExecRequest) error {
|
||||||
if req.ContainerId == "" {
|
if req.ContainerId == "" {
|
||||||
return grpc.Errorf(codes.InvalidArgument, "missing required container_id")
|
return status.Errorf(codes.InvalidArgument, "missing required container_id")
|
||||||
}
|
}
|
||||||
if req.Tty && req.Stderr {
|
if req.Tty && req.Stderr {
|
||||||
// If TTY is set, stderr cannot be true because multiplexing is not
|
// If TTY is set, stderr cannot be true because multiplexing is not
|
||||||
// supported.
|
// supported.
|
||||||
return grpc.Errorf(codes.InvalidArgument, "tty and stderr cannot both be true")
|
return status.Errorf(codes.InvalidArgument, "tty and stderr cannot both be true")
|
||||||
}
|
}
|
||||||
if !req.Stdin && !req.Stdout && !req.Stderr {
|
if !req.Stdin && !req.Stdout && !req.Stderr {
|
||||||
return grpc.Errorf(codes.InvalidArgument, "one of stdin, stdout, or stderr must be set")
|
return status.Errorf(codes.InvalidArgument, "one of stdin, stdout, or stderr must be set")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -188,15 +188,15 @@ func (s *server) GetExec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse,
|
|||||||
|
|
||||||
func validateAttachRequest(req *runtimeapi.AttachRequest) error {
|
func validateAttachRequest(req *runtimeapi.AttachRequest) error {
|
||||||
if req.ContainerId == "" {
|
if req.ContainerId == "" {
|
||||||
return grpc.Errorf(codes.InvalidArgument, "missing required container_id")
|
return status.Errorf(codes.InvalidArgument, "missing required container_id")
|
||||||
}
|
}
|
||||||
if req.Tty && req.Stderr {
|
if req.Tty && req.Stderr {
|
||||||
// If TTY is set, stderr cannot be true because multiplexing is not
|
// If TTY is set, stderr cannot be true because multiplexing is not
|
||||||
// supported.
|
// supported.
|
||||||
return grpc.Errorf(codes.InvalidArgument, "tty and stderr cannot both be true")
|
return status.Errorf(codes.InvalidArgument, "tty and stderr cannot both be true")
|
||||||
}
|
}
|
||||||
if !req.Stdin && !req.Stdout && !req.Stderr {
|
if !req.Stdin && !req.Stdout && !req.Stderr {
|
||||||
return grpc.Errorf(codes.InvalidArgument, "one of stdin, stdout, and stderr must be set")
|
return status.Errorf(codes.InvalidArgument, "one of stdin, stdout, and stderr must be set")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ func (s *server) GetAttach(req *runtimeapi.AttachRequest) (*runtimeapi.AttachRes
|
|||||||
|
|
||||||
func (s *server) GetPortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) {
|
func (s *server) GetPortForward(req *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) {
|
||||||
if req.PodSandboxId == "" {
|
if req.PodSandboxId == "" {
|
||||||
return nil, grpc.Errorf(codes.InvalidArgument, "missing required pod_sandbox_id")
|
return nil, status.Errorf(codes.InvalidArgument, "missing required pod_sandbox_id")
|
||||||
}
|
}
|
||||||
token, err := s.cache.Insert(req)
|
token, err := s.cache.Insert(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user