dual_burner 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/README.md +7 -1
- data/Rakefile +3 -3
- data/dual_burner.gemspec +1 -1
- data/exe/dual_burner +1 -1
- data/lib/dual_burner.rb +2 -0
- data/lib/dual_burner/base_command.rb +23 -11
- data/lib/dual_burner/base_heroku_command.rb +15 -0
- data/lib/dual_burner/commands/deployer.rb +8 -10
- data/lib/dual_burner/commands/heroku_config.rb +4 -14
- data/lib/dual_burner/commands/heroku_join.rb +13 -0
- data/lib/dual_burner/commands/last_release.rb +0 -1
- data/lib/dual_burner/configuration.rb +1 -1
- data/lib/dual_burner/runner.rb +21 -9
- data/lib/dual_burner/version.rb +1 -1
- metadata +14 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1d8c2c25e1bcce734886cfcda729cafd83e81d0
|
4
|
+
data.tar.gz: 6ec0cf8e2238eb616a706542cef5e7042246a77a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbe353d8e66511ae3e5556b2fa362f662f0bc4c7a7a6f96a6ea559048670fcfb03c2ebf41c82b78f2eb5a95c9711bef36d3486ac34da4b67b59194bb3c8993d0
|
7
|
+
data.tar.gz: db3c3384cd97b8204674d0f3372962737237cb74ef19ab08c4187e550154dbd7b21d74783ad84bf1334d4197acc64f2547253304f65121d6729d9b791f2aed73
|
data/.rubocop.yml
CHANGED
@@ -13,7 +13,7 @@ Metrics/LineLength:
|
|
13
13
|
Max: 120
|
14
14
|
|
15
15
|
Metrics/MethodLength:
|
16
|
-
Max:
|
16
|
+
Max: 40
|
17
17
|
|
18
18
|
Metrics/ParameterLists:
|
19
19
|
Max: 6
|
@@ -21,5 +21,8 @@ Metrics/ParameterLists:
|
|
21
21
|
Style/Documentation:
|
22
22
|
Enabled: false
|
23
23
|
|
24
|
+
Style/FrozenStringLiteralComment:
|
25
|
+
Enabled: false
|
26
|
+
|
24
27
|
Style/SignalException:
|
25
28
|
Enabled: false
|
data/README.md
CHANGED
@@ -89,7 +89,13 @@ You can pass in file locations of your deploy configuration if it is not under `
|
|
89
89
|
|
90
90
|
You can verify that all versions are consistent with the following command.
|
91
91
|
|
92
|
-
`dual_burner last_release
|
92
|
+
`dual_burner last_release -e wms_testing`
|
93
|
+
|
94
|
+
## Joining Heroku Apps
|
95
|
+
|
96
|
+
You can join all Heroku apps in a cluster.
|
97
|
+
|
98
|
+
`dual_burner join -e wms_testing`
|
93
99
|
|
94
100
|
## Heroku Config Management
|
95
101
|
|
data/Rakefile
CHANGED
data/dual_burner.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'colorize', '~> 0.7'
|
23
23
|
spec.add_dependency 'thor', '~> 0.19'
|
24
24
|
|
25
|
-
spec.add_development_dependency 'bundler', '
|
25
|
+
spec.add_development_dependency 'bundler', '>= 1.9.5', '< 2.0'
|
26
26
|
spec.add_development_dependency 'rake', '~> 10.0'
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
28
|
spec.add_development_dependency 'pry'
|
data/exe/dual_burner
CHANGED
data/lib/dual_burner.rb
CHANGED
@@ -5,7 +5,9 @@ require 'dual_burner/configuration'
|
|
5
5
|
require 'dual_burner/configuration_error'
|
6
6
|
require 'dual_burner/environment_not_found_error'
|
7
7
|
require 'dual_burner/base_command'
|
8
|
+
require 'dual_burner/base_heroku_command'
|
8
9
|
require 'dual_burner/commands/deployer'
|
9
10
|
require 'dual_burner/commands/heroku_config'
|
11
|
+
require 'dual_burner/commands/heroku_join'
|
10
12
|
require 'dual_burner/commands/last_release'
|
11
13
|
require 'dual_burner/runner'
|
@@ -15,12 +15,12 @@ module DualBurner
|
|
15
15
|
protected
|
16
16
|
|
17
17
|
def apps
|
18
|
-
@apps ||=
|
18
|
+
@apps ||= apps_for_environment
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def apps_for_environment
|
22
22
|
raise ArgumentError, 'ENV IS NOT PRESENT!' if env.nil?
|
23
|
-
raise DualBurner::ConfigurationError, 'CONFIG IS NOT PRESENT!' unless File.
|
23
|
+
raise DualBurner::ConfigurationError, 'CONFIG IS NOT PRESENT!' unless File.exist?(configuration.deploy_file)
|
24
24
|
config = YAML.load(File.read(configuration.deploy_file))[env]
|
25
25
|
raise DualBurner::EnvironmentNotFoundError, "ENV #{env} NOT FOUND!" if config.nil?
|
26
26
|
config.map { |c| app_instance(c) }
|
@@ -49,10 +49,22 @@ module DualBurner
|
|
49
49
|
)
|
50
50
|
end
|
51
51
|
|
52
|
+
def verify_results_exit_0(results, context:)
|
53
|
+
if !all_processes_exit_0?(results.map(&:value))
|
54
|
+
puts "The following #{context} failed:".red.blink
|
55
|
+
results.select { |r| r.value.exitstatus != 0 }.each do |r|
|
56
|
+
puts "#{r.app.name} failed with #{r.value.exitstatus}.".red
|
57
|
+
end
|
58
|
+
false
|
59
|
+
else
|
60
|
+
true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
52
64
|
##
|
53
65
|
# Determine of all processes return exit 0 status.
|
54
66
|
def all_processes_exit_0?(processes)
|
55
|
-
if processes.
|
67
|
+
if processes.count { |p| p.exitstatus == 0 } == processes.size
|
56
68
|
true
|
57
69
|
else
|
58
70
|
false
|
@@ -67,9 +79,9 @@ module DualBurner
|
|
67
79
|
puts "#{app.name} #{Time.now} - executing command [#{command}]".send(app.color)
|
68
80
|
|
69
81
|
result = result_instance
|
70
|
-
Open3.popen2e(command) do |
|
82
|
+
Open3.popen2e(command) do |_stdin, stdout_and_stderr, thread|
|
71
83
|
Thread.new do
|
72
|
-
|
84
|
+
while (raw_line = stdout_and_stderr.gets)
|
73
85
|
# There is a newline automatically appended from the stream.
|
74
86
|
print "#{app.name} #{Time.now} - #{raw_line}".send(app.color) if print_lines
|
75
87
|
result.lines << raw_line
|
@@ -96,24 +108,24 @@ module DualBurner
|
|
96
108
|
# We have different commit hashes, env variables, whatever, we need to warn.
|
97
109
|
if values.uniq.size > 1
|
98
110
|
puts "Inconsistent #{context} found!".red.blink
|
99
|
-
puts
|
111
|
+
puts ''
|
100
112
|
|
101
113
|
results.each_with_index do |result, i|
|
102
114
|
print result.app.name.send(result.app.color)
|
103
115
|
print " is at #{context} "
|
104
116
|
print values[i].bold
|
105
|
-
puts
|
117
|
+
puts ''
|
106
118
|
end
|
107
119
|
|
108
120
|
false
|
109
121
|
# Everything is fine!
|
110
122
|
elsif values.uniq.size == 1
|
111
|
-
puts
|
112
|
-
print
|
123
|
+
puts ''
|
124
|
+
print 'All apps '
|
113
125
|
print results.map { |r| r.app.name }.join(', ').bold
|
114
126
|
print " are on #{context} "
|
115
127
|
print values.first.green
|
116
|
-
puts
|
128
|
+
puts ''
|
117
129
|
|
118
130
|
true
|
119
131
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DualBurner
|
2
|
+
class BaseHerokuCommand < BaseCommand
|
3
|
+
protected
|
4
|
+
|
5
|
+
def execute_command_with_apps
|
6
|
+
results = []
|
7
|
+
apps.each do |app|
|
8
|
+
raise DualBurner::ConfigurationError, 'HEROKU APP NAME NOT CONFIGURED' if app.heroku_app_name.nil?
|
9
|
+
command = yield(app)
|
10
|
+
results << execute_command(command, app: app)
|
11
|
+
end
|
12
|
+
results
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -26,9 +26,7 @@ module DualBurner
|
|
26
26
|
# Wait for all commands to complete.
|
27
27
|
threads.map(&:join)
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
all_processes_exit_0?(results.map { |r| r.value })
|
29
|
+
verify_results_exit_0(results, context: 'deploys')
|
32
30
|
end
|
33
31
|
|
34
32
|
def build_deploy_command(app:, git_reference:)
|
@@ -43,17 +41,17 @@ module DualBurner
|
|
43
41
|
# Show the user what Heroku apps are involved.
|
44
42
|
puts "\n"
|
45
43
|
|
46
|
-
print
|
44
|
+
print 'You are about to deploy '
|
47
45
|
print git_reference.bold
|
48
|
-
print
|
46
|
+
print ' to '
|
49
47
|
print env.bold
|
50
|
-
print
|
51
|
-
print apps.map
|
48
|
+
print ' on the following Apps: '
|
49
|
+
print apps.map(&:name).join(', ').bold
|
52
50
|
|
53
51
|
puts "\n" * 2
|
54
52
|
|
55
53
|
# Show the user what we are about to do on their machine.
|
56
|
-
puts
|
54
|
+
puts 'These commands will be executed:'
|
57
55
|
apps.each do |app|
|
58
56
|
puts build_deploy_command(app: app, git_reference: git_reference).send(app.color).bold
|
59
57
|
end
|
@@ -65,10 +63,10 @@ module DualBurner
|
|
65
63
|
puts "If this is ok, please type in the following: #{challenge}"
|
66
64
|
response = STDIN.gets.chomp
|
67
65
|
if challenge != response
|
68
|
-
puts
|
66
|
+
puts 'You didn\'t enter the right challenge. Aborting!'.red.bold
|
69
67
|
exit(1)
|
70
68
|
else
|
71
|
-
puts
|
69
|
+
puts 'Preparing to deploy....'
|
72
70
|
end
|
73
71
|
end
|
74
72
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module DualBurner
|
2
2
|
module Commands
|
3
|
-
class HerokuConfig < DualBurner::
|
3
|
+
class HerokuConfig < DualBurner::BaseHerokuCommand
|
4
4
|
def get(key:)
|
5
5
|
results = execute_command_with_apps do |app|
|
6
6
|
"heroku config:get #{key} -a #{app.heroku_app_name}"
|
@@ -11,28 +11,18 @@ module DualBurner
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def set(
|
14
|
+
def set(key:, value:)
|
15
15
|
results = execute_command_with_apps do |app|
|
16
16
|
"heroku config:set #{key}=#{value} -a #{app.heroku_app_name}"
|
17
17
|
end
|
18
|
-
all_processes_exit_0?(results.map
|
18
|
+
all_processes_exit_0?(results.map(&:value))
|
19
19
|
end
|
20
20
|
|
21
21
|
def unset(key:)
|
22
22
|
results = execute_command_with_apps do |app|
|
23
23
|
"heroku config:unset #{key} -a #{app.heroku_app_name}"
|
24
24
|
end
|
25
|
-
all_processes_exit_0?(results.map
|
26
|
-
end
|
27
|
-
|
28
|
-
def execute_command_with_apps
|
29
|
-
results = []
|
30
|
-
apps.each do |app|
|
31
|
-
raise DualBurner::ConfigurationError, 'HEROKU APP NAME NOT CONFIGURED' if app.heroku_app_name.nil?
|
32
|
-
command = yield(app)
|
33
|
-
results << execute_command(command, app: app)
|
34
|
-
end
|
35
|
-
results
|
25
|
+
all_processes_exit_0?(results.map(&:value))
|
36
26
|
end
|
37
27
|
end
|
38
28
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module DualBurner
|
2
|
+
module Commands
|
3
|
+
class HerokuJoin < DualBurner::BaseHerokuCommand
|
4
|
+
def join
|
5
|
+
results = execute_command_with_apps do |app|
|
6
|
+
"heroku join -a #{app.heroku_app_name}"
|
7
|
+
end
|
8
|
+
|
9
|
+
verify_results_exit_0(results, context: 'Heroku app join')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/dual_burner/runner.rb
CHANGED
@@ -2,9 +2,9 @@ require 'dual_burner'
|
|
2
2
|
|
3
3
|
module DualBurner
|
4
4
|
class Runner < Thor
|
5
|
-
|
6
|
-
ENV_DESC = 'The cluster environment.'.freeze unless defined?(ENV_DESC)
|
7
5
|
CONFIG_DESC = 'Your configuration file if not .config/dual_burner.yml'.freeze unless defined?(CONFIG_DESC)
|
6
|
+
ENV_DESC = 'The cluster environment.'.freeze unless defined?(ENV_DESC)
|
7
|
+
GIT_DESC = 'The git reference to deploy.'.freeze unless defined?(GIT_DESC)
|
8
8
|
HEROKU_KEY_DESC = 'The key to set on the Heroku app.'.freeze unless defined?(HEROKU_KEY_DESC)
|
9
9
|
|
10
10
|
desc 'last_release', 'Finds the HEAD git revision for all applications in cluster <ENV>.'
|
@@ -14,18 +14,21 @@ module DualBurner
|
|
14
14
|
::DualBurner::Commands::LastRelease.new(
|
15
15
|
env: options.fetch('env'),
|
16
16
|
configuration: get_configuration_instance(deploy_file: options['config'])
|
17
|
-
).verify_apps
|
17
|
+
).verify_apps
|
18
18
|
end
|
19
19
|
|
20
20
|
desc 'deploy', 'Deploy <REF> to all applications in cluster <ENV>.'
|
21
21
|
method_option :env, aliases: '-e', type: :string, required: true, desc: ENV_DESC
|
22
22
|
method_option :config, aliases: '-c', type: :string, optional: true, desc: CONFIG_DESC
|
23
|
-
method_option :git_reference, aliases: '-g', default: 'master', type: :string,
|
23
|
+
method_option :git_reference, aliases: '-g', default: 'master', type: :string, optional: true, desc: GIT_DESC
|
24
|
+
method_option :join, aliases: '-j', default: true, optional: true, desc: 'Join all applications before deploy.'
|
24
25
|
def deploy
|
26
|
+
invoke(:join, [], env: options['env']) if options['join'] == true
|
27
|
+
|
25
28
|
::DualBurner::Commands::Deployer.new(
|
26
29
|
env: options.fetch('env'),
|
27
30
|
configuration: get_configuration_instance(deploy_file: options['config'])
|
28
|
-
).deploy(git_reference: options['git_reference'])
|
31
|
+
).deploy(git_reference: options['git_reference'])
|
29
32
|
end
|
30
33
|
|
31
34
|
desc 'config_set', 'Set <KEY> to <VALUE> for all Heroku appslocations in cluster <ENV>.'
|
@@ -37,7 +40,7 @@ module DualBurner
|
|
37
40
|
::DualBurner::Commands::HerokuConfig.new(
|
38
41
|
env: options.fetch('env'),
|
39
42
|
configuration: get_configuration_instance(deploy_file: options['config'])
|
40
|
-
).set(key: options.fetch('key'), value: options['value'])
|
43
|
+
).set(key: options.fetch('key'), value: options['value'])
|
41
44
|
end
|
42
45
|
|
43
46
|
desc 'config_get', 'Get <KEY> for all Heroku appslocations in cluster <ENV>.'
|
@@ -48,7 +51,7 @@ module DualBurner
|
|
48
51
|
::DualBurner::Commands::HerokuConfig.new(
|
49
52
|
env: options.fetch('env'),
|
50
53
|
configuration: get_configuration_instance(deploy_file: options['config'])
|
51
|
-
).get(key: options.fetch('key'))
|
54
|
+
).get(key: options.fetch('key'))
|
52
55
|
end
|
53
56
|
|
54
57
|
desc 'config_unset', 'Unset <KEY> for all Heroku appslocations in cluster <ENV>.'
|
@@ -59,13 +62,22 @@ module DualBurner
|
|
59
62
|
::DualBurner::Commands::HerokuConfig.new(
|
60
63
|
env: options.fetch('env'),
|
61
64
|
configuration: get_configuration_instance(deploy_file: options['config'])
|
62
|
-
).unset(key: options.fetch('key'))
|
65
|
+
).unset(key: options.fetch('key'))
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'join', 'Join all Heroku appslocations in cluster <ENV>.'
|
69
|
+
method_option :env, aliases: '-e', type: :string, required: true, desc: ENV_DESC
|
70
|
+
def join
|
71
|
+
::DualBurner::Commands::HerokuJoin.new(
|
72
|
+
env: options.fetch('env'),
|
73
|
+
configuration: get_configuration_instance(deploy_file: options['config'])
|
74
|
+
).join
|
63
75
|
end
|
64
76
|
|
65
77
|
protected
|
66
78
|
|
67
79
|
def get_configuration_instance(deploy_file: nil)
|
68
|
-
deploy_file ||=
|
80
|
+
deploy_file ||= File.join(Dir.getwd, 'config', 'dual_burner.yml')
|
69
81
|
|
70
82
|
c = DualBurner::Configuration.new
|
71
83
|
c.deploy_file = deploy_file
|
data/lib/dual_burner/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dual_burner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blue Apron Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -42,16 +42,22 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.9.5
|
48
|
+
- - "<"
|
46
49
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
50
|
+
version: '2.0'
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.9.5
|
58
|
+
- - "<"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
60
|
+
version: '2.0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rake
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,8 +150,10 @@ files:
|
|
144
150
|
- exe/dual_burner
|
145
151
|
- lib/dual_burner.rb
|
146
152
|
- lib/dual_burner/base_command.rb
|
153
|
+
- lib/dual_burner/base_heroku_command.rb
|
147
154
|
- lib/dual_burner/commands/deployer.rb
|
148
155
|
- lib/dual_burner/commands/heroku_config.rb
|
156
|
+
- lib/dual_burner/commands/heroku_join.rb
|
149
157
|
- lib/dual_burner/commands/last_release.rb
|
150
158
|
- lib/dual_burner/configuration.rb
|
151
159
|
- lib/dual_burner/configuration_error.rb
|