simple_deploy 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.6.4:
2
+
3
+ * Check for artifact encryption via attribute name_encrypted (where name is name of archive)
4
+ * Appendes .gpg to URL for encrypted archives
5
+
1
6
  ## v0.6.3:
2
7
 
3
8
  * Instances return different message when no instances vs non existent stack
@@ -3,13 +3,14 @@ module SimpleDeploy
3
3
 
4
4
  def initialize(args)
5
5
  @bucket_prefix = args[:bucket_prefix]
6
- @id = args[:id]
7
- @name = args[:name]
8
- @region = args[:region]
9
- @domain = args[:domain]
6
+ @id = args[:id]
7
+ @name = args[:name]
8
+ @region = args[:region]
9
+ @domain = args[:domain]
10
+ @encrypted = args[:encrypted]
10
11
 
11
12
  @bucket = "#{@bucket_prefix}-#{@region}"
12
- @key = "#{@id}.tar.gz"
13
+ @key = @encrypted ? "#{@id}.tar.gz.gpg" : "#{@id}.tar.gz"
13
14
  end
14
15
 
15
16
  def endpoints
@@ -75,12 +75,14 @@ module SimpleDeploy
75
75
  variable = @config.artifact_deploy_variable artifact
76
76
  bucket_prefix = attributes["#{artifact}_bucket_prefix"]
77
77
  domain = attributes["#{artifact}_domain"]
78
+ encrypted = attributes["#{artifact}_encrypted"] == 'true'
78
79
 
79
80
  artifact = Artifact.new :name => artifact,
80
81
  :id => attributes[artifact],
81
82
  :region => @region,
82
83
  :domain => domain,
83
- :bucket_prefix => bucket_prefix
84
+ :bucket_prefix => bucket_prefix,
85
+ :encrypted => encrypted
84
86
 
85
87
  h[variable] = artifact.endpoints['s3']
86
88
  end
@@ -2,24 +2,26 @@ module SimpleDeploy
2
2
  class StackAttributeFormater
3
3
 
4
4
  def initialize(args)
5
- @config = args[:config]
6
- @environment = args[:environment]
5
+ @config = args[:config]
6
+ @environment = args[:environment]
7
7
  @main_attributes = args[:main_attributes]
8
- @region = @config.region @environment
9
- @logger = @config.logger
8
+ @region = @config.region @environment
9
+ @logger = @config.logger
10
10
  end
11
11
 
12
12
  def updated_attributes(attributes)
13
+ @provided_attributes = attributes
14
+
13
15
  updates = []
14
- attributes.each do |attrhash|
16
+ @provided_attributes.each do |attrhash|
15
17
  key = attrhash.keys.first
16
18
  if artifact_names.include? key
17
- url_hash = cloud_formation_url attrhash, attributes
19
+ url_hash = cloud_formation_url attrhash, @provided_attributes
18
20
  updates << url_hash
19
21
  @logger.info "Adding artifact attribute: #{url_hash}"
20
22
  end
21
23
  end
22
- attributes + updates
24
+ @provided_attributes + updates
23
25
  end
24
26
 
25
27
  private
@@ -33,15 +35,28 @@ module SimpleDeploy
33
35
  id = selected_attribute[name]
34
36
 
35
37
  bucket_prefix, domain = find_bucket_prefix_and_domain selected_attribute, updated_attributes
38
+
36
39
  artifact = Artifact.new :name => name,
37
40
  :id => id,
38
41
  :region => @region,
39
42
  :config => @config,
40
43
  :domain => domain,
44
+ :encrypted => artifact_encrypted?(name),
41
45
  :bucket_prefix => bucket_prefix
42
46
 
43
47
  url_parameter = @config.artifact_cloud_formation_url name
