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

[WIP] Specify env file + envify on the config file #825

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

fabiosammy
Copy link
Contributor

@fabiosammy fabiosammy commented May 30, 2024

My main goal is to upload a custom env, entirely to the app or accessory.

Some projects have the .env committed inside of the git repository, and some of them have so much env that update his values, remove the keys or add new ones without changing the application code.

Also I put the "for_node" and "custom_env" to debug and understand the gem.

Lack of tests.

This is more a PR to discuss an approach rather than something ready to merge.

@fabiosammy fabiosammy changed the title [WIP] Specify env file + envify [WIP] Specify env file + envify on the config file May 30, 2024
Comment on lines +175 to +177
elsif envify_from_config = KAMAL.config.raw_config["envify"]
env_template_path = ".env.#{envify_from_config}.erb"
env_path = ".env.#{envify_from_config}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can extract this to his own PR.

delegate :argumentize, to: Kamal::Utils

def self.from_config(config:, secrets_file: nil)
secrets_keys = config.fetch("secret", [])
clear = config.fetch("clear", config.key?("secret") || config.key?("tags") ? {} : config)
env_key_config = config.class == Kamal::Configuration ? config.env : config.fetch("env", {})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "config" variable name is not too clear to what this represents. This is not "config", this is the "env" key from config with this values. Maybe we can also extract this to his own PR also?

Comment on lines +31 to +37
# TODO: More than one @env_file
# TODO: Considerer a merge between env_file and env
if @env_file
Dotenv::Environment.new(@env_file)
else
secrets_keys.to_h { |key| [ key, ENV.fetch(key) ] }
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main goal. Not sure how we can tackle this.
The reason behind this is to push an env file with "gazillions" of environment variables that can be related to the application code or not.

Any thoughts @djmb ? (sorry to tag you, but I saw that you did the last merges around here)

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

Successfully merging this pull request may close these issues.

1 participant