Puppet Function: patching_as_code::dedupe_arch
- Defined in:
-
lib/puppet/functions/patching_as_code/dedupe_arch.rb
- Function type:
- Ruby 4.x API
Overview
patching_as_code::dedupe_arch(Array $patches) ⇒ Any
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/puppet/functions/patching_as_code/dedupe_arch.rb', line 3
Puppet::Functions.create_function(:'patching_as_code::dedupe_arch') do
dispatch :dedupe_arch do
param 'Array', :patches
end
def dedupe_arch(patches)
no_arch = patches.map { |patch| patch.sub(%r{(.noarch|.x86_64|.i386|.i686)$}, '') }
multi_arch = no_arch.group_by { |x| x }.select { |_k, v| v.size > 1 }.map(&:first)
result = patches.map do |patch|
no_arch_patch = patch.sub(%r{(.noarch|.x86_64|.i386|.i686)$}, '')
if multi_arch.include? no_arch_patch
no_arch_patch
else
patch
end
end
result.uniq
end
end
|