lib/simple_deploy/cli/deploy.rb in simple_deploy-0.6.4 vs lib/simple_deploy/cli/deploy.rb in simple_deploy-0.6.5

- old
+ new

@@ -1,12 +1,15 @@ require 'trollop' module SimpleDeploy module CLI + class Deploy + include Shared + def deploy - opts = Trollop::options do + @opts = Trollop::options do version SimpleDeploy::VERSION banner <<-EOS Execute deployment on given stack(s). @@ -46,34 +49,43 @@ :multi => true opt :quiet, "Quiet, do not send notifications" opt :internal, "Use internal IP for ssh commands" end - CLI::Shared.valid_options? :provided => opts, - :required => [:environment, :name] + valid_options? :provided => @opts, + :required => [:environment, :name] - logger = SimpleDeployLogger.new :log_level => opts[:log_level] + new_attributes = parse_attributes :attributes => @opts[:attributes] - new_attributes = CLI::Shared.parse_attributes :attributes => opts[:attributes], - :logger => logger - opts[:name].each do |name| + @opts[:name].each do |name| notifier = Notifier.new :stack_name => name, - :environment => opts[:environment], + :environment => @opts[:environment], :logger => logger - stack = Stack.new :environment => opts[:environment], + stack = Stack.new :environment => @opts[:environment], :name => name, :logger => logger, - :internal => opts[:internal] + :internal => @opts[:internal] proceed = true - proceed = stack.update :force => opts[:force], :attributes => new_attributes if new_attributes.any? + if new_attributes.any? + rescue_stackster_exceptions_and_exit do + proceed = stack.update :force => @opts[:force], + :attributes => new_attributes + end + end + + stack.wait_for_stable + if proceed - notifier.send_deployment_start_message unless opts[:quiet] - if stack.deploy opts[:force] - notifier.send_deployment_complete_message unless opts[:quiet] + notifier.send_deployment_start_message unless @opts[:quiet] + + result = stack.deploy @opts[:force] + + if result + notifier.send_deployment_complete_message unless @opts[:quiet] else logger.error "Deployment to #{name} did not complete succesfully." exit 1 end else @@ -81,8 +93,18 @@ exit 1 end end end + + def logger + @logger ||= SimpleDeployLogger.new :log_level => @opts[:log_level] + end + + def command_summary + 'Execute deployment on given stack(s)' + end + end + end end