From f5cc3483fdcf40954e3efefccc58cb0e5c3156e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 5 May 2020 09:50:22 +0200 Subject: [PATCH] Ignore parameters (#12) --- lib/puppet/catalog-diff/comparer.rb | 11 +++++++++++ lib/puppet/catalog-diff/differ.rb | 1 - lib/puppet/face/catalog/diff.rb | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/puppet/catalog-diff/comparer.rb b/lib/puppet/catalog-diff/comparer.rb index 7bf8b3e..5d29609 100644 --- a/lib/puppet/catalog-diff/comparer.rb +++ b/lib/puppet/catalog-diff/comparer.rb @@ -37,6 +37,12 @@ def compare_resources(old, new, options) #resource[:parameters].delete(:command) unless new_resource[:parameters].include?(:command) #resource[:parameters].delete(:path) unless new_resource[:parameters].include?(:path) + if options[:ignore_parameters] + blacklist = options[:ignore_parameters].split(',') + filter_parameters!(new_resource[:parameters], blacklist) + filter_parameters!(resource[:parameters], blacklist) + end + sort_dependencies!(new_resource[:parameters]) sort_dependencies!(resource[:parameters]) @@ -82,6 +88,11 @@ def compare_resources(old, new, options) resource_differences end + # filter parameters + def filter_parameters!(params, blacklist) + params.reject! { |p, k| blacklist.include?(p.to_s) } + end + # sort require/before/notify/subscribe before comparison def sort_dependencies!(params) params.each do |x| diff --git a/lib/puppet/catalog-diff/differ.rb b/lib/puppet/catalog-diff/differ.rb index cf96963..2214134 100644 --- a/lib/puppet/catalog-diff/differ.rb +++ b/lib/puppet/catalog-diff/differ.rb @@ -75,7 +75,6 @@ def diff(options = {}) end end - Puppet.debug("Processing: #{from_file}") titles = {} titles[:to] = extract_titles(to) diff --git a/lib/puppet/face/catalog/diff.rb b/lib/puppet/face/catalog/diff.rb index 58718c5..a53af3a 100644 --- a/lib/puppet/face/catalog/diff.rb +++ b/lib/puppet/face/catalog/diff.rb @@ -37,6 +37,10 @@ summary 'Do not print classes in resource diffs' end + option '--ignore_parameters=' do + summary 'A comma-separated list of resource parameters to ignore in diff' + end + option "--filter_local" do summary "Use local YAML node files to filter out queried nodes" end