Documentation ¶
Index ¶
- Variables
- func CompiledAt() time.Time
- func ContainsString(items []string, target string) bool
- func ConvertUnit(size int64) (int64, string)
- func Exists(path string) (bool, error)
- func ExpandHomePath(p string, home string) string
- func FetchTarball(url string) (*http.Response, error)
- func FormatMessage(color string, useColors bool, messages ...string) string
- func FullVersion() string
- func InstalledWithHomebrew() bool
- func MaxInt(input ...int) int
- func MinInt(input ...int) int
- func QueryString(opts interface{}) map[string]interface{}
- func SortByModDate(dirs []os.FileInfo)
- func SplitSpaceOrComma(str string) []string
- func TarPath(writer io.Writer, root string) error
- func UntarOne(name string, dst io.Writer, src io.ReadCloser) error
- func Untargzip(path string, r io.Reader) error
- func Version() string
- type Archive
- func (a *Archive) Multi(source, target string, maxSize int64) (errs chan error)
- func (a *Archive) Single(source, target string, maxSize int64) (errs chan error)
- func (a *Archive) SingleBytes(source string, dst *bytes.Buffer) chan error
- func (a *Archive) Stream(processors ...ArchiveProcessor) error
- func (a *Archive) Tee(w io.Writer)
- type ArchiveBytes
- type ArchiveCheckEmpty
- type ArchiveExtract
- type ArchiveMaxSize
- type ArchiveProcessor
- type ArchiveSingle
- type ByModifiedTime
- type CLISettings
- func (s *CLISettings) Bool(name string, def ...interface{}) (rv bool, ok bool)
- func (s *CLISettings) BoolT(name string, def ...interface{}) (rv bool, ok bool)
- func (s *CLISettings) Duration(name string, def ...interface{}) (rv time.Duration, ok bool)
- func (s *CLISettings) Float64(name string, def ...interface{}) (rv float64, ok bool)
- func (s *CLISettings) GlobalBool(name string, def ...interface{}) (rv bool, ok bool)
- func (s *CLISettings) GlobalDuration(name string, def ...interface{}) (rv time.Duration, ok bool)
- func (s *CLISettings) GlobalInt(name string, def ...interface{}) (rv int, ok bool)
- func (s *CLISettings) GlobalIntSlice(name string, def ...interface{}) (rv []int, ok bool)
- func (s *CLISettings) GlobalString(name string, def ...interface{}) (rv string, ok bool)
- func (s *CLISettings) GlobalStringSlice(name string, def ...interface{}) (rv []string, ok bool)
- func (s *CLISettings) Int(name string, def ...interface{}) (rv int, ok bool)
- func (s *CLISettings) IntSlice(name string, def ...interface{}) (rv []int, ok bool)
- func (s *CLISettings) String(name string, def ...interface{}) (rv string, ok bool)
- func (s *CLISettings) StringSlice(name string, def ...interface{}) (rv []string, ok bool)
- type CheapSettings
- func (s *CheapSettings) Bool(name string, def ...interface{}) (rv bool, ok bool)
- func (s *CheapSettings) BoolT(name string, def ...interface{}) (rv bool, ok bool)
- func (s *CheapSettings) Duration(name string, def ...interface{}) (rv time.Duration, ok bool)
- func (s *CheapSettings) Float64(name string, def ...interface{}) (rv float64, ok bool)
- func (s *CheapSettings) GlobalBool(name string, def ...interface{}) (rv bool, ok bool)
- func (s *CheapSettings) GlobalDuration(name string, def ...interface{}) (rv time.Duration, ok bool)
- func (s *CheapSettings) GlobalInt(name string, def ...interface{}) (rv int, ok bool)
- func (s *CheapSettings) GlobalIntSlice(name string, def ...interface{}) (rv []int, ok bool)
- func (s *CheapSettings) GlobalString(name string, def ...interface{}) (rv string, ok bool)
- func (s *CheapSettings) GlobalStringSlice(name string, def ...interface{}) (rv []string, ok bool)
- func (s *CheapSettings) Int(name string, def ...interface{}) (rv int, ok bool)
- func (s *CheapSettings) IntSlice(name string, def ...interface{}) (rv []int, ok bool)
- func (s *CheapSettings) String(name string, def ...interface{}) (rv string, ok bool)
- func (s *CheapSettings) StringSlice(name string, def ...interface{}) (rv []string, ok bool)
- type Counter
- type CounterReader
- type Debouncer
- type Environment
- func (e *Environment) Add(key, value string)
- func (e *Environment) Export() []string
- func (e *Environment) Get(key string) string
- func (e *Environment) GetHiddenPassthru() (env *Environment)
- func (e *Environment) GetInclHidden(key string) string
- func (e *Environment) GetMirror() [][]string
- func (e *Environment) GetPassthru() (env *Environment)
- func (e *Environment) Interpolate(s string) string
- func (e *Environment) Ordered() [][]string
- func (e *Environment) Update(a [][]string)
- type Finisher
- type Formatter
- type LogEntry
- type LogFields
- type Logger
- type Settings
- type SignalHandler
- type SignalMonkey
- type Stepper
- type TerseFormatter
- type TestLogFormatter
- type TestLogWriter
- type TestSuite
- type Timer
- type VerboseFormatter
- type Versions
Constants ¶
This section is empty.
Variables ¶
var ( // GitCommit is the git commit hash associated with this build. GitCommit = "" // MajorVersion is the semver major version. MajorVersion = "1" // MinorVersion is the semver minor version. MinorVersion = "0" // PatchVersion is the semver patch version. (use 0 for dev, build process // will inject a build number) PatchVersion = "0" // Compiled is the unix timestamp when this binary got compiled. Compiled = "" )
var ( // ErrEmptyTarball is returned when the tarball has no files in it ErrEmptyTarball = errors.New("empty tarball") )
Functions ¶
func CompiledAt ¶
CompiledAt converts the Unix time Compiled to a time.Time using UTC timezone.
func ContainsString ¶
ContainsString checks if the array items contains the string target. TODO(bvdberg): write units tests
func ConvertUnit ¶
ConvertUnit takes the number of bytes and converts this to the largest unit possible, where the result is still > 1. Uses default golang int rounding.
func ExpandHomePath ¶
ExpandHomePath will expand ~/ in p to home.
func FetchTarball ¶
FetchTarball tries to fetch a tarball For now this is pretty naive and useless, but we are doing it in a couple places and this is a fine stub to expand upon.
func FormatMessage ¶
FormatMessage handles one or two messages. If more messages are used, those are ignore. If no messages are used, than it will return an empty string. 1 message : --> message[0] 2 messages: --> message[0]: message[1] color will be applied to the first message, varColor will be used for the second message. If useColors is false, than color will be ignored.
func FullVersion ¶
func FullVersion() string
FullVersion returns the semver version and the git version if available.
func InstalledWithHomebrew ¶
func InstalledWithHomebrew() bool
InstalledWithHomebrew tries to determine if the cli was installed with homebrew
func MaxInt ¶
MaxInt finds the biggest int in input and return that value. If no input is given, it will return 0.
func MinInt ¶
MinInt finds the smallest int in input and return that value. If no input is given, it will return 0.
func QueryString ¶
func QueryString(opts interface{}) map[string]interface{}
QueryString converts a struct to a map. It looks for items with a qs tag. This code was taken from the fsouza/go-dockerclient, and then slightly modified. See: https://github.com/fsouza/go-dockerclient/blob/5fa67ac8b52afe9430a490391a639085e9357e1e/client.go#L535
func SortByModDate ¶
SortByModDate sorts the files or folders descending by modification date
func SplitSpaceOrComma ¶
Types ¶
type Archive ¶
type Archive struct {
// contains filtered or unexported fields
}
Archive holds the tarball stream and provides methods to manipulate it
func (*Archive) SingleBytes ¶
SingleBytes gives you the bytes of a single file, with empty check
func (*Archive) Stream ¶
func (a *Archive) Stream(processors ...ArchiveProcessor) error
Stream is the low-level interface to the archive stream processor
type ArchiveBytes ¶
ArchiveBytes is expected to be used with an ArchiveSingle filter so that it only gets one file, if not the buffer will be pretty silly
type ArchiveCheckEmpty ¶
type ArchiveCheckEmpty struct {
// contains filtered or unexported fields
}
ArchiveCheckEmpty is an ArchiveProcessor to check whether a stream is empty
func (*ArchiveCheckEmpty) IsEmpty ¶
func (p *ArchiveCheckEmpty) IsEmpty() bool
IsEmpty will represent whether the tarball was empty after processing
type ArchiveExtract ¶
type ArchiveExtract struct {
// contains filtered or unexported fields
}
ArchiveExtract everything to a tempdir, methods for Rename and Cleanup
func NewArchiveExtract ¶
func NewArchiveExtract(tempDir string) *ArchiveExtract
NewArchiveExtract creates a new ArchiveExtract. tempDir is directory to perform work. Leave empty string to use default
func (*ArchiveExtract) Clean ¶
func (p *ArchiveExtract) Clean()
Clean should be called to clean up the workingDir
func (*ArchiveExtract) Rename ¶
func (p *ArchiveExtract) Rename(source, target string) error
Rename one of the extracted paths to the target path
type ArchiveMaxSize ¶
type ArchiveMaxSize struct { MaxSize int64 // in bytes // contains filtered or unexported fields }
ArchiveMaxSize throws an error and stop stream if MaxSize reached
type ArchiveProcessor ¶
ArchiveProcessor is a stream processor for the archive tarballs
type ArchiveSingle ¶
type ArchiveSingle struct {
Name string
}
ArchiveSingle filters all but a single item out of the string
type ByModifiedTime ¶
ByModifiedTime is used for sorting files/folders by mod time
func (ByModifiedTime) Len ¶
func (s ByModifiedTime) Len() int
Len returns the length of items in the slice
func (ByModifiedTime) Less ¶
func (s ByModifiedTime) Less(i, j int) bool
Less returns true if the first value shoudl appear first in the sorted results
func (ByModifiedTime) Swap ¶
func (s ByModifiedTime) Swap(i, j int)
Swap swaps two items when sorting
type CLISettings ¶
type CLISettings struct { CheapSettings *CheapSettings // contains filtered or unexported fields }
CLISettings is a wrapper on a cli.Context with a special "target" set in place of "Args().First()"
func NewCLISettings ¶
func NewCLISettings(ctx *cli.Context) *CLISettings
func (*CLISettings) Bool ¶
func (s *CLISettings) Bool(name string, def ...interface{}) (rv bool, ok bool)
func (*CLISettings) BoolT ¶
func (s *CLISettings) BoolT(name string, def ...interface{}) (rv bool, ok bool)
func (*CLISettings) Duration ¶
func (s *CLISettings) Duration(name string, def ...interface{}) (rv time.Duration, ok bool)
func (*CLISettings) Float64 ¶
func (s *CLISettings) Float64(name string, def ...interface{}) (rv float64, ok bool)
func (*CLISettings) GlobalBool ¶
func (s *CLISettings) GlobalBool(name string, def ...interface{}) (rv bool, ok bool)
func (*CLISettings) GlobalDuration ¶
func (s *CLISettings) GlobalDuration(name string, def ...interface{}) (rv time.Duration, ok bool)
func (*CLISettings) GlobalInt ¶
func (s *CLISettings) GlobalInt(name string, def ...interface{}) (rv int, ok bool)
func (*CLISettings) GlobalIntSlice ¶
func (s *CLISettings) GlobalIntSlice(name string, def ...interface{}) (rv []int, ok bool)
func (*CLISettings) GlobalString ¶
func (s *CLISettings) GlobalString(name string, def ...interface{}) (rv string, ok bool)
func (*CLISettings) GlobalStringSlice ¶
func (s *CLISettings) GlobalStringSlice(name string, def ...interface{}) (rv []string, ok bool)
func (*CLISettings) Int ¶
func (s *CLISettings) Int(name string, def ...interface{}) (rv int, ok bool)
func (*CLISettings) IntSlice ¶
func (s *CLISettings) IntSlice(name string, def ...interface{}) (rv []int, ok bool)
func (*CLISettings) String ¶
func (s *CLISettings) String(name string, def ...interface{}) (rv string, ok bool)
func (*CLISettings) StringSlice ¶
func (s *CLISettings) StringSlice(name string, def ...interface{}) (rv []string, ok bool)
type CheapSettings ¶
type CheapSettings struct {
// contains filtered or unexported fields
}
CheapSettings based on a map, returns val, ok
func NewCheapSettings ¶
func NewCheapSettings(data map[string]interface{}) *CheapSettings
func (*CheapSettings) Bool ¶
func (s *CheapSettings) Bool(name string, def ...interface{}) (rv bool, ok bool)
func (*CheapSettings) BoolT ¶
func (s *CheapSettings) BoolT(name string, def ...interface{}) (rv bool, ok bool)
BoolT is true by default
func (*CheapSettings) Duration ¶
func (s *CheapSettings) Duration(name string, def ...interface{}) (rv time.Duration, ok bool)
func (*CheapSettings) Float64 ¶
func (s *CheapSettings) Float64(name string, def ...interface{}) (rv float64, ok bool)
func (*CheapSettings) GlobalBool ¶
func (s *CheapSettings) GlobalBool(name string, def ...interface{}) (rv bool, ok bool)
func (*CheapSettings) GlobalDuration ¶
func (s *CheapSettings) GlobalDuration(name string, def ...interface{}) (rv time.Duration, ok bool)
func (*CheapSettings) GlobalInt ¶
func (s *CheapSettings) GlobalInt(name string, def ...interface{}) (rv int, ok bool)
All the Global versions to do the same thing as the non-global
func (*CheapSettings) GlobalIntSlice ¶
func (s *CheapSettings) GlobalIntSlice(name string, def ...interface{}) (rv []int, ok bool)
func (*CheapSettings) GlobalString ¶
func (s *CheapSettings) GlobalString(name string, def ...interface{}) (rv string, ok bool)
func (*CheapSettings) GlobalStringSlice ¶
func (s *CheapSettings) GlobalStringSlice(name string, def ...interface{}) (rv []string, ok bool)
func (*CheapSettings) Int ¶
func (s *CheapSettings) Int(name string, def ...interface{}) (rv int, ok bool)
func (*CheapSettings) IntSlice ¶
func (s *CheapSettings) IntSlice(name string, def ...interface{}) (rv []int, ok bool)
func (*CheapSettings) String ¶
func (s *CheapSettings) String(name string, def ...interface{}) (rv string, ok bool)
func (*CheapSettings) StringSlice ¶
func (s *CheapSettings) StringSlice(name string, def ...interface{}) (rv []string, ok bool)
type Counter ¶
type Counter struct { Current int // contains filtered or unexported fields }
Counter is a simple struct
type CounterReader ¶
type CounterReader struct {
// contains filtered or unexported fields
}
CounterReader is a io.Reader which wraps a other io.Reader and stores the bytes reader from it.
func NewCounterReader ¶
func NewCounterReader(r io.Reader) *CounterReader
NewCounterReader creates a new CounterReader.
func (*CounterReader) Count ¶
func (c *CounterReader) Count() int64
Count returns the bytes read from r.
type Debouncer ¶
Debouncer silences repeated triggers for settlePeriod and sends the current time on first trigger to C C is the public read only channel, c is the private r/w chan
type Environment ¶
type Environment struct { Hidden *Environment Map map[string]string Order []string }
Environment represents a shell environment and is implemented as something like an OrderedMap
func NewEnvironment ¶
func NewEnvironment(env ...string) *Environment
NewEnvironment fills up an Environment from a []string Usually called like: env := NewEnvironment(os.Environ())
func (*Environment) Export ¶
func (e *Environment) Export() []string
Export the environment as shell commands for use with Session.Send*
func (*Environment) GetHiddenPassthru ¶
func (e *Environment) GetHiddenPassthru() (env *Environment)
Collect the hidden passthru variables
func (*Environment) GetInclHidden ¶
func (e *Environment) GetInclHidden(key string) string
GetInclHidden gets an individual record either from this environment or the hidden environment.
func (*Environment) GetMirror ¶
func (e *Environment) GetMirror() [][]string
func (*Environment) GetPassthru ¶
func (e *Environment) GetPassthru() (env *Environment)
Collect passthru variables from the project
func (*Environment) Interpolate ¶
func (e *Environment) Interpolate(s string) string
Interpolate is a naive interpolator that attempts to replace variables identified by $VAR with the value of the VAR pipeline environment variable NOTE(termie): This will check the hidden env, too.
func (*Environment) Ordered ¶
func (e *Environment) Ordered() [][]string
Ordered returns a [][]string of the items in the env. Used only for debugging
func (*Environment) Update ¶
func (e *Environment) Update(a [][]string)
Update adds new elements to the Environment data structure.
type Finisher ¶
type Finisher struct {
// contains filtered or unexported fields
}
Finisher is a helper class for running something either right away or at `defer` time.
func NewFinisher ¶
func NewFinisher(callback func(interface{})) *Finisher
NewFinisher returns a new Finisher with a callback.
type Formatter ¶
type Formatter struct {
ShowColors bool
}
Formatter formats the messages, and optionally disabling colors. See FormatMessage for the structure of messages.
type LogEntry ¶
LogEntry wraps logrus
func (*LogEntry) WithFields ¶
WithFields wraps logrus
type Logger ¶
Logger is a wrapper for logrus so that we don't have to keep referring to its types everywhere and can add helpers
func RootLogger ¶
func RootLogger() *Logger
func (*Logger) WithFields ¶
WithFields wraps logrus
type Settings ¶
type Settings interface { Int(string, ...interface{}) (int, bool) Duration(string, ...interface{}) (time.Duration, bool) Float64(string, ...interface{}) (float64, bool) Bool(string, ...interface{}) (bool, bool) BoolT(string, ...interface{}) (bool, bool) String(string, ...interface{}) (string, bool) StringSlice(string, ...interface{}) ([]string, bool) IntSlice(string, ...interface{}) ([]int, bool) GlobalInt(string, ...interface{}) (int, bool) GlobalDuration(string, ...interface{}) (time.Duration, bool) // NOTE(termie): for some reason not in cli.Context // GlobalFloat64(string, ...interface{}) (float64, bool) GlobalBool(string, ...interface{}) (bool, bool) // NOTE(termie): for some reason not in cli.Context // GlobalBoolT(string, ...interface{}) (bool, bool) GlobalString(string, ...interface{}) (string, bool) GlobalStringSlice(string, ...interface{}) ([]string, bool) GlobalIntSlice(string, ...interface{}) ([]int, bool) }
Settings mathces the cli.Context interface so we can make a cheap re-implementation for testing purposes.
type SignalHandler ¶
SignalHandler is a little struct to hold our signal handling functions and an identifier so we can remove it from the list.
type SignalMonkey ¶
type SignalMonkey struct {
// contains filtered or unexported fields
}
SignalMonkey is a LIFO, cascading, singleton for dispatching signal handlers
func (*SignalMonkey) Dispatch ¶
func (s *SignalMonkey) Dispatch()
Dispatch calls the handlers LIFO, removing them from the list as it does if any returns false, it stops processing further handlers.
func (*SignalMonkey) Register ¶
func (s *SignalMonkey) Register(sig os.Signal)
Register ourselves to get notifications on a signal
func (*SignalMonkey) Remove ¶
func (s *SignalMonkey) Remove(fn *SignalHandler)
Remove a handler from our array
type Stepper ¶
type Stepper struct {
// contains filtered or unexported fields
}
Stepper lets use step and sync goroutines
type TerseFormatter ¶
type TerseFormatter struct { // Set to true to bypass checking for a TTY before outputting colors. ForceColors bool DisableColors bool // Set to true to disable timestamp logging (useful when the output // is redirected to a logging system already adding a timestamp) DisableTimestamp bool }
TerseFormatter gives us very basic output
type TestLogFormatter ¶
type TestLogFormatter struct {
*logrus.TextFormatter
}
TestLogFormatter removes the last newline character
func NewTestLogFormatter ¶
func NewTestLogFormatter() *TestLogFormatter
NewTestLogFormatter constructor
type TestLogWriter ¶
type TestLogWriter struct {
// contains filtered or unexported fields
}
TestLogWriter writes our logs to the test output
func NewTestLogWriter ¶
func NewTestLogWriter(t *testing.T) *TestLogWriter
NewTestLogWriter constructor
type TestSuite ¶
TestSuite is our base class for test suites
func (*TestSuite) SetupTest ¶
func (s *TestSuite) SetupTest()
SetupTest mostly just configures logging now
func (*TestSuite) TearDownTest ¶
func (s *TestSuite) TearDownTest()
TearDownTest cleans up our working dir if we made one
func (*TestSuite) WorkingDir ¶
WorkingDir makes a new temp dir to run tests in
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer so we can dump step timings
type VerboseFormatter ¶
type VerboseFormatter struct { // Set to true to bypass checking for a TTY before outputting colors. ForceColors bool DisableColors bool // Set to true to disable timestamp logging (useful when the output // is redirected to a logging system already adding a timestamp) DisableTimestamp bool }
VerboseFormatter gives us very informative output
type Versions ¶
type Versions struct { CompiledAt time.Time `json:"compiledAt,omitempty"` GitCommit string `json:"gitCommit,omitempty"` Version string `json:"version,omitempty"` }
Versions contains GitCommit and Version as a JSON marshall friendly struct.
func GetVersions ¶
func GetVersions() *Versions
GetVersions returns a Versions struct filled with the current values.
func (*Versions) FullVersion ¶
FullVersion returns the semver version and the git version if available. TODO(mh): I'd like to make the above methods of Versions
Because I'd like to reuse them on `Versions` objects used in updating