diff --git a/lib/capistrano/hivequeen/capistrano_configuration.rb b/lib/capistrano/hivequeen/capistrano_configuration.rb index bb461f4..f277e72 100644 --- a/lib/capistrano/hivequeen/capistrano_configuration.rb +++ b/lib/capistrano/hivequeen/capistrano_configuration.rb @@ -15,6 +15,9 @@ # From the command line, use -s override=true to force a deployment set :override, false + # Don't mark deployments as canary deployments by default + set :canary, false + # Command to get the changes being deployed set :changelog_command do `git log #{current_commit}...#{real_revision} --pretty="%n%h %an: %s (%ar)" --stat --no-color` diff --git a/lib/capistrano/hivequeen/deploy.rb b/lib/capistrano/hivequeen/deploy.rb index 08f0305..7493c6f 100644 --- a/lib/capistrano/hivequeen/deploy.rb +++ b/lib/capistrano/hivequeen/deploy.rb @@ -7,6 +7,8 @@ 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" @@ -14,6 +16,14 @@ 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? @@ -22,7 +32,8 @@ params = { :task => tasks.join(' '), :commit => real_revision, - :override => override + :override => override, + :canary => canary, } if current_commit @@ -44,7 +55,7 @@ desc "[internal] Prompt if deploying the currently running commit, or if tests haven't passed" task :check_commit do - if environment.to_s == 'production' && !override + if environment.to_s == 'production' && !override && !canary if current_commit == real_revision banner = %q{ ______ _ _ _ ___ diff --git a/lib/capistrano/hivequeen/version.rb b/lib/capistrano/hivequeen/version.rb index 96e581f..b83f615 100644 --- a/lib/capistrano/hivequeen/version.rb +++ b/lib/capistrano/hivequeen/version.rb @@ -1,6 +1,6 @@ class HiveQueen class Version - @@version = '7.4.0' + @@version = '7.5.0' def self.to_s @@version