moonshot 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cdc444c7d1abfc032353018913e6a8eccb90b035
4
- data.tar.gz: 82a6a2f524bc812d9c0c7155b1437a10c378594d
3
+ metadata.gz: 706a76719c8af3e934f0f141d79ca04513456fa6
4
+ data.tar.gz: 7f4912bacb3d49ba8015d71130db779ef1e912ed
5
5
  SHA512:
6
- metadata.gz: 870266482ea59c020549ec66f4cd114b4cdb2dff89957a18387ff3eb6409b5f7f1b831c06c0503397ed79cc597bfdc659b8d9100bfeb9d2df3f177aad5953538
7
- data.tar.gz: efbef2587e5b0305c608bcdd21695388145a98f981097eb5be875dcb27faa1cbeac1e354631891b3fd8ced6b3d898d7c3d59050199ea21c006decb65e8072c84
6
+ metadata.gz: 9fd5749505b66b86c639aef84e862a3b83360ee66528d34930131282754cec3d018f7dbad38bc0d6c9887bfc5b8d9b8aa850b50fa1535fa2949511c2b49cabb2
7
+ data.tar.gz: f2d265eaf095ad3e387cef1ce435405875645873f74ce938bd1b0f547e11a1042f0fc0138c4a7b88c4b55602ff9c6923cccb98130532a72f8211c35166cd4a8a
@@ -26,7 +26,7 @@ class Moonshot::ArtifactRepository::S3Bucket
26
26
  key = filename_for_version(version_name)
27
27
 
28
28
  ilog.start_threaded "Uploading #{file} to s3://#{bucket_name}/#{key}" do |s|
29
- s3_client.put_object(key: key, body: File.open(file), bucket: bucket_name)
29
+ upload_to_s3(file, key)
30
30
  s.success "Uploaded s3://#{bucket_name}/#{key} successfully."
31
31
  end
32
32
  end
@@ -37,6 +37,15 @@ class Moonshot::ArtifactRepository::S3Bucket
37
37
 
38
38
  private
39
39
 
40
+ def upload_to_s3(file, key)
41
+ s3_client.put_object(
42
+ key: key,
43
+ body: File.open(file),
44
+ bucket: @bucket_name,
45
+ storage_class: 'STANDARD_IA'
46
+ )
47
+ end
48
+
40
49
  def doctor_check_bucket_exists
41
50
  s3_client.get_bucket_location(bucket: @bucket_name)
42
51
  success "Bucket '#{@bucket_name}' exists."
@@ -49,7 +58,12 @@ class Moonshot::ArtifactRepository::S3Bucket
49
58
  end
50
59
 
51
60
  def doctor_check_bucket_writable
52
- s3_client.put_object(key: 'test-object', body: '', bucket: @bucket_name)
61
+ s3_client.put_object(
62
+ key: 'test-object',
63
+ body: '',
64
+ bucket: @bucket_name,
65
+ storage_class: 'REDUCED_REDUNDANCY'
66
+ )
53
67
  s3_client.delete_object(key: 'test-object', bucket: @bucket_name)
54
68
  success 'Bucket is writable, new builds can be uploaded.'
55
69
  rescue => e
@@ -71,8 +71,8 @@ module Moonshot::ArtifactRepository
71
71
  Dir.mktmpdir('github_to_s3', Dir.getwd) do |tmpdir|
72
72
  Dir.chdir(tmpdir) do
73
73
  sh_out("hub release download #{version}")
74
- file = File.open(Dir.glob("*#{version}*.tar.gz").fetch(0))
75
- s3_client.put_object(key: s3_name, body: file, bucket: bucket_name)
74
+ file = Dir.glob("*#{version}*.tar.gz").fetch(0)
75
+ upload_to_s3(file, s3_name)
76
76
  end
77
77
  end
78
78
  end
@@ -71,7 +71,7 @@ module Moonshot::BuildMechanism
71
71
  say("Changelog for #{version}", :yellow)
72
72
  say("#{@changes}\n\n")
73
73
 
