config

package module
v0.0.0-...-9b2e7d9 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{
	Global: GlobalConfig{
		Env: EnvVariables{
			Static: map[string]string{"LC_ENVSSH": "1"},
			Moved:  []string{"LANG", "EDITOR", "VISUAL"},
		},
		Files:    []File{{Local: "$HOME/.bashrc", Remote: "$HOME/.bashrc"}},
		Commands: []string{"export ENVSSH=1"},
	},
	Servers: []ServerConfig{
		{
			Host:    "localhost",
			Port:    22,
			Aliases: []string{"127.0.0.1"},
			Env: EnvVariables{
				Static: map[string]string{},
				Moved:  []string{},
			},
			Files:    []File{},
			Commands: []string{},
		},
	},
}

DefaultConfig is the default configuration for the tool that is written to the YAML file on first connect if it does not exist.

Functions

func CreateDefaultConfigFile

func CreateDefaultConfigFile(location string) error

CreateDefaultConfigFile creates default configuration file to given location.

func GetDefaultConfigLocation

func GetDefaultConfigLocation() string

GetDefaultConfigLocation returns default envssh configuration file location.

Types

type Config

type Config struct {
	Global  GlobalConfig   `yaml:"global"`
	Servers []ServerConfig `yaml:"servers"`
}

Config contains global and server specific configurations.

func ParseConfig

func ParseConfig(location string) (*Config, error)

ParseConfig parses envssh configuration from given location. Creates new default configuration to the location if it does not exist.

func (*Config) GetCommandsForRemote

func (config *Config) GetCommandsForRemote(remote *util.Remote) []string

GetCommandsForRemote returns a list of commands to run on remote.

func (*Config) GetEnvironmentVariablesForRemote

func (config *Config) GetEnvironmentVariablesForRemote(remote *util.Remote) map[string]string

GetEnvironmentVariablesForRemote returns a list of environment variables that are set to remote.

func (*Config) GetFilesForRemote

func (config *Config) GetFilesForRemote(remote *util.Remote) []File

GetFilesForRemote returns a list of files that are transferred to remote.

func (*Config) GetServerConfig

func (config *Config) GetServerConfig(remote *util.Remote) *ServerConfig

GetServerConfig returns server specific config based on hostname if it exists in the Config struct.

type EnvVariables

type EnvVariables struct {
	Static map[string]string `yaml:"static"`
	Moved  []string          `yaml:"moved"`
}

EnvVariables that should be set on remote.

type File

type File struct {
	Local  string `yaml:"local"`
	Remote string `yaml:"remote"`
}

File presents a single file that is moved to remote.

type GlobalConfig

type GlobalConfig struct {
	Env      EnvVariables `yaml:"env"`
	Files    []File       `yaml:"files"`
	Commands []string     `yaml:"commands"`
}

GlobalConfig is base for all server configurations and is used for all remotes.

type ServerConfig

type ServerConfig struct {
	Host     string       `yaml:"host"`
	Port     uint16       `yaml:"port"`
	Aliases  []string     `yaml:"aliases"`
	Env      EnvVariables `yaml:"env"`
	Files    []File       `yaml:"files"`
	Commands []string     `yaml:"commands"`
}

ServerConfig presents a single server configuration identified by the host name.

Jump to

Keyboard shortcuts

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