kitchen-digitalocean 0.8.0.pre1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -2
- data/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/lib/kitchen/driver/digitalocean.rb +14 -6
- data/lib/kitchen/driver/digitalocean_version.rb +1 -1
- data/spec/kitchen/driver/digitalocean_spec.rb +40 -5
- data/spec/spec_helper.rb +0 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7162a19c2408c4f1f1f965120d34482a0946a3e4
|
4
|
+
data.tar.gz: 6bc37a3e482c27595ffa155f0dcd5356ac534f27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a90f4f5bc4ea67e76f04d4bf116d4a598f30a347339e9d2c063dddcbacc78b6573fec9f72f4c4975a59d8ac78b2ac066d4de3517e3a8741f7ea9ca6983ce6e48
|
7
|
+
data.tar.gz: 51d39d58131da506a022f4106df0fa8d283f48e642f1d0f67df7850bd0803d52c21860573387f94b007fdaddfcc30430ba3ab2d7bde474aa2638665e6ce864b4
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -123,9 +123,9 @@ example:
|
|
123
123
|
|
124
124
|
Created and maintained by [Greg Fitzgerald](https://github.com/gregf/) (<greg@gregf.org>)
|
125
125
|
|
126
|
-
Special Thanks
|
126
|
+
***Special Thanks:***
|
127
127
|
|
128
|
-
[Will Farrington](
|
128
|
+
[Will Farrington](https://github.com/wfarr/kitchen-digital_ocean), His fork was a help during the creation of my api v2 driver.
|
129
129
|
|
130
130
|
# License
|
131
131
|
|
@@ -83,13 +83,21 @@ module Kitchen
|
|
83
83
|
instance.platform.name
|
84
84
|
end
|
85
85
|
|
86
|
+
# Generate what should be a unique server name up to 63 total chars
|
87
|
+
# Base name: 15
|
88
|
+
# Username: 15
|
89
|
+
# Hostname: 23
|
90
|
+
# Random string: 7
|
91
|
+
# Separators: 3
|
92
|
+
# ================
|
93
|
+
# Total: 63
|
86
94
|
def default_name
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
95
|
+
[
|
96
|
+
instance.name.gsub(/\W/, '')[0..14],
|
97
|
+
Etc.getlogin.gsub(/\W/, '')[0..14],
|
98
|
+
Socket.gethostname.gsub(/\W/, '')[0..22],
|
99
|
+
Array.new(7) { rand(36).to_s(36) }.join
|
100
|
+
].join('-')
|
93
101
|
end
|
94
102
|
|
95
103
|
private
|
@@ -28,11 +28,12 @@ describe Kitchen::Driver::Digitalocean do
|
|
28
28
|
let(:logger) { Logger.new(logged_output) }
|
29
29
|
let(:config) { Hash.new }
|
30
30
|
let(:state) { Hash.new }
|
31
|
+
let(:instance_name) { 'potatoes' }
|
31
32
|
let(:platform_name) { 'ubuntu' }
|
32
33
|
|
33
34
|
let(:instance) do
|
34
35
|
double(
|
35
|
-
name:
|
36
|
+
name: instance_name,
|
36
37
|
logger: logger,
|
37
38
|
to_str: 'instance',
|
38
39
|
platform: double(name: platform_name)
|
@@ -247,14 +248,48 @@ describe Kitchen::Driver::Digitalocean do
|
|
247
248
|
# end
|
248
249
|
|
249
250
|
describe '#default_name' do
|
251
|
+
let(:login) { 'user' }
|
252
|
+
let(:hostname) { 'host' }
|
253
|
+
|
250
254
|
before(:each) do
|
251
|
-
allow(Etc).to receive(:getlogin).and_return(
|
252
|
-
allow(Socket).to receive(:gethostname).and_return(
|
255
|
+
allow(Etc).to receive(:getlogin).and_return(login)
|
256
|
+
allow(Socket).to receive(:gethostname).and_return(hostname)
|
253
257
|
end
|
254
258
|
|
255
259
|
it 'generates a name' do
|
256
|
-
expect(driver.default_name).to match(
|
257
|
-
|
260
|
+
expect(driver.default_name).to match(/^potatoes-user-host-(\S*)/)
|
261
|
+
end
|
262
|
+
|
263
|
+
context 'local node with a long hostname' do
|
264
|
+
let(:hostname) { 'ab.c' * 20 }
|
265
|
+
|
266
|
+
it 'limits the generated name to 63 characters' do
|
267
|
+
expect(driver.default_name.length).to be <= (63)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
context 'node with a long hostname, username, and base name' do
|
272
|
+
let(:login) { 'abcd' * 20 }
|
273
|
+
let(:hostname) { 'efgh' * 20 }
|
274
|
+
let(:instance_name) { 'ijkl' * 20 }
|
275
|
+
|
276
|
+
it 'limits the generated name to 63 characters' do
|
277
|
+
expect(driver.default_name.length).to eq(63)
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
context 'a login and hostname with punctuation in them' do
|
282
|
+
let(:login) { 'some.u-se-r' }
|
283
|
+
let(:hostname) { 'a.host-name' }
|
284
|
+
let(:instance_name) { 'a.instance-name' }
|
285
|
+
|
286
|
+
it 'strips out the dots to prevent bad server names' do
|
287
|
+
expect(driver.default_name).to_not include('.')
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'strips out all but the three hyphen separators' do
|
291
|
+
expect(driver.default_name.count('-')).to eq(3)
|
292
|
+
end
|
258
293
|
end
|
259
294
|
end
|
260
295
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-digitalocean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.0
|
4
|
+
version: 0.8.0
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -216,9 +216,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
216
|
version: '0'
|
217
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
218
|
requirements:
|
219
|
-
- - "
|
219
|
+
- - ">="
|
220
220
|
- !ruby/object:Gem::Version
|
221
|
-
version:
|
221
|
+
version: '0'
|
222
222
|
requirements: []
|
223
223
|
rubyforge_project:
|
224
224
|
rubygems_version: 2.4.1
|