Skip to content

Commit

Permalink
Clean and simplify route provider get code
Browse files Browse the repository at this point in the history
  • Loading branch information
David Hollinger committed May 29, 2018
1 parent 9d028cc commit f62041e
Showing 1 changed file with 20 additions and 29 deletions.
49 changes: 20 additions & 29 deletions lib/puppet/provider/network_route/network_route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,26 @@ def routes_list
end

def get(_context)
instances = Array.new
routes_list.map do |route|
default = if route['prefix'] == 'default'
true
else
false
end

routes_list.map { |route|
instances << self.class.routes_list_to_hash(route)
# require 'pry'; binding.pry
}

instances
end

def self.routes_list_to_hash(route)
default = if route['prefix'] == 'default'
true
else
false
end

{
ensure: 'present',
prefix: route['prefix'],
default_route: default,
gateway: route['via'],
interface: route['dev'],
metric: route['metric'],
table: route['table'],
source: route['src'],
scope: route['scope'],
protocol: route['proto'],
mtu: route['mtu']
}.compact!
{
ensure: 'present',
prefix: route['prefix'],
default_route: default,
gateway: route['via'],
interface: route['dev'],
metric: route['metric'],
table: route['table'],
source: route['src'],
scope: route['scope'],
protocol: route['proto'],
mtu: route['mtu']
}.compact!
end
end
end

0 comments on commit f62041e

Please sign in to comment.