simple_deploy 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/lib/simple_deploy/stack/stack_attribute_formater.rb +29 -10
- data/lib/simple_deploy/version.rb +1 -1
- data/simple_deploy.gemspec +1 -1
- data/spec/stack_spec.rb +52 -78
- metadata +13 -13
data/CHANGELOG
CHANGED
@@ -11,11 +11,12 @@ module SimpleDeploy
|
|
11
11
|
|
12
12
|
def updated_attributes(attributes)
|
13
13
|
updates = []
|
14
|
-
attributes.each do |
|
15
|
-
key =
|
14
|
+
attributes.each do |attrhash|
|
15
|
+
key = attrhash.keys.first
|
16
16
|
if artifact_names.include? key
|
17
|
-
|
18
|
-
|
17
|
+
url_hash = cloud_formation_url attrhash, attributes
|
18
|
+
updates << url_hash
|
19
|
+
@logger.info "Adding artifact attribute: #{url_hash}"
|
19
20
|
end
|
20
21
|
end
|
21
22
|
attributes + updates
|
@@ -26,13 +27,12 @@ module SimpleDeploy
|
|
26
27
|
def artifact_names
|
27
28
|
@config.artifacts
|
28
29
|
end
|
29
|
-
|
30
|
-
def cloud_formation_url(attribute)
|
31
|
-
name = attribute.keys.first
|
32
|
-
id = attribute[name]
|
33
30
|
|
34
|
-
|
35
|
-
|
31
|
+
def cloud_formation_url(selected_attribute, updated_attributes)
|
32
|
+
name = selected_attribute.keys.first
|
33
|
+
id = selected_attribute[name]
|
34
|
+
|
35
|
+
bucket_prefix, domain = find_bucket_prefix_and_domain selected_attribute, updated_attributes
|
36
36
|
artifact = Artifact.new :name => name,
|
37
37
|
:id => id,
|
38
38
|
:region => @region,
|
@@ -44,5 +44,24 @@ module SimpleDeploy
|
|
44
44
|
{ url_parameter => artifact.endpoints['s3'] }
|
45
45
|
end
|
46
46
|
|
47
|
+
def find_bucket_prefix_and_domain(selected_attribute, updated_attributes)
|
48
|
+
name = selected_attribute.keys.first
|
49
|
+
|
50
|
+
bucket_match = updated_attributes.find { |h| h.has_key? "#{name}_bucket_prefix" }
|
51
|
+
if bucket_match
|
52
|
+
bucket_prefix = bucket_match["#{name}_bucket_prefix"]
|
53
|
+
else
|
54
|
+
bucket_prefix = @main_attributes["#{name}_bucket_prefix"]
|
55
|
+
end
|
56
|
+
|
57
|
+
domain_match = updated_attributes.find { |h| h.has_key? "#{name}_domain" }
|
58
|
+
if domain_match
|
59
|
+
domain = domain_match["#{name}_domain"]
|
60
|
+
else
|
61
|
+
domain = @main_attributes["#{name}_domain"]
|
62
|
+
end
|
63
|
+
|
64
|
+
[bucket_prefix, domain]
|
65
|
+
end
|
47
66
|
end
|
48
67
|
end
|
data/simple_deploy.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_development_dependency "rspec"
|
22
22
|
|
23
23
|
s.add_runtime_dependency "capistrano"
|
24
|
-
s.add_runtime_dependency "stackster", '= 0.
|
24
|
+
s.add_runtime_dependency "stackster", '= 0.3.0'
|
25
25
|
s.add_runtime_dependency "tinder"
|
26
26
|
s.add_runtime_dependency "trollop"
|
27
27
|
end
|
data/spec/stack_spec.rb
CHANGED
@@ -4,99 +4,82 @@ describe SimpleDeploy do
|
|
4
4
|
|
5
5
|
before do
|
6
6
|
@logger_stub = stub 'logger stub', :info => 'true', :warn => 'true'
|
7
|
-
|
8
7
|
@environment_config_mock = mock 'environment config mock'
|
9
|
-
|
10
|
-
@
|
11
|
-
@
|
8
|
+
|
9
|
+
@config_stub = stub 'config stub', :region => 'us-west-1', :logger => @logger_stub
|
10
|
+
@config_stub.stub(:environment).and_return(@environment_config_mock)
|
11
|
+
@config_stub.stub(:artifacts).and_return(['chef_repo', 'cookbooks', 'app'])
|
12
|
+
@config_stub.stub(:artifact_cloud_formation_url).and_return('CookBooksURL')
|
12
13
|
|
13
14
|
SimpleDeploy::Config.should_receive(:new).
|
14
15
|
with(:logger => 'my-logger').
|
15
|
-
and_return @
|
16
|
+
and_return @config_stub
|
16
17
|
@stack = SimpleDeploy::Stack.new :environment => 'test-env',
|
17
18
|
:name => 'test-stack',
|
18
19
|
:logger => 'my-logger',
|
19
|
-
:config => @
|
20
|
+
:config => @config_stub
|
21
|
+
|
22
|
+
@main_attributes = {
|
23
|
+
'chef_repo_bucket_prefix' => 'test-prefix',
|
24
|
+
'chef_repo_domain' => 'test-domain'
|
25
|
+
}
|
26
|
+
|
27
|
+
@stack_mock = mock 'stackster stack'
|
20
28
|
|
21
|
-
@
|
29
|
+
@expected_attributes = [
|
30
|
+
{ 'chef_repo' => 'test123' },
|
31
|
+
{ 'CookBooksURL' => 's3://test-prefix-us-west-1/test-domain/test123.tar.gz' }
|
32
|
+
]
|
22
33
|
end
|
23
34
|
|
24
|
-
describe "
|
25
|
-
|
26
|
-
|
27
|
-
stack_mock = mock 'stackster stack mock'
|
28
|
-
stack_mock.stub(:attributes).and_return(@main_attributes)
|
29
|
-
@config_mock.should_receive(:environment).with('test-env').
|
30
|
-
and_return @environment_config_mock
|
31
|
-
SimpleDeploy::StackAttributeFormater.should_receive(:new).
|
32
|
-
with(:config => @config_mock,
|
33
|
-
:environment => 'test-env',
|
34
|
-
:main_attributes => @main_attributes).
|
35
|
-
and_return saf_mock
|
36
|
-
Stackster::Stack.should_receive(:new).with(:environment => 'test-env',
|
37
|
-
:name => 'test-stack',
|
38
|
-
:config => @environment_config_mock,
|
39
|
-
:logger => @logger_stub).
|
40
|
-
and_return stack_mock
|
41
|
-
saf_mock.should_receive(:updated_attributes).with({'arg1' => 'val'}).
|
42
|
-
and_return('arg1' => 'new_val')
|
43
|
-
stack_mock.should_receive(:create).with :attributes => { 'arg1' => 'new_val' },
|
44
|
-
:template => 'some_json'
|
45
|
-
@stack.create(:attributes => { 'arg1' => 'val' },
|
46
|
-
:template => 'some_json')
|
35
|
+
describe "creating a stack" do
|
36
|
+
before do
|
37
|
+
@stack_mock.stub(:attributes).and_return({})
|
47
38
|
end
|
48
39
|
|
49
|
-
it "should
|
50
|
-
deployment_stub = stub 'deployment', :clear_for_deployment? => true
|
51
|
-
@stack.stub(:deployment).and_return(deployment_stub)
|
52
|
-
|
53
|
-
saf_mock = mock 'stack attribute formater mock'
|
54
|
-
stack_mock = mock 'stackster stack mock'
|
55
|
-
stack_mock.stub(:attributes).and_return(@main_attributes)
|
56
|
-
@config_mock.should_receive(:environment).with('test-env').
|
57
|
-
and_return @environment_config_mock
|
58
|
-
SimpleDeploy::StackAttributeFormater.should_receive(:new).
|
59
|
-
with(:config => @config_mock,
|
60
|
-
:environment => 'test-env',
|
61
|
-
:main_attributes => @main_attributes).
|
62
|
-
and_return saf_mock
|
40
|
+
it "should set the attributes using what is passed to the create command" do
|
63
41
|
Stackster::Stack.should_receive(:new).with(:environment => 'test-env',
|
64
42
|
:name => 'test-stack',
|
65
43
|
:config => @environment_config_mock,
|
66
44
|
:logger => @logger_stub).
|
67
|
-
and_return stack_mock
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
45
|
+
and_return @stack_mock
|
46
|
+
|
47
|
+
expecteds = [
|
48
|
+
{ 'chef_repo' => 'test123' },
|
49
|
+
{ 'chef_repo_bucket_prefix' => 'test-prefix' },
|
50
|
+
{ 'chef_repo_domain' => 'test-domain' },
|
51
|
+
{ 'CookBooksURL' => 's3://test-prefix-us-west-1/test-domain/test123.tar.gz' }
|
52
|
+
]
|
53
|
+
@stack_mock.should_receive(:create).with :attributes => expecteds,
|
54
|
+
:template => 'some_json'
|
55
|
+
|
56
|
+
attributes = [
|
57
|
+
{ 'chef_repo' => 'test123' },
|
58
|
+
{ 'chef_repo_bucket_prefix' => 'test-prefix' },
|
59
|
+
{ 'chef_repo_domain' => 'test-domain' }
|
60
|
+
]
|
61
|
+
|
62
|
+
@stack.create :attributes => attributes, :template => 'some_json'
|
72
63
|
end
|
73
|
-
|
74
64
|
end
|
75
65
|
|
76
66
|
describe "updating a stack" do
|
67
|
+
before do
|
68
|
+
@stack_mock.stub(:attributes).and_return(@main_attributes)
|
69
|
+
end
|
70
|
+
|
77
71
|
it "should update when the deployment is not locked" do
|
78
72
|
deployment_stub = stub 'deployment', :clear_for_deployment? => true
|
79
73
|
@stack.stub(:deployment).and_return(deployment_stub)
|
80
74
|
|
81
|
-
saf_mock = mock 'stack attribute formater mock'
|
82
|
-
stack_mock = mock 'stackster stack mock'
|
83
|
-
stack_mock.stub(:attributes).and_return(@main_attributes)
|
84
|
-
@config_mock.should_receive(:environment).with('test-env').
|
85
|
-
and_return @environment_config_mock
|
86
|
-
SimpleDeploy::StackAttributeFormater.should_receive(:new).
|
87
|
-
with(:config => @config_mock,
|
88
|
-
:environment => 'test-env',
|
89
|
-
:main_attributes => @main_attributes).
|
90
|
-
and_return saf_mock
|
91
75
|
Stackster::Stack.should_receive(:new).with(:environment => 'test-env',
|
92
76
|
:name => 'test-stack',
|
93
77
|
:config => @environment_config_mock,
|
94
78
|
:logger => @logger_stub).
|
95
|
-
and_return stack_mock
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
@stack.update :attributes => { 'arg1' => 'val' }
|
79
|
+
and_return @stack_mock
|
80
|
+
@stack_mock.should_receive(:update).with :attributes => @expected_attributes
|
81
|
+
|
82
|
+
@stack.update :attributes => [{ 'chef_repo' => 'test123' }]
|
100
83
|
end
|
101
84
|
|
102
85
|
it "should not update when the deployment is locked and force is not set" do
|
@@ -115,23 +98,14 @@ describe SimpleDeploy do
|
|
115
98
|
deployment_mock.should_receive(:clear_deployment_lock).with(true)
|
116
99
|
@stack.stub(:deployment).and_return(deployment_mock)
|
117
100
|
|
118
|
-
saf_mock = mock 'stack attribute formater mock'
|
119
|
-
stack_mock = mock 'stackster stack mock'
|
120
|
-
stack_mock.stub(:attributes).and_return(@main_attributes)
|
121
|
-
SimpleDeploy::StackAttributeFormater.should_receive(:new).
|
122
|
-
with(:config => @config_mock,
|
123
|
-
:environment => 'test-env',
|
124
|
-
:main_attributes => @main_attributes).
|
125
|
-
and_return saf_mock
|
126
101
|
Stackster::Stack.should_receive(:new).with(:environment => 'test-env',
|
127
102
|
:name => 'test-stack',
|
128
103
|
:config => @environment_config_mock,
|
129
104
|
:logger => @logger_stub).
|
130
|
-
and_return stack_mock
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
@stack.update :force => true, :attributes => { 'arg1' => 'val' }
|
105
|
+
and_return @stack_mock
|
106
|
+
@stack_mock.should_receive(:update).with :attributes => @expected_attributes
|
107
|
+
|
108
|
+
@stack.update :force => true, :attributes => [{ 'chef_repo' => 'test123' }]
|
135
109
|
end
|
136
110
|
|
137
111
|
it "should not update when the deployment is locked and force is set false" do
|
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.5.
|
4
|
+
version: 0.5.2
|
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
|
+
date: 2012-10-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2164719400 !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: *
|
24
|
+
version_requirements: *2164719400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: capistrano
|
27
|
-
requirement: &
|
27
|
+
requirement: &2164718320 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,21 +32,21 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2164718320
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: stackster
|
38
|
-
requirement: &
|
38
|
+
requirement: &2164716240 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - =
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
43
|
+
version: 0.3.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2164716240
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: tinder
|
49
|
-
requirement: &
|
49
|
+
requirement: &2164728520 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2164728520
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: trollop
|
60
|
-
requirement: &
|
60
|
+
requirement: &2164727880 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2164727880
|
69
69
|
description: I am designed to deploy artifacts uploaded by Heirloom
|
70
70
|
email:
|
71
71
|
- brett@weav.net
|