Skip to content

Commit

Permalink
add verify
Browse files Browse the repository at this point in the history
  • Loading branch information
Hubert Liu committed Jan 7, 2014
1 parent d5c1d3d commit 06160c4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
35 changes: 30 additions & 5 deletions lib/capistrano/ops_works/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def initialize aws={}
end

def deploy args={}
create_deployment args
deploy_id = create_deployment(args)
verify deploy_id
end

def check args={}
Expand All @@ -28,14 +29,38 @@ def check args={}
stack_apps.data[:apps].collect { |a| a[:app_id] }.include? app_id
end

def history args={}
describe_deployments args
def history app_id
describe_deployments :app_id => app_id
end

def verify deploy_id
complete = false

until complete
finished_deploy = check_completion deploy_id
if finished_deploy
puts " [ #{Time.now} ] [ #{finished_deploy[:status]} ] #{finished_deploy[:deployment_id]} "
complete = true
else
sleep 15
end
end

end

private

def check_completion deploy_id
puts "verifying ..."

d = describe_deployments(:deployment_ids => [deploy_id])
the_deploy = d.first

return the_deploy if the_deploy.fetch(:completed_at, nil)
end

def describe_deployments args={}
client.describe_deployments(:app_id => args.fetch(:app_id))
client.describe_deployments(args).data[:deployments]
end

def describe args={}
Expand All @@ -60,7 +85,7 @@ def create_deployment args={}
},
:comment => comment,
:custom_json => custom_json
)
).data[:deployment_id]
end

end
Expand Down
7 changes: 6 additions & 1 deletion lib/capistrano/tasks/ops_works.rake
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ namespace :opsworks do
puts "app_id #{fetch(:app_id)} is valid" if opsworks.check(deployment_ids)
end

desc "Displays deployment history for app_id"
task :history do
puts opsworks.history(deployment_ids)
puts opsworks.history deployment_ids[:app_id]
end

task :verify do
deploy_id = "ec832d03-d96f-4f0c-ba75-ca702e293b6a"
puts opsworks.verify deploy_id
end
end

desc "Deploy to opsworks"
Expand Down

0 comments on commit 06160c4

Please sign in to comment.