common

package
v1.73.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2023 License: Apache-2.0 Imports: 30 Imported by: 12

Documentation

Overview

DBDeployer - The MySQL Sandbox Copyright © 2006-2020 Giuseppe Maxia

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// Tarball flavors
	MySQLFlavor         = "mysql"
	MySQLShellFlavor    = "mysql-shell"
	PerconaServerFlavor = "percona"
	MariaDbFlavor       = "mariadb"
	NdbFlavor           = "ndb"
	PxcFlavor           = "pxc"
	TiDbFlavor          = "tidb"

	// Feature names
	InstallDb                   = "installdb"
	DynVariables                = "dynVars"
	SemiSynch                   = "semiSync"
	CrashSafe                   = "crashSafe"
	GTID                        = "GTID"
	EnhancedGTID                = "enhancedGTID"
	Initialize                  = "initialize"
	CreateUser                  = "createUser"
	SuperReadOnly               = "superReadOnly"
	MySQLX                      = "mysqlx"
	MySQLXDefault               = "mysqlxDefault"
	MultiSource                 = "multiSource"
	GroupReplication            = "groupReplication"
	SetPersist                  = "setPersist"
	Roles                       = "roles"
	NativeAuth                  = "nativeAuth"
	DataDict                    = "datadict"
	UpgradeWithTool             = "upgrade_with_tool"
	UpgradeWithServer           = "upgrade_with_server"
	XtradbCluster               = "xtradbCluster"
	XtradbClusterNoSlaveUpdates = "xtradbCluster_no_slave_updates"
	XtradbClusterEncryptCluster = "xtradbCluster_encrypt_cluster"
	XtradbClusterRsync          = "xtradb_cluster_rsync"
	XtradbClusterXtrabackup     = "xtradb_cluster_xtrabackup"
	NdbCluster                  = "ndbCluster"
	RootAuth                    = "rootAuth"
	AdminAddress                = "adminAddress"
	EmbedMySQLShell             = "embed-mysql-shell"
	CloneServer                 = "clone-server"
	CircularReplication         = "circular-replication"
)

Variables

View Source
var CommandLineArgs []string
View Source
var CompatibleVersion string

CompatibleVersion 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

View Source
var FlavorCompositionList = []flavorIndicator{
	{
		AllNeeded: true,
		// contains filtered or unexported fields
	},
	{
		AllNeeded: true,
		// contains filtered or unexported fields
	},
	{
		AllNeeded: true,
		// contains filtered or unexported fields
	},
	{
		AllNeeded: true,
		// contains filtered or unexported fields
	},
	{
		AllNeeded: true,
		// contains filtered or unexported fields
	},
	{
		AllNeeded: false,
		// contains filtered or unexported fields
	},
	{
		AllNeeded: false,
		// contains filtered or unexported fields
	},
	{
		AllNeeded: false,
		// contains filtered or unexported fields
	},
	{
		AllNeeded: false,
		// contains filtered or unexported fields
	},
	{
		AllNeeded: true,
		// contains filtered or unexported fields
	},
}

Flavor indicators must be listed from the most complex ones to the simplest ones, because we want to catch the flavors that require multiple elements to be identified. If we put the simpler ones on top, we would miss the complex ones.

View Source
var MariadbCapabilities = Capabilities{
	Flavor: MariaDbFlavor,
	Features: FeatureList{
		InstallDb: {
			Description: "uses mysql_install_db",
			Since:       globals.MinimumMySQLInstallDb,
			Until:       nil,
		},
		RootAuth: {
			Description: "Root Authentication during install",
			Since:       globals.MinimumRootAuthVersion,
		},
		DynVariables: MySQLCapabilities.Features[DynVariables],
		SemiSynch:    MySQLCapabilities.Features[SemiSynch],
	},
}

NOTE: We only list the capabilities for which dbdeployer needs to take action

