Documentation ¶
Index ¶
- Constants
- Variables
- func DefineServerFlags(flags *pflag.FlagSet)
- func GetApiErrorMessage(resp *resty.Response) string
- func GetViperBoolIfSet(viper *viper.Viper, key string) *bool
- func GetViperStringIfSet(viper *viper.Viper, key string) *string
- func NewApiClient(config Config) (*resty.Client, error)
- func NewApiRequest(config Config, state State) (*resty.Request, error)
- func NewApiRequestWithoutAuth(config Config) (*resty.Request, error)
- func PrintCaveatlnf(printer mocking.IPrinter, format string, a ...interface{})
- func PrintCelebrationlnf(printer mocking.IPrinter, format string, a ...interface{})
- func PrintSeparatorln(printer mocking.IPrinter)
- func PrintTiplnf(printer mocking.IPrinter, format string, a ...interface{})
- func RequireConfigOptions(viper *viper.Viper, spec ConfigRequirementSpec) error
- func RequireOneOfConfigOptions(viper *viper.Viper, spec ConfigRequirementSpec) error
- func StateFilePath() (string, error)
- type Config
- type ConfigRequirementSpec
- type State
Constants ¶
const SupportLogin = false
SupportLogin is a feature flag. Set it to true after we've implemented user management & authentication support in the server.
const VersionString = "0.1.0"
Variables ¶
var MockHttpClientFunc func(client *http.Client)
Functions ¶
func DefineServerFlags ¶
func GetApiErrorMessage ¶
func GetApiErrorMessage(resp *resty.Response) string
func NewApiClient ¶
func NewApiRequest ¶
func PrintCaveatlnf ¶
func PrintCelebrationlnf ¶
func PrintSeparatorln ¶
func PrintTiplnf ¶
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 ¶
Types ¶
type Config ¶
type Config struct { ServerBaseURL string BasicAuthUser string BasicAuthPassword string Debug bool }
func LoadConfigFromViper ¶
func (Config) RequireServerConfig ¶
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 LoadStateFromFilesystem ¶
LoadStateFromFilesystem attempts to load state from the state file. If the state file does not exists, it returns the empty state.