Class: Lolipop::Mc::Starter::Rails::CheckItem::EnvRailsKey
- Defined in:
- lib/lolipop/mc/starter/rails/check_item/env_rails_key.rb
Constant Summary
Constants inherited from Base
Base::NOCHECK, Base::SKIPCHECK
Instance Method Summary collapse
Methods inherited from Base
#desc, #dump_config, #initialize, #item_name, #load_config
Constructor Details
This class inherits a constructor from Lolipop::Mc::Starter::Rails::CheckItem::Base
Instance Method Details
#check ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lolipop/mc/starter/rails/check_item/env_rails_key.rb', line 7 def check key_path = "#{Dir.pwd}/config/master.key" raise 'config/master.keyがありません' unless File.exist?(key_path) config = load_config ssh_command = config['ssh'] if ssh_command == NOCHECK raise 'SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください' end begin stdout = `#{ssh_command} env` rescue => e raise "SSHコマンドの実行に失敗しました。SSH接続の設定を確認してください #{e.message}" end raise '環境変数 `RAILS_MASTER_KEY` が設定されていません' unless stdout.match(/RAILS_MASTER_KEY/) key = File.read(key_path) raise '環境変数 `RAILS_MASTER_KEY` の値がconfig/master.keyと異なります' unless stdout.match("RAILS_MASTER_KEY=#{key}") '環境変数 `RAILS_MASTER_KEY` が設定されています' end |
#hint ⇒ Object
27 28 29 30 31 |
# File 'lib/lolipop/mc/starter/rails/check_item/env_rails_key.rb', line 27 def hint puts 'Railsではconfig/credentials.yml.encの情報を復号化して読み取るためにconfig/master.keyが必要です' puts 'config/master.keyを本番環境に設置する代わりに、環境変数 `RAILS_MASTER_KEY` にconfig/master.keyの値を設定することが可能です' puts 'マネージドクラウドのプロジェクト詳細の `環境変数の設定と管理` で環境変数 `RAILS_MASTER_KEY` にconfig/master.keyの値を追加してください' end |