summaryrefslogtreecommitdiff
path: root/lib/chef/platform/resource_priority_map.rb
blob: fc43b3e7db38088bc277d63e316da115a92e0aa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class Chef
  class Platform
    class ResourcePriorityMap
      include Singleton

      def initialize
        load_default_map
      end

      def get_priority_array(node, resource_name)
        priority_map.get(node, resource_name.to_sym)
      end

      def set_priority_array(resource_name, priority_array, *filter)
        priority resource_name.to_sym, priority_array.to_a, *filter
      end

      def priority(*args)
        priority_map.set(*args)
      end

      private

      def load_default_map
        require 'chef/resources'

        # MacOSX
        priority :package, Chef::Resource::HomebrewPackage, os: "darwin"
      end

      def priority_map
        require 'chef/node_map'
        @priority_map ||= Chef::NodeMap.new
      end
    end
  end
end