mirror of
https://github.com/containers/podman.git
synced 2025-05-20 16:47:39 +08:00
bump golangci-lint to v1.50.1
Also fix a number of duplicate words. Yet disable the new `dupword` linter as it displays too many false positives. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
@ -15,6 +15,7 @@ linters:
|
|||||||
# All these break for one reason or another
|
# All these break for one reason or another
|
||||||
- tagliatelle # too many JSON keys cannot be changed due to compat
|
- tagliatelle # too many JSON keys cannot be changed due to compat
|
||||||
- nosnakecase # too many false positives due to the `unix` package
|
- nosnakecase # too many false positives due to the `unix` package
|
||||||
|
- dupword # too many false positives (e.g., in tests)
|
||||||
- gocognit
|
- gocognit
|
||||||
- testpackage
|
- testpackage
|
||||||
- goerr113
|
- goerr113
|
||||||
|
2
Makefile
2
Makefile
@ -914,7 +914,7 @@ install.tools: .install.golangci-lint .install.swagger ## Install needed tools
|
|||||||
|
|
||||||
.PHONY: .install.golangci-lint
|
.PHONY: .install.golangci-lint
|
||||||
.install.golangci-lint:
|
.install.golangci-lint:
|
||||||
VERSION=1.49.0 ./hack/install_golangci.sh
|
VERSION=1.50.1 ./hack/install_golangci.sh
|
||||||
|
|
||||||
.PHONY: .install.swagger
|
.PHONY: .install.swagger
|
||||||
.install.swagger:
|
.install.swagger:
|
||||||
|
@ -203,7 +203,7 @@ func run(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
report, err := registry.ContainerEngine().ContainerRun(registry.GetContext(), runOpts)
|
report, err := registry.ContainerEngine().ContainerRun(registry.GetContext(), runOpts)
|
||||||
// report.ExitCode is set by ContainerRun even it it returns an error
|
// report.ExitCode is set by ContainerRun even it returns an error
|
||||||
if report != nil {
|
if report != nil {
|
||||||
registry.SetExitCode(report.ExitCode)
|
registry.SetExitCode(report.ExitCode)
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ var (
|
|||||||
|
|
||||||
// ABIMode used in cobra.Annotations registry.EngineMode when command only supports ABIMode
|
// ABIMode used in cobra.Annotations registry.EngineMode when command only supports ABIMode
|
||||||
ABIMode = entities.ABIMode.String()
|
ABIMode = entities.ABIMode.String()
|
||||||
// TunnelMode used in in cobra.Annotations registry.EngineMode when command only supports TunnelMode
|
// TunnelMode used in cobra.Annotations registry.EngineMode when command only supports TunnelMode
|
||||||
TunnelMode = entities.TunnelMode.String()
|
TunnelMode = entities.TunnelMode.String()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ func isUnambiguousName(imageName string) bool {
|
|||||||
// What is before the first slash can be a domain or a path
|
// What is before the first slash can be a domain or a path
|
||||||
domain := imageName[:firstSlash]
|
domain := imageName[:firstSlash]
|
||||||
|
|
||||||
// If its a a domain (has dot or port or is "localhost") it is considered fq
|
// If its a domain (has dot or port or is "localhost") it is considered fq
|
||||||
if strings.ContainsAny(domain, ".:") || domain == "localhost" {
|
if strings.ContainsAny(domain, ".:") || domain == "localhost" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -3451,7 +3451,7 @@ func (s *BoltState) RemoveContainerFromPod(pod *Pod, ctr *Container) error {
|
|||||||
return fmt.Errorf("pod %s is in namespace %q but we are in namespace %q: %w", pod.ID(), pod.config.Namespace, s.namespace, define.ErrNSMismatch)
|
return fmt.Errorf("pod %s is in namespace %q but we are in namespace %q: %w", pod.ID(), pod.config.Namespace, s.namespace, define.ErrNSMismatch)
|
||||||
}
|
}
|
||||||
if s.namespace != ctr.config.Namespace {
|
if s.namespace != ctr.config.Namespace {
|
||||||
return fmt.Errorf("container %s in in namespace %q but we are in namespace %q: %w", ctr.ID(), ctr.config.Namespace, s.namespace, define.ErrNSMismatch)
|
return fmt.Errorf("container %s in namespace %q but we are in namespace %q: %w", ctr.ID(), ctr.config.Namespace, s.namespace, define.ErrNSMismatch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1253,7 +1253,7 @@ func (c *Container) Secrets() []*ContainerSecret {
|
|||||||
// values at runtime via network connect and disconnect.
|
// values at runtime via network connect and disconnect.
|
||||||
// If the container is configured to use CNI and this function returns an empty
|
// If the container is configured to use CNI and this function returns an empty
|
||||||
// array, the container will still be connected to the default network.
|
// array, the container will still be connected to the default network.
|
||||||
// The second return parameter, a bool, indicates that the container container
|
// The second return parameter, a bool, indicates that the container
|
||||||
// is joining the default CNI network - the network name will be included in the
|
// is joining the default CNI network - the network name will be included in the
|
||||||
// returned array of network names, but the container did not explicitly join
|
// returned array of network names, but the container did not explicitly join
|
||||||
// this network.
|
// this network.
|
||||||
|
@ -13,7 +13,7 @@ const (
|
|||||||
// InspectResponseFalse) it will be used in the output of Inspect().
|
// InspectResponseFalse) it will be used in the output of Inspect().
|
||||||
InspectAnnotationAutoremove = "io.podman.annotations.autoremove"
|
InspectAnnotationAutoremove = "io.podman.annotations.autoremove"
|
||||||
// InspectAnnotationVolumesFrom is used by Inspect to identify
|
// InspectAnnotationVolumesFrom is used by Inspect to identify
|
||||||
// containers whose volumes are are being used by this container.
|
// containers whose volumes are being used by this container.
|
||||||
// It is expected to be a comma-separated list of container names and/or
|
// It is expected to be a comma-separated list of container names and/or
|
||||||
// IDs.
|
// IDs.
|
||||||
// If an annotation with this key is found in the OCI spec, it will be
|
// If an annotation with this key is found in the OCI spec, it will be
|
||||||
|
@ -25,7 +25,7 @@ const (
|
|||||||
ContainerStateStopped ContainerStatus = iota
|
ContainerStateStopped ContainerStatus = iota
|
||||||
// ContainerStatePaused indicates that the container has been paused
|
// ContainerStatePaused indicates that the container has been paused
|
||||||
ContainerStatePaused ContainerStatus = iota
|
ContainerStatePaused ContainerStatus = iota
|
||||||
// ContainerStateExited indicates the the container has stopped and been
|
// ContainerStateExited indicates the container has stopped and been
|
||||||
// cleaned up
|
// cleaned up
|
||||||
ContainerStateExited ContainerStatus = iota
|
ContainerStateExited ContainerStatus = iota
|
||||||
// ContainerStateRemoving indicates the container is in the process of
|
// ContainerStateRemoving indicates the container is in the process of
|
||||||
|
@ -16,7 +16,7 @@ type ReverseReader struct {
|
|||||||
|
|
||||||
// NewReverseReader returns a reader that reads from the end of a file
|
// NewReverseReader returns a reader that reads from the end of a file
|
||||||
// rather than the beginning. It sets the readsize to pagesize and determines
|
// rather than the beginning. It sets the readsize to pagesize and determines
|
||||||
// the first offset using using modulus.
|
// the first offset using modulus.
|
||||||
func NewReverseReader(reader *os.File) (*ReverseReader, error) {
|
func NewReverseReader(reader *os.File) (*ReverseReader, error) {
|
||||||
// pagesize should be safe for memory use and file reads should be on page
|
// pagesize should be safe for memory use and file reads should be on page
|
||||||
// boundaries as well
|
// boundaries as well
|
||||||
|
@ -296,7 +296,7 @@ func WithHooksDir(hooksDirs ...string) RuntimeOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithCDI sets the devices to check for for CDI configuration.
|
// WithCDI sets the devices to check for CDI configuration.
|
||||||
func WithCDI(devices []string) CtrCreateOption {
|
func WithCDI(devices []string) CtrCreateOption {
|
||||||
return func(ctr *Container) error {
|
return func(ctr *Container) error {
|
||||||
if ctr.valid {
|
if ctr.valid {
|
||||||
@ -307,7 +307,7 @@ func WithCDI(devices []string) CtrCreateOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithStorageOpts sets the devices to check for for CDI configuration.
|
// WithStorageOpts sets the devices to check for CDI configuration.
|
||||||
func WithStorageOpts(storageOpts map[string]string) CtrCreateOption {
|
func WithStorageOpts(storageOpts map[string]string) CtrCreateOption {
|
||||||
return func(ctr *Container) error {
|
return func(ctr *Container) error {
|
||||||
if ctr.valid {
|
if ctr.valid {
|
||||||
|
@ -44,7 +44,7 @@ func (p *Pod) save() error {
|
|||||||
// This cannot lock any other pod, but may lock individual containers, as those
|
// This cannot lock any other pod, but may lock individual containers, as those
|
||||||
// will have refreshed by the time pod refresh runs.
|
// will have refreshed by the time pod refresh runs.
|
||||||
func (p *Pod) refresh() error {
|
func (p *Pod) refresh() error {
|
||||||
// Need to to an update from the DB to pull potentially-missing state
|
// Need to do an update from the DB to pull potentially-missing state
|
||||||
if err := p.runtime.state.UpdatePod(p); err != nil {
|
if err := p.runtime.state.UpdatePod(p); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ func Restart(ctx context.Context, nameOrID string, options *RestartOptions) (*en
|
|||||||
return &report, response.ProcessWithError(&report, &errorhandling.PodConflictErrorModel{})
|
return &report, response.ProcessWithError(&report, &errorhandling.PodConflictErrorModel{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove deletes a Pod from from local storage. The optional force parameter denotes
|
// Remove deletes a Pod from local storage. The optional force parameter denotes
|
||||||
// that the Pod can be removed even if in a running state.
|
// that the Pod can be removed even if in a running state.
|
||||||
func Remove(ctx context.Context, nameOrID string, options *RemoveOptions) (*entities.PodRmReport, error) {
|
func Remove(ctx context.Context, nameOrID string, options *RemoveOptions) (*entities.PodRmReport, error) {
|
||||||
var report entities.PodRmReport
|
var report entities.PodRmReport
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WriteCloser is an io.WriteCloser that that proxies Write() calls to a channel
|
// WriteCloser is an io.WriteCloser that proxies Write() calls to a channel
|
||||||
// The []byte buffer of the Write() is queued on the channel as one message.
|
// The []byte buffer of the Write() is queued on the channel as one message.
|
||||||
type WriteCloser interface {
|
type WriteCloser interface {
|
||||||
io.WriteCloser
|
io.WriteCloser
|
||||||
|
@ -21,7 +21,7 @@ type Overrides struct {
|
|||||||
ContainerEtcGroupPath string
|
ContainerEtcGroupPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserGroupInfo takes string forms of the the container's mount path and the container user and
|
// GetUserGroupInfo takes string forms of the container's mount path and the container user and
|
||||||
// returns a ExecUser with uid, gid, sgids, and home. And override can be provided for defaults.
|
// returns a ExecUser with uid, gid, sgids, and home. And override can be provided for defaults.
|
||||||
func GetUserGroupInfo(containerMount, containerUser string, override *Overrides) (*user.ExecUser, error) {
|
func GetUserGroupInfo(containerMount, containerUser string, override *Overrides) (*user.ExecUser, error) {
|
||||||
var (
|
var (
|
||||||
|
@ -135,7 +135,7 @@ func GetAvailableGids() (int64, error) {
|
|||||||
return countAvailableIDs(gids), nil
|
return countAvailableIDs(gids), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// findIDInMappings find the the mapping that contains the specified ID.
|
// findIDInMappings find the mapping that contains the specified ID.
|
||||||
// It assumes availableMappings is sorted by ID.
|
// It assumes availableMappings is sorted by ID.
|
||||||
func findIDInMappings(id int64, availableMappings []user.IDMap) *user.IDMap {
|
func findIDInMappings(id int64, availableMappings []user.IDMap) *user.IDMap {
|
||||||
i := sort.Search(len(availableMappings), func(i int) bool {
|
i := sort.Search(len(availableMappings), func(i int) bool {
|
||||||
|
@ -672,7 +672,7 @@ func TestParsePortMappingWithoutHostPort(t *testing.T) {
|
|||||||
assert.NoError(t, err, "error is not nil")
|
assert.NoError(t, err, "error is not nil")
|
||||||
|
|
||||||
// because we always get random host ports when it is set to 0 we cannot check that exactly
|
// because we always get random host ports when it is set to 0 we cannot check that exactly
|
||||||
// check if it is not 0 and set to to 0 afterwards
|
// check if it is not 0 and set to 0 afterwards
|
||||||
for i := range got {
|
for i := range got {
|
||||||
assert.Greater(t, got[i].HostPort, uint16(0), "host port is zero")
|
assert.Greater(t, got[i].HostPort, uint16(0), "host port is zero")
|
||||||
got[i].HostPort = 0
|
got[i].HostPort = 0
|
||||||
|
@ -25,8 +25,7 @@ const (
|
|||||||
// Default indicates the spec generator should determine
|
// Default indicates the spec generator should determine
|
||||||
// a sane default
|
// a sane default
|
||||||
Default NamespaceMode = "default"
|
Default NamespaceMode = "default"
|
||||||
// Host means the the namespace is derived from
|
// Host means the namespace is derived from the host
|
||||||
// the host
|
|
||||||
Host NamespaceMode = "host"
|
Host NamespaceMode = "host"
|
||||||
// Path is the path to a namespace
|
// Path is the path to a namespace
|
||||||
Path NamespaceMode = "path"
|
Path NamespaceMode = "path"
|
||||||
|
@ -431,7 +431,7 @@ RUN > file2
|
|||||||
`
|
`
|
||||||
podmanTest.BuildImageWithLabel(dockerfile, "foobar.com/workdir:latest", "false", "abc")
|
podmanTest.BuildImageWithLabel(dockerfile, "foobar.com/workdir:latest", "false", "abc")
|
||||||
podmanTest.BuildImageWithLabel(dockerfile2, "foobar.com/workdir:latest", "false", "xyz")
|
podmanTest.BuildImageWithLabel(dockerfile2, "foobar.com/workdir:latest", "false", "xyz")
|
||||||
// --force used to to avoid y/n question
|
// --force used to avoid y/n question
|
||||||
result := podmanTest.Podman([]string{"image", "prune", "--filter", "label=abc", "--force"})
|
result := podmanTest.Podman([]string{"image", "prune", "--filter", "label=abc", "--force"})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(Exit(0))
|
Expect(result).Should(Exit(0))
|
||||||
|
Reference in New Issue
Block a user