Documentation
¶
Index ¶
- Constants
- Variables
- type BuiltinConfig
- type BuiltinCustomConfig
- type Config
- type KubeswitcherConfig
- type KubeswitcherRuntime
- func (kr *KubeswitcherRuntime) Config() *Config
- func (kr *KubeswitcherRuntime) ConfigDirectory() string
- func (kr *KubeswitcherRuntime) Context() *libcontext.Context
- func (kr *KubeswitcherRuntime) GenericStatePath() string
- func (kr *KubeswitcherRuntime) IdPath() string
- func (kr *KubeswitcherRuntime) InternalCallPath() string
- func (kr *KubeswitcherRuntime) InternalCallbackPath(callbackID string) string
- func (kr *KubeswitcherRuntime) KubeconfigPath() string
- func (kr *KubeswitcherRuntime) NotificationMessageBackupPath() string
- func (kr *KubeswitcherRuntime) NotificationMessagePath() string
- func (kr *KubeswitcherRuntime) PluginStatePath() string
- func (kr *KubeswitcherRuntime) SessionDir() string
- func (kr *KubeswitcherRuntime) SessionID() string
- func (kr *KubeswitcherRuntime) State() *state.State
- type PluginConfig
- type PluginConfigList
Constants ¶
const ( // ENV_KW_CONFIG_REPO is the name of the environment variable which contains the path to the kubeswitcher config repo ENV_KW_CONFIG_REPO = "KW_CONFIG_REPO" // KW_CONFIG_REPO_DEFAULT_NAME is the default name of the folder containing the kubeswitcher config files KW_CONFIG_REPO_DEFAULT_NAME = ".kubeswitcher_config" // ENV_KW_SESSION_ID is the name of the environment variable which contains the kubeswitcher-specific session id ENV_KW_SESSION_ID = "KW_SESSION_ID" // ENV_DEFAULT_SESSION_ID is the name of the environment variable which is used if the env var from ENV_KW_SESSION_ID is not set ENV_DEFAULT_SESSION_ID = "TERM_SESSION_ID" )
const ( KubeconfigFileName = "kubeconfig" GenericStateFileName = "state.json" PluginStateFileName = "plugin_state.json" NotificationMessageFileName = "message" NotificationMessageBackupFileName = "message.bak" IdFileName = "id" InternalCallFileName = "internal_call" InternalCallbackFilePrefix = "icb_" )
const ConfigFileName = "config.yaml"
Variables ¶
var ( BuiltinSubcommands sets.Set[string] // set of built-in subcommand names BuiltinAliases map[string]string // map of built-in subcommand aliases as keys, mapped to the subcommands they belong to )
var ( SIDRegex = regexp.MustCompile(`^[\w-]{1,128}$`) UUIDRegex = regexp.MustCompile(`([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12})`) )
Functions ¶
This section is empty.
Types ¶
type BuiltinConfig ¶
type BuiltinConfig struct {
Custom *BuiltinCustomConfig `json:"custom,omitempty"`
}
func (*BuiltinConfig) GetBuiltinCustomConfig ¶
func (c *BuiltinConfig) GetBuiltinCustomConfig() *BuiltinCustomConfig
GetBuiltinCustomConfig is a getter method that will not panic on a nil receiver.
type BuiltinCustomConfig ¶
type BuiltinCustomConfig struct {
// MaxIdLength is the maximum length of the id that is generated by the 'custom' subcommand.
// Usually, the id is 'custom:' followed by the path to the kubeconfig.
// Since this can get somewhat long and the id is meant to be displayed in the shell prompt, it can be shortened.
// This value affects only the path part of the id, not the prefix, and it cuts off the beginning of the path.
// Example: The path '/foo/bar/baz' could lead to the id 'custom:…ar/baz' if the max length is set to 6.
// The total length of the id will be maxIdLength + 8.
// If set to 0 or a negative value, the id will not be shortened.
MaxIdLength int `json:"maxIdLength,omitempty"`
}
type Config ¶
type Config struct {
Kubeswitcher *KubeswitcherConfig `json:"kubeswitcher"`
Builtin *BuiltinConfig `json:"builtin,omitempty"`
Plugins PluginConfigList `json:"plugins,omitempty"`
}
func LoadConfig ¶
type KubeswitcherConfig ¶
type KubeswitcherConfig struct {
// KubectlBinary is the path to the kubectl binary to use.
// If not set, "kubectl" is used and is expected to be resolvable via $PATH.
KubectlBinary string `json:"kubectlBinary,omitempty"`
// PrintInfoOnKubeconfigChange controls whether a message is printed if the kubeconfig changed.
PrintInfoOnKubeconfigChange bool `json:"printInfoOnKubeconfigChange"`
// PrintChangeInfoToStderr controls whether the info message is printed to stderr or stdout.
PrintChangeInfoToStderr bool `json:"printChangeInfoToStderr"`
// HistoryDepth controls how many entries are stored in the history.
// If set to 0, the history is disabled.
HistoryDepth int `json:"historyDepth"`
}
type KubeswitcherRuntime ¶
type KubeswitcherRuntime struct {
// contains filtered or unexported fields
}
KubeswitcherRuntime holds the internal state during commands. Basically, it stores values like the session ID and directory, which have to be computed once per command call and are then reused.
var (
Runtime *KubeswitcherRuntime
)
func (*KubeswitcherRuntime) Config ¶
func (kr *KubeswitcherRuntime) Config() *Config
Config returns the kubeswitcher config
func (*KubeswitcherRuntime) ConfigDirectory ¶
func (kr *KubeswitcherRuntime) ConfigDirectory() string
ConfigDirectory returns the path to the kubeswitcher config directory
func (*KubeswitcherRuntime) Context ¶
func (kr *KubeswitcherRuntime) Context() *libcontext.Context
Context returns the context. Creates a new context with an empty plugin name if no context has been created yet.
func (*KubeswitcherRuntime) GenericStatePath ¶
func (kr *KubeswitcherRuntime) GenericStatePath() string
GenericStatePath returns the path to the state file
func (*KubeswitcherRuntime) IdPath ¶
func (kr *KubeswitcherRuntime) IdPath() string
IdPath returns the path to the file containing the id
func (*KubeswitcherRuntime) InternalCallPath ¶
func (kr *KubeswitcherRuntime) InternalCallPath() string
InternalCallPath returns the path to the file containing the internal call
func (*KubeswitcherRuntime) InternalCallbackPath ¶
func (kr *KubeswitcherRuntime) InternalCallbackPath(callbackID string) string
InternalCallbackPath returns the path to the file containing the internal callback
func (*KubeswitcherRuntime) KubeconfigPath ¶
func (kr *KubeswitcherRuntime) KubeconfigPath() string
KubeconfigPath returns the path to the kubeconfig file
func (*KubeswitcherRuntime) NotificationMessageBackupPath ¶
func (kr *KubeswitcherRuntime) NotificationMessageBackupPath() string
NotificationMessageBackupPath returns the path to the backup file containing the notification message
func (*KubeswitcherRuntime) NotificationMessagePath ¶
func (kr *KubeswitcherRuntime) NotificationMessagePath() string
NotificationMessagePath returns the path to the file containing the notification message
func (*KubeswitcherRuntime) PluginStatePath ¶
func (kr *KubeswitcherRuntime) PluginStatePath() string
PluginStatePath returns the path to the plugin state file
func (*KubeswitcherRuntime) SessionDir ¶
func (kr *KubeswitcherRuntime) SessionDir() string
SessionDir returns the current session directory
func (*KubeswitcherRuntime) SessionID ¶
func (kr *KubeswitcherRuntime) SessionID() string
SessionID() returns the current session ID
func (*KubeswitcherRuntime) State ¶
func (kr *KubeswitcherRuntime) State() *state.State
State returns the state
type PluginConfig ¶
type PluginConfig struct {
// Name of the plugin and also the subcommand.
Name string `json:"name"`
// Aliases for the subcommand.
// Optional.
Aliases []string `json:"aliases,omitempty"`
// Binary is the path to the binary for the plugin.
// Must be either an absolute path or resolvable via $PATH.
Binary string `json:"binary"`
// Short description of the plugin to display on 'kw --help'.
Short string `json:"short"`
// Config contains plugin-specific configuration.
// Optional.
Config json.RawMessage `json:"config,omitempty"`
// Env contains environment variables to set before running the plugin.
// Optional.
Env map[string]string `json:"env,omitempty"`
}
type PluginConfigList ¶
type PluginConfigList []*PluginConfig