Documentation ¶
Index ¶
- Constants
- func Confirm(opts ConfirmOpts) (bool, error)
- func DownloadFile(opts DownloadFileOpts) (err error)
- func IsProjectType(pathToDirectory string, projectType ProjectType) (bool, error)
- func LoadConfiguration(config interface{}) error
- func NormalizeLocalPath(userInputPath string) (string, error)
- func SendHTTPRequest(opts SendHTTPRequestOpts) (*http.Response, error)
- func ValidateApplications(opts ValidateApplicationsOpts) error
- func ValidateConnection(opts ValidateConnectionOpts) (bool, error)
- func ValidateEnvironment(opts ValidateEnvironmentOpts) error
- type BasicAuth
- type Command
- type CommandFlagset
- type ConfirmOpts
- type ConnectionProtocol
- type DownloadFileOpts
- type EnvType
- type EnvironmentKey
- type EnvironmentKeys
- type GetSshKeyFingerprintOpts
- type InputHook
- type InputHooks
- type LoadConfigurationError
- type LoadConfigurationErrors
- type NewCommandOpts
- type NewSSHKeypairOpts
- type ProjectType
- type SSHKeypair
- type SendHTTPRequestOpts
- type SshKeyFingerprint
- type ValidateApplicationsErrors
- type ValidateApplicationsOpts
- type ValidateConnectionOpts
- type ValidateEnvironmentError
- type ValidateEnvironmentErrors
- type ValidateEnvironmentOpts
Constants ¶
const ( ZeroValueBool = false ZeroValueString = "" ZeroValueFloat32 = float32(0) ZeroValueFloat64 = float64(0) ZeroValueInt = int(0) ZeroValueInt64 = int64(0) ZeroValueUint = uint(0) ZeroValueUint64 = uint64(0) )
const ( DefaultStringSliceDelimiter = "," ErrorLoadConfigurationPrereqs = 1 << iota ErrorLoadConfigurationNotFound = 1 << iota ErrorLoadConfigurationInvalidType = 1 << iota ErrorLoadConfigurationInvalidValue = 1 << iota )
const (
DefaultConfirmInputHint = " (only '%s' will be accepted) "
)
const (
DefaultSSHKeyLength = 8192
)
const (
DefaultTimeout = 3 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
func Confirm ¶
func Confirm(opts ConfirmOpts) (bool, error)
Confirm performs a user-terminal-input based confirmation. This can be used in situations where it could be useful for a user to manually verify a string such as a command to be run
func DownloadFile ¶
func DownloadFile(opts DownloadFileOpts) (err error)
DownloadFile downloads a file as directed by the configuration set in the options object `opts`
func IsProjectType ¶ added in v0.2.4
func IsProjectType(pathToDirectory string, projectType ProjectType) (bool, error)
func LoadConfiguration ¶ added in v0.1.0
func LoadConfiguration(config interface{}) error
func NormalizeLocalPath ¶
func SendHTTPRequest ¶ added in v0.2.3
func SendHTTPRequest(opts SendHTTPRequestOpts) (*http.Response, error)
SendHTTPRequest performs a HTTP request as configured by the provided options object instance `opts`.
func ValidateApplications ¶
func ValidateApplications(opts ValidateApplicationsOpts) error
func ValidateConnection ¶
func ValidateConnection(opts ValidateConnectionOpts) (bool, error)
func ValidateEnvironment ¶
func ValidateEnvironment(opts ValidateEnvironmentOpts) error
Types ¶
type BasicAuth ¶ added in v0.2.3
type BasicAuth struct { // Username represents the username section of // the credential Username string // Password represents the password section of // the credential Password string }
BasicAuth provides credentials for basic access authentication
Reference link: https://en.wikipedia.org/wiki/Basic_access_authentication
type Command ¶
type Command interface { // Bytes returns the full terminal invocation represented // by this instance of a Command as a slice of bytes Bytes() []byte // GetEnvironment returns a key-value dictionary of // environment variables to be injected into the process // created via the invocation this Command represents GetEnvironment() map[string]string // GetStderr returns the output to the stderr stream // (only available after the Command has completed its // execution) GetStderr() []byte // GetStdout returns the output to the stdout stream // (only available after the Command has completed its // execution) GetStdout() []byte // Run triggers the invocation represented by this // Command instance Run() error // String returns the full terminal invocation represented // by this instance of a Command as a string String() string }
Command interface defines a command object's methods
func NewCommand ¶
func NewCommand(opts NewCommandOpts) (Command, error)
NewCommand initialises a new Command interface and returns it
type CommandFlagset ¶
type CommandFlagset struct { // HideStdout indicates whether STDOUT should be printed to the terminal HideStdout bool // HideStderr indicates whether STDERR should be printed to the terminal HideStderr bool // UseGlobalEnvironment indicates whether the child process should // inherit the parent's environment UseGlobalEnvironment bool // UseTTY enables use of STDIN UseTTY bool }
CommandFlagSet defines a set of boolean configuration flags for the Command class
type ConfirmOpts ¶
type ConfirmOpts struct { // Question can optionally be specified for the .Confirm method to // print a string before requesting for confirmation. A space will // be added at the end of the provided .Question before the // string defined in .InputHint is added Question string // Input defines the input stream to read the input from // // Defaults to os.Stdin if not specified Input io.Reader // InputHint is a format string containing a single %s denoting // a string that needs to be matched for the confirmation to succeed. // Example. " (enter '%s' to continue)", the .Confirm method will // populate the %s with the correct matcher value based on // .MatchExact or .MatchRegexp // // Defaults to DefaultConfirmInputHint if not specified InputHint string // MatchExact defines an exact string match for the confirmation // to succeed. // // When this is defined, MatchRegexp CANNOT be defined MatchExact string // MatchRegexp defines a regular expression match for the // confirmation to succeed. // // When this is defined, MatchExact CANNOT be defined MatchRegexp *regexp.Regexp // Output defines the output stream to write output to // // Defaults to os.Stdin if not specified Output io.Writer }
func (*ConfirmOpts) SetDefaults ¶
func (o *ConfirmOpts) SetDefaults()
SetDefaults checks for unspecified properties which have defaults and adds them
func (ConfirmOpts) Validate ¶
func (o ConfirmOpts) Validate() error
Validate runs validation checks against the provided options
type ConnectionProtocol ¶
type ConnectionProtocol string
const ( ConnectionTCP ConnectionProtocol = "tcp" ConnectionUDP ConnectionProtocol = "udp" DefaultConnectionProtocol = ConnectionTCP )
type DownloadFileOpts ¶
type DownloadFileOpts struct { BasicAuth *BasicAuth Client *http.Client Headers map[string][]string DestinationPath string Overwrite bool URL *url.URL }
DownloadFileOpts presents configuration for the DownloadFile method
func (*DownloadFileOpts) SetDefaults ¶
func (o *DownloadFileOpts) SetDefaults()
SetDefaults sets defaults for this object instance
func (DownloadFileOpts) Validate ¶
func (o DownloadFileOpts) Validate() error
Validate verifies that this object instance is usable by the DownloadFile method
type EnvironmentKey ¶
type EnvironmentKeys ¶
type EnvironmentKeys []EnvironmentKey
type GetSshKeyFingerprintOpts ¶
type GetSshKeyFingerprintOpts struct { // IsPrivateKey if set to true indicates that we are // targetting a private key. If both this and .IsPublicKey // are not set, .IsPublicKey will be set to true IsPrivateKey bool // IsPublicKey if set to true indicates that we are // targetting a public key. If both this and .IsPrivateKey // are not set, .IsPublicKey will be set to true IsPublicKey bool // Passphrase defines a passphrase for the private key if // applicable Passphrase string // Path defines the file directory path to the key file // of interest Path string }
GetSshKeyFingerprintOpts provides the configuration values for identifying the key whose fingerprint we want
func (*GetSshKeyFingerprintOpts) SetDefaults ¶
func (o *GetSshKeyFingerprintOpts) SetDefaults()
SetDefaults sets defaults for this object instance
func (GetSshKeyFingerprintOpts) Validate ¶
func (o GetSshKeyFingerprintOpts) Validate() error
Validate checks if this object instance has sufficient parameters to be used by GetSshKeyFingerprint
type InputHook ¶
type InputHook struct { // On defines a byte matcher that when matched, should trigger a // write to the input stream using the byte sequence defined in // .Send On []byte // Send defines a sequence of bytes to send to the input when .On // is detected Send []byte }
InputHook defines a structure for responding to a byte sequence of `.On` using the byte sequence .Send. Receiver and signaller is left to the controller to implement
type InputHooks ¶
type InputHooks []InputHook
InputHooks is a convenience reference for a slice of InputHook instances
type LoadConfigurationError ¶ added in v0.1.0
func (LoadConfigurationError) Error ¶ added in v0.1.0
func (e LoadConfigurationError) Error() string
type LoadConfigurationErrors ¶ added in v0.2.0
type LoadConfigurationErrors []LoadConfigurationError
func (LoadConfigurationErrors) Error ¶ added in v0.2.0
func (e LoadConfigurationErrors) Error() string
func (LoadConfigurationErrors) GetCode ¶ added in v0.2.0
func (e LoadConfigurationErrors) GetCode() int
func (LoadConfigurationErrors) GetMessage ¶ added in v0.2.0
func (e LoadConfigurationErrors) GetMessage() string
type NewCommandOpts ¶
type NewCommandOpts struct { // Arguments lists the parameters to pass to the `.Command` Arguments []string // Command is an invocation that is in the $PATH OR a path to the // binary to execute (relative paths will be resolved to absolute) Command string // Environment is a mapping of key=value that will be injected into // the child process's environment. Use the `.Flag.UseGlobalEnvironment` // configuration flag to inject the parent environment into the child's Environment map[string]string // WorkingDir indicates the working directory of the child process. // If not an absolute path, this will be resolved to its absolute // one before the process begins WorkingDir string // StdoutHooks allows you to send a []byte data structure to STDIN // when receiving a predefined string from STDOUT. The `.Flag.UseTTY` // has to be enabled for this to work // // NOTE: If you have defined any `StdanyHooks`, those take execution // precedence StdoutHooks InputHooks // StderrHooks allows you to send a []byte data structure to STDIN // when receiving a predefined string from STDERR. The `.Flag.UseTTY` // has to be enabled for this to work // // NOTE: If you have defined any `StdanyHooks`, those take execution // precedence StderrHooks InputHooks // StdanyHooks allows you to send a []byte data structure to STDIN // when receiving a predefined string from both STDOUT and STDERR. // The `.Flag.UseTTY` has to be enabled for this to work // // NOTE: If you have defined any `StdoutHooks` or `StderrHooks` that // overlap with hooks defined in `StdanyHooks`, the hooks from // `StdanyHooks` will be executed first StdanyHooks InputHooks // Flag defines a boolean configuration flagset Flag CommandFlagset }
NewCommandOpts defines a set of options for use with the `NewCommand()` intiializer method
func (NewCommandOpts) Validate ¶
func (nco NewCommandOpts) Validate() error
Validate returns an error if a combination of the provided options will cause problems during execution or just plain invalid
type NewSSHKeypairOpts ¶ added in v0.2.2
func (*NewSSHKeypairOpts) SetDefaults ¶ added in v0.2.2
func (o *NewSSHKeypairOpts) SetDefaults()
func (NewSSHKeypairOpts) Validate ¶ added in v0.2.2
func (o NewSSHKeypairOpts) Validate() error
type ProjectType ¶ added in v0.2.4
type ProjectType string
const ( TypeC ProjectType = "c" TypeGo ProjectType = "go" TypeHaskell ProjectType = "hs" TypeJava ProjectType = "java" TypeJavascript ProjectType = "js" TypePython ProjectType = "py" TypeRuby ProjectType = "rb" TypeRust ProjectType = "rs" TypeTypescript ProjectType = "ts" )
type SSHKeypair ¶ added in v0.2.2
func NewSSHKeypair ¶ added in v0.2.2
func NewSSHKeypair(opts NewSSHKeypairOpts) (*SSHKeypair, error)
type SendHTTPRequestOpts ¶ added in v0.2.3
type SendHTTPRequestOpts struct { // BasicAuth defines user credentials for use with the // request similar to curl's --basic flag. If left nil, // basic auth will not be used BasicAuth *BasicAuth // Body defines the body data to be sent with the request. // If left nil, a request without a body will be sent Body []byte // Client defines the HTTP client to use. If left nil, // defaults to http.DefaultClient Client *http.Client // Headers defines the headers to be sent along with this // request. If left nil, no headers will be sent Headers map[string][]string // Method defines the HTTP method to make the request with Method string // URL defines the endpoint to call URL *url.URL }
SendHTTPRequestOpts presents options for the SendHTTPRequest method
func (*SendHTTPRequestOpts) SetDefaults ¶ added in v0.2.3
func (o *SendHTTPRequestOpts) SetDefaults()
SetDefaults sets defaults for the options object instance
func (SendHTTPRequestOpts) Validate ¶ added in v0.2.3
func (o SendHTTPRequestOpts) Validate() error
Validate validates the options to check if this object instance is usable by SendHTTPRequest
type SshKeyFingerprint ¶
type SshKeyFingerprint interface { // GetSHA256 returns a SHA256 fingerprint as a string // that looks like 'SHA256:aBcDeF ...' GetSHA256() string // GetMD5 returns a MD5 fingerprint (legacy) as a string // that looks like 'aa:bb:cc:dd ...' GetMD5() string }
SshKeyFingerprint holds the key's fingerprint
func GetSshKeyFingerprint ¶
func GetSshKeyFingerprint(opts GetSshKeyFingerprintOpts) (SshKeyFingerprint, error)
GetSshKeyFingerprint returns the fingerprints for the provided key as specified in the GetSshKeyFingerprintOpts parameter
type ValidateApplicationsErrors ¶
type ValidateApplicationsErrors struct {
Errors []string
}
func (ValidateApplicationsErrors) Error ¶
func (e ValidateApplicationsErrors) Error() string
func (ValidateApplicationsErrors) Len ¶
func (e ValidateApplicationsErrors) Len() int
func (*ValidateApplicationsErrors) Push ¶
func (e *ValidateApplicationsErrors) Push(err string)
type ValidateApplicationsOpts ¶
type ValidateApplicationsOpts struct {
Paths []string
}
type ValidateConnectionOpts ¶
type ValidateConnectionOpts struct { Hostname string IsIpV6 bool Port uint16 Protocol ConnectionProtocol RetryInterval time.Duration RetryLimit uint Timeout time.Duration }
func (*ValidateConnectionOpts) SetDefaults ¶
func (o *ValidateConnectionOpts) SetDefaults()
func (ValidateConnectionOpts) Validate ¶
func (o ValidateConnectionOpts) Validate() error
type ValidateEnvironmentErrors ¶
type ValidateEnvironmentErrors struct {
Errors []ValidateEnvironmentError
}
func (ValidateEnvironmentErrors) Error ¶
func (e ValidateEnvironmentErrors) Error() string
func (ValidateEnvironmentErrors) Len ¶
func (e ValidateEnvironmentErrors) Len() int
func (*ValidateEnvironmentErrors) Push ¶
func (e *ValidateEnvironmentErrors) Push(err ValidateEnvironmentError)
type ValidateEnvironmentOpts ¶
type ValidateEnvironmentOpts struct {
Keys EnvironmentKeys
}
func (*ValidateEnvironmentOpts) SetDefaults ¶
func (o *ValidateEnvironmentOpts) SetDefaults()
Source Files ¶
- command.go
- configuration.go
- confirm.go
- constants.go
- download_file.go
- get_ssh_key_fingerprint.go
- is_project_type.go
- load_configuration.go
- new_ssh_keypair.go
- send_http_request.go
- types.go
- utils_files.go
- utils_path.go
- utils_strings.go
- validate_applications.go
- validate_connection.go
- validate_environment.go