runner

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: MIT Imports: 23 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateInteractiveStreamOptions

func CreateInteractiveStreamOptions(streams IOStreams) (remotecommand.StreamOptions, func(term.SafeFunc) error)

CreateInteractiveStreamOptions constructs streaming configuration that attaches the default OS stdout, stderr, stdin, with a tty, and an additional function which should be used to wrap any interactive process that will make use of the tty.

Types

type AttachOptions

type AttachOptions struct {
	Namespace  string
	KubeConfig *rest.Config
	Name       string

	IO IOStreams

	// Lifecycle hook to notify when the state of the console changes
	Hook LifecycleHook
}

AttachOptions encapsulates the arguments to attach to a console

func (AttachOptions) WithDefaults

func (opts AttachOptions) WithDefaults() AttachOptions

WithDefaults sets any unset options to defaults

type Attacher

type Attacher struct {
	// contains filtered or unexported fields
}

Attacher knows how to attach to stdio of an existing container, relaying io to the parent process file descriptors.

func NewAttacher

func NewAttacher(clientset kubernetes.Interface, restconfig *rest.Config) *Attacher

func (*Attacher) Attach

func (a *Attacher) Attach(ctx context.Context, pod *corev1.Pod, streams IOStreams) error

Attach will interactively attach to a containers output, creating a new TTY and hooking this into the current processes file descriptors.

type AuthoriseOptions

type AuthoriseOptions struct {
	Namespace   string
	ConsoleName string
	Username    string
}

type ConsoleSlice

type ConsoleSlice []workloadsv1alpha1.Console

func (ConsoleSlice) Print

func (cs ConsoleSlice) Print(output io.Writer) error

type CreateOptions

type CreateOptions struct {
	Namespace string
	Selector  string
	Timeout   time.Duration
	Reason    string
	Command   []string
	Attach    bool

	// Options only used when Attach is true
	KubeConfig *rest.Config
	IO         IOStreams

	// Lifecycle hook to notify when the state of the console changes
	Hook LifecycleHook
}

CreateOptions encapsulates the arguments to create a console

func (CreateOptions) WithDefaults

func (opts CreateOptions) WithDefaults() CreateOptions

WithDefaults sets any unset options to defaults

type DefaultLifecycleHook

type DefaultLifecycleHook struct {
	AttachingToPodFunc               func(*workloadsv1alpha1.Console) error
	ConsoleCreatedFunc               func(*workloadsv1alpha1.Console) error
	ConsoleRequiresAuthorisationFunc func(*workloadsv1alpha1.Console, *workloadsv1alpha1.ConsoleAuthorisationRule) error
	ConsoleReadyFunc                 func(*workloadsv1alpha1.Console) error
	TemplateFoundFunc                func(*workloadsv1alpha1.ConsoleTemplate) error
}

func (DefaultLifecycleHook) AttachingToConsole

func (d DefaultLifecycleHook) AttachingToConsole(c *workloadsv1alpha1.Console) error

func (DefaultLifecycleHook) ConsoleCreated

func (d DefaultLifecycleHook) ConsoleCreated(c *workloadsv1alpha1.Console) error

func (DefaultLifecycleHook) ConsoleReady

func (DefaultLifecycleHook) ConsoleRequiresAuthorisation

func (DefaultLifecycleHook) TemplateFound

type GetOptions

type GetOptions struct {
	Namespace   string
	ConsoleName string
}

type IOStreams

type IOStreams genericclioptions.IOStreams

Alias genericclioptions.IOStreams to avoid additional imports

type LifecycleHook

type LifecycleHook interface {
	AttachingToConsole(*workloadsv1alpha1.Console) error
	ConsoleCreated(*workloadsv1alpha1.Console) error
	ConsoleRequiresAuthorisation(*workloadsv1alpha1.Console, *workloadsv1alpha1.ConsoleAuthorisationRule) error
	ConsoleReady(*workloadsv1alpha1.Console) error
	TemplateFound(*workloadsv1alpha1.ConsoleTemplate) error
}

LifecycleHook provides a communication to react to console lifecycle changes

type ListOptions

type ListOptions struct {
	Namespace string
	Username  string
	Selector  string
	Output    io.Writer
}

type Options

type Options struct {
	Cmd     []string
	Timeout int
	Reason  string
}

Options defines the parameters that can be set upon a new console

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner is responsible for managing the lifecycle of a console

func New

func New(client kubernetes.Interface, theatreClient versioned.Interface) *Runner

New builds a runner

func (*Runner) Attach

func (c *Runner) Attach(ctx context.Context, opts AttachOptions) error

Attach provides the ability to attach to a running console, given the console name

func (*Runner) Authorise

func (c *Runner) Authorise(ctx context.Context, opts AuthoriseOptions) error

func (*Runner) Create

Create attempts to create a console in the given in the given namespace after finding the a template using selectors.

func (*Runner) CreateResource

func (c *Runner) CreateResource(namespace string, template workloadsv1alpha1.ConsoleTemplate, opts Options) (*workloadsv1alpha1.Console, error)

CreateResource builds a console according to the supplied options and submits it to the API

func (*Runner) FindConsoleByName

func (c *Runner) FindConsoleByName(namespace, name string) (*workloadsv1alpha1.Console, error)

func (*Runner) FindTemplateBySelector

func (c *Runner) FindTemplateBySelector(namespace string, labelSelector string) (*workloadsv1alpha1.ConsoleTemplate, error)

FindTemplateBySelector will search for a template matching the given label selector and return errors if none or multiple are found (when the selector is too broad)

func (*Runner) Get

Get provides a standardised method to get a console

func (*Runner) GetAttachablePod

func (c *Runner) GetAttachablePod(csl *workloadsv1alpha1.Console) (*corev1.Pod, error)

GetAttachablePod returns an attachable pod for the given console

func (*Runner) List

func (c *Runner) List(ctx context.Context, opts ListOptions) (ConsoleSlice, error)

List is a wrapper around ListConsolesByLabelsAndUser that will output to a specified output. This functionality is intended to be used in a CLI setting, where you are usually outputting to os.Stdout.

func (*Runner) ListConsolesByLabelsAndUser

func (c *Runner) ListConsolesByLabelsAndUser(namespace, username, labelSelector string) (ConsoleSlice, error)

func (*Runner) WaitUntilReady

func (c *Runner) WaitUntilReady(ctx context.Context, createdCsl workloadsv1alpha1.Console, waitForAuthorisation bool) (*workloadsv1alpha1.Console, error)

WaitUntilReady will block until the console reaches a phase that indicates that it's ready to be attached to, or has failed. It will then block until an associated RoleBinding exists that contains the console user in its subject list. This RoleBinding gives the console user permission to attach to the pod.

Jump to

Keyboard shortcuts

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