Documentation ¶
Overview ¶
Provides storage and retrieval of user preferences and cluster environment configuration
Index ¶
- Constants
- Variables
- func ConfigDir() string
- func DecodePassword(authStr string) (string, error)
- func EncodePassword(auth *ServiceConfig) string
- func SetConfigDir(dir string)
- func ValidateMarathonURL(marathonURL string) error
- type ConfigEnvironment
- type ConfigFile
- func (configFile *ConfigFile) AddEnvironment()
- func (configFile *ConfigFile) AddMarathonEnvironment(name, host, user, pass, token string)
- func (configFile *ConfigFile) DetermineIfServiceIsRooted() (string, bool)
- func (configFile *ConfigFile) Filename() string
- func (configFile *ConfigFile) GetEnvironment(name string) (*ConfigEnvironment, error)
- func (configFile *ConfigFile) GetEnvironments() []string
- func (configFile *ConfigFile) LoadFromReader(configData io.Reader) error
- func (configFile *ConfigFile) RemoveEnvironment(name string, force bool) error
- func (configFile *ConfigFile) RenameEnvironment(oldName, newName string) error
- func (configFile *ConfigFile) Save() error
- func (configFile *ConfigFile) SaveToWriter(writer io.Writer) error
- func (configFile *ConfigFile) SetDefaultEnvironment(name string) error
- type ServiceConfig
Constants ¶
const ( ConfigFileName = "config.json" DotConfigDir = ".depcon" TypeMarathon = "marathon" TypeKubernetes = "kubernetes" TypeECS = "ecs" )
const ( StrDefaultY string = "[Y/n]" StrDefaultN string = "[y/N]" )
const (
AlphaNumDash string = `^[a-zA-Z0-9_-]*$`
)
Variables ¶
var (
ErrEnvNotFound = errors.New("Specified environment was not found")
)
var (
RegExAlphaNumDash *regexp.Regexp = regexp.MustCompile(AlphaNumDash)
)
Functions ¶
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns the directory the configuration file is stored in
func DecodePassword ¶
func EncodePassword ¶
func EncodePassword(auth *ServiceConfig) string
EncodePassword creates a base64 encoded string using the authorization info. If the username is not specified then an empty password is returned since we need both
func SetConfigDir ¶
func SetConfigDir(dir string)
SetConfigDir sets the directory the configuration file is stored in
func ValidateMarathonURL ¶ added in v0.8.9
Types ¶
type ConfigEnvironment ¶
type ConfigEnvironment struct { // currently only supporting marathon as initial release Marathon *ServiceConfig `json:"marathon,omitempty"` }
func (*ConfigEnvironment) EnvironmentType ¶
func (configEnv *ConfigEnvironment) EnvironmentType() string
type ConfigFile ¶
type ConfigFile struct { Format string `json:"format,omitempty"` RootService bool `json:"rootservice"` Environments map[string]*ConfigEnvironment `json:"environments,omitempty"` DefaultEnv string `json:"default,omitempty"` // contains filtered or unexported fields }
func CreateMemoryMarathonConfig ¶
func CreateMemoryMarathonConfig(host, user, password, token string) *ConfigFile
func CreateNewConfigFromUserInput ¶
func CreateNewConfigFromUserInput() *ConfigFile
func HasExistingConfig ¶
func HasExistingConfig() (*ConfigFile, bool)
func Load ¶
func Load(configDir string) (*ConfigFile, error)
func (*ConfigFile) AddEnvironment ¶
func (configFile *ConfigFile) AddEnvironment()
func (*ConfigFile) AddMarathonEnvironment ¶ added in v0.8.9
func (configFile *ConfigFile) AddMarathonEnvironment(name, host, user, pass, token string)
func (*ConfigFile) DetermineIfServiceIsRooted ¶
func (configFile *ConfigFile) DetermineIfServiceIsRooted() (string, bool)
Determines if the configuration has only a single environment defined and the user prefers a rooted service Returns the environment type and true or else "" and false
func (*ConfigFile) Filename ¶
func (configFile *ConfigFile) Filename() string
Filename returns the name of the configuration file
func (*ConfigFile) GetEnvironment ¶
func (configFile *ConfigFile) GetEnvironment(name string) (*ConfigEnvironment, error)
Returns the Configuration for the specified environment. If the environment is not found then
func (*ConfigFile) GetEnvironments ¶
func (configFile *ConfigFile) GetEnvironments() []string
func (*ConfigFile) LoadFromReader ¶
func (configFile *ConfigFile) LoadFromReader(configData io.Reader) error
func (*ConfigFile) RemoveEnvironment ¶
func (configFile *ConfigFile) RemoveEnvironment(name string, force bool) error
Removes the specified environment from the configuration {name} - name of the environment {force} - if true will not prompt for confirmation
Will return ErrEnvNotFound if the environment could not be found
func (*ConfigFile) RenameEnvironment ¶
func (configFile *ConfigFile) RenameEnvironment(oldName, newName string) error
Renames an environment and updates the default environment if it matches the current old {oldName} - the old environment name {newName} - the new environment name
Will return ErrEnvNOtFound if the old environment could not be found
func (*ConfigFile) Save ¶
func (configFile *ConfigFile) Save() error
func (*ConfigFile) SaveToWriter ¶
func (configFile *ConfigFile) SaveToWriter(writer io.Writer) error
func (*ConfigFile) SetDefaultEnvironment ¶
func (configFile *ConfigFile) SetDefaultEnvironment(name string) error
Sets the default environment to use. This is used by other parts of the application to eliminate the user always specifying and environment {name} - the environment name
Will return ErrEnvNOtFound if the environment could not be found