cheffish 13.0.0 → 13.1.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: 6e182c603b2941d06e40d833ec685f06e25f98ba
4
- data.tar.gz: 0cd62ae5880554e897daa09d8794a4df5dd65227
3
+ metadata.gz: '009864416ce70d90ec113db22d788d8ed0eba2d5'
4
+ data.tar.gz: bb24eb7314fb2791dec51e44c6da5b4ec05cddcf
5
5
  SHA512:
6
- metadata.gz: 0ae3152e329c4678230c35ce591d0e142ae134081e254610e5be19760668ce5f0f4dae56c0dc2d1e24404d6543968fe9bf978fe242f2baa75b510bd29ba324e6
7
- data.tar.gz: 22f1b8d47e6afc666db9901fea2fc986913c2aa0fe405486c1e88977045070ebc8281e77165831054c5b54fc12493ebe09fd28f84b3d976daee5548360a46f87
6
+ metadata.gz: b7082e80979fc45e905a5cae7c0c97096ee9a28a72f187b46f9eb6377bfb18ba929c3112e51b7a4e7d4293790289d66bc634361cf6c317d524cabb5e9c262aae
7
+ data.tar.gz: 71527d52be685dda74fef2e4a5115a285360b9c2163c880725962fe9c276b97a9c2c0326fb0d972ae253ac6baee613c848d951619628c0f2b18521d8d02d509b
@@ -466,21 +466,19 @@ class Chef
466
466
  end
467
467
 
468
468
  def rest_list(path)
469
- begin
470
469
  # All our rest lists are hashes where the keys are the names
471
- [ rest.get(rest_url(path)).keys, nil ]
472
- rescue Net::HTTPServerException => e
473
- if e.response.code == "405" || e.response.code == "404"
474
- parts = path.split("/").select { |p| p != "" }.to_a
475
-
476
- # We KNOW we expect these to exist. Other containers may or may not.
477
- unless (parts.size == 1 || (parts.size == 3 && parts[0] == "organizations")) &&
478
- %w{clients containers cookbooks data environments groups nodes roles}.include?(parts[-1])
479
- return [ [], "Cannot get list of #{path}: HTTP response code #{e.response.code}" ]
480
- end
470
+ [ rest.get(rest_url(path)).keys, nil ]
471
+ rescue Net::HTTPServerException => e
472
+ if e.response.code == "405" || e.response.code == "404"
473
+ parts = path.split("/").select { |p| p != "" }.to_a
474
+
475
+ # We KNOW we expect these to exist. Other containers may or may not.
476
+ unless (parts.size == 1 || (parts.size == 3 && parts[0] == "organizations")) &&
477
+ %w{clients containers cookbooks data environments groups nodes roles}.include?(parts[-1])
478
+ return [ [], "Cannot get list of #{path}: HTTP response code #{e.response.code}" ]
481
479
  end
482
- raise
483
480
  end
481
+ raise
484
482
  end
485
483
  end
486
484
 
@@ -27,14 +27,12 @@ class Chef
27
27
 
28
28
  action_class.class_eval do
29
29
  def load_current_resource
30
- begin
31
- @current_exists = rest.get("containers/#{new_resource.chef_container_name}")
32
- rescue Net::HTTPServerException => e
33
- if e.response.code == "404"
34
- @current_exists = false
35
- else
36
- raise
37
- end
30
+ @current_exists = rest.get("containers/#{new_resource.chef_container_name}")
31
+ rescue Net::HTTPServerException => e
32
+ if e.response.code == "404"
33
+ @current_exists = false
34
+ else
35
+ raise
38
36
  end
39
37
  end
40
38
 
@@ -26,14 +26,12 @@ class Chef
26
26
 
27
27
  action_class.class_eval do
28
28
  def load_current_resource
29
- begin
30
- @current_resource = json_to_resource(rest.get("data/#{new_resource.data_bag_name}"))
31
- rescue Net::HTTPServerException => e
32
- if e.response.code == "404"
33
- @current_resource = not_found_resource
34
- else
35
- raise
36
- end
29
+ @current_resource = json_to_resource(rest.get("data/#{new_resource.data_bag_name}"))
30
+ rescue Net::HTTPServerException => e
31
+ if e.response.code == "404"
32
+ @current_resource = not_found_resource
33
+ else
34
+ raise
37
35
  end
38
36
  end
39
37
 
@@ -83,14 +83,12 @@ class Chef
83
83
 
84
84
  action_class.class_eval do
85
85
  def load_current_resource
86
- begin
87
- @current_resource = json_to_resource(rest.get("environments/#{new_resource.environment_name}"))
88
- rescue Net::HTTPServerException => e
89
- if e.response.code == "404"
90
- @current_resource = not_found_resource
91
- else
92
- raise
93
- end
86
+ @current_resource = json_to_resource(rest.get("environments/#{new_resource.environment_name}"))
87
+ rescue Net::HTTPServerException => e
88
+ if e.response.code == "404"
89
+ @current_resource = not_found_resource
90
+ else
91
+ raise
94
92
  end
95
93
  end
96
94
 
@@ -44,14 +44,12 @@ class Chef
44
44
 
45
45
  action_class.class_eval do
46
46
  def load_current_resource
