cliconfig

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2017 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Overview

Provides storage and retrieval of user preferences and cluster environment configuration

Index

Constants

View Source
const (
	ConfigFileName = "config.json"
	DotConfigDir   = ".depcon"
	TypeMarathon   = "marathon"
	TypeKubernetes = "kubernetes"
	TypeECS        = "ecs"
)
View Source
const (
	StrDefaultY string = "[Y/n]"
	StrDefaultN string = "[y/N]"
)
View Source
const (
	AlphaNumDash string = `^[a-zA-Z0-9_-]*$`
)

Variables

View Source
var (
	ErrEnvNotFound = errors.New("Specified environment was not found")
)
View Source
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 DecodePassword(authStr string) (string, error)

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

func ValidateMarathonURL(marathonURL string) error

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

type ServiceConfig

type ServiceConfig struct {
	Username string            `json:"username,omitempty"`
	Password string            `json:"password,omitempty"`
	Token    string            `json:"token"`
	HostUrl  string            `json:"serveraddress,omitempty"`
	Features map[string]string `json:"features,omitempty"`
	Name     string            `json:"-"`
}

Jump to

Keyboard shortcuts

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