View Source
var MySQLCapabilities = Capabilities{
	Flavor:      MySQLFlavor,
	Description: "MySQL server",
	Features: FeatureList{
		InstallDb: {
			Description: "uses mysql_install_db",
			Since:       globals.MinimumMySQLInstallDb,
			Until:       globals.MaximumMySQLInstallDb,
		},
		DynVariables: {
			Description: "dynamic variables",
			Since:       globals.MinimumDynVariablesVersion,
		},
		SemiSynch: {
			Description: "semi-synchronous replication",
			Since:       globals.MinimumSemiSyncVersion,
		},
		CrashSafe: {
			Description: "crash-safe replication",
			Since:       globals.MinimumCrashSafeVersion,
		},
		GTID: {
			Description: "Global transaction identifiers",
			Since:       globals.MinimumGtidVersion,
		},
		EnhancedGTID: {
			Description: "Enhanced Global transaction identifiers",
			Since:       globals.MinimumEnhancedGtidVersion,
		},
		Initialize: {
			Description: "mysqld --initialize as default",
			Since:       globals.MinimumDefaultInitializeVersion,
		},
		CreateUser: {
			Description: "Create user mandatory",
			Since:       globals.MinimumCreateUserVersion,
		},
		SuperReadOnly: {
			Description: "super-read-only support",
			Since:       globals.MinimumSuperReadOnly,
		},
		MySQLX: {
			Description: "MySQLX supported",
			Since:       globals.MinimumMysqlxVersion,
		},
		MySQLXDefault: {
			Description: "MySQLX enabled by default",
			Since:       globals.MinimumMysqlxDefaultVersion,
		},
		MultiSource: {
			Description: "multi-source replication",
			Since:       globals.MinimumMultiSourceReplVersion,
		},
		GroupReplication: {
			Description: "group replication",
			Since:       globals.MinimumGroupReplVersion,
		},
		SetPersist: {
			Description: "Set persist supported",
			Since:       globals.MinimumPersistVersion,
		},
		Roles: {
			Description: "Roles supported",
			Since:       globals.MinimumRolesVersion,
		},
		NativeAuth: {
			Description: "Native Authentication plugin",
			Since:       globals.MinimumNativeAuthPluginVersion,
		},
		DataDict: {
			Description: "data dictionary",
			Since:       globals.MinimumDataDictionaryVersion,
		},
		AdminAddress: {
			Description: "Connection through admin address",
			Since:       globals.MinimumAdminAddressVersion,
		},
		UpgradeWithTool: {
			Description: "upgrade using mysql_upgrade tool",
			Since:       globals.MinimumMySQLUpgradeTool,
			Until:       globals.MaximumMySQLUpgradeTool,
		},
		UpgradeWithServer: {
			Description: "upgrade using mysqld server",
			Since:       globals.MinimumMySQLUpgradeServer,
		},
		CloneServer: {
			Description: "clone MySQL server",
			Since:       globals.MinimumCloneMySQLServer,
		},
		CircularReplication: {
			Description: "Allow circular replication",
			Since:       globals.MinimumMySQLAutoIncrementIncrement,
		},
	},
}
View Source
var MySQLShellCapabilities = Capabilities{
	Flavor: MySQLShellFlavor,
	Features: FeatureList{
		EmbedMySQLShell: {
			Description: "Can embed mysql-shell into server tree",
			Since:       globals.MinimumMySQLShellEmbed,
			Until:       nil,
		},
	},
}
View Source
var NdbCapabilities = Capabilities{
	Flavor:      NdbFlavor,
	Description: "MySQL NDB Cluster",
	Features: FeatureList{
		CreateUser:   MySQLCapabilities.Features[CreateUser],
		DataDict:     MySQLCapabilities.Features[DataDict],
		DynVariables: MySQLCapabilities.Features[DynVariables],
		InstallDb: {
			Description: "uses mysql_install_db",
			Since:       globals.MinimumNdbInstallDb,
			Until:       globals.MaximumNdbInstallDb,
		},
		Initialize: {
			Description: "uses mysqld initialize",
			Since:       globals.MinimumNdbInitialize,
		},
		MySQLXDefault: MySQLCapabilities.Features[MySQLXDefault],
		Roles:         MySQLCapabilities.Features[Roles],
		SetPersist:    MySQLCapabilities.Features[SetPersist],
		NdbCluster: {
			Description: "MySQL NDB Cluster",
			Since:       globals.MinimumNdbClusterVersion,
		},
	},
}
View Source
var PerconaCapabilities = Capabilities{
	Flavor:      PerconaServerFlavor,
	Description: "Percona Server",
	Features:    MySQLCapabilities.Features,
}
View Source
var PxcCapabilities = Capabilities{
	Flavor:      PxcFlavor,
	Description: "Percona XtraDB Cluster",
	Features: addCapabilities(PerconaCapabilities.Features,
		FeatureList{
			XtradbCluster: {
				Description: "XtraDB Cluster creation",
				Since:       globals.MinimumXtradbClusterVersion,
			},
			XtradbClusterNoSlaveUpdates: {
				Description: "XtraDB Cluster creation without log_slave_updates",
				Since:       globals.MinimumXtradbClusterNoSlaveUpdatesVersion,
			},
			XtradbClusterEncryptCluster: {
				Description: "XtraDB Cluster creation with cluster encryption",
				Since:       globals.MinimumXtradbClusterNoSlaveUpdatesVersion,
			},
			XtradbClusterRsync: {
				Description: "XtraDB Cluster SST method using rsync",
				Since:       globals.MinimumXtradbClusterRsync,
				Until:       globals.MaximumXtradbClusterRsync,
			},
			XtradbClusterXtrabackup: {
				Description: "XtraDB Cluster SST method using XtraBackup",
				Since:       globals.MinimumXtradbClusterXtraBackup,
			},
		}),
}
View Source
var TiDBCapabilities = Capabilities{
	Flavor:      TiDbFlavor,
	Description: "TiDB isolated server",
	Features:    FeatureList{},
}
View Source
var VersionDef string

