Documentation
¶
Index ¶
- Variables
- func AbsolutePath(value string) (string, error)
- func AddToCleanupStack(cf CleanupFunc, funcName, arg string)
- func AppendStrings(lines []string, filename string, termination string) error
- func Atoi(val string) int
- func BaseName(filename string) string
- func CheckOrigin(args []string)
- func CheckSandboxDir(sandboxHome string) error
- func CheckTarballOperatingSystem(basedir string) error
- func CondPrintf(format string, args ...interface{})
- func CondPrintln(args ...interface{})
- func CopyFile(source, destination string) error
- func DirExists(filename string) bool
- func DirName(filename string) string
- func ErrCheckExitf(err error, exitCode int, format string, args ...interface{})
- func ExecExists(filename string) bool
- func Exit(exitCode int, messages ...string)
- func Exitf(exitCode int, format string, args ...interface{})
- func FileExists(filename string) bool
- func FindFreePort(basePort int, installedPorts []int, howMany int) (int, error)
- func FindInPath(filename string) string
- func GetAvailableVersions() ([]string, error)
- func GetInstalledPorts(sandboxHome string) ([]int, error)
- func GetVersionsFromDir(basedir string) ([]string, error)
- func GreaterOrEqualVersion(version string, comparedTo []int) (bool, error)
- func Includes(mainString, contained string) bool
- func IntSliceToDottedString(val []int) string
- func IsATarball(fileName string) bool
- func IsEnvSet(envVar string) bool
- func IsVersion(version string) bool
- func LatestVersion(searchDir, pattern string) string
- func LogDirName() string
- func MakeCustomizedUuid(port, nodeNum int) (string, error)
- func Mkdir(dirName string)
- func RemoveTrailingSlash(s string) string
- func ReplaceEnvVar(name string, envVar string) string
- func ReplaceHomeVar(path string) string
- func ReplaceLiteralEnvVar(name string, envVar string) string
- func ReplaceLiteralHome(path string) string
- func Rmdir(dirName string)
- func RmdirAll(dirName string)
- func RunCleanupActions()
- func RunCmd(c string) (string, error)
- func RunCmdCtrl(c string, silent bool) (string, error)
- func RunCmdWithArgs(c string, args []string) (string, error)
- func SandboxInfoToFileNames(sbList []SandboxInfo) (fileNames []string)
- func SlurpAsBytes(filename string) ([]byte, error)
- func SlurpAsLines(filename string) ([]string, error)
- func SlurpAsString(filename string) (string, error)
- func SortVersions(versions []string) []string
- func SortVersionsSubset(versions []string, wanted string) (sorted []string)
- func StringToIntSlice(val string) (numberList []int, err error)
- func TemplateFill(tmpl string, data StringMap) string
- func TextToBool(value string) (result bool)
- func TrimmedLines(s string) string
- func VersionToList(version string) ([]int, error)
- func VersionToName(version string) string
- func VersionToPort(version string) (int, error)
- func Which(filename string) string
- func WriteSandboxDescription(destination string, sd SandboxDescription) error
- func WriteString(line string, filename string) error
- func WriteStrings(lines []string, filename string, termination string) error
- type CleanupFunc
- type CleanupRec
- type ConfigOptions
- type KeyValue
- type PortMap
- type SandboxDescription
- type SandboxInfo
- type SandboxUser
- type Stack
- type StringMap
Constants ¶
This section is empty.
Variables ¶
var CommandLineArgs []string
var CompatibleVersion string = "1.14.0" // 2018-12-04
Compatible version is the version used to mark compatible archives (templates, configuration). It is usually major.minor.0, except when we are at version 0.x, when every revision may bring incompatibility
var VersionDef string = "1.15.1" // 2018-12-10
Functions ¶
func AbsolutePath ¶
Returns the absolute path of a file
func AddToCleanupStack ¶
func AddToCleanupStack(cf CleanupFunc, funcName, arg string)
Adds an action to the list of clean-up operations to run before aborting the program
func AppendStrings ¶
append a string slice into an existing file
func CheckOrigin ¶
func CheckOrigin(args []string)
Checks the initial argument for a sandbox deployment
func CheckSandboxDir ¶
Creates a sandbox directory if it does not exist
func CheckTarballOperatingSystem ¶
Checks that the extracted tarball directory
contains one or more files expected for the current operating system. It prevents simple errors like : * using a Linux tarball on a Mac or vice-versa * using a source or test tarball instead of a binaries one.
func CondPrintf ¶
func CondPrintf(format string, args ...interface{})
func CondPrintln ¶
func CondPrintln(args ...interface{})
func ErrCheckExitf ¶
Checks the status of error variable and exit with custom message if it is not nil.
func FindFreePort ¶
Finds the a range of howMany free ports available, starting at basePort. installedPorts is a slice of ports already used by other sandboxes. Calls either findFreePortRange or findFreePortSingle, depending on the amount of ports requested. Returns the first port of the requested range
func GetAvailableVersions ¶
func GetInstalledPorts ¶
Collects a list of used ports from deployed sandboxes
func GetVersionsFromDir ¶
Returns the list of versions available for deployment
func GreaterOrEqualVersion ¶
Checks if a version string is greater or equal a given numeric version "5.6.33" >= []{5.7.0} = false "5.7.21" >= []{5.7.0} = true "10.1.21" >= []{5.7.0} = false (!) Note: MariaDB versions are skipped. The function returns false for MariaDB 10+. So far (2018-02-19) this comparison holds, because MariaDB behaves like 5.5+ for the purposes of sandbox deployment
func IntSliceToDottedString ¶
Given an array of integers, returns a string containing the numbers separated by a dot. For example: an input of []int{1, 2, 3} returns "1.2.3"
func IsATarball ¶
Returns true if the file name has a recognized tarball extension for use with dbdeployer
func LatestVersion ¶
Returns the latest version among the ones found in a Sandbox binary directory
func MakeCustomizedUuid ¶
Creates a "human readable" and predictable UUID using some pre-defined elements. Used to replace the random UUID created by MySQL 5.6+, with the purpose of returning easy to read server identifiers that can be processed visually.
func RemoveTrailingSlash ¶
Removes a slash (if any) at the end of a given string
func ReplaceEnvVar ¶
Replaces the environment variable `envVar` with its value for example, if "$HOME" resolves to "/home/goofy" the string "$HOME/some/path" would become "/home/goofy/some/path"
func ReplaceHomeVar ¶
Given a path with the variable "$HOME" at the start, returns a string with the value of HOME expanded
func ReplaceLiteralEnvVar ¶
Replaces the literal value of an environment variable with its name for example, if "$HOME" resolves to "/home/goofy" the string "/home/goofy/some/path" would become "$HOME/some/path"
func ReplaceLiteralHome ¶
Given a path starting at the HOME directory returns a string where the literal value for $HOME is replaced by the string "$HOME"
func RmdirAll ¶
func RmdirAll(dirName string)
Removes a directory with its contents, and exits if an error occurs
func RunCmdCtrl ¶
Runs a command, with optional quiet output
func RunCmdWithArgs ¶
Runs a command with arguments
func SandboxInfoToFileNames ¶
func SandboxInfoToFileNames(sbList []SandboxInfo) (fileNames []string)
Returns a list of inner sandboxes
func SlurpAsBytes ¶
reads a file and returns its contents as a byte slice
func SlurpAsLines ¶
Reads a file and returns its lines as a string slice
func SlurpAsString ¶
Reads a file and returns its contents as a single string
func SortVersions ¶
func SortVersionsSubset ¶
Given a list of version strings (in the format x.x.x) this function returns an ordered list, taking into account the components of the versions, so that 5.6.2 sorts lower than 5.6.11 while a text sort would put 5.6.11 before 5.6.2 If wanted is not empty, it will be interpreted as a short version to match. For example, when wanted is "5.6", only the versions starting with '5.6' will be considered.
func StringToIntSlice ¶
Given a string containing comma-separated integers, returns an array of integers Example: an input of "1,2,3" returns []int{1, 2, 3}
func TemplateFill ¶
TemplateFill passed template string is formatted using its operands and returns the resulting string. Spaces are added between operands when neither is a string. Based on code from https://play.golang.org/p/COHKlB2RML
func TextToBool ¶
Returns true if the input value is either of "true", "yes", "1"
func TrimmedLines ¶
Given a multi-line string, this function removes leading spaces from every line. It also removes the first line, if it is empty
func VersionToList ¶
Gets three integers for a version string Converts "1.2.3" into []int{1, 2, 3}
func VersionToName ¶
Converts a version string into a name. Replaces dots with underscores. "1.2.3" -> "1_2_3"
func VersionToPort ¶
Converts a version string into a port number e.g. "5.6.33" -> 5633
func Which ¶
Returns the full path of an executable, or an empty string if the executable is not found
func WriteSandboxDescription ¶
func WriteSandboxDescription(destination string, sd SandboxDescription) error
Writes the description of a sandbox in the appropriate directory
func WriteString ¶
append a string into an existing file
Types ¶
type CleanupFunc ¶
type CleanupFunc func(target string)
type CleanupRec ¶
type CleanupRec struct {
// contains filtered or unexported fields
}
type ConfigOptions ¶
func ParseConfigFile ¶
func ParseConfigFile(filename string) (ConfigOptions, error)
Reads a MySQL configuration file and returns its structured contents
type SandboxDescription ¶
type SandboxDescription struct {
Basedir string `json:"basedir"`
SBType string `json:"type"` // single multi master-slave group
Version string `json:"version"`
Port []int `json:"port"`
Nodes int `json:"nodes"`
NodeNum int `json:"node_num"`
DbDeployerVersion string `json:"dbdeployer-version"`
Timestamp string `json:"timestamp"`
CommandLine string `json:"command-line"`
LogFile string `json:"log-file,omitempty"`
}
func ReadSandboxDescription ¶
func ReadSandboxDescription(sandboxDirectory string) (SandboxDescription, error)
Reads sandbox description from a given directory
type SandboxInfo ¶
func GetInstalledSandboxes ¶
func GetInstalledSandboxes(sandboxHome string) (installedSandboxes []SandboxInfo, err error)
Gets a list of installed sandboxes from the $SANDBOX_HOME directory
type SandboxUser ¶
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
The stack is implemented using a double-linked list from Go standard library
func (*Stack) Bottom ¶
func (stack *Stack) Bottom() interface{}
Bottom() returns the object stored as .Value in the bottom list element The object is NOT removed from the list
func (*Stack) Pop ¶
func (stack *Stack) Pop() interface{}
Pop() returns the object stored as .Value in the top list element Client calls will need to cast the object to the expected type. The object is removed from the list e.g.:
type MyType struct { ... }
var lastOne MyType
lastOne = stack.Pop().(MyType)