44
- { url_parameter => artifact.endpoints['s3'] }
48
+ url_value = artifact.endpoints['s3']
49
+
50
+ { url_parameter => url_value }
51
+ end
52
+
53
+ def artifact_encrypted?(name)
54
+ provided_attributes_encrypted = @provided_attributes.select do |attribute|
55
+ attribute["#{name}_encrypted"] == 'true'
56
+ end.any?
57
+ main_attributes_encrypted = @main_attributes["#{name}_encrypted"] == 'true'
58
+
59
+ provided_attributes_encrypted || main_attributes_encrypted
45
60
  end
46
61
 
47
62
  def find_bucket_prefix_and_domain(selected_attribute, updated_attributes)
@@ -124,8 +124,8 @@ module SimpleDeploy
124
124
  end
125
125
 
126
126
  def stack_attribute_formater
127
- @saf ||= StackAttributeFormater.new :config => @config,
128
- :environment => @environment,
127
+ @saf ||= StackAttributeFormater.new :config => @config,
128
+ :environment => @environment,
129
129
  :main_attributes => attributes
130
130
  end
131
131
 
@@ -1,3 +1,3 @@
1
1
  module SimpleDeploy
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  end
@@ -4,20 +4,40 @@ describe SimpleDeploy do
4
4
 
5
5
  describe "an artifact" do
6
6
 
7
- before do
8
- @artifact = SimpleDeploy::Artifact.new :bucket_prefix => 'test_prefix',
9
- :domain => 'us-west-1',
10
- :id => 'abc123',
11
- :name => 'myapp',
12
- :region => 'us-west-1'
13
- end
7
+ context "when unencrypted" do
8
+ before do
9
+ @artifact = SimpleDeploy::Artifact.new :bucket_prefix => 'test_prefix',
10
+ :domain => 'us-west-1',
11
+ :id => 'abc123',
12
+ :name => 'myapp',
13
+ :region => 'us-west-1',
14
+ :encrypted => false
15
+ end
14
16
 
15
- it "should return the endpoints for the artifact" do
16
- endpoints = { "s3" => "s3://test_prefix-us-west-1/us-west-1/abc123.tar.gz",
17
- "http" => "http://s3-us-west-1.amazonaws.com/test_prefix-us-west-1/us-west-1/abc123.tar.gz",
18
- "https" => "https://s3-us-west-1.amazonaws.com/test_prefix-us-west-1/us-west-1/abc123.tar.gz" }
19
- @artifact.endpoints.should == endpoints
17
+ it "should return the endpoints for the artifact" do
18
+ endpoints = { "s3" => "s3://test_prefix-us-west-1/us-west-1/abc123.tar.gz",
19
+ "http" => "http://s3-us-west-1.amazonaws.com/test_prefix-us-west-1/us-west-1/abc123.tar.gz",
20
+ "https" => "https://s3-us-west-1.amazonaws.com/test_prefix-us-west-1/us-west-1/abc123.tar.gz" }
21
+ @artifact.endpoints.should == endpoints
22
+ end
20
23
  end
21
24
 
25
+ context "when encrypted" do
26
+ before do
27
+ @artifact = SimpleDeploy::Artifact.new :bucket_prefix => 'test_prefix',
28
+ :domain => 'us-west-1',
29
+ :id => 'abc123',
30
+ :name => 'myapp',
31
+ :region => 'us-west-1',
32
+ :encrypted => true
33
+ end
34
+
35
+ it "should return the endpoints for the artifact" do
36
+ endpoints = { "s3" => "s3://test_prefix-us-west-1/us-west-1/abc123.tar.gz.gpg",
37
+ "http" => "http://s3-us-west-1.amazonaws.com/test_prefix-us-west-1/us-west-1/abc123.tar.gz.gpg",
38
+ "https" => "https://s3-us-west-1.amazonaws.com/test_prefix-us-west-1/us-west-1/abc123.tar.gz.gpg" }
39
+ @artifact.endpoints.should == endpoints
40
+ end
41
+ end
22
42
  end
23
43
  end
@@ -86,51 +86,75 @@ describe SimpleDeploy do
86
86
  end
