| Crates.io | activate |
| lib.rs | activate |
| version | 0.5.3 |
| created_at | 2024-02-06 22:08:27.138551+00 |
| updated_at | 2024-11-26 19:42:33.848753+00 |
| description | A tool to manage environment-specific configurations. Simplifying working across various settings like Development, Testing, Production, etc. |
| homepage | |
| repository | https://github.com/mcmah309/activate |
| max_upload_size | |
| id | 1129534 |
| size | 57,913 |
A tool to manage environment-specific configurations. Simplifying working across various settings like Development, Testing, Production, etc.
Code in different environments such as Dev, QA, Prod, etc. may need various configurations to run. The solution often used is loading environment variables or property files at build or run time. This by itself has a few drawbacks:
activate solves all these problems.
active.toml file declaratively defines environments.Different environments like Dev, QA, etc. may have assets, data files, executables, or program files that should be used in each. All of these can be switched over at once. e.g.
[dev.links]
"app/data" = "path/to/dev/data"
[qa.links]
"app/data" = "path/to/qa/data"
The result of the above is app/data is created and symlinked to the file or directory of the active environment.
Often each environment has specific environment variables. This can be easily defined. e.g.
[dev.env]
HOST = "localhost"
PORT = 3000
[qa.env]
HOST = "178.32.44.2"
PORT = 443
To load an environment into the current shell, and unload any activate environment, run
eval "$(activate <name>)"`
Consider adding the following to ~/.bashrc as a shortcut
a() {
eval "$(activate "$@")";
}
Then environments can be easily loaded with an even shorter command
a dev
.env,configmap,env.jsonand files, representing the active environment, are also created in the.activate/activedirectory for convenient use.
activate.toml files can be distributed across a codebase, where each application has its own
activate.toml file. From the root of the repo everything can be switched together with the -d
flag. e.g.
activate -d <name>
Any directory/subdirectory (respecting .gitignore) with an activate.toml file is switched to <name>.
activate.toml Schema[<ENV_NAME>.env]
<ENV_VAR_NAME> = <ENV_VAR_VALUE>
[<ENV_NAME>.links]
"<LINK_PATH_FROM_ROOT>" = "<SOURCE_PATH_FROM_ROOT>"
release_ver=<INSERT_CURRENT_VERSION> # e.g. release_ver='v0.5.0'
deb_file="activate_$(echo $release_ver | sed 's/^v//')-1_amd64.deb"
curl -LO https://github.com/mcmah309/activate/releases/download/$release_ver/$deb_file
dpkg -i "$deb_file"
cargo install activate