cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const SupportLogin = false

SupportLogin is a feature flag. Set it to true after we've implemented user management & authentication support in the server.

View Source
const VersionString = "0.1.0"

Variables

View Source
var MockHttpClientFunc func(client *http.Client)

Functions

func DefineServerFlags

func DefineServerFlags(flags *pflag.FlagSet)

func GetApiErrorMessage

func GetApiErrorMessage(resp *resty.Response) string

func GetViperBoolIfSet

func GetViperBoolIfSet(viper *viper.Viper, key string) *bool

func GetViperStringIfSet

func GetViperStringIfSet(viper *viper.Viper, key string) *string

func NewApiClient

func NewApiClient(config Config) (*resty.Client, error)

func NewApiRequest

func NewApiRequest(config Config, state State) (*resty.Request, error)

func NewApiRequestWithoutAuth

func NewApiRequestWithoutAuth(config Config) (*resty.Request, error)

func PrintCaveatlnf

func PrintCaveatlnf(printer mocking.IPrinter, format string, a ...interface{})

func PrintCelebrationlnf

func PrintCelebrationlnf(printer mocking.IPrinter, format string, a ...interface{})

func PrintSeparatorln

func PrintSeparatorln(printer mocking.IPrinter)

func PrintTiplnf

func PrintTiplnf(printer mocking.IPrinter, format string, a ...interface{})

func RequireConfigOptions

func RequireConfigOptions(viper *viper.Viper, spec ConfigRequirementSpec) error

RequireConfigOptions checks whether the given configuration options are set. Returns an error if some are missing, nil if everything is present.

func RequireOneOfConfigOptions

func RequireOneOfConfigOptions(viper *viper.Viper, spec ConfigRequirementSpec) error

RequireOneOfConfigOptions checks whether exactly one of the given configuration options is set. Returns an error if none are set or if more than one is set. Returns nil if exactly one is present.

func StateFilePath

func StateFilePath() (string, error)

Types

type Config

type Config struct {
	ServerBaseURL     string
	BasicAuthUser     string
	BasicAuthPassword string
	Debug             bool
}

func LoadConfigFromViper

func LoadConfigFromViper(viper *viper.Viper) Config

func (Config) RequireServerConfig

func (config Config) RequireServerConfig() error

type ConfigRequirementSpec

type ConfigRequirementSpec struct {
	// StringNonEmpty contains a list of Viper config names, whose
	// String value must be non-empty.
	StringNonEmpty []string
	// UintNonZero contains a list of Viper config names, whose
	// Uint value must be non-zero.
	UintNonZero []string
}

ConfigRequirementSpec describes which configuration options must be set, and what "not set" exactly means.

func (ConfigRequirementSpec) Names

func (spec ConfigRequirementSpec) Names() []string

Names returns all configuration option names that appear in this spec.

type State

type State struct {
	AuthToken               string    `json:"auth_token"`
	AuthTokenExpirationTime time.Time `json:"auth_token_expiration_time"`
}
var MockState *State

func LoadState

func LoadState(reader io.Reader) (State, error)

func LoadStateFromFilesystem

func LoadStateFromFilesystem() (State, error)

LoadStateFromFilesystem attempts to load state from the state file. If the state file does not exists, it returns the empty state.

func (State) RequireAuthToken

func (state State) RequireAuthToken() error

func (State) SaveToFilesystem

func (state State) SaveToFilesystem() error

Jump to

Keyboard shortcuts

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