87
87
 
88
88
  describe "when succesful" do
89
- before do
90
- @execute_mock = mock "execute"
91
- execute_options = { :name => 'stack-name',
92
- :environment => 'test-us-west-1',
93
- :instances => ['1.2.3.4', '4.3.2.1'],
94
- :ssh_user => 'user',
95
- :ssh_key => 'key',
96
- :config => @config_mock,
97
- :stack => @stack_mock }
98
- SimpleDeploy::Stack::Execute.should_receive(:new).
99
- with(execute_options).
100
- and_return @execute_mock
101
- @config_mock.should_receive(:artifact_deploy_variable).
102
- with("cookbooks").
103
- and_return('CHEF_REPO_URL')
104
- @config_mock.should_receive(:artifact_deploy_variable).
105
- with("app").
106
- and_return('APP_URL')
107
- @config_mock.should_receive(:artifact_deploy_variable).
108
- with("chef_repo").
109
- and_return('CHEF_REPO_URL')
110
- @execute_mock.should_receive(:execute).
111
- with( {:sudo=>true, :command=>"env CHEF_REPO_URL=s3://cookbooks_bp-test-us-west-1/cookbooks_d/cookbooks.tar.gz APP_URL=s3://app_bp-test-us-west-1/app_d/app.tar.gz PRIMARY_HOST=10.1.2.3 /tmp/script"} )
89
+ before do
90
+ @execute_mock = mock "execute"
91
+ execute_options = { :name => 'stack-name',
92
+ :environment => 'test-us-west-1',
93
+ :instances => ['1.2.3.4', '4.3.2.1'],
94
+ :ssh_user => 'user',
95
+ :ssh_key => 'key',
96
+ :config => @config_mock,
97
+ :stack => @stack_mock }
98
+ SimpleDeploy::Stack::Execute.should_receive(:new).
99
+ with(execute_options).
100
+ and_return @execute_mock
101
+ @config_mock.should_receive(:artifact_deploy_variable).
102
+ with("cookbooks").
103
+ and_return('CHEF_REPO_URL')
104
+ @config_mock.should_receive(:artifact_deploy_variable).
105
+ with("app").
106
+ and_return('APP_URL')
107
+ @config_mock.should_receive(:artifact_deploy_variable).
108
+ with("chef_repo").
109
+ and_return('CHEF_REPO_URL')
110
+ end
111
+
112
+ context "when app encrypted" do
113
+ before do
114
+ @attributes['app_encrypted'] = 'true'
115
+ @execute_mock.should_receive(:execute).
116
+ with( {:sudo=>true, :command=>"env CHEF_REPO_URL=s3://cookbooks_bp-test-us-west-1/cookbooks_d/cookbooks.tar.gz APP_URL=s3://app_bp-test-us-west-1/app_d/app.tar.gz.gpg PRIMARY_HOST=10.1.2.3 /tmp/script"} )
117
+ end
118
+
119
+ it "should deploy if the stack is clear to deploy" do
120
+ @status_mock.stub :clear_for_deployment? => true
121
+ @status_mock.should_receive(:set_deployment_in_progress)
122
+ @status_mock.should_receive(:unset_deployment_in_progress)
123
+ @deployment.execute(false).should be_true
124
+ end
125
+
126
+ it "should deploy if the stack is not clear to deploy but forced and clear in time" do
127
+ @status_mock.stub :clear_for_deployment? => false,
128
+ :clear_deployment_lock => true,
129
+ :clear_for_deployment? => true
130
+ @status_mock.should_receive(:set_deployment_in_progress)
131
+ @status_mock.should_receive(:unset_deployment_in_progress)
132
+ @deployment.execute(true).should be_true
133
+ end
112
134
  end
113
135
 
114
- it "should deploy if the stack is clear to deploy" do
115
- @status_mock.stub :clear_for_deployment? => true
116
- @status_mock.should_receive(:set_deployment_in_progress)
117
- @status_mock.should_receive(:unset_deployment_in_progress)
118
- @deployment.execute(false).should be_true
119
- end
120
-
121
- it "should deploy if the stack is not clear to deploy but forced and clear in time" do
122
- @status_mock.should_receive(:clear_for_deployment?).
123
- and_return(false)
124
- @status_mock.should_receive(:clear_deployment_lock).
125
- with(true)
126
- @status_mock.should_receive(:clear_for_deployment?).
127
- exactly(2).times.
128
- and_return(true)
129
- @status_mock.should_receive(:set_deployment_in_progress)
130
- @status_mock.should_receive(:unset_deployment_in_progress)
131
- @deployment.execute(true).should be_true
136
+ context "when unencrypted" do
137
+ before do
138
+ @execute_mock.should_receive(:execute).
139
+ with( {:sudo=>true, :command=>"env CHEF_REPO_URL=s3://cookbooks_bp-test-us-west-1/cookbooks_d/cookbooks.tar.gz APP_URL=s3://app_bp-test-us-west-1/app_d/app.tar.gz PRIMARY_HOST=10.1.2.3 /tmp/script"} )
140
+ end
141
+
142
+ it "should deploy if the stack is clear to deploy" do
143
+ @status_mock.stub :clear_for_deployment? => true
144
+ @status_mock.should_receive(:set_deployment_in_progress)
145
+ @status_mock.should_receive(:unset_deployment_in_progress)
146
+ @deployment.execute(false).should be_true
147
+ end
148
+
149
+ it "should deploy if the stack is not clear to deploy but forced and clear in time" do
150
+ @status_mock.stub :clear_for_deployment? => false,
151
+ :clear_deployment_lock => true,
152
+ :clear_for_deployment? => true
153
+ @status_mock.should_receive(:set_deployment_in_progress)
154
+ @status_mock.should_receive(:unset_deployment_in_progress)
155
+ @deployment.execute(true).should be_true
156
+ end
132
157
  end
133
-
134
158
  end
135
159
 
136
160
  describe "when unsuccesful" do
@@ -4,20 +4,64 @@ describe SimpleDeploy do
4
4
  before do
5
5
  @logger_mock = mock 'logger mock', :info => 'true'
6
6
  @config_mock = mock 'config mock', :logger => @logger_mock, :region => 'us-west-1'
7
- @config_mock.stub(:artifact_cloud_formation_url).and_return('CookBooksURL')
7
+ @config_mock.stub(:artifact_cloud_formation_url).and_return('ChefRepoURL')
8
8
  @config_mock.stub(:artifacts).and_return(['chef_repo', 'cookbooks', 'app'])
9
+ end
10
+
11
+ context "when chef_repo unencrypted" do
12
+ before do
13
+ options = { :config => @config_mock,
14
+ :environment => 'preprod',
15
+ :main_attributes => {
16
+ 'chef_repo_bucket_prefix' => 'test-prefix',
17
+ 'chef_repo_domain' => 'test-domain' }
18
+ }
19
+ @formater = SimpleDeploy::StackAttributeFormater.new options
20
+ end
21
+
22
+ it 'should return updated attributes including the un encrypted cloud formation url' do
23
+ updates = @formater.updated_attributes([ { 'chef_repo' => 'test123' } ])
24
+ updates.should == [{ 'chef_repo' => 'test123' },
25
+ { 'ChefRepoURL' => 's3://test-prefix-us-west-1/test-domain/test123.tar.gz' }]
26
+ end
27
+ end
28
+
29
+ context "when main_attributes set chef_repo encrypted" do
30
+ before do
31
+ options = { :config => @config_mock,
32
+ :environment => 'preprod',
33
+ :main_attributes => {
34
+ 'chef_repo_bucket_prefix' => 'test-prefix',
35
+ 'chef_repo_encrypted' => 'true',
36
+ 'chef_repo_domain' => 'test-domain' }
37
+ }
38
+ @formater = SimpleDeploy::StackAttributeFormater.new options
39
+ end
9
40
 
