moonshot 2.0.0.beta3 → 2.0.0.beta4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36e066b2e7b8b790bbdf2a6ae2f0ff2b460be924
4
- data.tar.gz: ca20969b8fe43fe8cf7296ab3559a9af2132505c
3
+ metadata.gz: c356399f35faaaf5a8607cdd8981be62eeae1ec5
4
+ data.tar.gz: 5b84246b209003da95a2ec5debcd5418786efe93
5
5
  SHA512:
6
- metadata.gz: afd2ff66f8f3892cebd6c66c32c90af442eb2d518b86b2c6fd315da716dba8d5097a0c16f9563ad3f85ba6664d905a1dfc0e4790c03ed83eac5288f75f0072c6
7
- data.tar.gz: 76667b1b524cabecd1b6994c29d5ecc7b38e80fb92bfcce9d55f6620d4d1566873d612d6177ce58ca50136116e898415e4b2d74d3b2c7bc9fe3cd2ca163f1cb1
6
+ metadata.gz: 329a31f99d19662734d917c41036dbeef77398319feb9afe93e7375c3b57d1cbbda4a368e9b05d22a64620db4cc49d6a6f5359cfeeccac6e08b60fb504e325df
7
+ data.tar.gz: a7917a5b06f86e4442e03ee976b48b6360eb7eef12c87634774a76b2f3983fca3a373a2391ec94a0088788c28620c916492f5fba421ae51ee186b8f0fc3d2d8d
@@ -17,10 +17,20 @@ module Moonshot::BuildMechanism
17
17
  def_delegator :@build_mechanism, :output_file
18
18
 
19
19
  # @param build_mechanism Delegates building after GitHub release is created.
20
- def initialize(build_mechanism, ci_status_timeout: 600, max_tag_find_timeout: 240)
20
+ def initialize(build_mechanism,
21
+ ci_status_timeout: 600,
22
+ max_tag_find_timeout: 240,
23
+ skip_ci_status: false)
21
24
  @build_mechanism = build_mechanism
22
25
  @ci_status_timeout = ci_status_timeout
23
26
  @max_tag_find_timeout = max_tag_find_timeout
27
+ @skip_ci_status = skip_ci_status
28
+ end
29
+
30
+ def build_cli_hook(parser)
31
+ parser.on('-s', '--[no-]skip-ci-status', 'Skips checks on CI jobs', TrueClass) do |value|
32
+ @skip_ci_status = value
33
+ end
24
34
  end
25
35
 
26
36
  def doctor_hook
@@ -159,7 +169,7 @@ module Moonshot::BuildMechanism
159
169
  sh_step(cmd, msg: "Validate commit #{@sha}.") do |_, out|
160
170
  @commit_detail = out
161
171
  end
162
- @ci_statuses = check_ci_status(@sha)
172
+ @ci_statuses = check_ci_status(@sha) if @skip_ci_status == false
163
173
  end
164
174
 
165
175
  def validate_changelog(version)
@@ -111,6 +111,8 @@ module Moonshot
111
111
  command_name = commandify(klass)
112
112
  @commands[command_name] = klass
113
113
  end
114
+
115
+ @commands = @commands.sort_by { |k, _v| k.to_s }.to_h
114
116
  end
115
117
 
116
118
  def commandify(klass)
@@ -26,6 +26,7 @@ module Moonshot
26
26
  attr_accessor :ssh_command
27
27
  attr_accessor :ssh_config
28
28
  attr_accessor :ssh_instance
29
+ attr_accessor :template_s3_bucket
29
30
 
30
31
  def initialize
31
32
  @default_parameter_source = AskUserSource.new
@@ -176,14 +176,39 @@ module Moonshot
176
176
  raise "Could not describe stack: #{name}"
177
177
  end
178
178
 
179
+ def upload_template_to_s3
180
+ unless @config.template_s3_bucket
181
+ raise 'The S3 bucket to store the template in is not configured.'
182
+ end
183
+
184
+ s3_object_key = "#{@name}-#{Time.now.getutc.to_i}-#{File.basename(template.filename)}"
185
+ template_url = "http://#{@config.template_s3_bucket}.s3.amazonaws.com/#{s3_object_key}"
186
+
187
+ @ilog.start "Uploading template to #{template_url}" do |s|
188
+ s3_client.put_object(
189
+ bucket: @config.template_s3_bucket,
190
+ key: s3_object_key,
191
+ body: template.body
192
+ )
193
+ s.success "Template has been uploaded successfully to #{template_url}"
194
+ end
195
+
196
+ template_url
197
+ end
198
+
179
199
  def create_stack
180
- cf_client.create_stack(
200
+ parameters = {
181
201
  stack_name: @name,
182
- template_body: template.body,
183
202
  capabilities: %w(CAPABILITY_IAM CAPABILITY_NAMED_IAM),
184
203
  parameters: @config.parameters.values.map(&:to_cf),
185
204
  tags: make_tags
186
- )
205
+ }
206
+ if @config.template_s3_bucket
207
+ parameters[:template_url] = upload_template_to_s3
208
+ else
209
+ parameters[:template_body] = template.body
210
+ end
211
+ cf_client.create_stack(parameters)
187
212
  rescue Aws::CloudFormation::Errors::AccessDenied
188
213
  raise 'You are not authorized to perform create_stack calls.'
189
214
  end
@@ -195,14 +220,20 @@ module Moonshot
195
220
  Time.now.utc.to_i.to_s
196
221
  ].join('-')
197
222
 
198
- cf_client.create_change_set(
223
+ parameters = {
199
224
  change_set_name: change_set_name,
200
225
  description: "Moonshot update command for application '#{Moonshot.config.app_name}'",
201
226
  stack_name: @name,
202
- template_body: template.body,
203
227
  capabilities: %w(CAPABILITY_IAM CAPABILITY_NAMED_IAM),
204
228
  parameters: @config.parameters.values.map(&:to_cf)
205
- )
229
+ }
230
+ if @config.template_s3_bucket
231
+ parameters[:template_url] = upload_template_to_s3
232
+ else
233
+ parameters[:template_body] = template.body
234
+ end
235
+
236
+ cf_client.create_change_set(parameters)
206
237
 
207
238
  change_set_name
208
239
  end
@@ -289,7 +320,12 @@ module Moonshot
289
320
  end
290
321
 
291
322
  def doctor_check_template_against_aws
292
- cf_client.validate_template(template_body: template.body)
323
+ if @config.template_s3_bucket
324
+ parameters[:template_url] = upload_template_to_s3
325
+ else
326
+ parameters[:template_body] = template.body
327
+ end
328
+ cf_client.validate_template(parameters)
293
329
  success('CloudFormation template is valid.')
294
330
  rescue => e
295
331
  critical('Invalid CloudFormation template!', e.message)
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: 2.0.0.beta3
4
+ version: 2.0.0.beta4
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: 2017-07-25 00:00:00.000000000 Z
11
+ date: 2017-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk