chef-sugar-rackspace 0.2.0 → 0.3.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: 0283047c23349f14f045529d7f6c3ef9a63c8c02
4
- data.tar.gz: 43f6d7037c2e4bb5d25205c28a1c37711b431179
3
+ metadata.gz: b2ea2b95702f677b15c5e8ca4a97d2e721a9402f
4
+ data.tar.gz: 249a1b705d2893af550ab8591b8f655ad0d8beb8
5
5
  SHA512:
6
- metadata.gz: 4c3b2319fa418958f59f8a87625acd5369c27843156a4f579ea54a37003e23fbc5a797b6b886e268145b8f9d27759a5948f33852f5f7eef042b370f47de54a42
7
- data.tar.gz: b38250b16635c73386bcde1592434644d21f27afcd5a6883d08637fdf8ef938928215eb994e9321255ed1d8a4d64c7f54ccc4fbc08eb79ceda65c4152eeb1982
6
+ metadata.gz: 34048dfae0277faa95803b8a27e3c2c2c0581390464846fea0039af11cdc5e988bbfbf757d78653688a021607795b5aed59e4a3674958f8b9f9680d28e695faf
7
+ data.tar.gz: fe0c1d1078cd5fac5ac18bd62b2b1fbbac26c881f81562835bdcb795c872c93f328327e1c8d7a12add885f45058119742de785ee55ccb0c2f0148ed9ac53b517
data/.rubocop.yml ADDED
@@ -0,0 +1,21 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-04-07 11:00:29 -0500 using RuboCop version 0.30.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ Metrics/AbcSize:
9
+ Max: 20
10
+
11
+ Metrics/LineLength:
12
+ Max: 100
13
+
14
+ Metrics/MethodLength:
15
+ Max: 20
16
+
17
+ Style/Documentation:
18
+ Enabled: false
19
+
20
+ Style/ModuleFunction:
21
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  chef-sugar-rackspace CHANGELOG
2
2
  ==============================
3
3
 
4
+ 0.3.0
5
+ -----
6
+ - [martinb3] - Bumped chefspec pinning to newer
7
+ - [martinb3] - Added rubocop
8
+ - [jarosser06] - rackconnected? no longer fails if the rackconnect ohai plugin is not installed
9
+
4
10
  0.2.0
5
11
  -----
6
12
  - [jarosser06] - Added rackconnected? sugar method
data/Gemfile CHANGED
@@ -1,2 +1,5 @@
1
1
  source 'https://rubygems.org'
2
+
2
3
  gemspec
4
+
5
+ gem 'rubocop'
data/README.md CHANGED
@@ -17,6 +17,11 @@ Rackconnect helpers require the [Rackconnect Ohai plugin](https://github.com/jar
17
17
 
18
18
  - `rackconnected?` - return true if the node is rackconnected
19
19
 
20
+ ####Note
21
+ If the rackconnect plugin is not installed but the helper is called
22
+ rackconnected? will return false. This should not be an issue in most
23
+ cases but could cause unexepected results on a rackconnected server.
24
+
20
25
  #### rackconnected?
21
26
  ```ruby
22
27
  unless rackconnected?
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rspec/core/rake_task'
4
4
  RSpec::Core::RakeTask.new do |t|
5
5
  t.rspec_opts = [
6
6
  '--color',
7
- '--format progress',
7
+ '--format progress'
8
8
  ].join(' ')
9
9
  end
10
10
 
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
23
  spec.require_paths = %w(lib)
24
24
 
25
- spec.add_runtime_dependency 'chef-sugar', '~> 2.0'
25
+ spec.add_runtime_dependency 'chef-sugar', '~> 3.0'
26
26
 
27
27
  spec.add_development_dependency 'rake'
28
28
  spec.add_development_dependency 'bundler', '~> 1.3'
@@ -9,7 +9,7 @@ class Chef
9
9
  ## if no label is passed and more than one cloud
10
10
  ## network is attached it will pop the first off
11
11
  ## the array
12
- def cloud_network_ip(node, label=nil)
12
+ def cloud_network_ip(node, label = nil)
13
13
  networks = cloud_networks(node)
14
14
  return '' if networks.empty?
15
15
 
@@ -21,40 +21,37 @@ class Chef
21
21
  end
22
22
 
23
23
  ## Return the first ip address in ips
24
- return net['ips'].first['ip']
24
+ net['ips'].first['ip']
25
25
  end
26
26
 
27
27
  def best_rackspace_ip_for(node, other)
28
- begin
29
- ## Fail early if either node has no cloud networks
30
- node_clnet = cloud_networks(node)
31
- fail if node_clnet.empty?
28
+ node_clnet = cloud_networks(node)
29
+ fail 'no cloud networks found for this node' if node_clnet.empty?
32
30
 
33
- other_clnet = cloud_networks(other)
34
- fail if other_clnet.empty?
31
+ other_clnet = cloud_networks(other)
32
+ fail 'no cloud networks found for other node' if other_clnet.empty?
35
33
 
36
- ip = nil
37
- node_clnet.each_key do |node_label|
38
- other_clnet.each_key do |other_label|
39
- if node_label == other_label
40
- ip = other_clnet[node_label]['ips'].first['ip']
41
- end
34
+ ip = nil
35
+ node_clnet.each_key do |node_label|
36
+ other_clnet.each_key do |other_label|
37
+ if node_label == other_label
38
+ ip = other_clnet[node_label]['ips'].first['ip']
42
39
  end
43
40
  end
41
+ end
44
42
 
45
- # Couldn't locate a matching cloud network, falling through
46
- fail if ip.nil?
43
+ # Couldn't locate a matching cloud network, falling through
44
+ fail 'could not locate a matching cloud network' if ip.nil?
47
45
 
48
- return ip
49
- rescue
50
- best_ip_for(node, other)
51
- end
46
+ return ip
47
+ rescue
48
+ best_ip_for(node, other)
52
49
  end
53
50
 
54
51
  def cloud_networks(node)
55
52
  networks = {}
56
- return networks unless node.has_key? 'rackspace'
57
- if node['rackspace'].has_key? 'private_networks'
53
+ return networks unless node.key? 'rackspace'
54
+ if node['rackspace'].key? 'private_networks'
58
55
  private_networks = node['rackspace']['private_networks']
59
56
 
60
57
  unless private_networks.nil? || private_networks.empty?
@@ -64,12 +61,12 @@ class Chef
64
61
  end
65
62
  end
66
63
 
67
- return networks
64
+ networks
68
65
  end
69
66
  end
70
67
 
71
68
  module DSL
72
- def cloud_network_ip(label=nil)
69
+ def cloud_network_ip(label = nil)
73
70
  Chef::Sugar::IP.cloud_network_ip(node, label)
74
71
  end
75
72
 
@@ -6,11 +6,11 @@ class Chef
6
6
  extend self
7
7
 
8
8
  def rackconnected?(node)
9
- return false unless node.has_key? 'rackspace'
10
- if node['rackspace'].has_key? 'rackconnect'
9
+ return false unless node.key? 'rackspace'
10
+ if node['rackspace'].key? 'rackconnect'
11
11
  return node['rackspace']['rackconnect']['enabled']
12
12
  else
13
- fail 'must have rackconnect ohai plugin installed'
13
+ return false
14
14
  end
15
15
  end
16
16
  end
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  module Sugar
3
3
  module Rackspace
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
6
6
  end
7
7
  end
data/metadata.rb CHANGED
@@ -1,8 +1,8 @@
1
- name 'chef-sugar-rackspace'
2
- maintainer 'Jim Rosser'
1
+ name 'chef-sugar-rackspace'
2
+ maintainer 'Jim Rosser'
3
3
  maintainer_email 'jarosser06@gmail.com'
4
- license 'MIT'
5
- description 'Installs the chef-sugar-rackspace gem'
4
+ license 'MIT'
5
+ description 'Installs the chef-sugar-rackspace gem'
6
6
  long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
- require File.expand_path('../lib/chef/sugar/rackspace/version', __FILE__)
8
- version Chef::Sugar::Rackspace::VERSION
7
+ require File.expand_path('../lib/chef/sugar/rackspace/version', __FILE__)
8
+ version Chef::Sugar::Rackspace::VERSION
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Chef::Sugar::IP do
4
-
5
4
  fake_node = {
6
5
  'cloud' => {
7
6
  'public_ipv4' => '23.253.110.230',
@@ -38,14 +37,14 @@ describe Chef::Sugar::IP do
38
37
  context 'when on different cloud networks' do
39
38
  before do
40
39
  node['rackspace']['private_networks'] = [{
41
- 'ips' => [{ 'ip' => '192.168.10.2' }],
42
- 'label' => 'myprivatenet1'
43
- }]
40
+ 'ips' => [{ 'ip' => '192.168.10.2' }],
41
+ 'label' => 'myprivatenet1'
42
+ }]
44
43
 
45
44
  other['rackspace']['private_networks'] = [{
46
- 'ips' => [{ 'ip' => '192.168.12.4' }],
47
- 'label' => 'myprivatenet2'
48
- }]
45
+ 'ips' => [{ 'ip' => '192.168.12.4' }],
46
+ 'label' => 'myprivatenet2'
47
+ }]
49
48
  end
50
49
  it '#best_rackspace_ip_for returns the service net ip address' do
51
50
  expect(described_class.best_rackspace_ip_for(node, other)).to eq(other['cloud']['local_ipv4'])
@@ -59,14 +58,14 @@ describe Chef::Sugar::IP do
59
58
  context 'when on the same cloud network' do
60
59
  before do
61
60
  node['rackspace']['private_networks'] = [{
62
- 'ips' => [{ 'ip' => '192.168.10.2' }],
63
- 'label' => 'myprivatenet1'
64
- }]
61
+ 'ips' => [{ 'ip' => '192.168.10.2' }],
62
+ 'label' => 'myprivatenet1'
63
+ }]
65
64
 
66
65
  other['rackspace']['private_networks'] = [{
67
- 'ips' => [{ 'ip' => '192.168.10.4' }],
68
- 'label' => 'myprivatenet1'
69
- }]
66
+ 'ips' => [{ 'ip' => '192.168.10.4' }],
67
+ 'label' => 'myprivatenet1'
68
+ }]
70
69
  end
71
70
  it '#best_rackspace_ip_for returns other\'s cloud network ip address' do
72
71
  expect(described_class.best_rackspace_ip_for(node, other)).to eq('192.168.10.4')
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Chef::Sugar::Rackconnect do
4
-
5
4
  fake_node = {
6
5
  'rackspace' => {}
7
6
  }
@@ -9,8 +8,8 @@ describe Chef::Sugar::Rackconnect do
9
8
  let(:node) { fake_node }
10
9
 
11
10
  context 'when the ohai plugin is not found' do
12
- it '#rackconnected? raises an error' do
13
- expect{described_class.rackconnected?(node)}.to raise_error(RuntimeError)
11
+ it '#rackconnected? returns false' do
12
+ expect(described_class.rackconnected?(node)).to eq(false)
14
13
  end
15
14
  end
16
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-sugar-rackspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Rosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-07 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-sugar
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -103,6 +103,7 @@ extra_rdoc_files: []
103
103
  files:
104
104
  - ".gitignore"
105
105
  - ".kitchen.yml"
106
+ - ".rubocop.yml"
106
107
  - ".travis.yml"
107
108
  - Berksfile
108
109
  - CHANGELOG.md