capabilities

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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) *core.ClusterCapability

func Has

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

func NewBackend

func NewBackend(client capability.BackendClient) capability.Backend

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 {
	Get(name string) (capability.Backend, error)
	Add(name string, backend capability.Backend) error
	List() []string
	RenderInstaller(name string, spec UserInstallerTemplateSpec) (string, error)
	CanInstall(capabilities ...string) error
	InstallCapabilities(cluster *core.Reference, capabilities ...string)
}

func NewBackendStore

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

type InputSpec

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

type Installer

type Installer interface {
	CanInstall(capabilities ...string) error
	InstallCapabilities(target *core.Reference, capabilities ...string)
}

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
}

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