Documentation ¶
Index ¶
- Constants
- func CallBrowser(url string) error
- func GeneratePassword() (pass string)
- func ParseDiscSpec(spec string) (*brain.Disc, error)
- func PromptValidate(p Prompter, prompt string, valid func(string) bool) (input string)
- func PromptYesNo(p Prompter, prompt string) bool
- func Promptf(p Prompter, promptFormat string, values ...interface{}) string
- func PromptfValidate(p Prompter, valid func(string) (bool, string), prompt string, ...) (input string)
- 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 DiscSpecError
- type ExitCode
- type Prompter
- type RecursiveDeleteGroupError
- type SubprocessFailedError
- type UsageDisplayedError
- type UserRequestedExit
- type WontDeleteGroupWithVMsError
Constants ¶
const ( // ExitCodeUsageDisplayed is returned when some usage info / help page was displayed. Unsure whether it should == E_SUCCESS or not ExitCodeUsageDisplayed ExitCode = 0 // ExitCodeSuccess is used to say everything went well ExitCodeSuccess = 0 // ExitCodeTrappedInterrupt is the exit code returned when an unexpected interrupt like SIGUSR1 was trapped ExitCodeTrappedInterrupt = -1 // ExitCodeClientBug is the exit code returned when bytemark-client knows it's faulty ExitCodeClientBug = 1 // ExitCodeCantReadConfig is the exit code returned when we couldn't read a config variable from the disk for some reason ExitCodeCantReadConfig = 3 // ExitCodeCantWriteConfig is the exit code returned when we couldn't write a config variable to the disk for some reason ExitCodeCantWriteConfig = 4 // ExitCodeUserExit is the exit code returned when the user's action caused the program to terminate (usually by saying no to a prompt) ExitCodeUserExit = 5 // ExitCodeWontDeletePopulated is the exit code returned when the user's requested that a group be deleted when it still had servers in ExitCodeWontDeletePopulated = 6 // ExitCodeBadInput is the exit code returned when the user entered a malformed command, name, or flag. ExitCodeBadInput = 7 // ExitCodeSubprocessFailed 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 ExitCodeSubprocessFailed = 8 // ExitCodeNoDefaultAccount is the exit code returned when the client couldn't determine a default account. In this situation, the user should manually specify the account to use with the --account flag or using `bytemark config set account` ExitCodeNoDefaultAccount = 9 // ExitCodeUnknownError is the exit code returned when we got an error we couldn't deal with. ExitCodeUnknownError = 49 // ExitCodeCantConnectAuth is the exit code returned when we were unable to establish an HTTP connection to the auth endpoint. ExitCodeCantConnectAuth = 50 // ExitCodeCantConnectAPI is the exit code returned when we were unable to establish an HTTP connection to the API endpoint. ExitCodeCantConnectAPI = 150 // ExitCodeAuthInternalError is the exit code returned when the auth server reported an internal error. ExitCodeAuthInternalError = 51 // ExitCodeAPIInternalError is the exit code returned when the API server reported an internal error. ExitCodeAPIInternalError = 152 // ExitCodeCantParseAuthResponse is the exit code returned when the auth server returned something we were unable to parse. ExitCodeCantParseAuthResponse = 52 // ExitCodeCantParseAPIResponse is the exit code returned when the API server returned something we were unable to parse. ExitCodeCantParseAPIResponse = 152 // ExitCodeInvalidCredentials is the exit code returned when the auth server says your credentials contain invalid characters. ExitCodeInvalidCredentials = 53 // ExitCodeBadCredentials is the exit code returned when the auth server says your credentials don't match a user in its database. ExitCodeBadCredentials = 54 // ExitCodeActionNotPermitted is the exit code returned when the API server says you haven't got permission to do that. ExitCodeActionNotPermitted = 155 // ExitCodeNotFound 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. ExitCodeNotFound = 156 // ExitCodeBadRequest is the exit code returned when we send a bad request to API. (E.g. names being too short or having wrong characters in) ExitCodeBadRequest = 157 // ExitCodeUnknownAuthError is the exit code returned when we get an unexpected error from the auth server. ExitCodeUnknownAuthError = 149 // ExitCodeUnknownAPIError is the exit code returned when we get an unexpected error from the Bytemark API. ExitCodeUnknownAPIError = 249 )
Variables ¶
This section is empty.
Functions ¶
func CallBrowser ¶
CallBrowser opens the user's desktop browser to the given URL. It tries really hard - first trying open on mac or xdg-open on other systems. If xdg-open couldn't be used, it attempts to use /usr/bin/x-www-browser
func GeneratePassword ¶
func GeneratePassword() (pass string)
GeneratePassword generates a random 16-character password made entirely of letters.
func ParseDiscSpec ¶
ParseDiscSpec reads the given string and attempts to interpret it as a disc spec.
func PromptValidate ¶
PromptValidate prompts for input, validates it. Repeats until the input is actually valid. Returns the valid input.
func PromptYesNo ¶
PromptYesNo provides a y/n prompt. Returns true if the user enters y, false otherwise.
func Promptf ¶
Promptf formats its arguments with fmt.Sprintf, prompts for input and then returns it.
func PromptfValidate ¶
func PromptfValidate(p Prompter, valid func(string) (bool, string), prompt string, values ...interface{}) (input string)
PromptfValidate uses prompt as a format string, values as the values for the prompt, then prompts for input. The input is then validated using the validation function, and if the input is invalid, it repeats the prompting. Returns the valid input once valid input is put in.
func ValidCreditCard ¶
ValidCreditCard is a credit-card-looking bunch of numbers. Doesn't check the check digit.
func ValidEmail ¶
ValidEmail checks that the input looks vaguely like an email address. It's very loose, relies on better validation elsewhere.
func ValidExpiry ¶
ValidExpiry checks that the input is a valid credit card expiry, written in MMYY format.
Types ¶
type DiscSpecError ¶
DiscSpecError represents an error during parse.
func (*DiscSpecError) Error ¶
func (e *DiscSpecError) Error() 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 ¶
ProcessError processes the given error, outputs a message, and returns the relevant ExitCode for the given error.
type Prompter ¶
Prompter is an object responsible for prompting the user for input
func NewPrompter ¶
func NewPrompter() Prompter
NewPrompter creates a Prompter which uses stderr and stdin for output and input respectively.
type RecursiveDeleteGroupError ¶
type RecursiveDeleteGroupError struct { Group lib.GroupName // Map of VirtualMachine names to the error that occurred when trying to delete them. // N.B. that this will not contain nil errors for VMs that were successfully deleted. Errors map[string]error }
RecursiveDeleteGroupError is returned by delete group when called with --recursive, when deleting VMs.
func (RecursiveDeleteGroupError) Error ¶
func (e RecursiveDeleteGroupError) Error() string
type SubprocessFailedError ¶
SubprocessFailedError is returned when a process run by bytemark-client (e.g. open/xdg-open to open a browser) failed
func (SubprocessFailedError) Error ¶
func (e SubprocessFailedError) Error() string
type UsageDisplayedError ¶
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{}
UserRequestedExit is returned when the user said 'No' to a 'yes/no' prompt.
func (UserRequestedExit) Error ¶
func (e UserRequestedExit) Error() string
type WontDeleteGroupWithVMsError ¶
WontDeleteGroupWithVMsError is returned when 'delete group' was called on a group with stuff in, without --recursive being specified
func (WontDeleteGroupWithVMsError) Error ¶
func (e WontDeleteGroupWithVMsError) Error() string