moonshot 2.0.0.beta6 → 3.0.4
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 +5 -5
- data/bin/moonshot +4 -1
- data/lib/default/bin/build.sh +0 -0
- data/lib/moonshot/account_context.rb +2 -0
- data/lib/moonshot/always_use_default_source.rb +5 -4
- data/lib/moonshot/artifact_repository/s3_bucket.rb +11 -5
- data/lib/moonshot/artifact_repository/s3_bucket_via_github_releases.rb +7 -7
- data/lib/moonshot/ask_user_source.rb +2 -0
- data/lib/moonshot/build_mechanism/github_release.rb +9 -2
- data/lib/moonshot/build_mechanism/script.rb +8 -7
- data/lib/moonshot/build_mechanism/travis_deploy.rb +5 -5
- data/lib/moonshot/build_mechanism/version_proxy.rb +13 -0
- data/lib/moonshot/change_set.rb +24 -34
- data/lib/moonshot/command.rb +3 -1
- data/lib/moonshot/command_line.rb +12 -9
- data/lib/moonshot/command_line_dispatcher.rb +5 -7
- data/lib/moonshot/commands/build.rb +6 -0
- data/lib/moonshot/commands/console.rb +2 -0
- data/lib/moonshot/commands/create.rb +16 -2
- data/lib/moonshot/commands/delete.rb +9 -0
- data/lib/moonshot/commands/deploy.rb +4 -8
- data/lib/moonshot/commands/doctor.rb +2 -0
- data/lib/moonshot/commands/generate_template.rb +46 -0
- data/lib/moonshot/commands/interactive_command.rb +15 -0
- data/lib/moonshot/commands/list.rb +2 -0
- data/lib/moonshot/commands/new.rb +5 -2
- data/lib/moonshot/commands/parameter_arguments.rb +5 -4
- data/lib/moonshot/commands/parent_stack_option.rb +2 -0
- data/lib/moonshot/commands/push.rb +2 -0
- data/lib/moonshot/commands/show_all_events_option.rb +2 -0
- data/lib/moonshot/commands/ssh.rb +4 -0
- data/lib/moonshot/commands/status.rb +2 -0
- data/lib/moonshot/commands/tag_arguments.rb +20 -0
- data/lib/moonshot/commands/update.rb +8 -1
- data/lib/moonshot/commands/version.rb +2 -0
- data/lib/moonshot/controller.rb +28 -13
- data/lib/moonshot/controller_config.rb +13 -27
- data/lib/moonshot/creds_helper.rb +2 -0
- data/lib/moonshot/deployment_mechanism/code_deploy.rb +44 -37
- data/lib/moonshot/doctor_helper.rb +14 -15
- data/lib/moonshot/dynamic_template.rb +76 -0
- data/lib/moonshot/interactive_logger_proxy.rb +4 -4
- data/lib/moonshot/json_stack_template.rb +3 -0
- data/lib/moonshot/parameter_collection.rb +3 -0
- data/lib/moonshot/parent_stack_parameter_loader.rb +7 -3
- data/lib/moonshot/resources.rb +2 -0
- data/lib/moonshot/resources_helper.rb +5 -1
- data/lib/moonshot/shell.rb +8 -8
- data/lib/moonshot/ssh_command.rb +2 -0
- data/lib/moonshot/ssh_command_builder.rb +3 -1
- data/lib/moonshot/ssh_config.rb +3 -2
- data/lib/moonshot/ssh_fork_executor.rb +2 -0
- data/lib/moonshot/ssh_target_selector.rb +3 -1
- data/lib/moonshot/stack.rb +73 -55
- data/lib/moonshot/stack_asg_printer.rb +14 -12
- data/lib/moonshot/stack_config.rb +3 -2
- data/lib/moonshot/stack_events_poller.rb +3 -1
- data/lib/moonshot/stack_list_printer.rb +2 -0
- data/lib/moonshot/stack_lister.rb +6 -2
- data/lib/moonshot/stack_output_printer.rb +2 -0
- data/lib/moonshot/stack_parameter.rb +5 -9
- data/lib/moonshot/stack_parameter_printer.rb +3 -1
- data/lib/moonshot/stack_template.rb +2 -0
- data/lib/moonshot/task.rb +3 -0
- data/lib/moonshot/tools/asg_rollout/asg.rb +22 -21
- data/lib/moonshot/tools/asg_rollout/asg_instance.rb +2 -0
- data/lib/moonshot/tools/asg_rollout/hook_exec_environment.rb +2 -0
- data/lib/moonshot/tools/asg_rollout/instance_health.rb +2 -0
- data/lib/moonshot/tools/asg_rollout.rb +16 -14
- data/lib/moonshot/tools/asg_rollout_config.rb +2 -0
- data/lib/moonshot/unicode_table.rb +5 -3
- data/lib/moonshot/yaml_stack_template.rb +2 -0
- data/lib/moonshot.rb +13 -1
- data/lib/plugins/backup.rb +24 -30
- data/lib/plugins/code_deploy_setup.rb +4 -2
- data/lib/plugins/dynamic_template.rb +36 -0
- data/lib/plugins/encrypted_parameters/kms_key.rb +26 -5
- data/lib/plugins/encrypted_parameters/parameter_encrypter.rb +2 -0
- data/lib/plugins/encrypted_parameters.rb +6 -2
- metadata +189 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d87f616758ca8f4b32b4af436e73c565665b8753d38b3fd14d478f6a6d347ce4
|
4
|
+
data.tar.gz: 616b51d3d59341f58beb48efea6af2dba7a3821ef0dace26f4dd1eae395a34bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8532967756fa789d68ce86fbdffc25bb053f5c483d784285b43ed1c934c40d72c03dc3ec73674bb6d06eb58bf2ec3b6f3641156ea6f7797e387e3d16ecf3ecc8
|
7
|
+
data.tar.gz: a4bcf9e2b1d6367670aa7cba505d4d561231d114dce658c2a92b10786f8eae24c25ba7052057966e5d6c8a5569633f4676eedda7d198483f7ef0c9446bd132da
|
data/bin/moonshot
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
require 'moonshot'
|
3
5
|
|
4
6
|
# This is the main entry point for the `moonshot` command-line tool.
|
5
7
|
begin
|
6
8
|
Moonshot::CommandLine.new.run!
|
7
|
-
rescue => e
|
9
|
+
rescue StandardError => e
|
8
10
|
warn "#{e} (at #{e.backtrace.first})"
|
9
11
|
raise e if ENV['MOONSHOT_BACKTRACE']
|
12
|
+
|
10
13
|
exit 1
|
11
14
|
end
|
data/lib/default/bin/build.sh
CHANGED
File without changes
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Moonshot
|
2
4
|
# The AlwaysUseDefaultSource will always use the previous value in
|
3
5
|
# the stack, or use the default value during stack creation. This is
|
@@ -6,12 +8,11 @@ module Moonshot
|
|
6
8
|
# answer files or command-line arguments will always apply.
|
7
9
|
class AlwaysUseDefaultSource
|
8
10
|
def get(sp)
|
9
|
-
unless sp.default?
|
10
|
-
raise "Parameter #{sp.name} does not have a default, cannot use AlwaysUseDefaultSource!"
|
11
|
-
end
|
12
|
-
|
13
11
|
# Don't do anything, the default will apply on create, and the
|
14
12
|
# previous value will be used on update.
|
13
|
+
return if sp.default?
|
14
|
+
|
15
|
+
raise "Parameter #{sp.name} does not have a default, cannot use AlwaysUseDefaultSource!"
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -1,3 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../resources_helper'
|
4
|
+
require_relative '../creds_helper'
|
5
|
+
require_relative '../doctor_helper'
|
6
|
+
|
1
7
|
# The S3Bucket stores builds in an S3 Bucket.
|
2
8
|
#
|
3
9
|
# For example:
|
@@ -19,7 +25,7 @@ class Moonshot::ArtifactRepository::S3Bucket
|
|
19
25
|
|
20
26
|
def store_hook(build_mechanism, version_name)
|
21
27
|
unless build_mechanism.respond_to?(:output_file)
|
22
|
-
raise "S3Bucket does not know how to store artifacts from #{build_mechanism.class}, no method '#output_file'."
|
28
|
+
raise "S3Bucket does not know how to store artifacts from #{build_mechanism.class}, no method '#output_file'."
|
23
29
|
end
|
24
30
|
|
25
31
|
file = build_mechanism.output_file
|
@@ -41,7 +47,7 @@ class Moonshot::ArtifactRepository::S3Bucket
|
|
41
47
|
def upload_to_s3(file, key)
|
42
48
|
s3_client.put_object(
|
43
49
|
acl: 'bucket-owner-full-control',
|
44
|
-
key
|
50
|
+
key:,
|
45
51
|
body: File.open(file),
|
46
52
|
bucket: @bucket_name,
|
47
53
|
storage_class: 'STANDARD_IA'
|
@@ -51,7 +57,7 @@ class Moonshot::ArtifactRepository::S3Bucket
|
|
51
57
|
def doctor_check_bucket_exists
|
52
58
|
s3_client.get_bucket_location(bucket: @bucket_name)
|
53
59
|
success "Bucket '#{@bucket_name}' exists."
|
54
|
-
rescue => e
|
60
|
+
rescue StandardError => e
|
55
61
|
# This is warning because the role you use for deployment may not actually
|
56
62
|
# be able to read builds, however the instance role assigned to the nodes
|
57
63
|
# might.
|
@@ -68,9 +74,9 @@ class Moonshot::ArtifactRepository::S3Bucket
|
|
68
74
|
)
|
69
75
|
s3_client.delete_object(key: 'test-object', bucket: @bucket_name)
|
70
76
|
success 'Bucket is writable, new builds can be uploaded.'
|
71
|
-
rescue => e
|
77
|
+
rescue StandardError => e
|
72
78
|
# This is a warning because you may deploy to an environment where you have
|
73
79
|
# read access to builds, but could not publish a new build.
|
74
|
-
warning('Could not write to bucket, you may still be able to deploy existing builds.', e.message)
|
80
|
+
warning('Could not write to bucket, you may still be able to deploy existing builds.', e.message)
|
75
81
|
end
|
76
82
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'moonshot/artifact_repository/s3_bucket'
|
2
4
|
require 'moonshot/shell'
|
3
5
|
require 'digest'
|
@@ -9,7 +11,7 @@ require 'retriable'
|
|
9
11
|
module Moonshot::ArtifactRepository
|
10
12
|
# S3 Bucket repository backed by GitHub releases.
|
11
13
|
# If a SemVer package isn't found in S3, it is copied from GitHub releases.
|
12
|
-
class S3BucketViaGithubReleases < S3Bucket # rubocop:disable ClassLength
|
14
|
+
class S3BucketViaGithubReleases < S3Bucket # rubocop:disable Metrics/ClassLength
|
13
15
|
include Moonshot::BuildMechanism
|
14
16
|
include Moonshot::Shell
|
15
17
|
|
@@ -36,9 +38,7 @@ module Moonshot::ArtifactRepository
|
|
36
38
|
# artifact repositories a hook before deploy.
|
37
39
|
def filename_for_version(version)
|
38
40
|
s3_name = super
|
39
|
-
if !@output_file && release?(version) && !in_s3?(s3_name)
|
40
|
-
github_to_s3(version, s3_name)
|
41
|
-
end
|
41
|
+
github_to_s3(version, s3_name) if !@output_file && release?(version) && !in_s3?(s3_name)
|
42
42
|
s3_name
|
43
43
|
end
|
44
44
|
|
@@ -51,7 +51,7 @@ module Moonshot::ArtifactRepository
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def in_s3?(key)
|
54
|
-
s3_client.head_object(key
|
54
|
+
s3_client.head_object(key:, bucket: bucket_name)
|
55
55
|
rescue ::Aws::S3::Errors::NotFound
|
56
56
|
false
|
57
57
|
end
|
@@ -62,7 +62,7 @@ module Moonshot::ArtifactRepository
|
|
62
62
|
|
63
63
|
# If there is a checksum file, attach it as well. We only support MD5
|
64
64
|
# since that's what S3 uses.
|
65
|
-
checksum_file = File.basename(file, '.tar.gz')
|
65
|
+
checksum_file = "#{File.basename(file, '.tar.gz')}.md5"
|
66
66
|
cmd += " --attach=#{checksum_file}" if File.exist?(checksum_file)
|
67
67
|
|
68
68
|
sh_step(cmd)
|
@@ -218,7 +218,7 @@ module Moonshot::ArtifactRepository
|
|
218
218
|
|
219
219
|
def doctor_check_hub_release_download
|
220
220
|
sh_out('hub release download --help')
|
221
|
-
rescue
|
221
|
+
rescue StandardError
|
222
222
|
critical '`hub release download` command missing, upgrade hub.' \
|
223
223
|
' See https://github.com/github/hub/pull/1103'
|
224
224
|
else
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'forwardable'
|
2
4
|
require 'moonshot/shell'
|
3
5
|
require 'open3'
|
@@ -31,6 +33,8 @@ module Moonshot::BuildMechanism
|
|
31
33
|
parser.on('-s', '--[no-]skip-ci-status', 'Skips checks on CI jobs', TrueClass) do |value|
|
32
34
|
@skip_ci_status = value
|
33
35
|
end
|
36
|
+
|
37
|
+
parser
|
34
38
|
end
|
35
39
|
|
36
40
|
def doctor_hook
|
@@ -83,6 +87,8 @@ module Moonshot::BuildMechanism
|
|
83
87
|
say("Changelog for #{version}", :yellow)
|
84
88
|
say("#{@changes}\n\n")
|
85
89
|
|
90
|
+
return unless Moonshot.config.interactive
|
91
|
+
|
86
92
|
q = "Do you want to tag and release this commit as #{version}? [y/n]"
|
87
93
|
raise 'Release declined.' unless yes?(q)
|
88
94
|
end
|
@@ -131,6 +137,7 @@ module Moonshot::BuildMechanism
|
|
131
137
|
|
132
138
|
def hub_create_release(semver, commitish, changelog_entry)
|
133
139
|
return if hub_release_exists(semver)
|
140
|
+
|
134
141
|
message = "#{semver}\n\n#{changelog_entry}"
|
135
142
|
cmd = "hub release create #{semver} --commitish=#{commitish}"
|
136
143
|
cmd << ' --prerelease' if semver.pre || semver.build
|
@@ -216,7 +223,7 @@ module Moonshot::BuildMechanism
|
|
216
223
|
|
217
224
|
def doctor_check_upstream
|
218
225
|
sh_out('git remote | grep ^upstream$')
|
219
|
-
rescue => e
|
226
|
+
rescue StandardError => e
|
220
227
|
critical "git remote `upstream` not found.\n#{e.message}"
|
221
228
|
else
|
222
229
|
success 'git remote `upstream` exists.'
|
@@ -224,7 +231,7 @@ module Moonshot::BuildMechanism
|
|
224
231
|
|
225
232
|
def doctor_check_hub_auth
|
226
233
|
sh_out('hub ci-status 0.0.0')
|
227
|
-
rescue => e
|
234
|
+
rescue StandardError => e
|
228
235
|
critical "`hub` failed, install hub and authorize it.\n#{e.message}"
|
229
236
|
else
|
230
237
|
success '`hub` installed and authorized.'
|
@@ -1,5 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'open3'
|
2
|
-
include Open3
|
3
4
|
|
4
5
|
# Compile a release artifact using a shell script.
|
5
6
|
#
|
@@ -18,6 +19,8 @@ class Moonshot::BuildMechanism::Script
|
|
18
19
|
include Moonshot::ResourcesHelper
|
19
20
|
include Moonshot::DoctorHelper
|
20
21
|
|
22
|
+
include Open3
|
23
|
+
|
21
24
|
attr_reader :output_file
|
22
25
|
|
23
26
|
def initialize(script, output_file: 'output.tar.gz')
|
@@ -35,12 +38,12 @@ class Moonshot::BuildMechanism::Script
|
|
35
38
|
'OUTPUT_FILE' => @output_file
|
36
39
|
}
|
37
40
|
ilog.start_threaded "Running Script: #{@script}" do |s|
|
38
|
-
run_script(s, env:
|
41
|
+
run_script(s, env:)
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
42
45
|
def post_build_hook(_version)
|
43
|
-
unless File.exist?(@output_file) # rubocop:disable GuardClause
|
46
|
+
unless File.exist?(@output_file) # rubocop:disable Style/GuardClause
|
44
47
|
raise 'Build command did not produce output file!'
|
45
48
|
end
|
46
49
|
end
|
@@ -61,10 +64,8 @@ class Moonshot::BuildMechanism::Script
|
|
61
64
|
end
|
62
65
|
|
63
66
|
result = wait.value
|
64
|
-
if result.exitstatus
|
65
|
-
|
66
|
-
end
|
67
|
-
unless result.exitstatus == 0
|
67
|
+
step.success "Build script #{@script} exited successfully!" if result.exitstatus.zero?
|
68
|
+
unless result.exitstatus.zero?
|
68
69
|
ilog.error "Build script failed with exit status #{result.exitstatus}!"
|
69
70
|
ilog.error output.join("\n")
|
70
71
|
step.failure "Build script #{@script} failed with exit status #{result.exitstatus}!"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'moonshot/shell'
|
2
4
|
require 'travis'
|
3
5
|
require 'travis/pro'
|
@@ -25,8 +27,7 @@ module Moonshot::BuildMechanism
|
|
25
27
|
@cli_args = "-r #{@slug} #{@endpoint}"
|
26
28
|
end
|
27
29
|
|
28
|
-
def pre_build_hook(_)
|
29
|
-
end
|
30
|
+
def pre_build_hook(_); end
|
30
31
|
|
31
32
|
def build_hook(version)
|
32
33
|
job_number = find_build_and_job(version)
|
@@ -34,8 +35,7 @@ module Moonshot::BuildMechanism
|
|
34
35
|
check_build(version)
|
35
36
|
end
|
36
37
|
|
37
|
-
def post_build_hook(_)
|
38
|
-
end
|
38
|
+
def post_build_hook(_); end
|
39
39
|
|
40
40
|
private
|
41
41
|
|
@@ -120,7 +120,7 @@ module Moonshot::BuildMechanism
|
|
120
120
|
|
121
121
|
def doctor_check_travis_auth
|
122
122
|
sh_out("bundle exec travis raw #{@endpoint} repos/#{@slug}")
|
123
|
-
rescue => e
|
123
|
+
rescue StandardError => e
|
124
124
|
critical "`travis` not available or not authorized.\n#{e.message}"
|
125
125
|
else
|
126
126
|
success '`travis` installed and authorized.'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'forwardable'
|
2
4
|
require 'semantic'
|
3
5
|
|
@@ -37,6 +39,17 @@ class Moonshot::BuildMechanism::VersionProxy
|
|
37
39
|
active(version).post_build_hook(version)
|
38
40
|
end
|
39
41
|
|
42
|
+
def build_cli_hook(parser)
|
43
|
+
# Expose any command line arguments provided by the build mechanisms. We
|
44
|
+
# don't know the version at this point, so we can't call the hook on only
|
45
|
+
# the one we're going to use, which may result in options being exposed that
|
46
|
+
# are only applicable for one of the build mechanisms.
|
47
|
+
parser = @release.build_cli_hook(parser) if @release.respond_to?(:build_cli_hook)
|
48
|
+
parser = @dev.build_cli_hook(parser) if @dev.respond_to?(:build_cli_hook)
|
49
|
+
|
50
|
+
parser
|
51
|
+
end
|
52
|
+
|
40
53
|
private
|
41
54
|
|
42
55
|
def active(version)
|
data/lib/moonshot/change_set.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Moonshot
|
2
4
|
class ChangeSet
|
3
|
-
attr_reader :name
|
4
|
-
attr_reader :stack_name
|
5
|
+
attr_reader :name, :stack_name
|
5
6
|
|
6
7
|
def initialize(name, stack_name)
|
7
8
|
@name = name
|
@@ -11,9 +12,7 @@ module Moonshot
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def confirm?
|
14
|
-
unless Moonshot.config.interactive
|
15
|
-
raise 'Cannot confirm ChangeSet when interactive mode is disabled!'
|
16
|
-
end
|
15
|
+
raise 'Cannot confirm ChangeSet when interactive mode is disabled!' unless Moonshot.config.interactive
|
17
16
|
|
18
17
|
loop do
|
19
18
|
print 'Apply changes? '
|
@@ -21,6 +20,7 @@ module Moonshot
|
|
21
20
|
|
22
21
|
return true if resp == 'yes'
|
23
22
|
return false if resp == 'no'
|
23
|
+
|
24
24
|
puts "Please enter 'yes' or 'no'!"
|
25
25
|
end
|
26
26
|
end
|
@@ -39,9 +39,10 @@ module Moonshot
|
|
39
39
|
@change_set.changes.map(&:resource_change).each do |c|
|
40
40
|
puts "* #{c.action} #{c.logical_resource_id} (#{c.resource_type})"
|
41
41
|
|
42
|
-
|
42
|
+
case c.replacement
|
43
|
+
when 'True'
|
43
44
|
puts ' - Will be replaced'
|
44
|
-
|
45
|
+
when 'Conditional'
|
45
46
|
puts ' - May be replaced (Conditional)'
|
46
47
|
end
|
47
48
|
|
@@ -60,47 +61,36 @@ module Moonshot
|
|
60
61
|
wait_for_change_set unless @change_set
|
61
62
|
@cf_client.execute_change_set(
|
62
63
|
change_set_name: @name,
|
63
|
-
stack_name: @stack_name
|
64
|
+
stack_name: @stack_name
|
65
|
+
)
|
64
66
|
end
|
65
67
|
|
66
68
|
def delete
|
67
69
|
wait_for_change_set unless @change_set
|
68
70
|
@cf_client.delete_change_set(
|
69
71
|
change_set_name: @name,
|
70
|
-
stack_name: @stack_name
|
72
|
+
stack_name: @stack_name
|
73
|
+
)
|
71
74
|
rescue Aws::CloudFormation::Errors::InvalidChangeSetStatus
|
72
75
|
sleep 1
|
73
76
|
retry
|
74
77
|
end
|
75
78
|
|
76
|
-
# NOTE: At the time of this patch, AWS-SDK native Waiters do not
|
77
|
-
# have support for ChangeSets. Once they add this, we can make
|
78
|
-
# this code much better.
|
79
|
-
# Still no support for this waiter, but it's planned.
|
80
|
-
# https://github.com/aws/aws-sdk-ruby/issues/1388
|
81
79
|
def wait_for_change_set
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
@change_set = resp
|
92
|
-
return
|
93
|
-
end
|
94
|
-
|
95
|
-
if Time.now.to_i > start + wait_seconds
|
96
|
-
raise "ChangeSet did not complete creation within #{wait_seconds} seconds!"
|
80
|
+
begin
|
81
|
+
@cf_client.wait_until(:change_set_create_complete,
|
82
|
+
stack_name: @stack_name,
|
83
|
+
change_set_name: @name)
|
84
|
+
rescue Aws::Waiters::Errors::FailureStateError => e
|
85
|
+
if e.message != 'stopped waiting, encountered a failure state'
|
86
|
+
throw e
|
87
|
+
else
|
88
|
+
puts "The change set didn't contain any new changes."
|
97
89
|
end
|
98
|
-
|
99
|
-
sleep 5 # http://bit.ly/1qY1ZXJ
|
100
|
-
# Wait 5 seconds because other waiters seem to wait at least 5 seconds
|
101
|
-
# before repeating requests.
|
102
|
-
# See: https://github.com/aws/aws-sdk-ruby/blob/master/aws-sdk-core/apis/cloudformation/2010-05-15/waiters-2.json#L5
|
103
90
|
end
|
91
|
+
|
92
|
+
@change_set = @cf_client.describe_change_set(stack_name: @stack_name,
|
93
|
+
change_set_name: @name)
|
104
94
|
end
|
105
95
|
end
|
106
96
|
end
|
data/lib/moonshot/command.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'optparse'
|
2
4
|
|
3
5
|
module Moonshot
|
@@ -44,7 +46,7 @@ module Moonshot
|
|
44
46
|
# Degrade to a more compatible logger if the terminal seems outdated,
|
45
47
|
# or at the users request.
|
46
48
|
if !$stdout.isatty || !@use_interactive_logger
|
47
|
-
log = Logger.new(
|
49
|
+
log = Logger.new($stdout)
|
48
50
|
controller.config.interactive_logger = InteractiveLoggerProxy.new(log)
|
49
51
|
end
|
50
52
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Moonshot
|
2
4
|
# This class implements the command-line `moonshot` tool.
|
3
5
|
class CommandLine
|
@@ -10,7 +12,7 @@ module Moonshot
|
|
10
12
|
@classes || []
|
11
13
|
end
|
12
14
|
|
13
|
-
def run! # rubocop:disable
|
15
|
+
def run! # rubocop:disable Metrics/MethodLength
|
14
16
|
# Commands defined as Moonshot::Commands require a properly
|
15
17
|
# configured Moonshot.rb and supporting files. Without them, we only
|
16
18
|
# support `--help` and `new`.
|
@@ -24,7 +26,7 @@ module Moonshot
|
|
24
26
|
|
25
27
|
if Dir.pwd == '/'
|
26
28
|
warn 'No Moonfile.rb found, are you in a project? Maybe you need to '\
|
27
|
-
|
29
|
+
'create one with `moonshot new <app_name>`?'
|
28
30
|
raise 'No Moonfile found'
|
29
31
|
end
|
30
32
|
|
@@ -51,7 +53,7 @@ module Moonshot
|
|
51
53
|
|
52
54
|
# Determine what command is being run, which should be the first argument.
|
53
55
|
command = ARGV.shift
|
54
|
-
if %w
|
56
|
+
if %w[--help -h help].include?(command) || command.nil?
|
55
57
|
usage
|
56
58
|
return
|
57
59
|
end
|
@@ -94,7 +96,7 @@ module Moonshot
|
|
94
96
|
max_len = fields.map(&:first).map(&:size).max
|
95
97
|
|
96
98
|
fields.each do |f|
|
97
|
-
line = format(" %-#{max_len}s # %s", *f)
|
99
|
+
line = format(" %-#{max_len}s # %s", *f) # rubocop:disable Lint/FormatParameterMismatch
|
98
100
|
warn line
|
99
101
|
end
|
100
102
|
end
|
@@ -117,9 +119,9 @@ module Moonshot
|
|
117
119
|
|
118
120
|
def commandify(klass)
|
119
121
|
word = klass.to_s.split('::').last
|
120
|
-
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'
|
121
|
-
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2'
|
122
|
-
word.tr!('_'
|
122
|
+
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
|
123
|
+
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
124
|
+
word.tr!('_', '-')
|
123
125
|
word.downcase!
|
124
126
|
word
|
125
127
|
end
|
@@ -127,10 +129,11 @@ module Moonshot
|
|
127
129
|
def handle_early_commands
|
128
130
|
# If this is a legacy (Thor) help command, re-write it as
|
129
131
|
# OptionParser format.
|
130
|
-
|
132
|
+
case ARGV[0]
|
133
|
+
when 'help'
|
131
134
|
ARGV.delete_at(0)
|
132
135
|
ARGV.push('-h')
|
133
|
-
|
136
|
+
when 'new'
|
134
137
|
app_name = ARGV[1]
|
135
138
|
::Moonshot::Commands::New.run!(app_name)
|
136
139
|
return true
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Moonshot
|
2
4
|
class CommandLineDispatcher
|
3
5
|
def initialize(command, klass, args)
|
@@ -46,18 +48,14 @@ module Moonshot
|
|
46
48
|
|
47
49
|
# Each mechanism / plugin may manipulate the OptionParser object
|
48
50
|
# associated with this command.
|
49
|
-
[
|
51
|
+
%i[build_mechanism deployment_mechanism artifact_repository].each do |prov|
|
50
52
|
provider = Moonshot.config.send(prov)
|
51
53
|
|
52
|
-
if provider.respond_to?(hook_func_name(@command))
|
53
|
-
parser = provider.send(hook_func_name(@command), parser)
|
54
|
-
end
|
54
|
+
parser = provider.send(hook_func_name(@command), parser) if provider.respond_to?(hook_func_name(@command))
|
55
55
|
end
|
56
56
|
|
57
57
|
Moonshot.config.plugins.each do |plugin|
|
58
|
-
if plugin.respond_to?(hook_func_name(@command))
|
59
|
-
parser = plugin.send(hook_func_name(@command), parser)
|
60
|
-
end
|
58
|
+
parser = plugin.send(hook_func_name(@command), parser) if plugin.respond_to?(hook_func_name(@command))
|
61
59
|
end
|
62
60
|
|
63
61
|
parser
|
@@ -1,6 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'interactive_command'
|
4
|
+
|
1
5
|
module Moonshot
|
2
6
|
module Commands
|
3
7
|
class Build < Moonshot::Command
|
8
|
+
include InteractiveCommand
|
9
|
+
|
4
10
|
self.usage = 'build VERSION'
|
5
11
|
self.description = 'Build a release artifact, ready for deployment'
|
6
12
|
|
@@ -1,7 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'parameter_arguments'
|
4
|
+
require_relative 'tag_arguments'
|
5
|
+
require_relative 'show_all_events_option'
|
6
|
+
require_relative 'parent_stack_option'
|
7
|
+
|
1
8
|
module Moonshot
|
2
9
|
module Commands
|
3
10
|
class Create < Moonshot::Command
|
4
11
|
include ParameterArguments
|
12
|
+
include TagArguments
|
5
13
|
include ShowAllEventsOption
|
6
14
|
include ParentStackOption
|
7
15
|
|
@@ -14,13 +22,19 @@ module Moonshot
|
|
14
22
|
@deploy = true
|
15
23
|
|
16
24
|
parser = super
|
17
|
-
|
25
|
+
desc = 'Choose if code should be deployed immediately after the stack is created'
|
26
|
+
parser.on('-d', '--[no-]deploy', TrueClass, desc) do |v|
|
18
27
|
@deploy = v
|
19
28
|
end
|
20
29
|
|
21
|
-
|
30
|
+
desc = 'Version for initial deployment. If unset, a new development build is created from the local directory'
|
31
|
+
parser.on('--version VERSION_NAME', desc) do |v|
|
22
32
|
@version = v
|
23
33
|
end
|
34
|
+
|
35
|
+
parser.on('--template-file=FILE', 'Override the path to the CloudFormation template.') do |v|
|
36
|
+
Moonshot.config.template_file = v
|
37
|
+
end
|
24
38
|
end
|
25
39
|
|
26
40
|
def execute
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Moonshot
|
2
4
|
module Commands
|
3
5
|
class Delete < Moonshot::Command
|
@@ -6,6 +8,13 @@ module Moonshot
|
|
6
8
|
self.usage = 'delete [options]'
|
7
9
|
self.description = 'Delete an existing environment'
|
8
10
|
|
11
|
+
def parser
|
12
|
+
parser = super
|
13
|
+
parser.on('--template-file=FILE', 'Override the path to the CloudFormation template.') do |v|
|
14
|
+
Moonshot.config.template_file = v
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
9
18
|
def execute
|
10
19
|
controller.delete
|
11
20
|
end
|
@@ -1,17 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Moonshot
|
2
4
|
module Commands
|
3
5
|
class Deploy < Moonshot::Command
|
6
|
+
include InteractiveCommand
|
7
|
+
|
4
8
|
self.usage = 'deploy VERSION'
|
5
9
|
self.description = 'Deploy a versioned release to the environment'
|
6
10
|
|
7
|
-
def parser
|
8
|
-
parser = super
|
9
|
-
|
10
|
-
parser.on('--[no-]interactive', TrueClass, 'Use interactive prompts.') do |v|
|
11
|
-
Moonshot.config.interactive = v
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
11
|
def execute(version_name)
|
16
12
|
controller.deploy_version(version_name)
|
17
13
|
end
|