core

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ConfigPathDefault = ".envctl.yaml"
	ConfigPathEnv     = "ENVCTL_CONFIG"
)

Variables

View Source
var (
	ErrCircularDependency = errors.New("circular dependency")
	ErrUnknownEnvironment = errors.New("unknown environment")
)
View Source
var ConfigContentDefault []byte
View Source
var (
	DotEnvPathVar = "ENVCTL_DOTENV_PATH"
)

Functions

func ConfigPath

func ConfigPath(args []string) (string, error)

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

func AppForContext(ctx context.Context) *App

AppForContext returns the app singleton stored in the given context.

func NewApp

func NewApp(version, commit, date, path string) (*App, error)

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) Close

func (a *App) Close() error

Close ensures all app resources have been closed.

func (*App) Context

func (a *App) Context() context.Context

Context returns the root context.Context for the app.

func (*App) Init

func (a *App) Init() error

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 CleanupFunc added in v0.3.0

type CleanupFunc func() error

type Config

type Config struct {
	ConfigPath string
	Color      bool   `yaml:"color" env:"ENVCTL_COLOR" default:"true"`
	Debug      bool   `yaml:"debug" env:"ENVCTL_DEBUG"`
	DotEnv     bool   `yaml:"dotenv" env:"ENVCTL_DOTENV" default:"false"`
	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"`
	Environments []Environment `yaml:"environments"`
}

func NewConfigFromPath

func NewConfigFromPath(path string) (*Config, error)

NewConfigFromPath returns a new config for the file at path.

func NewTestConfig

func NewTestConfig() (*Config, error)

NewTestConfig returns a new Config for unit tests populated with default values.

func (*Config) EnvironmentNames added in v0.3.0

func (c *Config) EnvironmentNames() []string

type DotEnvService added in v0.3.0

type DotEnvService struct {
	// contains filtered or unexported fields
}

func NewDotEnvService added in v0.3.0

func NewDotEnvService(path string) *DotEnvService

func (*DotEnvService) Create added in v0.3.0

func (s *DotEnvService) Create(vars models.Vars, args []string) (models.Vars, []string, CleanupFunc, error)

type Environment added in v0.3.0

type Environment struct {
	Name    string      `yaml:"name"`
	Extends []string    `yaml:"extends"`
	Vars    models.Vars `yaml:"vars"`
}

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

type Logger

type Logger struct {
	*log.Logger
}

Logger is a simple wrapper around the charmbracelet/log package.

func NewLogger

func NewLogger(ios *ui.IOStreams, config *Config) *Logger

NewLogger returns a new Logger.

type Meta

type Meta struct {
	BuildCommit    string
	BuildTime      time.Time
	BuildGoVersion string
	BuildVersion   string
	BuildChecksum  string
	Version        string
	GOOS           string
	GOARCH         string
}

Meta contains application metadata (version, os, build info, etc).

func NewMeta

func NewMeta(version, commit, date string) *Meta

NewMeta returns a new Meta struct.

Jump to

Keyboard shortcuts

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