Exenv v0.3.0 Exenv View Source
Loads env vars using an adapter-based approach.
Exenv dynamically assigns env vars on application start using whatever adapters
have been configured to run. By default, Exenv is setup to use the included
Exenv.Adapters.Dotenv
adapter - loading env vars from a .env
file in your
projects directory on startup.
Configuration
If you need to further configure Exenv - it is typically done via application config.
config :exenv, [
adapters: [
{Exenv.Adapters.Dotenv, [file: "path/to/.env"]}
]
]
You can simply list the adapters and any options you would like to pass to it
via {MyAdapter, opts}
- where opts
is a keyword list of options defined by
the adapter.
Alternatively, you can also configure Exenv to be used via your own supervision tree. In this case simply add the following to your config:
config :exenv, start_on_application: false
You can then add Exenv to your supervisor.
children = [
{Exenv, [adapters: [{Exenv.Adapters.Dotenv, [file: "path/to/.env"]}]]}
]
Encryption
Exenv has support for encryption out of the box. This allows you to keep an
encrypted secrets file checked into your repository. Please see Exenv.Encryption
for more details.
Link to this section Summary
Functions
Loads all env vars using the adapters defined within our config
Loads all env vars using the adapter config provided
Loads env vars using the adapter and options provided
Returns {:ok, binary}
, where binary is a binary data object that contains the
contents of path, or {:error, reason}
if an error occurs
Starts the Exenv process
Link to this section Types
on_load()
View Source
on_load() :: [{Exenv.Adapter.t(), Exenv.Adapter.result()}]
on_load() :: [{Exenv.Adapter.t(), Exenv.Adapter.result()}]
Link to this section Functions
load()
View Source
load() :: on_load()
load() :: on_load()
Loads all env vars using the adapters defined within our config.
load(adapters)
View Source
load(adapters :: [Exenv.Adapter.config()]) :: on_load()
load(adapters :: [Exenv.Adapter.config()]) :: on_load()
Loads all env vars using the adapter config provided.
load(adapter, opts)
View Source
load(adapter :: Exenv.Adapter.t(), opts :: keyword()) :: Exenv.Adapter.result()
load(adapter :: Exenv.Adapter.t(), opts :: keyword()) :: Exenv.Adapter.result()
Loads env vars using the adapter and options provided.
read_file(path, opts \\ []) View Source
Returns {:ok, binary}
, where binary is a binary data object that contains the
contents of path, or {:error, reason}
if an error occurs.
Options
:encryption
- options used to decrypt the binary result if required.
# Decrypts the file using the MASTER_KEY env var
[encryption: true]
# Decrypts the file using the master key file
[encryption: [master_key: "/path/to/master.key"]]
start_link(opts \\ [])
View Source
start_link(any()) :: Supervisor.on_start()
start_link(any()) :: Supervisor.on_start()
Starts the Exenv process.