Documentation ¶
Index ¶
- Variables
- func ChangeViperValues(key string, value interface{}) error
- func CheckEmptyArgs(args map[string]string) error
- func ExistingKeys() []string
- func ExistsKey(key string) bool
- func GetCliClient() controller.Interface
- func GetCliOutput() io.Writer
- func GetConfiguredScope() string
- func GetConfiguredServerIP() string
- func GetScope() (string, error)
- func GetToken(path string) []byte
- func InitViperConfig()
- func ProcessAliasArg(arg, scope string) (string, string, error)
- func ProcessArg(arg, scope string) (string, string, error)
- func ReadConfigFromFile(file string) error
- func ReadDefaultConfig() error
- func ReadViperConfig(basePath string) error
- func RequestErrorMessage(err error, w io.Writer)
- func SetClient(url string)
- func SetMockedClient(err error)
- func SetOutput(out io.Writer)
- type Authenticator
Constants ¶
This section is empty.
Variables ¶
var ConfigFile string
ConfigFile is the currently loaded config file
Functions ¶
func ChangeViperValues ¶
ChangeViperValues - changes the values of the viper configuration and saves it in the config file of inspr, if the file is not created it will return an error.
func CheckEmptyArgs ¶
CheckEmptyArgs receives the args of a cli command and returns a error in case any of them are empty
func ExistingKeys ¶
func ExistingKeys() []string
ExistingKeys - returns to the user all available keys in viper's configs.
func ExistsKey ¶
ExistsKey - informs to the user if the key passed exists in the default keys that are saved in the insprctl config file
func GetCliClient ¶
func GetCliClient() controller.Interface
GetCliClient returns the default controller client for cli.
func GetConfiguredScope ¶
func GetConfiguredScope() string
GetConfiguredScope is responsible for returning config value for scope. Avoids having to constants public.
func GetConfiguredServerIP ¶
func GetConfiguredServerIP() string
GetConfiguredServerIP is responsible for returning config value for serverIp. Avoids having to constants public.
func GetScope ¶
GetScope retreives the path to be used as base scope for an Insprd request. Takes into consideration viper config and scope flag.
func GetToken ¶
GetToken gets a token from a filepath, returns an empty token if file does not exist.
func InitViperConfig ¶
func InitViperConfig()
InitViperConfig - sets defaults values and where is the file in which new values can be read
func ProcessAliasArg ¶
ProcessAliasArg is responsible for separating a path into an alias name and it's parent's path. < path, name, error >
func ProcessArg ¶
ProcessArg is responsible for separating a path into an component name and it's parent's path. < path, name, error >
func ReadConfigFromFile ¶
ReadConfigFromFile reads a config from a file
func ReadDefaultConfig ¶
func ReadDefaultConfig() error
ReadDefaultConfig reads the default insprctl configuration
func ReadViperConfig ¶
ReadViperConfig - reads the inspr's viper config, in case it didn't found any, it creates one with the defaults values
func RequestErrorMessage ¶
RequestErrorMessage prints an error to the user based on the error given, in actuality it converts the error to an insprErr and then process what type of return the apply request returned.
func SetMockedClient ¶
func SetMockedClient(err error)
SetMockedClient configures singleton's client as a mocked client given a error
Types ¶
type Authenticator ¶
type Authenticator struct {
TokenPath string
}
Authenticator is responsible for implementing the interface methods defined in the rest/request pkg.
func (Authenticator) GetToken ¶
func (a Authenticator) GetToken() ([]byte, error)
GetToken read the token from the file specified in the struct TokenPath and returns it's bytes
func (Authenticator) SetToken ¶
func (a Authenticator) SetToken(token []byte) error
SetToken receives a new token as a parameter and then writes it in the file specified in the TokenPath