config

package
v1.0.32 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddK8sHost added in v1.0.2

func AddK8sHost(host K8sHost) error

AddK8sHost adds a new k8s host to the config

func AddSSHHost

func AddSSHHost(host SSHHost) error

AddSSHHost adds a new SSH host to the config file

func AddSSHHostToFile

func AddSSHHostToFile(host SSHHost, configPath string) error

AddSSHHostToFile adds a new SSH host to a specific config file

func AddSSHHostWithFileSelection

func AddSSHHostWithFileSelection(host SSHHost, targetFile string) error

AddSSHHostWithFileSelection adds a new SSH host to a user-specified config file

func DeleteK8sHost added in v1.0.2

func DeleteK8sHost(name string) error

DeleteK8sHost removes a k8s host from the config

func DeleteSSHHost

func DeleteSSHHost(hostName string) error

DeleteSSHHost removes an SSH host configuration from the config file

func DeleteSSHHostFromFile

func DeleteSSHHostFromFile(hostName, configPath string) error

DeleteSSHHostFromFile deletes an SSH host from a specific config file

func DeleteSSHHostV2

func DeleteSSHHostV2(hostName string) error

DeleteSSHHostV2 removes an SSH host configuration, searching in all config files

func FormatSSHOptionsForCommand

func FormatSSHOptionsForCommand(options string) string

FormatSSHOptionsForCommand converts SSH config options to command line format Input: "Compression yes\nServerAliveInterval 60" Output: "-o Compression=yes -o ServerAliveInterval=60"

func GetAllConfigFiles

func GetAllConfigFiles() ([]string, error)

GetAllConfigFiles returns all SSH config files (main + included files)

func GetAllConfigFilesFromBase

func GetAllConfigFilesFromBase(baseConfigPath string) ([]string, error)

GetAllConfigFilesFromBase returns all SSH config files starting from a specific base config file

func GetAppConfigPath

func GetAppConfigPath() (string, error)

GetAppConfigPath returns the path to the application config file

func GetConfigFilesExcludingCurrent

func GetConfigFilesExcludingCurrent(hostName string, baseConfigFile string) ([]string, error)

GetConfigFilesExcludingCurrent returns all config files except the one containing the specified host

func GetDefaultSSHConfigPath

func GetDefaultSSHConfigPath() (string, error)

GetDefaultSSHConfigPath returns the default SSH config path for the current platform

func GetIncludedConfigFiles

func GetIncludedConfigFiles() ([]string, error)

GetIncludedConfigFiles returns a list of config files that can be used for adding hosts

func GetK8sConfigPath added in v1.0.2

func GetK8sConfigPath() (string, error)

GetK8sConfigPath returns the path to the k8s config file

func GetSSHDirectory

func GetSSHDirectory() (string, error)

GetSSHDirectory returns the .ssh directory path

func GetSSHMBackupDir

func GetSSHMBackupDir() (string, error)

GetSSHMBackupDir returns the SSHM backup directory

func GetSSHMConfigDir

func GetSSHMConfigDir() (string, error)

GetSSHMConfigDir returns the SSHM config directory

func HostExists

func HostExists(hostName string) (bool, error)

HostExists checks if a host already exists in the config

func HostExistsInFile

func HostExistsInFile(hostName string, configPath string) (bool, error)

HostExistsInFile checks if a host exists in a specific config file

func HostExistsInSpecificFile

func HostExistsInSpecificFile(hostName string, configPath string) (bool, error)

HostExistsInSpecificFile checks if a host exists in a specific file only (no includes)

func IsPartOfMultiHostDeclaration

func IsPartOfMultiHostDeclaration(hostName string, configPath string) (bool, []string, error)

IsPartOfMultiHostDeclaration checks if a host is part of a multi-host declaration

func K8sConfigExists added in v1.0.2

func K8sConfigExists() bool

K8sConfigExists checks if the k8s config file exists

func K8sHostExists added in v1.0.2

func K8sHostExists(name string) (bool, error)

K8sHostExists checks if a k8s host with the given name exists

func MoveHostToFile

func MoveHostToFile(hostName string, targetConfigFile string) error

MoveHostToFile moves an SSH host from its current config file to a target config file

func ParseSSHOptionsFromCommand

func ParseSSHOptionsFromCommand(options string) string

ParseSSHOptionsFromCommand converts SSH command line options to config format Input: "-o Compression=yes -o ServerAliveInterval=60" Output: "Compression yes\nServerAliveInterval 60"

func QuickHostExists

func QuickHostExists(hostName string) (bool, error)

QuickHostExists performs a fast check if a host exists without full parsing This is optimized for connection scenarios where we just need to verify existence

func QuickHostExistsInFile

func QuickHostExistsInFile(hostName string, configPath string) (bool, error)

QuickHostExistsInFile performs a fast check if a host exists in config files This stops parsing as soon as the host is found, making it much faster for connection scenarios

func SaveAppConfig

func SaveAppConfig(config *AppConfig) error

SaveAppConfig saves the application configuration to file

func SaveK8sConfig added in v1.0.2

