capabilities

package
v0.9.1-rc3 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrObjectDeleted      = errors.New("object deleted")
	ErrCapabilityNotFound = errors.New("capability not found")
	ErrEventChannelClosed = errors.New("event channel closed")
)
View Source
var (
	ErrBackendNotFound      = fmt.Errorf("capability backend not found")
	ErrBackendAlreadyExists = fmt.Errorf("capability backend already exists")
)
View Source
var ErrUnknownCapability = errors.New("unknown capability")

Functions

func Arg

func Arg(kind ArgKind, args ...string) (string, error)

Arg generates a JSON string that the UI can parse to generate input controls (text boxes, combo boxes, etc.) for the user to fill in. The values the user provides will be substituted into the install command for the user to copy.

Usage: {{ arg <kind> [args...] [+option ...] }} The args are specific to each kind of input control.

Kinds:

"input": A text box.
  Arguments:
    1: Label
"select": A combo box.
  Arguments:
    1: Label
    2+: Combo box items
"toggle": A checkbox.
  Arguments:
    1: Label

Options:

"+format:<value>": Controls how the value is substituted into the install
                   command. Within the format text, {{ value }} will be
                   replaced with the user input. Defaults to '{{ value }}'
"+required": Marks the input is required.
"+omitEmpty": If the value is "falsy" ('', 'false', etc), the argument
              will be omitted from the install command.
"+default:<value>": Adds a default value to the input.

func Cluster

func Cluster(name string) *corev1.ClusterCapability

func Has

func Has[T corev1.MetadataAccessor[U], U corev1.Capability[U]](
	accessor T,
	capability U,
) bool

func NewContext added in v0.6.0

func NewContext[T corev1.Capability[T], U corev1.MetadataAccessor[T]](
	base context.Context,
	eventC <-chan storage.WatchEvent[U],
	capabilities ...T,
) (context.Context, context.CancelFunc)

Returns a context that listens on a watch event channel and closes its Done channel when the watched object loses one of the specified capabilities, or if the object is deleted. This context should have exclusive read access to the event channel to avoid missing events. If the list of capabilities is empty, the context will close its Done channel if any capabilities are deleted. Specific capabilities listed will be ignored if the context does not have them. The context must have previously had one of the capabilities and lose it to cause the context to close its Done channel.

func RenderInstallerCommand

func RenderInstallerCommand(tmpl string, spec InstallerTemplateSpec) (string, error)

Types

type ArgKind

type ArgKind string
const (
	ArgKindInput  ArgKind = "input"
	ArgKindSelect ArgKind = "select"
	ArgKindToggle ArgKind = "toggle"
)

type ArgSpec

type ArgSpec struct {
	Kind    ArgKind      `json:"kind"`
	Input   *InputSpec   `json:"input,omitempty"`
	Select  *SelectSpec  `json:"select,omitempty"`
	Toggle  *ToggleSpec  `json:"toggle,omitempty"`
	Options []OptionSpec `json:"options,omitempty"`
}

type BackendStore

type BackendStore interface {
	// Obtain a backend client for the given capability name
	Get(name string) (capabilityv1.BackendClient, error)
	// Add a capability backend with the given name
	Add(name string, backend capabilityv1.BackendClient) error
	// Returns all capability names known to the store
	List() []string
	// Render the installer command template for the given capability
	RenderInstaller(name string, spec UserInstallerTemplateSpec) (string, error)
}

func NewBackendStore

func NewBackendStore(serverSpec ServerInstallerTemplateSpec, logger *zap.SugaredLogger) BackendStore

type InputSpec

type InputSpec struct {
	Label string `json:"label"`
}

type OptionSpec

type OptionSpec struct {
	Name  string `json:"name"`
	Value string `json:"value,omitempty"`
}

type SelectSpec

type SelectSpec struct {
	Label string   `json:"label"`
	Items []string `json:"items"`
}

type ServerInstallerTemplateSpec

type ServerInstallerTemplateSpec struct {
	Address string
	Port    string
}

type ToggleSpec

type ToggleSpec struct {
	Label string `json:"label"`
}

type TokenCapabilities

type TokenCapabilities string
const (
	JoinExistingCluster TokenCapabilities = "join_existing_cluster"
)

func (TokenCapabilities) For

type UserInstallerTemplateSpec

type UserInstallerTemplateSpec struct {
	Token string
	Pin   string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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