Corrected search_for
recipe and role queries
Each query needed surrounding by parens, otherwise returned an empty result. Bug: 1209037 Change-Id: I1a7de0aba30c757e244375abf4e307a36a1bff71
This commit is contained in:
parent
de99e40540
commit
eb5eed7126
@ -2,6 +2,9 @@
|
||||
|
||||
This file is used to list changes made in each version of cookbook-openstack-common.
|
||||
|
||||
## 0.4.3:
|
||||
* Corrected `#search_for` role and recipe queries.
|
||||
|
||||
## 0.4.2:
|
||||
* Remove hardcoded localhost for mysql host specification.
|
||||
|
||||
|
@ -23,8 +23,8 @@ module ::Openstack
|
||||
# @param [String] The role or recipe to be found.
|
||||
# @return [Array] The matching result or an empty list.
|
||||
def search_for r, &block
|
||||
role_query = "chef_environment:#{node.chef_environment} AND roles:#{r}"
|
||||
recipe_query = "chef_environment:#{node.chef_environment} AND recipes:#{r}".sub("::","\\:\\:")
|
||||
role_query = "(chef_environment:#{node.chef_environment} AND roles:#{r})"
|
||||
recipe_query = "(chef_environment:#{node.chef_environment} AND recipes:#{r})".sub("::","\\:\\:")
|
||||
query = "#{role_query} OR #{recipe_query}"
|
||||
|
||||
resp = search(:node, query, &block)
|
||||
|
@ -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.4.2"
|
||||
version "0.4.3"
|
||||
|
||||
recipe "openstack-common", "Installs/Configures common recipes"
|
||||
recipe "openstack-common::logging", "Installs/Configures common logging"
|
||||
|
@ -17,7 +17,7 @@ describe ::Openstack do
|
||||
it "returns results" do
|
||||
@subject.stub(:node).and_return @chef_run.node
|
||||
@subject.stub(:search).
|
||||
with(:node, "chef_environment:_default AND roles:role OR chef_environment:_default AND recipes:role").
|
||||
with(:node, "(chef_environment:_default AND roles:role) OR (chef_environment:_default AND recipes:role)").
|
||||
and_return [@chef_run.node]
|
||||
resp = @subject.search_for("role")
|
||||
|
||||
@ -27,7 +27,7 @@ describe ::Openstack do
|
||||
it "returns empty results" do
|
||||
@subject.stub(:node).and_return @chef_run.node
|
||||
@subject.stub(:search).
|
||||
with(:node, "chef_environment:_default AND roles:empty-role OR chef_environment:_default AND recipes:empty-role").
|
||||
with(:node, "(chef_environment:_default AND roles:empty-role) OR (chef_environment:_default AND recipes:empty-role)").
|
||||
and_return []
|
||||
resp = @subject.search_for("empty-role")
|
||||
|
||||
@ -37,7 +37,7 @@ describe ::Openstack do
|
||||
it "always returns empty results" do
|
||||
@subject.stub(:node).and_return @chef_run.node
|
||||
@subject.stub(:search).
|
||||
with(:node, "chef_environment:_default AND roles:empty-role OR chef_environment:_default AND recipes:empty-role").
|
||||
with(:node, "(chef_environment:_default AND roles:empty-role) OR (chef_environment:_default AND recipes:empty-role)").
|
||||
and_return nil
|
||||
resp = @subject.search_for("empty-role")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user