47
- begin
48
- @current_resource = json_to_resource(rest.get("groups/#{new_resource.group_name}"))
49
- rescue Net::HTTPServerException => e
50
- if e.response.code == "404"
51
- @current_resource = not_found_resource
52
- else
53
- raise
54
- end
47
+ @current_resource = json_to_resource(rest.get("groups/#{new_resource.group_name}"))
48
+ rescue Net::HTTPServerException => e
49
+ if e.response.code == "404"
50
+ @current_resource = not_found_resource
51
+ else
52
+ raise
55
53
  end
56
54
  end
57
55
 
@@ -38,14 +38,12 @@ class Chef
38
38
 
39
39
  action_class.class_eval do
40
40
  def load_current_resource
41
- begin
42
- @current_resource = json_to_resource(rest.get("nodes/#{new_resource.name}"))
43
- rescue Net::HTTPServerException => e
44
- if e.response.code == "404"
45
- @current_resource = not_found_resource
46
- else
47
- raise
48
- end
41
+ @current_resource = json_to_resource(rest.get("nodes/#{new_resource.name}"))
42
+ rescue Net::HTTPServerException => e
43
+ if e.response.code == "404"
44
+ @current_resource = not_found_resource
45
+ else
46
+ raise
49
47
  end
50
48
  end
51
49
 
@@ -129,14 +129,12 @@ class Chef
129
129
 
130
130
  action_class.class_eval do
131
131
  def load_current_resource
132
- begin
133
- @current_resource = json_to_resource(rest.get("#{rest.root_url}/organizations/#{new_resource.organization_name}"))
134
- rescue Net::HTTPServerException => e
135
- if e.response.code == "404"
136
- @current_resource = not_found_resource
137
- else
138
- raise
139
- end
132
+ @current_resource = json_to_resource(rest.get("#{rest.root_url}/organizations/#{new_resource.organization_name}"))
133
+ rescue Net::HTTPServerException => e
134
+ if e.response.code == "404"
135
+ @current_resource = not_found_resource
136
+ else
137
+ raise
140
138
  end
141
139
  end
142
140
 
@@ -118,14 +118,12 @@ class Chef
118
118
 
119
119
  action_class.class_eval do
120
120
  def load_current_resource
121
- begin
122
- @current_resource = json_to_resource(rest.get("roles/#{new_resource.role_name}"))
123
- rescue Net::HTTPServerException => e
124
- if e.response.code == "404"
125
- @current_resource = not_found_resource
126
- else
127
- raise
128
- end
121
+ @current_resource = json_to_resource(rest.get("roles/#{new_resource.role_name}"))
122
+ rescue Net::HTTPServerException => e
123
+ if e.response.code == "404"
124
+ @current_resource = not_found_resource
125
+ else
126
+ raise
129
127
  end
130
128
  end
131
129
 
@@ -86,13 +86,11 @@ module Cheffish
86
86
  end
87
87
 
88
88
  def converge
89
- begin
90
- client.converge
91
- @converged = true
92
- rescue RuntimeError => e
93
- @raised_exception = e
94
- raise
95
- end
89
+ client.converge
90
+ @converged = true
91
+ rescue RuntimeError => e
92
+ @raised_exception = e
93
+ raise
96
94
  end
97
95
 
98
96
  def reset
@@ -3,8 +3,8 @@ require "chef/mash"
3
3
  module Cheffish
4
4
  class MergedConfig
5
5
  def initialize(*configs)
6
- @configs = configs.map { |config| Chef::Mash.from_hash config }
7
- @merge_arrays = Chef::Mash.new
6
+ @configs = configs.map { |config| Mash.from_hash config.to_hash }
7
+ @merge_arrays = Mash.new
8
8
  end
9
9
 
10
10
  include Enumerable
@@ -48,6 +48,7 @@ module Cheffish
48
48
  end
49
49
 
50
50
  def method_missing(name, *args)
51
+ $stderr.puts "WARN: deprecated use of method_missing on a Cheffish::MergedConfig object at #{caller[0]}"
51
52
  if args.count > 0
52
53
  raise NoMethodError, "Unexpected method #{name} for MergedConfig with arguments #{args}"
53
54
  else
@@ -1,3 +1,3 @@
1
1
  module Cheffish
2
- VERSION = "13.0.0"
2
+ VERSION = "13.1.0"
3
3
  end
@@ -24,6 +24,13 @@ describe "merged_config" do
24
24
  Cheffish::MergedConfig.new(c1, c2)
25
25
  end
26
26
 
27
+ let(:nested_config) do
28
+ c1 = { :test => { :test => "val" } }
29
+ c2 = { :test => { :test2 => "val2" } }
30
+ mc = Cheffish::MergedConfig.new(c2)
31
+ Cheffish::MergedConfig.new(c1, mc)
32
+ end
33
+
27
34
  it "returns value in config" do
28
35
  expect(config.test).to eq("val")
29
36
  end
@@ -57,4 +64,8 @@ describe "merged_config" do
57
64
  it "merges values when they're hashes" do
58
65
  expect(config_hashes[:test].keys).to eq(%w{test test2})
59
66
  end
67
+
68
+ it "supports nested merged configs" do
69
+ expect(nested_config[:test].keys).to eq(%w{test test2})
70
+ end
60
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheffish
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.0.0
4
+ version: 13.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-03 00:00:00.000000000 Z
11
+ date: 2017-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-zero
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.6.11
133
+ rubygems_version: 2.6.13
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: A library to manipulate Chef in Chef.