Functions

func AbsolutePath

func AbsolutePath(value string) (string, error)

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

func AppendStrings(lines []string, filename string, termination string) error

append a string slice into an existing file

func Atoi

func Atoi(val string) int

Converts a string to an integer. Exits on error

func BaseName

func BaseName(filename string) string

Returns the base name of a file

func BeginsWith added in v1.52.0

func BeginsWith(s, expr string) bool

BeginsWith returns true when a given expression is found at the start of the input string Unlike `strings.HasPrefix`, the expression can be a regular expression rather than a fixed string

func CheckFlavorSupport added in v1.19.0

func CheckFlavorSupport(flavor string) error

func CheckLibraries added in v1.40.0

func CheckLibraries(basedir string) error

func CheckOrigin

func CheckOrigin(args []string)

Checks the initial argument for a sandbox deployment

func CheckPrerequisites added in v1.21.0

func CheckPrerequisites(label string, neededExecutables []string) error

func CheckSandboxDir

func CheckSandboxDir(sandboxHome string) error

Creates a sandbox directory if it does not exist

func CheckTarballOperatingSystem

func CheckTarballOperatingSystem(basedir string) error

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 Coalesce added in v1.32.0

func Coalesce(items ...interface{}) interface{}

Coalesce returns the first object that is not empty

func CoalesceString added in v1.32.0

func CoalesceString(items ...string) string

CoalesceString returns the first string that it is not empty or an empty string if all items are empty

func CondPrintf

func CondPrintf(format string, args ...interface{})

func CondPrintln

func CondPrintln(args ...interface{})

func CopyFile

func CopyFile(source, destination string) error

Copies a file

func DetectBinaryFlavor added in v1.19.0

func DetectBinaryFlavor(basedir string) string

Tries to detect the database flavor from files in the tarball directory

func DetectTarballFlavor added in v1.44.0

func DetectTarballFlavor(tarballName string) string

Tries to detect the database flavor from tarball name

func DirExists

func DirExists(filename string) bool

returns true if a given directory exists

func DirName

func DirName(filename string) string

Returns the directory name of a file

func EndsWith added in v1.52.0

func EndsWith(s, expr string) bool

EndsWith returns true when a given expression is found at the end of the input string Unlike `strings.HasSuffix`, the expression can be a regular expression rather than a fixed string

func ErrCheckExitf

func ErrCheckExitf(err error, exitCode int, format string, args ...interface{})

Checks the status of error variable and exit with custom message if it is not nil.

func ExecExists

func ExecExists(filename string) bool

returns true if a given executable exists

func Exit

func Exit(exitCode int, messages ...string)

Exit with custom set of messages Runs cleanup actions before aborting the program

func Exitf

func Exitf(exitCode int, format string, args ...interface{})

Exit with formatted message Runs cleanup actions before aborting the program

func FileExists

func FileExists(filename string) bool

returns true if a given file exists

func FindFreePort

func FindFreePort(basePort int, installedPorts []int, howMany int) (int, error)

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 FindInPath

