Correct faulty Chef search query
The search returns a Hash, not a list, so we need to remove the reference to [0] in the memcached_servers library routine call otherwise you get: undefined method `[]' for nil:NilClass in chef-client runs. Change-Id: I479aca833a2eb80fa2baf3e54809b2edaa713b89
This commit is contained in:
parent
ae80d36e8f
commit
8311869e5b
|
@ -2,6 +2,10 @@
|
|||
|
||||
This file is used to list changes made in each version of cookbook-openstack-common.
|
||||
|
||||
## 0.3.1:
|
||||
* Corrected a faulty Chef search query with `#config_by_role`. The search returns a
|
||||
Hash, not an array.
|
||||
|
||||
## 0.3.0:
|
||||
* Added `#rabbit_servers` method, which returns a comma-delimited string of rabbit
|
||||
servers in the format of host:port.
|
||||
|
|
|
@ -39,7 +39,7 @@ module ::Openstack
|
|||
log("Searched for role #{role} by found no nodes with that role in run list.") { level :debug }
|
||||
nil
|
||||
else
|
||||
section.nil? ? result[0] : result[0][section]
|
||||
section.nil? ? result : result[section]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ maintainer_email "cookbooks@lists.tfoundry.com"
|
|||
license "Apache 2.0"
|
||||
description "Common OpenStack attributes, libraries and recipes."
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version "0.3.0"
|
||||
version "0.3.1"
|
||||
|
||||
recipe "openstack-common", "Installs/Configures common recipes"
|
||||
recipe "openstack-common::logging", "Installs/Configures common logging"
|
||||
|
|
|
@ -39,24 +39,20 @@ describe ::Openstack do
|
|||
end
|
||||
|
||||
it "returns section when section in first search result" do
|
||||
nodes = [
|
||||
{ "foo" => "bar" }
|
||||
]
|
||||
node = { "foo" => "bar" }
|
||||
@subject.stub(:search_for).
|
||||
with("role1").
|
||||
and_return nodes
|
||||
and_return node
|
||||
@subject.stub(:node).and_return @chef_run.node
|
||||
|
||||
expect(@subject.config_by_role("role1", "foo")).to eq "bar"
|
||||
end
|
||||
|
||||
it "returns full node hash when search match but no section supplied" do
|
||||
nodes = [
|
||||
{ "foo" => "bar" }
|
||||
]
|
||||
node = { "foo" => "bar" }
|
||||
@subject.stub(:search_for).
|
||||
with("role1").
|
||||
and_return nodes
|
||||
and_return node
|
||||
@subject.stub(:node).and_return @chef_run.node
|
||||
|
||||
expect(@subject.config_by_role("role1")).to eq("foo" => "bar")
|
||||
|
|
Loading…
Reference in New Issue