mirror of https://github.com/containers/podman.git
				
				
				
			Merge pull request #9342 from Luap99/lint
Enable more golangci-lint linters
This commit is contained in:
		
						commit
						3ba0afdd0f
					
				| 
						 | 
					@ -4,14 +4,10 @@ run:
 | 
				
			||||||
  deadline: 5m
 | 
					  deadline: 5m
 | 
				
			||||||
  skip-dirs-use-default: true
 | 
					  skip-dirs-use-default: true
 | 
				
			||||||
  skip-dirs:
 | 
					  skip-dirs:
 | 
				
			||||||
    - dependencies
 | 
					 | 
				
			||||||
    - contrib
 | 
					    - contrib
 | 
				
			||||||
    - dependencies
 | 
					    - dependencies
 | 
				
			||||||
    - test
 | 
					    - test
 | 
				
			||||||
    - pkg/spec
 | 
					 | 
				
			||||||
    - vendor
 | 
					 | 
				
			||||||
  skip-files:
 | 
					  skip-files:
 | 
				
			||||||
    - iopodman.go
 | 
					 | 
				
			||||||
    - swagger.go
 | 
					    - swagger.go
 | 
				
			||||||
  modules-download-mode: readonly
 | 
					  modules-download-mode: readonly
 | 
				
			||||||
linters:
 | 
					linters:
 | 
				
			||||||
