From 78b419909bdf1eeb4af17fff471b381de91bcf73 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 12 Feb 2021 17:59:50 +0100 Subject: Enable more golangci-lint linters Cleanup the golangci.yml file and enable more linters. `pkg/spec` and `iopodman.io` is history. The vendor directory is excluded by default. The dependencies dir was listed twice. Fix the reported problems in `pkg/specgen` because that was also excluded by `pkg/spec`. Enable the structcheck, typecheck, varcheck, deadcode and depguard linters. [NO TESTS NEEDED] Signed-off-by: Paul Holzinger --- pkg/specgen/generate/security.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'pkg/specgen/generate/security.go') diff --git a/pkg/specgen/generate/security.go b/pkg/specgen/generate/security.go index 390b19beb..fb45d87db 100644 --- a/pkg/specgen/generate/security.go +++ b/pkg/specgen/generate/security.go @@ -109,17 +109,15 @@ func securityConfigureGenerator(s *specgen.SpecGenerator, g *generate.Generator, } } if !s.Privileged && len(capsRequiredRequested) > 0 { - // Pass capRequiredRequested in CapAdd field to normalize capabilities names capsRequired, err := capabilities.MergeCapabilities(nil, capsRequiredRequested, nil) if err != nil { return errors.Wrapf(err, "capabilities requested by user or image are not valid: %q", strings.Join(capsRequired, ",")) - } else { - // Verify all capRequired are in the capList - for _, cap := range capsRequired { - if !util.StringInSlice(cap, caplist) { - privCapsRequired = append(privCapsRequired, cap) - } + } + // Verify all capRequired are in the capList + for _, cap := range capsRequired { + if !util.StringInSlice(cap, caplist) { + privCapsRequired = append(privCapsRequired, cap) } } if len(privCapsRequired) == 0 { @@ -189,7 +187,6 @@ func securityConfigureGenerator(s *specgen.SpecGenerator, g *generate.Generator, return err } for sysctlKey, sysctlVal := range defaultSysctls { - // Ignore mqueue sysctls if --ipc=host if noUseIPC && strings.HasPrefix(sysctlKey, "fs.mqueue.") { logrus.Infof("Sysctl %s=%s ignored in containers.conf, since IPC Namespace set to host", sysctlKey, sysctlVal) @@ -213,7 +210,6 @@ func securityConfigureGenerator(s *specgen.SpecGenerator, g *generate.Generator, } for sysctlKey, sysctlVal := range s.Sysctl { - if s.IpcNS.IsHost() && strings.HasPrefix(sysctlKey, "fs.mqueue.") { return errors.Wrapf(define.ErrInvalidArg, "sysctl %s=%s can't be set since IPC Namespace set to host", sysctlKey, sysctlVal) } -- cgit v1.2.3-54-g00ecf