remotecommand

package
v0.0.0-...-7ef7dd6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusSuccess = "Success"
	StatusFailure = "Failure"
)

Values of Status.Status

Variables

This section is empty.

Functions

func ServeAttach

func ServeAttach(ctx context.Context, w http.ResponseWriter, req *http.Request, attacher Attacher, container string, streamOpts *Options, idleTimeout, streamCreationTimeout time.Duration, supportedProtocols []string)

ServeAttach handles requests to attach to a container. After creating/receiving the required streams, it delegates the actual attaching to attacher.

func ServeExec

func ServeExec(ctx context.Context, w http.ResponseWriter, req *http.Request, executor Executor, container string, cmd []string, streamOpts *Options, supportedProtocols []string, idleTimeout time.Duration, streamCreationTimeout time.Duration)

ServeExec handles requests to execute a command in a container. After creating/receiving the required streams, it delegates the actual execution to the executor.

Types

type Attacher

type Attacher interface {
	// Attach attaches to the running container in the pod.
	Attach(ctx context.Context, containerID string, streamOpts *Options, streams *Streams) error
}

Attacher knows how to attach a running container in a pod.

type CauseType

type CauseType string

CauseType is a machine readable value providing more detail about what occurred in a status response. An operation may have multiple causes for a status (whether Failure or Success).

const (
	// ExitCodeCauseType indicates that the status cause is the command's exit code is not zero.
	ExitCodeCauseType CauseType = "ExitCode"
)

type Executor

type Executor interface {
	// Exec executes a command in a container of the pod.
	Exec(ctx context.Context, containerID string, cmd []string, resizeChan <-chan apitypes.ResizeOptions, streamOpts *Options, streams *Streams) (uint32, error)
}

Executor knows how to execute a command in a container of the pod.

type Options

type Options struct {
	Stdin  bool
	Stdout bool
	Stderr bool
	TTY    bool
}

Options contains details about which streams are required for remote command execution.

type Status

type Status struct {
	// Status of the operation.
	// One of: "Success" or "Failure".
	// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
	// +optional
	Status string `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"`
	// A human-readable description of the status of this operation.
	// +optional
	Message string `json:"message,omitempty" protobuf:"bytes,3,opt,name=message"`
	// A machine-readable description of why this operation is in the
	// "Failure" status. If this value is empty there
	// is no information available. A Reason clarifies an HTTP status
	// code but does not override it.
	// +optional
	Reason StatusReason `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason,casttype=StatusReason"`
	// Extended data associated with the reason.  Each reason may define its
	// own extended details. This field is optional and the data returned
	// is not guaranteed to conform to any schema except that defined by
	// the reason type.
	// +optional
	Details *StatusDetails `json:"details,omitempty" protobuf:"bytes,5,opt,name=details"`
	// Suggested HTTP return code for this status, 0 if not set.
	// +optional
	Code int32 `json:"code,omitempty" protobuf:"varint,6,opt,name=code"`
}

Status is a return value for calls that don't return other objects.

type StatusCause

type StatusCause struct {
	// A machine-readable description of the cause of the error. If this value is
	// empty there is no information available.
	// +optional
	Type CauseType `json:"reason,omitempty" protobuf:"bytes,1,opt,name=reason,casttype=CauseType"`
	// A human-readable description of the cause of the error.  This field may be
	// presented as-is to a reader.
	// +optional
	Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
}

StatusCause provides more information about an api.Status failure, including cases when multiple errors are encountered.

type StatusDetails

type StatusDetails struct {
	Causes []StatusCause `json:"causes,omitempty" protobuf:"bytes,4,rep,name=causes"`
}

StatusDetails is a set of additional properties that MAY be set by the server to provide additional information about a response. The Reason field of a Status object defines what attributes will be set. Clients must ignore fields that do not match the defined type of each attribute, and should assume that any attribute may be empty, invalid, or under defined.

type StatusError

type StatusError struct {
	ErrStatus Status
}

StatusError is an error intended for consumption by a REST API server; it can also be reconstructed by clients from a REST response. Public to allow easy type switches.

func NewInternalError

func NewInternalError(err error) *StatusError

NewInternalError returns an error indicating the item is invalid and cannot be processed.

func (*StatusError) Error

func (e *StatusError) Error() string

Error implements the Error interface.

func (*StatusError) Status

func (e *StatusError) Status() Status

Status allows access to e's status without having to know the detailed workings of StatusError.

type StatusReason

type StatusReason string

StatusReason is an enumeration of possible failure causes. Each StatusReason must map to a single HTTP status code, but multiple reasons may map to the same HTTP status code. TODO: move to apiserver

const (
	// NonZeroExitCodeReason indicates that the command executing failed with non zero exit code.
	NonZeroExitCodeReason StatusReason = "NonZeroExitCode"

	// StatusReasonInternalError indicates that an internal error occurred, it is unexpected
	// and the outcome of the call is unknown.
	// Details (optional):
	//   "causes" - The original error
	// Status code 500
	StatusReasonInternalError StatusReason = "InternalError"
)

type Streams

type Streams struct {
	// Notified from StreamCh if streams broken.
	StreamCh     chan struct{}
	StdinStream  io.ReadCloser
	StdoutStream io.WriteCloser
	StderrStream io.WriteCloser
}

Streams contains all the streams used to stdio for remote command execution.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL