kitchen-digitalocean 0.8.0.pre1 → 0.8.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccc0c06837baf2d9f228b5415b1b8d663900b1e6
4
- data.tar.gz: 7698c10da2f2b786a3d032273b452d2de1ea83c7
3
+ metadata.gz: 7162a19c2408c4f1f1f965120d34482a0946a3e4
4
+ data.tar.gz: 6bc37a3e482c27595ffa155f0dcd5356ac534f27
5
5
  SHA512:
6
- metadata.gz: 1a3f917e5742397efe95e9fa4c216dac32f4878961f9a43a32dd2fbdcb81003c39b851f8abdf72e5c54dcf793943b932a0511c5be882df855eae44a539504ca0
7
- data.tar.gz: e389ffc4079832011843131960d752fa2d1dcebd95f0209f8b27e4465a821e61e77ff39f01953f6f9d631f84efe7ada31d32a22ebc567fb94310bdd9af8a8314
6
+ metadata.gz: a90f4f5bc4ea67e76f04d4bf116d4a598f30a347339e9d2c063dddcbacc78b6573fec9f72f4c4975a59d8ac78b2ac066d4de3517e3a8741f7ea9ca6983ce6e48
7
+ data.tar.gz: 51d39d58131da506a022f4106df0fa8d283f48e642f1d0f67df7850bd0803d52c21860573387f94b007fdaddfcc30430ba3ab2d7bde474aa2638665e6ce864b4
data/.travis.yml CHANGED
@@ -1,8 +1,6 @@
1
1
  ---
2
2
  language: ruby
3
3
  rvm:
4
- - 1.9.3
5
- - 2.0
6
4
  - 2.1
7
5
  bundler_args: --jobs 7
8
6
  gemfile:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.8.0 / 2014-8-21
2
+
3
+ * [@RoboticCheese](https://github.com/RoboticCheese) [PR #25] Sanitize default names, limit to 63 chars
4
+
1
5
  # 0.8.0.pre1 / 2014-08-21
2
6
 
3
7
  ***Breaking Changes***
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](@https://github.com/wfarr/kitchen-digital_ocean), His fork was a help during the creation of my api v2 driver.
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
- # Generate what should be a unique server name
88
- rand_str = Array.new(8) { rand(36).to_s(36) }.join
89
- "#{instance.name}-"\
90
- "#{Etc.getlogin.gsub('_', '-')}-"\
91
- "#{rand_str}-"\
92
- "#{Socket.gethostname}"
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
@@ -19,7 +19,7 @@
19
19
  module Kitchen
20
20
  module Driver
21
21
  # Version string for Digital Ocean Kitchen driver
22
- DIGITALOCEAN_VERSION = '0.8.0.pre1'
22
+ DIGITALOCEAN_VERSION = '0.8.0'
23
23
  end
24
24
  end
25
25
 
@@ -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: 'potatoes',
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('user')
252
- allow(Socket).to receive(:gethostname).and_return('host')
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
- /^potatoes-user-(\S*)-host/)
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
@@ -27,7 +27,6 @@ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
27
27
  SimpleCov::Formatter::HTMLFormatter,
28
28
  SimpleCov::Formatter::Console
29
29
  ]
30
- SimpleCov.minimum_coverage 90
31
30
  SimpleCov.start
32
31
 
33
32
  WebMock.disable_net_connect!(allow_localhost: true)
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.pre1
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-22 00:00:00.000000000 Z
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: 1.3.1
221
+ version: '0'
222
222
  requirements: []
223
223
  rubyforge_project:
224
224
  rubygems_version: 2.4.1