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
- type BorderColors
- type CellColors
- type ColorOptions
- type Config
- func (c *Config) CheckConfigNoColor()
- func (c Config) EditConfig() error
- func (c Config) EditServer(name string) error
- func (c Config) EditTask(name string) error
- func (c Config) FilterServers(allServersFlag bool, serversFlag []string, tagsFlag []string) ([]Server, error)
- func (c Config) GetRemoteServerNameAndDesc() []string
- func (c Config) GetServer(name string) (*Server, error)
- func (c Config) GetServerHosts() []string
- func (c Config) GetServerNameAndDesc() []string
- func (c Config) GetServerNames() []string
- func (c Config) GetServersByName(serverNames []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) 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) GetTask(id string) (*Task, error)
- func (c Config) GetTaskIDAndDesc() []string
- func (c Config) GetTaskNames() []string
- func (c Config) GetTaskServers(task *Task, runFlags *core.RunFlags) ([]Server, error)
- func (c Config) GetTasksByIDs(ids []string) ([]Task, error)
- func (c Config) GetTheme(name string) (*Theme, error)
- func (c Config) GetThemeNames() []string
- type ConfigResources
- type ConfigYAML
- 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 FoundDuplicateHosts
- type FoundDuplicateImports
- type Import
- type Node
- type NodeLink
- type Resource
- type ResourceErrors
- type Row
- type Server
- type ServerYAML
- type Spec
- type Table
- type TableColor
- type TableFormat
- type TableOptions
- type TableOutput
- type Tag
- type Target
- type Task
- type TaskCmd
- type TaskLink
- type TaskNode
- type TaskRef
- type TaskRefYAML
- type TaskResources
- 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_THEME = Theme{ Name: "default", Table: DefaultTable, Text: DefaultText, } DEFAULT_TARGET = Target{ Name: "default", All: false, Servers: []string{}, Tags: []string{}, } DEFAULT_SPEC = Spec{ Name: "default", Output: "text", Parallel: false, AnyErrorsFatal: false, IgnoreUnreachable: false, IgnoreErrors: false, OmitEmpty: false, } )
var DefaultTable = Table{ Style: "default", Box: StyleBoxASCII, Format: &TableFormat{ Header: core.Ptr("title"), Row: core.Ptr(""), }, Options: &TableOptions{ DrawBorder: core.Ptr(false), SeparateColumns: core.Ptr(true), SeparateHeader: core.Ptr(true), SeparateRows: core.Ptr(false), SeparateFooter: core.Ptr(false), }, Color: &TableColor{ Border: &BorderColors{ Header: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Attr: core.Ptr("faint"), }, Row: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Attr: core.Ptr("faint"), }, RowAlternate: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Attr: core.Ptr("faint"), }, Footer: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Attr: core.Ptr("faint"), }, }, Header: &CellColors{ Server: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("bold"), }, Tag: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("bold"), }, Desc: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("bold"), }, Host: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("bold"), }, User: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("bold"), }, Local: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("bold"), }, Port: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("bold"), }, Task: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("bold"), }, Output: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr("bold"), }, }, Row: &CellColors{ Server: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr(""), }, Tag: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr(""), }, Desc: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr(""), }, Host: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr(""), }, User: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr(""), }, Local: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr(""), }, Port: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr(""), }, Task: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr(""), }, Output: &ColorOptions{ Fg: core.Ptr(""), Bg: core.Ptr(""), Align: core.Ptr(""), Attr: core.Ptr(""), }, }, }, }
var DefaultText = Text{ Prefix: true, 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 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 ¶
Types ¶
type BorderColors ¶
type BorderColors struct { Header *ColorOptions `yaml:"header"` Row *ColorOptions `yaml:"row"` RowAlternate *ColorOptions `yaml:"row_alt"` }
type CellColors ¶
type CellColors struct { Server *ColorOptions `yaml:"server"` Tag *ColorOptions `yaml:"tag"` Desc *ColorOptions `yaml:"desc"` Host *ColorOptions `yaml:"host"` User *ColorOptions `yaml:"user"` Port *ColorOptions `yaml:"port"` Local *ColorOptions `yaml:"local"` Task *ColorOptions `yaml:"task"` Output *ColorOptions `yaml:"output"` }
type ColorOptions ¶
type Config ¶
type Config struct { DisableVerifyHost bool KnownHostsFile string Shell string Envs []string Themes []Theme Specs []Spec Targets []Target Servers []Server Tasks []Task Path string }
func ReadConfig ¶
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) 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, ) ([]Server, error)
FilterServers returns servers matching filters, it does a union select.
func (Config) GetRemoteServerNameAndDesc ¶
func (Config) GetServerHosts ¶
func (Config) GetServerNameAndDesc ¶
func (Config) GetServerNames ¶
func (Config) GetServersByName ¶
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) GetTargetNames ¶
func (Config) GetTaskIDAndDesc ¶
func (Config) GetTaskNames ¶
func (Config) GetTaskServers ¶
func (Config) GetThemeNames ¶
type ConfigResources ¶
type ConfigResources struct { DisableVerifyHost *bool 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"` 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) 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 FoundDuplicateHosts ¶
type FoundDuplicateHosts struct {
// contains filtered or unexported fields
}
func (*FoundDuplicateHosts) Error ¶
func (c *FoundDuplicateHosts) Error() string
type FoundDuplicateImports ¶
type FoundDuplicateImports struct {
// contains filtered or unexported fields
}
func (*FoundDuplicateImports) Error ¶
func (c *FoundDuplicateImports) Error() string
type Import ¶
type Import struct { Path string // contains filtered or unexported fields }
func (*Import) GetContext ¶
func (*Import) GetContextLine ¶
type ResourceErrors ¶
type Server ¶
type Server struct { Name string Desc string Host string User string Port uint16 Local bool Tags []string Envs []string Shell string WorkDir string IdentityFile *string Password *string // contains filtered or unexported fields }
func GetFirstRemoteServer ¶
func GetUnionServers ¶
func (*Server) GetContext ¶
func (*Server) GetContextLine ¶
type ServerYAML ¶
type ServerYAML struct { Name string `yaml:"-"` Desc string `yaml:"desc"` Host string `yaml:"host"` 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:"_"` Output string `yaml:"output"` Parallel bool `yaml:"parallel"` AnyErrorsFatal bool `yaml:"any_errors_fatal"` IgnoreErrors bool `yaml:"ignore_errors"` IgnoreUnreachable bool `yaml:"ignore_unreachable"` OmitEmpty bool `yaml:"omit_empty"` // 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"` Color *TableColor `yaml:"color"` Format *TableFormat `yaml:"format"` Options *TableOptions `yaml:"options"` // Not stylable via YAML Box table.BoxStyle `yaml:"-"` }
type TableColor ¶
type TableColor struct { Border *BorderColors `yaml:"border"` Header *CellColors `yaml:"header"` Row *CellColors `yaml:"row"` }
type TableFormat ¶
type TableOptions ¶
type TableOutput ¶
type Target ¶
type Target struct { Name string `yaml:"name"` All bool `yaml:"all"` Servers []string `yaml:"servers"` Tags []string `yaml:"tags"` // contains filtered or unexported fields }
func (*Target) GetContext ¶
func (*Target) GetContextLine ¶
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 ¶
func (Task) GetDefaultEnvs ¶
type TaskCmd ¶
type TaskCmd struct { ID string Name string Desc string WorkDir string Shell string RootDir string Cmd string Local bool TTY 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 Task string Local *bool TTY *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"` Local *bool `yaml:"local"` TTY *bool `yaml:"tty"` Env yaml.Node `yaml:"env"` }
This is the struct that will be unmarsheld from YAML
type TaskResources ¶
type TaskResources struct { Tasks []Task TaskErrors []ResourceErrors[Task] }
Used for config imports
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"` }