Documentation
¶
Index ¶
Constants ¶
const ( // JSONOutput is the json output format JSONOutput = "json" // TextOutput is the text (templated) output format TextOutput = "text" )
Variables ¶
var ( // DefaultPassFunc can be used to consume a password from a file descriptor. // References terminal.ReadPassword which obscures the user input. DefaultPassFunc = term.ReadPassword )
Functions ¶
func InitConfig ¶
func InitConfig(params InitConfigParams) error
InitConfig initialises a configuration file or changes an existing one it thought of as a mechanism for users to onboard easily and have a guided and interactive configuration bootstrap.
Types ¶
type App ¶
App stitches together all the parts to create the ecctl application.
func Instance ¶
Instance instantiates a new Application from a config, if it's already been instantiated, an error is returned.
func NewApplication ¶
NewApplication returns a fully initialized App, which will be called from the presentation layer (cmd)
type Commentator ¶
type Commentator interface {
// Set sets an extra message in the commentator
Set(m string)
// Message formats the message so it returns any extra message
// after the message it receives.
Message(m string) string
}
Commentator contains the actions for any commentator
func GetOperationInstance ¶
func GetOperationInstance() Commentator
GetOperationInstance obtains the operation Commenter singleton
type Config ¶
type Config struct {
User string `json:"user,omitempty"`
Pass string `json:"pass,omitempty"`
Host string `json:"host,omitempty"`
APIKey string `json:"api_key,omitempty" mapstructure:"api_key"`
Region string `json:"region,omitempty"`
Output string `json:"output,omitempty"`
Message string `json:"message,omitempty"`
Format string `json:"format,omitempty"`
VerboseFile string `json:"verbose_file,omitempty" mapstructure:"verbose_file"`
OutputDevice *output.Device `json:"-"`
ErrorDevice io.Writer `json:"-"`
Client *http.Client `json:"-"`
Timeout time.Duration `json:"timeout,omitempty"`
Verbose bool `json:"verbose,omitempty"`
VerboseCredentials bool `json:"verbose_credentials,omitempty" mapstructure:"verbose_credentials"`
Force bool `json:"force,omitempty"`
Insecure bool `json:"insecure,omitempty"`
// SkipLogin skips loging in when user and pass are set.
SkipLogin bool `json:"-"`
// SkipLogin skips loging in when user and pass are set.
UserAgent string `json:"-"`
}
Config contains the application configuration
type InitConfigParams ¶
type InitConfigParams struct {
// Viper instance
Viper *viper.Viper
// Reader is Input reader
Reader io.Reader
// Writer is where the output will be written
Writer io.Writer
// ErrWriter is where any Errors will be written
ErrWriter io.Writer
// PasswordReadFunc is the function used to read a password from the file descriptor.
PasswordReadFunc PassFunc
// Client used to perform authentication validations.
Client *http.Client
// FilePath of the configuration
FilePath string
}
InitConfigParams is consumed by InitConfig
func (InitConfigParams) Validate ¶
func (params InitConfigParams) Validate() error
Validate ensures the parameters are usable.
type ReturnCodeError ¶
ReturnCodeError is an error that is accompanied of an intended application return code.