kitchen-digitalocean 0.7.3 → 0.8.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -3
- data/CHANGELOG.md +10 -0
- data/README.md +31 -46
- data/kitchen-digitalocean.gemspec +8 -3
- data/lib/kitchen/driver/digitalocean.rb +43 -80
- data/lib/kitchen/driver/digitalocean_version.rb +1 -1
- data/spec/kitchen/driver/digitalocean_spec.rb +58 -118
- data/spec/mocks/auth_error.txt +17 -0
- data/spec/mocks/create.txt +132 -0
- data/spec/mocks/delete.txt +16 -0
- data/spec/spec_helper.rb +25 -3
- metadata +84 -9
- data/data/digitalocean.json +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccc0c06837baf2d9f228b5415b1b8d663900b1e6
|
4
|
+
data.tar.gz: 7698c10da2f2b786a3d032273b452d2de1ea83c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a3f917e5742397efe95e9fa4c216dac32f4878961f9a43a32dd2fbdcb81003c39b851f8abdf72e5c54dcf793943b932a0511c5be882df855eae44a539504ca0
|
7
|
+
data.tar.gz: e389ffc4079832011843131960d752fa2d1dcebd95f0209f8b27e4465a821e61e77ff39f01953f6f9d631f84efe7ada31d32a22ebc567fb94310bdd9af8a8314
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# 0.8.0.pre1 / 2014-08-21
|
2
|
+
|
3
|
+
***Breaking Changes***
|
4
|
+
|
5
|
+
From this version on the driver uses API V2, the use of image_id, flavor_id, and region_id has been replaced
|
6
|
+
with image, size, region. You can now rely on slugs instead of uses IDs. Please refer to the readme for additional information.
|
7
|
+
|
8
|
+
* Upgrade to API V2
|
9
|
+
* Drop Fog, for [droplet_kit](https://github.com/digitaloceancloud/droplet_kit)
|
10
|
+
|
1
11
|
# 0.7.3 / 2014-08-19
|
2
12
|
|
3
13
|
* Add id for New York 3
|
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/kitchen-digitalocean.png)](http://badge.fury.io/rb/kitchen-digitalocean)
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/kitchen-digitalocean.png)](http://badge.fury.io/rb/kitchen-digitalocean)
|
2
|
+
[![Build Status](https://travis-ci.org/test-kitchen/kitchen-digitalocean.png?branch=master)](https://travis-ci.org/test-kitchen/kitchen-digitalocean)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/test-kitchen/kitchen-digitalocean.png)](https://codeclimate.com/github/test-kitchen/kitchen-digitalocean)
|
4
|
+
[![Dependency Status](https://gemnasium.com/test-kitchen/kitchen-digitalocean.png)](https://gemnasium.com/test-kitchen/kitchen-digitalocean)
|
2
5
|
|
3
6
|
# Kitchen::Digitalocean
|
4
7
|
|
@@ -7,6 +10,13 @@ A Test Kitchen Driver for Digital Ocean
|
|
7
10
|
Shamelessly copied from [RoboticCheese](https://github.com/RoboticCheese)'s
|
8
11
|
awesome work on an [Rackspace driver](https://github.com/RoboticCheese/kitchen-rackspace).
|
9
12
|
|
13
|
+
# Upgrading
|
14
|
+
|
15
|
+
From this version forward the driver uses [API V2](https://developers.digitalocean.com/) only.
|
16
|
+
Use of image_id, flavor_id, and region_id have been replaced with image, size, and region.
|
17
|
+
You can now use slugs instead of relying on the old data.json to translate IDs.
|
18
|
+
Please refer to the examples below, and the API documentation for more information.
|
19
|
+
|
10
20
|
# Requirements
|
11
21
|
|
12
22
|
There are no external system requirements for this driver. However you will need access to an [DigitalOcean](https://digitalocean.com/) account.
|
@@ -35,14 +45,13 @@ At minimum, you'll need to tell test-kitchen to use the digitalocean driver.
|
|
35
45
|
driver:
|
36
46
|
- name: digitalocean
|
37
47
|
platforms:
|
38
|
-
- name: ubuntu-12
|
48
|
+
- name: ubuntu-12-10-x64
|
39
49
|
```
|
40
50
|
|
41
51
|
You also have the option of providing your credentials from environment variables.
|
42
52
|
|
43
53
|
```bash
|
44
|
-
export
|
45
|
-
export DIGITALOCEAN_API_KEY="5678"
|
54
|
+
export DIGITALOCEAN_ACCESS_TOKEN="1234"
|
46
55
|
export DIGITALOCEAN_SSH_KEY_IDS="1234, 5678"
|
47
56
|
```
|
48
57
|
|
@@ -50,77 +59,49 @@ Note that your `SSH_KEY_ID` must be the numeric id of your ssh key, not the symb
|
|
50
59
|
of your keys, use something like to following command to get them from the digital ocean API:
|
51
60
|
|
52
61
|
```bash
|
53
|
-
curl -X GET https://api.digitalocean.com/v2/account/keys -H "Authorization: Bearer $
|
62
|
+
curl -X GET https://api.digitalocean.com/v2/account/keys -H "Authorization: Bearer $DIGITALOCEAN_ACCESS_TOKEN"
|
54
63
|
```
|
55
64
|
|
56
65
|
Please refer to the [Getting Started Guide](http://kitchen.ci/) for any further documentation.
|
57
66
|
|
58
67
|
# Default Configuration
|
59
68
|
|
60
|
-
|
61
|
-
|
62
|
-
```ruby
|
63
|
-
---
|
64
|
-
platforms:
|
65
|
-
- name: ubuntu-10.04
|
66
|
-
- name: ubuntu-12.04
|
67
|
-
- name: ubuntu-14.04
|
68
|
-
- name: centos-5.8
|
69
|
-
- name: centos-6.4
|
70
|
-
- name: centos-6.5
|
71
|
-
- name: centos-7.0
|
72
|
-
- name: debian-6.0
|
73
|
-
- name: debian-7.0
|
74
|
-
- name: fedora-19
|
75
|
-
- name: fedora-20
|
76
|
-
```
|
69
|
+
The driver now uses api v2 which provides slugs for image names, sizes, and regions.
|
77
70
|
|
78
|
-
|
71
|
+
Example configuration:
|
79
72
|
|
80
73
|
```ruby
|
81
74
|
---
|
82
75
|
platforms:
|
83
|
-
- name:
|
84
|
-
driver_config:
|
85
|
-
image_id: 14097
|
86
|
-
- name: ubuntu-12.04
|
76
|
+
- name: debian-7-0-x64
|
87
77
|
driver_config:
|
88
|
-
|
89
|
-
|
90
|
-
- name: centos-5.8
|
78
|
+
region: ams1
|
79
|
+
- name: centos-6-4-x64
|
91
80
|
driver_config:
|
92
|
-
|
81
|
+
size: 2gb
|
93
82
|
# ...
|
94
83
|
```
|
95
84
|
|
96
|
-
|
97
|
-
|
98
|
-
```ruby
|
99
|
-
driver:
|
100
|
-
- region: amsterdam 2
|
101
|
-
- flavor: 8GB
|
102
|
-
```
|
85
|
+
# Private Networking
|
103
86
|
|
104
|
-
|
87
|
+
Private networking is enabled by default, but will only work in certain regions. You can disable private networking by changing private_networking to
|
88
|
+
false. Example below.
|
105
89
|
|
106
90
|
```ruby
|
107
91
|
---
|
108
92
|
driver:
|
109
|
-
-
|
110
|
-
- flavor: 65
|
93
|
+
- private_networking: false
|
111
94
|
```
|
112
95
|
|
113
|
-
|
96
|
+
# IPv6
|
114
97
|
|
115
|
-
|
98
|
+
IPv6 is disabled by default, you can enable this if needed. IPv6 is only available in limited regions.
|
116
99
|
|
117
|
-
Private networking is enabled by default, but will only work in certain regions. You can disable private networking by changing private_networking to
|
118
|
-
false. Example below.
|
119
100
|
|
120
101
|
```ruby
|
121
102
|
---
|
122
103
|
driver:
|
123
|
-
-
|
104
|
+
- ipv6: true
|
124
105
|
```
|
125
106
|
|
126
107
|
# Development
|
@@ -142,6 +123,10 @@ example:
|
|
142
123
|
|
143
124
|
Created and maintained by [Greg Fitzgerald](https://github.com/gregf/) (<greg@gregf.org>)
|
144
125
|
|
126
|
+
Special Thanks
|
127
|
+
|
128
|
+
[Will Farrington](@https://github.com/wfarr/kitchen-digital_ocean), His fork was a help during the creation of my api v2 driver.
|
129
|
+
|
145
130
|
# License
|
146
131
|
|
147
132
|
Apache 2.0 (see [LICENSE](https://github.com/test-kitchen/kitchen-digitalocean/blob/master/LICENSE.txt))
|
@@ -18,14 +18,19 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(/^(test|spec|features)/)
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'test-kitchen', '~> 1.
|
22
|
-
spec.add_dependency '
|
21
|
+
spec.add_dependency 'test-kitchen', '~> 1.2'
|
22
|
+
spec.add_dependency 'droplet_kit', '~> 1.0'
|
23
23
|
|
24
|
-
spec.add_development_dependency '
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
25
|
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'rubocop'
|
26
27
|
spec.add_development_dependency 'cane'
|
27
28
|
spec.add_development_dependency 'countloc'
|
28
29
|
spec.add_development_dependency 'rspec'
|
30
|
+
spec.add_development_dependency 'webmock'
|
31
|
+
spec.add_development_dependency 'simplecov'
|
32
|
+
spec.add_development_dependency 'simplecov-console'
|
33
|
+
spec.add_development_dependency 'coveralls'
|
29
34
|
end
|
30
35
|
|
31
36
|
# vim: ai et ts=2 sts=2 sw=2 ft=ruby
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
19
|
require 'benchmark'
|
20
|
-
require '
|
20
|
+
require 'droplet_kit'
|
21
21
|
require 'kitchen'
|
22
22
|
require 'etc'
|
23
23
|
require 'socket'
|
@@ -30,41 +30,22 @@ module Kitchen
|
|
30
30
|
class Digitalocean < Kitchen::Driver::SSHBase
|
31
31
|
default_config :username, 'root'
|
32
32
|
default_config :port, '22'
|
33
|
+
default_config :region, 'nyc2'
|
34
|
+
default_config :size, '512mb'
|
35
|
+
default_config(:image) { |driver| driver.default_image }
|
36
|
+
default_config(:server_name) { |driver| driver.default_name }
|
37
|
+
default_config :private_networking, true
|
38
|
+
default_config :ipv6, false
|
33
39
|
|
34
|
-
default_config :
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
default_config :region_id do |driver|
|
39
|
-
driver.default_region
|
40
|
-
end
|
41
|
-
|
42
|
-
default_config :flavor_id do |driver|
|
43
|
-
driver.default_flavor
|
44
|
-
end
|
45
|
-
|
46
|
-
default_config :image_id do |driver|
|
47
|
-
driver.default_image
|
48
|
-
end
|
49
|
-
|
50
|
-
default_config :server_name do |driver|
|
51
|
-
driver.default_name
|
52
|
-
end
|
53
|
-
|
54
|
-
default_config :digitalocean_client_id do
|
55
|
-
ENV['DIGITALOCEAN_CLIENT_ID']
|
56
|
-
end
|
57
|
-
|
58
|
-
default_config :digitalocean_api_key do
|
59
|
-
ENV['DIGITALOCEAN_API_KEY']
|
40
|
+
default_config :digitalocean_access_token do
|
41
|
+
ENV['DIGITALOCEAN_ACCESS_TOKEN']
|
60
42
|
end
|
61
43
|
|
62
44
|
default_config :ssh_key_ids do
|
63
45
|
ENV['DIGITALOCEAN_SSH_KEY_IDS'] || ENV['SSH_KEY_IDS']
|
64
46
|
end
|
65
47
|
|
66
|
-
required_config :
|
67
|
-
required_config :digitalocean_api_key
|
48
|
+
required_config :digitalocean_access_token
|
68
49
|
required_config :ssh_key_ids
|
69
50
|
|
70
51
|
def create(state)
|
@@ -72,39 +53,34 @@ module Kitchen
|
|
72
53
|
state[:server_id] = server.id
|
73
54
|
|
74
55
|
info("Digital Ocean instance <#{state[:server_id]}> created.")
|
75
|
-
|
76
|
-
|
56
|
+
|
57
|
+
while true
|
58
|
+
sleep 8
|
59
|
+
droplet = client.droplets.find(id: state[:server_id])
|
60
|
+
|
61
|
+
break if droplet \
|
62
|
+
&& droplet.networks[:v4] \
|
63
|
+
&& droplet.networks[:v4].any? { |n| n[:type] == 'public' }
|
64
|
+
end
|
65
|
+
|
66
|
+
state[:hostname] = droplet.networks[:v4]
|
67
|
+
.find { |n| n[:type] == 'public' }['ip_address']
|
68
|
+
|
77
69
|
wait_for_sshd(state[:hostname]); print "(ssh ready)\n"
|
78
70
|
debug("digitalocean:create #{state[:hostname]}")
|
79
|
-
rescue Fog::Errors::Error, Excon::Errors::Error => ex
|
80
|
-
raise ActionFailed, ex.message
|
81
71
|
end
|
82
72
|
|
83
73
|
def destroy(state)
|
84
74
|
return if state[:server_id].nil?
|
85
75
|
|
86
|
-
|
87
|
-
server.destroy unless server.nil?
|
76
|
+
client.droplets.delete(id: state[:server_id])
|
88
77
|
info("Digital Ocean instance <#{state[:server_id]}> destroyed.")
|
89
78
|
state.delete(:server_id)
|
90
79
|
state.delete(:hostname)
|
91
80
|
end
|
92
81
|
|
93
|
-
def default_flavor
|
94
|
-
flavor = config[:flavor] ? config[:flavor].upcase : nil
|
95
|
-
data['flavors'].fetch(flavor) { '66' }
|
96
|
-
end
|
97
|
-
|
98
|
-
def default_region
|
99
|
-
regions = {}
|
100
|
-
data['regions'].each_pair do |key, value|
|
101
|
-
regions[key.upcase] = value
|
102
|
-
end
|
103
|
-
regions.fetch(config[:region] ? config[:region].upcase : nil) { '4' }
|
104
|
-
end
|
105
|
-
|
106
82
|
def default_image
|
107
|
-
|
83
|
+
instance.platform.name
|
108
84
|
end
|
109
85
|
|
110
86
|
def default_name
|
@@ -118,53 +94,40 @@ module Kitchen
|
|
118
94
|
|
119
95
|
private
|
120
96
|
|
121
|
-
def
|
122
|
-
|
97
|
+
def client
|
98
|
+
debug_client_config
|
123
99
|
|
124
|
-
|
125
|
-
provider: 'Digitalocean',
|
126
|
-
digitalocean_api_key: config[:digitalocean_api_key],
|
127
|
-
digitalocean_client_id: config[:digitalocean_client_id]
|
128
|
-
}
|
129
|
-
|
130
|
-
Fog::Compute.new(server_def)
|
100
|
+
DropletKit::Client.new(access_token: config[:digitalocean_access_token])
|
131
101
|
end
|
132
102
|
|
133
103
|
def create_server
|
134
104
|
debug_server_config
|
135
105
|
|
136
|
-
|
137
|
-
name:
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
private_networking: config[:private_networking]
|
106
|
+
droplet = DropletKit::Droplet.new(
|
107
|
+
name: config[:server_name],
|
108
|
+
region: config[:region],
|
109
|
+
image: config[:image],
|
110
|
+
size: config[:size],
|
111
|
+
ssh_keys: config[:ssh_key_ids].split(' '),
|
112
|
+
private_networking: config[:private_networking],
|
113
|
+
ipv6: config[:ipv6]
|
143
114
|
)
|
144
|
-
end
|
145
115
|
|
146
|
-
|
147
|
-
@data ||= begin
|
148
|
-
json_file = File.expand_path(
|
149
|
-
File.join(%w(.. .. .. .. data digitalocean.json)),
|
150
|
-
__FILE__
|
151
|
-
)
|
152
|
-
JSON.load(IO.read(json_file))
|
153
|
-
end
|
116
|
+
client.droplets.create(droplet)
|
154
117
|
end
|
155
118
|
|
156
119
|
def debug_server_config
|
157
120
|
debug("digitalocean:name #{config[:server_name]}")
|
158
|
-
debug("digitalocean:
|
159
|
-
debug("digitalocean:
|
160
|
-
debug("digitalocean:
|
121
|
+
debug("digitalocean:image#{config[:image]}")
|
122
|
+
debug("digitalocean:size #{config[:size]}")
|
123
|
+
debug("digitalocean:region #{config[:region]}")
|
161
124
|
debug("digitalocean:ssh_key_ids #{config[:ssh_key_ids]}")
|
162
125
|
debug("digitalocean:private_networking #{config[:private_networking]}")
|
126
|
+
debug("digitalocean:ipv6 #{config[:ipv6]}")
|
163
127
|
end
|
164
128
|
|
165
|
-
def
|
166
|
-
debug("digitalocean_api_key #{config[:
|
167
|
-
debug("digitalocean_client_id #{config[:digitalocean_client_id]}")
|
129
|
+
def debug_client_config
|
130
|
+
debug("digitalocean_api_key #{config[:digitalocean_access_token]}")
|
168
131
|
end
|
169
132
|
end
|
170
133
|
end
|
@@ -46,15 +46,14 @@ describe Kitchen::Driver::Digitalocean do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
before(:each) do
|
49
|
-
ENV['
|
50
|
-
ENV['DIGITALOCEAN_API_KEY'] = 'apikey'
|
49
|
+
ENV['DIGITALOCEAN_ACCESS_TOKEN'] = 'access_token'
|
51
50
|
ENV['DIGITALOCEAN_SSH_KEY_IDS'] = '1234'
|
52
51
|
end
|
53
52
|
|
54
53
|
describe '#initialize'do
|
55
54
|
context 'default options' do
|
56
55
|
it 'defaults to the smallest flavor size' do
|
57
|
-
expect(driver[:
|
56
|
+
expect(driver[:size]).to eq('512mb')
|
58
57
|
end
|
59
58
|
|
60
59
|
it 'defaults to SSH with root user on port 22' do
|
@@ -67,47 +66,35 @@ describe Kitchen::Driver::Digitalocean do
|
|
67
66
|
end
|
68
67
|
|
69
68
|
it 'defaults to region id 1' do
|
70
|
-
expect(driver[:
|
69
|
+
expect(driver[:region]).to eq('nyc2')
|
71
70
|
end
|
72
71
|
|
73
72
|
it 'defaults to SSH Key Ids from $SSH_KEY_IDS' do
|
74
73
|
expect(driver[:ssh_key_ids]).to eq('1234')
|
75
74
|
end
|
76
75
|
|
77
|
-
it 'defaults to
|
78
|
-
expect(driver[:
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'defaults to API key from $DIGITALOCEAN_API_KEY' do
|
82
|
-
expect(driver[:digitalocean_api_key]).to eq('apikey')
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'name is ubuntu-12.10' do
|
87
|
-
let(:platform_name) { 'ubuntu-12.10' }
|
88
|
-
|
89
|
-
it 'defaults to the correct image ID' do
|
90
|
-
expect(driver[:image_id]).to eq('473123')
|
76
|
+
it 'defaults to Access Token from $DIGITALOCEAN_ACCESS_TOKEN' do
|
77
|
+
expect(driver[:digitalocean_access_token]).to eq('access_token')
|
91
78
|
end
|
92
79
|
end
|
93
80
|
|
94
|
-
context 'name is
|
95
|
-
let(:platform_name) { '
|
81
|
+
context 'name is ubuntu-14-04-x64' do
|
82
|
+
let(:platform_name) { 'ubuntu-14-04-x64' }
|
96
83
|
|
97
84
|
it 'defaults to the correct image ID' do
|
98
|
-
expect(driver[:
|
85
|
+
expect(driver[:image]).to eq('ubuntu-14-04-x64')
|
99
86
|
end
|
100
87
|
end
|
101
88
|
|
102
89
|
context 'overridden options' do
|
103
90
|
config = {
|
104
|
-
|
105
|
-
|
91
|
+
image: 'debian-7-0-x64',
|
92
|
+
flavor: '1gb',
|
106
93
|
ssh_key_ids: '5678',
|
107
94
|
username: 'admin',
|
108
95
|
port: '2222',
|
109
96
|
server_name: 'puppy',
|
110
|
-
|
97
|
+
region: 'ams1',
|
111
98
|
flavor: '1GB'
|
112
99
|
}
|
113
100
|
|
@@ -123,7 +110,7 @@ describe Kitchen::Driver::Digitalocean do
|
|
123
110
|
|
124
111
|
describe '#create' do
|
125
112
|
let(:server) do
|
126
|
-
double(id: '
|
113
|
+
double(id: '1234', wait_for: true,
|
127
114
|
public_ip_address: '1.2.3.4')
|
128
115
|
end
|
129
116
|
let(:driver) do
|
@@ -138,22 +125,27 @@ describe Kitchen::Driver::Digitalocean do
|
|
138
125
|
context 'username and API key only provided' do
|
139
126
|
let(:config) do
|
140
127
|
{
|
141
|
-
|
142
|
-
digitalocean_api_key: 'world'
|
128
|
+
digitalocean_access_token: 'access_token'
|
143
129
|
}
|
144
130
|
end
|
145
131
|
|
146
132
|
it 'generates a server name in the absence of one' do
|
133
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/1234')
|
134
|
+
.to_return(create)
|
147
135
|
driver.create(state)
|
148
136
|
expect(driver[:server_name]).to eq('a_monkey!')
|
149
137
|
end
|
150
138
|
|
151
139
|
it 'gets a proper server ID' do
|
140
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/1234')
|
141
|
+
.to_return(create)
|
152
142
|
driver.create(state)
|
153
|
-
expect(state[:server_id]).to eq('
|
143
|
+
expect(state[:server_id]).to eq('1234')
|
154
144
|
end
|
155
145
|
|
156
146
|
it 'gets a proper hostname (IP)' do
|
147
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/1234')
|
148
|
+
.to_return(create)
|
157
149
|
driver.create(state)
|
158
150
|
expect(state[:hostname]).to eq('1.2.3.4')
|
159
151
|
end
|
@@ -177,6 +169,8 @@ describe Kitchen::Driver::Digitalocean do
|
|
177
169
|
|
178
170
|
context 'a live server that needs to be destroyed' do
|
179
171
|
it 'destroys the server' do
|
172
|
+
stub_request(:delete, 'https://api.digitalocean.com/v2/droplets/12345')
|
173
|
+
.to_return(delete)
|
180
174
|
expect(state).to receive(:delete).with(:server_id)
|
181
175
|
expect(state).to receive(:delete).with(:hostname)
|
182
176
|
driver.destroy(state)
|
@@ -209,102 +203,48 @@ describe Kitchen::Driver::Digitalocean do
|
|
209
203
|
end
|
210
204
|
|
211
205
|
it 'does not try to destroy the server again' do
|
206
|
+
stub_request(:delete, 'https://api.digitalocean.com/v2/droplets/12345')
|
207
|
+
.to_return(delete)
|
212
208
|
allow_message_expectations_on_nil
|
213
209
|
driver.destroy(state)
|
214
210
|
end
|
215
211
|
end
|
216
212
|
end
|
217
213
|
|
218
|
-
describe '#
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
end
|
253
|
-
|
254
|
-
describe '#create_server' do
|
255
|
-
let(:config) do
|
256
|
-
{
|
257
|
-
server_name: 'hello',
|
258
|
-
image_id: 'there',
|
259
|
-
flavor_id: '68',
|
260
|
-
region_id: '3',
|
261
|
-
private_networking: true,
|
262
|
-
ssh_key_ids: '1234'
|
263
|
-
}
|
264
|
-
end
|
265
|
-
before(:each) do
|
266
|
-
@expected = config.merge(name: config[:server_name])
|
267
|
-
@expected.delete_if do |k, _v|
|
268
|
-
k == :server_name
|
269
|
-
end
|
270
|
-
end
|
271
|
-
let(:servers) do
|
272
|
-
s = double('servers')
|
273
|
-
allow(s).to receive(:create) { |arg| arg }
|
274
|
-
s
|
275
|
-
end
|
276
|
-
let(:compute) { double(servers: servers) }
|
277
|
-
let(:driver) do
|
278
|
-
d = Kitchen::Driver::Digitalocean.new(config)
|
279
|
-
d.instance = instance
|
280
|
-
allow(d).to receive(:compute).and_return(compute)
|
281
|
-
d
|
282
|
-
end
|
283
|
-
|
284
|
-
it 'creates the server using a compute connection' do
|
285
|
-
expect(driver.send(:create_server)).to eq(@expected)
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
describe 'Region and Flavor names should be converted to IDs' do
|
290
|
-
let(:config) do
|
291
|
-
{
|
292
|
-
server_name: 'hello',
|
293
|
-
image_id: 'there',
|
294
|
-
flavor: '2gb',
|
295
|
-
region: 'amsterdam 2',
|
296
|
-
ssh_key_ids: '1234'
|
297
|
-
}
|
298
|
-
end
|
299
|
-
|
300
|
-
it 'defaults to the correct flavor ID' do
|
301
|
-
expect(driver[:flavor_id]).to eq('62')
|
302
|
-
end
|
303
|
-
|
304
|
-
it 'defaults to the correct region ID' do
|
305
|
-
expect(driver[:region_id]).to eq('5')
|
306
|
-
end
|
307
|
-
end
|
214
|
+
# describe '#create_server' do
|
215
|
+
# let(:config) do
|
216
|
+
# {
|
217
|
+
# server_name: 'test server',
|
218
|
+
# image: 'debian-7-0-x64',
|
219
|
+
# size: '2gb',
|
220
|
+
# region: 'nyc3',
|
221
|
+
# private_networking: true,
|
222
|
+
# ssh_key_ids: '1234'
|
223
|
+
# }
|
224
|
+
# end
|
225
|
+
# before(:each) do
|
226
|
+
# @expected = config.merge(name: config[:server_name])
|
227
|
+
# @expected.delete_if do |k, _v|
|
228
|
+
# k == :server_name
|
229
|
+
# end
|
230
|
+
# end
|
231
|
+
# let(:servers) do
|
232
|
+
# s = double('servers')
|
233
|
+
# allow(s).to receive(:create) { |arg| arg }
|
234
|
+
# s
|
235
|
+
# end
|
236
|
+
# let(:create_server) { double(servers: servers) }
|
237
|
+
# let(:driver) do
|
238
|
+
# d = Kitchen::Driver::Digitalocean.new(config)
|
239
|
+
# d.instance = instance
|
240
|
+
# allow(d).to receive(:create_server).and_return(create_server)
|
241
|
+
# d
|
242
|
+
# end
|
243
|
+
|
244
|
+
# it 'creates the server using a compute connection' do
|
245
|
+
# expect(driver.send(:create_server)).to eq(@expected)
|
246
|
+
# end
|
247
|
+
# end
|
308
248
|
|
309
249
|
describe '#default_name' do
|
310
250
|
before(:each) do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
HTTP/1.1 401 Unauthorized
|
2
|
+
Server: cloudflare-nginx
|
3
|
+
Date: Fri, 22 Aug 2014 00:23:51 GMT
|
4
|
+
Content-Type: application/json; charset=utf-8
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
Set-Cookie: __cfduid=de33405f4e3dfe14da3bc8fa075f282161408667031739; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.digitalocean.com; HttpOnly
|
8
|
+
Status: 401 Unauthorized
|
9
|
+
Cache-Control: no-store
|
10
|
+
Pragma: no-cache
|
11
|
+
WWW-Authenticate: Bearer realm="DigitalOcean", error="invalid_token", error_description="The access token is invalid"
|
12
|
+
X-Request-Id: 1da2bd7f00ee6102f4a105592ce7c5ba
|
13
|
+
X-Runtime: 0.008179
|
14
|
+
X-Rack-Cache: invalidate, pass
|
15
|
+
CF-RAY: 15daec945b0d0ed9-EWR
|
16
|
+
|
17
|
+
{"id":"unauthorized","message":"Unable to authenticate you."}
|
@@ -0,0 +1,132 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: cloudflare-nginx
|
3
|
+
Date: Thu, 21 Aug 2014 23:51:40 GMT
|
4
|
+
Content-Type: application/json; charset=utf-8
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
Set-Cookie: __cfduid=de2ed0d345ecce441bb505881fcf50d341408665100399; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.digitalocean.com; HttpOnly
|
8
|
+
Status: 200 OK
|
9
|
+
RateLimit-Limit: 1200
|
10
|
+
RateLimit-Remaining: 1191
|
11
|
+
RateLimit-Reset: 1408667389
|
12
|
+
Cache-Control: must-revalidate, private, max-age=0
|
13
|
+
X-Request-Id: 0018d68e007a1ddf51190a3f85746740
|
14
|
+
X-Runtime: 0.175303
|
15
|
+
X-Rack-Cache: miss
|
16
|
+
CF-RAY: 15dabd6d78ac00af-EWR
|
17
|
+
|
18
|
+
{
|
19
|
+
"droplet":{
|
20
|
+
"id":"1234",
|
21
|
+
"name":"test-1234",
|
22
|
+
"memory":512,
|
23
|
+
"vcpus":1,
|
24
|
+
"disk":20,
|
25
|
+
"region":{
|
26
|
+
"slug":"nyc2",
|
27
|
+
"name":"New York 2",
|
28
|
+
"sizes":[
|
29
|
+
"1gb",
|
30
|
+
"2gb",
|
31
|
+
"4gb",
|
32
|
+
"8gb",
|
33
|
+
"32gb",
|
34
|
+
"64gb",
|
35
|
+
"512mb",
|
36
|
+
"16gb",
|
37
|
+
"48gb"
|
38
|
+
],
|
39
|
+
"available":true,
|
40
|
+
"features":[
|
41
|
+
"virtio",
|
42
|
+
"private_networking",
|
43
|
+
"backups"
|
44
|
+
]
|
45
|
+
},
|
46
|
+
"image":{
|
47
|
+
"id":3445812,
|
48
|
+
"name":"Debian 7.0 x64",
|
49
|
+
"distribution":"Debian",
|
50
|
+
"slug":null,
|
51
|
+
"public":false,
|
52
|
+
"regions":[
|
53
|
+
"nyc1",
|
54
|
+
"ams1",
|
55
|
+
"sfo1",
|
56
|
+
"nyc2",
|
57
|
+
"ams2",
|
58
|
+
"sgp1",
|
59
|
+
"lon1",
|
60
|
+
"nyc3"
|
61
|
+
],
|
62
|
+
"created_at":"2014-05-02T18:16:21Z",
|
63
|
+
"action_ids":[
|
64
|
+
23178598,
|
65
|
+
23179182,
|
66
|
+
23179643,
|
67
|
+
23179647,
|
68
|
+
23179652,
|
69
|
+
23179657,
|
70
|
+
23179662,
|
71
|
+
23187797,
|
72
|
+
23188844,
|
73
|
+
23189209,
|
74
|
+
23190072,
|
75
|
+
23190271,
|
76
|
+
23190972,
|
77
|
+
23191081,
|
78
|
+
23192889,
|
79
|
+
23192901,
|
80
|
+
23193176,
|
81
|
+
23193805,
|
82
|
+
23193991,
|
83
|
+
23194165,
|
84
|
+
23194334,
|
85
|
+
23195135,
|
86
|
+
23196883,
|
87
|
+
23199694,
|
88
|
+
23200447
|
89
|
+
]
|
90
|
+
},
|
91
|
+
"size":{
|
92
|
+
"slug":"512mb",
|
93
|
+
"transfer":1,
|
94
|
+
"price_monthly":5.0,
|
95
|
+
"price_hourly":0.00744
|
96
|
+
},
|
97
|
+
"locked":false,
|
98
|
+
"status":"active",
|
99
|
+
"networks":{
|
100
|
+
"v4":[
|
101
|
+
{
|
102
|
+
"ip_address":"10.128.210.209",
|
103
|
+
"netmask":"255.255.0.0",
|
104
|
+
"gateway":"10.128.1.1",
|
105
|
+
"type":"private"
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"ip_address":"1.2.3.4",
|
109
|
+
"netmask":"255.255.255.0",
|
110
|
+
"gateway":"162.243.243.1",
|
111
|
+
"type":"public"
|
112
|
+
}
|
113
|
+
],
|
114
|
+
"v6":[]
|
115
|
+
},
|
116
|
+
"kernel":{
|
117
|
+
"id":952,
|
118
|
+
"name":"* Debian 7.0 x64 vmlinuz-3.2.0-4-amd64 (3.2.54-2)",
|
119
|
+
"version":"3.2.0-4-amd64"
|
120
|
+
},
|
121
|
+
"created_at":"2014-08-05T01:54:38Z",
|
122
|
+
"features":[
|
123
|
+
"private_networking",
|
124
|
+
"virtio"
|
125
|
+
],
|
126
|
+
"backup_ids":[],
|
127
|
+
"snapshot_ids":[],
|
128
|
+
"action_ids":[
|
129
|
+
30176699
|
130
|
+
]
|
131
|
+
}
|
132
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
HTTP/1.1 204 No Content
|
2
|
+
Server: cloudflare-nginx
|
3
|
+
Date: Fri, 22 Aug 2014 00:08:34 GMT
|
4
|
+
Content-Type: application/octet-stream
|
5
|
+
Connection: keep-alive
|
6
|
+
Set-Cookie: __cfduid=da9e671d485a710cdacdfab0537c9c5371408666113766; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.digitalocean.com; HttpOnly
|
7
|
+
Status: 204 No Content
|
8
|
+
RateLimit-Limit: 1200
|
9
|
+
RateLimit-Remaining: 1186
|
10
|
+
RateLimit-Reset: 1408667389
|
11
|
+
Cache-Control: no-cache
|
12
|
+
X-Request-Id: b1916109f4827d5df75311055b476205
|
13
|
+
X-Runtime: 0.426074
|
14
|
+
X-Rack-Cache: invalidate, pass
|
15
|
+
CF-RAY: 15dad62b0cfe00af-EWR
|
16
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -17,11 +17,33 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
19
|
require 'rspec'
|
20
|
+
require 'webmock/rspec'
|
21
|
+
require 'simplecov'
|
22
|
+
require 'simplecov-console'
|
23
|
+
require 'coveralls'
|
24
|
+
|
25
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
26
|
+
Coveralls::SimpleCov::Formatter,
|
27
|
+
SimpleCov::Formatter::HTMLFormatter,
|
28
|
+
SimpleCov::Formatter::Console
|
29
|
+
]
|
30
|
+
SimpleCov.minimum_coverage 90
|
31
|
+
SimpleCov.start
|
32
|
+
|
33
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
34
|
+
|
20
35
|
require_relative '../lib/kitchen/driver/digitalocean'
|
21
36
|
|
22
|
-
|
23
|
-
|
24
|
-
|
37
|
+
def create
|
38
|
+
File.read(File.join(File.dirname(__FILE__), 'mocks', 'create.txt'))
|
39
|
+
end
|
40
|
+
|
41
|
+
def delete
|
42
|
+
File.read(File.join(File.dirname(__FILE__), 'mocks', 'delete.txt'))
|
43
|
+
end
|
44
|
+
|
45
|
+
def auth_error
|
46
|
+
File.read(File.join(File.dirname(__FILE__), 'mocks', 'auth_error.txt'))
|
25
47
|
end
|
26
48
|
|
27
49
|
# vim: ai et ts=2 sts=2 sw=2 ft=ruby
|
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-digitalocean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Fitzgerald
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: droplet_kit
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
@@ -25,13 +39,13 @@ dependencies:
|
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '1.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '0'
|
34
|
-
type: :
|
48
|
+
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
@@ -39,7 +53,7 @@ dependencies:
|
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
@@ -53,7 +67,7 @@ dependencies:
|
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: rubocop
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -108,6 +122,62 @@ dependencies:
|
|
108
122
|
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov-console
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: coveralls
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
111
181
|
description: A Test Kitchen Driver for Digital Ocean
|
112
182
|
email:
|
113
183
|
- greg@gregf.org
|
@@ -123,11 +193,13 @@ files:
|
|
123
193
|
- LICENSE.txt
|
124
194
|
- README.md
|
125
195
|
- Rakefile
|
126
|
-
- data/digitalocean.json
|
127
196
|
- kitchen-digitalocean.gemspec
|
128
197
|
- lib/kitchen/driver/digitalocean.rb
|
129
198
|
- lib/kitchen/driver/digitalocean_version.rb
|
130
199
|
- spec/kitchen/driver/digitalocean_spec.rb
|
200
|
+
- spec/mocks/auth_error.txt
|
201
|
+
- spec/mocks/create.txt
|
202
|
+
- spec/mocks/delete.txt
|
131
203
|
- spec/spec_helper.rb
|
132
204
|
homepage: https://github.com/test-kitchen/kitchen-digitalocean
|
133
205
|
licenses:
|
@@ -144,9 +216,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
216
|
version: '0'
|
145
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
218
|
requirements:
|
147
|
-
- - "
|
219
|
+
- - ">"
|
148
220
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
221
|
+
version: 1.3.1
|
150
222
|
requirements: []
|
151
223
|
rubyforge_project:
|
152
224
|
rubygems_version: 2.4.1
|
@@ -155,4 +227,7 @@ specification_version: 4
|
|
155
227
|
summary: A Test Kitchen Driver for Digital Ocean
|
156
228
|
test_files:
|
157
229
|
- spec/kitchen/driver/digitalocean_spec.rb
|
230
|
+
- spec/mocks/auth_error.txt
|
231
|
+
- spec/mocks/create.txt
|
232
|
+
- spec/mocks/delete.txt
|
158
233
|
- spec/spec_helper.rb
|
data/data/digitalocean.json
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"images": {
|
3
|
-
"ubuntu-10.04": "5566812",
|
4
|
-
"ubuntu-12.04": "5588928",
|
5
|
-
"ubuntu-14.04": "5141286",
|
6
|
-
"centos-5.8": "1601",
|
7
|
-
"centos-6.5": "3448641",
|
8
|
-
"centos-7.0": "4856048",
|
9
|
-
"centos-6.4": "562354",
|
10
|
-
"debian-6.0": "5563026",
|
11
|
-
"debian-7.0": "5562742",
|
12
|
-
"fedora-19": "3102879",
|
13
|
-
"fedora-20": "3243145"
|
14
|
-
},
|
15
|
-
"flavors": {
|
16
|
-
"512MB": "66",
|
17
|
-
"1GB": "63",
|
18
|
-
"2GB": "62",
|
19
|
-
"4GB": "64",
|
20
|
-
"8GB": "65",
|
21
|
-
"16GB": "61",
|
22
|
-
"32GB": "60",
|
23
|
-
"48GB": "70",
|
24
|
-
"64GB": "69"
|
25
|
-
},
|
26
|
-
"regions": {
|
27
|
-
"New York 1": "1",
|
28
|
-
"New York 2": "4",
|
29
|
-
"New York 3": "8",
|
30
|
-
"Amsterdam 1": "2",
|
31
|
-
"Amsterdam 2": "5",
|
32
|
-
"San Francisco 1": "3",
|
33
|
-
"Singapore 1": "6"
|
34
|
-
}
|
35
|
-
}
|