Skip to content

Environment

Environment variable management and .env file loading.

3 modules

ModuleDescription
Get Environment VariableGet the value of an environment variable
Load .env FileLoad environment variables from a .env file
Set Environment VariableSet an environment variable in the current process

Modules

Get Environment Variable

env.get

Get the value of an environment variable

Parameters:

NameTypeRequiredDefaultDescription
namestringYes-Name of the environment variable
defaultstringNo-Default value if the variable is not set

Output:

FieldTypeDescription
namestringVariable name
valuestringVariable value (or default if not set)
existsbooleanWhether the variable exists in the environment

Example: Get HOME variable

yaml
name: HOME

Example: Get variable with default

yaml
name: MY_APP_PORT
default: 8080

Load .env File

env.load_dotenv

Load environment variables from a .env file

Parameters:

NameTypeRequiredDefaultDescription
pathstringYes.envPath to the .env file
overridebooleanNoFalseWhether to override existing environment variables

Output:

FieldTypeDescription
loaded_countnumberNumber of variables loaded
variablesarrayList of variable names that were loaded

Example: Load .env file

yaml
path: .env
override: false

Set Environment Variable

env.set

Set an environment variable in the current process

Parameters:

NameTypeRequiredDefaultDescription
namestringYes-Name of the environment variable to set
valuestringYes-Value to assign to the environment variable

Output:

FieldTypeDescription
namestringVariable name
valuestringNew value that was set
previous_valuestringPrevious value (null if not previously set)

Example: Set an environment variable

yaml
name: MY_APP_PORT
value: 3000

Released under the Apache 2.0 License.