| 
						 | 
					@ -51,12 +47,7 @@ linters:
 | 
				
			||||||
    - goconst
 | 
					    - goconst
 | 
				
			||||||
    - gocyclo
 | 
					    - gocyclo
 | 
				
			||||||
    - lll
 | 
					    - lll
 | 
				
			||||||
    - structcheck
 | 
					 | 
				
			||||||
    - typecheck
 | 
					 | 
				
			||||||
    - unconvert
 | 
					    - unconvert
 | 
				
			||||||
    - varcheck
 | 
					 | 
				
			||||||
    - deadcode
 | 
					 | 
				
			||||||
    - depguard
 | 
					 | 
				
			||||||
    - errcheck
 | 
					    - errcheck
 | 
				
			||||||
    - gocritic
 | 
					    - gocritic
 | 
				
			||||||
    - gosec
 | 
					    - gosec
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,6 @@ func exclusiveOptions(opt1, opt2 string) error {
 | 
				
			||||||
// Validate verifies that the given SpecGenerator is valid and satisfies required
 | 
					// Validate verifies that the given SpecGenerator is valid and satisfies required
 | 
				
			||||||
// input for creating a container.
 | 
					// input for creating a container.
 | 
				
			||||||
func (s *SpecGenerator) Validate() error {
 | 
					func (s *SpecGenerator) Validate() error {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if rootless.IsRootless() && len(s.CNINetworks) == 0 {
 | 
						if rootless.IsRootless() && len(s.CNINetworks) == 0 {
 | 
				
			||||||
		if s.StaticIP != nil || s.StaticIPv6 != nil {
 | 
							if s.StaticIP != nil || s.StaticIPv6 != nil {
 | 
				
			||||||
			return ErrNoStaticIPRootless
 | 
								return ErrNoStaticIPRootless
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -113,7 +113,6 @@ func DevicesFromPath(g *generate.Generator, devicePath string) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// mount the internal devices recursively
 | 
							// mount the internal devices recursively
 | 
				
			||||||
		if err := filepath.Walk(resolvedDevicePath, func(dpath string, f os.FileInfo, e error) error {
 | 
							if err := filepath.Walk(resolvedDevicePath, func(dpath string, f os.FileInfo, e error) error {
 | 
				
			||||||
 | 
					 | 
				
			||||||
			if f.Mode()&os.ModeDevice == os.ModeDevice {
 | 
								if f.Mode()&os.ModeDevice == os.ModeDevice {
 | 
				
			||||||
				found = true
 | 
									found = true
 | 
				
			||||||
				device := fmt.Sprintf("%s:%s", dpath, filepath.Join(dest, strings.TrimPrefix(dpath, src)))
 | 
									device := fmt.Sprintf("%s:%s", dpath, filepath.Join(dest, strings.TrimPrefix(dpath, src)))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -384,7 +384,6 @@ func getPodPorts(containers []v1.Container) []specgen.PortMapping {
 | 
				
			||||||
			if p.HostPort != 0 {
 | 
								if p.HostPort != 0 {
 | 
				
			||||||
				infraPorts = append(infraPorts, portBinding)
 | 
									infraPorts = append(infraPorts, portBinding)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return infraPorts
 | 
						return infraPorts
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,7 @@ import (
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// KubeSeccompPaths holds information about a pod YAML's seccomp configuration
 | 
					// KubeSeccompPaths holds information about a pod YAML's seccomp configuration
 | 
				
			||||||
// it holds both container and pod seccomp paths
 | 
					// it holds both container and pod seccomp paths
 | 
				
			||||||
 | 
					// nolint:golint
 | 
				
			||||||
type KubeSeccompPaths struct {
 | 
					type KubeSeccompPaths struct {
 | 
				
			||||||
	containerPaths map[string]string
 | 
						containerPaths map[string]string
 | 
				
			||||||
	podPath        string
 | 
						podPath        string
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,7 @@ const (
 | 
				
			||||||
	kubeFilePermission = 0644
 | 
						kubeFilePermission = 0644
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// nolint:golint
 | 
				
			||||||
type KubeVolumeType int
 | 
					type KubeVolumeType int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
| 
						 | 
					@ -24,6 +25,7 @@ const (
 | 
				
			||||||
	KubeVolumeTypeNamed     KubeVolumeType = iota
 | 
						KubeVolumeTypeNamed     KubeVolumeType = iota
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// nolint:golint
 | 
				
			||||||
type KubeVolume struct {
 | 
					type KubeVolume struct {
 | 
				
			||||||
	// Type of volume to create
 | 
						// Type of volume to create
 | 
				
			||||||
	Type KubeVolumeType
 | 
						Type KubeVolumeType
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -219,7 +219,6 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
 | 
				
			||||||
		if !mappingFound {
 | 
							if !mappingFound {
 | 
				
			||||||
			gid5Available = false
 | 
								gid5Available = false
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if !gid5Available {
 | 
						if !gid5Available {
 | 
				
			||||||
		// If we have no GID mappings, the gid=5 default option would fail, so drop it.
 | 
							// If we have no GID mappings, the gid=5 default option would fail, so drop it.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -109,17 +109,15 @@ func securityConfigureGenerator(s *specgen.SpecGenerator, g *generate.Generator,
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if !s.Privileged && len(capsRequiredRequested) > 0 {
 | 
							if !s.Privileged && len(capsRequiredRequested) > 0 {
 | 
				
			||||||
 | 
					 | 
				
			||||||
			// Pass capRequiredRequested in CapAdd field to normalize capabilities names
 | 
								// Pass capRequiredRequested in CapAdd field to normalize capabilities names
 | 
				
			||||||
			capsRequired, err := capabilities.MergeCapabilities(nil, capsRequiredRequested, nil)
 | 
								capsRequired, err := capabilities.MergeCapabilities(nil, capsRequiredRequested, nil)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				return errors.Wrapf(err, "capabilities requested by user or image are not valid: %q", strings.Join(capsRequired, ","))
 | 
									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
 | 
								// Verify all capRequired are in the capList
 | 
				
			||||||
				for _, cap := range capsRequired {
 | 
								for _, cap := range capsRequired {
 | 
				
			||||||
					if !util.StringInSlice(cap, caplist) {
 | 
									if !util.StringInSlice(cap, caplist) {
 | 
				
			||||||
						privCapsRequired = append(privCapsRequired, cap)
 | 
										privCapsRequired = append(privCapsRequired, cap)
 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if len(privCapsRequired) == 0 {
 | 
								if len(privCapsRequired) == 0 {
 | 
				
			||||||
| 
						 | 
					@ -189,7 +187,6 @@ func securityConfigureGenerator(s *specgen.SpecGenerator, g *generate.Generator,
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for sysctlKey, sysctlVal := range defaultSysctls {
 | 
						for sysctlKey, sysctlVal := range defaultSysctls {
 | 
				
			||||||
 | 
					 | 
				
			||||||
		// Ignore mqueue sysctls if --ipc=host
 | 
							// Ignore mqueue sysctls if --ipc=host
 | 
				
			||||||
		if noUseIPC && strings.HasPrefix(sysctlKey, "fs.mqueue.") {
 | 
							if noUseIPC && strings.HasPrefix(sysctlKey, "fs.mqueue.") {
 | 
				
			||||||
			logrus.Infof("Sysctl %s=%s ignored in containers.conf, since IPC Namespace set to host", sysctlKey, sysctlVal)
 | 
								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 {
 | 
						for sysctlKey, sysctlVal := range s.Sysctl {
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if s.IpcNS.IsHost() && strings.HasPrefix(sysctlKey, "fs.mqueue.") {
 | 
							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)
 | 
								return errors.Wrapf(define.ErrInvalidArg, "sysctl %s=%s can't be set since IPC Namespace set to host", sysctlKey, sysctlVal)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,6 @@ func exclusivePodOptions(opt1, opt2 string) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Validate verifies the input is valid
 | 
					// Validate verifies the input is valid
 | 
				
			||||||
func (p *PodSpecGenerator) Validate() error {
 | 
					func (p *PodSpecGenerator) Validate() error {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if rootless.IsRootless() && len(p.CNINetworks) == 0 {
 | 
						if rootless.IsRootless() && len(p.CNINetworks) == 0 {
 | 
				
			||||||
		if p.StaticIP != nil {
 | 
							if p.StaticIP != nil {
 | 
				
			||||||
			return ErrNoStaticIPRootless
 | 
								return ErrNoStaticIPRootless
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue