Class: Chef::Blacklist

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/blacklist.rb

Class Method Summary collapse

Class Method Details

.filter(data, blacklist = nil) ⇒ Object

filter takes two arguments - the data you want to filter, and a blacklisted array of keys you want discluded. You can capture a subtree of the data to filter by providing a “/”-delimited string of keys. If some key includes “/”-characters, you must provide an array of keys instead.

Blacklist.filter(

{ "filesystem" => {
    "/dev/disk" => {
      "size" => "10mb"
    },
    "map - autohome" => {
      "size" => "10mb"
    }
  },
  "network" => {
    "interfaces" => {
      "eth0" => {...},
      "eth1" => {...}
    }
  }
},
["network/interfaces/eth0", ["filesystem", "/dev/disk"]])

will exclude the eth0 and /dev/disk subtrees.



30
31
32
33
34
35
36
37
38
# File 'lib/chef/blacklist.rb', line 30

def self.filter(data, blacklist = nil)
  return data if blacklist.nil?

  blacklist.each do |item|
    Chef::Log.warn("Removing item #{item}")
    remove_data(data, item)
  end
  data
end