moonshot 0.7.7 → 1.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/moonshot +11 -0
- data/lib/default/Moonfile.rb +0 -0
- data/lib/moonshot.rb +33 -6
- data/lib/moonshot/always_use_default_source.rb +17 -0
- data/lib/moonshot/artifact_repository/s3_bucket_via_github_releases.rb +140 -3
- data/lib/moonshot/ask_user_source.rb +38 -0
- data/lib/moonshot/build_mechanism/github_release.rb +1 -1
- data/lib/moonshot/build_mechanism/script.rb +1 -1
- data/lib/moonshot/command.rb +64 -0
- data/lib/moonshot/command_line.rb +150 -0
- data/lib/moonshot/commands/build.rb +12 -0
- data/lib/moonshot/commands/console.rb +19 -0
- data/lib/moonshot/commands/create.rb +37 -0
- data/lib/moonshot/commands/delete.rb +12 -0
- data/lib/moonshot/commands/deploy.rb +12 -0
- data/lib/moonshot/commands/doctor.rb +12 -0
- data/lib/moonshot/commands/list.rb +16 -0
- data/lib/moonshot/commands/new.rb +99 -0
- data/lib/moonshot/commands/parameter_arguments.rb +27 -0
- data/lib/moonshot/commands/push.rb +12 -0
- data/lib/moonshot/commands/ssh.rb +12 -0
- data/lib/moonshot/commands/status.rb +12 -0
- data/lib/moonshot/commands/update.rb +29 -0
- data/lib/moonshot/commands/version.rb +12 -0
- data/lib/moonshot/config.rb +0 -0
- data/lib/moonshot/controller.rb +106 -42
- data/lib/moonshot/controller_config.rb +31 -13
- data/lib/moonshot/deployment_mechanism/code_deploy.rb +17 -7
- data/lib/moonshot/json_stack_template.rb +17 -0
- data/lib/moonshot/parameter_collection.rb +50 -0
- data/lib/moonshot/parent_stack_parameter_loader.rb +51 -0
- data/lib/moonshot/resources.rb +3 -3
- data/lib/moonshot/resources_helper.rb +2 -2
- data/lib/moonshot/ssh_command.rb +31 -0
- data/lib/moonshot/ssh_config.rb +1 -1
- data/lib/moonshot/stack.rb +66 -77
- data/lib/moonshot/stack_list_printer.rb +21 -0
- data/lib/moonshot/stack_lister.rb +16 -6
- data/lib/moonshot/stack_parameter.rb +64 -0
- data/lib/moonshot/stack_parameter_printer.rb +3 -49
- data/lib/moonshot/stack_template.rb +13 -25
- data/lib/moonshot/task.rb +10 -0
- data/lib/moonshot/tools/asg_rollout.rb +1 -1
- data/lib/moonshot/tools/asg_rollout/instance_health.rb +1 -1
- data/lib/moonshot/tools/asg_rollout_config.rb +1 -1
- data/lib/moonshot/yaml_stack_template.rb +17 -0
- metadata +51 -9
- data/lib/moonshot/cli.rb +0 -220
- data/lib/moonshot/environment_parser.rb +0 -32
@@ -0,0 +1,21 @@
|
|
1
|
+
module Moonshot
|
2
|
+
class StackListPrinter
|
3
|
+
attr_accessor :stacks
|
4
|
+
|
5
|
+
def initialize(stacks)
|
6
|
+
@stacks = stacks
|
7
|
+
@table = UnicodeTable.new('Environment List')
|
8
|
+
end
|
9
|
+
|
10
|
+
def print
|
11
|
+
rows = @stacks.map do |stack|
|
12
|
+
[stack.name, stack.creation_time, stack.status]
|
13
|
+
end
|
14
|
+
|
15
|
+
@table.add_table(rows)
|
16
|
+
|
17
|
+
@table.draw
|
18
|
+
@table.draw_children
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,20 +1,30 @@
|
|
1
1
|
module Moonshot
|
2
2
|
# The StackLister is world renoun for it's ability to list stacks.
|
3
3
|
class StackLister
|
4
|
+
EnvironmentDescription = Struct.new(:name, :creation_time, :status)
|
4
5
|
include CredsHelper
|
5
6
|
|
6
|
-
def initialize(app_name
|
7
|
+
def initialize(app_name)
|
7
8
|
@app_name = app_name
|
8
|
-
@log = log
|
9
9
|
end
|
10
10
|
|
11
11
|
def list
|
12
|
-
|
13
|
-
|
12
|
+
result = []
|
13
|
+
next_token = nil
|
14
|
+
loop do
|
15
|
+
resp = cf_client.describe_stacks(next_token: next_token)
|
16
|
+
resp.stacks.each do |stack|
|
17
|
+
app_tag = stack.tags.find { |t| t.key == 'moonshot_application' }
|
18
|
+
env_tag = stack.tags.find { |t| t.key == 'moonshot_environment' }
|
14
19
|
|
15
|
-
|
16
|
-
|
20
|
+
next unless app_tag && app_tag.value == Moonshot.config.app_name
|
21
|
+
result <<
|
22
|
+
EnvironmentDescription.new(env_tag.value, stack.creation_time, stack.stack_status)
|
23
|
+
end
|
24
|
+
break unless resp.next_token
|
25
|
+
next_token = resp.next_token
|
17
26
|
end
|
27
|
+
result.sort_by(&:name)
|
18
28
|
end
|
19
29
|
end
|
20
30
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Moonshot
|
2
|
+
class StackParameter
|
3
|
+
attr_reader :name
|
4
|
+
attr_reader :default
|
5
|
+
attr_reader :description
|
6
|
+
|
7
|
+
def initialize(name, default: nil, use_previous: false, description: '')
|
8
|
+
@default = default
|
9
|
+
@description = description
|
10
|
+
@name = name
|
11
|
+
@use_previous = use_previous
|
12
|
+
@value = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
# Does this Stack Parameter have a default value that will be used?
|
16
|
+
def default?
|
17
|
+
!@default.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def use_previous?
|
21
|
+
@use_previous ? true : false
|
22
|
+
end
|
23
|
+
|
24
|
+
# Has the user provided a value for this parameter?
|
25
|
+
def set?
|
26
|
+
!@value.nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
def set(value)
|
30
|
+
@value = value
|
31
|
+
@use_previous = false
|
32
|
+
end
|
33
|
+
|
34
|
+
def use_previous!(value)
|
35
|
+
if @value
|
36
|
+
raise "Value already set for StackParameter #{@name}, cannot use previous value!"
|
37
|
+
end
|
38
|
+
|
39
|
+
# Make the current value available to plugins.
|
40
|
+
@value = value
|
41
|
+
@use_previous = true
|
42
|
+
end
|
43
|
+
|
44
|
+
def value
|
45
|
+
unless @value || default?
|
46
|
+
raise "No value set and no default for StackParameter #{@name}!"
|
47
|
+
end
|
48
|
+
|
49
|
+
@value || default
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_cf
|
53
|
+
result = { parameter_key: @name }
|
54
|
+
|
55
|
+
if use_previous?
|
56
|
+
result[:use_previous_value] = true
|
57
|
+
else
|
58
|
+
result[:parameter_value] = value
|
59
|
+
end
|
60
|
+
|
61
|
+
result
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -9,62 +9,16 @@ module Moonshot
|
|
9
9
|
|
10
10
|
def print
|
11
11
|
p_table = @table.add_leaf('Stack Parameters')
|
12
|
-
overrides = @stack.overrides
|
13
12
|
rows = @stack.parameters.sort.map do |key, value|
|
14
|
-
|
15
|
-
p.name == key
|
16
|
-
end
|
17
|
-
|
18
|
-
properties = determine_change(t_param ? t_param.default : nil,
|
19
|
-
overrides[key],
|
20
|
-
value)
|
21
|
-
|
22
|
-
[
|
23
|
-
"#{key}:",
|
24
|
-
format_value(value),
|
25
|
-
format_properties(properties)
|
26
|
-
]
|
13
|
+
["#{key}:", format_value(value)]
|
27
14
|
end
|
28
15
|
|
29
16
|
p_table.add_table(rows)
|
30
17
|
end
|
31
18
|
|
32
|
-
def determine_change(default, override, current)
|
33
|
-
properties = []
|
34
|
-
|
35
|
-
# If there is a stack override, determine if it would change the current
|
36
|
-
# stack.
|
37
|
-
if override
|
38
|
-
properties << 'overridden'
|
39
|
-
if current == '****'
|
40
|
-
properties << 'may be updated, NoEcho set'
|
41
|
-
elsif override != current
|
42
|
-
properties << "would be updated to #{override}"
|
43
|
-
end
|
44
|
-
|
45
|
-
else
|
46
|
-
# Otherwise, compare the template default with the current value to
|
47
|
-
# determine outcome.
|
48
|
-
properties << 'default'
|
49
|
-
properties << "would be updated to #{default}" if default != current
|
50
|
-
end
|
51
|
-
|
52
|
-
properties
|
53
|
-
end
|
54
|
-
|
55
|
-
def format_properties(properties)
|
56
|
-
string = " (#{properties.join(', ')})"
|
57
|
-
|
58
|
-
if properties.any? { |p| p =~ /be updated/ }
|
59
|
-
string.yellow
|
60
|
-
else
|
61
|
-
string.green
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
19
|
def format_value(value)
|
66
|
-
if value.size >
|
67
|
-
value[0..
|
20
|
+
if value.size > 60
|
21
|
+
value[0..60] + '...'
|
68
22
|
else
|
69
23
|
value
|
70
24
|
end
|
@@ -1,39 +1,27 @@
|
|
1
|
-
|
1
|
+
require_relative 'stack_parameter'
|
2
2
|
|
3
3
|
module Moonshot
|
4
|
-
# A StackTemplate loads the
|
4
|
+
# A StackTemplate loads the template from disk and stores information
|
5
5
|
# about it.
|
6
6
|
class StackTemplate
|
7
|
-
|
8
|
-
|
9
|
-
default.nil?
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
attr_reader :body
|
14
|
-
|
15
|
-
def initialize(filename, log:)
|
16
|
-
@log = log
|
17
|
-
|
18
|
-
unless File.exist?(filename)
|
19
|
-
@log.error("Could not find CloudFormation template at #{filename}")
|
20
|
-
raise
|
21
|
-
end
|
22
|
-
|
23
|
-
# The maximum TemplateBody length is 51,200 bytes, so we remove
|
24
|
-
# formatting white space.
|
25
|
-
@body = JSON.parse(File.read(filename)).to_json
|
7
|
+
def initialize(filename)
|
8
|
+
@filename = filename
|
26
9
|
end
|
27
10
|
|
28
11
|
def parameters
|
29
|
-
|
30
|
-
|
12
|
+
template_body.fetch('Parameters', {}).map do |k, v|
|
13
|
+
StackParameter.new(k,
|
14
|
+
default: v['Default'],
|
15
|
+
description: v.fetch('Description', ''))
|
31
16
|
end
|
32
17
|
end
|
33
18
|
|
34
|
-
# Return a list of defined resource names in the template.
|
35
19
|
def resource_names
|
36
|
-
|
20
|
+
template_body.fetch('Resources', {}).keys
|
21
|
+
end
|
22
|
+
|
23
|
+
def exist?
|
24
|
+
File.exist?(@filename)
|
37
25
|
end
|
38
26
|
end
|
39
27
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require_relative 'stack_template'
|
3
|
+
|
4
|
+
module Moonshot
|
5
|
+
# Handles YAML formatted AWS template files.
|
6
|
+
class YamlStackTemplate < StackTemplate
|
7
|
+
def body
|
8
|
+
template_body.to_yaml
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def template_body
|
14
|
+
@template_body ||= YAML.load_file(@filename)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moonshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cloud Engineering <engineering@acquia.com>
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -170,6 +170,20 @@ dependencies:
|
|
170
170
|
- - ">="
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: pry
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
type: :runtime
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
173
187
|
- !ruby/object:Gem::Dependency
|
174
188
|
name: rspec
|
175
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,32 +226,56 @@ dependencies:
|
|
212
226
|
- - ">="
|
213
227
|
- !ruby/object:Gem::Version
|
214
228
|
version: '0'
|
215
|
-
description: A library for launching services into AWS.
|
229
|
+
description: A library and CLI tool for launching services into AWS.
|
216
230
|
email: engineering@acquia.com
|
217
|
-
executables:
|
231
|
+
executables:
|
232
|
+
- moonshot
|
218
233
|
extensions: []
|
219
234
|
extra_rdoc_files: []
|
220
235
|
files:
|
236
|
+
- bin/moonshot
|
237
|
+
- lib/default/Moonfile.rb
|
221
238
|
- lib/moonshot.rb
|
239
|
+
- lib/moonshot/always_use_default_source.rb
|
222
240
|
- lib/moonshot/artifact_repository/s3_bucket.rb
|
223
241
|
- lib/moonshot/artifact_repository/s3_bucket_via_github_releases.rb
|
242
|
+
- lib/moonshot/ask_user_source.rb
|
224
243
|
- lib/moonshot/build_mechanism/github_release.rb
|
225
244
|
- lib/moonshot/build_mechanism/script.rb
|
226
245
|
- lib/moonshot/build_mechanism/travis_deploy.rb
|
227
246
|
- lib/moonshot/build_mechanism/version_proxy.rb
|
228
|
-
- lib/moonshot/
|
247
|
+
- lib/moonshot/command.rb
|
248
|
+
- lib/moonshot/command_line.rb
|
249
|
+
- lib/moonshot/commands/build.rb
|
250
|
+
- lib/moonshot/commands/console.rb
|
251
|
+
- lib/moonshot/commands/create.rb
|
252
|
+
- lib/moonshot/commands/delete.rb
|
253
|
+
- lib/moonshot/commands/deploy.rb
|
254
|
+
- lib/moonshot/commands/doctor.rb
|
255
|
+
- lib/moonshot/commands/list.rb
|
256
|
+
- lib/moonshot/commands/new.rb
|
257
|
+
- lib/moonshot/commands/parameter_arguments.rb
|
258
|
+
- lib/moonshot/commands/push.rb
|
259
|
+
- lib/moonshot/commands/ssh.rb
|
260
|
+
- lib/moonshot/commands/status.rb
|
261
|
+
- lib/moonshot/commands/update.rb
|
262
|
+
- lib/moonshot/commands/version.rb
|
263
|
+
- lib/moonshot/config.rb
|
229
264
|
- lib/moonshot/controller.rb
|
230
265
|
- lib/moonshot/controller_config.rb
|
231
266
|
- lib/moonshot/creds_helper.rb
|
232
267
|
- lib/moonshot/default_strategy.rb
|
233
268
|
- lib/moonshot/deployment_mechanism/code_deploy.rb
|
234
269
|
- lib/moonshot/doctor_helper.rb
|
235
|
-
- lib/moonshot/environment_parser.rb
|
236
270
|
- lib/moonshot/interactive_logger_proxy.rb
|
271
|
+
- lib/moonshot/json_stack_template.rb
|
237
272
|
- lib/moonshot/merge_strategy.rb
|
273
|
+
- lib/moonshot/parameter_collection.rb
|
274
|
+
- lib/moonshot/parent_stack_parameter_loader.rb
|
238
275
|
- lib/moonshot/resources.rb
|
239
276
|
- lib/moonshot/resources_helper.rb
|
240
277
|
- lib/moonshot/shell.rb
|
278
|
+
- lib/moonshot/ssh_command.rb
|
241
279
|
- lib/moonshot/ssh_command_builder.rb
|
242
280
|
- lib/moonshot/ssh_config.rb
|
243
281
|
- lib/moonshot/ssh_fork_executor.rb
|
@@ -246,10 +284,13 @@ files:
|
|
246
284
|
- lib/moonshot/stack_asg_printer.rb
|
247
285
|
- lib/moonshot/stack_config.rb
|
248
286
|
- lib/moonshot/stack_events_poller.rb
|
287
|
+
- lib/moonshot/stack_list_printer.rb
|
249
288
|
- lib/moonshot/stack_lister.rb
|
250
289
|
- lib/moonshot/stack_output_printer.rb
|
290
|
+
- lib/moonshot/stack_parameter.rb
|
251
291
|
- lib/moonshot/stack_parameter_printer.rb
|
252
292
|
- lib/moonshot/stack_template.rb
|
293
|
+
- lib/moonshot/task.rb
|
253
294
|
- lib/moonshot/tools/asg_rollout.rb
|
254
295
|
- lib/moonshot/tools/asg_rollout/asg.rb
|
255
296
|
- lib/moonshot/tools/asg_rollout/asg_instance.rb
|
@@ -257,6 +298,7 @@ files:
|
|
257
298
|
- lib/moonshot/tools/asg_rollout/instance_health.rb
|
258
299
|
- lib/moonshot/tools/asg_rollout_config.rb
|
259
300
|
- lib/moonshot/unicode_table.rb
|
301
|
+
- lib/moonshot/yaml_stack_template.rb
|
260
302
|
- lib/plugins/backup.rb
|
261
303
|
homepage: https://github.com/acquia/moonshot
|
262
304
|
licenses:
|
@@ -273,14 +315,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
273
315
|
version: '0'
|
274
316
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
275
317
|
requirements:
|
276
|
-
- - "
|
318
|
+
- - ">"
|
277
319
|
- !ruby/object:Gem::Version
|
278
|
-
version:
|
320
|
+
version: 1.3.1
|
279
321
|
requirements: []
|
280
322
|
rubyforge_project:
|
281
323
|
rubygems_version: 2.4.8
|
282
324
|
signing_key:
|
283
325
|
specification_version: 4
|
284
|
-
summary: A library for launching services into AWS
|
326
|
+
summary: A library and CLI tool for launching services into AWS
|
285
327
|
test_files: []
|
286
328
|
has_rdoc:
|
data/lib/moonshot/cli.rb
DELETED
@@ -1,220 +0,0 @@
|
|
1
|
-
require 'interactive-logger'
|
2
|
-
require_relative 'default_strategy'
|
3
|
-
require_relative 'merge_strategy'
|
4
|
-
|
5
|
-
# Base class for Moonshot-powered project tooling.
|
6
|
-
module Moonshot
|
7
|
-
# The main entry point for Moonshot, this class should be extended by
|
8
|
-
# project tooling.
|
9
|
-
class CLI < Thor # rubocop:disable ClassLength
|
10
|
-
class_option(:name, aliases: 'n', default: nil, type: :string)
|
11
|
-
class_option(:interactive_logger, type: :boolean, default: true)
|
12
|
-
class_option(:verbose, aliases: 'v', type: :boolean)
|
13
|
-
|
14
|
-
class << self
|
15
|
-
attr_accessor :application_name
|
16
|
-
attr_accessor :artifact_repository
|
17
|
-
attr_accessor :auto_prefix_stack
|
18
|
-
attr_accessor :build_mechanism
|
19
|
-
attr_accessor :deployment_mechanism
|
20
|
-
attr_accessor :default_parent_stack
|
21
|
-
attr_accessor :default_parameter_strategy
|
22
|
-
attr_reader :plugins
|
23
|
-
|
24
|
-
def plugin(plugin)
|
25
|
-
@plugins ||= []
|
26
|
-
@plugins << plugin
|
27
|
-
end
|
28
|
-
|
29
|
-
def parent(value)
|
30
|
-
@default_parent_stack = value
|
31
|
-
end
|
32
|
-
|
33
|
-
def parameter_strategy(strategy)
|
34
|
-
@default_parameter_strategy = strategy
|
35
|
-
end
|
36
|
-
|
37
|
-
def check_class_configuration
|
38
|
-
raise Thor::Error, 'No application_name is set!' unless application_name
|
39
|
-
end
|
40
|
-
|
41
|
-
def exit_on_failure?
|
42
|
-
true
|
43
|
-
end
|
44
|
-
|
45
|
-
def inherited(base)
|
46
|
-
base.include(Moonshot::ArtifactRepository)
|
47
|
-
base.include(Moonshot::BuildMechanism)
|
48
|
-
base.include(Moonshot::DeploymentMechanism)
|
49
|
-
end
|
50
|
-
|
51
|
-
def ssh_options!
|
52
|
-
option :user, default: ENV['MOONSHOT_SSH_USER'] || ENV['USER'], type: :string,
|
53
|
-
aliases: '-l',
|
54
|
-
desc: 'Specifies the user to log in as on the remote machine.'
|
55
|
-
option :identity_file, default: ENV['MOONSHOT_SSH_KEY_FILE'], type: :string,
|
56
|
-
aliases: '-i',
|
57
|
-
desc: 'Selects a file from which the identity (private key) for '\
|
58
|
-
'public key authentication is read.'
|
59
|
-
option :instance, default: nil, type: :string, aliases: '-s',
|
60
|
-
desc: 'Connect to specified instance ID instead of the first one.'
|
61
|
-
option :command, default: nil, type: :string, aliases: '-c',
|
62
|
-
desc: 'Execute the specified command instead of opening a shell.'
|
63
|
-
option :auto_scaling_group, default: nil, type: :string, aliases: '-g',
|
64
|
-
desc: 'The logical ID of the auto scaling group to SSH into. '\
|
65
|
-
'Mandatory if the stack has multiple ASGs, '\
|
66
|
-
'ignored if you have only one.'
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def initialize(*args)
|
71
|
-
super
|
72
|
-
@log = Logger.new(STDOUT)
|
73
|
-
@log.formatter = proc do |s, d, _, msg|
|
74
|
-
"[#{self.class.name} #{s} #{d.strftime('%T')}] #{msg}\n"
|
75
|
-
end
|
76
|
-
@log.level = options[:verbose] ? Logger::DEBUG : Logger::INFO
|
77
|
-
|
78
|
-
EnvironmentParser.parse(@log)
|
79
|
-
self.class.check_class_configuration
|
80
|
-
end
|
81
|
-
|
82
|
-
no_tasks do
|
83
|
-
# Build a Moonshot::Controller from the CLI options.
|
84
|
-
def controller # rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity
|
85
|
-
Moonshot::Controller.new do |config|
|
86
|
-
config.app_name = self.class.application_name
|
87
|
-
config.artifact_repository = self.class.artifact_repository
|
88
|
-
config.auto_prefix_stack = self.class.auto_prefix_stack
|
89
|
-
config.build_mechanism = self.class.build_mechanism
|
90
|
-
config.deployment_mechanism = self.class.deployment_mechanism
|
91
|
-
config.environment_name = options[:name]
|
92
|
-
config.logger = @log
|
93
|
-
|
94
|
-
# Degrade to a more compatible logger if the terminal seems outdated,
|
95
|
-
# or at the users request.
|
96
|
-
if !$stdout.isatty || !options[:interactive_logger]
|
97
|
-
config.interactive_logger = InteractiveLoggerProxy.new(@log)
|
98
|
-
end
|
99
|
-
|
100
|
-
config.show_all_stack_events = true if options[:show_all_events]
|
101
|
-
config.plugins = self.class.plugins if self.class.plugins
|
102
|
-
|
103
|
-
if options[:parent]
|
104
|
-
config.parent_stacks << options[:parent]
|
105
|
-
elsif self.class.default_parent_stack
|
106
|
-
config.parent_stacks << self.class.default_parent_stack
|
107
|
-
end
|
108
|
-
|
109
|
-
parameter_strategy = options[:parameter_strategy] || self.class.default_parameter_strategy
|
110
|
-
config.parameter_strategy = parameter_strategy_factory(parameter_strategy) \
|
111
|
-
unless parameter_strategy.nil?
|
112
|
-
|
113
|
-
config.ssh_config.ssh_user = options[:user]
|
114
|
-
config.ssh_config.ssh_identity_file = options[:identity_file]
|
115
|
-
config.ssh_instance = options[:instance]
|
116
|
-
config.ssh_command = options[:command]
|
117
|
-
config.ssh_auto_scaling_group_name = options[:auto_scaling_group]
|
118
|
-
end
|
119
|
-
rescue => e
|
120
|
-
raise Thor::Error, e.message
|
121
|
-
end
|
122
|
-
|
123
|
-
def parameter_strategy_factory(value)
|
124
|
-
case value.to_sym
|
125
|
-
when :default
|
126
|
-
Moonshot::ParameterStrategy::DefaultStrategy.new
|
127
|
-
when :merge
|
128
|
-
Moonshot::ParameterStrategy::MergeStrategy.new
|
129
|
-
else
|
130
|
-
raise Thor::Error, "Unknown parameter strategy: #{value}"
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
def ssh_command(command)
|
135
|
-
arguments = ARGV.drop(1)
|
136
|
-
arguments += ['--command', command]
|
137
|
-
invoke :ssh, [], arguments
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
desc :list, 'List stacks for this application.'
|
142
|
-
def list
|
143
|
-
controller.list
|
144
|
-
end
|
145
|
-
|
146
|
-
desc :create, 'Create a new environment.'
|
147
|
-
option(
|
148
|
-
:parent,
|
149
|
-
type: :string,
|
150
|
-
aliases: '-p',
|
151
|
-
desc: "Parent stack to import parameters from. (Default: #{default_parent_stack || 'None'})")
|
152
|
-
option :deploy, default: true, type: :boolean, aliases: '-d',
|
153
|
-
desc: 'Choose if code should be deployed after stack is created'
|
154
|
-
option :version, default: nil, type: :string,
|
155
|
-
desc: 'Version to deploy. Only valid if deploy flag is set.'
|
156
|
-
option :show_all_events, desc: 'Show all stack events during update. (Default: errors only)'
|
157
|
-
def create
|
158
|
-
controller.create
|
159
|
-
|
160
|
-
if options[:deploy]
|
161
|
-
if options[:version].nil?
|
162
|
-
controller.deploy_code
|
163
|
-
else
|
164
|
-
controller.deploy_version(options[:version])
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
desc :update, 'Update the CloudFormation stack within an environment.'
|
170
|
-
option(
|
171
|
-
:parameter_strategy,
|
172
|
-
type: :string,
|
173
|
-
desc: 'Override default parameter strategy.')
|
174
|
-
option(
|
175
|
-
:show_all_events,
|
176
|
-
type: :boolean,
|
177
|
-
desc: 'Show all stack events during update. (Default: errors only)')
|
178
|
-
def update
|
179
|
-
controller.update
|
180
|
-
end
|
181
|
-
|
182
|
-
desc :status, 'Get the status of an existing environment.'
|
183
|
-
def status
|
184
|
-
controller.status
|
185
|
-
end
|
186
|
-
|
187
|
-
desc 'deploy-code', 'Create a build from the working directory, and deploy it.' # rubocop:disable LineLength
|
188
|
-
def deploy_code
|
189
|
-
controller.deploy_code
|
190
|
-
end
|
191
|
-
|
192
|
-
desc 'build-version VERSION', 'Build a tarball of the software, ready for deployment.' # rubocop:disable LineLength
|
193
|
-
def build_version(version_name)
|
194
|
-
controller.build_version(version_name)
|
195
|
-
end
|
196
|
-
|
197
|
-
desc 'deploy-version VERSION_NAME', 'Deploy a versioned release to both EB environments in an environment.' # rubocop:disable LineLength
|
198
|
-
def deploy_version(version_name)
|
199
|
-
controller.deploy_version(version_name)
|
200
|
-
end
|
201
|
-
|
202
|
-
desc :delete, 'Delete an existing environment.'
|
203
|
-
option :show_all_events, desc: 'Show all stack events during update. (Default: errors only)'
|
204
|
-
def delete
|
205
|
-
controller.delete
|
206
|
-
end
|
207
|
-
|
208
|
-
desc :doctor, 'Run configuration checks against current environment.'
|
209
|
-
def doctor
|
210
|
-
success = controller.doctor
|
211
|
-
raise Thor::Error, 'One or more checks failed.' unless success
|
212
|
-
end
|
213
|
-
|
214
|
-
desc :ssh, 'SSH into the first or specified instance on the stack.'
|
215
|
-
ssh_options!
|
216
|
-
def ssh
|
217
|
-
controller.ssh
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|