class Jack::Config::Apply
Attributes
upload_name[R]
upload_path[R]
Public Class Methods
new(options={})
click to toggle source
Calls superclass method
# File lib/jack/config/apply.rb, line 10 def initialize(options={}) super @upload_path = "#{@saved_configs}/#{@env_name}-#{timestamp}.cfg.yml" @upload_name = extract_name(@upload_path) end
Public Instance Methods
clean_up()
click to toggle source
# File lib/jack/config/apply.rb, line 90 def clean_up return if @options[:dirty] FileUtils.rm_f(@upload_path) end
compare()
click to toggle source
# File lib/jack/config/apply.rb, line 46 def compare Diff.new(@options).run end
confirmation_message()
click to toggle source
# File lib/jack/config/apply.rb, line 34 def confirmation_message message = "Are you sure you want to update the environment with your the new config #{@local_config_path}?\n".colorize(:yellow) message += <<-EOL If the difference is not what you expected, you should say no. If you want to download the config from the environment and get #{@local_config_path} back in sync, you can use this command: $ jack get #{@env_name} $ jack get -h # for more info EOL message end
cp_to_save_configs()
click to toggle source
# File lib/jack/config/apply.rb, line 76 def cp_to_save_configs ensure_folder_exist(@saved_configs) FileUtils.cp("#{@root}/#{@local_config_path}", @upload_path) end
eb_config_put()
click to toggle source
for specs
# File lib/jack/config/apply.rb, line 86 def eb_config_put sh("#{eb_bin} config put#{eb_base_flags} #{upload_name}", @options) end
local_cfg_exist?()
click to toggle source
# File lib/jack/config/apply.rb, line 72 def local_cfg_exist? File.exist?("#{@root}/#{@local_config_path}") end
run()
click to toggle source
# File lib/jack/config/apply.rb, line 16 def run unless local_cfg_exist? UI.say "#{local_config_path} does not exist, nothing to upload" exit 0 end difference = compare if difference if confirm(confirmation_message) upload update_env else UI.say("Whew, that was close. EB Configuration was not updated.") end else UI.say("There was no difference detected from your #{@local_config_path} and what exists on the EB environment") end end
update_env()
click to toggle source
# File lib/jack/config/apply.rb, line 58 def update_env UI.say("Updating environment #{@env_name} with template #{upload_name}") begin eb.update_environment( environment_name: @env_name, template_name: upload_name ) unless @options[:noop] rescue Aws::ElasticBeanstalk::Errors::InvalidParameterValue => e puts "ERROR: Unable to update the environment: #{@env_name}".colorize(:red) puts e.message.colorize(:red) exit 1 end end
upload()
click to toggle source
# File lib/jack/config/apply.rb, line 50 def upload return false unless local_cfg_exist? UI.say("Copying #{@local_config_path} to #{@upload_path} for the upload") cp_to_save_configs upload_to_eb clean_up end
upload_to_eb()
click to toggle source
# File lib/jack/config/apply.rb, line 81 def upload_to_eb eb_config_put end