[ANN] Announcing ConfigEnv.jl - your secrets manager

I am pleased to announce ConfigEnv.jl, an environment configuration package that loads environment variables from a .env file into ENV . This package was inspired by python-dotenv library and the Twelve-Factor App methodology.

Its intended usage is when you have some secrets like database passwords, which shouldn’t leak into public space, and at the same time, you want to have simple and flexible management of such secrets. Another usage possibility is when some library uses environmental variables for configuration and you want to configure them without editing your .bashrc or Windows environment.

It comes with the following features

  • load data from configuration files to ENV in overwriting and non-overwriting mode;
  • read data from String and IO objects;
  • merge data from different configuration files;
  • template variables with an arbitrary templating depth and introspection tools for discovering unresolved templates and circular dependencies.

Together these features provide a foundation of a very flexible manager, which can be used in a most simple scenario, when you just want to populate ENV with your password, to the possibility of switching your remote servers from production to test mode without changing a single line of code or building complicated hierarchical environments.

As an example, this is how you can use this package to simplify sending messages in Telegram.

First of all, prepare .env file

# .env
TELEGRAM_BOT_TOKEN = <YOUR TELEGRAM BOT TOKEN>
TELEGRAM_BOT_CHAT_ID = <YOUR TELEGRAM CHAT ID>

and now you can use dotenv function to automatically set up Telegram client.

using Telegram, Telegram.API
using ConfigEnv

dotenv()

# uses ENV["TELEGRAM_BOT_TOKEN"] and ENV["TELEGRAM_BOT_CHAT_ID"] internally
sendMessage(text = "Hello, world!")

More complicated examples of the usage can be found in Examples section of the documentation.

20 Likes

Yes!!! This is what I have been searching for! Thanks @Skoffer ! Looking forward to trying it out more!

1 Like