Class: PcfBlueGreen::SharedDeployFunctions
- Inherits:
-
Object
- Object
- PcfBlueGreen::SharedDeployFunctions
- Defined in:
- lib/pcf_blue_green.rb
Instance Method Summary collapse
- #blue_green_deploy ⇒ Object
- #env_var_manifest_update ⇒ Object
-
#initialize ⇒ SharedDeployFunctions
constructor
A new instance of SharedDeployFunctions.
Constructor Details
#initialize ⇒ SharedDeployFunctions
Returns a new instance of SharedDeployFunctions.
11 12 13 14 15 16 17 18 |
# File 'lib/pcf_blue_green.rb', line 11 def initialize cmd = "echo $(gem which pcf_blue_green)" shell = Mixlib::ShellOut.new(cmd) shell.run_command gem_path = shell.stdout sdf_path = gem_path.gsub("pcf_blue_green.rb\n", "shared-deploy-functions.sh") @source_cmd = "source \'#{sdf_path}\'" end |
Instance Method Details
#blue_green_deploy ⇒ Object
20 21 22 23 |
# File 'lib/pcf_blue_green.rb', line 20 def blue_green_deploy status = bash("#{@source_cmd} && blue-green") raise PcfBlueGreen::BlueGreenDeployFailed unless status end |
#env_var_manifest_update ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pcf_blue_green.rb', line 25 def env_var_manifest_update bash("#{@source_cmd} && cf-setup") manifest_file_path = ENV['cf_manifest'] app = ENV['cf_app'] tmp_json ='' command = 'cf curl /v2/apps' shell = Mixlib::ShellOut.new(command) shell.run_command tmp_stdout = JSON.parse(shell.stdout) tmp_stdout['resources'].each do |resource| tmp_json = resource if resource['entity']['name'] == app end environments = tmp_json['entity']['environment_json'].map { |k,v| [k, "'#{v}'"]}.to_h open(manifest_file_path, 'a') do |f| environments.each do |env| f.puts "\s\s\s\s#{env.join(': ')}" end end end |