Documentation
¶
Index ¶
Constants ¶
const ( ConfigPathDefault = ".envctl.yaml" ConfigPathEnv = "ENVCTL_CONFIG" )
Variables ¶
var ( ErrCircularDependency = errors.New("circular dependency") ErrUnknownEnvironment = errors.New("unknown environment") )
var ConfigContentDefault []byte
Functions ¶
func ConfigPath ¶
ConfigPath resolves and returns the config path. Lookup order:
- Flag
- Environment variable
- Default path name
Types ¶
type App ¶
type App struct {
Config *Config
Logger *Logger
Meta *Meta
IO *ui.IOStreams
UI *ui.UserInterface
Stores *stores.StoreService
Environments *EnvironmentService
Exec *exec.ExecService
// contains filtered or unexported fields
}
App contains global and/or singleton application data.
func AppForContext ¶
AppForContext returns the app singleton stored in the given context.
func NewApp ¶
NewApp returns the default App singleton. It will be minimally initialized with metadata and config. Call `Init()` after flag parsing to complete initialization.
func NewTestApp ¶
func NewTestApp() *App
NewTestApp returns the test App singleton. All properties will be configured for testing (mocks, stubs, etc).
func (*App) Context ¶
Context returns the root context.Context for the app.
func (*App) Init ¶
Init initializes and configures the app. It must be called once flags have been parsed.
func (*App) InitForTest ¶
func (a *App) InitForTest()
Init initializes and configures the app for unit testing.
type Config ¶
type Config struct {
ConfigPath string
Color bool `yaml:"color" env:"ENVCTL_COLOR" default:"true"`
Debug bool `yaml:"debug" env:"ENVCTL_DEBUG"`
Prompt bool `yaml:"prompt" env:"ENVCTL_PROMPT" default:"true"`
LogLevel string `yaml:"log_level" env:"ENVCTL_LOG_LEVEL" default:"warn" validate:"oneof=debug info warn error fatal"` //nolint: lll
Version string `yaml:"version"`
DotEnv DotEnvConfig `yaml:"dotenv"`
Environments []Environment `yaml:"environments"`
}
func NewConfigFromPath ¶
NewConfigFromPath returns a new config for the file at path.
func NewTestConfig ¶
NewTestConfig returns a new Config for unit tests populated with default values.
func (*Config) EnvironmentNames ¶ added in v0.3.0
type DotEnvConfig ¶ added in v0.5.0
type DotEnvConfig struct {
Enabled bool `yaml:"enabled" env:"ENVCTL_DOTENV_ENABLED"`
BasePath string `yaml:"base_path" env:"ENVCTL_DOTENV_BASE_PATH"`
QuoteStyle dotenv.QuoteStyle `yaml:"quote_style" env:"ENVCTL_DOTENV_QUOTE_STYLE" default:"double" validate:"oneof=none single double"` //nolint: lll
EscapeStyle dotenv.EscapeStyle `yaml:"escape_style" env:"ENVCTL_DOTENV_ESCAPE_STYLE" default:"default" validate:"oneof=default compose"` //nolint: lll
}
type Environment ¶ added in v0.3.0
type EnvironmentService ¶ added in v0.3.0
type EnvironmentService struct {
// contains filtered or unexported fields
}
func NewEnvironmentService ¶ added in v0.3.0
func NewEnvironmentService(config *Config) *EnvironmentService
func (*EnvironmentService) Get ¶ added in v0.3.0
func (s *EnvironmentService) Get(id string) (Environment, error)
type Logger ¶
Logger is a simple wrapper around the charmbracelet/log package.