Documentation
¶
Index ¶
- Constants
- Variables
- func AddCloudType(p Plugin)
- func AskUser(prompt string, defaultValue string) (string, error)
- func AskUserInteractiveInt(prompt string, defaultValue int, skipIfDefault bool, val *int) error
- func AskUserInteractiveString(prompt string, defaultValue string, skipIfDefault bool, val *string) error
- func AskUserYesOrNo(prompt string) bool
- func BbCode(data string)
- func CopyFile(src string, dst string) error
- func CreateInstance(context AppContext, baseD *BaseDeployment, dep Deployment, volumeSize int, ...) error
- func DeleteDeployment(context AppContext, name string)
- func DeploymentDir(confDir string, deploymentName string) string
- func FindProgramVersion(context AppContext, program string, version string, url string) error
- func FullStatus(context AppContext, baseD *BaseDeployment, dep Deployment, internal bool, ...) error
- func GatherLogs(context AppContext, baseD *BaseDeployment, dep Deployment, outfile string) error
- func GenerateKey(dir string, keyname string) (string, []byte, error)
- func GetLocalOnlyHTTPMask() string
- func GetMaxIopsRatio() int
- func IsHealthy(context AppContext, baseD *BaseDeployment, d Deployment, internal bool) bool
- func LoadJSON(obj interface{}, path string) error
- func PathExists(filepath string) bool
- func RunCommand(cliContext AppContext, cmd exec.Cmd, lineScanner LineScanner, spinner *Spinner) (*[]ScanResult, error)
- func RunSSH(context AppContext, baseD *BaseDeployment, d Deployment) error
- func UpdateStardog(context AppContext, baseD *BaseDeployment, dep Deployment, ...) error
- func ValueStringToInt(i string) (int, error)
- func WaitForHealth(context AppContext, baseD *BaseDeployment, d Deployment, waitTimeout int, ...) error
- func WaitForNClusterNodes(context AppContext, size int, sdURL string, pw string, waitTimeout int) error
- func WriteFile(path string, contents string) error
- func WriteJSON(obj interface{}, path string) error
- type AppContext
- type BaseDeployment
- type CommandOpts
- type ConsoleEffect
- type Deployment
- type LineScanner
- type Plugin
- type ScanResult
- type SdVaLogger
- type Spinner
- type StardogDescription
- type TestContext
- func (c *TestContext) ConsoleLog(level int, format string, v ...interface{})
- func (c *TestContext) FailString(a ...interface{}) string
- func (c *TestContext) GetConfigDir() string
- func (c *TestContext) GetInteractive() bool
- func (c *TestContext) GetVersion() string
- func (c *TestContext) HighlightString(a ...interface{}) string
- func (c *TestContext) Logf(level int, format string, v ...interface{})
- func (c *TestContext) SuccessString(a ...interface{}) string
Constants ¶
const ( // ERROR will only log error level messages ERROR = 1 // WARN will log ERROR and WARN level messages WARN = 2 // INFO is the default level and will log information, warnings and errors INFO = 3 // DEBUG is a very verbose log level and should be used only for finding problems DEBUG = 4 )
Variables ¶
var ( // LogLevelNames is an array of strings that define all the valid log levels LogLevelNames []string )
Functions ¶
func AddCloudType ¶
func AddCloudType(p Plugin)
AddCloudType will associate a new plugin type with this graviton instances
func AskUser ¶
AskUser prompts a console user to enter input. prompt is the string that will be displayed to them and defaultValue will be the result if the user just hits enter.
func AskUserInteractiveInt ¶
AskUserInteractiveInt prompts the user to enter an integer.
func AskUserInteractiveString ¶
func AskUserInteractiveString(prompt string, defaultValue string, skipIfDefault bool, val *string) error
AskUserInteractiveString prompts the user to enter a string.
func AskUserYesOrNo ¶
AskUserYesOrNo is just a convenience wrapper around AskUser that looks for a yes or no answer. A case insensitive yes will return true and all other values will return false.
func BbCode ¶
func BbCode(data string)
BbCode converts the bb ascii art information into console colorsMap
func CreateInstance ¶
func CreateInstance(context AppContext, baseD *BaseDeployment, dep Deployment, volumeSize int, zkSize int, waitMaxTimeSec int, timeoutSec int, mask string, bastionVolSnapshotId string, noWait bool) error
CreateInstance wraps up the deployment.CreateInstance method and blocks until the deployment is considered healthy. It will then change the password by SSHing into the bastion node. Once that is complete it will open up the the firewall.
func DeleteDeployment ¶
func DeleteDeployment(context AppContext, name string)
DeleteDeployment will remove all information stored on the local file system that is associated with a deployment.
func DeploymentDir ¶
DeploymentDir abstracts the location of deployment information files into a function
func FindProgramVersion ¶
func FindProgramVersion(context AppContext, program string, version string, url string) error
FindProgramVersion is used to check for golang style single executable programs of a specific version. We are currently using it for just packer and terraform and there are no guarantees that it will work for other programs with different path expectations
func FullStatus ¶
func FullStatus(context AppContext, baseD *BaseDeployment, dep Deployment, internal bool, outfile string) error
FullStatus inspects the state of a deployment and prints it out to the console.
func GatherLogs ¶
func GatherLogs(context AppContext, baseD *BaseDeployment, dep Deployment, outfile string) error
GatherLogs sshes into the bastion node and collects logs from the stardog nodes
func GetLocalOnlyHTTPMask ¶
func GetLocalOnlyHTTPMask() string
GetLocalOnlyHTTPMask uses a network service to guess the external IP of the local host.
func GetMaxIopsRatio ¶
func GetMaxIopsRatio() int
func IsHealthy ¶
func IsHealthy(context AppContext, baseD *BaseDeployment, d Deployment, internal bool) bool
IsHealthy checks the deployment to see if the Stardog service is healthy. if internal is set to true it will test by sshing into the bastion node first.
func PathExists ¶
PathExists is a convenience function to determine if a path path exists.
func RunCommand ¶
func RunCommand(cliContext AppContext, cmd exec.Cmd, lineScanner LineScanner, spinner *Spinner) (*[]ScanResult, error)
RunCommand will fork and execute a command in the shell. The lineScanner object will be used to collect output and return it to the caller.
func RunSSH ¶
func RunSSH(context AppContext, baseD *BaseDeployment, d Deployment) error
RunSSH will start an ssh session on the bastion node
func UpdateStardog ¶
func UpdateStardog(context AppContext, baseD *BaseDeployment, dep Deployment, sdReleaseFile string) error
Upload a new Stardog release zip to the nodes and restart Stardog
func ValueStringToInt ¶
ValueStringToInt returns a integer from a string with a unit of g, m, or k.
func WaitForHealth ¶
func WaitForHealth(context AppContext, baseD *BaseDeployment, d Deployment, waitTimeout int, internal bool) error
WaitForHealth will block until the deployment is considered healthy or the timeout expires. If internal is true it will ssh into the bastion node before checking the health URL.
func WaitForNClusterNodes ¶
Types ¶
type AppContext ¶
type AppContext interface { ConsoleLog(level int, format string, v ...interface{}) Logf(level int, format string, v ...interface{}) GetConfigDir() string GetVersion() string GetInteractive() bool HighlightString(a ...interface{}) string SuccessString(a ...interface{}) string FailString(a ...interface{}) string }
AppContext provides and abstraction to logging, console interaction and basic configuration information
type BaseDeployment ¶
type BaseDeployment struct { Type string `json:"type,omitempty"` Name string `json:"name,omitempty"` Directory string `json:"directory,omitempty"` Version string `json:"version,omitempty"` PrivateKey string `json:"private_key,omitempty"` CustomPropsFile string `json:"custom_props,omitempty"` CustomLog4J string `json:"custom_log4j,omitempty"` IdleTimeout int `json:"idle_timeout,omitempty"` Environment []string `json:"environment,omitempty"` DisableSecurity bool `json:"disable_security,omitempty"` CloudOpts interface{} `json:"cloud_opts,omitempty"` CustomScript string `json:"custom_script,omitempty"` CustomZkScript string `json:"custom_zk_script,omitempty"` }
BaseDeployment hold information about the deployments and is serialized to JSON. CloudOpts is defined by the specific plugin in use.
type CommandOpts ¶
type CommandOpts struct { Cli *kingpin.Application LaunchCmd *kingpin.CmdClause DestroyCmd *kingpin.CmdClause StatusCmd *kingpin.CmdClause LeaksCmd *kingpin.CmdClause ClientCmd *kingpin.CmdClause SSHCmd *kingpin.CmdClause PasswdCmd *kingpin.CmdClause AboutCmd *kingpin.CmdClause BuildCmd *kingpin.CmdClause NewDeploymentCmd *kingpin.CmdClause DestroyDeploymentCmd *kingpin.CmdClause ListDeploymentCmd *kingpin.CmdClause NewVolumesCmd *kingpin.CmdClause DestroyVolumesCmd *kingpin.CmdClause StatusVolumesCmd *kingpin.CmdClause LaunchInstanceCmd *kingpin.CmdClause DestroyInstanceCmd *kingpin.CmdClause StatusInstanceCmd *kingpin.CmdClause }
CommandOpts holds all of the CLI parsing information for the system. It is passed to plugins so that each driver can add their own specific flags.
type ConsoleEffect ¶
type ConsoleEffect func(a ...interface{}) string
ConsoleEffect is a function for writing lines to the console in a visually pleasing way. For example red text for error messages.
type Deployment ¶
type Deployment interface { CreateVolumeSet(licensePath string, sizeOfEachVolume int, clusterSize int) error DeleteVolumeSet() error StatusVolumeSet() error VolumeExists() bool ClusterSize() (int, error) CreateInstance(volumeSize int, zookeeperSize int, idleTimeout int, bastionVolSnapshotId string) error OpenInstance(volumeSize int, zookeeperSize int, mask string, idleTimeout int) error DeleteInstance() error StatusInstance() error InstanceExists() bool FullStatus() (*StardogDescription, error) DestroyDeployment() error }
Deployment is an interface to a plugin that is managing the actual Stardog services.
func LoadDeployment ¶
func LoadDeployment(context AppContext, baseD *BaseDeployment, new bool) (Deployment, error)
LoadDeployment inflates a Deployment object from the information stored in the configuration directory.
type LineScanner ¶
type LineScanner func(cliContext AppContext, line string) *ScanResult
LineScanner is a function that will search a line for given values and return results in a ScanResult if it finds something. It may return nil
type Plugin ¶
type Plugin interface { Register(cmdOpts *CommandOpts) error DeploymentLoader(context AppContext, baseD *BaseDeployment, new bool) (Deployment, error) LoadDefaults(defaultCliOpts interface{}) error BuildImage(context AppContext, sdReleaseFilePath string, version string) error GetName() string FindLeaks(context AppContext, deploymentName string, destroy bool, force bool) error HaveImage(context AppContext) bool }
Plugin defines the interface for adding drivers to the system
type ScanResult ¶
ScanResult is an object returned from a LineScanner. This allows us to use the uility function RunScanner and return different values from the output based on the specific command.
type SdVaLogger ¶
SdVaLogger is the interface to the Stardog Logger
func NewSdVaLogger ¶
func NewSdVaLogger(realLogger *log.Logger, logLevel string) (SdVaLogger, error)
NewSdVaLogger creates a new Stardog logging object from a system logger
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner is an object used to show progress on the console.
func NewSpinner ¶
func NewSpinner(context AppContext, level int, message string) *Spinner
NewSpinner creates a new spinner object.
type StardogDescription ¶
type StardogDescription struct { StardogURL string `json:"stardog_url,omitempty"` StardogInternalURL string `json:"stardog_internal_url,omitempty"` StardogNodes []string `json:"stardog_nodes,omitempty"` SSHHost string `json:"ssh_host,omitempty"` Healthy bool `json:"healthy,omitempty"` TimeStamp time.Time `json:"timestamp,omitempty"` VolumeDescription interface{} `json:"volume,omitempty"` InstanceDescription interface{} `json:"instance,omitempty"` }
StardogDescription represents the state of a Stardog deployment. It is effectively the output from a status command.
type TestContext ¶
TestContext is used for mocking out a context in many tests
func (*TestContext) ConsoleLog ¶
func (c *TestContext) ConsoleLog(level int, format string, v ...interface{})
func (*TestContext) FailString ¶
func (c *TestContext) FailString(a ...interface{}) string
func (*TestContext) GetConfigDir ¶
func (c *TestContext) GetConfigDir() string
func (*TestContext) GetInteractive ¶
func (c *TestContext) GetInteractive() bool
func (*TestContext) GetVersion ¶
func (c *TestContext) GetVersion() string
func (*TestContext) HighlightString ¶
func (c *TestContext) HighlightString(a ...interface{}) string
func (*TestContext) Logf ¶
func (c *TestContext) Logf(level int, format string, v ...interface{})
func (*TestContext) SuccessString ¶
func (c *TestContext) SuccessString(a ...interface{}) string