Documentation ¶
Index ¶
- Variables
- func Arg(kind ArgKind, args ...string) (string, error)
- func Cluster(name string) *corev1.ClusterCapability
- func Has[T corev1.MetadataAccessor[U], U corev1.Capability[U]](accessor T, capability U) bool
- func NewContext[T corev1.Capability[T], U corev1.MetadataAccessor[T]](base context.Context, eventC <-chan storage.WatchEvent[U], capabilities ...T) (context.Context, context.CancelFunc)
- func RenderInstallerCommand(tmpl string, spec InstallerTemplateSpec) (string, error)
- type ArgKind
- type ArgSpec
- type BackendStore
- type InputSpec
- type InstallerTemplateSpec
- type OptionSpec
- type SelectSpec
- type ServerInstallerTemplateSpec
- type ToggleSpec
- type TokenCapabilities
- type UserInstallerTemplateSpec
Constants ¶
This section is empty.
Variables ¶
var ( ErrObjectDeleted = errors.New("object deleted") ErrCapabilityNotFound = errors.New("capability not found") ErrEventChannelClosed = errors.New("event channel closed") )
var ( ErrBackendNotFound = fmt.Errorf("capability backend not found") ErrBackendAlreadyExists = fmt.Errorf("capability backend already exists") )
var ErrUnknownCapability = errors.New("unknown capability")
Functions ¶
func Arg ¶
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 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 *slog.Logger) BackendStore
type InstallerTemplateSpec ¶
type InstallerTemplateSpec struct { UserInstallerTemplateSpec ServerInstallerTemplateSpec }
type OptionSpec ¶
type SelectSpec ¶
type ToggleSpec ¶
type ToggleSpec struct {
Label string `json:"label"`
}
type TokenCapabilities ¶
type TokenCapabilities string
const (
JoinExistingCluster TokenCapabilities = "join_existing_cluster"
)
func (TokenCapabilities) For ¶
func (tc TokenCapabilities) For(ref *corev1.Reference) *corev1.TokenCapability