simple_deploy 0.4.6 → 0.4.7

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ ## v0.4.7:
2
+
3
+ * Added specs
4
+ * Updated deployment to set primary host properly in classic
5
+ * Updated ssh to return classic commands properly
6
+
1
7
  ## v0.4.6:
2
8
 
3
9
  * Added spec tests
@@ -46,15 +46,21 @@ module SimpleDeploy
46
46
  end
47
47
 
48
48
  def ssh
49
- @instances.map do |i|
50
- "\nssh -i #{@ssh_key} -l #{@ssh_user} -L 9998:#{i}:22 -N #{@ssh_gateway} &\nssh -p 9998 localhost"
49
+ @stack.instances.map do |instance|
50
+ info = instance['instancesSet'].first
51
+ if info['vpcId']
52
+ gw = @attributes['ssh_gateway']
53
+ "\nssh -i #{@ssh_key} -l #{@ssh_user} -L 9998:#{info['privateIpAddress']}:22 -N #{gw} &\nssh -p 9998 localhost"
54
+ else
55
+ "\nssh -i #{@ssh_key} -l #{@ssh_user} #{info['ipAddress']}"
56
+ end
51
57
  end
52
58
  end
53
59
 
54
60
  private
55
61
 
56
62
  def set_deploy_command
57
- cmd = get_artifact_endpoints.any? ? "env " : ""
63
+ cmd = 'env '
58
64
  get_artifact_endpoints.each_pair do |key,value|
59
65
  cmd += "#{key}=#{value} "
60
66
  end
@@ -112,7 +118,9 @@ module SimpleDeploy
112
118
  end
113
119
 
114
120
  def primary_instance
115
- @instances.first
121
+ if @stack.instances.any?
122
+ @stack.instances.first['instancesSet'].first['privateIpAddress']
123
+ end
116
124
  end
117
125
 
118
126
  def deploy_script
@@ -1,3 +1,3 @@
1
1
  module SimpleDeploy
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
@@ -3,12 +3,15 @@ require 'spec_helper'
3
3
  describe SimpleDeploy do
4
4
 
5
5
  before do
6
- @attributes = { 'key' => 'val' }
6
+ @attributes = { 'key' => 'val',
7
+ 'ssh_gateway' => '1.2.3.4' }
7
8
  @config_mock = mock 'config mock'
9
+ @logger_stub = stub 'logger stub'
10
+ @logger_stub.stub :debug => 'true', :info => 'true'
8
11
  @stack_mock = mock 'stack mock'
9
12
 
10
13
  @stack_mock.should_receive(:attributes).and_return @attributes
11
- @config_mock.should_receive(:logger).and_return @logger_mock
14
+ @config_mock.should_receive(:logger).and_return @logger_stub
12
15
  @config_mock.should_receive(:region).with('test-us-west-1').
13
16
  and_return 'us-west-1'
14
17
 
@@ -26,8 +29,70 @@ describe SimpleDeploy do
26
29
  @stack.class.should == SimpleDeploy::Stack::Deployment
27
30
  end
28
31
 
