Module: Chef::DSL::DataQuery
- Included in:
- Mixin::DeprecatedLanguageModule, Provider::LWRPBase, Recipe, Resource
- Defined in:
- lib/chef/dsl/data_query.rb
Overview
Chef::DSL::DataQuery
Provides DSL for querying data from the chef-server via search or data bag.
Instance Method Summary collapse
Instance Method Details
#data_bag(bag) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/chef/dsl/data_query.rb', line 47 def data_bag(bag) DataBag.validate_name!(bag.to_s) rbag = DataBag.load(bag) rbag.keys rescue Exception Log.error("Failed to list data bag items in data bag: #{bag.inspect}") raise end |
#data_bag_item(bag, item) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/chef/dsl/data_query.rb', line 56 def data_bag_item(bag, item) DataBag.validate_name!(bag.to_s) DataBagItem.validate_id!(item) DataBagItem.load(bag, item) rescue Exception Log.error("Failed to load data bag item: #{bag.inspect} #{item.inspect}") raise end |
#search(*args, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/chef/dsl/data_query.rb', line 32 def search(*args, &block) # If you pass a block, or have at least the start argument, do raw result parsing # # Otherwise, do the iteration for the end user if Kernel.block_given? || args.length >= 4 Chef::Search::Query.new.search(*args, &block) else results = Array.new Chef::Search::Query.new.search(*args) do |o| results << o end results end end |