Documentation
¶
Index ¶
- Constants
- Variables
- func Execute() (cmd *cobra.Command, err error)
- func IsTerminal(f *os.File) bool
- func NewAppCommand(baseCmd *BaseCommand) *cobra.Command
- func NewAppConfigCommand(baseCmd *BaseCommand) *cobra.Command
- func NewAppConfigEditCommand(baseCmd *BaseCommand) *cobra.Command
- func NewAppConfigGetCommand(baseCmd *BaseCommand) *cobra.Command
- func NewAppConfigPatchCommand(baseCmd *BaseCommand) *cobra.Command
- func NewAppConfigSetCommand(baseCmd *BaseCommand) *cobra.Command
- func NewAppConsoleCommand(baseCmd *BaseCommand) *cobra.Command
- func NewAppRestartCommand(baseCmd *BaseCommand) *cobra.Command
- func NewAppStartCommand(baseCmd *BaseCommand) *cobra.Command
- func NewAppStatusCommand(baseCmd *BaseCommand) *cobra.Command
- func NewAppStopCommand(baseCmd *BaseCommand) *cobra.Command
- func NewCompletionCommand(baseCmd *BaseCommand) *cobra.Command
- func NewConfigCommand(baseCmd *BaseCommand) *cobra.Command
- func NewInitCommand(baseCommand *BaseCommand) *cobra.Command
- func NewProfileCommand(baseCmd *BaseCommand) *cobra.Command
- func NewServoCommand(baseCmd *BaseCommand) *cobra.Command
- func PrettyPrintJSONBytes(bytes []byte) error
- func PrettyPrintJSONObject(obj interface{}) error
- func PrettyPrintJSONResponse(resp *resty.Response) error
- func PrettyPrintJSONString(str string) error
- func RangeOfValidJSONArgs(min int, max int) cobra.PositionalArgs
- func SetJSONKeyPathValuesFromStringOnBytes(jsonPathDescriptor string, bytes []byte) ([]byte, error)
- func SetJSONKeyPathValuesFromStringsOnBytes(jsonPathDescriptors []string, bytes []byte) ([]byte, error)
- func SetStdio(stdio terminal.Stdio)
- func ValidSetJSONKeyPathArgs(cmd *cobra.Command, args []string) error
- type BaseCommand
- func (cmd *BaseCommand) AccessToken() string
- func (cmd *BaseCommand) AllSettings() map[string]interface{}
- func (cmd *BaseCommand) App() string
- func (cmd *BaseCommand) AppComponents() (orgSlug string, appSlug string)
- func (cmd *BaseCommand) Ask(qs []*survey.Question, response interface{}, opts ...survey.AskOpt) error
- func (cmd *BaseCommand) AskOne(p survey.Prompt, response interface{}, opts ...survey.AskOpt) error
- func (cmd *BaseCommand) BaseURL() string
- func (cmd *BaseCommand) BaseURLHostnameAndPort() string
- func (cmd *BaseCommand) ColorOutput() bool
- func (cmd *BaseCommand) DebugModeEnabled() bool
- func (baseCmd *BaseCommand) DefaultConfigFile() string
- func (baseCmd *BaseCommand) DefaultConfigPath() string
- func (baseCmd *BaseCommand) DefaultConfigType() string
- func (cmd *BaseCommand) Flags() *pflag.FlagSet
- func (baseCmd *BaseCommand) GetAllSettings() map[string]interface{}
- func (baseCmd *BaseCommand) GetAppComponents() (orgSlug string, appSlug string)
- func (baseCmd *BaseCommand) GetBaseURL() string
- func (baseCmd *BaseCommand) GetBaseURLHostnameAndPort() string
- func (baseCmd *BaseCommand) InitConfigRunE(cmd *cobra.Command, args []string) error
- func (baseCmd *BaseCommand) IsInitialized() bool
- func (cmd *BaseCommand) LoadProfile() (*Profile, error)
- func (baseCmd *BaseCommand) NewAPIClient() *opsani.Client
- func (cmd *BaseCommand) OutOrStdout() io.Writer
- func (cmd *BaseCommand) PersistentFlags() *pflag.FlagSet
- func (cmd *BaseCommand) PrettyPrintJSONBytes(bytes []byte) error
- func (cmd *BaseCommand) PrettyPrintJSONObject(obj interface{}) error
- func (cmd *BaseCommand) PrettyPrintJSONResponse(resp *resty.Response) error
- func (cmd *BaseCommand) PrettyPrintJSONString(str string) error
- func (cmd *BaseCommand) PrettyPrintYAML(bytes []byte, lineNumbers bool) error
- func (cmd *BaseCommand) PrettyPrintYAMLObject(obj interface{}) error
- func (cmd *BaseCommand) Print(i ...interface{})
- func (cmd *BaseCommand) PrintErr(i ...interface{})
- func (cmd *BaseCommand) PrintErrf(format string, i ...interface{})
- func (cmd *BaseCommand) PrintErrln(i ...interface{})
- func (cmd *BaseCommand) Printf(format string, i ...interface{})
- func (cmd *BaseCommand) Println(i ...interface{})
- func (cmd *BaseCommand) RequestTracingEnabled() bool
- func (baseCmd *BaseCommand) RequireConfigFileFlagToExistRunE(cmd *cobra.Command, args []string) error
- func (baseCmd *BaseCommand) RequireInitRunE(cmd *cobra.Command, args []string) error
- func (cmd *BaseCommand) RootCobraCommand() *cobra.Command
- func (cmd *BaseCommand) SetColorOutput(colorOutput bool)
- func (cmd *BaseCommand) Viper() *viper.Viper
- type FlagError
- type Profile
- type ProfileRegistry
- func (pr *ProfileRegistry) AddProfile(profile Profile) error
- func (pr *ProfileRegistry) ProfileNamed(name string) *Profile
- func (pr *ProfileRegistry) Profiles() ([]Profile, error)
- func (pr *ProfileRegistry) RemoveProfile(profile Profile) error
- func (pr *ProfileRegistry) RemoveProfileNamed(name string) error
- func (pr *ProfileRegistry) Save() error
- func (pr *ProfileRegistry) Set(profiles []Profile)
- type RunEFunc
- type RunFunc
- type Servo
- type ServoRegistry
Constants ¶
const ( KeyBaseURL = "base-url" KeyApp = "app" KeyToken = "token" KeyProfile = "profile" KeyDebugMode = "debug" KeyRequestTracing = "trace-requests" KeyEnvPrefix = "OPSANI" DefaultBaseURL = "https://api.opsani.com/" )
Configuration keys (Cobra and Viper)
Variables ¶
var ( Version = "dev" Commit = "none" BuildDate = "unknown" BuiltBy = "unknown" )
Functions ¶
func Execute ¶
Execute is the entry point for executing all commands from main All commands with RunE will bubble errors back here
func IsTerminal ¶
IsTerminal reports whether the file descriptor is connected to a terminal
func NewAppCommand ¶
func NewAppCommand(baseCmd *BaseCommand) *cobra.Command
NewAppCommand returns a new `opsani app` command instance
func NewAppConfigCommand ¶
func NewAppConfigCommand(baseCmd *BaseCommand) *cobra.Command
NewAppConfigCommand returns a new Opsani CLI `app config` action
func NewAppConfigEditCommand ¶
func NewAppConfigEditCommand(baseCmd *BaseCommand) *cobra.Command
NewAppConfigEditCommand returns a new Opsani CLI app config edit action
func NewAppConfigGetCommand ¶
func NewAppConfigGetCommand(baseCmd *BaseCommand) *cobra.Command
NewAppConfigGetCommand returns a new Opsani CLI `app config get` action
func NewAppConfigPatchCommand ¶
func NewAppConfigPatchCommand(baseCmd *BaseCommand) *cobra.Command
NewAppConfigPatchCommand returns a new Opsani CLI `app config patch` action
func NewAppConfigSetCommand ¶
func NewAppConfigSetCommand(baseCmd *BaseCommand) *cobra.Command
NewAppConfigSetCommand returns a new Opsani CLI `app config set` action
func NewAppConsoleCommand ¶
func NewAppConsoleCommand(baseCmd *BaseCommand) *cobra.Command
NewAppConsoleCommand returns a command that opens the Opsani Console in the default browser
func NewAppRestartCommand ¶
func NewAppRestartCommand(baseCmd *BaseCommand) *cobra.Command
NewAppRestartCommand returns an Opsani CLI command for restarting the app
func NewAppStartCommand ¶
func NewAppStartCommand(baseCmd *BaseCommand) *cobra.Command
NewAppStartCommand returns an Opsani CLI command for starting the app
func NewAppStatusCommand ¶
func NewAppStatusCommand(baseCmd *BaseCommand) *cobra.Command
NewAppStatusCommand returns an Opsani CLI command for retrieving status on the app
func NewAppStopCommand ¶
func NewAppStopCommand(baseCmd *BaseCommand) *cobra.Command
NewAppStopCommand returns an Opsani CLI command for stopping the app
func NewCompletionCommand ¶
func NewCompletionCommand(baseCmd *BaseCommand) *cobra.Command
NewCompletionCommand returns a new Opsani CLI cmpletion command instance
func NewConfigCommand ¶
func NewConfigCommand(baseCmd *BaseCommand) *cobra.Command
NewConfigCommand returns a new instance of the root command for Opsani CLI
func NewInitCommand ¶
func NewInitCommand(baseCommand *BaseCommand) *cobra.Command
NewInitCommand returns a new `opsani init` command instance
func NewProfileCommand ¶
func NewProfileCommand(baseCmd *BaseCommand) *cobra.Command
NewProfileCommand returns a new instance of the profile command
func NewServoCommand ¶
func NewServoCommand(baseCmd *BaseCommand) *cobra.Command
NewServoCommand returns a new instance of the servo command
func PrettyPrintJSONBytes ¶
PrettyPrintJSONBytes prints the given byte array as pretty printed JSON
func PrettyPrintJSONObject ¶
func PrettyPrintJSONObject(obj interface{}) error
PrettyPrintJSONObject prints the given object as pretty printed JSON
func PrettyPrintJSONResponse ¶
PrettyPrintJSONResponse prints the given API response as pretty printed JSON
func PrettyPrintJSONString ¶
PrettyPrintJSONString prints the given string as pretty printed JSON
func RangeOfValidJSONArgs ¶
func RangeOfValidJSONArgs(min int, max int) cobra.PositionalArgs
RangeOfValidJSONArgs ensures that the number of args are within the range and are all valid JSON
func SetJSONKeyPathValuesFromStringOnBytes ¶
SetJSONKeyPathValuesFromStringOnBytes sets a JSON dotted path expression of the form (this.key=value) to a new value in a JSON byte array
func SetJSONKeyPathValuesFromStringsOnBytes ¶
func SetJSONKeyPathValuesFromStringsOnBytes(jsonPathDescriptors []string, bytes []byte) ([]byte, error)
SetJSONKeyPathValuesFromStringsOnBytes sets an array of JSON dotted path expressions of the form (this.key=value) to a new value in a JSON byte array
Types ¶
type BaseCommand ¶
type BaseCommand struct {
// contains filtered or unexported fields
}
BaseCommand is the foundational command structure for the Opsani CLI It contains the root command for Cobra and is designed for embedding into other command structures to add subcommand functionality
func NewRootCommand ¶
func NewRootCommand() *BaseCommand
NewRootCommand returns a new instance of the root command for Opsani CLI
func (*BaseCommand) AccessToken ¶
func (cmd *BaseCommand) AccessToken() string
AccessToken returns the Opsani API access token
func (*BaseCommand) AllSettings ¶
func (cmd *BaseCommand) AllSettings() map[string]interface{}
AllSettings returns all configuration settings
func (*BaseCommand) AppComponents ¶
func (cmd *BaseCommand) AppComponents() (orgSlug string, appSlug string)
AppComponents returns the organization name and app ID as separate path components
func (*BaseCommand) Ask ¶
func (cmd *BaseCommand) Ask(qs []*survey.Question, response interface{}, opts ...survey.AskOpt) error
Ask is a wrapper for survey.AskOne that executes with the command's stdio
func (*BaseCommand) AskOne ¶
AskOne is a wrapper for survey.AskOne that executes with the command's stdio
func (*BaseCommand) BaseURL ¶
func (cmd *BaseCommand) BaseURL() string
BaseURL returns the Opsani API base URL The BaseURL is determined by config (args/env), active profile, or default
func (*BaseCommand) BaseURLHostnameAndPort ¶
func (cmd *BaseCommand) BaseURLHostnameAndPort() string
BaseURLHostnameAndPort returns the hostname and port portion of Opsani base URL for summary display
func (*BaseCommand) ColorOutput ¶
func (cmd *BaseCommand) ColorOutput() bool
ColorOutput indicates if ANSI colors will be used for output
func (*BaseCommand) DebugModeEnabled ¶
func (cmd *BaseCommand) DebugModeEnabled() bool
DebugModeEnabled returns a boolean value indicating if debugging is enabled
func (*BaseCommand) DefaultConfigFile ¶
func (baseCmd *BaseCommand) DefaultConfigFile() string
DefaultConfigFile returns the full path to the default Opsani configuration file
func (*BaseCommand) DefaultConfigPath ¶
func (baseCmd *BaseCommand) DefaultConfigPath() string
DefaultConfigPath returns the path to the directory storing the Opsani configuration file
func (*BaseCommand) DefaultConfigType ¶
func (baseCmd *BaseCommand) DefaultConfigType() string
DefaultConfigType returns the
func (*BaseCommand) Flags ¶
func (cmd *BaseCommand) Flags() *pflag.FlagSet
Flags returns the complete FlagSet that applies to this command (local and persistent declared here and by all parents).
func (*BaseCommand) GetAllSettings ¶
func (baseCmd *BaseCommand) GetAllSettings() map[string]interface{}
GetAllSettings returns all configuration settings
func (*BaseCommand) GetAppComponents ¶
func (baseCmd *BaseCommand) GetAppComponents() (orgSlug string, appSlug string)
GetAppComponents returns the organization name and app ID as separate path components
func (*BaseCommand) GetBaseURL ¶
func (baseCmd *BaseCommand) GetBaseURL() string
GetBaseURL returns the Opsani API base URL
func (*BaseCommand) GetBaseURLHostnameAndPort ¶
func (baseCmd *BaseCommand) GetBaseURLHostnameAndPort() string
GetBaseURLHostnameAndPort returns the hostname and port portion of Opsani base URL for summary display
func (*BaseCommand) InitConfigRunE ¶
func (baseCmd *BaseCommand) InitConfigRunE(cmd *cobra.Command, args []string) error
InitConfigRunE initializes client configuration and aborts execution if an error is encountered
func (*BaseCommand) IsInitialized ¶
func (baseCmd *BaseCommand) IsInitialized() bool
IsInitialized returns a boolean value that indicates if the client has been initialized
func (*BaseCommand) LoadProfile ¶
func (cmd *BaseCommand) LoadProfile() (*Profile, error)
LoadProfile loads the configuration for the specified profile
func (*BaseCommand) NewAPIClient ¶
func (baseCmd *BaseCommand) NewAPIClient() *opsani.Client
NewAPIClient returns an Opsani API client configured using the active configuration
func (*BaseCommand) OutOrStdout ¶
func (cmd *BaseCommand) OutOrStdout() io.Writer
OutOrStdout returns output to stdout.
func (*BaseCommand) PersistentFlags ¶
func (cmd *BaseCommand) PersistentFlags() *pflag.FlagSet
PersistentFlags returns the persistent FlagSet specifically set in the current command.
func (*BaseCommand) PrettyPrintJSONBytes ¶
func (cmd *BaseCommand) PrettyPrintJSONBytes(bytes []byte) error
PrettyPrintJSONBytes prints the given byte array as pretty printed JSON
func (*BaseCommand) PrettyPrintJSONObject ¶
func (cmd *BaseCommand) PrettyPrintJSONObject(obj interface{}) error
PrettyPrintJSONObject prints the given object as pretty printed JSON
func (*BaseCommand) PrettyPrintJSONResponse ¶
func (cmd *BaseCommand) PrettyPrintJSONResponse(resp *resty.Response) error
PrettyPrintJSONResponse prints the given API response as pretty printed JSON
func (*BaseCommand) PrettyPrintJSONString ¶
func (cmd *BaseCommand) PrettyPrintJSONString(str string) error
PrettyPrintJSONString prints the given string as pretty printed JSON
func (*BaseCommand) PrettyPrintYAML ¶
func (cmd *BaseCommand) PrettyPrintYAML(bytes []byte, lineNumbers bool) error
PrettyPrintYAML pretty prints the given YAML byte array, optionally including line numbers
func (*BaseCommand) PrettyPrintYAMLObject ¶
func (cmd *BaseCommand) PrettyPrintYAMLObject(obj interface{}) error
PrettyPrintYAMLObject pretty prints the given object marshalled into YAML
func (*BaseCommand) Print ¶
func (cmd *BaseCommand) Print(i ...interface{})
Print is a convenience method to Print to the defined output, fallback to Stderr if not set.
func (*BaseCommand) PrintErr ¶
func (cmd *BaseCommand) PrintErr(i ...interface{})
PrintErr is a convenience method to Print to the defined Err output, fallback to Stderr if not set.
func (*BaseCommand) PrintErrf ¶
func (cmd *BaseCommand) PrintErrf(format string, i ...interface{})
PrintErrf is a convenience method to Printf to the defined Err output, fallback to Stderr if not set.
func (*BaseCommand) PrintErrln ¶
func (cmd *BaseCommand) PrintErrln(i ...interface{})
PrintErrln is a convenience method to Println to the defined Err output, fallback to Stderr if not set.
func (*BaseCommand) Printf ¶
func (cmd *BaseCommand) Printf(format string, i ...interface{})
Printf is a convenience method to Printf to the defined output, fallback to Stderr if not set.
func (*BaseCommand) Println ¶
func (cmd *BaseCommand) Println(i ...interface{})
Println is a convenience method to Println to the defined output, fallback to Stderr if not set.
func (*BaseCommand) RequestTracingEnabled ¶
func (cmd *BaseCommand) RequestTracingEnabled() bool
RequestTracingEnabled returns a boolean value indicating if request tracing is enabled
func (*BaseCommand) RequireConfigFileFlagToExistRunE ¶
func (baseCmd *BaseCommand) RequireConfigFileFlagToExistRunE(cmd *cobra.Command, args []string) error
RequireConfigFileFlagToExistRunE aborts command execution with an error if the config file specified via a flag does not exist
func (*BaseCommand) RequireInitRunE ¶
func (baseCmd *BaseCommand) RequireInitRunE(cmd *cobra.Command, args []string) error
RequireInitRunE aborts command execution with an error if the client is not initialized
func (*BaseCommand) RootCobraCommand ¶
func (cmd *BaseCommand) RootCobraCommand() *cobra.Command
RootCobraCommand returns the root Cobra command of the Opsani CLI command
func (*BaseCommand) SetColorOutput ¶
func (cmd *BaseCommand) SetColorOutput(colorOutput bool)
SetColorOutput sets whether or not ANSI colors will be used for output
func (*BaseCommand) Viper ¶
func (cmd *BaseCommand) Viper() *viper.Viper
Viper returns the Viper configuration object underlying the Opsani CLI command
type FlagError ¶
type FlagError struct {
Err error
}
FlagError is the kind of error raised in flag processing
type Profile ¶
type Profile struct {
Name string `yaml:"name" mapstructure:"name"`
App string `yaml:"app" mapstructure:"app"`
Token string `yaml:"token" mapstructure:"token"`
BaseURL string `yaml:"base_url" mapstructure:"base_url"`
}
Profile represents an Opsani app, token, and base URL
type ProfileRegistry ¶
type ProfileRegistry struct {
// contains filtered or unexported fields
}
ProfileRegistry provides an interface for managing configuration of app profiles
func NewProfileRegistry ¶
func NewProfileRegistry(viper *viper.Viper) ProfileRegistry
NewProfileRegistry returns a new registry of configured app profiles
func (*ProfileRegistry) AddProfile ¶
func (pr *ProfileRegistry) AddProfile(profile Profile) error
AddProfile adds a Profile to the config
func (*ProfileRegistry) ProfileNamed ¶
func (pr *ProfileRegistry) ProfileNamed(name string) *Profile
ProfileNamed named returns the Profile with the given name
func (*ProfileRegistry) Profiles ¶
func (pr *ProfileRegistry) Profiles() ([]Profile, error)
Profiles returns the Profiles in the configuration
func (*ProfileRegistry) RemoveProfile ¶
func (pr *ProfileRegistry) RemoveProfile(profile Profile) error
RemoveProfile removes a Profile from the config
func (*ProfileRegistry) RemoveProfileNamed ¶
func (pr *ProfileRegistry) RemoveProfileNamed(name string) error
RemoveProfileNamed removes a Profile from the config with the given name
func (*ProfileRegistry) Save ¶
func (pr *ProfileRegistry) Save() error
Save the data back to the config
func (*ProfileRegistry) Set ¶
func (pr *ProfileRegistry) Set(profiles []Profile)
Set sets the Profile on the registry
type RunEFunc ¶
RunEFunc is a Cobra Run function that returns an error
func ReduceRunEFuncs ¶
ReduceRunEFuncs reduces a list of Cobra run functions that return an error into a single aggregate run function
type RunFunc ¶
RunFunc is a Cobra Run function
func ReduceRunFuncs ¶
ReduceRunFuncs reduces a list of Cobra run functions into a single aggregate run function
type Servo ¶
type Servo struct {
Name string `yaml:"name" mapstructure:"name"`
User string `yaml:"user" mapstructure:"user"`
Host string `yaml:"host" mapstructure:"host"`
Port string `yaml:"port" mapstructure:"port"`
Path string `yaml:"path" mapstructure:"path"`
Bastion string `yaml:"bastion" mapstructure:"bastion"`
}
Servo represents a deployed Servo assembly running somewhere
func (Servo) BastionComponents ¶
BastionComponents splits the bastion host identifier into user and host components
func (Servo) DisplayHost ¶
DisplayHost returns the hostname and port if different from 22
func (Servo) DisplayPath ¶
DisplayPath returns the path that the Servo is installed at
func (Servo) HostAndPort ¶
HostAndPort returns a string with the host and port when different from 22
type ServoRegistry ¶
type ServoRegistry struct {
// contains filtered or unexported fields
}
ServoRegistry manages a collection of configured Servos
func NewServoRegistry ¶
func NewServoRegistry(viper *viper.Viper) ServoRegistry
NewServoRegistry builds a Servo registry from the Viper configuration
func (*ServoRegistry) AddServo ¶
func (sr *ServoRegistry) AddServo(servo Servo) error
AddServo adds a Servo to the config
func (*ServoRegistry) RemoveServo ¶
func (sr *ServoRegistry) RemoveServo(servo Servo) error
RemoveServo removes a Servo from the config
func (*ServoRegistry) RemoveServoNamed ¶
func (sr *ServoRegistry) RemoveServoNamed(name string) error
RemoveServoNamed removes a Servo from the config with the given name
func (*ServoRegistry) ServoNamed ¶
func (sr *ServoRegistry) ServoNamed(name string) *Servo
ServoNamed named returns the Servo with the given name
func (*ServoRegistry) Servos ¶
func (sr *ServoRegistry) Servos() ([]Servo, error)
Servos returns the Servos in the configuration