dpl 1.8.32.travis.1949.5 → 1.8.32.travis.1950.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/lib/dpl/provider/elastic_beanstalk.rb +14 -8
- data/spec/provider/elastic_beanstalk_spec.rb +32 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 300ef455e344f5471132a6df110e5a6760c66094
|
4
|
+
data.tar.gz: b48aaf52eea60bfc5462b18d1d1a56ec70ecf239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4a5d47be5d641d18ea3fa810f5f18c809ea3ff28d17e8975e47d82d2dfeff016161d36c96b2673ee1a5eeeeef90af1aa04b2835f31f98fcbc3c479161eb8afa
|
7
|
+
data.tar.gz: 30c9c127ebeee2e643d2220ae4a0539201a0ea11dd518f7d27db94398a44a7d16f5d36bbefed2a0cf6a686cb7189820f49ed41d80678844cccc8af2a6afd48db
|
data/Gemfile
CHANGED
@@ -49,6 +49,7 @@ group :cloud_files do
|
|
49
49
|
gem 'fog-google', '< 0.1.1', platforms: :mri_19
|
50
50
|
gem 'fog-profitbricks', '< 2.0', platforms: :mri_19
|
51
51
|
gem 'fog'
|
52
|
+
gem 'nokogiri', '~> 1.6.8.1'
|
52
53
|
end
|
53
54
|
|
54
55
|
group :releases do
|
@@ -61,9 +62,8 @@ group :gcs do
|
|
61
62
|
end
|
62
63
|
|
63
64
|
group :elastic_beanstalk do
|
65
|
+
gem 'aws-sdk', '~> 2.6.32'
|
64
66
|
gem 'rubyzip', '~> 1.1'
|
65
|
-
gem 'nokogiri', '~>1.6.8'
|
66
|
-
gem 'aws-sdk-v1'
|
67
67
|
end
|
68
68
|
|
69
69
|
group :bitballoon do
|
@@ -5,8 +5,7 @@ module DPL
|
|
5
5
|
class ElasticBeanstalk < Provider
|
6
6
|
experimental 'AWS Elastic Beanstalk'
|
7
7
|
|
8
|
-
requires '
|
9
|
-
requires 'aws-sdk-v1'
|
8
|
+
requires 'aws-sdk'
|
10
9
|
requires 'rubyzip', :load => 'zip'
|
11
10
|
|
12
11
|
DEFAULT_REGION = 'us-east-1'
|
@@ -24,7 +23,11 @@ module DPL
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def check_auth
|
27
|
-
|
26
|
+
options = {
|
27
|
+
:region => region,
|
28
|
+
:credentials => Aws::Credentials.new(access_key_id, secret_access_key)
|
29
|
+
}
|
30
|
+
Aws.config.update(options)
|
28
31
|
end
|
29
32
|
|
30
33
|
def check_app
|
@@ -88,11 +91,11 @@ module DPL
|
|
88
91
|
end
|
89
92
|
|
90
93
|
def s3
|
91
|
-
@s3 ||=
|
94
|
+
@s3 ||= Aws::S3::Resource.new
|
92
95
|
end
|
93
96
|
|
94
97
|
def eb
|
95
|
-
@eb ||=
|
98
|
+
@eb ||= Aws::ElasticBeanstalk::Client.new
|
96
99
|
end
|
97
100
|
|
98
101
|
def bucket_exists?
|
@@ -121,9 +124,12 @@ module DPL
|
|
121
124
|
end
|
122
125
|
|
123
126
|
def upload(key, file)
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
+
options = {
|
128
|
+
:body => Pathname.new(file).open
|
129
|
+
}
|
130
|
+
bucket = s3.bucket(bucket_name)
|
131
|
+
obj = bucket_path ? bucket.object("#{bucket_path}#{key}") : bucket.object(key)
|
132
|
+
obj.put(options)
|
127
133
|
obj
|
128
134
|
end
|
129
135
|
|
@@ -1,14 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'aws-sdk
|
2
|
+
require 'aws-sdk'
|
3
3
|
require 'dpl/provider'
|
4
4
|
require 'dpl/provider/elastic_beanstalk'
|
5
5
|
|
6
6
|
describe DPL::Provider::ElasticBeanstalk do
|
7
7
|
|
8
|
-
before (:each) do
|
9
|
-
AWS.stub!
|
10
|
-
end
|
11
|
-
|
12
8
|
let(:access_key_id) { 'qwertyuiopasdfghjklz' }
|
13
9
|
let(:secret_access_key) { 'qwertyuiopasdfghjklzqwertyuiopasdfghjklz' }
|
14
10
|
let(:region) { 'us-west-2' }
|
@@ -27,7 +23,15 @@ describe DPL::Provider::ElasticBeanstalk do
|
|
27
23
|
|
28
24
|
let(:s3_mock) do
|
29
25
|
hash_dbl = double("Hash", :[] => bucket_mock, :map => [])
|
30
|
-
double("
|
26
|
+
double("Aws::S3", buckets: hash_dbl, config: hash_dbl)
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:io_double) do
|
30
|
+
double('IO', open: Object.new)
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:s3_obj_double) do
|
34
|
+
double("Aws::S3::Object", put: Object.new)
|
31
35
|
end
|
32
36
|
|
33
37
|
subject :provider do
|
@@ -48,40 +52,49 @@ describe DPL::Provider::ElasticBeanstalk do
|
|
48
52
|
|
49
53
|
describe "#check_auth" do
|
50
54
|
example do
|
51
|
-
expect(
|
55
|
+
expect(Aws.config).to receive(:update)
|
52
56
|
provider.check_auth
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
56
60
|
describe "#push_app" do
|
57
61
|
|
58
|
-
let(:bucket_name) { "travis-elasticbeanstalk-test-builds-#{region}" }
|
59
62
|
let(:app_version) { Object.new }
|
60
63
|
|
64
|
+
before :each do
|
65
|
+
allow(io_double).to receive(:open)
|
66
|
+
allow(s3_obj_double).to receive(:put).with(anything).and_return(Object.new)
|
67
|
+
allow(s3_mock).to receive(:bucket).with(bucket_name).and_return(bucket_mock)
|
68
|
+
expect(Pathname).to receive(:new).with('/path/to/file.zip').and_return(io_double)
|
69
|
+
end
|
70
|
+
|
61
71
|
example 'bucket exists already' do
|
62
72
|
allow(s3_mock.buckets).to receive(:map).and_return([bucket_name])
|
73
|
+
allow(bucket_mock).to receive(:object).with("some/app/file.zip").and_return(s3_obj_double)
|
63
74
|
|
64
75
|
expect(provider).to receive(:s3).and_return(s3_mock).twice
|
65
76
|
expect(provider).not_to receive(:create_bucket)
|
66
77
|
expect(provider).to receive(:create_zip).and_return('/path/to/file.zip')
|
67
78
|
expect(provider).to receive(:archive_name).and_return('file.zip')
|
68
|
-
expect(bucket_mock.objects).to receive(:[]).with("#{bucket_path}/file.zip").and_return(bucket_mock)
|
69
79
|
expect(provider).to receive(:upload).with('file.zip', '/path/to/file.zip').and_call_original
|
70
80
|
expect(provider).to receive(:sleep).with(5)
|
71
|
-
expect(provider).to receive(:create_app_version).with(
|
81
|
+
expect(provider).to receive(:create_app_version).with(s3_obj_double).and_return(app_version)
|
72
82
|
expect(provider).to receive(:update_app).with(app_version)
|
73
83
|
|
74
84
|
provider.push_app
|
75
85
|
end
|
76
86
|
|
77
87
|
example 'bucket doesnt exist yet' do
|
88
|
+
allow(s3_mock.buckets).to receive(:map).and_return([])
|
89
|
+
allow(bucket_mock).to receive(:object).with("some/app/file.zip").and_return(s3_obj_double)
|
90
|
+
|
78
91
|
expect(provider).to receive(:s3).and_return(s3_mock).twice
|
79
92
|
expect(provider).to receive(:create_bucket)
|
80
93
|
expect(provider).to receive(:create_zip).and_return('/path/to/file.zip')
|
81
94
|
expect(provider).to receive(:archive_name).and_return('file.zip')
|
82
95
|
expect(provider).to receive(:upload).with('file.zip', '/path/to/file.zip').and_call_original
|
83
96
|
expect(provider).to receive(:sleep).with(5)
|
84
|
-
expect(provider).to receive(:create_app_version).with(
|
97
|
+
expect(provider).to receive(:create_app_version).with(s3_obj_double).and_return(app_version)
|
85
98
|
expect(provider).to receive(:update_app).with(app_version)
|
86
99
|
|
87
100
|
provider.push_app
|
@@ -91,6 +104,8 @@ describe DPL::Provider::ElasticBeanstalk do
|
|
91
104
|
let(:only_create_app_version) { true }
|
92
105
|
|
93
106
|
example 'verify the app is not updated' do
|
107
|
+
allow(s3_mock.buckets).to receive(:map).and_return([])
|
108
|
+
allow(bucket_mock).to receive(:object).with("some/app/file.zip").and_return(s3_obj_double)
|
94
109
|
|
95
110
|
expect(provider).to receive(:s3).and_return(s3_mock).twice
|
96
111
|
expect(provider).to receive(:create_bucket)
|
@@ -98,7 +113,7 @@ describe DPL::Provider::ElasticBeanstalk do
|
|
98
113
|
expect(provider).to receive(:archive_name).and_return('file.zip')
|
99
114
|
expect(provider).to receive(:upload).with('file.zip', '/path/to/file.zip').and_call_original
|
100
115
|
expect(provider).to receive(:sleep).with(5)
|
101
|
-
expect(provider).to receive(:create_app_version).with(
|
116
|
+
expect(provider).to receive(:create_app_version).with(s3_obj_double).and_return(app_version)
|
102
117
|
expect(provider).not_to receive(:update_app).with(app_version)
|
103
118
|
|
104
119
|
provider.push_app
|
@@ -107,6 +122,7 @@ describe DPL::Provider::ElasticBeanstalk do
|
|
107
122
|
|
108
123
|
context 'When the bucket_path option is not set' do
|
109
124
|
example 'Does not prepend bucket_path to the s3 bucket' do
|
125
|
+
allow(bucket_mock).to receive(:object).with("file.zip").and_return(s3_obj_double)
|
110
126
|
allow(s3_mock.buckets).to receive(:map).and_return([bucket_name])
|
111
127
|
|
112
128
|
expect(provider_without_bucket_path).to receive(:s3).and_return(s3_mock).twice
|
@@ -114,10 +130,9 @@ describe DPL::Provider::ElasticBeanstalk do
|
|
114
130
|
expect(provider_without_bucket_path).to receive(:create_zip).and_return('/path/to/file.zip')
|
115
131
|
expect(provider_without_bucket_path).to receive(:archive_name).and_return('file.zip')
|
116
132
|
expect(provider_without_bucket_path).to receive(:bucket_path).and_return(nil)
|
117
|
-
expect(bucket_mock.objects).to receive(:[]).with("file.zip").and_return(bucket_mock)
|
118
133
|
expect(provider_without_bucket_path).to receive(:upload).with('file.zip', '/path/to/file.zip').and_call_original
|
119
134
|
expect(provider_without_bucket_path).to receive(:sleep).with(5)
|
120
|
-
expect(provider_without_bucket_path).to receive(:create_app_version).with(
|
135
|
+
expect(provider_without_bucket_path).to receive(:create_app_version).with(s3_obj_double).and_return(app_version)
|
121
136
|
expect(provider_without_bucket_path).to receive(:update_app).with(app_version)
|
122
137
|
|
123
138
|
provider_without_bucket_path.push_app
|
@@ -128,13 +143,15 @@ describe DPL::Provider::ElasticBeanstalk do
|
|
128
143
|
let(:wait_until_deployed) { true }
|
129
144
|
|
130
145
|
example 'Waits until deployment completes' do
|
146
|
+
allow(bucket_mock).to receive(:object).with("some/app/file.zip").and_return(s3_obj_double)
|
147
|
+
|
131
148
|
expect(provider).to receive(:s3).and_return(s3_mock).twice
|
132
149
|
expect(provider).to receive(:create_bucket)
|
133
150
|
expect(provider).to receive(:create_zip).and_return('/path/to/file.zip')
|
134
151
|
expect(provider).to receive(:archive_name).and_return('file.zip')
|
135
152
|
expect(provider).to receive(:upload).with('file.zip', '/path/to/file.zip').and_call_original
|
136
153
|
expect(provider).to receive(:sleep).with(5)
|
137
|
-
expect(provider).to receive(:create_app_version).with(
|
154
|
+
expect(provider).to receive(:create_app_version).with(s3_obj_double).and_return(app_version)
|
138
155
|
expect(provider).to receive(:update_app).with(app_version)
|
139
156
|
expect(provider).to receive(:wait_until_deployed)
|
140
157
|
|