Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special infisical-specific env var to test everything loaded correctly #2513

Open
gee-forr opened this issue Sep 30, 2024 · 2 comments
Open

Comments

@gee-forr
Copy link

Feature description

It would be amazing if Infisical could inject a special "back-office only" env var along with user-defined env vars so that we can determine if it loaded secrets correctly.

Why would it be useful?

background

We have a script that runs automatically when you cd into a directory with direnv. This script sets up a bunch of defaults, including install the infisical CLI if its not already installed.

It also loads secrets into the current shell by running eval $(infisical export --format=dotenv-export). This is great for DX, because developers don't need to do anything besides have a logged in infisical account, and cding into a project's dir will get everything ready for development.

how would we use this feature?

We would like to extend our envrc script to also throw an error if the env vars did not load correctly. As an Envkey refugee, we use to look for an __ENVKEY_LOADED env var and if it was there, we knew things loaded fine. If it was not there, we printed out a big red scary error, so that the dev could debug an Envkey issue instead of wasting time trying to figure out why their local dev environment is not working right.

Additional context

It would be great if infisical could add an __INFISICAL_LOADED env var with any non-blank value.

What would be even cooler is if there were also __INFISICAL_PROJECT and __INFISICAL_ENVIRONMENT env vars that contained the project and environment slug's respectively, which could help with throwing errors if the wrong env is being accidentally loaded.

@matzeeable
Copy link

Solved it this way:

INFISICAL_EXPORT=$(infisical export --format=dotenv-export)
eval $INFISICAL_EXPORT
__INFISICAL_LOADED=$(echo "$INFISICAL_EXPORT" | cut -d'=' -f1 | cut -d' ' -f2 | tr '\n' ',' | sed 's/,$//')

@gee-forr
Copy link
Author

gee-forr commented Oct 8, 2024

INFISICAL_EXPORT=$(infisical export --format=dotenv-export)
eval $INFISICAL_EXPORT
__INFISICAL_LOADED=$(echo "$INFISICAL_EXPORT" | cut -d'=' -f1 | cut -d' ' -f2 | tr '\n' ',' | sed 's/,$//')

Hey @matzeeable - this is nice DIY solution that should work until/if infisical implement it natively - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants