diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-01-13 13:01:45 +0100 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-01-13 14:27:02 +0100 |
commit | 67165b76753f65b6f58d471f314678ae12a4c722 (patch) | |
tree | 72580ee08e5d9d2e57b97a7293deaf8a2a0f2e67 /libpod/container_internal_linux.go | |
parent | 270d892c3d77de4fd8e6341193175c0572fb5f99 (diff) | |
download | podman-67165b76753f65b6f58d471f314678ae12a4c722.tar.gz podman-67165b76753f65b6f58d471f314678ae12a4c722.tar.bz2 podman-67165b76753f65b6f58d471f314678ae12a4c722.zip |
make lint: enable gocritic
`gocritic` is a powerful linter that helps in preventing certain kinds
of errors as well as enforcing a coding style.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r-- | libpod/container_internal_linux.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 6ec06943f..561dbdc1c 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -62,7 +62,7 @@ func (c *Container) unmountSHM(mount string) error { // prepare mounts the container and sets up other required resources like net // namespaces -func (c *Container) prepare() (Err error) { +func (c *Container) prepare() error { var ( wg sync.WaitGroup netNS ns.NetNS @@ -1277,21 +1277,21 @@ func (c *Container) generateResolvConf() (string, error) { } // If the user provided dns, it trumps all; then dns masq; then resolv.conf - if len(c.config.DNSServer) > 0 { + switch { + case len(c.config.DNSServer) > 0: // We store DNS servers as net.IP, so need to convert to string for _, server := range c.config.DNSServer { nameservers = append(nameservers, server.String()) } - } else if len(cniNameServers) > 0 { + case len(cniNameServers) > 0: nameservers = append(nameservers, cniNameServers...) - } else { + default: // Make a new resolv.conf nameservers = resolvconf.GetNameservers(resolv.Content) // slirp4netns has a built in DNS server. if c.config.NetMode.IsSlirp4netns() { nameservers = append([]string{"10.0.2.3"}, nameservers...) } - } search := resolvconf.GetSearchDomains(resolv.Content) @@ -1451,23 +1451,24 @@ func (c *Container) getOCICgroupPath() (string, error) { if err != nil { return "", err } - if (rootless.IsRootless() && !unified) || c.config.NoCgroups { + switch { + case (rootless.IsRootless() && !unified) || c.config.NoCgroups: return "", nil - } else if c.runtime.config.CgroupManager == define.SystemdCgroupsManager { + case c.runtime.config.CgroupManager == define.SystemdCgroupsManager: // When runc is set to use Systemd as a cgroup manager, it // expects cgroups to be passed as follows: // slice:prefix:name systemdCgroups := fmt.Sprintf("%s:libpod:%s", path.Base(c.config.CgroupParent), c.ID()) logrus.Debugf("Setting CGroups for container %s to %s", c.ID(), systemdCgroups) return systemdCgroups, nil - } else if c.runtime.config.CgroupManager == define.CgroupfsCgroupsManager { + case c.runtime.config.CgroupManager == define.CgroupfsCgroupsManager: cgroupPath, err := c.CGroupPath() if err != nil { return "", err } logrus.Debugf("Setting CGroup path for container %s to %s", c.ID(), cgroupPath) return cgroupPath, nil - } else { + default: return "", errors.Wrapf(define.ErrInvalidArg, "invalid cgroup manager %s requested", c.runtime.config.CgroupManager) } } |