types

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessKey    = "access_key"
	AccessSecret = "secret_key"
	Region       = "region"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOptions

type CreateOptions struct {
	// Connector indicates the model.Connector for creating.
	Connector model.Connector
}

CreateOptions holds the options for creating Operator.

type Creator

type Creator func(context.Context, CreateOptions) (Operator, error)

Creator is a factory func to create Operator.

type Credential

type Credential struct {
	AccessKey    string
	AccessSecret string
	Region       string
}

func CredentialFromCtx

func CredentialFromCtx(ctx context.Context) (*Credential, error)

func GetCredential

func GetCredential(configData crypto.Properties) (*Credential, error)

type CredentialKeyType

type CredentialKeyType string
const (
	CredentialKey CredentialKeyType = "credential"
)

type ExecOptions

type ExecOptions struct {
	// Out receives the output.
	Out io.Writer
	// In passes the input.
	In io.Reader
	// Shell indicates to launch what kind of shell.
	Shell string
	// Resizer indicates to resize the size(width, height) of the terminal.
	Resizer TerminalResizer
}

ExecOptions holds the options of Operator's Exec action.

type ExecutableResource

type ExecutableResource interface {
	Exec(ctx context.Context, key string, opts ExecOptions) error
	Supported(ctx context.Context, key string) (bool, error)
}

type LogOptions

type LogOptions struct {
	// Out receives the output.
	Out io.Writer
	// WithoutFollow returns logs without following.
	WithoutFollow bool
	// Previous indicates to get the previous log of the accessing target.
	Previous bool
	// SinceSeconds returns logs newer than a relative duration.
	SinceSeconds *int64
	// Timestamps returns logs with RFC3339 or RFC3339Nano timestamp.
	Timestamps bool
	// TailLines indicates to get the lines from end of the logs.
	TailLines *int64
}

LogOptions holds the options of Operator's Log action.

type LoggableResource

type LoggableResource interface {
	Log(ctx context.Context, key string, opts LogOptions) error
}

type Operator

type Operator interface {
	// Type returns Type.
	Type() Type

	// IsConnected validates whether is connected.
	IsConnected(context.Context) error

	// GetKeys returns keys from the given resource.
	GetKeys(context.Context, *model.ServiceResource) (*types.ServiceResourceOperationKeys, error)

	// GetStatus gets status of the given resource,
	// must returns GeneralStatusError if raises error.
	GetStatus(context.Context, *model.ServiceResource) (*status.Status, error)

	// GetEndpoints gets endpoints of the given resource.
	GetEndpoints(context.Context, *model.ServiceResource) ([]types.ServiceResourceEndpoint, error)

	// GetComponents gets components of the given resource,
	// returns list must not be `nil` unless unexpected input or raising error,
	// it can be used to clean stale items safety if got an empty list.
	GetComponents(context.Context, *model.ServiceResource) ([]*model.ServiceResource, error)

	// Log gets logs from the given key.
	Log(context.Context, string, LogOptions) error

	// Exec executes commands to the given key.
	Exec(context.Context, string, ExecOptions) error

	// Label apply labels to the resource.
	Label(context.Context, *model.ServiceResource, map[string]string) error
}

Operator holds the actions that an operator must satisfy.

type TerminalResizer

type TerminalResizer interface {
	// Next returns the new terminal size after the terminal has been resized.
	// It returns false when monitoring has been stopped.
	Next() (width, height uint16, ok bool)
}

TerminalResizer holds the options to resize the terminal.

type Type

type Type = string

Type indicates the type of Operator, e.g. Kubernetes, AWS, etc.

Jump to

Keyboard shortcuts

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