74
- q = "Do you wan't to tag and release this commit as #{version}? [y/n]"
74
+ q = "Do you want to tag and release this commit as #{version}? [y/n]"
75
75
  raise Thor::Error, 'Release declined.' unless yes?(q)
76
76
  end
77
77
 
@@ -1,6 +1,8 @@
1
1
  module Moonshot
2
2
  # The Controller coordinates and performs all Moonshot actions.
3
3
  class Controller # rubocop:disable ClassLength
4
+ attr_reader :config
5
+
4
6
  def initialize
5
7
  @config = ControllerConfig.new
6
8
  yield @config if block_given?
@@ -16,13 +16,17 @@ class Moonshot::DeploymentMechanism::CodeDeploy # rubocop:disable ClassLength
16
16
  # @param asg [String]
17
17
  # The logical name of the AutoScalingGroup to create and manage a Deployment
18
18
  # Group for in CodeDeploy.
19
+ # @param role [String]
20
+ # IAM role with AWSCodeDeployRole policy. CodeDeployRole is considered as
21
+ # default role if its not specified.
19
22
  # @param app_name [String, nil] (nil)
20
23
  # The name of the CodeDeploy Application and Deployment Group. By default,
21
24
  # this is the same as the stack name, and probably what you want. If you
22
25
  # have multiple deployments in a single Stack, they must have unique names.
23
- def initialize(asg:, app_name: nil)
26
+ def initialize(asg:, role: 'CodeDeployRole', app_name: nil)
24
27
  @asg_logical_id = asg
25
28
  @app_name = app_name
29
+ @codedeploy_role = role
26
30
  end
27
31
 
28
32
  def post_create_hook
@@ -180,9 +184,9 @@ class Moonshot::DeploymentMechanism::CodeDeploy # rubocop:disable ClassLength
180
184
  end
181
185
 
182
186
  def role
183
- iam_client.get_role(role_name: 'CodeDeployRole').role
187
+ iam_client.get_role(role_name: @codedeploy_role).role
184
188
  rescue Aws::IAM::Errors::NoSuchEntity
185
- raise Thor::Error, 'Did not find an IAM Role: CodeDeployRole'
189
+ raise Thor::Error, "Did not find an IAM Role: #{@codedeploy_role}"
186
190
  end
187
191
 
188
192
  def delete_deployment_group
@@ -281,8 +285,8 @@ class Moonshot::DeploymentMechanism::CodeDeploy # rubocop:disable ClassLength
281
285
  end
282
286
 
283
287
  def doctor_check_code_deploy_role
284
- iam_client.get_role(role_name: 'CodeDeployRole').role
285
- success('CodeDeployRole exists.')
288
+ iam_client.get_role(role_name: @codedeploy_role).role
289
+ success("#{@codedeploy_role} exists.")
286
290
  rescue => e
287
291
  help = <<-EOF
288
292
  Error: #{e.message}
@@ -290,7 +294,7 @@ Error: #{e.message}
290
294
  For information on provisioning an account for use with CodeDeploy, see:
291
295
  http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-create-service-role.html
292
296
  EOF
293
- critical('Could not find CodeDeployRole, ', help)
297
+ critical("Could not find #{@codedeploy_role}, ", help)
294
298
  end
295
299
 
296
300
  def doctor_check_auto_scaling_resource_defined
@@ -60,7 +60,9 @@ module Moonshot
60
60
  end
61
61
  end
62
62
 
63
- should_wait ? wait_for_stack_state(:stack_update_complete, 'updated') : true
63
+ success = should_wait ? wait_for_stack_state(:stack_update_complete, 'updated') : true
64
+ raise Thor::Error, 'Failed to update the CloudFormation Stack.' unless success
65
+ success
64
66
  end
65
67
 
66
68
  def delete
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Moonshot
2
4
  # A StackTemplate loads the JSON template from disk and stores information
3
5
  # about it.
@@ -18,7 +20,9 @@ module Moonshot
18
20
  raise
19
21
  end
20
22
 
21
- @body = File.read(filename)
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
22
26
  end
23
27
 
24
28
  def parameters
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.7.0
4
+ version: 0.7.1
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-03-10 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk