Documentation
¶
Overview ¶
Package env implements multi-environment management for nSelf projects. Each environment (dev, staging, prod) has its own .env file, Docker project name, network, and volume namespace to enable side-by-side operation.
Index ¶
- Constants
- Variables
- func ActiveEnv(projectDir string) string
- func Copy(projectDir, fromEnv, toEnv string) error
- func DockerProjectName(projectName, env string) string
- func SetActiveEnv(projectDir, env string) error
- func ShiftPort(basePort int, env string) int
- type DiffEntry
- type EnvInfo
- type KeyValue
Constants ¶
const DefaultEnv = "dev"
DefaultEnv is the environment used when none is explicitly set.
Variables ¶
var PortShifts = map[string]int{
"dev": 0,
"staging": 100,
"prod": 200,
}
PortShifts maps environment names to port offset values. dev=default, staging=+100, prod=+200.
Functions ¶
func ActiveEnv ¶
ActiveEnv reads the currently active environment from .nself/active_env. Returns DefaultEnv if the file does not exist.
func DockerProjectName ¶
DockerProjectName returns the Docker Compose project name for a given project and environment: nself-{project}-{env}.
func SetActiveEnv ¶
SetActiveEnv writes the active environment to .nself/active_env.
Types ¶
type DiffEntry ¶
type DiffEntry struct {
Key string
ValueA string // value in env A (empty = not present)
ValueB string // value in env B (empty = not present)
}
DiffEntry describes a difference between two environments.