Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hfrog committed Aug 17, 2024
1 parent 4603809 commit 591e7b6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/puppet/provider/network_config/interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def self.parse_file(_filename, contents)
end

def self.interface_order(name, rules)
(rules['rules'].map{ |entry| if name.match(entry.first) then entry.last end } + [rules['default']]).compact.first
(rules['rules'].map { |entry| entry.last if name.match(entry.first) } + [rules['default']]).compact.first
end

# Generate an array of sections
Expand All @@ -257,20 +257,20 @@ def self.format_file(_filename, providers)
auto_interfaces = providers.select { |provider| provider.onboot == true }
unless auto_interfaces.empty?
stanza = []
stanza << ('auto ' + auto_interfaces.sort_by{ |provider| interface_order(provider.name, provider.order_rules) }.map(&:name).join(' '))
stanza << ('auto ' + auto_interfaces.sort_by { |provider| interface_order(provider.name, provider.order_rules) }.map(&:name).join(' '))
contents << stanza.join("\n")
end

# Add hotpluggable interfaces
hotplug_interfaces = providers.select { |provider| provider.hotplug == true }
unless hotplug_interfaces.empty?
stanza = []
stanza << ('allow-hotplug ' + hotplug_interfaces.sort_by{ |provider| interface_order(provider.name, provider.order_rules) }.map(&:name).join(' '))
stanza << ('allow-hotplug ' + hotplug_interfaces.sort_by { |provider| interface_order(provider.name, provider.order_rules) }.map(&:name).join(' '))
contents << stanza.join("\n")
end

# Build iface stanzas
providers.sort_by{ |provider| interface_order(provider.name, provider.order_rules) }.each do |provider|
providers.sort_by { |provider| interface_order(provider.name, provider.order_rules) }.each do |provider|
# TODO: add validation method
raise Puppet::Error, "#{provider.name} does not have a method." if provider.method.nil?
raise Puppet::Error, "#{provider.name} does not have a family." if provider.family.nil?
Expand Down

0 comments on commit 591e7b6

Please sign in to comment.