Documentation ¶
Index ¶
- Constants
- func CallBrowser(url string) error
- func EnsureAccountName(account string, config ConfigManager) string
- func EnsureGroupName(group lib.GroupName, config ConfigManager) lib.GroupName
- func EnsureVMName(vm lib.VirtualMachineName, config ConfigManager) lib.VirtualMachineName
- func FormatAccount(a *client.Account) string
- func FormatImageInstall(ii *client.ImageInstall) string
- func FormatVirtualMachine(vm *client.VirtualMachine, options ...int) string
- func FormatVirtualMachineSpec(group *client.GroupName, spec *client.VirtualMachineSpec) string
- func FormatVirtualMachines(vms []*client.VirtualMachine, options ...int) []string
- func GeneratePassword() (pass string)
- func IsConfigVar(name string) bool
- func Luhn(number string) (int, error)
- func MakeSignupForm(creditCardForm bool) (fields map[int]form.Field, f *form.Form, signup *bool)
- func ParseDiscSpec(spec string) (*lib.Disc, error)
- func ParseSize(spec string) (int, error)
- func Prompt(prompt string) string
- func PromptValidate(prompt string, valid func(string) bool) (input string)
- func PromptYesNo(prompt string) bool
- func Promptf(promptFormat string, values ...interface{}) string
- func PromptfValidate(valid func(string) (bool, string), prompt string, values ...interface{}) (input string)
- func ShiftArgument(args *[]string, kindOfThing string) (string, bool)
- func ValidCreditCard(input string) (bool, string)
- func ValidEmail(input string) (bool, string)
- func ValidExpiry(input string) (bool, string)
- func ValidName(input string) (bool, string)
- type CannotLoadDefinitionsError
- type Config
- func (config *Config) EndpointName() string
- func (config *Config) Force() bool
- func (config *Config) Get(name string) (string, error)
- func (config *Config) GetAll() (vars []ConfigVar, err error)
- func (config *Config) GetBool(name string) (bool, error)
- func (config *Config) GetDebugLevel() int
- func (config *Config) GetDefault(name string) ConfigVar
- func (config *Config) GetGroup() (group *lib.GroupName)
- func (config *Config) GetIgnoreErr(name string) string
- func (config *Config) GetPath(name string) string
- func (config *Config) GetV(name string) (ConfigVar, error)
- func (config *Config) GetVirtualMachine() (vm *lib.VirtualMachineName)
- func (config *Config) ImportFlags(flags *flag.FlagSet) []string
- func (config *Config) PanelURL() string
- func (config *Config) Set(name, value, source string)
- func (config *Config) SetPersistent(name, value, source string) error
- func (config *Config) Silent() bool
- func (config *Config) Unset(name string) error
- type ConfigDirInvalidError
- type ConfigManager
- type ConfigReadError
- type ConfigVar
- type ConfigWriteError
- type DiscSpecError
- type DiscSpecFlag
- type ExitCode
- type FileFlag
- type IPFlag
- type InvalidConfigVarError
- type NotEnoughArgumentsError
- type SizeSpecError
- type SizeSpecFlag
- type SubprocessFailedError
- type UsageDisplayedError
- type UserRequestedExit
- type VMFormatOptions
- type VMListFormatMode
- type WontDeleteNonEmptyGroupError
Constants ¶
const ( // E_USAGE_DISPLAYED is returned when some usage info / help page was displayed. Unsure whether it should == E_SUCCESS or not E_USAGE_DISPLAYED ExitCode = 0 // E_SUCCESS is used to say everything went well E_SUCCESS = 0 // E_TRAPPED_INTERRUPT is the exit code returned when an unexpected interrupt like SIGUSR1 was trapped E_TRAPPED_INTERRUPT = -1 // E_CANT_READ_CONFIG is the exit code returned when we couldn't read a config variable from the disk for some reason E_CANT_READ_CONFIG = 3 // E_CANT_WRITE_CONFIG is the exit code returned when we couldn't write a config variable to the disk for some reason E_CANT_WRITE_CONFIG = 4 // E_USER_EXIT is the exit code returned when the user's action caused the program to terminate (usually by saying no to a prompt) E_USER_EXIT = 5 // E_WONT_DELETE_NONEMPTY is the exit code returned when the user's requested that a group be deleted when it still had servers in E_WONT_DELETE_NONEMPTY = 6 // E_PEBKAC is the exit code returned when the user entered a malformed command, name, or flag. E_PEBKAC = 7 // E_SUBPROCESS_FAILED is the exit code returned when the client attempted to run a subprocess (e.g. ssh, a browser or a vpn client) but couldn't E_SUBPROCESS_FAILED = 8 // E_UNKNOWN_ERROR is the exit code returned when we got an error we couldn't deal with. E_UNKNOWN_ERROR = 49 // E_CANT_CONNECT_AUTH is the exit code returned when we were unable to establish an HTTP connection to the auth endpoint. E_CANT_CONNECT_AUTH = 50 // E_CANT_CONNECT_API is the exit code returned when we were unable to establish an HTTP connection to the API endpoint. E_CANT_CONNECT_API = 150 // E_AUTH_REPORTED_ERROR is the exit code returned when the auth server reported an internal error. E_AUTH_REPORTED_ERROR = 51 // E_API_REPORTED_ERROR is the exit code returned when the API server reported an internal error. E_API_REPORTED_ERROR = 152 // E_CANT_PARSE_AUTH is the exit code returned when the auth server returned something we were unable to parse. E_CANT_PARSE_AUTH = 52 // E_CANT_PARSE_API is the exit code returned when the API server returned something we were unable to parse. E_CANT_PARSE_API = 152 // E_CREDENTIALS_INVALID is the exit code returned when the auth server says your credentials contain invalid characters. E_CREDENTIALS_INVALID = 53 // E_CREDENTIALS_WRONG is the exit code returned when the auth server says your credentials don't match a user in its database. E_CREDENTIALS_WRONG = 54 // E_NOT_AUTHORIZED_API is the exit code returned when the API server says you haven't got permission to do that. E_NOT_AUTHORIZED_API = 155 // E_NOT_FOUND_API is the exit code returned when the API server says you do not have permission to see the object you are trying to view, or that it does not exist. E_NOT_FOUND_API = 156 // E_BAD_REQUEST_API is the exit code returned when we send a bad request to API. (E.g. names being too short or having wrong characters in) E_BAD_REQUEST_API = 157 // E_UNKNOWN_AUTH is the exit code returned when we get an unexpected error from the auth server. E_UNKNOWN_AUTH_ERROR = 149 // E_UNKNOWN_API_ERROR is the exit code returned when we get an unexpected error from the Bytemark API. E_UNKNOWN_API_ERROR = 249 )
const ( FIELD_OWNER_NAME = iota FIELD_OWNER_PASS FIELD_OWNER_PASS_CONFIRM FIELD_OWNER_EMAIL FIELD_OWNER_FIRSTNAME FIELD_OWNER_LASTNAME FIELD_OWNER_CC FIELD_OWNER_POSTCODE FIELD_OWNER_CITY FIELD_OWNER_ADDRESS FIELD_OWNER_PHONE FIELD_OWNER_MOBILE FIELD_OWNER_ORG_NAME FIELD_OWNER_ORG_DIVISION FIELD_OWNER_ORG_VAT FIELD_CC_NUMBER FIELD_CC_NAME FIELD_CC_EXPIRY FIELD_CC_CVV )
Variables ¶
This section is empty.
Functions ¶
func CallBrowser ¶
func EnsureAccountName ¶
func EnsureAccountName(account string, config ConfigManager) string
func EnsureGroupName ¶
func EnsureGroupName(group lib.GroupName, config ConfigManager) lib.GroupName
func EnsureVMName ¶
func EnsureVMName(vm lib.VirtualMachineName, config ConfigManager) lib.VirtualMachineName
func FormatAccount ¶
func FormatImageInstall ¶ added in v0.7.0
func FormatImageInstall(ii *client.ImageInstall) string
func FormatVirtualMachine ¶
func FormatVirtualMachine(vm *client.VirtualMachine, options ...int) string
FormatVirtualMachine pretty-prints a VM. The optional second argument is a bitmask of VMFormatOptions, and the optional third is the width you'd like to display..oh.
func FormatVirtualMachineSpec ¶
func FormatVirtualMachineSpec(group *client.GroupName, spec *client.VirtualMachineSpec) string
func FormatVirtualMachines ¶
func FormatVirtualMachines(vms []*client.VirtualMachine, options ...int) []string
FormatVirtualMachines loops through a bunch of VMs, formatting each one as it goes, and returns each formatted VM as a string. The options are the same as FormatVirtualMachine
func GeneratePassword ¶
func GeneratePassword() (pass string)
func IsConfigVar ¶ added in v0.7.0
func MakeSignupForm ¶ added in v0.7.0
func ParseSize ¶
ParseSize will take a size as a string like <num>[G|M][[i]B] and output a size. It's actually more permissive than that but w/e
func Prompt ¶
Prompt provides a string prompt, returns the entered string with no whitespace (hopefully)
func PromptValidate ¶ added in v0.7.0
func PromptYesNo ¶
PromptYesNo provides a y/n prompt. Returns true if the user enters y, false otherwise.
func PromptfValidate ¶ added in v0.7.0
func ValidCreditCard ¶ added in v0.7.0
func ValidEmail ¶ added in v0.7.0
func ValidExpiry ¶ added in v0.7.0
Types ¶
type CannotLoadDefinitionsError ¶
type CannotLoadDefinitionsError struct {
Err error
}
func (*CannotLoadDefinitionsError) Error ¶
func (e *CannotLoadDefinitionsError) Error() string
type Config ¶
type Config struct { Dir string Memo map[string]ConfigVar Definitions map[string]string // contains filtered or unexported fields }
A Config determines the configuration of the Bytemark client. It's responsible for handling things like the credentials to use and what endpoints to talk to.
Each configuration item is read from the following places, falling back to successive places:
Per-command command-line flags, global command-line flags, environment variables, configuration directory, hard-coded defaults ¶
The location of the configuration directory is read from global command-line flags, or is otherwise ~/.bytemark
func NewConfig ¶
NewConfig sets up a new config struct. Pass in an empty string to default to ~/.bytemark
func (*Config) EndpointName ¶
func (*Config) Get ¶
Get returns the value of a ConfigVar. Used to simplify code when the source is unnecessary.
func (*Config) GetDebugLevel ¶
GetDebugLevel returns the current debug-level as an integer. This is used throughout the bytemark.co.uk/client library to determine verbosity of output.
func (*Config) GetDefault ¶
GetDefault returns the default ConfigVar for the given key.
func (*Config) GetIgnoreErr ¶
GetIgnoreErr returns the value of a ConfigVar or an empty string , if it was unable to read it for whatever reason.
func (*Config) GetVirtualMachine ¶
func (config *Config) GetVirtualMachine() (vm *lib.VirtualMachineName)
func (*Config) Set ¶
Set stores the given key-value pair in config's Memo. This storage does not persist once the program terminates.
func (*Config) SetPersistent ¶
SetPersistent writes a file to the config directory for the given key-value pair.
type ConfigDirInvalidError ¶
type ConfigDirInvalidError struct {
Path string
}
func (*ConfigDirInvalidError) Error ¶
func (e *ConfigDirInvalidError) Error() string
type ConfigManager ¶
type ConfigManager interface { Get(string) (string, error) GetIgnoreErr(string) string GetBool(string) (bool, error) GetV(string) (ConfigVar, error) GetVirtualMachine() *lib.VirtualMachineName GetGroup() *lib.GroupName GetAll() ([]ConfigVar, error) Set(string, string, string) SetPersistent(string, string, string) error Unset(string) error GetDebugLevel() int Force() bool EndpointName() string PanelURL() string ImportFlags(*flag.FlagSet) []string }
ConfigManager is an interface defining a key->value store that also knows where the values were set from.
type ConfigReadError ¶
func (*ConfigReadError) Error ¶
func (e *ConfigReadError) Error() string
type ConfigVar ¶
ConfigVar is a struct which contains a name-value-source triplet Source is up to two words separated by a space. The first word is the source type: FLAG, ENV, DIR, CODE. The second is the name of the flag/file/environment var used.
func (*ConfigVar) SourceBaseName ¶
func (*ConfigVar) SourceType ¶
type ConfigWriteError ¶
func (*ConfigWriteError) Error ¶
func (e *ConfigWriteError) Error() string
type DiscSpecError ¶
DiscSpecError represents an error during parse.
func (*DiscSpecError) Error ¶
func (e *DiscSpecError) Error() string
type DiscSpecFlag ¶
func (*DiscSpecFlag) Set ¶
func (discsFlag *DiscSpecFlag) Set(value string) error
func (*DiscSpecFlag) String ¶
func (discFlag *DiscSpecFlag) String() string
type ExitCode ¶
type ExitCode int
ExitCode is a named type for the E_* constants which are used as exit codes.
func HelpForExitCodes ¶
func HelpForExitCodes() ExitCode
HelpForExitCodes prints readable information on what the various exit codes do.
func ProcessError ¶
type FileFlag ¶
FileFlag implements the flag.Value (aka codegangsta/cli.Generic) interface to provide a flag value type that reads its effective value from the file named as its input.
type InvalidConfigVarError ¶
type InvalidConfigVarError struct {
ConfigVar string
}
func (InvalidConfigVarError) Error ¶
func (e InvalidConfigVarError) Error() string
type NotEnoughArgumentsError ¶
type NotEnoughArgumentsError struct { }
func (NotEnoughArgumentsError) Error ¶
func (e NotEnoughArgumentsError) Error() string
type SizeSpecError ¶
func (*SizeSpecError) Error ¶
func (e *SizeSpecError) Error() string
type SizeSpecFlag ¶
type SizeSpecFlag int
func (*SizeSpecFlag) Set ¶
func (ssf *SizeSpecFlag) Set(spec string) error
func (*SizeSpecFlag) String ¶
func (ssf *SizeSpecFlag) String() string
type SubprocessFailedError ¶
func (*SubprocessFailedError) Error ¶
func (e *SubprocessFailedError) Error() string
type UsageDisplayedError ¶
type UsageDisplayedError struct {
TheProblem string
}
UsageDisplayedError is returned by commands when the user entered wrong info and the help was output
func (UsageDisplayedError) Error ¶
func (e UsageDisplayedError) Error() string
type UserRequestedExit ¶
type UserRequestedExit struct{}
func (*UserRequestedExit) Error ¶
func (e *UserRequestedExit) Error() string
type VMFormatOptions ¶
type VMFormatOptions uint8
VMFormatOptions controls formatting of VMs in FormatVirtualMachine Add or or them together to get what you want
type VMListFormatMode ¶
type VMListFormatMode uint8
VMListFormatMode is the way that FormatVirtualMachineList will format the VMList
type WontDeleteNonEmptyGroupError ¶
func (WontDeleteNonEmptyGroupError) Error ¶
func (e WontDeleteNonEmptyGroupError) Error() string