10
- options = { :config => @config_mock,
11
- :environment => 'preprod',
12
- :main_attributes => {
13
- 'chef_repo_bucket_prefix' => 'test-prefix',
14
- 'chef_repo_domain' => 'test-domain' }
15
- }
16
- @formater = SimpleDeploy::StackAttributeFormater.new options
41
+ it 'should return updated attributes including the encrypted cloud formation url ' do
42
+ updates = @formater.updated_attributes([ { 'chef_repo' => 'test123' } ])
43
+ updates.should == [{ 'chef_repo' => 'test123' },
44
+ { 'ChefRepoURL' => 's3://test-prefix-us-west-1/test-domain/test123.tar.gz.gpg' }]
45
+ end
17
46
  end
18
47
 
19
- it 'should return updated attributes including the cloud formation url' do
20
- updates = @formater.updated_attributes([ { 'chef_repo' => 'test123' } ])
21
- updates.should == [{ 'chef_repo' => 'test123' }, { 'CookBooksURL' => 's3://test-prefix-us-west-1/test-domain/test123.tar.gz' }]
48
+ context "when provided attributes set chef_repo encrypted" do
49
+ before do
50
+ options = { :config => @config_mock,
51
+ :environment => 'preprod',
52
+ :main_attributes => {
53
+ 'chef_repo_bucket_prefix' => 'test-prefix',
54
+ 'chef_repo_domain' => 'test-domain' }
55
+ }
56
+ @formater = SimpleDeploy::StackAttributeFormater.new options
57
+ end
58
+
59
+ it 'should return updated attributes including the encrypted cloud formation url ' do
60
+ updates = @formater.updated_attributes([ { 'chef_repo' => 'test123' },
61
+ { 'chef_repo_encrypted' => 'true' } ])
62
+ updates.should == [{ 'chef_repo' => 'test123' },
63
+ { 'chef_repo_encrypted' => 'true' },
64
+ { 'ChefRepoURL' => 's3://test-prefix-us-west-1/test-domain/test123.tar.gz.gpg' }]
65
+ end
22
66
  end
23
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-11 00:00:00.000000000 Z
12
+ date: 2012-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70276931560440 !ruby/object:Gem::Requirement
16
+ requirement: &70290261403920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70276931560440
24
+ version_requirements: *70290261403920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70276931559900 !ruby/object:Gem::Requirement
27
+ requirement: &70290261403200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.11.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70276931559900
35
+ version_requirements: *70290261403200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: capistrano
38
- requirement: &70276931559100 !ruby/object:Gem::Requirement
38
+ requirement: &70290261402600 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.13.5
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70276931559100
46
+ version_requirements: *70290261402600
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: stackster
49
- requirement: &70276931558560 !ruby/object:Gem::Requirement
49
+ requirement: &70290261402060 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - =
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.4.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70276931558560
57
+ version_requirements: *70290261402060
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: tinder
60
- requirement: &70276931558020 !ruby/object:Gem::Requirement
60
+ requirement: &70290261506180 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - =
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.9.1
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70276931558020
68
+ version_requirements: *70290261506180
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: trollop
71
- requirement: &70276931557360 !ruby/object:Gem::Requirement
71
+ requirement: &70290261505540 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - =
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '2.0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70276931557360
79
+ version_requirements: *70290261505540
80
80
  description: I am designed to deploy artifacts uploaded by Heirloom
81
81
  email:
82
82
  - brett@weav.net
@@ -163,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  segments:
165
165
  - 0
166
- hash: 1556323809252766114
166
+ hash: 826964826445741436
167
167
  required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  none: false
169
169
  requirements:
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  segments:
174
174
  - 0
175
- hash: 1556323809252766114
175
+ hash: 826964826445741436
176
176
  requirements: []
177
177
  rubyforge_project: simple_deploy
178
178
  rubygems_version: 1.8.16