v1alpha

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Providers map[string]Provider

A map of registered providers.

Functions

func RegisterProvider

func RegisterProvider(providerName string, provider Provider, providerConfig interface{})

Register a Provider.

func WriteAutoDiscoveryManifestToPath

func WriteAutoDiscoveryManifestToPath(prompts []*Prompt, path string) error

Types

type AutoDiscoveryConfig

type AutoDiscoveryConfig struct {
	Queries []*PromptQuery `yaml:"queries"`
}

func LoadAutoDiscoveryConfigFromPaths

func LoadAutoDiscoveryConfigFromPaths(paths []string) (*AutoDiscoveryConfig, error)

func (*AutoDiscoveryConfig) DiscoverPrompts

func (config *AutoDiscoveryConfig) DiscoverPrompts() ([]*Prompt, error)

Dispatches PromptQueries to each registered Provider. Returns a list of Prompts.

type AutoDiscoveryManifest

type AutoDiscoveryManifest struct {
	Prompts []*Prompt `json:"prompts"`
}

An AutoDiscoveryManifest is a JSON-encoded list of Prompts. The Cased Shell application reads this manifest and uses it to display a list of Prompts to the user.

type Prompt

type Prompt struct {
	Hostname            string            `json:"hostname" yaml:"hostname,omitempty"`                                 // The hostname to establish an SSH connection to. Use only for display purposes if IpAddress is provided.
	Username            string            `json:"username,omitempty" yaml:"username,omitempty"`                       // The username to use to establish an SSH connection to the host.
	IpAddress           string            `json:"ipAddress,omitempty" yaml:"ipAddress,omitempty"`                     // Optional: the IP address to establish an SSH connection to.
	Port                string            `json:"port,omitempty" yaml:"port,omitempty"`                               // Optional: the port to use when establishing an SSH connection.
	Name                string            `json:"name,omitempty" yaml:"name,omitempty"`                               // A descriptive name for this Prompt.
	Description         string            `json:"description,omitempty" yaml:"description,omitempty"`                 // A longer description of this Prompt. Use this field to explain common use cases.
	JumpCommand         string            `json:"jumpCommand,omitempty" yaml:"jumpCommand,omitempty"`                 // Optional: the command to run after establishing an SSH connection to the host
	ShellCommand        string            `json:"shellCommand,omitempty" yaml:"shellCommand,omitempty"`               // Optional: the command to run on the host or container to start the interactive session.
	PreDownloadCommand  string            `json:"preDownloadCommand,omitempty" yaml:"preDownloadCommand,omitempty"`   // Optional: a command to run before processing a user request to download a file. The tokens `{filepath}` and `{filename}` will be replaced with the filepath and filename of the file to download. The command is expected to output the path to the file to download to stdout.
	Kind                string            `json:"kind,omitempty" yaml:"kind,omitempty"`                               // The kind of prompt. Currently valid values are "host" and "container".
	Provider            string            `json:"provider,omitempty" yaml:"provider,omitempty"`                       // The name of the provider that created this prompt.
	Labels              map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`                           // Optional: a map of key-value pairs containing additional information about this Prompt. The Cased Shell Dashboard may in the future provide functionality to filter Prompts by label values.
	Annotations         map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`                 // Optional: a map of key-value pairs containing additional information about this Prompt. The Cased Shell Dashboard may in the future display these values alongside the Prompt, but is not expected to use them for filtering.
	Principals          []string          `json:"principals,omitempty" yaml:"principals,omitempty"`                   // Optional: a list of users and groups that should have access to this Prompt. The Cased Shell Dashboard will use this information to conditionally display this Prompt.
	Featured            bool              `json:"featured,omitempty" yaml:"featured,omitempty"`                       // Optional: whether this Prompt should be featured in the Cased Shell Dashboard.
	PromptForKey        bool              `json:"promptForKey,omitempty" yaml:"promptForKey,omitempty"`               // Set to true to tell the Cased Shell Dashboard to prompt the user for a key.
	PromptForUsername   bool              `json:"promptForUsername,omitempty" yaml:"promptForUsername,omitempty"`     // Set to true to tell the Cased Shell Dashboard to prompt the user for a username.
	CloseTerminalOnExit *bool             `json:"closeTerminalOnExit,omitempty" yaml:"closeTerminalOnExit,omitempty"` // Set to false to retain the terminal window after the remote command completes.
	ProxyJumpSelector   map[string]string `json:"proxyJumpSelector,omitempty" yaml:"proxyJumpSelector,omitempty"`     // Optional: a map of key-value pairs matching the labels on an existing prompt. If a matching prompt is found, connections to the prompt containing the ProxyHostJump attribute will be proxied via the matching prompt, similar to SSH's `ProxyJump` option.

}

A Prompt represents an interactive command line, and can represent the initial shell presented by an SSH connection to a host OR the interactive session presented by a command run on that host.

func PromptWithDefaults added in v0.3.0

func PromptWithDefaults(p *Prompt) *Prompt

func Prompts added in v0.3.0

func Prompts(ps []*Prompt) []*Prompt

func (*Prompt) DecorateWithQuery

func (p *Prompt) DecorateWithQuery(query *PromptQuery) *Prompt

Merges any fields provided here with fields returned by their respective searches. Each Provider is expected to call this function at the right time for their use case.

type PromptQuery

type PromptQuery struct {
	Provider  string            `yaml:"provider"`            // The name of a registered Provider to use to perform this query.
	Filters   map[string]string `yaml:"filters,omitempty"`   // A map of filters. Each Provider defines its own filters.
	Limit     int               `yaml:"limit,omitempty"`     // The maximum number of results to return.
	SortBy    string            `yaml:"sortBy,omitempty"`    // The field to sort results by, passed to the Provider.
	SortOrder string            `yaml:"sortOrder,omitempty"` // The order in which to sort results, passed to the Provider.
	Prompt    *Prompt           `yaml:"prompt,omitempty"`    // A Prompt template, which can be used to give all returned results a common name, description, etc.
}

A PromptQuery is a query for a Prompt.

type Provider

type Provider interface {
	Initialize(interface{})
	Discover([]*PromptQuery) ([]*Prompt, error)
}

A Provider turns a list of PromptQueries into a list of Prompts.

Jump to

Keyboard shortcuts

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