ecctl

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JSONOutput is the json output format
	JSONOutput = "json"
	// TextOutput is the text (templated) output format
	TextOutput = "text"
)

Variables

View Source
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 Cleanup

func Cleanup()

Cleanup resets the singleton to nil.

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.

func ReadSecret

func ReadSecret(w io.Writer, passFunc PassFunc, msg string) ([]byte, error)

ReadSecret obtains a secret by reading the PassFunc passing the stdin file descriptor. If passFunc is empty, it defaults to terminal.

Types

type App

type App struct {
	API       *api.API
	Formatter formatter.Formatter
	Config    Config
}

App stitches together all the parts to create the ecctl application.

func Get

func Get() *App

Get obtains the initialized instance of the application

func Instance

func Instance(c Config) (*App, error)

Instance instantiates a new Application from a config, if it's already been instantiated, an error is returned.

func NewApplication

func NewApplication(c Config) (*App, error)

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

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that the application config is a valid one

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 PassFunc

type PassFunc func(fd int) ([]byte, error)

PassFunc represents the function used to consume a password.

type ReturnCodeError

type ReturnCodeError interface {
	error
	ReturnCode() int
}

ReturnCodeError is an error that is accompanied of an intended application return code.

type VersionInfo

type VersionInfo struct {
	Version    string
	APIVersion string
	Commit     string
	Built      string

	// Non Displayed fields
	Repository   string
	Organization string
}

VersionInfo contains detailed information about the binary.

func (VersionInfo) String

func (v VersionInfo) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL