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

Reading .env or config.edn files by default #78

Open
crimsonhawk47 opened this issue Oct 25, 2022 · 4 comments
Open

Reading .env or config.edn files by default #78

crimsonhawk47 opened this issue Oct 25, 2022 · 4 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@crimsonhawk47
Copy link

crimsonhawk47 commented Oct 25, 2022

As a new user I've been struggling with this for a while. From what I can tell, system.edn uses aero to read environment variables, but it has no ability to read from actual .env files.

Since Integrant is so central to the kit workflow, it'd be great if there was already a bootstrap in place for reading from either .env or config.edn files. It's standard to have local environment files that aren't in version history. I, however, have had trouble finding a way to "export" these locally defined variables before integrant's config is read.

There doesn't appear to be anything for this at the moment.

@yogthos
Copy link
Collaborator

yogthos commented Oct 25, 2022

It might be worth asking regarding .env usage on the aero repo to see if there is a recommended way. With regards to using a config.edn, that should be addressed by the system.edn itself. Environment configuration is treated as part of the Integrant config.

@crimsonhawk47
Copy link
Author

crimsonhawk47 commented Oct 25, 2022

It might be worth asking regarding .env usage on the aero repo to see if there is a recommended way. With regards to using a config.edn, that should be addressed by the system.edn itself. Environment configuration is treated as part of the Integrant config.

I did find a half solution in the aero docs, but the way I implemented it is maybe not what others want. Maybe there's a version of this that could be included in the default kit bootstrap.

Obviously you wouldn't put secrets directly in system.edn. In Aero, they recommend not using the system environment either. They recommend using the #include macro to include other .edn files.

Here is what I did.

{:secrets #include #profile {:dev "../dev-config.edn"
                             :prod "../prod-config.edn"
                             :test "../test-config.edn"}}

I'm including the file directly in aero, which may not be desirable to others. The path has to be relative to system.edn unless you make a custom resolver. Others may want to make a custom resolver and include it in kit.guestbook.env/defaults, aliasing it with secrets.edn and then the system.edn file could just look like this.

{:secrets #include "secrets.edn"}

@yogthos
Copy link
Collaborator

yogthos commented Oct 26, 2022

I think that's a reasonable solution. Perhaps updating the environment page to mention this approach might be a good solution for now?

@markokocic markokocic added documentation Improvements or additions to documentation enhancement New feature or request labels Feb 28, 2023
@vollcheck
Copy link
Contributor

Here's the PR that addresses storing secrets. What is your opinion on making "secrets" file a part of the template?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants