diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2020-03-05 16:23:04 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2020-03-05 16:23:04 -0800 |
commit | e6167aa5fe2decfe2395012c302360fc50054b9c (patch) | |
tree | 1d9455c7ef516a43ab156e15725aa9ec7860688f | |
parent | fe71cbcdf09618307b594a28431dc6fa1a6c08d0 (diff) | |
download | chef-lcg/remove-canonical-dsl.tar.gz |
remove more canonical wiring from the node maplcg/remove-canonical-dsl
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/node_map.rb | 38 | ||||
-rw-r--r-- | lib/chef/resource.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource_inspector.rb | 2 |
3 files changed, 8 insertions, 36 deletions
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb index 3c78d6cb9b..8a858315b9 100644 --- a/lib/chef/node_map.rb +++ b/lib/chef/node_map.rb @@ -1,6 +1,6 @@ # # Author:: Lamont Granquist (<lamont@chef.io>) -# Copyright:: Copyright 2014-2019, Chef Software Inc. +# Copyright:: Copyright 2014-2020, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,14 +55,13 @@ class Chef # # @return [NodeMap] Returns self for possible chaining # - def set(key, klass, platform: nil, platform_version: nil, platform_family: nil, os: nil, canonical: nil, override: nil, chef_version: nil, target_mode: nil, &block) + def set(key, klass, platform: nil, platform_version: nil, platform_family: nil, os: nil, override: nil, chef_version: nil, target_mode: nil, &block) new_matcher = { klass: klass } new_matcher[:platform] = platform if platform new_matcher[:platform_version] = platform_version if platform_version new_matcher[:platform_family] = platform_family if platform_family new_matcher[:os] = os if os new_matcher[:block] = block if block - new_matcher[:canonical] = canonical if canonical new_matcher[:override] = override if override new_matcher[:target_mode] = target_mode @@ -113,16 +112,14 @@ class Chef # @param node [Chef::Node] The Chef::Node object for the run, or `nil` to # ignore all filters. # @param key [Object] Key to look up - # @param canonical [Boolean] `true` or `false` to match canonical or - # non-canonical values only. `nil` to ignore canonicality. Default: `nil` # # @return [Object] Class # - def get(node, key, canonical: nil) + def get(node, key) return nil unless map.key?(key) map[key].map do |matcher| - return matcher[:klass] if node_matches?(node, matcher) && canonical_matches?(canonical, matcher) + return matcher[:klass] if node_matches?(node, matcher) end nil end @@ -134,16 +131,14 @@ class Chef # @param node [Chef::Node] The Chef::Node object for the run, or `nil` to # ignore all filters. # @param key [Object] Key to look up - # @param canonical [Boolean] `true` or `false` to match canonical or - # non-canonical values only. `nil` to ignore canonicality. Default: `nil` # # @return [Object] Class # - def list(node, key, canonical: nil) + def list(node, key) return [] unless map.key?(key) map[key].select do |matcher| - node_matches?(node, matcher) && canonical_matches?(canonical, matcher) + node_matches?(node, matcher) end.map { |matcher| matcher[:klass] } end @@ -174,21 +169,6 @@ class Chef deleted end - # Seriously, don't use this, it's nearly certain to change on you - # @return remaining - # @api private - def delete_canonical(key, klass) - remaining = map[key] - if remaining - remaining.delete_if { |matcher| matcher[:canonical] && Array(matcher[:klass]) == Array(klass) } - if remaining.empty? - map.delete(key) - remaining = nil - end - end - remaining - end - # Check if this map has been locked. # # @api internal @@ -299,12 +279,6 @@ class Chef filters_match?(node, matcher) && block_matches?(node, matcher[:block]) end - def canonical_matches?(canonical, matcher) - return true if canonical.nil? - - !!canonical == !!matcher[:canonical] - end - # # "provides" lines with identical filters sort by class name (ascending). # diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 069d149c32..ad2862c70b 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -1320,9 +1320,7 @@ class Chef # # Since resource_name calls provides the generally correct way of doing this is # to do `chef_version_for_provides` first, then `resource_name` and then - # any additional options `provides` lines. Calling `resource_name` is somewhat - # important to have the canonical_dsl removed or else that'll stick around - # and chef_version won't get applied to it. + # any additional options `provides` lines. # # Once we no longer care about supporting chef < 14.4 then we can deprecate # this API. diff --git a/lib/chef/resource_inspector.rb b/lib/chef/resource_inspector.rb index 8d92db04b6..187bd6338b 100644 --- a/lib/chef/resource_inspector.rb +++ b/lib/chef/resource_inspector.rb @@ -92,7 +92,7 @@ module ResourceInspector if File.directory?(arg) extract_cookbook(arg, complete).each { |k, v| acc[k] = v } else - r = Chef::ResourceResolver.resolve(arg.to_sym, canonical: nil) + r = Chef::ResourceResolver.resolve(arg.to_sym) acc[r.resource_name] = extract_resource(r, complete) end end |