Documentation
¶
Index ¶
- Constants
- func ExtractComposeProjectName(envContent []byte) string
- func ExtractEnvVar(content []byte, key string) string
- func LoadSymfonyEnvFile(projectRoot string) error
- func ReadAll(projectRoot string) (map[string]string, error)
- func ReadAllForEnvironment(projectRoot, environment string) (map[string]string, error)
- func ReadComposeProjectName(projectRoot string) string
- func ReadEnvVar(path, key string) string
- func ReadValue(projectRoot, key string) (string, error)
- func ReadValues(projectRoot string, keys ...string) (map[string]string, error)
- func UpsertEnvVar(path, key, value string) error
- func WriteValue(projectRoot, key, value string) error
- func WriteValues(projectRoot string, values map[string]string) error
Constants ¶
const ComposeProjectNameEnvKey = "COMPOSE_PROJECT_NAME"
ComposeProjectNameEnvKey is the host-side Docker Compose project name written to the project .env (not .env.local). Compose loads .env automatically when commands run with Dir = project root.
Variables ¶
This section is empty.
Functions ¶
func ExtractComposeProjectName ¶
ExtractComposeProjectName returns the COMPOSE_PROJECT_NAME value from raw dotenv content, or "" when unset.
func ExtractEnvVar ¶
ExtractEnvVar returns the value of key in raw dotenv content, or "" when unset. Blank and comment lines are skipped, whitespace around key and value is trimmed, and the first assignment wins.
func LoadSymfonyEnvFile ¶
LoadSymfonyEnvFile loads the Symfony .env file from the project root.
func ReadAll ¶
ReadAll returns every variable defined across the project's Symfony env files, merged with Symfony precedence (.env.dist < .env < .env.local). An empty map is returned when no env file exists.
func ReadAllForEnvironment ¶
ReadAllForEnvironment is like ReadAll but additionally layers the environment-specific files on top, following Symfony precedence (.env.dist < .env < .env.local < .env.<env> < .env.<env>.local). An empty environment behaves exactly like ReadAll.
func ReadComposeProjectName ¶
ReadComposeProjectName returns the COMPOSE_PROJECT_NAME configured in the project's .env, or "" when the file or the key is missing.
func ReadEnvVar ¶
ReadEnvVar returns the value of key in the env file at path, or "" when the file or the key does not exist.
func ReadValue ¶
ReadValue returns the effective value of key in the project's Symfony env files. Precedence follows Symfony: .env.dist < .env < .env.local. An empty string is returned when the key is undefined or no env file exists.
func ReadValues ¶
ReadValues returns the resolved values for the requested keys. The returned map always contains every requested key; missing keys map to "".
func UpsertEnvVar ¶
UpsertEnvVar sets key to value in the env file at path, replacing an existing assignment or appending one. The file is created when missing; all other lines are preserved as-is.
func WriteValue ¶
WriteValue is a convenience wrapper around WriteValues for a single key.
func WriteValues ¶
WriteValues persists all entries into .env.local. Existing assignments are replaced in place to preserve surrounding lines, comments and formatting; missing keys are appended in deterministic (sorted) order. The file is created when it does not exist.
Types ¶
This section is empty.