summaryrefslogtreecommitdiff
path: root/libpod/networking_linux.go
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2022-04-22 15:10:13 +0200
committerPaul Holzinger <pholzing@redhat.com>2022-04-25 13:23:20 +0200
commitc7b16645aff27fff0b87bb2a98298693bbf20894 (patch)
treed93f86c9e13f0f87f09eb048929add31e13f8f93 /libpod/networking_linux.go
parentad3da638ce17439a7adbf2aa7e1b4017d583f660 (diff)
downloadpodman-c7b16645aff27fff0b87bb2a98298693bbf20894.tar.gz
podman-c7b16645aff27fff0b87bb2a98298693bbf20894.tar.bz2
podman-c7b16645aff27fff0b87bb2a98298693bbf20894.zip
enable unparam linter
The unparam linter is useful to detect unused function parameters and return values. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'libpod/networking_linux.go')
-rw-r--r--libpod/networking_linux.go40
1 files changed, 11 insertions, 29 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index 41beaf41d..937dc4fae 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -74,7 +74,7 @@ func (c *Container) convertPortMappings() []types.PortMapping {
return newPorts
}
-func (c *Container) getNetworkOptions(networkOpts map[string]types.PerNetworkOptions) (types.NetworkOptions, error) {
+func (c *Container) getNetworkOptions(networkOpts map[string]types.PerNetworkOptions) types.NetworkOptions {
opts := types.NetworkOptions{
ContainerID: c.config.ID,
ContainerName: getCNIPodName(c),
@@ -88,7 +88,7 @@ func (c *Container) getNetworkOptions(networkOpts map[string]types.PerNetworkOpt
} else {
opts.Networks = networkOpts
}
- return opts, nil
+ return opts
}
type RootlessNetNS struct {
@@ -653,10 +653,7 @@ func (r *Runtime) configureNetNS(ctr *Container, ctrNS ns.NetNS) (status map[str
return nil, nil
}
- netOpts, err := ctr.getNetworkOptions(networks)
- if err != nil {
- return nil, err
- }
+ netOpts := ctr.getNetworkOptions(networks)
netStatus, err := r.setUpNetwork(ctrNS.Path(), netOpts)
if err != nil {
return nil, err
@@ -814,10 +811,7 @@ func (r *Runtime) teardownCNI(ctr *Container) error {
}
if !ctr.config.NetMode.IsSlirp4netns() && len(networks) > 0 {
- netOpts, err := ctr.getNetworkOptions(networks)
- if err != nil {
- return err
- }
+ netOpts := ctr.getNetworkOptions(networks)
return r.teardownNetwork(ctr.state.NetNS.Path(), netOpts)
}
return nil
@@ -1000,11 +994,9 @@ func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, e
if c.state.NetNS == nil {
if networkNSPath := c.joinedNetworkNSPath(); networkNSPath != "" {
if result, err := c.inspectJoinedNetworkNS(networkNSPath); err == nil {
- if basicConfig, err := resultToBasicNetworkConfig(result); err == nil {
- // fallback to dummy configuration
- settings.InspectBasicNetworkConfig = basicConfig
- return settings, nil
- }
+ // fallback to dummy configuration
+ settings.InspectBasicNetworkConfig = resultToBasicNetworkConfig(result)
+ return settings, nil
}
// do not propagate error inspecting a joined network ns
logrus.Errorf("Inspecting network namespace: %s of container %s: %v", networkNSPath, c.ID(), err)
@@ -1047,14 +1039,8 @@ func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, e
result := netStatus[name]
addedNet := new(define.InspectAdditionalNetwork)
addedNet.NetworkID = name
-
- basicConfig, err := resultToBasicNetworkConfig(result)
- if err != nil {
- return nil, err
- }
addedNet.Aliases = opts.Aliases
-
- addedNet.InspectBasicNetworkConfig = basicConfig
+ addedNet.InspectBasicNetworkConfig = resultToBasicNetworkConfig(result)
settings.Networks[name] = addedNet
}
@@ -1074,11 +1060,7 @@ func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, e
if len(netStatus) == 1 {
for _, status := range netStatus {
- basicConfig, err := resultToBasicNetworkConfig(status)
- if err != nil {
- return nil, err
- }
- settings.InspectBasicNetworkConfig = basicConfig
+ settings.InspectBasicNetworkConfig = resultToBasicNetworkConfig(status)
}
}
return settings, nil
@@ -1152,7 +1134,7 @@ func (c *Container) inspectJoinedNetworkNS(networkns string) (q types.StatusBloc
// resultToBasicNetworkConfig produces an InspectBasicNetworkConfig from a CNI
// result
-func resultToBasicNetworkConfig(result types.StatusBlock) (define.InspectBasicNetworkConfig, error) {
+func resultToBasicNetworkConfig(result types.StatusBlock) define.InspectBasicNetworkConfig {
config := define.InspectBasicNetworkConfig{}
interfaceNames := make([]string, 0, len(result.Interfaces))
for interfaceName := range result.Interfaces {
@@ -1190,7 +1172,7 @@ func resultToBasicNetworkConfig(result types.StatusBlock) (define.InspectBasicNe
config.AdditionalMacAddresses = append(config.AdditionalMacAddresses, netInt.MacAddress.String())
}
}
- return config, nil
+ return config
}
type logrusDebugWriter struct {