Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Raise an error if canary deployments havent specified any hostss
Browse files Browse the repository at this point in the history
  • Loading branch information
pje committed Aug 3, 2018
1 parent 2c06e58 commit 0f9d6f7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/capistrano/hivequeen/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@
before "deploy:stage", "hivequeen:start"
before 'hivequeen:start', 'hivequeen:check_commit'
on :start, "hivequeen:require_environment", :except => HiveQueen.environment_names
on :start, "hivequeen:ensure_canary_specifies_hosts"

namespace :hivequeen do

desc "[internal] abort if no environment specified"
task :require_environment do
abort "No environment specified." if !exists?(:environment)
end

desc "[internal] abort if we're trying to do a canary deploy but HOSTS hasn't been defined"
task :ensure_canary_specifies_hosts do
# TODO: I suppose we could randomly select instance(s) in this case
if canary && !ENV.key?('HOSTS')
abort "You asked to do a canary deployment but didn't specify any hosts! \nPlease invoke like `cap HOSTS=foo.com deploy -s canary=true'"
end
end

desc "[internal] Start a deployment in hivequeen"
task :start do
# TODO: is there a better way to determine what cap tasks are running?
Expand Down

0 comments on commit 0f9d6f7

Please sign in to comment.