Closed kwerle closed 6 months ago
I would like to be able to load secrets if the key was provided or do nothing if not. To this end, I would like to
def load_sekrets <do stuff with Sekrets.settings_for> end load_sekrets if Sekrets.key_provided?
Where Sekrets.key_provided? will return true if it is able to find the key in one of the usual places without resorting to Sekrets.ask.
I'm happy to PR this if you think this is a worthwhile feature.
Specific background: My rails 4.2 sekrets.rb initializer looks like:
def merge_sekrets(sekrets) secrets = sekrets['shared'] || {} secrets.merge!(sekrets[Rails.env] || {}) Rails.application.secrets.merge!(secrets).symbolize_keys! end settings = Sekrets.settings_for('./config/sekrets.yml.enc') merge_sekrets(settings)
I don't really want to have to provide the secret key to make the dev/test environments work. But I probably do for staging, production.
you may use, instead:
key = Sekrets.key_for('./config/sekrets.yml.enc', prompt: false) if key settings = Sekrets.settings_for('./config/sekrets.yml.enc', key: key) merge_sekrets(settings) end
I would like to be able to load secrets if the key was provided or do nothing if not. To this end, I would like to
Where Sekrets.key_provided? will return true if it is able to find the key in one of the usual places without resorting to Sekrets.ask.
I'm happy to PR this if you think this is a worthwhile feature.
Specific background: My rails 4.2 sekrets.rb initializer looks like:
I don't really want to have to provide the secret key to make the dev/test environments work. But I probably do for staging, production.