func FindInPath(filename string) string

Same as Which

func FindTarballInfo added in v1.44.0

func FindTarballInfo(fileName string) (flavor, version, shortVersion string, err error)

func GetAvailableVersions

func GetAvailableVersions() ([]string, error)

func GetBashPath added in v1.32.0

func GetBashPath(wantedValue string) (string, error)

func GetCompatibleClientVersion added in v1.39.0

func GetCompatibleClientVersion(basedir, serverVersion string) (string, error)

func GetEarliestVersion added in v1.39.0

func GetEarliestVersion(sandboxBinary string, wantedVersion, flavor string) string

func GetFileChecksum added in v1.34.0

func GetFileChecksum(fileName, crcType string) (string, error)

Get a file checksum, choosing among MD5, SH1, SHA256, and SHA512

func GetFileMd5 added in v1.34.0

func GetFileMd5(fileName string) (string, error)

func GetFileSha1 added in v1.34.0

func GetFileSha1(fileName string) (string, error)

func GetFileSha256 added in v1.34.0

func GetFileSha256(fileName string) (string, error)

func GetFileSha512 added in v1.34.0

func GetFileSha512(fileName string) (string, error)

func GetFlavoredVersionsFromDir added in v1.24.0

func GetFlavoredVersionsFromDir(basedir, flavor string) []string

Returns the list of versions of a given flavor, or an empty list if no versions were available for that flavor

func GetInstalledPorts

func GetInstalledPorts(sandboxHome string) ([]int, error)

Collects a list of used ports from deployed sandboxes

func GetLatestVersion added in v1.39.0

func GetLatestVersion(sandboxBinary string, wantedVersion, flavor string) string

func GetRegexNamedGroups added in v1.52.0

func GetRegexNamedGroups(text string, expression *regexp.Regexp) (map[string]string, error)

GetRegexNamedGroups returns the strings captured by a regular expression with named groups It returns an error when no named groups were in the regular expression It returns nil when the expression did not match

func GetRegexPositionalGroups added in v1.52.0

func GetRegexPositionalGroups(text string, expression *regexp.Regexp) ([]string, error)

GetRegexPositionalGroups returns the strings captured by a regular expression with positional groups It returns an error when named groups were in the regular expression It returns nil when the expression did not match

func GetVarsFromTemplate added in v1.24.0

func GetVarsFromTemplate(tmpl string) []string

Gets a list of all variables mentioned in a template

func GetVersionsFromDir

func GetVersionsFromDir(basedir string) ([]string, error)

Returns the list of versions available for deployment

func GlobalTempDir added in v1.30.0

func GlobalTempDir() string

func GreaterOrEqualVersion

func GreaterOrEqualVersion(version string, comparedTo []int) (bool, error)

