Skip to content

Commit

Permalink
Merge pull request #1189 from yast/fix_double_splat_argument
Browse files Browse the repository at this point in the history
Replace double splat argument as could be problematic
  • Loading branch information
teclator committed Mar 18, 2021
2 parents 31385c7 + f73ab1e commit 0ac388a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/lib/y2network/network_manager/config_writer.rb
Expand Up @@ -38,8 +38,8 @@ def write_connections(config, _old_config)
opts = {
routes: routes_for(conn, config.routing.routes),
parent: conn.find_master(config.connections)
}.reject { |_k, v| v.nil? }
writer.write(conn, nil, **opts) # FIXME
}
writer.write(conn, nil, opts)
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/lib/y2network/network_manager/connection_config_writer.rb
Expand Up @@ -36,7 +36,7 @@ class ConnectionConfigWriter
# @param old_conn [ConnectionConfig::Base] Original connection
# configuration
# @param opts [Hash] writer options
def write(conn, old_conn = nil, **opts)
def write(conn, old_conn = nil, opts = {})
return if conn == old_conn

path = SYSTEM_CONNECTIONS_PATH.join(conn.name).sub_ext(FILE_EXT)
Expand All @@ -46,7 +46,7 @@ def write(conn, old_conn = nil, **opts)

ensure_permissions(path) unless ::File.exist?(path)

handler_class.new(file).write(conn, **opts)
handler_class.new(file).write(conn, opts)
file.save
end

Expand Down
Expand Up @@ -40,17 +40,20 @@ def initialize(file)
# Writes connection information to the interface configuration file
#
# @param conn [Y2Network::ConnectionConfig::Base] Connection to take settings from
# @param routes [<Array<Y2Network::Route>] routes associated with the connection
# @param parent [Y2Network::ConnectionConfig::Bonding, Y2Network::ConnectionConfig::Bridge]
def write(conn, routes: [], parent: nil)
# @param opts [Hash] additional options needed to write properly the
# connection config
# @option opts [<Array<Y2Network::Route>] :routes associated with the connection
# @option opts [Y2Network::ConnectionConfig::Base] :parent device in
# case that the connection to be written is an slave one.
def write(conn, opts = {})
file.connection["id"] = conn.name
file.connection["autoconnect"] = "false" if ["manual", "off"].include? conn.startmode.name
file.connection["permissions"] = nil
file.connection["interface-name"] = conn.interface
file.connection["zone"] = conn.firewall_zone unless ["", nil].include? conn.firewall_zone
conn.bootproto.dhcp? ? configure_dhcp(conn) : configure_ips(conn)
configure_routes(routes)
configure_as_child(parent) if parent
configure_routes(opts[:routes] || [])
configure_as_child(opts[:parent]) if opts[:parent]
update_file(conn)
end

Expand Down
2 changes: 1 addition & 1 deletion test/y2network/network_manager/config_writer_test.rb
Expand Up @@ -71,7 +71,7 @@
end

it "writes connections configuration" do
expect(conn_config_writer).to receive(:write).with(eth0_conn, nil, routes: [])
expect(conn_config_writer).to receive(:write).with(eth0_conn, nil, routes: [], parent: nil)
writer.write(config)
end
end
Expand Down
Expand Up @@ -75,7 +75,7 @@

it "uses the appropiate handler" do
expect(writer).to receive(:require).and_return(handler)
expect(handler).to receive(:write).with(conn)
expect(handler).to receive(:write).with(conn, {})
writer.write(conn)
end

Expand Down

0 comments on commit 0ac388a

Please sign in to comment.