Documentation ¶
Index ¶
- Variables
- func CreateConfig(v *viper.Viper, path, file string) error
- func CreateProjectConfig(projectPath string)
- func InitConfig(fs afero.Fs)
- func IsProjectDir(path string) (bool, error)
- func PrintCurrentContext(out io.Writer) error
- func ProjectConfigExists() bool
- func ProjectRoot() (string, error)
- type Context
- func (c Context) ContextExists() bool
- func (c Context) GetAPIURL() string
- func (c Context) GetAppURL() string
- func (c Context) GetContext() (Context, error)
- func (c Context) GetContextKey() (string, error)
- func (c Context) GetWebsocketURL() string
- func (c Context) PrintContext(out io.Writer) error
- func (c Context) SetContext() error
- func (c Context) SetContextKey(key, value string) error
- func (c Context) SwitchContext() error
- type Contexts
Constants ¶
This section is empty.
Variables ¶
var ( // ConfigFileName is the name of the config files (home / project) ConfigFileName = "config" // ConfigFileType is the config file extension ConfigFileType = "yaml" // ConfigFileNameWithExt is the config filename with extension ConfigFileNameWithExt = fmt.Sprintf("%s.%s", ConfigFileName, ConfigFileType) // ConfigDir is the directory for astro files ConfigDir = ".astro" // HomePath is the path to a users home directory HomePath, _ = fileutil.GetHomeDir() // HomeConfigPath is the path to the users global config directory HomeConfigPath = filepath.Join(HomePath, ConfigDir) // HomeConfigFile is the global config file HomeConfigFile = filepath.Join(HomeConfigPath, ConfigFileNameWithExt) // WorkingPath is the path to the working directory WorkingPath, _ = fileutil.GetWorkingDir() // CFGStrMap maintains string to cfg mapping CFGStrMap = make(map[string]cfg) // CFG Houses configuration meta CFG = cfgs{ CloudAPIProtocol: newCfg("cloud.api.protocol", "https"), CloudAPIPort: newCfg("cloud.api.port", "443"), CloudWSProtocol: newCfg("cloud.api.ws_protocol", "wss"), CloudAPIToken: newCfg("cloud.api.token", ""), Context: newCfg("context", ""), Contexts: newCfg("contexts", ""), LocalHouston: newCfg("local.houston", ""), LocalOrbit: newCfg("local.orbit", ""), PostgresUser: newCfg("postgres.user", "postgres"), PostgresPassword: newCfg("postgres.password", "postgres"), PostgresHost: newCfg("postgres.host", "postgres"), PostgresPort: newCfg("postgres.port", "5432"), ProjectDeployment: newCfg("project.deployment", ""), ProjectName: newCfg("project.name", ""), ProjectWorkspace: newCfg("project.workspace", ""), WebserverPort: newCfg("webserver.port", "8080"), } )
Functions ¶
func CreateConfig ¶
CreateConfig creates a config file in the given directory
func CreateProjectConfig ¶
func CreateProjectConfig(projectPath string)
CreateProjectConfig creates a project config file
func IsProjectDir ¶ added in v0.2.2
IsProjectDir returns a boolean depending on if path is a valid project dir
func PrintCurrentContext ¶ added in v0.2.2
PrintCurrentContext prints the current config context
func ProjectConfigExists ¶
func ProjectConfigExists() bool
ProjectConfigExists returns a boolean indicating if a project config file exists
func ProjectRoot ¶
ProjectRoot returns the path to the nearest project root TODO Deprecate if remains unused, removed due to https://github.com/astronomer/astro-cli/issues/103
Types ¶
type Context ¶ added in v0.2.2
type Context struct { Domain string `mapstructure:"domain"` Workspace string `mapstructure:"workspace"` LastUsedWorkspace string `mapstructure:"last_used_workspace"` Token string `mapstructure:"token"` }
Context represents a single cluster context
func GetCurrentContext ¶ added in v0.2.2
GetCurrentContext looks up current context and gets corresponding Context struct
func (Context) ContextExists ¶ added in v0.2.2
ContextExists checks if a cluster struct exists in config based on Cluster.Domain Returns a boolean indicating whether or not cluster exists
func (Context) GetAPIURL ¶ added in v0.2.2
GetAPIURL returns full Houston API Url for the provided Context
func (Context) GetAppURL ¶ added in v0.4.0
GetAppURL returns full Houston API Url for the provided Context
func (Context) GetContext ¶ added in v0.2.2
GetContext gets the full context from the specified Context receiver struct Returns based on Domain prop
func (Context) GetContextKey ¶ added in v0.2.2
GetContextKey allows a cluster domain to be used without interfering with viper's dot (.) notation for fetching configs by replacing with underscores (_)
func (Context) GetWebsocketURL ¶ added in v0.9.0
GetWebsocketURL returns full Houston websocket Url for the provided Context
func (Context) PrintContext ¶ added in v0.2.2
PrintContext prints current context to stdOut
func (Context) SetContext ¶ added in v0.2.2
SetContext saves Context to the config
func (Context) SetContextKey ¶ added in v0.2.2
SetContextKey saves a single context key value pair
func (Context) SwitchContext ¶ added in v0.2.2
SwitchContext sets the current config context to the one matching the provided Context struct
type Contexts ¶ added in v0.2.2
Contexts holds all available Context structs in a map
func (Contexts) GetContexts ¶ added in v0.2.2
GetContexts gets all contexts currently configured in the global config Returns a Contexts struct containing a map of all Context structs