Checks if a version string is greater or equal a given numeric version "5.6.33" >= []int{5,7,0} = false "5.7.21" >= []int{5,7,0} = true "10.1.21" >= []int{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

DEPRECATED as of 1.18.0 Use GreaterOrEqualVersionList and flavors instead

func GreaterOrEqualVersionList added in v1.19.0

func GreaterOrEqualVersionList(verList, comparedTo []int) (bool, error)

func HasCapability added in v1.19.0

func HasCapability(flavor, feature, version string) (bool, error)

Returns true if a given flavor and version support the wanted feature

func Includes

func Includes(mainString, contained string) bool

Return true is `contained` is a sub-string of `mainString`

func IntSliceToDottedString

func IntSliceToDottedString(val []int) string

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 IntSliceToSeparatedString added in v1.41.0

func IntSliceToSeparatedString(val []int, separator string) string

Given an array of integers, returns a string containing the numbers separated by a given string. For example: an input of []int{1, 2, 3}, "#" returns "1#2#3"

func IsATarball

func IsATarball(fileName string) bool

Returns true if the file name has a recognized tarball extension for use with dbdeployer

func IsCompatibleVersion added in v1.31.0

func IsCompatibleVersion(versionStr string) bool

Checks whether a version string is equal or greater than the current compatible version

func IsEmptyOrBlank added in v1.32.0

func IsEmptyOrBlank(s string) bool

IsEmptyOrBlank returns true if the given string is empty or contains only spaces It also returns true for a string that contains spaces AND A NEWLINE empty: "" empty with newline: "\n" only spaces: " " spaces and tabs: " \t" spaces and newline: " \n"

func IsEnvSet

func IsEnvSet(envVar string) bool

Checks whether a given environment variable is set

func IsIPV4 added in v1.17.0

func IsIPV4(ip string) bool

Returns true if a given string looks like an IPV4

func IsUrl added in v1.35.0

func IsUrl(s string) bool

Return true if a given string is a valid URL

func IsVersion

func IsVersion(version string) bool

Returns true if a given string looks contains a version number (major.minor.rev)

func LatestVersion

func LatestVersion(searchDir, pattern string) string

Returns the latest version among the ones found in a Sandbox binary directory

func LogDirName

func LogDirName() string

Returns the name of the log directory

func MakeCustomizedUuid

func MakeCustomizedUuid(port, nodeNum int) (string, error)

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 Matches added in v1.52.0

func Matches(s string, expr string) bool

Matches returns true when a given expression matches the input string

func Mkdir

func Mkdir(dirName string)

Creates a directory, and exits if an error occurs

func OptionCompare added in v1.44.0

func OptionCompare(option, value string) bool

func OptionComponents added in v1.44.0

func OptionComponents(s string) (value string, negation bool)

func RemoveSuffix added in v1.56.0

func RemoveSuffix(s, suffix string) string

func RemoveTrailingSlash

func RemoveTrailingSlash(s string) string

Removes a slash (if any) at the end of a given string

func ReplaceEnvVar

func ReplaceEnvVar(name string, envVar string) string

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

func ReplaceHomeVar(path string) string

Given a path with the variable "$HOME" at the start, returns a string with the value of HOME expanded

func ReplaceLiteralEnvVar

func ReplaceLiteralEnvVar(name string, envVar string) string

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

func ReplaceLiteralHome(path string) string

Given a path starting at the HOME directory returns a string where the literal value for $HOME is replaced by the string "$HOME"

func Rmdir

func Rmdir(dirName string)

Removes a directory, and exits if an error occurs

func RmdirAll

func RmdirAll(dirName string)

RmDirAll removes a directory with its contents, and exits if an error occurs Checks that the directory does not contain $HOME or $PWD

func RunCleanupActions

func RunCleanupActions()

Runs the cleanup actions (usually before Exit)

func RunCmd

func RunCmd(c string) (string, error)

Runs a command

func RunCmdCtrl

func RunCmdCtrl(c string, silent bool) (string, error)

Runs a command, with optional quiet output

func RunCmdCtrlWithArgs added in v1.32.0

func RunCmdCtrlWithArgs(c string, args []string, silent bool) (string, error)

Runs a command with arguments and output suppression

func RunCmdWithArgs

func RunCmdWithArgs(c string, args []string) (string, error)

Runs a command with arguments

func SafeTemplateFill added in v1.23.0

func SafeTemplateFill(template_name, tmpl string, data StringMap) (string, error)

SafeTemplateFill passed template string is formatted using its operands and returns the resulting string. It checks that the data was safely initialized

func SandboxInfoToFileNames

func SandboxInfoToFileNames(sbList []SandboxInfo) (fileNames []string)

Returns a list of inner sandboxes

func SlurpAsBytes

func SlurpAsBytes(filename string) ([]byte, error)

reads a file and returns its contents as a byte slice

func SlurpAsLines

func SlurpAsLines(filename string) ([]string, error)

Reads a file and returns its lines as a string slice

func SlurpAsString

func SlurpAsString(filename string) (string, error)

Reads a file and returns its contents as a single string

func SortVersions

func SortVersions(versions []string) []string

func SortVersionsSubset

func SortVersionsSubset(versions []string, wanted string) (sorted []string)

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

func StringToIntSlice(val string) (numberList []int, err error)

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

func TemplateFill(tmpl string, data StringMap) string

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 DEPRECATED: replaced by SafeTemplateFill

func TextToBool

func TextToBool(value string) (result bool)

Returns true if the input value is either of "true", "yes", "1"

func TrimmedLines

func TrimmedLines(s string) string

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

func VersionToList(version string) ([]int, error)

Gets three integers for a version string Converts "1.2.3" into []int{1, 2, 3}

func VersionToName

func VersionToName(version string) string

Converts a version string into a name. Replaces dots with underscores. "1.2.3" -> "1_2_3"

func VersionToPort

func VersionToPort(version string) (int, error)

VersionToPort converts a version string into a port number e.g. "5.6.33" -> 5633 Note that if the conversion exceeds the maximum port (65,535), such as 10.10.x, the actual number will be reduced by 60,000

func Which

func Which(filename string) string

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

func WriteString(line string, filename string) error

append a string into an existing file

func WriteStrings

func WriteStrings(lines []string, filename string, termination string) error

Writes a string slice into a file The file is created

Types

type Capabilities added in v1.19.0

type Capabilities struct {
	Flavor      string      `json:"flavor"`
	Description string      `json:"description"`
	Features    FeatureList `json:"features"`
}

Capabilities holds the broad definition of a feature set for a flavor

type Capability added in v1.19.0

type Capability struct {
	Description string                 `json:"description"`
	Since       globals.NumericVersion `json:"since"`
	Until       globals.NumericVersion `json:"until"`
}

Capability defines a feature availability

type CleanupFunc

type CleanupFunc func(target string)

type CleanupRec

type CleanupRec struct {
	// contains filtered or unexported fields
}

type ConfigOptions

type ConfigOptions map[string][]KeyValue

func ParseConfigFile

func ParseConfigFile(filename string) (ConfigOptions, error)

Reads a MySQL configuration file and returns its structured contents

type FeatureList added in v1.19.0

type FeatureList map[string]Capability

FeatureList is the set of capabilities for a given flavor

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

type PortMap

type PortMap map[int]bool

type SandboxDescription

type SandboxDescription struct {
	Basedir           string `json:"basedir"`
	ClientBasedir     string `json:"client_basedir,omitempty"`
	SBType            string `json:"type"` // single multi master-slave group
	Version           string `json:"version"`
	Flavor            string `json:"flavor,omitempty"`
	Host              string `json:"host,omitempty"`
	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

type SandboxInfo struct {
	SandboxName string
	SandboxDesc SandboxDescription
	Locked      bool
}

func FindSandbox added in v1.44.0

func FindSandbox(sandboxList []SandboxInfo, wanted string) (SandboxInfo, error)

FindSandbox will find a wanted sandbox from a list of sandboxes It will get the sandbox by name, if it matches. If not, it will try to match by version, port, type, or flavor, provided that the wanted parameter is unique among the sandboxes. For example, if we ask for version 8.0.19 and only one sandbox uses such version, we return a match. If two or more sandboxes use that version, there is no match. The same applies for the other criteria.

FOR FUTURE USAGE with `dbdeployer delete` or `dbdeployer run sandboxIdentifier`

type SandboxInfoList added in v1.53.0

type SandboxInfoList []SandboxInfo

func GetFullSandboxInfo added in v1.53.0

func GetFullSandboxInfo(sandboxHome string) SandboxInfoList

func GetInstalledSandboxes

func GetInstalledSandboxes(sandboxHome string) (installedSandboxes SandboxInfoList, err error)

Gets a list of installed sandboxes from the $SANDBOX_HOME directory

func GetSandboxesByDate added in v1.53.0

func GetSandboxesByDate(sandboxHome string) (SandboxInfoList, error)

type SandboxUser

type SandboxUser struct {
	Description string `json:"description"`
	Username    string `json:"username"`
	Password    string `json:"password"`
	Privileges  string `json:"privileges"`
}

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

The stack is implemented using a double-linked list from Go standard library

func NewStack

func NewStack() (stack Stack)

NewStack returns a new stack

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) Len

func (stack *Stack) Len() int

The length of the stack is that of the underlying 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)

func (*Stack) Push

func (stack *Stack) Push(item interface{})

Push() inserts an item to the front of the stack. The item can be of any type

func (*Stack) Reset

func (stack *Stack) Reset()

Removes all items from the stack

func (*Stack) Top

func (stack *Stack) Top() interface{}

Top() returns the object stored as .Value in the top list element The object is NOT removed from the list

type StringMap

type StringMap map[string]interface{}

StringMap defines the map of variable types, for brevity

type VersionInfo added in v1.28.0

type VersionInfo struct {
	Version string
	Flavor  string
}

func GetVersionInfoFromDir added in v1.28.0

func GetVersionInfoFromDir(basedir string) []VersionInfo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL