diff options
author | Hiroaki Nakamura <hnakamur@gmail.com> | 2013-04-08 22:39:10 +0900 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2013-05-24 10:32:06 -0700 |
commit | 68ff2b7e66181d636e574641f29ace0d10f7c2b7 (patch) | |
tree | b954b115e71d00d4e28e792cde6500f6dc3d3e68 /lib/chef/data_bag.rb | |
parent | c519884f0f6628296cddd2de07b1a16b7d5561ce (diff) | |
download | chef-68ff2b7e66181d636e574641f29ace0d10f7c2b7.tar.gz |
Modify DataBag.list for chef-solo.
Diffstat (limited to 'lib/chef/data_bag.rb')
-rw-r--r-- | lib/chef/data_bag.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/chef/data_bag.rb b/lib/chef/data_bag.rb index be88d07e59..fa7755b3f8 100644 --- a/lib/chef/data_bag.rb +++ b/lib/chef/data_bag.rb @@ -82,14 +82,22 @@ class Chef end def self.list(inflate=false) - if inflate - # Can't search for all data bags like other objects, fall back to N+1 :( - list(false).inject({}) do |response, bag_and_uri| - response[bag_and_uri.first] = load(bag_and_uri.first) - response + if Chef::Config[:solo] + unless File.directory?(Chef::Config[:data_bag_path]) + raise Chef::Exceptions::InvalidDataBagPath, "Data bag path '#{Chef::Config[:data_bag_path]}' is invalid" end + + Dir.glob(File.join(Chef::Config[:data_bag_path], "*")).map{|f|File.basename(f)}.sort else - Chef::REST.new(Chef::Config[:chef_server_url]).get_rest("data") + if inflate + # Can't search for all data bags like other objects, fall back to N+1 :( + list(false).inject({}) do |response, bag_and_uri| + response[bag_and_uri.first] = load(bag_and_uri.first) + response + end + else + Chef::REST.new(Chef::Config[:chef_server_url]).get_rest("data") + end end end |