Documentation
¶
Index ¶
- Constants
- Variables
- func FilterNonPrintable(r io.Reader) (string, error)
- func IsShell(cmd string) bool
- func ResolveShell(value string) (string, error)
- type AffixMappig
- type ArgParserFacade
- type ClientFacade
- type Command
- type Commands
- type ConnectOrder
- type CopyOrder
- type EnvList
- type EnvVar
- type ErrMustUpdate
- type ErrTask
- type ErrUnsupportedSupfileVersion
- type FetchOrder
- type FlagStringSlice
- type HelpDisplayer
- type HostNamespace
- type InitState
- type InitialArgs
- type Inventory
- func (i *Inventory) CheckBashCommand() []string
- func (i *Inventory) CheckHomeCommand() []string
- func (i *Inventory) CheckOsTypeCommand() []string
- func (i *Inventory) CheckShCommand() []string
- func (i *Inventory) CheckUserCommand() []string
- func (i *Inventory) DetectArchCommand() []string
- func (i *Inventory) GetHomeUnixCommand() []string
- func (i *Inventory) GetHomeWinCommand() []string
- func (i *Inventory) GetShell() string
- type Network
- type NetworkHost
- type Networks
- type Play
- type PlayBook
- type ShellCheckFacade
- type Supfile
- type Targets
- type Task
- type Upload
Constants ¶
const CsupDoSudoEnv = "SUP_SUDO"
const CsupPasswdEnv = "SUP_PASSWORD"
const HASHED_PASS = "_ssup_pass"
const INJECTED_COMMANDS_FILE = "_ssup_commands"
const MAIN_SCRIPT = "_ssup_run"
const PassSeparator = " | "
const SPEW_DEPTH = 1
const SSUP_WORK_FOLDER = ".local" + string(os.PathSeparator) + "ssup" + string(os.PathSeparator) + "run" + string(os.PathSeparator)
const SourceDirective = "#source://"
const TubeNameSeparator = " << "
const VARS_FILE = "_ssup_env"
const VERSION = "0.5"
Variables ¶
var ( Colors = []string{ "\033[32m", "\033[33m", "\033[36m", "\033[35m", "\033[31m", "\033[34m", } ResetColor = "\033[0m" )
var ( ErrUsage = errors.New("Usage: sup [OPTIONS] NETWORK COMMAND [...]\n sup [ --help | -v | --version ]") ErrUnknownNetwork = errors.New("Unknown network\nif Supfile has networks: section defined\nyou MUST give network name as a first argument") ErrNetworkNoHosts = errors.New("No hosts defined for a given network") ErrCmd = errors.New("Unknown command/target") ErrTargetNoCommands = errors.New("No commands defined for a given target") ErrConfigFile = errors.New("Unknown ssh_config file") )
var ExampleSupfile = `` /* 1172-byte string literal not displayed */
ExampleSupfile is an example supfile.
Functions ¶
func FilterNonPrintable ¶
@this original 81A0C135-69EA-4736-AFD4-1D132A2DB91E@
func ResolveShell ¶
Types ¶
type AffixMappig ¶
type ArgParserFacade ¶
type ArgParserFacade interface {
Parse(conf *Supfile, initialArgs *InitialArgs, helpMenu HelpDisplayer) (*PlayBook, error)
}
type ClientFacade ¶
type ClientFacade interface {
GetConnection() *ssh.Client
GetSSHConfig() *ssh.ClientConfig
Connect(host NetworkHost) error
SetConnection(*ssh.Client)
Run(task *Task) error
Wait() error
Close() error
Prefix() (string, int)
Write(p []byte) (n int, err error)
WriteClose() error
Stdin() io.WriteCloser
Stderr() io.Reader
Stdout() io.Reader
Signal(os.Signal) error
Upload(src string, dest string) error
Download(src string, dest string, silent bool) error
GenerateOnRemote(data []byte, dest string) error
GetHost() string
GetTube() string
SetTube(name string)
GetInventory() *Inventory
GetShell() string
}
type Command ¶
type Command struct {
Name string `yaml:"-"` // Command name.
Desc string `yaml:"desc"` // Command description.
Local string `yaml:"local"` // Command(s) to be run locally.
Run string `yaml:"run"` // Command(s) to be run remotelly.
Script string `yaml:"script"` // Load command(s) from script and run it remotelly.
Upload []*Upload `yaml:"upload"` // See Upload struct.
// Copy *CopyOrder `yaml:"copy"` // See Upload struct.
Stdin bool `yaml:"stdin"` // Attach localhost STDOUT to remote commands' STDIN?
Once bool `yaml:"once"` // The command should be run "once" (on one host only).
Serial int `yaml:"serial"` // Max number of clients processing a task in parallel.
Fetch *FetchOrder `yaml:"fetch" ` // See Fetch struct.
Sudo bool `yaml:"sudo" ` // Run command(s) as root?
SudoPass string `yaml:"sudo_pass"`
Env EnvList `yaml:"env"`
// API backward compatibility. Will be deprecated in v1.0.
RunOnce bool `yaml:"run_once"` // The command should be run once only.
}
Command represents command(s) to be run remotely.
type ConnectOrder ¶
type ConnectOrder struct {
Host string // will contain ip:port
ClientConfig *ssh.ClientConfig
}
type EnvList ¶
type EnvList struct {
// contains filtered or unexported fields
}
EnvList is a list of environment variables that maps to a YAML map, but maintains order, enabling late variables to reference early variables.
func (*EnvList) UnmarshalYAML ¶
type EnvVar ¶
EnvVar represents an environment variable
type ErrMustUpdate ¶
type ErrMustUpdate struct {
Msg string
}
func (ErrMustUpdate) Error ¶
func (e ErrMustUpdate) Error() string
type ErrUnsupportedSupfileVersion ¶
type ErrUnsupportedSupfileVersion struct {
Msg string
}
func (ErrUnsupportedSupfileVersion) Error ¶
func (e ErrUnsupportedSupfileVersion) Error() string
type FetchOrder ¶
type FlagStringSlice ¶
type FlagStringSlice []string
func (*FlagStringSlice) Set ¶
func (f *FlagStringSlice) Set(value string) error
func (*FlagStringSlice) String ¶
func (f *FlagStringSlice) String() string
type HelpDisplayer ¶
type HelpDisplayer struct {
ShowNetwork bool
ShowCmd bool
// ShowTarget bool
ShowMakeMode bool
Color bool
}
func (*HelpDisplayer) Show ¶
func (h *HelpDisplayer) Show(conf *Supfile)
func (*HelpDisplayer) ShowAll ¶
func (h *HelpDisplayer) ShowAll(conf *Supfile)
type HostNamespace ¶
HostNamespace stores env vars from the host it has methods to get and set env variables
func (*HostNamespace) Get ¶
func (h *HostNamespace) Get(key string) string
Get returns the value of the env var
func (HostNamespace) Set ¶
func (h HostNamespace) Set(key, value string)
Set sets the value of the env var
func (*HostNamespace) Unset ¶
func (h *HostNamespace) Unset(key string)
Unset unsets the value of the env var
type InitState ¶
type InitState struct {
Conf *Supfile
InitialArgs *InitialArgs
}
type InitialArgs ¶
type Inventory ¶
type Inventory struct {
Bash bool
Sh bool
Arch string
Home string
User string
OsType string
IsLocal bool
}
func (*Inventory) CheckBashCommand ¶
func (*Inventory) CheckHomeCommand ¶
CheckHomeCommand returns the command to get the home directory based on the OS type
it's expected that it will run AFTER a call to check os type
func (*Inventory) CheckOsTypeCommand ¶
func (*Inventory) CheckShCommand ¶
func (*Inventory) CheckUserCommand ¶
func (*Inventory) DetectArchCommand ¶
func (*Inventory) GetHomeUnixCommand ¶
func (*Inventory) GetHomeWinCommand ¶
type Network ¶
type Network struct {
Env EnvList `yaml:"env"`
Inventory string `yaml:"inventory"`
Hosts []NetworkHost `yaml:"hosts"`
Bastion string `yaml:"bastion"` // Jump host for the environment
// Should these live on Hosts too? We'd have to change []string to struct, even in Supfile.
User string `yaml:"user"`
Password string `yaml:"pass" `
IdentityFile string `yaml:"id_file"`
Name string
}
Network is group of hosts with extra custom env vars.
func (Network) ParseInventory ¶
func (n Network) ParseInventory() ([]NetworkHost, error)
ParseInventory runs the inventory command, if provided, and appends the command's output lines to the manually defined list of hosts.
func (*Network) UnmarshalYAML ¶
type NetworkHost ¶
type NetworkHost struct {
Host string `yaml:"host"`
User string `yaml:"user"`
Password string `yaml:"pass"`
Tube string `yaml:"tube"`
Env EnvList `yaml:"env"`
Sudo bool `yaml:"sudo" default:"false"`
}
func (*NetworkHost) UnmarshalYAML ¶
func (n *NetworkHost) UnmarshalYAML(unmarshal func(interface{}) error) error
type Networks ¶
Networks is a list of user-defined networks
func (*Networks) Set ¶
this is just to set localhost so we dont process slice of values as we should be...
func (*Networks) UnmarshalYAML ¶
type PlayBook ¶
type PlayBook struct {
// contains filtered or unexported fields
}
func (*PlayBook) IsMakefileMode ¶
func (*PlayBook) MarkAsMakefileMode ¶
func (p *PlayBook) MarkAsMakefileMode()
type ShellCheckFacade ¶
type Supfile ¶
type Supfile struct {
Networks Networks `yaml:"networks"`
Commands Commands `yaml:"commands"`
Targets Targets `yaml:"targets"`
Env EnvList `yaml:"env"`
Version string `yaml:"version"`
Desc string `yaml:"desc"`
}
Supfile represents the Stack Up configuration YAML file.
type Targets ¶
type Targets struct {
Names []string
// contains filtered or unexported fields
}
Targets is a list of user-defined targets by default affixed are mapped by command name
func (*Targets) GetAffixByCommandName ¶
func (t *Targets) GetAffixByCommandName(name string) (AffixMappig, bool)
func (*Targets) HasAffixes ¶
func (*Targets) UnmarshalYAML ¶
Source Files
¶
- Interfaces.go
- colors.go
- command.go
- connect_order.go
- const.go
- copy_order.go
- env_v2.go
- errors.go
- example_supfile.go
- fetch_order.go
- help_displayer.go
- hostNamespace.go
- init_state.go
- initial_args.go
- inventory.go
- network.go
- network_host.go
- network_host_utils.go
- networks.go
- parsed_data.go
- shellcheck.go
- shellresolve.go
- supfile.go
- target.go
- task.go
- upload.go