broadside 1.2.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +4 -0
- data/bin/broadside +4 -0
- data/lib/broadside/configuration/deploy_config.rb +52 -27
- data/lib/broadside/deploy/ecs_deploy.rb +14 -1
- data/lib/broadside/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1de9e1e538f010d28635f3fa1729f4ea8325583f
|
4
|
+
data.tar.gz: c7c2c7d1a3dc580a76a9e4793509ad1eff6f9e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73310a4a5dbd7bd54cf6a9dfbd93933acd91ba8b050c947b1726d89f45ac19f4155f15e82cdd556416168919fd15336dbd6946b99ac24caaf1d82d69c49bf8f9
|
7
|
+
data.tar.gz: 3ab6ffad553c01486c59ce3e27fa7446ace9e9ec9a5124aad6c168049be839fe5e0ab0994e42a7841a4749aeb1e91516d3b07f05c84036023f5a0b07aeaf0549
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 1.4.0
|
2
|
+
= [#42](https://github.com/lumoslabs/broadside/pull/42/files): Update the task definition when running bootstrap
|
3
|
+
|
4
|
+
# 1.3.0
|
5
|
+
- [#41](https://github.com/lumoslabs/broadside/pull/41/files): Introduce the concept of bootstrap commands, which are designed to be run when setting up a new server or environment.
|
6
|
+
|
1
7
|
# 1.2.1
|
2
8
|
- [#35](https://github.com/lumoslabs/broadside/pull/35/files): Allows logtail to display more than 10 lines
|
3
9
|
|
data/Gemfile
CHANGED
data/bin/broadside
CHANGED
@@ -44,6 +44,10 @@ end
|
|
44
44
|
|
45
45
|
desc 'Bootstrap your service and task definition from the configured definition.'
|
46
46
|
command :bootstrap do |b|
|
47
|
+
subcmd.desc 'Docker tag for application container'
|
48
|
+
subcmd.arg_name 'TAG'
|
49
|
+
subcmd.flag [:tag]
|
50
|
+
|
47
51
|
add_shared_deploy_configs(b)
|
48
52
|
end
|
49
53
|
|
@@ -24,15 +24,17 @@ module Broadside
|
|
24
24
|
:instance,
|
25
25
|
:lines,
|
26
26
|
:predeploy_commands,
|
27
|
+
:bootstrap_commands,
|
27
28
|
:service_config,
|
28
29
|
:task_definition_config
|
29
30
|
)
|
30
31
|
|
31
32
|
TARGET_ATTRIBUTE_VALIDATIONS = {
|
32
33
|
scale: ->(target_attribute) { validate_types([Fixnum], target_attribute) },
|
33
|
-
env_file: ->(target_attribute) { validate_types([String], target_attribute) },
|
34
|
+
env_file: ->(target_attribute) { validate_types([String, Array], target_attribute) },
|
34
35
|
command: ->(target_attribute) { validate_types([Array, NilClass], target_attribute) },
|
35
36
|
predeploy_commands: ->(target_attribute) { validate_predeploy_commands(target_attribute) },
|
37
|
+
bootstrap_commands: ->(target_attribute) { validate_bootstrap_commands(target_attribute) },
|
36
38
|
service_config: ->(target_attribute) { validate_types([Hash, NilClass], target_attribute) },
|
37
39
|
task_definition_config: ->(target_attribute) { validate_types([Hash, NilClass], target_attribute) }
|
38
40
|
}
|
@@ -49,6 +51,7 @@ module Broadside
|
|
49
51
|
@env_vars = nil
|
50
52
|
@command = nil
|
51
53
|
@predeploy_commands = DEFAULT_PREDEPLOY_COMMANDS
|
54
|
+
@bootstrap_commands = []
|
52
55
|
@instance = 0
|
53
56
|
@service_config = nil
|
54
57
|
@task_definition_config = nil
|
@@ -77,46 +80,68 @@ module Broadside
|
|
77
80
|
# Loads deploy target data using provided target
|
78
81
|
def load_target!
|
79
82
|
validate_targets!
|
80
|
-
|
81
|
-
|
82
|
-
unless env_file.absolute?
|
83
|
-
dir = config.file.nil? ? Dir.pwd : Pathname.new(config.file).dirname
|
84
|
-
env_file = env_file.expand_path(dir)
|
85
|
-
end
|
86
|
-
|
87
|
-
if env_file.exist?
|
88
|
-
vars = Dotenv.load(env_file)
|
89
|
-
@env_vars = vars.map { |k, v| { 'name'=> k, 'value' => v } }
|
90
|
-
else
|
91
|
-
raise ArgumentError, "Could not find file '#{env_file}' for loading environment variables !"
|
92
|
-
end
|
83
|
+
load_env_vars!
|
93
84
|
|
94
85
|
@scale ||= @targets[@target][:scale]
|
95
86
|
@command = @targets[@target][:command]
|
96
|
-
# TODO: what's up with predeploy_commands. ||= []?
|
97
87
|
@predeploy_commands = @targets[@target][:predeploy_commands] if @targets[@target][:predeploy_commands]
|
88
|
+
@bootstrap_commands = @targets[@target][:bootstrap_commands] if @targets[@target][:bootstrap_commands]
|
98
89
|
@service_config = @targets[@target][:service_config]
|
99
90
|
@task_definition_config = @targets[@target][:task_definition_config]
|
100
91
|
end
|
101
92
|
|
102
|
-
|
93
|
+
def load_env_vars!
|
94
|
+
@env_vars ||= {}
|
95
|
+
|
96
|
+
[@targets[@target][:env_file]].flatten.each do |env_path|
|
97
|
+
env_file = Pathname.new(env_path)
|
103
98
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
99
|
+
unless env_file.absolute?
|
100
|
+
dir = config.file.nil? ? Dir.pwd : Pathname.new(config.file).dirname
|
101
|
+
env_file = env_file.expand_path(dir)
|
102
|
+
end
|
103
|
+
|
104
|
+
if env_file.exist?
|
105
|
+
vars = Dotenv.load(env_file)
|
106
|
+
@env_vars.merge!(vars)
|
107
|
+
else
|
108
|
+
raise ArgumentError, "Could not find file '#{env_file}' for loading environment variables !"
|
109
|
+
end
|
109
110
|
end
|
111
|
+
|
112
|
+
# convert env vars to format ecs expects
|
113
|
+
@env_vars = @env_vars.map { |k, v| { 'name' => k, 'value' => v } }
|
110
114
|
end
|
111
115
|
|
112
|
-
|
113
|
-
|
114
|
-
|
116
|
+
private
|
117
|
+
|
118
|
+
class << self
|
119
|
+
def validate_types(types, target_attribute)
|
120
|
+
if types.include?(target_attribute.class)
|
121
|
+
nil
|
122
|
+
else
|
123
|
+
"'#{target_attribute}' must be of type [#{types.join('|')}], got '#{target_attribute.class}' !"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def validate_predeploy_commands(commands)
|
128
|
+
validate_commands(commands, 'predeploy_commands')
|
129
|
+
end
|
130
|
+
|
131
|
+
def validate_bootstrap_commands(commands)
|
132
|
+
validate_commands(commands, 'bootstrap_commands')
|
133
|
+
end
|
134
|
+
|
135
|
+
def validate_commands(commands, attribute_name)
|
136
|
+
return nil if commands.nil?
|
137
|
+
return "#{attribute_name} must be an array" unless commands.is_a?(Array)
|
138
|
+
|
139
|
+
messages = commands.reject { |cmd| cmd.is_a?(Array) }.map do |command|
|
140
|
+
"#{attribute_name} '#{command}' must be an array" unless command.is_a?(Array)
|
141
|
+
end
|
115
142
|
|
116
|
-
|
117
|
-
"predeploy_command '#{command}' must be an array" unless command.is_a?(Array)
|
143
|
+
messages.empty? ? nil : messages.join(', ')
|
118
144
|
end
|
119
|
-
messages.empty? ? nil : messages.join(', ')
|
120
145
|
end
|
121
146
|
end
|
122
147
|
end
|
@@ -48,6 +48,7 @@ module Broadside
|
|
48
48
|
def bootstrap
|
49
49
|
if EcsManager.get_latest_task_definition_arn(family)
|
50
50
|
info("Task definition for #{family} already exists.")
|
51
|
+
run_bootstrap_commands
|
51
52
|
else
|
52
53
|
unless @deploy_config.task_definition_config
|
53
54
|
raise ArgumentError, "No first task definition and no :task_definition_config in '#{family}' configuration"
|
@@ -61,6 +62,8 @@ module Broadside
|
|
61
62
|
container_definitions: [DEFAULT_CONTAINER_DEFINITION.merge(container_definition)]
|
62
63
|
)
|
63
64
|
)
|
65
|
+
|
66
|
+
run_bootstrap_commands
|
64
67
|
end
|
65
68
|
|
66
69
|
if EcsManager.service_exists?(config.ecs.cluster, family)
|
@@ -75,6 +78,16 @@ module Broadside
|
|
75
78
|
end
|
76
79
|
end
|
77
80
|
|
81
|
+
def run_bootstrap_commands
|
82
|
+
update_task_revision
|
83
|
+
|
84
|
+
begin
|
85
|
+
@deploy_config.bootstrap_commands.each { |command| run_command(command) }
|
86
|
+
ensure
|
87
|
+
EcsManager.deregister_last_n_tasks_definitions(family, 1)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
78
91
|
def rollback(count = @deploy_config.rollback)
|
79
92
|
super do
|
80
93
|
begin
|
@@ -279,4 +292,4 @@ module Broadside
|
|
279
292
|
)
|
280
293
|
end
|
281
294
|
end
|
282
|
-
end
|
295
|
+
end
|
data/lib/broadside/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: broadside
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Leung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -185,3 +185,4 @@ signing_key:
|
|
185
185
|
specification_version: 4
|
186
186
|
summary: A command-line tool for EC2 Container Service deployment.
|
187
187
|
test_files: []
|
188
|
+
has_rdoc:
|