29
- it "should deploy if the stack is clear to deploy"
30
- it "should deploy if the stack is not clear to deploy but forced"
31
- it "should deploy if the stack is not clear to deploy but forced"
32
+ describe "creating a deploy" do
33
+ before do
34
+ @deployment_mock = mock 'cap config'
35
+ @variables_mock = mock 'variables mock'
36
+ @artifact_mock = mock 'artifact mock'
37
+ level_stub = stub 'level'
38
+ level_stub.should_receive(:level=).with(3)
39
+ Capistrano::Configuration.should_receive(:new).and_return @deployment_mock
40
+ @deployment_mock.should_receive(:logger).and_return level_stub
41
+ @deployment_mock.should_receive(:set).with :gateway, '1.2.3.4'
42
+ @deployment_mock.should_receive(:set).with :user, 'user'
43
+ @deployment_mock.should_receive(:variables).and_return @variables_mock
44
+ @variables_mock.should_receive(:[]=).
45
+ with :ssh_options, ( { :keys => 'key',
46
+ :paranoid => false } )
47
+ @deployment_mock.should_receive(:server).with '1.2.3.4', :instances
48
+ @deployment_mock.should_receive(:server).with '4.3.2.1', :instances
49
+ @config_mock.should_receive(:artifacts).
50
+ and_return ['cookbooks']
51
+ @config_mock.should_receive(:artifact_deploy_variable).with('cookbooks').
52
+ and_return 'deploy_var'
53
+ @config_mock.should_receive(:artifact_bucket_prefix).with('cookbooks').
54
+ and_return 'bucket_prefix'
55
+ SimpleDeploy::Artifact.should_receive(:new).and_return @artifact_mock
56
+ @artifact_mock.should_receive(:endpoints).
57
+ and_return('s3' => 's3://bucket/dir/key')
58
+ @stack_mock.should_receive(:instances).exactly(2).times.
59
+ and_return [ { 'instancesSet' =>
60
+ [ { 'privateIpAddress' => '10.1.2.3' } ] } ]
61
+ @config_mock.should_receive(:deploy_script).and_return 'script.sh'
62
+ @deployment_mock.should_receive(:load).with({:string=>"task :simpledeploy do\n sudo 'env deploy_var=s3://bucket/dir/key PRIMARY_HOST=10.1.2.3 script.sh'\n end"}).and_return true
63
+ @stack.create_deployment
64
+ end
65
+
66
+ it "should deploy if the stack is clear to deploy" do
67
+ status_mock = mock 'status mock'
68
+ SimpleDeploy::Stack::Deployment::Status.should_receive(:new).
69
+ and_return status_mock
70
+ status_mock.should_receive(:cleared_to_deploy?).with(false).and_return true
71
+ status_mock.should_receive(:set_deployment_in_progress)
72
+ @deployment_mock.should_receive(:simpledeploy)
73
+ status_mock.should_receive(:unset_deployment_in_progress)
74
+ @stack.execute.should == true
75
+ end
76
+
77
+ it "should deploy if the stack is not clear to deploy but forced" do
78
+ status_mock = mock 'status mock'
79
+ SimpleDeploy::Stack::Deployment::Status.should_receive(:new).
80
+ and_return status_mock
81
+ status_mock.should_receive(:cleared_to_deploy?).with(true).and_return true
82
+ status_mock.should_receive(:set_deployment_in_progress)
83
+ @deployment_mock.should_receive(:simpledeploy)
84
+ status_mock.should_receive(:unset_deployment_in_progress)
85
+ @stack.execute(true).should == true
86
+ end
87
+
88
+ it "should deploy if the stack is not clear to deploy but forced" do
89
+ status_mock = mock 'status mock'
90
+ SimpleDeploy::Stack::Deployment::Status.should_receive(:new).
91
+ and_return status_mock
92
+ status_mock.should_receive(:cleared_to_deploy?).with(false).and_return false
93
+ @logger_stub.should_receive(:error)
94
+ @stack.execute.should == false
95
+ end
96
+ end
32
97
 
33
98
  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.4.6
4
+ version: 0.4.7
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-07-26 00:00:00.000000000 Z
12
+ date: 2012-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70150787913560 !ruby/object:Gem::Requirement
16
+ requirement: &70353611776560 !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: *70150787913560
24
+ version_requirements: *70353611776560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: capistrano
27
- requirement: &70150787912240 !ruby/object:Gem::Requirement
27
+ requirement: &70353611775520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70150787912240
35
+ version_requirements: *70353611775520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: stackster
38
- requirement: &70150787911000 !ruby/object:Gem::Requirement
38
+ requirement: &70353611735820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.2.9
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70150787911000
46
+ version_requirements: *70353611735820
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: tinder
49
- requirement: &70150787909440 !ruby/object:Gem::Requirement
49
+ requirement: &70353611734300 !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: *70150787909440
57
+ version_requirements: *70353611734300
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: trollop
60
- requirement: &70150787878560 !ruby/object:Gem::Requirement
60
+ requirement: &70353611732160 !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: *70150787878560
68
+ version_requirements: *70353611732160
69
69
  description: I am designed to deploy artifacts uploaded by Heirloom
70
70
  email:
71
71
  - brett@weav.net
@@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  segments:
138
138
  - 0
139
- hash: -5787533256512322
139
+ hash: -4377497411000345519
140
140
  required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  none: false
142
142
  requirements:
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  segments:
147
147
  - 0
148
- hash: -5787533256512322
148
+ hash: -4377497411000345519
149
149
  requirements: []
150
150
  rubyforge_project: simple_deploy
151
151
  rubygems_version: 1.8.16