func SaveK8sConfig(hosts []K8sHost) error

SaveK8sConfig saves the k8s configuration to file

func SetSecureFilePermissions

func SetSecureFilePermissions(filepath string) error

SetSecureFilePermissions configures secure permissions on Unix systems

func UpdateK8sHost added in v1.0.2

func UpdateK8sHost(oldName string, newHost K8sHost) error

UpdateK8sHost updates an existing k8s host

func UpdateMultiHostBlock

func UpdateMultiHostBlock(originalHosts, newHosts []string, commonProperties SSHHost, configPath string) error

UpdateMultiHostBlock updates a multi-host block configuration

func UpdateSSHHost

func UpdateSSHHost(oldName string, newHost SSHHost) error

UpdateSSHHost updates an existing SSH host configuration

func UpdateSSHHostInFile

func UpdateSSHHostInFile(oldName string, newHost SSHHost, configPath string) error

UpdateSSHHostInFile updates an existing SSH host configuration in a specific file

func UpdateSSHHostV2

func UpdateSSHHostV2(oldName string, newHost SSHHost) error

Types

type AppConfig

type AppConfig struct {
	KeyBindings       KeyBindings `json:"key_bindings"`
	Theme             string      `json:"theme"`
	SortMode          string      `json:"sort_mode"`            // "name" or "recent"
	StartInSearchMode bool        `json:"start_in_search_mode"` // Start with search focused
}

AppConfig represents the main application configuration

func GetDefaultAppConfig

func GetDefaultAppConfig() AppConfig

GetDefaultAppConfig returns the default application configuration

func LoadAppConfig

func LoadAppConfig() (*AppConfig, error)

LoadAppConfig loads the application configuration from file If the file doesn't exist, it returns the default configuration

type K8sConfig added in v1.0.2

type K8sConfig struct {
	Hosts []K8sHost `yaml:"hosts"`
}

K8sConfig represents the kubernetes configuration file structure

type K8sHost added in v1.0.2

type K8sHost struct {
	Name       string   `yaml:"name"`
	Namespace  string   `yaml:"namespace"`
	Pod        string   `yaml:"pod"`
	Container  string   `yaml:"container,omitempty"`
	Context    string   `yaml:"context,omitempty"`
	Kubeconfig string   `yaml:"kubeconfig,omitempty"`
	Shell      string   `yaml:"shell,omitempty"`
	Tags       []string `yaml:"tags,omitempty"`
}

K8sHost represents a Kubernetes pod connection configuration

func GetK8sHost added in v1.0.2

func GetK8sHost(name string) (*K8sHost, error)

GetK8sHost retrieves a specific k8s host by name

func ParseK8sConfig added in v1.0.2

func ParseK8sConfig() ([]K8sHost, error)

ParseK8sConfig parses the k8s config file and returns the list of hosts

func (*K8sHost) BuildKubectlCommand added in v1.0.2

func (h *K8sHost) BuildKubectlCommand() *exec.Cmd

BuildKubectlCommand builds the kubectl exec command for a k8s host

type KeyBindings

type KeyBindings struct {
	// Quit keys - keys that will quit the application
	QuitKeys []string `json:"quit_keys"`

	// DisableEscQuit - if true, ESC key won't quit the application (useful for vim users)
	DisableEscQuit bool `json:"disable_esc_quit"`
}

KeyBindings represents configurable key bindings for the application

func GetDefaultKeyBindings

func GetDefaultKeyBindings() KeyBindings

GetDefaultKeyBindings returns the default key bindings configuration

func (*KeyBindings) ShouldQuitOnKey

func (kb *KeyBindings) ShouldQuitOnKey(key string) bool

ShouldQuitOnKey checks if the given key should trigger quit based on configuration

type SSHHost

type SSHHost struct {
	Name          string
	Hostname      string
	User          string
	Port          string
	Identity      string
	ProxyJump     string
	Options       string
	RemoteCommand string // Command to execute after SSH connection
	RequestTTY    string // Request TTY (yes, no, force, auto)
	Tags          []string
	SourceFile    string // Path to the config file where this host is defined
	// contains filtered or unexported fields
}

SSHHost represents an SSH host configuration

func FindHostInAllConfigs

func FindHostInAllConfigs(hostName string) (*SSHHost, error)

FindHostInAllConfigs finds a host in all configuration files and returns the host with its source file

func GetSSHHost

func GetSSHHost(hostName string) (*SSHHost, error)

GetSSHHost retrieves a specific host configuration by name

func GetSSHHostFromFile

func GetSSHHostFromFile(hostName string, configPath string) (*SSHHost, error)

GetSSHHostFromFile retrieves a specific host configuration by name from a specific config file

func ParseSSHConfig

func ParseSSHConfig() ([]SSHHost, error)

ParseSSHConfig parses the SSH config file and returns the list of hosts

func ParseSSHConfigFile

func ParseSSHConfigFile(configPath string) ([]SSHHost, error)

ParseSSHConfigFile parses a specific SSH config file and returns the list of hosts

Jump to

Keyboard shortcuts

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