Documentation
¶
Index ¶
- Variables
- func CheckIsMappingNode(node yaml.Node) error
- func CheckIsScalarNode(node yaml.Node) error
- func CheckIsSequenceNode(node yaml.Node) error
- func CheckUserNoColor(noColorFlag bool)
- func EvaluateEnv(envList []string) ([]string, error)
- func EvaluatePassword(password string) (string, error)
- func FormatErrors(re Resource, errs []error) error
- func IsNullNode(node yaml.Node) bool
- func MergeEnvs(envs ...[]string) []string
- func ParseNodeEnv(node yaml.Node) []string
- func ParseTaskEnv(cmdEnv []string, userEnv []string, parentEnv []string, configEnv []string) ([]string, error)
- func SelectFirstNonEmpty(values ...string) string
- func ServerInSlice(name string, list []Server) bool
- func SortServers(order string, servers *[]Server)
- type Bastion
- type BorderColors
- type CellColors
- type Config
- func (c *Config) CheckConfigNoColor()
- func (c *Config) EditConfig() error
- func (c *Config) EditServer(name string) error
- func (c *Config) EditSpec(name string) error
- func (c *Config) EditTarget(name string) error
- func (c *Config) EditTask(name string) error
- func (c *Config) FilterServers(allServersFlag bool, serversFlag []string, tagsFlag []string, regexFlag string, ...) ([]Server, error)
- func (c *Config) GetRemoteServerNameAndDesc() []string
- func (c *Config) GetServer(name string) (*Server, error)
- func (c *Config) GetServerByGroup(group string) (*Server, error)
- func (c *Config) GetServerGroupsAndDesc() []string
- func (c *Config) GetServerNameAndDesc() []string
- func (c *Config) GetServerNames() []string
- func (c *Config) GetServersByName(groupNames []string) ([]Server, error)
- func (c *Config) GetServersByRegex(r string) ([]Server, error)
- func (c *Config) GetServersByTags(tags []string) ([]Server, error)
- func (c *Config) GetSpec(name string) (*Spec, error)
- func (c *Config) GetSpecNames() []string
- func (c *Config) GetSpecsByName(names []string) ([]Spec, error)
- func (c *Config) GetTagAssocations(tags []string) ([]Tag, error)
- func (c *Config) GetTags() []string
- func (c *Config) GetTarget(name string) (*Target, error)
- func (c *Config) GetTargetNames() []string
- func (c *Config) GetTargetsByName(names []string) ([]Target, error)
- func (c *Config) GetTask(id string) (*Task, error)
- func (c *Config) GetTaskIDAndDesc() []string
- func (c *Config) GetTaskNames() []string
- func (c *Config) GetTaskServers(task *Task, runFlags *core.RunFlags, setRunFlags *core.SetRunFlags) ([]Server, error)
- func (c *Config) GetTasksByIDs(ids []string) ([]Task, error)
- func (c *Config) GetTheme(name string) (*Theme, error)
- func (c *Config) GetThemeNames() []string
- func (c *Config) ParseInventory(userArgs []string) error
- type ConfigResources
- type ConfigYAML
- func (c *ConfigYAML) DecodeSpec(name string, specYAML yaml.Node) (*Spec, []error)
- func (c *ConfigYAML) DecodeTarget(name string, targetYAML yaml.Node) (*Target, []error)
- func (c *ConfigYAML) GetContext() string
- func (c *ConfigYAML) GetContextLine() int
- func (c *ConfigYAML) ParseImportsYAML() ([]Import, []ResourceErrors[Import])
- func (c *ConfigYAML) ParseServersYAML() ([]Server, []ResourceErrors[Server])
- func (c *ConfigYAML) ParseSpecsYAML() ([]Spec, []ResourceErrors[Spec])
- func (c *ConfigYAML) ParseTargetsYAML() ([]Target, []ResourceErrors[Target])
- func (c *ConfigYAML) ParseTasksYAML() ([]Task, []ResourceErrors[Task])
- func (c *ConfigYAML) ParseThemesYAML() ([]Theme, []ResourceErrors[Theme])
- type FoundCyclicDependency
- type FoundCyclicTaskDependency
- type FoundDuplicateImports
- type FoundDuplicateObjects
- type Import
- type Items
- type Node
- type NodeLink
- type Report
- type ReportData
- type ReportRow
- type Resource
- type ResourceErrors
- type Row
- type Server
- func CreateInventoryServers(inputHost string, i int, server Server, userArgs []string) (Server, error)
- func GetFirstRemoteServer(servers []Server) (Server, error)
- func GetIntersectionServers(s ...[]Server) []Server
- func GetInvertedServers(allServers []Server, excludeServers []Server) []Server
- func InitSake(args []string) ([]Server, error)
- type ServerYAML
- type Spec
- type Table
- type TableOptions
- type TableOutput
- type Tag
- type Target
- type TargetRange
- type Task
- type TaskCmd
- type TaskLink
- type TaskNode
- type TaskRef
- type TaskRefYAML
- type TaskResources
- type TaskStatus
- type TaskYAML
- type Text
- type Theme
Constants ¶
This section is empty.
Variables ¶
var ( ACCEPTABLE_FILE_NAMES = []string{"sake.yaml", "sake.yml", ".sake.yaml", ".sake.yml"} DEFAULT_SHELL = "bash -c" DEFAULT_TIMEOUT = uint(20) DEFAULT_THEME = Theme{ Name: "default", Table: DefaultTable, Text: DefaultText, } DEFAULT_TARGET = Target{ Name: "default", All: false, Servers: []string{}, Tags: []string{}, Regex: "", Invert: false, Limit: 0, LimitP: 0, } DEFAULT_SPEC = Spec{ Name: "default", Desc: "the default spec", Describe: false, ListHosts: false, Order: "inventory", Silent: false, Hidden: false, Strategy: "linear", Batch: 0, BatchP: 0, Forks: 10000, Output: "text", MaxFailPercentage: 0, AnyErrorsFatal: true, IgnoreErrors: false, IgnoreUnreachable: false, OmitEmptyRows: false, OmitEmptyColumns: false, Report: []string{"recap"}, Verbose: false, Confirm: false, Step: false, Print: "all", } )
var DefaultTable = Table{ Style: "default", Box: StyleBoxASCII, Prefix: `{{ .Host }}`, Options: &TableOptions{ DrawBorder: core.Ptr(false), SeparateColumns: core.Ptr(true), SeparateHeader: core.Ptr(true), SeparateRows: core.Ptr(false), SeparateFooter: core.Ptr(false), }, Border: &BorderColors{ Header: &CellColors{ Fg: core.Ptr(""), Bg: core.Ptr(""), Attr: core.Ptr("faint"), }, Row: &CellColors{ Fg: core.Ptr(""), Bg: core.Ptr(""), Attr: core.Ptr("faint"), }, RowAlternate: &CellColors{ Fg: core.Ptr(""), Bg: core.Ptr(""), Attr: core.Ptr("faint"), }, Footer: &CellColors{ Fg: core.Ptr(""), Bg: core.Ptr(""), Attr: core.Ptr("faint"), }, }, Title: &CellColors{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("bold"), }, Header: &CellColors{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("bold"), Format: core.Ptr("default"), }, Row: &CellColors{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("normal"), Format: core.Ptr("default"), }, Footer: &CellColors{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("normal"), Format: core.Ptr("default"), }, }
var DefaultText = Text{ Prefix: `{{ .Host }}`, PrefixColors: []string{"green", "blue", "red", "yellow", "magenta", "cyan"}, Header: `{{ .Style "TASK" "bold" }}{{ if ne .NumTasks 1 }} ({{ .Index }}/{{ .NumTasks }}){{end}}{{ if and .Name .Desc }} [{{.Style .Name "bold"}}: {{ .Desc }}] {{ else if .Name }} [{{ .Name }}] {{ else if .Desc }} [{{ .Desc }}] {{end}}`, HeaderFiller: "*", }
var REGISTER_REGEX = regexp.MustCompile("^[a-zA-Z_]+[a-zA-Z0-9_]*$")
var StyleBoxASCII = table.BoxStyle{ BottomLeft: "+", BottomRight: "+", BottomSeparator: "+", EmptySeparator: text.RepeatAndTrim(" ", text.RuneCount("+")), Left: "|", LeftSeparator: "+", MiddleHorizontal: "-", MiddleSeparator: "+", MiddleVertical: "|", PaddingLeft: " ", PaddingRight: " ", PageSeparator: "\n", Right: "|", RightSeparator: "+", TopLeft: "+", TopRight: "+", TopSeparator: "+", UnfinishedRow: " ~", }
var StyleBoxLight = table.BoxStyle{ BottomLeft: "└", BottomRight: "┘", BottomSeparator: "┴", EmptySeparator: text.RepeatAndTrim(" ", text.RuneCount("┼")), Left: "│", LeftSeparator: "├", MiddleHorizontal: "─", MiddleSeparator: "┼", MiddleVertical: "│", PaddingLeft: " ", PaddingRight: " ", PageSeparator: "\n", Right: "│", RightSeparator: "┤", TopLeft: "┌", TopRight: "┐", TopSeparator: "┬", UnfinishedRow: " ≈", }
Functions ¶
func CheckIsMappingNode ¶
func CheckIsMappingNode(node yaml.Node) error
func CheckIsScalarNode ¶
func CheckIsScalarNode(node yaml.Node) error
func CheckIsSequenceNode ¶
func CheckIsSequenceNode(node yaml.Node) error
func CheckUserNoColor ¶
func CheckUserNoColor(noColorFlag bool)
func EvaluateEnv ¶
func EvaluatePassword ¶
func FormatErrors ¶
FormatErrors concats one or many errors attached to it for a single resource.
func IsNullNode ¶
func IsNullNode(node yaml.Node) bool
func MergeEnvs ¶
MergeEnvs merges environment variables. Priority is from highest to lowest (1st env takes precedence over the last entry).
func ParseNodeEnv ¶
func ParseNodeEnv(node yaml.Node) []string
func ParseTaskEnv ¶
func SelectFirstNonEmpty ¶
SelectFirstNonEmpty selects first non-empty string.
func ServerInSlice ¶
func SortServers ¶ added in v0.13.0
Types ¶
type BorderColors ¶
type BorderColors struct { Header *CellColors `yaml:"header"` Row *CellColors `yaml:"row"` RowAlternate *CellColors `yaml:"row_alt"` }
type CellColors ¶
type Config ¶
type Config struct { SSHConfigFile *string DefaultTimeout uint DisableVerifyHost bool KnownHostsFile string Shell string Envs []string Themes []Theme Specs []Spec Targets []Target Servers []Server Tasks []Task Path string }
func ReadConfig ¶
func ReadConfig(configFilepath string, userConfigPath string, sshConfigFile string, noColor bool) (Config, error)
Function to read sake configs.
func (*Config) CheckConfigNoColor ¶
func (c *Config) CheckConfigNoColor()
func (*Config) EditServer ¶
Open sake config in editor and optionally go to line matching the server name
func (*Config) EditSpec ¶ added in v0.12.0
Open sake config in editor and optionally go to line matching the spec name
func (*Config) EditTarget ¶ added in v0.12.0
Open sake config in editor and optionally go to line matching the target name
func (*Config) EditTask ¶
Open sake config in editor and optionally go to line matching the task name
func (*Config) FilterServers ¶
func (c *Config) FilterServers( allServersFlag bool, serversFlag []string, tagsFlag []string, regexFlag string, invertFlag bool, ) ([]Server, error)
FilterServers returns servers matching filters, it does a union select.
func (*Config) GetRemoteServerNameAndDesc ¶
func (*Config) GetServerByGroup ¶ added in v0.12.0
func (*Config) GetServerGroupsAndDesc ¶ added in v0.12.0
func (*Config) GetServerNameAndDesc ¶
func (*Config) GetServerNames ¶
func (*Config) GetServersByName ¶
func (*Config) GetServersByRegex ¶ added in v0.12.0
Matches on server host
func (*Config) GetServersByTags ¶
Servers must have all tags to match. For instance, if --tags frontend,backend is passed, then a server must have both tags. We only return error if the flags provided do not exist in the sake config.
func (*Config) GetSpecNames ¶
func (*Config) GetSpecsByName ¶ added in v0.12.0
func (*Config) GetTargetNames ¶
func (*Config) GetTargetsByName ¶ added in v0.12.0
func (*Config) GetTaskIDAndDesc ¶
func (*Config) GetTaskNames ¶
func (*Config) GetTaskServers ¶
func (*Config) GetThemeNames ¶
func (*Config) ParseInventory ¶ added in v0.12.0
type ConfigResources ¶
type ConfigResources struct { DisableVerifyHost *bool DefaultTimeout *uint KnownHostsFile *string Shell string Imports []Import Themes []Theme Specs []Spec Targets []Target Tasks []Task Servers []Server Envs []string ConfigErrors []ResourceErrors[ConfigYAML] ImportErrors []ResourceErrors[Import] ThemeErrors []ResourceErrors[Theme] SpecErrors []ResourceErrors[Spec] TargetErrors []ResourceErrors[Target] TaskErrors []ResourceErrors[Task] ServerErrors []ResourceErrors[Server] }
Used for config imports
type ConfigYAML ¶
type ConfigYAML struct { // Internal Path string `yaml:"-"` Dir string `yaml:"-"` UserConfigFile *string `yaml:"-"` // Intermediate DisableVerifyHost *bool `yaml:"disable_verify_host"` DefaultTimeout *uint `yaml:"default_timeout"` KnownHostsFile *string `yaml:"known_hosts_file"` Shell string `yaml:"shell"` Import yaml.Node `yaml:"import"` Env yaml.Node `yaml:"env"` Themes yaml.Node `yaml:"themes"` Specs yaml.Node `yaml:"specs"` Targets yaml.Node `yaml:"targets"` Servers yaml.Node `yaml:"servers"` Tasks yaml.Node `yaml:"tasks"` // contains filtered or unexported fields }
func (*ConfigYAML) DecodeSpec ¶ added in v0.13.0
func (c *ConfigYAML) DecodeSpec(name string, specYAML yaml.Node) (*Spec, []error)
func (*ConfigYAML) DecodeTarget ¶ added in v0.13.0
func (c *ConfigYAML) DecodeTarget(name string, targetYAML yaml.Node) (*Target, []error)
func (*ConfigYAML) GetContext ¶
func (c *ConfigYAML) GetContext() string
func (*ConfigYAML) GetContextLine ¶
func (c *ConfigYAML) GetContextLine() int
func (*ConfigYAML) ParseImportsYAML ¶
func (c *ConfigYAML) ParseImportsYAML() ([]Import, []ResourceErrors[Import])
func (*ConfigYAML) ParseServersYAML ¶
func (c *ConfigYAML) ParseServersYAML() ([]Server, []ResourceErrors[Server])
ParseServersYAML parses the servers dictionary and returns it as a list.
func (*ConfigYAML) ParseSpecsYAML ¶
func (c *ConfigYAML) ParseSpecsYAML() ([]Spec, []ResourceErrors[Spec])
ParseSpecsYAML parses the specs dictionary and returns it as a list.
func (*ConfigYAML) ParseTargetsYAML ¶
func (c *ConfigYAML) ParseTargetsYAML() ([]Target, []ResourceErrors[Target])
ParseTargetsYAML parses the target dictionary and returns it as a list.
func (*ConfigYAML) ParseTasksYAML ¶
func (c *ConfigYAML) ParseTasksYAML() ([]Task, []ResourceErrors[Task])
ParseTasksYAML parses the task dictionary and returns it as a list. This function also sets task references. Valid formats (only one is allowed):
cmd: | echo pong task: ping tasks: - task: ping - task: ping - cmd: echo pong
func (*ConfigYAML) ParseThemesYAML ¶
func (c *ConfigYAML) ParseThemesYAML() ([]Theme, []ResourceErrors[Theme])
Populates ThemeList
type FoundCyclicDependency ¶
type FoundCyclicDependency struct {
Cycles []NodeLink
}
func (*FoundCyclicDependency) Error ¶
func (c *FoundCyclicDependency) Error() string
type FoundCyclicTaskDependency ¶
type FoundCyclicTaskDependency struct {
Cycles []TaskLink
}
func (*FoundCyclicTaskDependency) Error ¶
func (c *FoundCyclicTaskDependency) Error() string
type FoundDuplicateImports ¶
type FoundDuplicateImports struct {
// contains filtered or unexported fields
}
func (*FoundDuplicateImports) Error ¶
func (c *FoundDuplicateImports) Error() string
type FoundDuplicateObjects ¶ added in v0.14.0
func (*FoundDuplicateObjects) Error ¶ added in v0.14.0
func (c *FoundDuplicateObjects) Error() string
type Import ¶
type Import struct { Path string // contains filtered or unexported fields }
func (*Import) GetContext ¶
func (*Import) GetContextLine ¶
type Report ¶ added in v0.13.0
type Report struct { ReturnCode int Duration time.Duration Status TaskStatus }
type ReportData ¶ added in v0.13.0
type ReportData struct { Headers []string Tasks []ReportRow Status map[TaskStatus]int }
type ReportRow ¶ added in v0.13.0
type ReportRow struct { Name string Status map[TaskStatus]int Rows []Report }
type ResourceErrors ¶
type Server ¶
type Server struct { Name string Desc string Host string Inventory string Bastions []Bastion User string Port uint16 Local bool Tags []string Envs []string Shell string WorkDir string IdentityFile *string Password *string // Internal Group string PubFile *string RootDir string // config dir // contains filtered or unexported fields }
func CreateInventoryServers ¶ added in v0.12.0
func GetFirstRemoteServer ¶
func GetIntersectionServers ¶ added in v0.12.0
func GetInvertedServers ¶ added in v0.12.0
func (*Server) GetContext ¶
func (*Server) GetContextLine ¶
func (*Server) GetNonDefaultEnvs ¶ added in v0.12.0
type ServerYAML ¶
type ServerYAML struct { Name string `yaml:"-"` Desc string `yaml:"desc"` Host string `yaml:"host"` Hosts yaml.Node `yaml:"hosts"` Inventory string `yaml:"inventory"` Bastion string `yaml:"bastion"` Bastions []string `yaml:"bastions"` User string `yaml:"user"` Port uint16 `yaml:"port"` Local bool `yaml:"local"` Tags []string `yaml:"tags"` Env yaml.Node `yaml:"env"` Shell string `yaml:"shell"` WorkDir string `yaml:"work_dir"` IdentityFile *string `yaml:"identity_file"` Password *string `yaml:"password"` }
type Spec ¶
type Spec struct { Name string `yaml:"_"` Desc string `yaml:"desc"` Describe bool `yaml:"describe"` ListHosts bool `yaml:"list_hosts"` Order string `yaml:"order"` Silent bool `yaml:"silent"` Hidden bool `yaml:"hidden"` Strategy string `yaml:"strategy"` Batch uint32 `yaml:"batch"` BatchP uint8 `yaml:"batch_p"` Forks uint32 `yaml:"forks"` Output string `yaml:"output"` MaxFailPercentage uint8 `yaml:"max_fail_percentage"` AnyErrorsFatal bool `yaml:"any_errors_fatal"` IgnoreErrors bool `yaml:"ignore_errors"` IgnoreUnreachable bool `yaml:"ignore_unreachable"` OmitEmptyRows bool `yaml:"omit_empty_rows"` OmitEmptyColumns bool `yaml:"omit_empty_columns"` Report []string `yaml:"report"` Verbose bool `yaml:"verbose"` Confirm bool `yaml:"confirm"` Step bool `yaml:"step"` Print string `yaml:"print"` // contains filtered or unexported fields }
func (*Spec) GetContext ¶
func (*Spec) GetContextLine ¶
type Table ¶
type Table struct { // Stylable via YAML Name string `yaml:"name"` Style string `yaml:"style"` Prefix string `yaml:"prefix"` Options *TableOptions `yaml:"options"` Border *BorderColors `yaml:"border"` Title *CellColors `yaml:"title"` Header *CellColors `yaml:"header"` Row *CellColors `yaml:"row"` // Not stylable via YAML Box table.BoxStyle `yaml:"-"` }
type TableOptions ¶
type TableOutput ¶
type Target ¶
type Target struct { Name string `yaml:"name"` Desc string `yaml:"desc"` All bool `yaml:"all"` Servers []string `yaml:"servers"` Tags []string `yaml:"tags"` Regex string `yaml:"regex"` Invert bool `yaml:"invert"` Limit uint32 `yaml:"limit"` LimitP uint8 `yaml:"limit_p"` // contains filtered or unexported fields }
func (*Target) GetContext ¶
func (*Target) GetContextLine ¶
type TargetRange ¶ added in v0.12.0
type Task ¶
type Task struct { ID string Name string Desc string TTY bool Local bool Attach bool WorkDir string Shell string Envs []string Cmd string Tasks []TaskCmd Spec Spec Target Target Theme Theme TaskRefs []TaskRef SpecRef string TargetRef string ThemeRef string // contains filtered or unexported fields }
func (*Task) GetContext ¶
func (*Task) GetContextLine ¶
type TaskCmd ¶
type TaskCmd struct { ID string Name string Desc string WorkDir string Shell string RootDir string Register string Cmd string Local bool TTY bool IgnoreErrors bool Envs []string }
This is the struct that is added to the Task.Tasks in import_task.go
type TaskRef ¶
type TaskRef struct { Name string Desc string Cmd string WorkDir string Shell string Register string Task string Local *bool TTY *bool IgnoreErrors *bool Envs []string }
This is the struct that is added to the Task.TaskRefs
type TaskRefYAML ¶
type TaskRefYAML struct { Name string `yaml:"name"` Desc string `yaml:"desc"` WorkDir string `yaml:"work_dir"` Shell string `yaml:"shell"` Cmd string `yaml:"cmd"` Task string `yaml:"task"` Register string `yaml:"register"` Local *bool `yaml:"local"` IgnoreErrors *bool `yaml:"ignore_errors"` TTY *bool `yaml:"tty"` Env yaml.Node `yaml:"env"` }
Unmarshaled from YAML
type TaskResources ¶
type TaskResources struct { Tasks []Task TaskErrors []ResourceErrors[Task] }
Used for config imports
type TaskStatus ¶ added in v0.13.0
type TaskStatus int64
const ( Skipped TaskStatus = iota Ok Failed Ignored Unreachable )
func (TaskStatus) String ¶ added in v0.13.0
func (s TaskStatus) String() string
type TaskYAML ¶
type TaskYAML struct { Name string `yaml:"name"` Desc string `yaml:"desc"` Local bool `yaml:"local"` TTY bool `yaml:"tty"` Attach bool `yaml:"attach"` WorkDir string `yaml:"work_dir"` Shell string `yaml:"shell"` Cmd string `yaml:"cmd"` Task string `yaml:"task"` Tasks []TaskRefYAML `yaml:"tasks"` Env yaml.Node `yaml:"env"` Spec yaml.Node `yaml:"spec"` Target yaml.Node `yaml:"target"` Theme yaml.Node `yaml:"theme"` }
Unmarshaled from YAML