dpl 1.8.18.travis.1530.3 → 1.8.18.travis.1543.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +4 -0
- data/README.md +4 -1
- data/lib/dpl/provider/ops_works.rb +22 -18
- data/spec/provider/ops_works_spec.rb +93 -57
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjQ2NjZlMjdhNzBlMWY3MTg4NWZlZjBhM2Q3MTNmNTJjM2ZlYTczMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzRjODY3NzU2Y2U5YTY5MGI2NjMyYzI2Mzg4ZjZkNjlmOWNkYjMzYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzJhOTA0NjRiZTc1ZDlmMTE4NmJkZDhkMDU3MjFlMzM1NDZkZjFiZDQzZGM2
|
10
|
+
YTM1OWE0NGZkNDE3YWViYTU5MTU1ZmY5MmY1ZDRjYzI0NTJiNTAzZTA0MjFi
|
11
|
+
ZGY3MWU0OTVlNTRjMzYyMjkxYzBkMmJiMzJlYmQ3MWU0NTRlZTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDdjYWQ3YThlMjk1ZmRjZjEyYzM1MWE3NDA3NjUzZjE1Yzg2ZTkyOTdmMDM2
|
14
|
+
OGE4NmIzZmE1NTRlMjAzN2JkZDE3YzJlZWRlOTEzMTYzNjIwYzJkM2JhMjdk
|
15
|
+
YzU5NjllYTNkOWQ5YjI5Mzg1Njk3NWZiYjI1N2QxNTUzN2I0ZTI=
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -375,9 +375,11 @@ It is possible to set file-specific `Cache-Control` and `Expires` headers using
|
|
375
375
|
* **access-key-id**: AWS Access Key ID. Can be obtained from [here](https://console.aws.amazon.com/iam/home?#security_credential).
|
376
376
|
* **secret-access-key**: AWS Secret Key. Can be obtained from [here](https://console.aws.amazon.com/iam/home?#security_credential).
|
377
377
|
* **app-id**: The app ID.
|
378
|
+
* **instance-ids**: An instance id. (Use this option multiple times to specify multiple instance ids. Default: [])
|
379
|
+
* **layer-ids**: A layer id. (Use this option multiple times to specify multiple layer ids. Default: [])
|
378
380
|
* **migrate**: Migrate the database. (Default: false)
|
379
381
|
* **wait-until-deployed**: Wait until the app is deployed and return the deployment status. (Default: false)
|
380
|
-
* **custom_json**: Override custom_json options. If using this, default configuration will be overriden. See the code [here](https://github.com/travis-ci/dpl/blob/master/lib/dpl/provider/ops_works.rb#
|
382
|
+
* **custom_json**: Override custom_json options. If using this, default configuration will be overriden. See the code [here](https://github.com/travis-ci/dpl/blob/master/lib/dpl/provider/ops_works.rb#L43). More about `custom_json` [here](http://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook-json.html).
|
381
383
|
|
382
384
|
#### Environment variables:
|
383
385
|
|
@@ -387,6 +389,7 @@ It is possible to set file-specific `Cache-Control` and `Expires` headers using
|
|
387
389
|
#### Examples:
|
388
390
|
|
389
391
|
dpl --provider=opsworks --access-key-id=<access-key-id> --secret-access-key=<secret-access-key> --app-id=<app-id> --migrate --wait-until-deployed
|
392
|
+
dpl --provider=opsworks --access-key-id=<access-key-id> --secret-access-key=<secret-access-key> --app-id=<app-id> --layer-ids=<layer-id>
|
390
393
|
|
391
394
|
### Anynines:
|
392
395
|
|
@@ -3,15 +3,18 @@ require 'timeout'
|
|
3
3
|
module DPL
|
4
4
|
class Provider
|
5
5
|
class OpsWorks < Provider
|
6
|
-
requires 'aws-sdk
|
6
|
+
requires 'aws-sdk', version: '~> 2'
|
7
7
|
experimental 'AWS OpsWorks'
|
8
8
|
|
9
|
-
def
|
10
|
-
@
|
9
|
+
def opsworks
|
10
|
+
@opsworks ||= Aws::OpsWorks::Client.new(opsworks_options)
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
13
|
+
def opsworks_options
|
14
|
+
{
|
15
|
+
region: region || 'us-east-1',
|
16
|
+
credentials: ::Aws::Credentials.new(access_key_id, secret_access_key)
|
17
|
+
}
|
15
18
|
end
|
16
19
|
|
17
20
|
def needs_key?
|
@@ -22,6 +25,10 @@ module DPL
|
|
22
25
|
|
23
26
|
end
|
24
27
|
|
28
|
+
def region
|
29
|
+
options[:region] || context.env['AWS_DEFAULT_REGION']
|
30
|
+
end
|
31
|
+
|
25
32
|
def access_key_id
|
26
33
|
options[:access_key_id] || context.env['AWS_ACCESS_KEY_ID'] || raise(Error, "missing access_key_id")
|
27
34
|
end
|
@@ -30,13 +37,8 @@ module DPL
|
|
30
37
|
options[:secret_access_key] || context.env['AWS_SECRET_ACCESS_KEY'] || raise(Error, "missing secret_access_key")
|
31
38
|
end
|
32
39
|
|
33
|
-
def setup_auth
|
34
|
-
AWS.config(access_key_id: access_key_id, secret_access_key: secret_access_key)
|
35
|
-
end
|
36
|
-
|
37
40
|
def check_auth
|
38
|
-
|
39
|
-
log "Logging in with Access Key: #{option(:access_key_id)[-4..-1].rjust(20, '*')}"
|
41
|
+
log "Logging in with Access Key: #{access_key_id[-4..-1].rjust(20, '*')}"
|
40
42
|
end
|
41
43
|
|
42
44
|
def custom_json
|
@@ -61,7 +63,7 @@ module DPL
|
|
61
63
|
end
|
62
64
|
|
63
65
|
def fetch_ops_works_app
|
64
|
-
data =
|
66
|
+
data = opsworks.describe_apps(app_ids: [option(:app_id)])
|
65
67
|
unless data[:apps] && data[:apps].count == 1
|
66
68
|
raise Error, "App #{option(:app_id)} not found.", error.backtrace
|
67
69
|
end
|
@@ -87,7 +89,11 @@ module DPL
|
|
87
89
|
if !options[:instance_ids].nil?
|
88
90
|
deployment_config[:instance_ids] = Array(option(:instance_ids))
|
89
91
|
end
|
90
|
-
|
92
|
+
if !options[:layer_ids].nil?
|
93
|
+
deployment_config[:layer_ids] = Array(option(:layer_ids))
|
94
|
+
end
|
95
|
+
log "creating deployment #{deployment_config.to_json}"
|
96
|
+
data = opsworks.create_deployment(deployment_config)
|
91
97
|
log "Deployment created: #{data[:deployment_id]}"
|
92
98
|
return unless options[:wait_until_deployed]
|
93
99
|
print "Deploying "
|
@@ -103,7 +109,7 @@ module DPL
|
|
103
109
|
def wait_until_deployed(deployment_id)
|
104
110
|
deployment = nil
|
105
111
|
loop do
|
106
|
-
result =
|
112
|
+
result = opsworks.describe_deployments(deployment_ids: [deployment_id])
|
107
113
|
deployment = result[:deployments].first
|
108
114
|
break unless deployment[:status] == "running"
|
109
115
|
print "."
|
@@ -118,10 +124,8 @@ module DPL
|
|
118
124
|
|
119
125
|
def deploy
|
120
126
|
super
|
121
|
-
rescue
|
122
|
-
raise Error, "Stopping Deploy, OpsWorks error: #{error.message}", error.backtrace
|
123
|
-
rescue AWS::Errors::ServerError => error
|
124
|
-
raise Error, "Stopping Deploy, OpsWorks server error: #{error.message}", error.backtrace
|
127
|
+
rescue Aws::Errors::ServiceError => error
|
128
|
+
raise Error, "Stopping Deploy, OpsWorks service error: #{error.message}", error.backtrace
|
125
129
|
end
|
126
130
|
end
|
127
131
|
end
|
@@ -1,91 +1,127 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'aws-sdk
|
2
|
+
require 'aws-sdk'
|
3
3
|
require 'dpl/provider'
|
4
4
|
require 'dpl/provider/ops_works'
|
5
5
|
|
6
6
|
describe DPL::Provider::OpsWorks do
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
subject :provider do
|
9
|
+
described_class.new(DummyContext.new, :access_key_id => 'qwertyuiopasdfghjklz', :secret_access_key => 'qwertyuiopasdfghjklzqwertyuiopasdfghjklz')
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
describe '#opsworks_options' do
|
13
|
+
context 'without region' do
|
14
|
+
example do
|
15
|
+
options = provider.opsworks_options
|
16
|
+
expect(options[:region]).to eq('us-east-1')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with region' do
|
21
|
+
example do
|
22
|
+
region = 'us-west-1'
|
23
|
+
provider.options.update(:region => region)
|
24
|
+
options = provider.opsworks_options
|
25
|
+
expect(options[:region]).to eq(region)
|
26
|
+
end
|
27
|
+
end
|
14
28
|
end
|
15
29
|
|
16
30
|
describe "#check_auth" do
|
17
31
|
example do
|
18
|
-
expect(provider).to receive(:setup_auth)
|
19
32
|
expect(provider).to receive(:log).with('Logging in with Access Key: ****************jklz')
|
20
33
|
provider.check_auth
|
21
34
|
end
|
22
35
|
end
|
23
36
|
|
24
|
-
describe "#setup_auth" do
|
25
|
-
example do
|
26
|
-
expect(AWS).to receive(:config).with(:access_key_id => 'qwertyuiopasdfghjklz', :secret_access_key => 'qwertyuiopasdfghjklzqwertyuiopasdfghjklz').once.and_call_original
|
27
|
-
provider.setup_auth
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
37
|
describe "#needs_key?" do
|
32
38
|
example do
|
33
39
|
expect(provider.needs_key?).to eq(false)
|
34
40
|
end
|
35
41
|
end
|
36
42
|
|
37
|
-
describe
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
expect(provider).to receive(:current_sha).and_return('sha')
|
42
|
-
expect(provider.api).to receive(:client).and_return(client)
|
43
|
-
expect(provider.context.env).to receive(:[]).with('TRAVIS_BUILD_NUMBER').and_return('123')
|
44
|
-
end
|
43
|
+
describe DPL::Provider::OpsWorks do
|
44
|
+
access_key_id = 'someaccesskey'
|
45
|
+
secret_access_key = 'somesecretaccesskey'
|
46
|
+
region = 'us-east-1'
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
expect(client).to receive(:create_deployment).with(
|
52
|
-
stack_id: 'stack-id', app_id: 'app-id', command: {name: 'deploy'}, comment: 'Deploy build 123 via Travis CI', custom_json: custom_json
|
53
|
-
).and_return({})
|
54
|
-
provider.push_app
|
55
|
-
end
|
48
|
+
client_options = {
|
49
|
+
stub_responses: true,
|
50
|
+
region: region,
|
51
|
+
credentials: Aws::Credentials.new(access_key_id, secret_access_key)
|
52
|
+
}
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
stack_id: 'stack-id', app_id: 'app-id', command: {name: 'deploy'}, comment: 'Deploy build 123 via Travis CI', custom_json: custom_json_with_migrate
|
63
|
-
).and_return({})
|
64
|
-
provider.push_app
|
54
|
+
subject :provider do
|
55
|
+
described_class.new(DummyContext.new, {
|
56
|
+
access_key_id: access_key_id,
|
57
|
+
secret_access_key: secret_access_key
|
58
|
+
})
|
65
59
|
end
|
66
60
|
|
67
|
-
|
68
|
-
provider.
|
69
|
-
expect(client).to receive(:describe_apps).with(app_ids: ['app-id']).and_return({apps: [ops_works_app]})
|
70
|
-
expect(client).to receive(:create_deployment).and_return({deployment_id: 'deployment_id'})
|
71
|
-
expect(client).to receive(:describe_deployments).with({deployment_ids: ['deployment_id']}).and_return({deployments: [status: 'running']}, {deployments: [status: 'successful']})
|
72
|
-
provider.push_app
|
61
|
+
before :each do
|
62
|
+
expect(provider).to receive(:opsworks_options).and_return(client_options)
|
73
63
|
end
|
74
64
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
).and_return({})
|
81
|
-
provider.push_app
|
65
|
+
describe '#opsworks' do
|
66
|
+
example do
|
67
|
+
expect(Aws::OpsWorks::Client).to receive(:new).with(client_options).once
|
68
|
+
provider.opsworks
|
69
|
+
end
|
82
70
|
end
|
83
|
-
end
|
84
71
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
72
|
+
describe "#push_app" do
|
73
|
+
let(:client) { provider.opsworks }
|
74
|
+
let(:ops_works_app) { {shortname: 'app', stack_id: 'stack-id'} }
|
75
|
+
before do
|
76
|
+
expect(provider).to receive(:current_sha).and_return('sha')
|
77
|
+
expect(provider.context.env).to receive(:[]).with('TRAVIS_BUILD_NUMBER').and_return('123')
|
78
|
+
end
|
79
|
+
|
80
|
+
let(:custom_json) { "{\"deploy\":{\"app\":{\"migrate\":false,\"scm\":{\"revision\":\"sha\"}}}}" }
|
81
|
+
example 'without :migrate option' do
|
82
|
+
provider.options.update(app_id: 'app-id')
|
83
|
+
expect(client).to receive(:describe_apps).with(app_ids: ['app-id']).and_return({apps: [ops_works_app]})
|
84
|
+
expect(client).to receive(:create_deployment).with(
|
85
|
+
stack_id: 'stack-id', app_id: 'app-id', command: {name: 'deploy'}, comment: 'Deploy build 123 via Travis CI', custom_json: custom_json
|
86
|
+
).and_return({})
|
87
|
+
provider.push_app
|
88
|
+
end
|
89
|
+
|
90
|
+
let(:custom_json_with_migrate) { "{\"deploy\":{\"app\":{\"migrate\":true,\"scm\":{\"revision\":\"sha\"}}}}" }
|
91
|
+
example 'with :migrate option' do
|
92
|
+
provider.options.update(app_id: 'app-id', migrate: true)
|
93
|
+
expect(client).to receive(:describe_apps).with(app_ids: ['app-id']).and_return({apps: [ops_works_app]})
|
94
|
+
expect(client).to receive(:create_deployment).with(
|
95
|
+
stack_id: 'stack-id', app_id: 'app-id', command: {name: 'deploy'}, comment: 'Deploy build 123 via Travis CI', custom_json: custom_json_with_migrate
|
96
|
+
).and_return({})
|
97
|
+
provider.push_app
|
98
|
+
end
|
99
|
+
|
100
|
+
example 'with :wait_until_deployed' do
|
101
|
+
provider.options.update(app_id: 'app-id', wait_until_deployed: true)
|
102
|
+
expect(client).to receive(:describe_apps).with(app_ids: ['app-id']).and_return({apps: [ops_works_app]})
|
103
|
+
expect(client).to receive(:create_deployment).and_return({deployment_id: 'deployment_id'})
|
104
|
+
expect(client).to receive(:describe_deployments).with({deployment_ids: ['deployment_id']}).and_return({deployments: [status: 'running']}, {deployments: [status: 'successful']})
|
105
|
+
provider.push_app
|
106
|
+
end
|
107
|
+
|
108
|
+
example 'with :instance-ids' do
|
109
|
+
provider.options.update(app_id: 'app-id', instance_ids: ['instance-id'])
|
110
|
+
expect(client).to receive(:describe_apps).with(app_ids: ['app-id']).and_return({apps: [ops_works_app]})
|
111
|
+
expect(client).to receive(:create_deployment).with(
|
112
|
+
stack_id: 'stack-id', app_id: 'app-id', instance_ids:['instance-id'], command: {name: 'deploy'}, comment: 'Deploy build 123 via Travis CI', custom_json: custom_json
|
113
|
+
).and_return({})
|
114
|
+
provider.push_app
|
115
|
+
end
|
116
|
+
|
117
|
+
example 'with :layer-ids' do
|
118
|
+
provider.options.update(app_id: 'app-id', layer_ids: ['layer-id'])
|
119
|
+
expect(client).to receive(:describe_apps).with(app_ids: ['app-id']).and_return({apps: [ops_works_app]})
|
120
|
+
expect(client).to receive(:create_deployment).with(
|
121
|
+
stack_id: 'stack-id', app_id: 'app-id', layer_ids:['layer-id'], command: {name: 'deploy'}, comment: 'Deploy build 123 via Travis CI', custom_json: custom_json
|
122
|
+
).and_return({})
|
123
|
+
provider.push_app
|
124
|
+
end
|
89
125
|
end
|
90
126
|
end
|
91
127
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dpl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.18.travis.
|
4
|
+
version: 1.8.18.travis.1543.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|