Class: LocalVault::CLI::RailsImport
- Inherits:
-
Object
- Object
- LocalVault::CLI::RailsImport
- Defined in:
- lib/localvault/cli/rails_import.rb
Overview
Finds a Rails app's credentials keys so they can be stored in the vault and injected as RAILS_MASTER_KEY instead of living in a file.
Reads only. Removing the key files is the operator's call — this reports what is still on disk and leaves it alone.
Defined Under Namespace
Classes: Key
Constant Summary collapse
- MASTER_KEY_PATH =
"config/master.key".freeze
- CREDENTIALS_PATH =
"config/credentials.yml.enc".freeze
Instance Method Summary collapse
-
#initialize(root = Dir.pwd) ⇒ RailsImport
constructor
A new instance of RailsImport.
-
#keys ⇒ Object
Every key file this app has: the default master key plus one per environment (config/credentials/production.key).
- #rails_app? ⇒ Boolean
Constructor Details
#initialize(root = Dir.pwd) ⇒ RailsImport
Returns a new instance of RailsImport.
14 15 16 |
# File 'lib/localvault/cli/rails_import.rb', line 14 def initialize(root = Dir.pwd) @root = root end |
Instance Method Details
#keys ⇒ Object
Every key file this app has: the default master key plus one per environment (config/credentials/production.key).
26 27 28 |
# File 'lib/localvault/cli/rails_import.rb', line 26 def keys [master_key, *environment_keys].compact end |
#rails_app? ⇒ Boolean
18 19 20 21 22 |
# File 'lib/localvault/cli/rails_import.rb', line 18 def rails_app? File.exist?(File.join(@root, CREDENTIALS_PATH)) || File.exist?(File.join(@root, MASTER_KEY_PATH)) || Dir.exist?(File.join(@root, "config/credentials")) end |