diff --git a/.golangci.yml b/.golangci.yml index e987dea0df6..ed1ce1e44bb 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,7 +4,7 @@ run: formatters: enable: - - gofmt + - gofumpt - goimports exclusions: generated: disable diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5ba57b33078..eb16b3c6d6a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -146,7 +146,8 @@ It is not necessary to test a single change in multiple places. ### Go Format and lint -All code changes must pass ``make validatepr``. +All code changes must pass `make validatepr`. +We are using the [`gofumpt`](https://github.com/mvdan/gofumpt) formatter for our go code, you can either use it directly or format via `golangci-lint fmt`. The `validatepr`/`validate` make targets will fail if the code is not formatted correctly. ### Integration Tests diff --git a/cmd/podman-mac-helper/install.go b/cmd/podman-mac-helper/install.go index 42a31245773..60e4b6f7b2b 100644 --- a/cmd/podman-mac-helper/install.go +++ b/cmd/podman-mac-helper/install.go @@ -19,8 +19,8 @@ import ( ) const ( - mode755 = 0755 - mode644 = 0644 + mode755 = 0o755 + mode644 = 0o644 ) const launchConfig = ` diff --git a/cmd/podman-testing/store_unsupported.go b/cmd/podman-testing/store_unsupported.go index d17334dd203..ac21a731fa1 100644 --- a/cmd/podman-testing/store_unsupported.go +++ b/cmd/podman-testing/store_unsupported.go @@ -6,9 +6,7 @@ import ( "github.com/containers/podman/v6/pkg/domain/entities" ) -var ( - engineMode = entities.TunnelMode -) +var engineMode = entities.TunnelMode func storeBefore() error { return nil diff --git a/cmd/podman-wslkerninst/main.go b/cmd/podman-wslkerninst/main.go index c16bce88399..632128061d8 100644 --- a/cmd/podman-wslkerninst/main.go +++ b/cmd/podman-wslkerninst/main.go @@ -43,9 +43,7 @@ func setupLogging(name string) (*eventlog.Log, error) { func installWslKernel() error { logrus.Info("Installing WSL Kernel update") - var ( - err error - ) + var err error backoff := 500 * time.Millisecond for i := 1; i < 6; i++ { err = wutil.SilentExec("--update") diff --git a/cmd/podman/artifact/add.go b/cmd/podman/artifact/add.go index f5f722c93bb..7a0720ea402 100644 --- a/cmd/podman/artifact/add.go +++ b/cmd/podman/artifact/add.go @@ -12,19 +12,17 @@ import ( "go.podman.io/common/pkg/completion" ) -var ( - addCmd = &cobra.Command{ - Use: "add [options] ARTIFACT PATH [...PATH]", - Short: "Add an OCI artifact to the local store", - Long: "Add an OCI artifact to the local store from the local filesystem", - RunE: add, - Args: cobra.MinimumNArgs(2), - ValidArgsFunction: common.AutocompleteArtifactAdd, - Example: `podman artifact add quay.io/myimage/myartifact:latest /tmp/foobar.txt +var addCmd = &cobra.Command{ + Use: "add [options] ARTIFACT PATH [...PATH]", + Short: "Add an OCI artifact to the local store", + Long: "Add an OCI artifact to the local store from the local filesystem", + RunE: add, + Args: cobra.MinimumNArgs(2), + ValidArgsFunction: common.AutocompleteArtifactAdd, + Example: `podman artifact add quay.io/myimage/myartifact:latest /tmp/foobar.txt podman artifact add --file-type text/yaml quay.io/myimage/myartifact:latest /tmp/foobar.yaml podman artifact add --append quay.io/myimage/myartifact:latest /tmp/foobar.tar.gz`, - } -) +} // AddOptionsWrapper wraps entities.ArtifactsAddOptions and prevents leaking // CLI-only fields into the API types. diff --git a/cmd/podman/artifact/extract.go b/cmd/podman/artifact/extract.go index de12617bb4b..a45b3b66757 100644 --- a/cmd/podman/artifact/extract.go +++ b/cmd/podman/artifact/extract.go @@ -8,22 +8,18 @@ import ( "go.podman.io/common/pkg/completion" ) -var ( - extractCmd = &cobra.Command{ - Use: "extract [options] ARTIFACT PATH", - Short: "Extract an OCI artifact to a local path", - Long: "Extract the blobs of an OCI artifact to a local file or directory", - RunE: extract, - Args: cobra.ExactArgs(2), - ValidArgsFunction: common.AutocompleteArtifactAdd, - Example: `podman artifact Extract quay.io/myimage/myartifact:latest /tmp/foobar.txt +var extractCmd = &cobra.Command{ + Use: "extract [options] ARTIFACT PATH", + Short: "Extract an OCI artifact to a local path", + Long: "Extract the blobs of an OCI artifact to a local file or directory", + RunE: extract, + Args: cobra.ExactArgs(2), + ValidArgsFunction: common.AutocompleteArtifactAdd, + Example: `podman artifact Extract quay.io/myimage/myartifact:latest /tmp/foobar.txt podman artifact Extract quay.io/myimage/myartifact:latest /home/paul/mydir`, - } -) +} -var ( - extractOpts entities.ArtifactExtractOptions -) +var extractOpts entities.ArtifactExtractOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/artifact/list.go b/cmd/podman/artifact/list.go index a1d09b5857c..23c53c8c959 100644 --- a/cmd/podman/artifact/list.go +++ b/cmd/podman/artifact/list.go @@ -63,9 +63,7 @@ func (a artifactListOutput) CreatedAt() string { return a.created.String() } -var ( - defaultArtifactListOutputFormat = "{{range .}}{{.Repository}}\t{{.Tag}}\t{{.Digest}}\t{{.Created}}\t{{.Size}}\n{{end -}}" -) +var defaultArtifactListOutputFormat = "{{range .}}{{.Repository}}\t{{.Tag}}\t{{.Digest}}\t{{.Created}}\t{{.Size}}\n{{end -}}" func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ @@ -93,9 +91,7 @@ func outputTemplate(cmd *cobra.Command, lrs []*entities.ArtifactListReport) erro var err error artifacts := make([]artifactListOutput, 0) for _, lr := range lrs { - var ( - tag string - ) + var tag string artifactName, err := lr.Artifact.GetName() if err != nil { return err diff --git a/cmd/podman/artifact/rm.go b/cmd/podman/artifact/rm.go index eab35302ae0..2eb6e4e5008 100644 --- a/cmd/podman/artifact/rm.go +++ b/cmd/podman/artifact/rm.go @@ -35,6 +35,7 @@ func rmFlags(cmd *cobra.Command) { flags.BoolVarP(&rmOptions.All, "all", "a", false, "Remove all artifacts") flags.BoolVarP(&rmOptions.Ignore, "ignore", "i", false, "Ignore error if artifact does not exist") } + func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ Command: rmCmd, diff --git a/cmd/podman/common/build.go b/cmd/podman/common/build.go index 744b75e6e54..033ba8e9aed 100644 --- a/cmd/podman/common/build.go +++ b/cmd/podman/common/build.go @@ -52,9 +52,11 @@ type BuildFlagsWrapper struct { // FarmBuildHiddenFlags are the flags hidden from the farm build command because they are either not // supported or don't make sense in the farm build use case -var FarmBuildHiddenFlags = []string{"arch", "all-platforms", "compress", "cw", "disable-content-trust", +var FarmBuildHiddenFlags = []string{ + "arch", "all-platforms", "compress", "cw", "disable-content-trust", "logsplit", "manifest", "os", "output", "platform", "sign-by", "signature-policy", "stdin", - "variant"} + "variant", +} func DefineBuildFlags(cmd *cobra.Command, buildOpts *BuildFlagsWrapper, isFarmBuild bool) { flags := cmd.Flags() diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go index 3dc15192c98..3f3856906f3 100644 --- a/cmd/podman/common/completion.go +++ b/cmd/podman/common/completion.go @@ -1186,8 +1186,10 @@ func AutocompletePullOption(_ *cobra.Command, _ []string, _ string) ([]string, c // AutocompleteRestartOption - Autocomplete restart options for create and run command. // -> "always", "no", "on-failure", "unless-stopped" func AutocompleteRestartOption(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { - restartOptions := []string{define.RestartPolicyAlways, define.RestartPolicyNo, - define.RestartPolicyOnFailure, define.RestartPolicyUnlessStopped} + restartOptions := []string{ + define.RestartPolicyAlways, define.RestartPolicyNo, + define.RestartPolicyOnFailure, define.RestartPolicyUnlessStopped, + } return restartOptions, cobra.ShellCompDirectiveNoFileComp } @@ -1595,7 +1597,8 @@ func getMethodNames(f reflect.Value, prefix string) []formatSuggestion { // -> "container=", "event=", "image=", "pod=", "volume=", "type=" func AutocompleteEventFilter(cmd *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) { event := func(_ string) ([]string, cobra.ShellCompDirective) { - return []string{events.Attach.String(), events.AutoUpdate.String(), events.Checkpoint.String(), events.Cleanup.String(), + return []string{ + events.Attach.String(), events.AutoUpdate.String(), events.Checkpoint.String(), events.Cleanup.String(), events.Commit.String(), events.Create.String(), events.Exec.String(), events.ExecDied.String(), events.Exited.String(), events.Export.String(), events.Import.String(), events.Init.String(), events.Kill.String(), events.LoadFromArchive.String(), events.Mount.String(), events.NetworkConnect.String(), @@ -1607,7 +1610,8 @@ func AutocompleteEventFilter(cmd *cobra.Command, _ []string, toComplete string) }, cobra.ShellCompDirectiveNoFileComp } eventTypes := func(_ string) ([]string, cobra.ShellCompDirective) { - return []string{events.Container.String(), events.Image.String(), events.Network.String(), + return []string{ + events.Container.String(), events.Image.String(), events.Network.String(), events.Pod.String(), events.System.String(), events.Volume.String(), events.Secret.String(), }, cobra.ShellCompDirectiveNoFileComp } @@ -1710,9 +1714,11 @@ func AutocompleteImageSaveFormat(_ *cobra.Command, _ []string, _ string) ([]stri // AutocompleteWaitCondition - Autocomplete wait condition options. // -> "unknown", "configured", "created", "running", "stopped", "paused", "exited", "removing" func AutocompleteWaitCondition(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { - states := []string{"unknown", "configured", "created", "exited", + states := []string{ + "unknown", "configured", "created", "exited", "healthy", "initialized", "paused", "removing", "running", - "stopped", "stopping", "unhealthy"} + "stopped", "stopping", "unhealthy", + } return states, cobra.ShellCompDirectiveNoFileComp } @@ -1792,8 +1798,10 @@ func AutocompletePsFilters(cmd *cobra.Command, _ []string, toComplete string) ([ "command=": func(s string) ([]string, cobra.ShellCompDirective) { return getCommands(cmd, s) }, "exited=": nil, "health=": func(_ string) ([]string, cobra.ShellCompDirective) { - return []string{define.HealthCheckHealthy, - define.HealthCheckUnhealthy}, cobra.ShellCompDirectiveNoFileComp + return []string{ + define.HealthCheckHealthy, + define.HealthCheckUnhealthy, + }, cobra.ShellCompDirectiveNoFileComp }, "id=": func(s string) ([]string, cobra.ShellCompDirective) { return getContainers(cmd, s, completeIDs) }, "label=": nil, @@ -1832,8 +1840,10 @@ func AutocompletePodPsFilters(cmd *cobra.Command, _ []string, toComplete string) "name=": func(s string) ([]string, cobra.ShellCompDirective) { return getPods(cmd, s, completeNames) }, "network=": func(s string) ([]string, cobra.ShellCompDirective) { return getNetworks(cmd, s, completeDefault) }, "status=": func(_ string) ([]string, cobra.ShellCompDirective) { - return []string{"stopped", "running", - "paused", "exited", "dead", "created", "degraded"}, cobra.ShellCompDirectiveNoFileComp + return []string{ + "stopped", "running", + "paused", "exited", "dead", "created", "degraded", + }, cobra.ShellCompDirectiveNoFileComp }, "until=": nil, } @@ -2002,7 +2012,6 @@ func AutocompleteSysctl(_ *cobra.Command, _ []string, toComplete string) ([]stri return nil }) - if err != nil { return nil, cobra.ShellCompDirectiveError } diff --git a/cmd/podman/common/completion_test.go b/cmd/podman/common/completion_test.go index e806c693593..4a4b62073ef 100644 --- a/cmd/podman/common/completion_test.go +++ b/cmd/podman/common/completion_test.go @@ -180,9 +180,11 @@ func TestAutocompleteFormat(t *testing.T) { { "two variables struct field name", "{{ .Car.Brand }} {{ .Car.", - []string{"{{ .Car.Brand }} {{ .Car.Color}}", "{{ .Car.Brand }} {{ .Car.Struct.", "{{ .Car.Brand }} {{ .Car.Type}}", + []string{ + "{{ .Car.Brand }} {{ .Car.Color}}", "{{ .Car.Brand }} {{ .Car.Struct.", "{{ .Car.Brand }} {{ .Car.Type}}", "{{ .Car.Brand }} {{ .Car.Brand}}", "{{ .Car.Brand }} {{ .Car.Stats.", "{{ .Car.Brand }} {{ .Car.Extras.", - "{{ .Car.Brand }} {{ .Car.Extras2."}, + "{{ .Car.Brand }} {{ .Car.Extras2.", + }, }, { "only dot without variable", diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index 91bd68f70d6..7189743a3ad 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -430,7 +430,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions, timezoneFlagName, cf.Timezone, "Set timezone in container", ) - _ = cmd.RegisterFlagCompletionFunc(timezoneFlagName, completion.AutocompleteNone) //TODO: add timezone completion + _ = cmd.RegisterFlagCompletionFunc(timezoneFlagName, completion.AutocompleteNone) // TODO: add timezone completion umaskFlagName := "umask" createFlags.StringVar( diff --git a/cmd/podman/common/default.go b/cmd/podman/common/default.go index da7844fe67e..936d9e1af16 100644 --- a/cmd/podman/common/default.go +++ b/cmd/podman/common/default.go @@ -4,7 +4,5 @@ import ( "github.com/containers/podman/v6/cmd/podman/registry" ) -var ( - // Pull in configured json library - json = registry.JSONLibrary() -) +// Pull in configured json library +var json = registry.JSONLibrary() diff --git a/cmd/podman/common/netflags.go b/cmd/podman/common/netflags.go index addc55c4d55..de2aa3d9575 100644 --- a/cmd/podman/common/netflags.go +++ b/cmd/podman/common/netflags.go @@ -107,9 +107,7 @@ func DefineNetFlags(cmd *cobra.Command) { // NetFlagsToNetOptions parses the network flags for the given cmd. func NetFlagsToNetOptions(opts *entities.NetOptions, flags pflag.FlagSet) (*entities.NetOptions, error) { - var ( - err error - ) + var err error if opts == nil { opts = &entities.NetOptions{} } diff --git a/cmd/podman/containers/attach.go b/cmd/podman/containers/attach.go index 80add08e1f0..a90140e25a9 100644 --- a/cmd/podman/containers/attach.go +++ b/cmd/podman/containers/attach.go @@ -39,9 +39,7 @@ var ( } ) -var ( - attachOpts entities.AttachOptions -) +var attachOpts entities.AttachOptions func attachFlags(cmd *cobra.Command) { flags := cmd.Flags() diff --git a/cmd/podman/containers/cleanup.go b/cmd/podman/containers/cleanup.go index deb32df7330..618a8d1464a 100644 --- a/cmd/podman/containers/cleanup.go +++ b/cmd/podman/containers/cleanup.go @@ -35,9 +35,7 @@ var ( } ) -var ( - cleanupOptions entities.ContainerCleanupOptions -) +var cleanupOptions entities.ContainerCleanupOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ @@ -62,9 +60,7 @@ func init() { } func cleanup(_ *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors if cleanupOptions.Exec != "" { switch { diff --git a/cmd/podman/containers/clone.go b/cmd/podman/containers/clone.go index 8404f2db1c6..19476d1ea0c 100644 --- a/cmd/podman/containers/clone.go +++ b/cmd/podman/containers/clone.go @@ -24,9 +24,7 @@ var ( } ) -var ( - ctrClone entities.ContainerCloneOptions -) +var ctrClone entities.ContainerCloneOptions func cloneFlags(cmd *cobra.Command) { flags := cmd.Flags() @@ -43,6 +41,7 @@ func cloneFlags(cmd *cobra.Command) { common.DefineCreateDefaults(&ctrClone.CreateOpts) common.DefineCreateFlags(cmd, &ctrClone.CreateOpts, entities.CloneMode) } + func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ Command: containerCloneCommand, diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go index 74648c5e6cf..fc7fcedcda2 100644 --- a/cmd/podman/containers/cp.go +++ b/cmd/podman/containers/cp.go @@ -1,6 +1,7 @@ package containers import ( + "errors" "fmt" "io" "os" @@ -10,8 +11,6 @@ import ( "strconv" "strings" - "errors" - buildahCopiah "github.com/containers/buildah/copier" "github.com/containers/podman/v6/cmd/podman/common" "github.com/containers/podman/v6/cmd/podman/registry" @@ -466,16 +465,16 @@ func resolvePathOnDestinationContainer(container string, containerPath string, i containerInfo, err = registry.ContainerEngine().ContainerStat(registry.Context(), container, containerPath) if err == nil { baseName = path.Base(containerInfo.LinkTarget) - return //nolint: nilerr + return baseName, containerInfo, resolvedToParentDir, err //nolint: nilerr } if strings.HasSuffix(containerPath, "/") { err = fmt.Errorf("%q could not be found on container %s: %w", containerPath, container, err) - return + return baseName, containerInfo, resolvedToParentDir, err } if isStdin { err = errors.New("destination must be a directory when copying from stdin") - return + return baseName, containerInfo, resolvedToParentDir, err } // NOTE: containerInfo may actually be set. That happens when @@ -492,13 +491,13 @@ func resolvePathOnDestinationContainer(container string, containerPath string, i parentDir, err := containerParentDir(container, parentPath) if err != nil { err = fmt.Errorf("could not determine parent dir of %q on container %s: %w", parentPath, container, err) - return + return baseName, containerInfo, resolvedToParentDir, err } containerInfo, err = registry.ContainerEngine().ContainerStat(registry.Context(), container, parentDir) if err != nil { err = fmt.Errorf("%q could not be found on container %s: %w", containerPath, container, err) - return + return baseName, containerInfo, resolvedToParentDir, err } resolvedToParentDir = true diff --git a/cmd/podman/containers/init.go b/cmd/podman/containers/init.go index 475166ffdd4..a19971da267 100644 --- a/cmd/podman/containers/init.go +++ b/cmd/podman/containers/init.go @@ -40,9 +40,7 @@ var ( } ) -var ( - initOptions entities.ContainerInitOptions -) +var initOptions entities.ContainerInitOptions func initFlags(flags *pflag.FlagSet) { flags.BoolVarP(&initOptions.All, "all", "a", false, "Initialize all containers") diff --git a/cmd/podman/containers/list.go b/cmd/podman/containers/list.go index f22061e3ef5..25989fff114 100644 --- a/cmd/podman/containers/list.go +++ b/cmd/podman/containers/list.go @@ -7,21 +7,19 @@ import ( "go.podman.io/common/pkg/completion" ) -var ( - // podman container _list_ - listCmd = &cobra.Command{ - Use: "list [options]", - Aliases: []string{"ls"}, - Args: validate.NoArgs, - Short: "List containers", - Long: "Prints out information about the containers", - RunE: ps, - ValidArgsFunction: completion.AutocompleteNone, - Example: `podman container list -a +// podman container _list_ +var listCmd = &cobra.Command{ + Use: "list [options]", + Aliases: []string{"ls"}, + Args: validate.NoArgs, + Short: "List containers", + Long: "Prints out information about the containers", + RunE: ps, + ValidArgsFunction: completion.AutocompleteNone, + Example: `podman container list -a podman container list -a --format "{{.ID}} {{.Image}} {{.Labels}} {{.Mounts}}" podman container list --size --sort names`, - } -) +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/containers/mount.go b/cmd/podman/containers/mount.go index 6a07ef11e84..1cb180b368d 100644 --- a/cmd/podman/containers/mount.go +++ b/cmd/podman/containers/mount.go @@ -49,9 +49,7 @@ var ( } ) -var ( - mountOpts entities.ContainerMountOptions -) +var mountOpts entities.ContainerMountOptions func mountFlags(cmd *cobra.Command) { flags := cmd.Flags() diff --git a/cmd/podman/containers/pause.go b/cmd/podman/containers/pause.go index b85aa639bdb..1d09908b58e 100644 --- a/cmd/podman/containers/pause.go +++ b/cmd/podman/containers/pause.go @@ -87,9 +87,7 @@ func init() { } func pause(_ *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors args = utils.RemoveSlash(args) for _, cidFile := range pauseCidFiles { diff --git a/cmd/podman/containers/port.go b/cmd/podman/containers/port.go index 802c5858ae8..7297edf7562 100644 --- a/cmd/podman/containers/port.go +++ b/cmd/podman/containers/port.go @@ -44,9 +44,7 @@ var ( } ) -var ( - portOpts entities.ContainerPortOptions -) +var portOpts entities.ContainerPortOptions func portFlags(flags *pflag.FlagSet) { flags.BoolVarP(&portOpts.All, "all", "a", false, "Display port information for all containers") diff --git a/cmd/podman/containers/prune.go b/cmd/podman/containers/prune.go index e0f71d28859..0385d51a144 100644 --- a/cmd/podman/containers/prune.go +++ b/cmd/podman/containers/prune.go @@ -69,7 +69,6 @@ func prune(_ *cobra.Command, _ []string) error { return err } responses, err := registry.ContainerEngine().ContainerPrune(context.Background(), pruneOptions) - if err != nil { return err } diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index b4116cc241c..88cef61132c 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -47,6 +47,7 @@ var ( Example: strings.ReplaceAll(psCommand.Example, "podman ps", "podman container ps"), } ) + var ( listOpts = entities.ContainerListOptions{ Filters: make(map[string][]string), @@ -107,6 +108,7 @@ func listFlagSet(cmd *cobra.Command) { flags.SetNormalizeFunc(utils.AliasFlags) } + func checkFlags(c *cobra.Command) error { // latest, and last are mutually exclusive. if listOpts.Last >= 0 && listOpts.Latest { diff --git a/cmd/podman/containers/restart.go b/cmd/podman/containers/restart.go index 9471fb83c1c..8be1bff0695 100644 --- a/cmd/podman/containers/restart.go +++ b/cmd/podman/containers/restart.go @@ -94,9 +94,7 @@ func init() { } func restart(cmd *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors args = utils.RemoveSlash(args) if cmd.Flag("time").Changed { diff --git a/cmd/podman/containers/start.go b/cmd/podman/containers/start.go index 3e0e60cde51..b0a8cecea02 100644 --- a/cmd/podman/containers/start.go +++ b/cmd/podman/containers/start.go @@ -40,11 +40,9 @@ var ( } ) -var ( - startOptions = entities.ContainerStartOptions{ - Filters: make(map[string][]string), - } -) +var startOptions = entities.ContainerStartOptions{ + Filters: make(map[string][]string), +} func startFlags(cmd *cobra.Command) { flags := cmd.Flags() @@ -68,6 +66,7 @@ func startFlags(cmd *cobra.Command) { _ = flags.MarkHidden("sig-proxy") } } + func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ Command: startCommand, diff --git a/cmd/podman/containers/stop.go b/cmd/podman/containers/stop.go index 34058a1d306..c611caf6a08 100644 --- a/cmd/podman/containers/stop.go +++ b/cmd/podman/containers/stop.go @@ -97,9 +97,7 @@ func init() { } func stop(cmd *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors args = utils.RemoveSlash(args) if cmd.Flag("time").Changed { diff --git a/cmd/podman/containers/unmount.go b/cmd/podman/containers/unmount.go index f1dd16a4c57..908cf0aec1e 100644 --- a/cmd/podman/containers/unmount.go +++ b/cmd/podman/containers/unmount.go @@ -52,9 +52,7 @@ var ( } ) -var ( - unmountOpts entities.ContainerUnmountOptions -) +var unmountOpts entities.ContainerUnmountOptions func unmountFlags(flags *pflag.FlagSet) { flags.BoolVarP(&unmountOpts.All, "all", "a", false, "Unmount all of the currently mounted containers") diff --git a/cmd/podman/containers/unpause.go b/cmd/podman/containers/unpause.go index 382ab48591b..dbde2c62e42 100644 --- a/cmd/podman/containers/unpause.go +++ b/cmd/podman/containers/unpause.go @@ -88,9 +88,7 @@ func init() { } func unpause(_ *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors args = utils.RemoveSlash(args) if rootless.IsRootless() && !registry.IsRemote() { diff --git a/cmd/podman/farm/farm.go b/cmd/podman/farm/farm.go index cd773f0db5a..eb35d3c017f 100644 --- a/cmd/podman/farm/farm.go +++ b/cmd/podman/farm/farm.go @@ -6,15 +6,13 @@ import ( "github.com/spf13/cobra" ) -var ( - // Command: podman _farm_ - farmCmd = &cobra.Command{ - Use: "farm", - Short: "Farm out builds to remote machines", - Long: "Farm out builds to remote machines that podman can connect to via podman system connection", - RunE: validate.SubCommandExists, - } -) +// Command: podman _farm_ +var farmCmd = &cobra.Command{ + Use: "farm", + Short: "Farm out builds to remote machines", + Long: "Farm out builds to remote machines that podman can connect to via podman system connection", + RunE: validate.SubCommandExists, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/generate/spec.go b/cmd/podman/generate/spec.go index 0dad5c65106..7bfccb5219f 100644 --- a/cmd/podman/generate/spec.go +++ b/cmd/podman/generate/spec.go @@ -12,21 +12,17 @@ import ( "go.podman.io/common/pkg/completion" ) -var ( - specCmd = &cobra.Command{ - Use: "spec [options] {CONTAINER|POD}", - Short: "Generate Specgen JSON based on containers or pods", - Long: "Generate Specgen JSON based on containers or pods", - RunE: spec, - Args: cobra.ExactArgs(1), - ValidArgsFunction: common.AutocompleteContainersAndPods, - Example: `podman generate spec ctrID`, - } -) +var specCmd = &cobra.Command{ + Use: "spec [options] {CONTAINER|POD}", + Short: "Generate Specgen JSON based on containers or pods", + Long: "Generate Specgen JSON based on containers or pods", + RunE: spec, + Args: cobra.ExactArgs(1), + ValidArgsFunction: common.AutocompleteContainersAndPods, + Example: `podman generate spec ctrID`, +} -var ( - opts *entities.GenerateSpecOptions -) +var opts *entities.GenerateSpecOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/healthcheck/healthcheck.go b/cmd/podman/healthcheck/healthcheck.go index 9b3c904693f..85a9c21e641 100644 --- a/cmd/podman/healthcheck/healthcheck.go +++ b/cmd/podman/healthcheck/healthcheck.go @@ -6,14 +6,12 @@ import ( "github.com/spf13/cobra" ) -var ( - healthCmd = &cobra.Command{ - Use: "healthcheck", - Short: "Manage health checks on containers", - Long: "Run health checks on containers", - RunE: validate.SubCommandExists, - } -) +var healthCmd = &cobra.Command{ + Use: "healthcheck", + Short: "Manage health checks on containers", + Long: "Run health checks on containers", + RunE: validate.SubCommandExists, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/healthcheck/run.go b/cmd/podman/healthcheck/run.go index eee68b69f4f..b5b29633f19 100644 --- a/cmd/podman/healthcheck/run.go +++ b/cmd/podman/healthcheck/run.go @@ -11,17 +11,15 @@ import ( "github.com/spf13/cobra" ) -var ( - runCmd = &cobra.Command{ - Use: "run CONTAINER", - Short: "Run the health check of a container", - Long: "Run the health check of a container", - Example: `podman healthcheck run mywebapp`, - RunE: run, - Args: cobra.ExactArgs(1), - ValidArgsFunction: common.AutocompleteContainersRunning, - } -) +var runCmd = &cobra.Command{ + Use: "run CONTAINER", + Short: "Run the health check of a container", + Long: "Run the health check of a container", + Example: `podman healthcheck run mywebapp`, + RunE: run, + Args: cobra.ExactArgs(1), + ValidArgsFunction: common.AutocompleteContainersRunning, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index d4387cbf489..bae13da28ac 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -97,7 +97,6 @@ func build(cmd *cobra.Command, args []string) error { }() } report, err := registry.ImageEngine().Build(registry.Context(), apiBuildOpts.ContainerFiles, *apiBuildOpts) - if err != nil { exitCode := buildahCLI.ExecErrorCodeGeneric if registry.IsRemote() { diff --git a/cmd/podman/images/buildx.go b/cmd/podman/images/buildx.go index 34ab24ebb5a..4d3bfb22bb4 100644 --- a/cmd/podman/images/buildx.go +++ b/cmd/podman/images/buildx.go @@ -6,22 +6,20 @@ import ( "github.com/spf13/cobra" ) -var ( - // Command: podman _buildx_ - // This is a hidden command, which was added to make converting - // from Docker to Podman easier. - // For now podman buildx build just calls into podman build - // If we are adding new buildx features, we will add them by default - // to podman build. - buildxCmd = &cobra.Command{ - Use: "buildx", - Aliases: []string{"builder"}, - Short: "Build images", - Long: "Build images", - RunE: validate.SubCommandExists, - Hidden: true, - } -) +// Command: podman _buildx_ +// This is a hidden command, which was added to make converting +// from Docker to Podman easier. +// For now podman buildx build just calls into podman build +// If we are adding new buildx features, we will add them by default +// to podman build. +var buildxCmd = &cobra.Command{ + Use: "buildx", + Aliases: []string{"builder"}, + Short: "Build images", + Long: "Build images", + RunE: validate.SubCommandExists, + Hidden: true, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/images/buildx_inspect.go b/cmd/podman/images/buildx_inspect.go index 44d4664eabd..c3400166bce 100644 --- a/cmd/podman/images/buildx_inspect.go +++ b/cmd/podman/images/buildx_inspect.go @@ -41,7 +41,6 @@ func init() { func runBuildxInspect(_ *cobra.Command, _ []string) error { info, err := registry.ContainerEngine().Info(registry.Context()) - if err != nil { return fmt.Errorf("retrieving podman information: %w", err) } diff --git a/cmd/podman/images/exists.go b/cmd/podman/images/exists.go index 924c7ffecd9..9abd0d4213c 100644 --- a/cmd/podman/images/exists.go +++ b/cmd/podman/images/exists.go @@ -6,18 +6,16 @@ import ( "github.com/spf13/cobra" ) -var ( - existsCmd = &cobra.Command{ - Use: "exists IMAGE", - Short: "Check if an image exists in local storage", - Long: `If the named image exists in local storage, podman image exists exits with 0, otherwise the exit code will be 1.`, - Args: cobra.ExactArgs(1), - RunE: exists, - ValidArgsFunction: common.AutocompleteImages, - Example: `podman image exists ID +var existsCmd = &cobra.Command{ + Use: "exists IMAGE", + Short: "Check if an image exists in local storage", + Long: `If the named image exists in local storage, podman image exists exits with 0, otherwise the exit code will be 1.`, + Args: cobra.ExactArgs(1), + RunE: exists, + ValidArgsFunction: common.AutocompleteImages, + Example: `podman image exists ID podman image exists IMAGE && podman pull IMAGE`, - } -) +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/images/import.go b/cmd/podman/images/import.go index 8d46c502591..461c96d483e 100644 --- a/cmd/podman/images/import.go +++ b/cmd/podman/images/import.go @@ -47,9 +47,7 @@ var ( } ) -var ( - importOpts entities.ImageImportOptions -) +var importOpts entities.ImageImportOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/images/load.go b/cmd/podman/images/load.go index 959ad7cb979..e76ea1579ca 100644 --- a/cmd/podman/images/load.go +++ b/cmd/podman/images/load.go @@ -40,9 +40,7 @@ var ( } ) -var ( - loadOpts entities.ImageLoadOptions -) +var loadOpts entities.ImageLoadOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/images/mount.go b/cmd/podman/images/mount.go index 6089cda0e38..b17627bc699 100644 --- a/cmd/podman/images/mount.go +++ b/cmd/podman/images/mount.go @@ -38,9 +38,7 @@ var ( } ) -var ( - mountOpts entities.ImageMountOptions -) +var mountOpts entities.ImageMountOptions func mountFlags(cmd *cobra.Command) { flags := cmd.Flags() diff --git a/cmd/podman/images/save.go b/cmd/podman/images/save.go index 6aede1a5e6e..048670265c6 100644 --- a/cmd/podman/images/save.go +++ b/cmd/podman/images/save.go @@ -18,9 +18,7 @@ import ( "golang.org/x/term" ) -var ( - containerConfig = registry.PodmanConfig() -) +var containerConfig = registry.PodmanConfig() var ( saveDescription = `Save an image to docker-archive or oci-archive on the local machine. Default is docker-archive.` @@ -62,9 +60,7 @@ var ( } ) -var ( - saveOpts entities.ImageSaveOptions -) +var saveOpts entities.ImageSaveOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/images/scp.go b/cmd/podman/images/scp.go index 6a6b8dd03ef..bb1b648248b 100644 --- a/cmd/podman/images/scp.go +++ b/cmd/podman/images/scp.go @@ -46,9 +46,7 @@ func scpFlags(cmd *cobra.Command) { } func scp(_ *cobra.Command, args []string) (finalErr error) { - var ( - err error - ) + var err error containerConfig := registry.PodmanConfig() diff --git a/cmd/podman/images/sign.go b/cmd/podman/images/sign.go index 0c76a983203..6b0072f1498 100644 --- a/cmd/podman/images/sign.go +++ b/cmd/podman/images/sign.go @@ -27,9 +27,7 @@ var ( } ) -var ( - signOptions entities.SignOptions -) +var signOptions entities.SignOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/images/trust_set.go b/cmd/podman/images/trust_set.go index ec2ccf2a18f..d5cab6106b2 100644 --- a/cmd/podman/images/trust_set.go +++ b/cmd/podman/images/trust_set.go @@ -27,9 +27,7 @@ var ( } ) -var ( - setOptions entities.SetTrustOptions -) +var setOptions entities.SetTrustOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/images/trust_show.go b/cmd/podman/images/trust_show.go index a850244f57e..2b4ad4b0f31 100644 --- a/cmd/podman/images/trust_show.go +++ b/cmd/podman/images/trust_show.go @@ -26,9 +26,7 @@ var ( } ) -var ( - showTrustOptions entities.ShowTrustOptions -) +var showTrustOptions entities.ShowTrustOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/images/unmount.go b/cmd/podman/images/unmount.go index e1feafe14e1..f59afbba26c 100644 --- a/cmd/podman/images/unmount.go +++ b/cmd/podman/images/unmount.go @@ -33,9 +33,7 @@ var ( } ) -var ( - unmountOpts entities.ImageUnmountOptions -) +var unmountOpts entities.ImageUnmountOptions func unmountFlags(flags *pflag.FlagSet) { flags.BoolVarP(&unmountOpts.All, "all", "a", false, "Unmount all of the currently mounted images") diff --git a/cmd/podman/login.go b/cmd/podman/login.go index 4ae3e27b2f9..60cc5c7de08 100644 --- a/cmd/podman/login.go +++ b/cmd/podman/login.go @@ -78,7 +78,7 @@ func login(cmd *cobra.Command, args []string) error { if len(loginOptions.Username) == 0 { loginOptions.Username = secretName } - var inspectOpts = entities.SecretInspectOptions{ + inspectOpts := entities.SecretInspectOptions{ ShowSecret: true, } inspected, errs, _ := registry.ContainerEngine().SecretInspect(context.Background(), []string{secretName}, inspectOpts) diff --git a/cmd/podman/machine/client9p.go b/cmd/podman/machine/client9p.go index 0d7bddd0a7b..683ed658313 100644 --- a/cmd/podman/machine/client9p.go +++ b/cmd/podman/machine/client9p.go @@ -17,18 +17,16 @@ import ( "go.podman.io/common/pkg/completion" ) -var ( - client9pCommand = &cobra.Command{ - Args: cobra.ExactArgs(2), - Use: "client9p PORT DIR", - Hidden: true, - Short: "Mount a remote directory using 9p over hvsock", - Long: "Connect to the given hvsock port using 9p and mount the served filesystem at the given directory", - RunE: remoteDirClient, - ValidArgsFunction: completion.AutocompleteNone, - Example: `podman system client9p 55000 /mnt`, - } -) +var client9pCommand = &cobra.Command{ + Args: cobra.ExactArgs(2), + Use: "client9p PORT DIR", + Hidden: true, + Short: "Mount a remote directory using 9p over hvsock", + Long: "Connect to the given hvsock port using 9p and mount the served filesystem at the given directory", + RunE: remoteDirClient, + ValidArgsFunction: completion.AutocompleteNone, + Example: `podman system client9p 55000 /mnt`, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/machine/info.go b/cmd/podman/machine/info.go index 973bc0e10d4..14821df3b34 100644 --- a/cmd/podman/machine/info.go +++ b/cmd/podman/machine/info.go @@ -23,22 +23,18 @@ import ( var infoDescription = `Display information pertaining to the machine host.` -var ( - infoCmd = &cobra.Command{ - Use: "info [options]", - Short: "Display machine host info", - Long: infoDescription, - PersistentPreRunE: machinePreRunE, - RunE: info, - Args: validate.NoArgs, - ValidArgsFunction: completion.AutocompleteNone, - Example: `podman machine info`, - } -) +var infoCmd = &cobra.Command{ + Use: "info [options]", + Short: "Display machine host info", + Long: infoDescription, + PersistentPreRunE: machinePreRunE, + RunE: info, + Args: validate.NoArgs, + ValidArgsFunction: completion.AutocompleteNone, + Example: `podman machine info`, +} -var ( - inFormat string -) +var inFormat string func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/machine/inspect.go b/cmd/podman/machine/inspect.go index a87d43ddb89..2c31581b588 100644 --- a/cmd/podman/machine/inspect.go +++ b/cmd/podman/machine/inspect.go @@ -45,9 +45,7 @@ func init() { } func inspect(cmd *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors if len(args) < 1 { args = append(args, defaultMachineName) } diff --git a/cmd/podman/machine/os.go b/cmd/podman/machine/os.go index 6521e8829ea..2901ca99f46 100644 --- a/cmd/podman/machine/os.go +++ b/cmd/podman/machine/os.go @@ -8,15 +8,13 @@ import ( "github.com/spf13/cobra" ) -var ( - OSCmd = &cobra.Command{ - Use: "os", - Short: "Manage a Podman virtual machine's OS", - Long: "Manage a Podman virtual machine's operating system", - PersistentPreRunE: validate.NoOp, - RunE: validate.SubCommandExists, - } -) +var OSCmd = &cobra.Command{ + Use: "os", + Short: "Manage a Podman virtual machine's OS", + Long: "Manage a Podman virtual machine's operating system", + PersistentPreRunE: validate.NoOp, + RunE: validate.SubCommandExists, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/machine/os/apply.go b/cmd/podman/machine/os/apply.go index 80111fa3c94..da011c29a13 100644 --- a/cmd/podman/machine/os/apply.go +++ b/cmd/podman/machine/os/apply.go @@ -11,18 +11,16 @@ import ( "github.com/spf13/cobra" ) -var ( - applyCmd = &cobra.Command{ - Use: "apply [options] IMAGE [NAME]", - Short: "Apply an OCI image to a Podman Machine's OS", - Long: "Apply custom layers from a containerized Fedora CoreOS OCI image on top of an existing VM", - PersistentPreRunE: validate.NoOp, - Args: cobra.RangeArgs(1, 2), - RunE: apply, - ValidArgsFunction: common.AutocompleteImages, - Example: `podman machine os apply myimage`, - } -) +var applyCmd = &cobra.Command{ + Use: "apply [options] IMAGE [NAME]", + Short: "Apply an OCI image to a Podman Machine's OS", + Long: "Apply custom layers from a containerized Fedora CoreOS OCI image on top of an existing VM", + PersistentPreRunE: validate.NoOp, + Args: cobra.RangeArgs(1, 2), + RunE: apply, + ValidArgsFunction: common.AutocompleteImages, + Example: `podman machine os apply myimage`, +} var restart bool diff --git a/cmd/podman/machine/reset.go b/cmd/podman/machine/reset.go index 5a598e0e8b5..37159e7f965 100644 --- a/cmd/podman/machine/reset.go +++ b/cmd/podman/machine/reset.go @@ -19,21 +19,17 @@ import ( "go.podman.io/common/pkg/completion" ) -var ( - resetCmd = &cobra.Command{ - Use: "reset [options]", - Short: "Remove all machines", - Long: "Remove all machines, configurations, data, and cached images", - RunE: reset, - Args: validate.NoArgs, - Example: `podman machine reset`, - ValidArgsFunction: completion.AutocompleteNone, - } -) +var resetCmd = &cobra.Command{ + Use: "reset [options]", + Short: "Remove all machines", + Long: "Remove all machines, configurations, data, and cached images", + RunE: reset, + Args: validate.NoArgs, + Example: `podman machine reset`, + ValidArgsFunction: completion.AutocompleteNone, +} -var ( - resetOptions machine.ResetOptions -) +var resetOptions machine.ResetOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/machine/rm.go b/cmd/podman/machine/rm.go index c6ced6fcf7c..2dd59402df5 100644 --- a/cmd/podman/machine/rm.go +++ b/cmd/podman/machine/rm.go @@ -10,22 +10,18 @@ import ( "github.com/spf13/cobra" ) -var ( - rmCmd = &cobra.Command{ - Use: "rm [options] [MACHINE]", - Short: "Remove an existing machine", - Long: "Remove a managed virtual machine ", - PersistentPreRunE: machinePreRunE, - RunE: rm, - Args: cobra.MaximumNArgs(1), - Example: `podman machine rm podman-machine-default`, - ValidArgsFunction: autocompleteMachine, - } -) +var rmCmd = &cobra.Command{ + Use: "rm [options] [MACHINE]", + Short: "Remove an existing machine", + Long: "Remove a managed virtual machine ", + PersistentPreRunE: machinePreRunE, + RunE: rm, + Args: cobra.MaximumNArgs(1), + Example: `podman machine rm podman-machine-default`, + ValidArgsFunction: autocompleteMachine, +} -var ( - destroyOptions machine.RemoveOptions -) +var destroyOptions machine.RemoveOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ @@ -45,9 +41,7 @@ func init() { } func rm(_ *cobra.Command, args []string) error { - var ( - err error - ) + var err error vmName := defaultMachineName if len(args) > 0 && len(args[0]) > 0 { vmName = args[0] diff --git a/cmd/podman/machine/server9p.go b/cmd/podman/machine/server9p.go index 57bd110d335..d1b7a47dfa9 100644 --- a/cmd/podman/machine/server9p.go +++ b/cmd/podman/machine/server9p.go @@ -16,18 +16,16 @@ import ( "go.podman.io/common/pkg/completion" ) -var ( - server9pCommand = &cobra.Command{ - Args: cobra.ExactArgs(1), - Use: "server9p [options] PID", - Hidden: true, - Short: "Serve a directory using 9p over hvsock", - Long: "Start a number of 9p servers on given hvsock UUIDs, and run until the given PID exits", - RunE: remoteDirServer, - ValidArgsFunction: completion.AutocompleteNone, - Example: `podman system server9p --serve C:\Users\myuser:00000050-FACB-11E6-BD58-64006A7986D3 /mnt`, - } -) +var server9pCommand = &cobra.Command{ + Args: cobra.ExactArgs(1), + Use: "server9p [options] PID", + Hidden: true, + Short: "Serve a directory using 9p over hvsock", + Long: "Start a number of 9p servers on given hvsock UUIDs, and run until the given PID exits", + RunE: remoteDirServer, + ValidArgsFunction: completion.AutocompleteNone, + Example: `podman system server9p --serve C:\Users\myuser:00000050-FACB-11E6-BD58-64006A7986D3 /mnt`, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ @@ -42,9 +40,7 @@ func init() { _ = server9pCommand.RegisterFlagCompletionFunc(serveFlagName, completion.AutocompleteNone) } -var ( - serveDirs []string -) +var serveDirs []string func remoteDirServer(_ *cobra.Command, args []string) error { pid, err := strconv.Atoi(args[0]) diff --git a/cmd/podman/machine/set.go b/cmd/podman/machine/set.go index ecfae810ae8..ee403ffefa1 100644 --- a/cmd/podman/machine/set.go +++ b/cmd/podman/machine/set.go @@ -11,18 +11,16 @@ import ( "go.podman.io/common/pkg/strongunits" ) -var ( - setCmd = &cobra.Command{ - Use: "set [options] [NAME]", - Short: "Set a virtual machine setting", - Long: "Set an updatable virtual machine setting", - PersistentPreRunE: machinePreRunE, - RunE: setMachine, - Args: cobra.MaximumNArgs(1), - Example: `podman machine set --rootful=false`, - ValidArgsFunction: completion.AutocompleteNone, - } -) +var setCmd = &cobra.Command{ + Use: "set [options] [NAME]", + Short: "Set a virtual machine setting", + Long: "Set an updatable virtual machine setting", + PersistentPreRunE: machinePreRunE, + RunE: setMachine, + Args: cobra.MaximumNArgs(1), + Example: `podman machine set --rootful=false`, + ValidArgsFunction: completion.AutocompleteNone, +} var ( setFlags = SetFlags{} diff --git a/cmd/podman/machine/ssh.go b/cmd/podman/machine/ssh.go index 66beaeb0722..eed77b1339c 100644 --- a/cmd/podman/machine/ssh.go +++ b/cmd/podman/machine/ssh.go @@ -16,22 +16,18 @@ import ( "go.podman.io/common/pkg/completion" ) -var ( - sshCmd = &cobra.Command{ - Use: "ssh [options] [NAME] [COMMAND [ARG ...]]", - Short: "SSH into an existing machine", - Long: "SSH into a managed virtual machine ", - PersistentPreRunE: machinePreRunE, - RunE: ssh, - Example: `podman machine ssh podman-machine-default +var sshCmd = &cobra.Command{ + Use: "ssh [options] [NAME] [COMMAND [ARG ...]]", + Short: "SSH into an existing machine", + Long: "SSH into a managed virtual machine ", + PersistentPreRunE: machinePreRunE, + RunE: ssh, + Example: `podman machine ssh podman-machine-default podman machine ssh myvm echo hello`, - ValidArgsFunction: autocompleteMachineSSH, - } -) + ValidArgsFunction: autocompleteMachineSSH, +} -var ( - sshOpts machine.SSHOptions -) +var sshOpts machine.SSHOptions func init() { sshCmd.Flags().SetInterspersed(false) diff --git a/cmd/podman/machine/stop.go b/cmd/podman/machine/stop.go index 144f5e9cfec..83bfd239b13 100644 --- a/cmd/podman/machine/stop.go +++ b/cmd/podman/machine/stop.go @@ -11,18 +11,16 @@ import ( "github.com/spf13/cobra" ) -var ( - stopCmd = &cobra.Command{ - Use: "stop [MACHINE]", - Short: "Stop an existing machine", - Long: "Stop a managed virtual machine ", - PersistentPreRunE: machinePreRunE, - RunE: stop, - Args: cobra.MaximumNArgs(1), - Example: `podman machine stop podman-machine-default`, - ValidArgsFunction: autocompleteMachine, - } -) +var stopCmd = &cobra.Command{ + Use: "stop [MACHINE]", + Short: "Stop an existing machine", + Long: "Stop a managed virtual machine ", + PersistentPreRunE: machinePreRunE, + RunE: stop, + Args: cobra.MaximumNArgs(1), + Example: `podman machine stop podman-machine-default`, + ValidArgsFunction: autocompleteMachine, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ @@ -33,9 +31,7 @@ func init() { // TODO Name shouldn't be required, need to create a default vm func stop(_ *cobra.Command, args []string) error { - var ( - err error - ) + var err error vmName := defaultMachineName if len(args) > 0 && len(args[0]) > 0 { diff --git a/cmd/podman/main.go b/cmd/podman/main.go index da010076e46..1ce01bac578 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -41,6 +41,7 @@ type logrusLogger struct{} func (l logrusLogger) Errorf(format string, args ...any) { logrus.Errorf(format, args...) } + func (l logrusLogger) Debugf(format string, args ...any) { logrus.Debugf(format, args...) } diff --git a/cmd/podman/manifest/exists.go b/cmd/podman/manifest/exists.go index dfe15537c72..7be901e6bbf 100644 --- a/cmd/podman/manifest/exists.go +++ b/cmd/podman/manifest/exists.go @@ -6,17 +6,15 @@ import ( "github.com/spf13/cobra" ) -var ( - existsCmd = &cobra.Command{ - Use: "exists MANIFEST", - Short: "Check if a manifest list exists in local storage", - Long: `If the manifest list exists in local storage, podman manifest exists exits with 0, otherwise the exit code will be 1.`, - Args: cobra.ExactArgs(1), - RunE: exists, - ValidArgsFunction: common.AutocompleteImages, - Example: "podman manifest exists mylist", - } -) +var existsCmd = &cobra.Command{ + Use: "exists MANIFEST", + Short: "Check if a manifest list exists in local storage", + Long: `If the manifest list exists in local storage, podman manifest exists exits with 0, otherwise the exit code will be 1.`, + Args: cobra.ExactArgs(1), + RunE: exists, + ValidArgsFunction: common.AutocompleteImages, + Example: "podman manifest exists mylist", +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/manifest/remove.go b/cmd/podman/manifest/remove.go index 01fe077a36a..f3aee2e733a 100644 --- a/cmd/podman/manifest/remove.go +++ b/cmd/podman/manifest/remove.go @@ -8,17 +8,15 @@ import ( "github.com/spf13/cobra" ) -var ( - removeCmd = &cobra.Command{ - Use: "remove LIST DIGEST", - Short: "Remove an item from a manifest list or image index", - Long: "Removes an item from a manifest list or image index.", - RunE: remove, - Args: cobra.ExactArgs(2), - ValidArgsFunction: common.AutocompleteManifestListAndMember, - Example: `podman manifest remove mylist:v1.11 sha256:15352d97781ffdf357bf3459c037be3efac4133dc9070c2dce7eca7c05c3e736`, - } -) +var removeCmd = &cobra.Command{ + Use: "remove LIST DIGEST", + Short: "Remove an item from a manifest list or image index", + Long: "Removes an item from a manifest list or image index.", + RunE: remove, + Args: cobra.ExactArgs(2), + ValidArgsFunction: common.AutocompleteManifestListAndMember, + Example: `podman manifest remove mylist:v1.11 sha256:15352d97781ffdf357bf3459c037be3efac4133dc9070c2dce7eca7c05c3e736`, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/networks/create.go b/cmd/podman/networks/create.go index e2d961658fb..cefbad485e4 100644 --- a/cmd/podman/networks/create.go +++ b/cmd/podman/networks/create.go @@ -94,6 +94,7 @@ func networkCreateFlags(cmd *cobra.Command) { flags.StringSliceVar(&networkCreateOptions.NetworkDNSServers, dnsserverFlagName, nil, "DNS servers this network will use") _ = cmd.RegisterFlagCompletionFunc(dnsserverFlagName, completion.AutocompleteNone) } + func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ Command: networkCreateCommand, @@ -103,9 +104,7 @@ func init() { } func networkCreate(cmd *cobra.Command, args []string) error { - var ( - name string - ) + var name string if len(args) > 0 { name = args[0] } @@ -184,7 +183,6 @@ func networkCreate(cmd *cobra.Command, args []string) error { for i := range networkCreateOptions.Routes { route, err := parseRoute(networkCreateOptions.Routes[i]) - if err != nil { return err } @@ -225,7 +223,6 @@ func parseRoute(routeStr string) (*types.Route, error) { if len(s) == 3 { mtr, err := strconv.ParseUint(s[2], 10, 32) - if err != nil { return nil, fmt.Errorf("invalid route metric %s", s[2]) } diff --git a/cmd/podman/networks/disconnect.go b/cmd/podman/networks/disconnect.go index 0aaa34b701c..5b37ec8b2f7 100644 --- a/cmd/podman/networks/disconnect.go +++ b/cmd/podman/networks/disconnect.go @@ -21,9 +21,7 @@ var ( } ) -var ( - networkDisconnectOptions entities.NetworkDisconnectOptions -) +var networkDisconnectOptions entities.NetworkDisconnectOptions func networkDisconnectFlags(flags *pflag.FlagSet) { flags.BoolVarP(&networkDisconnectOptions.Force, "force", "f", false, "force removal of container from network") diff --git a/cmd/podman/networks/reload.go b/cmd/podman/networks/reload.go index 5f2216e394d..5b8bf427c58 100644 --- a/cmd/podman/networks/reload.go +++ b/cmd/podman/networks/reload.go @@ -29,9 +29,7 @@ var ( } ) -var ( - reloadOptions entities.NetworkReloadOptions -) +var reloadOptions entities.NetworkReloadOptions func reloadFlags(flags *pflag.FlagSet) { flags.BoolVarP(&reloadOptions.All, "all", "a", false, "Reload network configuration of all containers") diff --git a/cmd/podman/networks/rm.go b/cmd/podman/networks/rm.go index fc98b011a64..67a5e4370f7 100644 --- a/cmd/podman/networks/rm.go +++ b/cmd/podman/networks/rm.go @@ -30,9 +30,7 @@ var ( stopTimeout int ) -var ( - networkRmOptions entities.NetworkRmOptions -) +var networkRmOptions entities.NetworkRmOptions func networkRmFlags(flags *pflag.FlagSet) { flags.BoolVarP(&networkRmOptions.Force, "force", "f", false, "remove any containers using network") @@ -51,9 +49,7 @@ func init() { } func networkRm(cmd *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors if cmd.Flag("time").Changed { if !networkRmOptions.Force { diff --git a/cmd/podman/networks/update.go b/cmd/podman/networks/update.go index 3d2e0bf8ceb..4e92b4bab01 100644 --- a/cmd/podman/networks/update.go +++ b/cmd/podman/networks/update.go @@ -23,9 +23,7 @@ var ( } ) -var ( - networkUpdateOptions entities.NetworkUpdateOptions -) +var networkUpdateOptions entities.NetworkUpdateOptions func networkUpdateFlags(cmd *cobra.Command) { flags := cmd.Flags() @@ -37,6 +35,7 @@ func networkUpdateFlags(cmd *cobra.Command) { _ = cmd.RegisterFlagCompletionFunc(addDNSServerFlagName, completion.AutocompleteNone) _ = cmd.RegisterFlagCompletionFunc(removeDNSServerFlagName, completion.AutocompleteNone) } + func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ Command: networkUpdateCommand, diff --git a/cmd/podman/parse/net.go b/cmd/podman/parse/net.go index 3f6806e18f6..a34418ec31e 100644 --- a/cmd/podman/parse/net.go +++ b/cmd/podman/parse/net.go @@ -57,7 +57,7 @@ func ValidateExtraHost(val string) (string, error) { // validateIPAddress validates an Ip address. // for dns, ip, and ip6 flags also func validateIPAddress(val string) (string, error) { - var ip = net.ParseIP(strings.TrimSpace(val)) + ip := net.ParseIP(strings.TrimSpace(val)) if ip != nil { return ip.String(), nil } diff --git a/cmd/podman/parse/net_test.go b/cmd/podman/parse/net_test.go index c0aebe0df46..185b27407b8 100644 --- a/cmd/podman/parse/net_test.go +++ b/cmd/podman/parse/net_test.go @@ -13,9 +13,7 @@ import ( "go.podman.io/common/libnetwork/etchosts" ) -var ( - Var1 = []string{"ONE=1", "TWO=2"} -) +var Var1 = []string{"ONE=1", "TWO=2"} func createTmpFile(content []byte) (string, error) { tmpfile, err := os.CreateTemp(os.TempDir(), "unittest") diff --git a/cmd/podman/pods/clone.go b/cmd/podman/pods/clone.go index df6d71254fc..364a8e81961 100644 --- a/cmd/podman/pods/clone.go +++ b/cmd/podman/pods/clone.go @@ -26,9 +26,7 @@ var ( } ) -var ( - podClone entities.PodCloneOptions -) +var podClone entities.PodCloneOptions func cloneFlags(cmd *cobra.Command) { flags := cmd.Flags() @@ -54,6 +52,7 @@ func cloneFlags(cmd *cobra.Command) { // TODO: add support for container specific arguments/flags common.DefineCreateDefaults(&podClone.PerContainerOptions) } + func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ Command: podCloneCommand, diff --git a/cmd/podman/pods/kill.go b/cmd/podman/pods/kill.go index cc86f0e269d..3fe29011c82 100644 --- a/cmd/podman/pods/kill.go +++ b/cmd/podman/pods/kill.go @@ -30,9 +30,7 @@ var ( } ) -var ( - killOpts entities.PodKillOptions -) +var killOpts entities.PodKillOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ @@ -50,9 +48,7 @@ func init() { } func kill(_ *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors responses, err := registry.ContainerEngine().PodKill(context.Background(), args, killOpts) if err != nil { return err diff --git a/cmd/podman/pods/pause.go b/cmd/podman/pods/pause.go index 24a3c7b7fe8..01c69fc903d 100644 --- a/cmd/podman/pods/pause.go +++ b/cmd/podman/pods/pause.go @@ -30,9 +30,7 @@ var ( } ) -var ( - pauseOptions entities.PodPauseOptions -) +var pauseOptions entities.PodPauseOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ @@ -43,10 +41,9 @@ func init() { flags.BoolVarP(&pauseOptions.All, "all", "a", false, "Pause all running pods") validate.AddLatestFlag(pauseCommand, &pauseOptions.Latest) } + func pause(_ *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors responses, err := registry.ContainerEngine().PodPause(context.Background(), args, pauseOptions) if err != nil { return err diff --git a/cmd/podman/pods/prune.go b/cmd/podman/pods/prune.go index d3c6c34ff68..b17447260d3 100644 --- a/cmd/podman/pods/prune.go +++ b/cmd/podman/pods/prune.go @@ -15,9 +15,7 @@ import ( "go.podman.io/common/pkg/completion" ) -var ( - pruneOptions = entities.PodPruneOptions{} -) +var pruneOptions = entities.PodPruneOptions{} var ( pruneDescription = `podman pod prune Removes all exited pods` diff --git a/cmd/podman/pods/restart.go b/cmd/podman/pods/restart.go index 415f0ac58b3..a57332f8ccc 100644 --- a/cmd/podman/pods/restart.go +++ b/cmd/podman/pods/restart.go @@ -30,9 +30,7 @@ var ( } ) -var ( - restartOptions = entities.PodRestartOptions{} -) +var restartOptions = entities.PodRestartOptions{} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ @@ -46,9 +44,7 @@ func init() { } func restart(_ *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors responses, err := registry.ContainerEngine().PodRestart(context.Background(), args, restartOptions) if err != nil { return err diff --git a/cmd/podman/pods/unpause.go b/cmd/podman/pods/unpause.go index d19fcc757cd..8d05e6f1fc1 100644 --- a/cmd/podman/pods/unpause.go +++ b/cmd/podman/pods/unpause.go @@ -30,9 +30,7 @@ var ( } ) -var ( - unpauseOptions entities.PodunpauseOptions -) +var unpauseOptions entities.PodunpauseOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ @@ -45,9 +43,7 @@ func init() { } func unpause(_ *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors responses, err := registry.ContainerEngine().PodUnpause(context.Background(), args, unpauseOptions) if err != nil { return err diff --git a/cmd/podman/secrets/create.go b/cmd/podman/secrets/create.go index 97a2d8f955a..89ca19c0bb8 100644 --- a/cmd/podman/secrets/create.go +++ b/cmd/podman/secrets/create.go @@ -16,18 +16,16 @@ import ( "go.podman.io/common/pkg/completion" ) -var ( - createCmd = &cobra.Command{ - Use: "create [options] NAME FILE|-", - Short: "Create a new secret", - Long: "Create a secret. Input can be a path to a file or \"-\" (read from stdin). Secret drivers \"file\" (default), \"pass\", and \"shell\" are available.", - RunE: create, - Args: cobra.ExactArgs(2), - Example: `podman secret create mysecret /path/to/secret +var createCmd = &cobra.Command{ + Use: "create [options] NAME FILE|-", + Short: "Create a new secret", + Long: "Create a secret. Input can be a path to a file or \"-\" (read from stdin). Secret drivers \"file\" (default), \"pass\", and \"shell\" are available.", + RunE: create, + Args: cobra.ExactArgs(2), + Example: `podman secret create mysecret /path/to/secret printf "secretdata" | podman secret create mysecret -`, - ValidArgsFunction: common.AutocompleteSecretCreate, - } -) + ValidArgsFunction: common.AutocompleteSecretCreate, +} var ( createOpts = entities.SecretCreateOptions{} diff --git a/cmd/podman/secrets/exists.go b/cmd/podman/secrets/exists.go index 06357409c0c..1569ca7f6d2 100644 --- a/cmd/podman/secrets/exists.go +++ b/cmd/podman/secrets/exists.go @@ -6,18 +6,16 @@ import ( "github.com/spf13/cobra" ) -var ( - existsCmd = &cobra.Command{ - Use: "exists SECRET", - Short: "Check if a secret exists in local storage", - Long: `If the named secret exists in local storage, podman secret exists exits with 0, otherwise the exit code will be 1.`, - Args: cobra.ExactArgs(1), - RunE: exists, - ValidArgsFunction: common.AutocompleteSecrets, - Example: `podman secret exists ID +var existsCmd = &cobra.Command{ + Use: "exists SECRET", + Short: "Check if a secret exists in local storage", + Long: `If the named secret exists in local storage, podman secret exists exits with 0, otherwise the exit code will be 1.`, + Args: cobra.ExactArgs(1), + RunE: exists, + ValidArgsFunction: common.AutocompleteSecrets, + Example: `podman secret exists ID podman secret exists SECRET || podman secret create SECRET `, - } -) +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/secrets/inspect.go b/cmd/podman/secrets/inspect.go index 6507815444c..595fecbbd87 100644 --- a/cmd/podman/secrets/inspect.go +++ b/cmd/podman/secrets/inspect.go @@ -13,17 +13,15 @@ import ( "go.podman.io/common/pkg/report" ) -var ( - inspectCmd = &cobra.Command{ - Use: "inspect [options] SECRET [SECRET...]", - Short: "Inspect a secret", - Long: "Display detail information on one or more secrets", - RunE: inspect, - Example: "podman secret inspect MYSECRET", - Args: cobra.MinimumNArgs(1), - ValidArgsFunction: common.AutocompleteSecrets, - } -) +var inspectCmd = &cobra.Command{ + Use: "inspect [options] SECRET [SECRET...]", + Short: "Inspect a secret", + Long: "Display detail information on one or more secrets", + RunE: inspect, + Example: "podman secret inspect MYSECRET", + Args: cobra.MinimumNArgs(1), + ValidArgsFunction: common.AutocompleteSecrets, +} var ( format string diff --git a/cmd/podman/secrets/rm.go b/cmd/podman/secrets/rm.go index f3648ec91bd..22ed429937e 100644 --- a/cmd/podman/secrets/rm.go +++ b/cmd/podman/secrets/rm.go @@ -12,15 +12,13 @@ import ( "github.com/spf13/cobra" ) -var ( - rmCmd = &cobra.Command{ - Use: "rm [options] SECRET [SECRET...]", - Short: "Remove one or more secrets", - RunE: rm, - ValidArgsFunction: common.AutocompleteSecrets, - Example: "podman secret rm mysecret1 mysecret2", - } -) +var rmCmd = &cobra.Command{ + Use: "rm [options] SECRET [SECRET...]", + Short: "Remove one or more secrets", + RunE: rm, + ValidArgsFunction: common.AutocompleteSecrets, + Example: "podman secret rm mysecret1 mysecret2", +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ @@ -32,14 +30,10 @@ func init() { flags.BoolVarP(&rmOptions.Ignore, "ignore", "i", false, "Ignore errors when a specified secret is missing") } -var ( - rmOptions = entities.SecretRmOptions{} -) +var rmOptions = entities.SecretRmOptions{} func rm(_ *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors if (len(args) > 0 && rmOptions.All) || (len(args) < 1 && !rmOptions.All) { return errors.New("`podman secret rm` requires one argument, or the --all flag") } diff --git a/cmd/podman/secrets/secret.go b/cmd/podman/secrets/secret.go index e9703aeaa9c..18875c149c0 100644 --- a/cmd/podman/secrets/secret.go +++ b/cmd/podman/secrets/secret.go @@ -6,15 +6,13 @@ import ( "github.com/spf13/cobra" ) -var ( - // Command: podman _secret_ - secretCmd = &cobra.Command{ - Use: "secret", - Short: "Manage secrets", - Long: "Manage secrets", - RunE: validate.SubCommandExists, - } -) +// Command: podman _secret_ +var secretCmd = &cobra.Command{ + Use: "secret", + Short: "Manage secrets", + Long: "Manage secrets", + RunE: validate.SubCommandExists, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/system/connection.go b/cmd/podman/system/connection.go index 06e703aafd2..81e35614672 100644 --- a/cmd/podman/system/connection.go +++ b/cmd/podman/system/connection.go @@ -6,19 +6,17 @@ import ( "github.com/spf13/cobra" ) -var ( - // ConnectionCmd skips creating engines (PersistentPreRunE/PersistentPostRunE are No-Op's) since - // sub-commands will obtain connection information to said engines - ConnectionCmd = &cobra.Command{ - Use: "connection", - Short: "Manage remote API service destinations", - Long: `Manage remote API service destination information in podman configuration`, - PersistentPreRunE: validate.NoOp, - RunE: validate.SubCommandExists, - PersistentPostRunE: validate.NoOp, - TraverseChildren: false, - } -) +// ConnectionCmd skips creating engines (PersistentPreRunE/PersistentPostRunE are No-Op's) since +// sub-commands will obtain connection information to said engines +var ConnectionCmd = &cobra.Command{ + Use: "connection", + Short: "Manage remote API service destinations", + Long: `Manage remote API service destination information in podman configuration`, + PersistentPreRunE: validate.NoOp, + RunE: validate.SubCommandExists, + PersistentPostRunE: validate.NoOp, + TraverseChildren: false, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/system/connection/rename.go b/cmd/podman/system/connection/rename.go index 680b7f44682..ff5c505ce13 100644 --- a/cmd/podman/system/connection/rename.go +++ b/cmd/podman/system/connection/rename.go @@ -10,20 +10,18 @@ import ( "go.podman.io/common/pkg/config" ) -var ( - // Skip creating engines since this command will obtain connection information to said engines - renameCmd = &cobra.Command{ - Use: "rename OLD NEW", - Aliases: []string{"mv"}, - Args: cobra.ExactArgs(2), - Short: "Rename \"old\" to \"new\"", - Long: `Rename destination for the Podman service from "old" to "new"`, - ValidArgsFunction: common.AutocompleteSystemConnections, - RunE: rename, - Example: `podman system connection rename laptop devl, +// Skip creating engines since this command will obtain connection information to said engines +var renameCmd = &cobra.Command{ + Use: "rename OLD NEW", + Aliases: []string{"mv"}, + Args: cobra.ExactArgs(2), + Short: "Rename \"old\" to \"new\"", + Long: `Rename destination for the Podman service from "old" to "new"`, + ValidArgsFunction: common.AutocompleteSystemConnections, + RunE: rename, + Example: `podman system connection rename laptop devl, podman system connection mv laptop devl`, - } -) +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/system/context.go b/cmd/podman/system/context.go index ac0d60dac56..3ab7b5f129b 100644 --- a/cmd/podman/system/context.go +++ b/cmd/podman/system/context.go @@ -6,20 +6,18 @@ import ( "github.com/spf13/cobra" ) -var ( - // ContextCmd skips creating engines (PersistentPreRunE/PersistentPostRunE are No-Op's) since - // sub-commands will obtain connection information to said engines - ContextCmd = &cobra.Command{ - Use: "context", - Short: "Manage remote API service destinations", - Long: `Manage remote API service destination information in podman configuration`, - PersistentPreRunE: validate.NoOp, - RunE: validate.SubCommandExists, - PersistentPostRunE: validate.NoOp, - Hidden: true, - TraverseChildren: false, - } -) +// ContextCmd skips creating engines (PersistentPreRunE/PersistentPostRunE are No-Op's) since +// sub-commands will obtain connection information to said engines +var ContextCmd = &cobra.Command{ + Use: "context", + Short: "Manage remote API service destinations", + Long: `Manage remote API service destination information in podman configuration`, + PersistentPreRunE: validate.NoOp, + RunE: validate.SubCommandExists, + PersistentPostRunE: validate.NoOp, + Hidden: true, + TraverseChildren: false, +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/system/df.go b/cmd/podman/system/df.go index fcb76152979..c0fcd7b7e26 100644 --- a/cmd/podman/system/df.go +++ b/cmd/podman/system/df.go @@ -34,9 +34,7 @@ var ( } ) -var ( - dfOptions entities.SystemDfOptions -) +var dfOptions entities.SystemDfOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/system/dial_stdio.go b/cmd/podman/system/dial_stdio.go index d31a4f4a1b1..dd33c245f1a 100644 --- a/cmd/podman/system/dial_stdio.go +++ b/cmd/podman/system/dial_stdio.go @@ -2,12 +2,11 @@ package system import ( "context" + "errors" "fmt" "io" "os" - "errors" - "github.com/containers/podman/v6/cmd/podman/registry" "github.com/containers/podman/v6/cmd/podman/validate" "github.com/containers/podman/v6/pkg/bindings" @@ -15,18 +14,16 @@ import ( "github.com/spf13/cobra" ) -var ( - dialStdioCommand = &cobra.Command{ - Use: "dial-stdio", - Short: "Proxy the stdio stream to the daemon connection. Should not be invoked manually.", - Args: validate.NoArgs, - Hidden: true, - RunE: func(_ *cobra.Command, _ []string) error { - return runDialStdio() - }, - Example: "podman system dial-stdio", - } -) +var dialStdioCommand = &cobra.Command{ + Use: "dial-stdio", + Short: "Proxy the stdio stream to the daemon connection. Should not be invoked manually.", + Args: validate.NoArgs, + Hidden: true, + RunE: func(_ *cobra.Command, _ []string) error { + return runDialStdio() + }, + Example: "podman system dial-stdio", +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/system/locks.go b/cmd/podman/system/locks.go index 3a99299f2ca..cc15906f96f 100644 --- a/cmd/podman/system/locks.go +++ b/cmd/podman/system/locks.go @@ -8,18 +8,16 @@ import ( "github.com/spf13/cobra" ) -var ( - locksCommand = &cobra.Command{ - Use: "locks", - Short: "Debug Libpod's use of locks, identifying any potential conflicts", - Args: validate.NoArgs, - Hidden: true, - RunE: func(_ *cobra.Command, _ []string) error { - return runLocks() - }, - Example: "podman system locks", - } -) +var locksCommand = &cobra.Command{ + Use: "locks", + Short: "Debug Libpod's use of locks, identifying any potential conflicts", + Args: validate.NoArgs, + Hidden: true, + RunE: func(_ *cobra.Command, _ []string) error { + return runLocks() + }, + Example: "podman system locks", +} func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ @@ -27,6 +25,7 @@ func init() { Parent: systemCmd, }) } + func runLocks() error { report, err := registry.ContainerEngine().Locks(registry.Context()) if err != nil { diff --git a/cmd/podman/system/migrate.go b/cmd/podman/system/migrate.go index edcce98c5ca..7933520a7c1 100644 --- a/cmd/podman/system/migrate.go +++ b/cmd/podman/system/migrate.go @@ -31,9 +31,7 @@ var ( } ) -var ( - migrateOptions entities.SystemMigrateOptions -) +var migrateOptions entities.SystemMigrateOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/utils/error.go b/cmd/podman/utils/error.go index 02aa5a14585..73bd147dc58 100644 --- a/cmd/podman/utils/error.go +++ b/cmd/podman/utils/error.go @@ -16,13 +16,13 @@ type OutputErrors []error func (o OutputErrors) PrintErrors() (lastError error) { if len(o) == 0 { - return + return lastError } lastError = o[len(o)-1] for e := 0; e < len(o)-1; e++ { fmt.Fprintf(os.Stderr, "Error: %s\n", o[e]) } - return + return lastError } /* diff --git a/cmd/podman/volumes/create.go b/cmd/podman/volumes/create.go index ec7614ecd59..78c09048949 100644 --- a/cmd/podman/volumes/create.go +++ b/cmd/podman/volumes/create.go @@ -71,9 +71,7 @@ func init() { } func create(cmd *cobra.Command, args []string) error { - var ( - err error - ) + var err error if len(args) > 0 { createOpts.Name = args[0] } diff --git a/cmd/podman/volumes/export.go b/cmd/podman/volumes/export.go index 774e8608968..b4825742bd0 100644 --- a/cmd/podman/volumes/export.go +++ b/cmd/podman/volumes/export.go @@ -29,9 +29,7 @@ Allow content of volume to be exported into external tar.` } ) -var ( - targetPath string -) +var targetPath string func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/volumes/inspect.go b/cmd/podman/volumes/inspect.go index a91a69881de..24931eecc27 100644 --- a/cmd/podman/volumes/inspect.go +++ b/cmd/podman/volumes/inspect.go @@ -27,9 +27,7 @@ var ( } ) -var ( - inspectOpts *entities.InspectOptions -) +var inspectOpts *entities.InspectOptions func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ diff --git a/cmd/podman/volumes/rm.go b/cmd/podman/volumes/rm.go index 0b75eeeae07..e4da2b02a34 100644 --- a/cmd/podman/volumes/rm.go +++ b/cmd/podman/volumes/rm.go @@ -51,9 +51,7 @@ func init() { } func rm(cmd *cobra.Command, args []string) error { - var ( - errs utils.OutputErrors - ) + var errs utils.OutputErrors if (len(args) > 0 && rmOptions.All) || (len(args) < 1 && !rmOptions.All) { return errors.New("choose either one or more volumes or all") } diff --git a/cmd/quadlet/main.go b/cmd/quadlet/main.go index c8b63e22e56..a6090201dd0 100644 --- a/cmd/quadlet/main.go +++ b/cmd/quadlet/main.go @@ -39,9 +39,7 @@ var ( kmsgFile *os.File ) -var ( - void struct{} -) +var void struct{} // We log directly to /dev/kmsg, because that is the only way to get information out // of the generator into the system logs. @@ -146,7 +144,7 @@ func loadUnitDropins(unit *parser.UnitFile, sourcePaths []string) error { } } - var dropinPaths = make(map[string]string) + dropinPaths := make(map[string]string) for _, dropinDir := range dropinDirs { dropinFiles, err := os.ReadDir(dropinDir) if err != nil { diff --git a/libpod/container_exec.go b/libpod/container_exec.go index 9879a007ac5..3aef3060a2a 100644 --- a/libpod/container_exec.go +++ b/libpod/container_exec.go @@ -478,7 +478,8 @@ func (c *Container) execStartAndAttach(sessionID string, streams *define.AttachS // ExecHTTPStartAndAttach starts and performs an HTTP attach to an exec session. // newSize resizes the tty to this size before the process is started, must be nil if the exec session has no tty func (c *Container) ExecHTTPStartAndAttach(sessionID string, r *http.Request, w http.ResponseWriter, - streams *HTTPAttachStreams, _ *string, cancel <-chan bool, hijackDone chan<- bool, newSize *resize.TerminalSize) error { + streams *HTTPAttachStreams, _ *string, cancel <-chan bool, hijackDone chan<- bool, newSize *resize.TerminalSize, +) error { // TODO: How do we combine streams with the default streams set in the exec session? // Ensure that we don't leak a goroutine here @@ -1016,9 +1017,9 @@ func (c *Container) cleanupExecBundle(sessionID string) (err error) { continue } } - return + return err } - return + return err } // the path to a container's exec session bundle diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 31dc7f5f7d3..5ffe18c46e9 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -61,7 +61,7 @@ import ( const ( // name of the directory holding the artifacts artifactsDir = "artifacts" - execDirPermission = 0755 + execDirPermission = 0o755 preCheckpointDir = "pre-checkpoint" ) @@ -681,7 +681,7 @@ func (c *Container) refresh() error { if err != nil { return err } - if err := os.Chmod(c.runtime.config.Engine.TmpDir, info.Mode()|0111); err != nil { + if err := os.Chmod(c.runtime.config.Engine.TmpDir, info.Mode()|0o111); err != nil { return err } root := filepath.Join(c.runtime.config.Engine.TmpDir, "containers-root", c.ID()) @@ -1799,7 +1799,7 @@ func (c *Container) mountStorage() (_ string, deferredErr error) { return "", fmt.Errorf("unable to get host UID and host GID: %w", err) } - //note: this should not be recursive, if using external rootfs users should be responsible on configuring ownership. + // note: this should not be recursive, if using external rootfs users should be responsible on configuring ownership. if err := chown.ChangeHostPathOwnership(mountPoint, false, int(hostUID), int(hostGID)); err != nil { return "", err } diff --git a/libpod/container_internal_common.go b/libpod/container_internal_common.go index 17454b6ffbd..acaa76ef3ae 100644 --- a/libpod/container_internal_common.go +++ b/libpod/container_internal_common.go @@ -338,7 +338,8 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc return nil, nil, err } - overlayOpts = &overlay.Options{RootUID: c.RootUID(), + overlayOpts = &overlay.Options{ + RootUID: c.RootUID(), RootGID: c.RootGID(), UpperDirOptionFragment: upperDir, WorkDirOptionFragment: workDir, @@ -471,7 +472,8 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc if err != nil { return nil, nil, err } - overlayOpts := &overlay.Options{RootUID: c.RootUID(), + overlayOpts := &overlay.Options{ + RootUID: c.RootUID(), RootGID: c.RootGID(), UpperDirOptionFragment: upperDir, WorkDirOptionFragment: workDir, @@ -1267,7 +1269,6 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error { IncludeSourceDir: true, IncludeFiles: includeFiles, }) - if err != nil { return fmt.Errorf("reading checkpoint directory %q: %w", c.ID(), err) } @@ -2023,7 +2024,6 @@ func (c *Container) makeBindMounts() error { resolvPath, exists := bindMounts[resolvconf.DefaultResolvConf] if !c.config.UseImageResolvConf && exists { err := c.mountIntoRootDirs(resolvconf.DefaultResolvConf, resolvPath) - if err != nil { return fmt.Errorf("assigning mounts to container %s: %w", c.ID(), err) } diff --git a/libpod/container_internal_freebsd.go b/libpod/container_internal_freebsd.go index ca74ba38720..2438f8b4c2e 100644 --- a/libpod/container_internal_freebsd.go +++ b/libpod/container_internal_freebsd.go @@ -21,9 +21,7 @@ import ( "golang.org/x/sys/unix" ) -var ( - bindOptions = []string{} -) +var bindOptions = []string{} func (c *Container) mountSHM(_ string) error { return nil diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 3574c4b1943..3bdbccf18ae 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -30,9 +30,7 @@ import ( "golang.org/x/sys/unix" ) -var ( - bindOptions = []string{define.TypeBind, "rprivate"} -) +var bindOptions = []string{define.TypeBind, "rprivate"} func (c *Container) mountSHM(shmOptions string) error { contextType := "context" diff --git a/libpod/container_log_linux.go b/libpod/container_log_linux.go index 3275e5b37ac..bccbf3f9af4 100644 --- a/libpod/container_log_linux.go +++ b/libpod/container_log_linux.go @@ -31,7 +31,8 @@ func init() { } func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOptions, - logChannel chan *logs.LogLine, colorID int64, passthroughUnit string) error { + logChannel chan *logs.LogLine, colorID int64, passthroughUnit string, +) error { // We need the container's events in the same journal to guarantee // consistency, see #10323. if options.Follow && c.runtime.config.Engine.EventsLogger != "journald" { diff --git a/libpod/define/mount_freebsd.go b/libpod/define/mount_freebsd.go index 3150ffbe7a2..7cce05d18f0 100644 --- a/libpod/define/mount_freebsd.go +++ b/libpod/define/mount_freebsd.go @@ -7,7 +7,5 @@ const ( TypeBind = "nullfs" ) -var ( - // Mount potions for bind - BindOptions = []string{} -) +// Mount potions for bind +var BindOptions = []string{} diff --git a/libpod/define/mount_linux.go b/libpod/define/mount_linux.go index 7c8e5fe7dda..87f1a970c6f 100644 --- a/libpod/define/mount_linux.go +++ b/libpod/define/mount_linux.go @@ -7,7 +7,5 @@ const ( TypeBind = "bind" ) -var ( - // Mount potions for bind - BindOptions = []string{TypeBind} -) +// Mount potions for bind +var BindOptions = []string{TypeBind} diff --git a/libpod/define/version.go b/libpod/define/version.go index e0bb673d062..1a57791cb07 100644 --- a/libpod/define/version.go +++ b/libpod/define/version.go @@ -41,7 +41,6 @@ func GetVersion() (Version, error) { if buildInfo != "" { // Converts unix time from string to int64 buildTime, err = strconv.ParseInt(buildInfo, 10, 64) - if err != nil { return Version{}, err } diff --git a/libpod/events/logfile.go b/libpod/events/logfile.go index 85789831245..0e33a0b448e 100644 --- a/libpod/events/logfile.go +++ b/libpod/events/logfile.go @@ -88,22 +88,22 @@ func (e EventLogFile) getTail(options ReadOptions) (*tail.Tail, error) { func (e EventLogFile) readRotateEvent(event *Event) (begin bool, end bool, err error) { if event.Status != Rotate { - return + return begin, end, err } if event.Details.Attributes == nil { // may be an old event before storing attributes in the rotate event - return + return begin, end, err } switch event.Details.Attributes[rotateEventAttribute] { case rotateEventBegin: begin = true - return + return begin, end, err case rotateEventEnd: end = true - return + return begin, end, err default: err = fmt.Errorf("unknown rotate-event attribute %q", event.Details.Attributes[rotateEventAttribute]) - return + return begin, end, err } } @@ -262,8 +262,8 @@ func logNeedsRotation(logfile string, content string, limit uint64) (bool, error } return false, err } - var filesize = uint64(file.Size()) - var contentsize = uint64(len([]rune(content))) + filesize := uint64(file.Size()) + contentsize := uint64(len([]rune(content))) if filesize+contentsize < limit { return false, nil } diff --git a/libpod/healthcheck_linux.go b/libpod/healthcheck_linux.go index 422abaee467..b0be18564ab 100644 --- a/libpod/healthcheck_linux.go +++ b/libpod/healthcheck_linux.go @@ -31,7 +31,7 @@ func (c *Container) createTimer(interval string, isStartup bool) error { return fmt.Errorf("failed to get path for podman for a health check timer: %w", err) } - var cmd = []string{"--property", "LogLevelMax=notice"} + cmd := []string{"--property", "LogLevelMax=notice"} if rootless.IsRootless() { cmd = append(cmd, "--user") } diff --git a/libpod/kube.go b/libpod/kube.go index 986101b3d53..49b442a3e32 100644 --- a/libpod/kube.go +++ b/libpod/kube.go @@ -1348,7 +1348,7 @@ func generateKubeSecurityContext(c *Container) (*v1.SecurityContext, bool, error sc := v1.SecurityContext{ // RunAsNonRoot is an optional parameter; our first implementations should be root only; however // I'm leaving this as a bread-crumb for later - //RunAsNonRoot: &nonRoot, + // RunAsNonRoot: &nonRoot, } if capabilities != nil { scHasData = true @@ -1441,7 +1441,7 @@ func generateKubeVolumeDeviceFromLinuxDevice(devices []specs.LinuxDevice) []v1.V for _, d := range devices { vd := v1.VolumeDevice{ // TBD How are we going to sync up these names - //Name: + // Name: DevicePath: d.Path, } volumeDevices = append(volumeDevices, vd) diff --git a/libpod/lock/shm/shm_lock.go b/libpod/lock/shm/shm_lock.go index 7aff2788a97..fcb3374d533 100644 --- a/libpod/lock/shm/shm_lock.go +++ b/libpod/lock/shm/shm_lock.go @@ -22,12 +22,10 @@ import ( "github.com/sirupsen/logrus" ) -var ( - // BitmapSize is the size of the bitmap used when managing SHM locks. - // an SHM lock manager's max locks will be rounded up to a multiple of - // this number. - BitmapSize = uint32(C.bitmap_size_c) -) +// BitmapSize is the size of the bitmap used when managing SHM locks. +// an SHM lock manager's max locks will be rounded up to a multiple of +// this number. +var BitmapSize = uint32(C.bitmap_size_c) // SHMLocks is a struct enabling POSIX semaphore locking in a shared memory // segment. @@ -134,14 +132,14 @@ func (locks *SHMLocks) AllocateSemaphore() (uint32, error) { // semaphore indexes, and can still return error codes. retCode := C.allocate_semaphore(locks.lockStruct) if retCode < 0 { - var err = syscall.Errno(-1 * retCode) + err := syscall.Errno(-1 * retCode) // Negative errno returned if errors.Is(err, syscall.ENOSPC) { // ENOSPC expands to "no space left on device". While it is technically true // that there's no room in the SHM inn for this lock, this tends to send normal people // down the path of checking disk-space which is not actually their problem. // Give a clue that it's actually due to num_locks filling up. - var errFull = fmt.Errorf("allocation failed; exceeded num_locks (%d)", locks.maxLocks) + errFull := fmt.Errorf("allocation failed; exceeded num_locks (%d)", locks.maxLocks) return uint32(retCode), errFull } return uint32(retCode), syscall.Errno(-1 * retCode) diff --git a/libpod/lock/shm/shm_lock_nocgo.go b/libpod/lock/shm/shm_lock_nocgo.go index 6040079387a..0dd955a6215 100644 --- a/libpod/lock/shm/shm_lock_nocgo.go +++ b/libpod/lock/shm/shm_lock_nocgo.go @@ -8,8 +8,7 @@ import ( // SHMLocks is a struct enabling POSIX semaphore locking in a shared memory // segment. -type SHMLocks struct { -} +type SHMLocks struct{} // CreateSHMLock sets up a shared-memory segment holding a given number of POSIX // semaphores, and returns a struct that can be used to operate on those locks. diff --git a/libpod/lock/shm/shm_lock_test.go b/libpod/lock/shm/shm_lock_test.go index 5f0b7080653..93bc318f75c 100644 --- a/libpod/lock/shm/shm_lock_test.go +++ b/libpod/lock/shm/shm_lock_test.go @@ -20,10 +20,8 @@ import ( // to test without actually having multiple processes... // We can at least verify that the locks work within the local process. -var ( - // 4 * BITMAP_SIZE to ensure we have to traverse bitmaps - numLocks = 4 * BitmapSize -) +// 4 * BITMAP_SIZE to ensure we have to traverse bitmaps +var numLocks = 4 * BitmapSize const lockPath = "/libpod_test" diff --git a/libpod/logs/log_test.go b/libpod/logs/log_test.go index da6ab22c3c9..47ce8fdce4a 100644 --- a/libpod/logs/log_test.go +++ b/libpod/logs/log_test.go @@ -80,8 +80,10 @@ func TestGetTailLog(t *testing.T) { 2023-08-07T19:56:34.223758260-06:00 stdout F line3 `, tail: 2, - want: []*LogLine{makeTestLogLine("P", "l"), makeTestLogLine("P", "i"), makeTestLogLine("P", "n"), - makeTestLogLine("P", "e"), makeTestLogLine("F", "2"), makeTestLogLine("F", "line3")}, + want: []*LogLine{ + makeTestLogLine("P", "l"), makeTestLogLine("P", "i"), makeTestLogLine("P", "n"), + makeTestLogLine("P", "e"), makeTestLogLine("F", "2"), makeTestLogLine("F", "line3"), + }, }, { name: "partial line at the end", diff --git a/libpod/oci_conmon_exec_common.go b/libpod/oci_conmon_exec_common.go index 2e6d6fb0c96..b562b493e33 100644 --- a/libpod/oci_conmon_exec_common.go +++ b/libpod/oci_conmon_exec_common.go @@ -87,7 +87,8 @@ func (r *ConmonOCIRuntime) ExecContainer(c *Container, sessionID string, options // ExecContainerHTTP executes a new command in an existing container and // forwards its standard streams over an attach func (r *ConmonOCIRuntime) ExecContainerHTTP(ctr *Container, sessionID string, options *ExecOptions, req *http.Request, w http.ResponseWriter, - streams *HTTPAttachStreams, cancel <-chan bool, hijackDone chan<- bool, holdConnOpen <-chan bool, newSize *resize.TerminalSize) (int, chan error, error) { + streams *HTTPAttachStreams, cancel <-chan bool, hijackDone chan<- bool, holdConnOpen <-chan bool, newSize *resize.TerminalSize, +) (int, chan error, error) { if streams != nil { if !streams.Stdin && !streams.Stdout && !streams.Stderr { return -1, nil, fmt.Errorf("must provide at least one stream to attach to: %w", define.ErrInvalidArg) diff --git a/libpod/oci_missing.go b/libpod/oci_missing.go index 1ab17e54182..3af617dd6f2 100644 --- a/libpod/oci_missing.go +++ b/libpod/oci_missing.go @@ -136,7 +136,8 @@ func (r *MissingRuntime) ExecContainer(_ *Container, _ string, _ *ExecOptions, _ // ExecContainerHTTP is not available as the runtime is missing func (r *MissingRuntime) ExecContainerHTTP(_ *Container, _ string, _ *ExecOptions, _ *http.Request, _ http.ResponseWriter, - _ *HTTPAttachStreams, _ <-chan bool, _ chan<- bool, _ <-chan bool, _ *resize.TerminalSize) (int, chan error, error) { + _ *HTTPAttachStreams, _ <-chan bool, _ chan<- bool, _ <-chan bool, _ *resize.TerminalSize, +) (int, chan error, error) { return -1, nil, r.printError() } diff --git a/libpod/options.go b/libpod/options.go index b65c5b8a77e..41d6bc4a78c 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -1962,7 +1962,7 @@ func WithPodRestartPolicy(policy string) PodCreateOption { } switch policy { - //TODO: v5.0 if no restart policy is set, follow k8s convention and default to Always + // TODO: v5.0 if no restart policy is set, follow k8s convention and default to Always case define.RestartPolicyNone, define.RestartPolicyNo, define.RestartPolicyOnFailure, define.RestartPolicyAlways, define.RestartPolicyUnlessStopped: pod.config.RestartPolicy = policy default: diff --git a/libpod/pod_api.go b/libpod/pod_api.go index f8a7e96c59f..5fa533526fc 100644 --- a/libpod/pod_api.go +++ b/libpod/pod_api.go @@ -590,7 +590,6 @@ func containerStatusFromContainers(allCtrs []*Container) (map[string]define.Cont status := make(map[string]define.ContainerStatus, len(allCtrs)) for _, ctr := range allCtrs { state, err := ctr.State() - if err != nil { return nil, err } diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index fd84be39768..3f0c0958a7a 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -235,7 +235,6 @@ func (r *Runtime) newContainer(ctx context.Context, rSpec *spec.Spec, options .. var err error ctr, err = r.initContainerVariables(rSpec, nil) - if err != nil { return nil, fmt.Errorf("initializing container variables: %w", err) } @@ -693,13 +692,13 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO // Container probably already removed // Or was never in the runtime to begin with removedCtrs[c.ID()] = nil - return + return removedCtrs, removedPods, retErr } } if opts.RemovePod && opts.RemoveDeps { retErr = fmt.Errorf("cannot remove dependencies while also removing a pod: %w", define.ErrInvalidArg) - return + return removedCtrs, removedPods, retErr } // We need to refresh container config from the DB, to ensure that any @@ -711,7 +710,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO newConf, err := r.state.GetContainerConfig(c.ID()) if err != nil { retErr = fmt.Errorf("retrieving container %s configuration from DB to remove: %w", c.ID(), err) - return + return removedCtrs, removedPods, retErr } c.config = newConf @@ -738,18 +737,18 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO // Mark this container as removed so there's no // confusion, though. removedCtrs[c.ID()] = nil - return + return removedCtrs, removedPods, retErr } retErr = err - return + return removedCtrs, removedPods, retErr } if !opts.RemovePod { // Lock the pod while we're removing container if pod.config.LockID == c.config.LockID { retErr = fmt.Errorf("container %s and pod %s share lock ID %d: %w", c.ID(), pod.ID(), c.config.LockID, define.ErrWillDeadlock) - return + return removedCtrs, removedPods, retErr } if !opts.NoLockPod { pod.lock.Lock() @@ -760,17 +759,17 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO // already removed. if errors.Is(err, define.ErrNoSuchPod) { removedCtrs[c.ID()] = nil - return + return removedCtrs, removedPods, retErr } retErr = err - return + return removedCtrs, removedPods, retErr } infraID := pod.state.InfraContainerID if c.ID() == infraID && !opts.RemoveDeps { retErr = fmt.Errorf("container %s is the infra container of pod %s and cannot be removed without removing the pod", c.ID(), pod.ID()) - return + return removedCtrs, removedPods, retErr } } } @@ -789,13 +788,13 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO if !r.valid { retErr = define.ErrRuntimeStopped - return + return removedCtrs, removedPods, retErr } // Update the container to get current state if err := c.syncContainer(); err != nil { retErr = err - return + return removedCtrs, removedPods, retErr } serviceForPod := false @@ -807,11 +806,11 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO continue } retErr = err - return + return removedCtrs, removedPods, retErr } if !opts.RemoveDeps { retErr = fmt.Errorf("container %s is the service container of pod(s) %s and cannot be removed without removing the pod(s)", c.ID(), strings.Join(c.state.Service.Pods, ",")) - return + return removedCtrs, removedPods, retErr } // If we are the service container for the pod we are a // member of: we need to remove that pod last, since @@ -826,7 +825,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO if err != nil && !errors.Is(err, define.ErrNoSuchPod) && !errors.Is(err, define.ErrPodRemoved) { removedPods[depPod.ID()] = err retErr = fmt.Errorf("error removing container %s dependency pods: %w", c.ID(), err) - return + return removedCtrs, removedPods, retErr } removedPods[depPod.ID()] = nil } @@ -846,10 +845,10 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO if err != nil && !errors.Is(err, define.ErrNoSuchPod) && !errors.Is(err, define.ErrPodRemoved) { removedPods[pod.ID()] = err retErr = fmt.Errorf("error removing container %s pod: %w", c.ID(), err) - return + return removedCtrs, removedPods, retErr } removedPods[pod.ID()] = nil - return + return removedCtrs, removedPods, retErr } // If we're not force-removing, we need to check if we're in a good @@ -857,7 +856,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO if !opts.Force { if err := c.checkReadyForRemoval(); err != nil { retErr = err - return + return removedCtrs, removedPods, retErr } } @@ -865,23 +864,23 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO isV2, err := cgroups.IsCgroup2UnifiedMode() if err != nil { retErr = err - return + return removedCtrs, removedPods, retErr } // cgroups v1 and v2 handle signals on paused processes differently if !isV2 { if err := c.unpause(); err != nil { retErr = err - return + return removedCtrs, removedPods, retErr } } if err := c.ociRuntime.KillContainer(c, 9, false); err != nil { retErr = err - return + return removedCtrs, removedPods, retErr } // Need to update container state to make sure we know it's stopped if err := c.waitForExitFileAndSync(); err != nil { retErr = err - return + return removedCtrs, removedPods, retErr } } @@ -892,20 +891,20 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO deps, err := r.state.ContainerInUse(c) if err != nil { retErr = err - return + return removedCtrs, removedPods, retErr } if !opts.RemoveDeps { if len(deps) != 0 { depsStr := strings.Join(deps, ", ") retErr = fmt.Errorf("container %s has dependent containers which must be removed before it: %s: %w", c.ID(), depsStr, define.ErrCtrExists) - return + return removedCtrs, removedPods, retErr } } for _, depCtr := range deps { dep, err := r.GetContainer(depCtr) if err != nil { retErr = err - return + return removedCtrs, removedPods, retErr } logrus.Infof("Removing container %s (dependency of container %s)", dep.ID(), c.ID()) recursiveOpts := ctrRmOpts{ @@ -926,7 +925,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO maps.Copy(removedPods, pods) if err != nil && !errors.Is(err, define.ErrNoSuchCtr) && !errors.Is(err, define.ErrCtrRemoved) { retErr = err - return + return removedCtrs, removedPods, retErr } } } @@ -941,7 +940,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO // exit code properly, but it's still stopped. if err := c.stop(time); err != nil && !errors.Is(err, define.ErrConmonDead) { retErr = fmt.Errorf("cannot remove container %s as it could not be stopped: %w", c.ID(), err) - return + return removedCtrs, removedPods, retErr } // We unlocked as part of stop() above - there's a chance someone @@ -953,11 +952,11 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO // When the container has already been removed, the OCI runtime directory remains. if err := c.cleanupRuntime(ctx); err != nil { retErr = fmt.Errorf("cleaning up container %s from OCI runtime: %w", c.ID(), err) - return + return removedCtrs, removedPods, retErr } // Do not add to removed containers, someone else // removed it. - return + return removedCtrs, removedPods, retErr } } @@ -1025,7 +1024,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO c.newContainerEvent(events.Remove) if !opts.RemoveVolume { - return + return removedCtrs, removedPods, retErr } for _, v := range c.config.NamedVolumes { @@ -1048,7 +1047,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO } //nolint:nakedret - return + return removedCtrs, removedPods, retErr } // EvictContainer removes the given container partial or full ID or name, and diff --git a/libpod/shutdown/handler.go b/libpod/shutdown/handler.go index ac41899e0e8..9196b10c2fd 100644 --- a/libpod/shutdown/handler.go +++ b/libpod/shutdown/handler.go @@ -11,9 +11,7 @@ import ( logrusImport "github.com/sirupsen/logrus" ) -var ( - ErrHandlerExists = errors.New("handler with given name already exists") -) +var ErrHandlerExists = errors.New("handler with given name already exists") var ( stopped bool diff --git a/libpod/sqlite_state.go b/libpod/sqlite_state.go index f688b7c9b96..39296562fd9 100644 --- a/libpod/sqlite_state.go +++ b/libpod/sqlite_state.go @@ -140,9 +140,7 @@ func (s *SQLiteState) Refresh() (defErr error) { defer ctrRows.Close() for ctrRows.Next() { - var ( - id, stateJSON string - ) + var id, stateJSON string if err := ctrRows.Scan(&id, &stateJSON); err != nil { return fmt.Errorf("scanning container state row: %w", err) } @@ -174,9 +172,7 @@ func (s *SQLiteState) Refresh() (defErr error) { defer podRows.Close() for podRows.Next() { - var ( - id, stateJSON string - ) + var id, stateJSON string if err := podRows.Scan(&id, &stateJSON); err != nil { return fmt.Errorf("scanning pod state row: %w", err) } @@ -208,9 +204,7 @@ func (s *SQLiteState) Refresh() (defErr error) { defer volRows.Close() for volRows.Next() { - var ( - name, stateJSON string - ) + var name, stateJSON string if err := volRows.Scan(&name, &stateJSON); err != nil { return fmt.Errorf("scanning volume state row: %w", err) diff --git a/libpod/state_test.go b/libpod/state_test.go index 7eb6e092ef5..85f48de7d6d 100644 --- a/libpod/state_test.go +++ b/libpod/state_test.go @@ -26,11 +26,9 @@ const ( tmpDirPrefix = "libpod_state_test_" ) -var ( - testedStates = map[string]emptyStateFunc{ - "sqlite": getEmptySqliteState, - } -) +var testedStates = map[string]emptyStateFunc{ + "sqlite": getEmptySqliteState, +} func getEmptySqliteState() (_ State, _ string, _ lock.Manager, retErr error) { tmpDir, err := os.MkdirTemp("", tmpDirPrefix) @@ -2452,6 +2450,7 @@ func TestGetContainerConfigEmptyIDFails(t *testing.T) { assert.Error(t, err) }) } + func TestGetContainerConfigNonExistentIDFails(t *testing.T) { runForAllStates(t, func(t *testing.T, state State, _ lock.Manager) { _, err := state.GetContainerConfig("does not exist") diff --git a/libpod/stats_linux.go b/libpod/stats_linux.go index d9d3d9cb174..84f853bf89a 100644 --- a/libpod/stats_linux.go +++ b/libpod/stats_linux.go @@ -120,7 +120,7 @@ func calculateBlockIO(stats *runccgroup.Stats) (read uint64, write uint64) { write += blkIOEntry.Value } } - return + return read, write } func getOnlineCPUs(container *Container) (int, error) { diff --git a/libpod/util.go b/libpod/util.go index 229e31425b8..3408e0a3268 100644 --- a/libpod/util.go +++ b/libpod/util.go @@ -209,7 +209,7 @@ func makeInspectPortBindings(bindings []types.PortMapping) map[string][]define.I for i := uint16(0); i < port.Range; i++ { key := fmt.Sprintf("%d/%s", port.ContainerPort+i, protocol) hostPorts := portBindings[key] - var hostIP = port.HostIP + hostIP := port.HostIP if len(port.HostIP) == 0 { hostIP = "0.0.0.0" } diff --git a/libpod/util_linux.go b/libpod/util_linux.go index 4e9c9935453..a6f4d1e7bf8 100644 --- a/libpod/util_linux.go +++ b/libpod/util_linux.go @@ -127,9 +127,11 @@ func assembleSystemdCgroupName(baseSlice, newSlice string) (string, string, erro return systemdPath, systemdPath, nil } -var lvpRelabel = label.Relabel -var lvpInitLabels = label.InitLabels -var lvpReleaseLabel = selinux.ReleaseLabel +var ( + lvpRelabel = label.Relabel + lvpInitLabels = label.InitLabels + lvpReleaseLabel = selinux.ReleaseLabel +) // LabelVolumePath takes a mount path for a volume and gives it an // selinux label of either shared or not diff --git a/pkg/annotations/validate.go b/pkg/annotations/validate.go index b4f8bdf89fb..d7b191d8abc 100644 --- a/pkg/annotations/validate.go +++ b/pkg/annotations/validate.go @@ -25,9 +25,11 @@ func regexErrorMsg(msg string, fmt string, examples ...string) string { return msg } -const dns1123LabelFmt string = "[a-z0-9]([-a-z0-9]*[a-z0-9])?" -const dns1123SubdomainFmt string = dns1123LabelFmt + "(\\." + dns1123LabelFmt + ")*" -const dns1123SubdomainErrorMsg string = "annotations must be formatted as a valid lowercase RFC1123 subdomain of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character" +const ( + dns1123LabelFmt string = "[a-z0-9]([-a-z0-9]*[a-z0-9])?" + dns1123SubdomainFmt string = dns1123LabelFmt + "(\\." + dns1123LabelFmt + ")*" + dns1123SubdomainErrorMsg string = "annotations must be formatted as a valid lowercase RFC1123 subdomain of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character" +) // DNS1123SubdomainMaxLength is a subdomain's max length in DNS (RFC 1123) const DNS1123SubdomainMaxLength int = 253 @@ -48,11 +50,13 @@ func isDNS1123Subdomain(value string) error { return nil } -const qnameCharFmt string = "[A-Za-z0-9]" -const qnameExtCharFmt string = "[-A-Za-z0-9_.]" -const qualifiedNameFmt string = "(" + qnameCharFmt + qnameExtCharFmt + "*)?" + qnameCharFmt -const qualifiedNameErrMsg string = "must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character" -const qualifiedNameMaxLength int = 63 +const ( + qnameCharFmt string = "[A-Za-z0-9]" + qnameExtCharFmt string = "[-A-Za-z0-9_.]" + qualifiedNameFmt string = "(" + qnameCharFmt + qnameExtCharFmt + "*)?" + qnameCharFmt + qualifiedNameErrMsg string = "must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character" + qualifiedNameMaxLength int = 63 +) var qualifiedNameRegexp = regexp.MustCompile("^" + qualifiedNameFmt + "$") diff --git a/pkg/api/grpcpb/noop.pb.go b/pkg/api/grpcpb/noop.pb.go index fb7c9678167..0a9f7bb85aa 100644 --- a/pkg/api/grpcpb/noop.pb.go +++ b/pkg/api/grpcpb/noop.pb.go @@ -7,11 +7,12 @@ package grpcpb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -134,11 +135,13 @@ func file_noop_proto_rawDescGZIP() []byte { return file_noop_proto_rawDescData } -var file_noop_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_noop_proto_goTypes = []any{ - (*NoopRequest)(nil), // 0: io.podman.v1.NoopRequest - (*NoopResponse)(nil), // 1: io.podman.v1.NoopResponse -} +var ( + file_noop_proto_msgTypes = make([]protoimpl.MessageInfo, 2) + file_noop_proto_goTypes = []any{ + (*NoopRequest)(nil), // 0: io.podman.v1.NoopRequest + (*NoopResponse)(nil), // 1: io.podman.v1.NoopResponse + } +) var file_noop_proto_depIdxs = []int32{ 0, // 0: io.podman.v1.Noop.Noop:input_type -> io.podman.v1.NoopRequest 1, // 1: io.podman.v1.Noop.Noop:output_type -> io.podman.v1.NoopResponse diff --git a/pkg/api/grpcpb/noop_grpc.pb.go b/pkg/api/grpcpb/noop_grpc.pb.go index 2782a920b44..715aa1d6102 100644 --- a/pkg/api/grpcpb/noop_grpc.pb.go +++ b/pkg/api/grpcpb/noop_grpc.pb.go @@ -8,6 +8,7 @@ package grpcpb import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/pkg/api/handlers/compat/containers_archive.go b/pkg/api/handlers/compat/containers_archive.go index 050ba459f69..35f84e3f681 100644 --- a/pkg/api/handlers/compat/containers_archive.go +++ b/pkg/api/handlers/compat/containers_archive.go @@ -4,13 +4,12 @@ package compat import ( "encoding/json" + "errors" "fmt" "net/http" "os" "strings" - "errors" - "github.com/containers/podman/v6/libpod" "github.com/containers/podman/v6/libpod/define" "github.com/containers/podman/v6/pkg/api/handlers/utils" diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index c70fc9934a7..af37f0a4720 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -281,7 +281,7 @@ func processBuildContext(query url.Values, r *http.Request, buildContext *BuildC } } else { if dockerFile := query.Get("dockerfile"); dockerFile != "" { - var m = []string{} + m := []string{} if err := json.Unmarshal([]byte(dockerFile), &m); err != nil { // it's not json, assume just a string m = []string{dockerFile} @@ -322,8 +322,8 @@ func processBuildContext(query url.Values, r *http.Request, buildContext *BuildC // processSecrets processes build secrets for podman-remote operations. // Moves secrets outside build context to prevent accidental inclusion in images. func processSecrets(query *BuildQuery, contextDirectory string, queryValues url.Values) ([]string, error) { - var secrets = []string{} - var m = []string{} + secrets := []string{} + m := []string{} if err := utils.ParseOptionalJSONField(query.Secrets, "secrets", queryValues, &m); err != nil { return nil, err } @@ -492,25 +492,25 @@ func createBuildOptions(query *BuildQuery, buildCtx *BuildContext, queryValues u } // Process build args - var buildArgs = map[string]string{} + buildArgs := map[string]string{} if err := utils.ParseOptionalJSONField(query.BuildArgs, "buildargs", queryValues, &buildArgs); err != nil { return nil, nil, utils.GetBadRequestError("buildargs", query.BuildArgs, err) } // Process excludes - var excludes = []string{} + excludes := []string{} if err := utils.ParseOptionalJSONField(query.Excludes, "excludes", queryValues, &excludes); err != nil { return nil, nil, utils.GetBadRequestError("excludes", query.Excludes, err) } // Process annotations - var annotations = []string{} + annotations := []string{} if err := utils.ParseOptionalJSONField(query.Annotations, "annotations", queryValues, &annotations); err != nil { return nil, nil, utils.GetBadRequestError("annotations", query.Annotations, err) } // Process CPP flags - var cppflags = []string{} + cppflags := []string{} if err := utils.ParseOptionalJSONField(query.CPPFlags, "cppflags", queryValues, &cppflags); err != nil { return nil, nil, utils.GetBadRequestError("cppflags", query.CPPFlags, err) } @@ -529,7 +529,7 @@ func createBuildOptions(query *BuildQuery, buildCtx *BuildContext, queryValues u } // Process labels - var labels = []string{} + labels := []string{} if _, found := queryValues["labels"]; found { makeLabels := make(map[string]string) err := json.Unmarshal([]byte(query.Labels), &makeLabels) @@ -565,7 +565,7 @@ func createBuildOptions(query *BuildQuery, buildCtx *BuildContext, queryValues u } } else { // handle security-opt - var securityOpts = []string{} + securityOpts := []string{} if err := utils.ParseOptionalJSONField(query.SecurityOpt, "securityopt", queryValues, &securityOpts); err != nil { return nil, nil, utils.GetBadRequestError("securityopt", query.SecurityOpt, err) } @@ -592,7 +592,7 @@ func createBuildOptions(query *BuildQuery, buildCtx *BuildContext, queryValues u } // Process ulimits - var ulimits = []string{} + ulimits := []string{} if err := utils.ParseOptionalJSONField(query.Ulimits, "ulimits", queryValues, &ulimits); err != nil { return nil, nil, utils.GetBadRequestError("ulimits", query.Ulimits, err) } @@ -674,7 +674,7 @@ func createBuildOptions(query *BuildQuery, buildCtx *BuildContext, queryValues u } if _, found := r.URL.Query()["sbom-scanner-command"]; found { - var m = []string{} + m := []string{} if err := json.Unmarshal([]byte(query.SBOMCommands), &m); err != nil { return nil, cleanup, utils.GetBadRequestError("sbom-scanner-command", query.SBOMCommands, err) } diff --git a/pkg/api/handlers/compat/info.go b/pkg/api/handlers/compat/info.go index f6cac300e7d..505a9dd34ef 100644 --- a/pkg/api/handlers/compat/info.go +++ b/pkg/api/handlers/compat/info.go @@ -208,7 +208,7 @@ func getFdCount() (count int) { if entries, err := os.ReadDir("/proc/self/fd"); err == nil { count = len(entries) } - return + return count } // Just ignoring Container errors here... diff --git a/pkg/api/handlers/libpod/networks.go b/pkg/api/handlers/libpod/networks.go index a16dfba5c08..7011230e6dd 100644 --- a/pkg/api/handlers/libpod/networks.go +++ b/pkg/api/handlers/libpod/networks.go @@ -4,11 +4,10 @@ package libpod import ( "encoding/json" + "errors" "fmt" "net/http" - "errors" - "github.com/containers/podman/v6/libpod" "github.com/containers/podman/v6/libpod/define" "github.com/containers/podman/v6/pkg/api/handlers/utils" diff --git a/pkg/api/handlers/utils/errors.go b/pkg/api/handlers/utils/errors.go index c46372808ff..52d5fcf71c5 100644 --- a/pkg/api/handlers/utils/errors.go +++ b/pkg/api/handlers/utils/errors.go @@ -13,9 +13,7 @@ import ( "go.podman.io/storage" ) -var ( - ErrLinkNotSupport = errors.New("link is not supported") -) +var ErrLinkNotSupport = errors.New("link is not supported") // TODO: document the exported functions in this file and make them more // generic (e.g., not tied to one ctr/pod). diff --git a/pkg/api/server/handler_api.go b/pkg/api/server/handler_api.go index 763948325f6..e4019deec42 100644 --- a/pkg/api/server/handler_api.go +++ b/pkg/api/server/handler_api.go @@ -99,6 +99,7 @@ func (w *BufferedResponseWriter) Flush() { wrapped.Flush() } } + func newBufferedResponseWriter(rw http.ResponseWriter) *BufferedResponseWriter { return &BufferedResponseWriter{ bufio.NewWriterSize(rw, 8192), diff --git a/pkg/autoupdate/autoupdate.go b/pkg/autoupdate/autoupdate.go index 258f05fbcb6..a95b22d44b6 100644 --- a/pkg/autoupdate/autoupdate.go +++ b/pkg/autoupdate/autoupdate.go @@ -184,7 +184,6 @@ func (u *updater) updateUnit(ctx context.Context, unit string, tasks []*task) [] tasksUpdated = true return nil }() - if err != nil { errors = append(errors, err) } diff --git a/pkg/bindings/containers/attach.go b/pkg/bindings/containers/attach.go index 4b3c7d7fbe2..8b1ee36c86f 100644 --- a/pkg/bindings/containers/attach.go +++ b/pkg/bindings/containers/attach.go @@ -237,17 +237,17 @@ func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Wri func DemuxHeader(r io.Reader, buffer []byte) (fd, sz int, err error) { _, err = io.ReadFull(r, buffer[0:8]) if err != nil { - return + return fd, sz, err } fd = int(buffer[0]) if fd < 0 || fd > 3 { err = fmt.Errorf(`channel "%d" found, 0-3 supported: %w`, fd, ErrLostSync) - return + return fd, sz, err } sz = int(binary.BigEndian.Uint32(buffer[4:8])) - return + return fd, sz, err } // DemuxFrame reads contents for frame from server multiplexed stdin/stdout/stderr/2nd error channel diff --git a/pkg/bindings/containers/containers.go b/pkg/bindings/containers/containers.go index 2868e986e34..577eface59e 100644 --- a/pkg/bindings/containers/containers.go +++ b/pkg/bindings/containers/containers.go @@ -16,9 +16,7 @@ import ( "github.com/containers/podman/v6/pkg/domain/entities/types" ) -var ( - ErrLostSync = errors.New("lost synchronization with multiplexed stream") -) +var ErrLostSync = errors.New("lost synchronization with multiplexed stream") // List obtains a list of containers in local storage. All parameters to this method are optional. // The filters are used to determine which containers are listed. The last parameter indicates to only return diff --git a/pkg/bindings/containers/healthcheck.go b/pkg/bindings/containers/healthcheck.go index 1bf4b950819..793bee605f9 100644 --- a/pkg/bindings/containers/healthcheck.go +++ b/pkg/bindings/containers/healthcheck.go @@ -19,9 +19,7 @@ func RunHealthCheck(ctx context.Context, nameOrID string, options *HealthCheckOp if err != nil { return nil, err } - var ( - status define.HealthCheckResults - ) + var status define.HealthCheckResults response, err := conn.DoRequest(ctx, nil, http.MethodGet, "/containers/%s/healthcheck", nil, nil, nameOrID) if err != nil { return nil, err diff --git a/pkg/bindings/containers/mount.go b/pkg/bindings/containers/mount.go index d17330498f3..ca517804166 100644 --- a/pkg/bindings/containers/mount.go +++ b/pkg/bindings/containers/mount.go @@ -18,9 +18,7 @@ func Mount(ctx context.Context, nameOrID string, options *MountOptions) (string, if err != nil { return "", err } - var ( - path string - ) + var path string response, err := conn.DoRequest(ctx, nil, http.MethodPost, "/containers/%s/mount", nil, nil, nameOrID) if err != nil { return path, err diff --git a/pkg/bindings/containers/types.go b/pkg/bindings/containers/types.go index a4336e366a8..ceb7bacce5f 100644 --- a/pkg/bindings/containers/types.go +++ b/pkg/bindings/containers/types.go @@ -115,8 +115,7 @@ type ExecInspectOptions struct{} // exec sessions // //go:generate go run ../generator/generator.go ExecStartOptions -type ExecStartOptions struct { -} +type ExecStartOptions struct{} // HealthCheckOptions are optional options for checking // the health of a container diff --git a/pkg/bindings/containers/types_wait_options.go b/pkg/bindings/containers/types_wait_options.go index 1643a4fd59b..2097012fc94 100644 --- a/pkg/bindings/containers/types_wait_options.go +++ b/pkg/bindings/containers/types_wait_options.go @@ -4,8 +4,9 @@ package containers import ( "net/url" - "github.com/containers/podman/v6/libpod/define" "github.com/containers/podman/v6/pkg/bindings/internal/util" + + "github.com/containers/podman/v6/libpod/define" ) // Changed returns true if named field has been set diff --git a/pkg/bindings/errors.go b/pkg/bindings/errors.go index 83e7d41c098..2dc55392faa 100644 --- a/pkg/bindings/errors.go +++ b/pkg/bindings/errors.go @@ -10,9 +10,7 @@ import ( "github.com/containers/podman/v6/pkg/errorhandling" ) -var ( - ErrNotImplemented = errors.New("function not implemented") -) +var ErrNotImplemented = errors.New("function not implemented") func handleError(data []byte, unmarshalErrorInto any) error { if err := json.Unmarshal(data, unmarshalErrorInto); err != nil { diff --git a/pkg/bindings/generator/generator.go b/pkg/bindings/generator/generator.go index 52230a7767a..6c962d1a743 100644 --- a/pkg/bindings/generator/generator.go +++ b/pkg/bindings/generator/generator.go @@ -120,7 +120,7 @@ func main() { composite = true } - //sub := "*" + // sub := "*" typeExpr := field.Type start := typeExpr.Pos() - 1 end := typeExpr.End() - 1 diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go index 35a057779d3..59ba6322617 100644 --- a/pkg/bindings/images/images.go +++ b/pkg/bindings/images/images.go @@ -191,9 +191,7 @@ func Export(ctx context.Context, nameOrIDs []string, w io.Writer, options *Expor // Prune removes unused images from local storage. The optional filters can be used to further // define which images should be pruned. func Prune(ctx context.Context, options *PruneOptions) ([]*reports.PruneReport, error) { - var ( - deleted []*reports.PruneReport - ) + var deleted []*reports.PruneReport if options == nil { options = new(PruneOptions) } diff --git a/pkg/bindings/images/types.go b/pkg/bindings/images/types.go index 6308fbe5e8a..32bcb378922 100644 --- a/pkg/bindings/images/types.go +++ b/pkg/bindings/images/types.go @@ -62,8 +62,7 @@ type TreeOptions struct { // HistoryOptions are optional options image history // //go:generate go run ../generator/generator.go HistoryOptions -type HistoryOptions struct { -} +type HistoryOptions struct{} // LoadOptions are optional options for loading an image // @@ -102,14 +101,12 @@ type PruneOptions struct { // TagOptions are optional options for tagging images // //go:generate go run ../generator/generator.go TagOptions -type TagOptions struct { -} +type TagOptions struct{} // UntagOptions are optional options for untagging images // //go:generate go run ../generator/generator.go UntagOptions -type UntagOptions struct { -} +type UntagOptions struct{} // ImportOptions are optional options for importing images // @@ -241,8 +238,7 @@ type BuildOptions = types.BuildOptions // ExistsOptions are optional options for checking if an image exists // //go:generate go run ../generator/generator.go ExistsOptions -type ExistsOptions struct { -} +type ExistsOptions struct{} type ScpOptions struct { Quiet *bool diff --git a/pkg/bindings/manifests/types.go b/pkg/bindings/manifests/types.go index 82a842aab7e..ce04d4249a7 100644 --- a/pkg/bindings/manifests/types.go +++ b/pkg/bindings/manifests/types.go @@ -26,8 +26,7 @@ type CreateOptions struct { // if a manifest list exists // //go:generate go run ../generator/generator.go ExistsOptions -type ExistsOptions struct { -} +type ExistsOptions struct{} // AddOptions are optional options for adding manifest lists // @@ -75,8 +74,7 @@ type AddArtifactOptions struct { // RemoveOptions are optional options for removing manifest lists // //go:generate go run ../generator/generator.go RemoveOptions -type RemoveOptions struct { -} +type RemoveOptions struct{} // ModifyOptions are optional options for modifying manifest lists // diff --git a/pkg/bindings/network/network.go b/pkg/bindings/network/network.go index b8c40c60fa7..5bc684980b6 100644 --- a/pkg/bindings/network/network.go +++ b/pkg/bindings/network/network.go @@ -220,9 +220,7 @@ func Prune(ctx context.Context, options *PruneOptions) ([]*entitiesTypes.Network if err != nil { return nil, err } - var ( - prunedNetworks []*entitiesTypes.NetworkPruneReport - ) + var prunedNetworks []*entitiesTypes.NetworkPruneReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, err diff --git a/pkg/bindings/network/types.go b/pkg/bindings/network/types.go index d99f784177b..80121141dcc 100644 --- a/pkg/bindings/network/types.go +++ b/pkg/bindings/network/types.go @@ -37,8 +37,7 @@ type CreateOptions struct { // InspectOptions are optional options for inspecting networks // //go:generate go run ../generator/generator.go InspectOptions -type InspectOptions struct { -} +type InspectOptions struct{} // RemoveOptions are optional options for inspecting networks // @@ -80,8 +79,7 @@ type DisconnectOptions struct { // if a network exists // //go:generate go run ../generator/generator.go ExistsOptions -type ExistsOptions struct { -} +type ExistsOptions struct{} // PruneOptions are optional options for removing unused // networks diff --git a/pkg/bindings/pods/types.go b/pkg/bindings/pods/types.go index 904815db76e..fc5e491084c 100644 --- a/pkg/bindings/pods/types.go +++ b/pkg/bindings/pods/types.go @@ -3,14 +3,12 @@ package pods // CreateOptions are optional options for creating pods // //go:generate go run ../generator/generator.go CreateOptions -type CreateOptions struct { -} +type CreateOptions struct{} // InspectOptions are optional options for inspecting pods // //go:generate go run ../generator/generator.go InspectOptions -type InspectOptions struct { -} +type InspectOptions struct{} // KillOptions are optional options for killing pods // @@ -22,14 +20,12 @@ type KillOptions struct { // PauseOptions are optional options for pausing pods // //go:generate go run ../generator/generator.go PauseOptions -type PauseOptions struct { -} +type PauseOptions struct{} // PruneOptions are optional options for pruning pods // //go:generate go run ../generator/generator.go PruneOptions -type PruneOptions struct { -} +type PruneOptions struct{} // ListOptions are optional options for listing pods // @@ -41,14 +37,12 @@ type ListOptions struct { // RestartOptions are optional options for restarting pods // //go:generate go run ../generator/generator.go RestartOptions -type RestartOptions struct { -} +type RestartOptions struct{} // StartOptions are optional options for starting pods // //go:generate go run ../generator/generator.go StartOptions -type StartOptions struct { -} +type StartOptions struct{} // StopOptions are optional options for stopping pods // @@ -67,8 +61,7 @@ type TopOptions struct { // UnpauseOptions are optional options for unpausinging pods // //go:generate go run ../generator/generator.go UnpauseOptions -type UnpauseOptions struct { -} +type UnpauseOptions struct{} // StatsOptions are optional options for getting stats of pods // @@ -88,5 +81,4 @@ type RemoveOptions struct { // ExistsOptions are optional options for checking if a pod exists // //go:generate go run ../generator/generator.go ExistsOptions -type ExistsOptions struct { -} +type ExistsOptions struct{} diff --git a/pkg/bindings/secrets/secrets.go b/pkg/bindings/secrets/secrets.go index 622cc93bb77..b489d0bd376 100644 --- a/pkg/bindings/secrets/secrets.go +++ b/pkg/bindings/secrets/secrets.go @@ -11,9 +11,7 @@ import ( // List returns information about existing secrets in the form of a slice. func List(ctx context.Context, options *ListOptions) ([]*entitiesTypes.SecretInfoReport, error) { - var ( - secrs []*entitiesTypes.SecretInfoReport - ) + var secrs []*entitiesTypes.SecretInfoReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, err @@ -36,9 +34,7 @@ func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) (*en if options == nil { options = new(InspectOptions) } - var ( - inspect *entitiesTypes.SecretInfoReport - ) + var inspect *entitiesTypes.SecretInfoReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, err @@ -73,9 +69,7 @@ func Remove(ctx context.Context, nameOrID string) error { // Create creates a secret given some data func Create(ctx context.Context, reader io.Reader, options *CreateOptions) (*entitiesTypes.SecretCreateReport, error) { - var ( - create *entitiesTypes.SecretCreateReport - ) + var create *entitiesTypes.SecretCreateReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, err diff --git a/pkg/bindings/secrets/types.go b/pkg/bindings/secrets/types.go index cefdf6af7a7..de025c52e76 100644 --- a/pkg/bindings/secrets/types.go +++ b/pkg/bindings/secrets/types.go @@ -17,8 +17,7 @@ type InspectOptions struct { // RemoveOptions are optional options for removing secrets // //go:generate go run ../generator/generator.go RemoveOptions -type RemoveOptions struct { -} +type RemoveOptions struct{} // CreateOptions are optional options for Creating secrets // diff --git a/pkg/bindings/system/system.go b/pkg/bindings/system/system.go index c4defe1472e..0e0d6fb96a4 100644 --- a/pkg/bindings/system/system.go +++ b/pkg/bindings/system/system.go @@ -49,7 +49,7 @@ func Events(ctx context.Context, eventChan chan types.Event, cancelChan chan boo defer close(eventChan) dec := json.NewDecoder(response.Body) for err = (error)(nil); err == nil; { - var e = types.Event{} + e := types.Event{} err = dec.Decode(&e) if err == nil { eventChan <- e @@ -61,9 +61,7 @@ func Events(ctx context.Context, eventChan chan types.Event, cancelChan chan boo // Prune removes all unused system data. func Prune(ctx context.Context, options *PruneOptions) (*types.SystemPruneReport, error) { - var ( - report types.SystemPruneReport - ) + var report types.SystemPruneReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, err diff --git a/pkg/bindings/system/types.go b/pkg/bindings/system/types.go index a66114976a0..cd1d69664a2 100644 --- a/pkg/bindings/system/types.go +++ b/pkg/bindings/system/types.go @@ -24,21 +24,18 @@ type PruneOptions struct { // VersionOptions are optional options for getting version info // //go:generate go run ../generator/generator.go VersionOptions -type VersionOptions struct { -} +type VersionOptions struct{} // DiskOptions are optional options for getting storage consumption // //go:generate go run ../generator/generator.go DiskOptions -type DiskOptions struct { -} +type DiskOptions struct{} // InfoOptions are optional options for getting info // about libpod // //go:generate go run ../generator/generator.go InfoOptions -type InfoOptions struct { -} +type InfoOptions struct{} // CheckOptions are optional options for storage consistency check/repair // diff --git a/pkg/bindings/test/api_response_test.go b/pkg/bindings/test/api_response_test.go index ac2502f4fe2..15de7e58394 100644 --- a/pkg/bindings/test/api_response_test.go +++ b/pkg/bindings/test/api_response_test.go @@ -15,7 +15,6 @@ import ( ) var _ = Describe("APIResponse Process method", func() { - createMockResponse := func(jsonResponse []byte, statusCode int) *bindings.APIResponse { response := &http.Response{ StatusCode: statusCode, diff --git a/pkg/bindings/test/auth_test.go b/pkg/bindings/test/auth_test.go index a568504f91f..526f699992c 100644 --- a/pkg/bindings/test/auth_test.go +++ b/pkg/bindings/test/auth_test.go @@ -49,7 +49,6 @@ var _ = Describe("Podman images", func() { // Test using credentials. It("tag + push + pull + search (with credentials)", func() { - imageRep := "localhost:" + registry.Port + "/test" imageTag := "latest" imageRef := imageRep + ":" + imageTag @@ -78,7 +77,6 @@ var _ = Describe("Podman images", func() { // Test using authfile. It("tag + push + pull + search (with authfile)", func() { - imageRep := "localhost:" + registry.Port + "/test" imageTag := "latest" imageRef := imageRep + ":" + imageTag @@ -130,5 +128,4 @@ var _ = Describe("Podman images", func() { _, err = images.Search(bt.conn, imageRef, searchOptions.WithSkipTLSVerify(true).WithAuthfile(authFilePath)) Expect(err).ToNot(HaveOccurred()) }) - }) diff --git a/pkg/bindings/test/common_test.go b/pkg/bindings/test/common_test.go index 1916ee04466..0bf60309d8c 100644 --- a/pkg/bindings/test/common_test.go +++ b/pkg/bindings/test/common_test.go @@ -193,6 +193,7 @@ func (b *bindingTest) RestoreImagesFromCache() { b.restoreImageFromCache(i) } } + func (b *bindingTest) restoreImageFromCache(i testImage) { p := b.runPodman([]string{"load", "-i", filepath.Join(ImageCacheDir, i.tarballName)}) p.Wait(45) diff --git a/pkg/bindings/test/connection_test.go b/pkg/bindings/test/connection_test.go index 751d768d2eb..67a53df4a00 100644 --- a/pkg/bindings/test/connection_test.go +++ b/pkg/bindings/test/connection_test.go @@ -39,7 +39,7 @@ var _ = Describe("Podman connection", func() { }) It("cancel request in flight reports cancelled context", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) diff --git a/pkg/bindings/test/containers_test.go b/pkg/bindings/test/containers_test.go index 4d07deb4a5d..2feb58f9637 100644 --- a/pkg/bindings/test/containers_test.go +++ b/pkg/bindings/test/containers_test.go @@ -55,7 +55,7 @@ var _ = Describe("Podman containers ", func() { It("podman pause a running container by name", func() { // Pausing by name should work - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Pause(bt.conn, name, nil) @@ -69,7 +69,7 @@ var _ = Describe("Podman containers ", func() { It("podman pause a running container by id", func() { // Pausing by id should work - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Pause(bt.conn, cid, nil) @@ -83,7 +83,7 @@ var _ = Describe("Podman containers ", func() { It("podman unpause a running container by name", func() { // Unpausing by name should work - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Pause(bt.conn, name, nil) @@ -99,7 +99,7 @@ var _ = Describe("Podman containers ", func() { It("podman unpause a running container by ID", func() { // Unpausing by ID should work - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) // Pause by name @@ -119,7 +119,7 @@ var _ = Describe("Podman containers ", func() { It("podman pause a paused container by name", func() { // Pausing a paused container by name should fail - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Pause(bt.conn, name, nil) @@ -132,7 +132,7 @@ var _ = Describe("Podman containers ", func() { It("podman pause a paused container by id", func() { // Pausing a paused container by id should fail - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Pause(bt.conn, cid, nil) @@ -145,7 +145,7 @@ var _ = Describe("Podman containers ", func() { It("podman pause a stopped container by name", func() { // Pausing a stopped container by name should fail - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, name, nil) @@ -158,7 +158,7 @@ var _ = Describe("Podman containers ", func() { It("podman pause a stopped container by id", func() { // Pausing a stopped container by id should fail - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, cid, nil) @@ -171,7 +171,7 @@ var _ = Describe("Podman containers ", func() { It("podman remove a paused container by id without force", func() { // Removing a paused container without force should fail - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Pause(bt.conn, cid, nil) @@ -184,7 +184,7 @@ var _ = Describe("Podman containers ", func() { It("podman remove a paused container by id with force", func() { // Removing a paused container with force should work - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Pause(bt.conn, cid, nil) @@ -197,7 +197,7 @@ var _ = Describe("Podman containers ", func() { It("podman stop a paused container by name", func() { // Stopping a paused container by name should fail - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Pause(bt.conn, name, nil) @@ -210,7 +210,7 @@ var _ = Describe("Podman containers ", func() { It("podman stop a paused container by id", func() { // Stopping a paused container by id should fail - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Pause(bt.conn, cid, nil) @@ -223,7 +223,7 @@ var _ = Describe("Podman containers ", func() { It("podman stop a running container by name", func() { // Stopping a running container by name should work - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, name, nil) @@ -237,7 +237,7 @@ var _ = Describe("Podman containers ", func() { It("podman stop a running container by ID", func() { // Stopping a running container by ID should work - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, cid, nil) @@ -322,7 +322,7 @@ var _ = Describe("Podman containers ", func() { Expect(code).To(BeNumerically("==", http.StatusNotFound)) // a container that has no healthcheck should be a 409 - var name = "top" + name := "top" _, err = bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) _, err = containers.RunHealthCheck(bt.conn, name, nil) @@ -378,7 +378,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman top", func() { - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) @@ -416,7 +416,7 @@ var _ = Describe("Podman containers ", func() { It("podman container exists in local storage by name", func() { // Container existence check by name should work - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) containerExists, err := containers.Exists(bt.conn, name, nil) @@ -426,7 +426,7 @@ var _ = Describe("Podman containers ", func() { It("podman container exists in local storage by ID", func() { // Container existence check by ID should work - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) containerExists, err := containers.Exists(bt.conn, cid, nil) @@ -436,7 +436,7 @@ var _ = Describe("Podman containers ", func() { It("podman container exists in local storage by short ID", func() { // Container existence check by short ID should work - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) containerExists, err := containers.Exists(bt.conn, cid[0:12], nil) @@ -454,7 +454,7 @@ var _ = Describe("Podman containers ", func() { It("podman kill a running container by name with SIGINT", func() { // Killing a running container should work - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Kill(bt.conn, name, new(containers.KillOptions).WithSignal("SIGINT")) @@ -465,7 +465,7 @@ var _ = Describe("Podman containers ", func() { It("podman kill a running container by ID with SIGTERM", func() { // Killing a running container by ID should work - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Kill(bt.conn, cid, new(containers.KillOptions).WithSignal("SIGTERM")) @@ -476,7 +476,7 @@ var _ = Describe("Podman containers ", func() { It("podman kill a running container by ID with SIGKILL", func() { // Killing a running container by ID with TERM should work - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Kill(bt.conn, cid, new(containers.KillOptions).WithSignal("SIGKILL")) @@ -485,7 +485,7 @@ var _ = Describe("Podman containers ", func() { It("podman kill a running container by bogus signal", func() { // Killing a running container by bogus signal should fail - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Kill(bt.conn, cid, new(containers.KillOptions).WithSignal("foobar")) @@ -496,8 +496,8 @@ var _ = Describe("Podman containers ", func() { It("podman kill latest container with SIGTERM", func() { // Killing latest container should work - var name1 = "first" - var name2 = "second" + name1 := "first" + name2 := "second" _, err := bt.RunTopContainer(&name1, nil) Expect(err).ToNot(HaveOccurred()) _, err = bt.RunTopContainer(&name2, nil) @@ -528,7 +528,7 @@ var _ = Describe("Podman containers ", func() { It("podman prune stopped containers", func() { // Start and stop a container to enter in exited state. - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, name, nil) @@ -543,7 +543,7 @@ var _ = Describe("Podman containers ", func() { It("podman prune stopped containers with filters", func() { // Start and stop a container to enter in exited state. - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, name, nil) @@ -583,7 +583,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman list containers with until filter", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) @@ -604,7 +604,7 @@ var _ = Describe("Podman containers ", func() { It("podman prune running containers", func() { // Start the container. - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) @@ -627,7 +627,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman inspect running container", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) // Inspecting running container should succeed @@ -636,7 +636,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman inspect stopped container", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, name, nil) @@ -647,7 +647,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman inspect running container with size", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) _, err = containers.Inspect(bt.conn, name, new(containers.InspectOptions).WithSize(true)) @@ -655,7 +655,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman inspect stopped container with size", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, name, nil) @@ -673,7 +673,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman remove running container by name", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) // Removing running container should fail @@ -684,7 +684,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman remove running container by ID", func() { - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) // Removing running container should fail @@ -695,7 +695,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman forcibly remove running container by name", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) // Removing running container should succeed @@ -706,7 +706,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman forcibly remove running container by ID", func() { - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) // Forcibly Removing running container should succeed @@ -717,7 +717,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman remove running container and volume by name", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) // Removing running container should fail @@ -728,7 +728,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman remove running container and volume by ID", func() { - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) // Removing running container should fail @@ -739,7 +739,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman forcibly remove running container and volume by name", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) // Forcibly Removing running container should succeed @@ -750,7 +750,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman forcibly remove running container and volume by ID", func() { - var name = "top" + name := "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) // Removing running container should fail @@ -761,8 +761,8 @@ var _ = Describe("Podman containers ", func() { }) It("List containers with filters", func() { - var name = "top" - var name2 = "top2" + name := "top" + name2 := "top2" cid, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) _, err = bt.RunTopContainer(&name2, nil) @@ -797,7 +797,7 @@ var _ = Describe("Podman containers ", func() { }) It("Update container allows for partial updates", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) diff --git a/pkg/bindings/test/create_test.go b/pkg/bindings/test/create_test.go index 3e0a0440b37..ad536669b13 100644 --- a/pkg/bindings/test/create_test.go +++ b/pkg/bindings/test/create_test.go @@ -47,5 +47,4 @@ var _ = Describe("Create containers ", func() { Expect(err).ToNot(HaveOccurred()) Expect(data.State.Status).To(Equal("running")) }) - }) diff --git a/pkg/bindings/test/images_test.go b/pkg/bindings/test/images_test.go index 0432c38fcf6..d87820002a0 100644 --- a/pkg/bindings/test/images_test.go +++ b/pkg/bindings/test/images_test.go @@ -112,7 +112,7 @@ var _ = Describe("Podman images", func() { Expect(code).To(BeNumerically("==", http.StatusNotFound)) // Start a container with alpine image - var top = "top" + top := "top" _, err = bt.RunTopContainer(&top, nil) Expect(err).ToNot(HaveOccurred()) // we should now have a container called "top" running @@ -148,7 +148,6 @@ var _ = Describe("Podman images", func() { // Tests to validate the image tag command. It("tag image", func() { - // Validates if invalid image name is given a bad response is encountered. err = images.Tag(bt.conn, "dummy", "demo", alpine.shortName, nil) Expect(err).To(HaveOccurred()) @@ -162,7 +161,6 @@ var _ = Describe("Podman images", func() { // Validates if name updates when the image is retagged. _, err := images.GetImage(bt.conn, "alpine:demo", nil) Expect(err).ToNot(HaveOccurred()) - }) // Test to validate the List images command. @@ -296,7 +294,6 @@ var _ = Describe("Podman images", func() { data, err := images.GetImage(bt.conn, alpine.name, nil) Expect(err).ToNot(HaveOccurred()) Expect(data.Comment).To(Equal(testMessage)) - }) It("History Image", func() { diff --git a/pkg/bindings/test/manifests_test.go b/pkg/bindings/test/manifests_test.go index 4a263e1761b..4b3bd54afe6 100644 --- a/pkg/bindings/test/manifests_test.go +++ b/pkg/bindings/test/manifests_test.go @@ -28,7 +28,6 @@ var _ = Describe("Podman manifests", func() { time.Sleep(1 * time.Second) err := bt.NewConnection() Expect(err).ToNot(HaveOccurred()) - }) AfterEach(func() { diff --git a/pkg/bindings/test/networks_test.go b/pkg/bindings/test/networks_test.go index d09df45d1bd..c309e09f0b4 100644 --- a/pkg/bindings/test/networks_test.go +++ b/pkg/bindings/test/networks_test.go @@ -25,7 +25,6 @@ var _ = Describe("Podman networks", func() { ) BeforeEach(func() { - bt = newBindingTest() bt.RestoreImagesFromCache() s = bt.startAPIService() diff --git a/pkg/bindings/test/pods_test.go b/pkg/bindings/test/pods_test.go index 114ec7e9c47..32e3b604ed0 100644 --- a/pkg/bindings/test/pods_test.go +++ b/pkg/bindings/test/pods_test.go @@ -77,7 +77,7 @@ var _ = Describe("Podman pods", func() { Expect(podSummary[0].Containers).To(HaveLen(2)) // Add multiple pods and verify them by name and size. - var newpod2 = "newpod2" + newpod2 := "newpod2" bt.Podcreate(&newpod2) podSummary, err = pods.List(bt.conn, nil) Expect(err).ToNot(HaveOccurred(), "Error from pods.List") @@ -219,7 +219,7 @@ var _ = Describe("Podman pods", func() { Expect(err).ToNot(HaveOccurred()) portPublish := fmt.Sprintf("%d:%d", randomport, randomport) - var podwithport = "newpodwithport" + podwithport := "newpodwithport" bt.PodcreateAndExpose(&podwithport, &portPublish) // Start pod and expose port 12345 @@ -227,7 +227,7 @@ var _ = Describe("Podman pods", func() { Expect(err).ToNot(HaveOccurred()) // Start another pod and expose same port 12345 - var podwithport2 = "newpodwithport2" + podwithport2 := "newpodwithport2" bt.PodcreateAndExpose(&podwithport2, &portPublish) _, err = pods.Start(bt.conn, podwithport2, nil) @@ -299,7 +299,7 @@ var _ = Describe("Podman pods", func() { // Test to validate all the pods in the stopped/exited state are pruned successfully. It("prune pod", func() { // Add a new pod - var newpod2 = "newpod2" + newpod2 := "newpod2" bt.Podcreate(&newpod2) // No pods pruned since no pod in exited state pruneResponse, err := pods.Prune(bt.conn, nil) @@ -377,7 +377,7 @@ var _ = Describe("Podman pods", func() { // Test validates the pod top bindings It("pod top", func() { - var name = "podA" + name := "podA" bt.Podcreate(&name) _, err := pods.Start(bt.conn, name, nil) diff --git a/pkg/bindings/test/secrets_test.go b/pkg/bindings/test/secrets_test.go index 134566dc43a..8811d0f141f 100644 --- a/pkg/bindings/test/secrets_test.go +++ b/pkg/bindings/test/secrets_test.go @@ -31,7 +31,6 @@ var _ = Describe("Podman secrets", func() { }) AfterEach(func() { - s.Kill() bt.cleanup() }) @@ -129,5 +128,4 @@ var _ = Describe("Podman secrets", func() { code, _ := bindings.CheckResponseCode(err) Expect(code).To(BeNumerically("==", http.StatusNotFound)) }) - }) diff --git a/pkg/bindings/test/system_test.go b/pkg/bindings/test/system_test.go index 47691b7817e..2a950c4957a 100644 --- a/pkg/bindings/test/system_test.go +++ b/pkg/bindings/test/system_test.go @@ -39,7 +39,7 @@ var _ = Describe("Podman system", func() { }) It("podman events", func() { - var name = "top" + name := "top" _, err := bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) @@ -70,7 +70,7 @@ var _ = Describe("Podman system", func() { _, err = pods.Stop(bt.conn, newpod, nil) Expect(err).ToNot(HaveOccurred()) // Start and stop a container to enter in exited state. - var name = "top" + name := "top" _, err = bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, name, nil) @@ -94,14 +94,14 @@ var _ = Describe("Podman system", func() { Expect(err).ToNot(HaveOccurred()) // Start and stop a container to enter in exited state. - var name = "top" + name := "top" _, err = bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, name, nil) Expect(err).ToNot(HaveOccurred()) // Start container and leave in running - var name2 = "top2" + name2 := "top2" _, err = bt.RunTopContainer(&name2, nil) Expect(err).ToNot(HaveOccurred()) @@ -128,14 +128,14 @@ var _ = Describe("Podman system", func() { Expect(err).ToNot(HaveOccurred()) // Start and stop a container to enter in exited state. - var name = "top" + name := "top" _, err = bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, name, nil) Expect(err).ToNot(HaveOccurred()) // Start second container and leave in running - var name2 = "top2" + name2 := "top2" _, err = bt.RunTopContainer(&name2, nil) Expect(err).ToNot(HaveOccurred()) @@ -163,14 +163,14 @@ var _ = Describe("Podman system", func() { Expect(err).ToNot(HaveOccurred()) // Start and stop a container to enter in exited state. - var name = "top" + name := "top" _, err = bt.RunTopContainer(&name, nil) Expect(err).ToNot(HaveOccurred()) err = containers.Stop(bt.conn, name, nil) Expect(err).ToNot(HaveOccurred()) // Start second container and leave in running - var name2 = "top2" + name2 := "top2" _, err = bt.RunTopContainer(&name2, nil) Expect(err).ToNot(HaveOccurred()) diff --git a/pkg/bindings/test/volumes_test.go b/pkg/bindings/test/volumes_test.go index ba519b9bfab..0b8ffe6005c 100644 --- a/pkg/bindings/test/volumes_test.go +++ b/pkg/bindings/test/volumes_test.go @@ -200,5 +200,4 @@ var _ = Describe("Podman volumes", func() { Expect(err).ToNot(HaveOccurred()) Expect(vols).To(HaveLen(2)) }) - }) diff --git a/pkg/bindings/volumes/types.go b/pkg/bindings/volumes/types.go index 791fc12405f..0be3238641f 100644 --- a/pkg/bindings/volumes/types.go +++ b/pkg/bindings/volumes/types.go @@ -3,14 +3,12 @@ package volumes // CreateOptions are optional options for creating volumes // //go:generate go run ../generator/generator.go CreateOptions -type CreateOptions struct { -} +type CreateOptions struct{} // InspectOptions are optional options for inspecting volumes // //go:generate go run ../generator/generator.go InspectOptions -type InspectOptions struct { -} +type InspectOptions struct{} // ListOptions are optional options for listing volumes // @@ -41,5 +39,4 @@ type RemoveOptions struct { // if a volume exists // //go:generate go run ../generator/generator.go ExistsOptions -type ExistsOptions struct { -} +type ExistsOptions struct{} diff --git a/pkg/bindings/volumes/volumes.go b/pkg/bindings/volumes/volumes.go index 01c9c3b2438..37f4ee44e49 100644 --- a/pkg/bindings/volumes/volumes.go +++ b/pkg/bindings/volumes/volumes.go @@ -15,9 +15,7 @@ import ( // Create creates a volume given its configuration. func Create(ctx context.Context, config entitiesTypes.VolumeCreateOptions, options *CreateOptions) (*entitiesTypes.VolumeConfigResponse, error) { - var ( - v entitiesTypes.VolumeConfigResponse - ) + var v entitiesTypes.VolumeConfigResponse if options == nil { options = new(CreateOptions) } @@ -42,9 +40,7 @@ func Create(ctx context.Context, config entitiesTypes.VolumeCreateOptions, optio // Inspect returns low-level information about a volume. func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) (*entitiesTypes.VolumeConfigResponse, error) { - var ( - inspect entitiesTypes.VolumeConfigResponse - ) + var inspect entitiesTypes.VolumeConfigResponse if options == nil { options = new(InspectOptions) } @@ -65,9 +61,7 @@ func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) (*en // List returns the configurations for existing volumes in the form of a slice. Optionally, filters // can be used to refine the list of volumes. func List(ctx context.Context, options *ListOptions) ([]*entitiesTypes.VolumeListReport, error) { - var ( - vols []*entitiesTypes.VolumeListReport - ) + var vols []*entitiesTypes.VolumeListReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, err @@ -87,9 +81,7 @@ func List(ctx context.Context, options *ListOptions) ([]*entitiesTypes.VolumeLis // Prune removes unused volumes from the local filesystem. func Prune(ctx context.Context, options *PruneOptions) ([]*reports.PruneReport, error) { - var ( - pruned []*reports.PruneReport - ) + var pruned []*reports.PruneReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, err diff --git a/pkg/copy/parse.go b/pkg/copy/parse.go index f42ef90ef7f..97829d2190c 100644 --- a/pkg/copy/parse.go +++ b/pkg/copy/parse.go @@ -31,14 +31,14 @@ func ParseSourceAndDestination(source, destination string) (string, string, stri // they start with a dot or slash. func parseUserInput(input string) (container string, path string) { if len(input) == 0 { - return + return container, path } path = input // If the input starts with a dot or slash, it cannot refer to a // container. if input[0] == '.' || input[0] == '/' { - return + return container, path } // If the input is an absolute path, it cannot refer to a container. @@ -46,12 +46,12 @@ func parseUserInput(input string) (container string, path string) { // a colon, which would cause the drive letter to be parsed as a // container name. if filepath.IsAbs(input) { - return + return container, path } if parsedContainer, parsedPath, ok := strings.Cut(path, ":"); ok { container = parsedContainer path = parsedPath } - return + return container, path } diff --git a/pkg/domain/entities/manifest.go b/pkg/domain/entities/manifest.go index 1027174403c..c58fc99e050 100644 --- a/pkg/domain/entities/manifest.go +++ b/pkg/domain/entities/manifest.go @@ -122,8 +122,7 @@ type ManifestPushReport = entitiesTypes.ManifestPushReport // ManifestRemoveOptions provides the model for removing digests from a manifest // // swagger:model -type ManifestRemoveOptions struct { -} +type ManifestRemoveOptions struct{} // ManifestRemoveReport provides the model for the removed manifest type ManifestRemoveReport = entitiesTypes.ManifestRemoveReport diff --git a/pkg/domain/entities/network.go b/pkg/domain/entities/network.go index 4a32a21205e..e013bad7a18 100644 --- a/pkg/domain/entities/network.go +++ b/pkg/domain/entities/network.go @@ -82,5 +82,7 @@ type NetworkPruneOptions struct { Filters map[string][]string } -type NetworkInspectReport = entitiesTypes.NetworkInspectReport -type NetworkContainerInfo = entitiesTypes.NetworkContainerInfo +type ( + NetworkInspectReport = entitiesTypes.NetworkInspectReport + NetworkContainerInfo = entitiesTypes.NetworkContainerInfo +) diff --git a/pkg/domain/entities/play.go b/pkg/domain/entities/play.go index 1e434378ca0..0131bf42839 100644 --- a/pkg/domain/entities/play.go +++ b/pkg/domain/entities/play.go @@ -92,8 +92,10 @@ type PlayKubePod = entitiesTypes.PlayKubePod type PlayKubeVolume entitiesTypes.PlayKubeVolume // PlayKubeReport contains the results of running play kube. -type PlayKubeReport = entitiesTypes.PlayKubeReport -type KubePlayReport = entitiesTypes.KubePlayReport +type ( + PlayKubeReport = entitiesTypes.PlayKubeReport + KubePlayReport = entitiesTypes.KubePlayReport +) // PlayKubeDownOptions are options for tearing down pods type PlayKubeDownOptions struct { diff --git a/pkg/domain/entities/pods.go b/pkg/domain/entities/pods.go index 09d98e9c195..46b65764e2e 100644 --- a/pkg/domain/entities/pods.go +++ b/pkg/domain/entities/pods.go @@ -52,11 +52,13 @@ type PodRestartOptions struct { Latest bool } -type PodRestartReport = types.PodRestartReport -type PodStartOptions struct { - All bool - Latest bool -} +type ( + PodRestartReport = types.PodRestartReport + PodStartOptions struct { + All bool + Latest bool + } +) type PodStartReport = types.PodStartReport diff --git a/pkg/domain/entities/system.go b/pkg/domain/entities/system.go index 3212dfdbe4c..1b3703a7d18 100644 --- a/pkg/domain/entities/system.go +++ b/pkg/domain/entities/system.go @@ -5,22 +5,26 @@ import ( ) // ServiceOptions provides the input for starting an API and sidecar pprof services -type ServiceOptions = types.ServiceOptions -type SystemPruneOptions = types.SystemPruneOptions -type SystemPruneReport = types.SystemPruneReport -type SystemMigrateOptions = types.SystemMigrateOptions -type SystemCheckOptions = types.SystemCheckOptions -type SystemCheckReport = types.SystemCheckReport -type SystemDfOptions = types.SystemDfOptions -type SystemDfReport = types.SystemDfReport -type SystemDfImageReport = types.SystemDfImageReport -type SystemDfContainerReport = types.SystemDfContainerReport -type SystemDfVolumeReport = types.SystemDfVolumeReport -type SystemVersionReport = types.SystemVersionReport -type SystemUnshareOptions = types.SystemUnshareOptions -type ComponentVersion = types.SystemComponentVersion -type ListRegistriesReport = types.ListRegistriesReport +type ( + ServiceOptions = types.ServiceOptions + SystemPruneOptions = types.SystemPruneOptions + SystemPruneReport = types.SystemPruneReport + SystemMigrateOptions = types.SystemMigrateOptions + SystemCheckOptions = types.SystemCheckOptions + SystemCheckReport = types.SystemCheckReport + SystemDfOptions = types.SystemDfOptions + SystemDfReport = types.SystemDfReport + SystemDfImageReport = types.SystemDfImageReport + SystemDfContainerReport = types.SystemDfContainerReport + SystemDfVolumeReport = types.SystemDfVolumeReport + SystemVersionReport = types.SystemVersionReport + SystemUnshareOptions = types.SystemUnshareOptions + ComponentVersion = types.SystemComponentVersion + ListRegistriesReport = types.ListRegistriesReport +) -type AuthConfig = types.AuthConfig -type AuthReport = types.AuthReport -type LocksReport = types.LocksReport +type ( + AuthConfig = types.AuthConfig + AuthReport = types.AuthReport + LocksReport = types.LocksReport +) diff --git a/pkg/domain/entities/types/types.go b/pkg/domain/entities/types/types.go index e9bbb14d617..b06a88b74a2 100644 --- a/pkg/domain/entities/types/types.go +++ b/pkg/domain/entities/types/types.go @@ -80,7 +80,6 @@ type BuildReport struct { // swagger:model type IDResponse struct { - // The id of the newly created object. // Required: true ID string `json:"Id"` diff --git a/pkg/domain/filters/pods.go b/pkg/domain/filters/pods.go index 06691e1d9c3..eb2739950c6 100644 --- a/pkg/domain/filters/pods.go +++ b/pkg/domain/filters/pods.go @@ -19,7 +19,8 @@ import ( // and generates a libpod function that can be used to filter // pods func GeneratePodFilterFunc(filter string, filterValues []string, r *libpod.Runtime) ( - func(pod *libpod.Pod) bool, error) { + func(pod *libpod.Pod) bool, error, +) { switch filter { case "ctr-ids": return func(p *libpod.Pod) bool { diff --git a/pkg/domain/infra/abi/artifact.go b/pkg/domain/infra/abi/artifact.go index 9b5c4d3a518..d5666d34fb7 100644 --- a/pkg/domain/infra/abi/artifact.go +++ b/pkg/domain/infra/abi/artifact.go @@ -93,9 +93,7 @@ func (ir *ImageEngine) ArtifactPull(ctx context.Context, name string, opts entit } func (ir *ImageEngine) ArtifactRm(ctx context.Context, opts entities.ArtifactRemoveOptions) (*entities.ArtifactRemoveReport, error) { - var ( - namesOrDigests []string - ) + var namesOrDigests []string artStore, err := ir.Libpod.ArtifactStore() if err != nil { return nil, err diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index 90c40ccfc68..63d2ad7efb1 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -217,8 +217,8 @@ func (ic *ContainerEngine) ContainerWait(ctx context.Context, namesOrIds []strin } func waitExitOnFirst(ctx context.Context, containers []containerWrapper, options entities.WaitOptions) entities.WaitReport { - var waitChannel = make(chan entities.WaitReport, 1) - var waitFunction = func(ctx context.Context, container containerWrapper, options entities.WaitOptions, waitChannel chan<- entities.WaitReport) { + waitChannel := make(chan entities.WaitReport, 1) + waitFunction := func(ctx context.Context, container containerWrapper, options entities.WaitOptions, waitChannel chan<- entities.WaitReport) { response := entities.WaitReport{} var conditions []string if len(options.Conditions) == 0 { @@ -294,6 +294,7 @@ func (ic *ContainerEngine) ContainerUnpause(_ context.Context, namesOrIds []stri } return reports, nil } + func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []string, options entities.StopOptions) ([]*entities.StopReport, error) { containers, err := getContainers(ic.Libpod, getContainersOptions{ @@ -627,9 +628,7 @@ func (ic *ContainerEngine) ContainerTop(_ context.Context, options entities.TopO } func (ic *ContainerEngine) ContainerCommit(ctx context.Context, nameOrID string, options entities.CommitOptions) (*entities.CommitReport, error) { - var ( - mimeType string - ) + var mimeType string ctr, err := ic.Libpod.LookupContainer(nameOrID) if err != nil { return nil, err @@ -993,7 +992,7 @@ func (ic *ContainerEngine) ContainerExecDetached(_ context.Context, nameOrID str func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) { reports := []*entities.ContainerStartReport{} - var exitCode = define.ExecErrorCodeGeneric + exitCode := define.ExecErrorCodeGeneric containers, err := getContainers(ic.Libpod, getContainersOptions{all: options.All, latest: options.Latest, names: namesOrIds, filters: options.Filters}) if err != nil { return nil, err diff --git a/pkg/domain/infra/abi/containers_runlabel.go b/pkg/domain/infra/abi/containers_runlabel.go index 72c8cf2e292..94904a3e3e3 100644 --- a/pkg/domain/infra/abi/containers_runlabel.go +++ b/pkg/domain/infra/abi/containers_runlabel.go @@ -267,9 +267,7 @@ func generateRunEnvironment(options entities.ContainerRunlabelOptions) []string } func substituteCommand(cmd string) (string, error) { - var ( - newCommand string - ) + var newCommand string // Replace cmd with "/proc/self/exe" if "podman" or "docker" is being // used. If "/usr/bin/docker" is provided, we also sub in podman. diff --git a/pkg/domain/infra/abi/farm.go b/pkg/domain/infra/abi/farm.go index 6096decd580..a32c2279464 100644 --- a/pkg/domain/infra/abi/farm.go +++ b/pkg/domain/infra/abi/farm.go @@ -48,9 +48,11 @@ func (ir *ImageEngine) FarmNodeInspect(ctx context.Context) (*entities.FarmInspe ir.platforms.Do(func() { ir.os, ir.arch, ir.variant, ir.nativePlatforms, ir.emulatedPlatforms, ir.platformsErr = ir.fetchInfo(ctx) }) - return &entities.FarmInspectReport{NativePlatforms: ir.nativePlatforms, + return &entities.FarmInspectReport{ + NativePlatforms: ir.nativePlatforms, EmulatedPlatforms: ir.emulatedPlatforms, OS: ir.os, Arch: ir.arch, - Variant: ir.variant}, ir.platformsErr + Variant: ir.variant, + }, ir.platformsErr } diff --git a/pkg/domain/infra/abi/quadlet.go b/pkg/domain/infra/abi/quadlet.go index 9011d79f21e..8bd41144569 100644 --- a/pkg/domain/infra/abi/quadlet.go +++ b/pkg/domain/infra/abi/quadlet.go @@ -119,7 +119,7 @@ func (ic *ContainerEngine) QuadletInstall(ctx context.Context, pathsOrURLs []str return nil, fmt.Errorf("cannot stat Quadlet generator, Quadlet may not be installed: %w", err) } - if !quadletStat.Mode().IsRegular() || quadletStat.Mode()&0100 == 0 { + if !quadletStat.Mode().IsRegular() || quadletStat.Mode()&0o100 == 0 { return nil, fmt.Errorf("no valid Quadlet binary installed to %q, unable to use Quadlet", quadletPath) } @@ -274,13 +274,13 @@ func (ic *ContainerEngine) installQuadlet(_ context.Context, path, destName, ins return "", fmt.Errorf("%q is not a supported Quadlet file type", filepath.Ext(finalPath)) } - var osFlags = os.O_CREATE | os.O_WRONLY + osFlags := os.O_CREATE | os.O_WRONLY if !replace { osFlags |= os.O_EXCL } - file, err := os.OpenFile(finalPath, osFlags, 0644) + file, err := os.OpenFile(finalPath, osFlags, 0o644) if err != nil { if errors.Is(err, fs.ErrExist) && !replace { return "", fmt.Errorf("a Quadlet with name %s already exists, refusing to overwrite", filepath.Base(finalPath)) diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go index 955e0151278..6655341672e 100644 --- a/pkg/domain/infra/abi/system.go +++ b/pkg/domain/infra/abi/system.go @@ -66,7 +66,7 @@ func (ic *ContainerEngine) Info(_ context.Context) (*define.Info, error) { // SystemPrune removes unused data from the system. Pruning pods, containers, build container, networks, volumes and images. func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.SystemPruneOptions) (*entities.SystemPruneReport, error) { - var systemPruneReport = new(entities.SystemPruneReport) + systemPruneReport := new(entities.SystemPruneReport) if options.External { if options.All || options.Volume || len(options.Filters) > 0 || options.Build { @@ -179,9 +179,7 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys } func (ic *ContainerEngine) SystemDf(ctx context.Context, _ entities.SystemDfOptions) (*entities.SystemDfReport, error) { - var ( - dfImages = []*entities.SystemDfImageReport{} - ) + dfImages := []*entities.SystemDfImageReport{} imageStats, totalImageSize, err := ic.Libpod.LibimageRuntime().DiskUsage(ctx) if err != nil { diff --git a/pkg/domain/infra/abi/terminal/terminal.go b/pkg/domain/infra/abi/terminal/terminal.go index a39a2a71ad9..f2876a4d984 100644 --- a/pkg/domain/infra/abi/terminal/terminal.go +++ b/pkg/domain/infra/abi/terminal/terminal.go @@ -15,8 +15,7 @@ import ( ) // RawTtyFormatter ... -type RawTtyFormatter struct { -} +type RawTtyFormatter struct{} // getResize returns a TerminalSize command matching stdin's current // size on success, and nil on errors. diff --git a/pkg/domain/infra/abi/volumes.go b/pkg/domain/infra/abi/volumes.go index 07342c98a53..ea9a8fdfcb8 100644 --- a/pkg/domain/infra/abi/volumes.go +++ b/pkg/domain/infra/abi/volumes.go @@ -17,9 +17,7 @@ import ( ) func (ic *ContainerEngine) VolumeCreate(ctx context.Context, opts entities.VolumeCreateOptions) (*entities.IDOrNameResponse, error) { - var ( - volumeOptions []libpod.VolumeCreateOption - ) + var volumeOptions []libpod.VolumeCreateOption if len(opts.Name) > 0 { volumeOptions = append(volumeOptions, libpod.WithVolumeName(opts.Name)) } diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go index 1eb275457e6..83c6d4d1e3a 100644 --- a/pkg/domain/infra/tunnel/containers.go +++ b/pkg/domain/infra/tunnel/containers.go @@ -42,8 +42,8 @@ func (ic *ContainerEngine) ContainerWait(ctx context.Context, namesOrIds []strin options := new(containers.WaitOptions).WithConditions(opts.Conditions).WithInterval(opts.Interval.String()) if opts.ExitFirstMatch { - var waitChannel = make(chan entities.WaitReport, 1) - var waitFunction = func(ctx context.Context, nameOrId string, options *containers.WaitOptions, waitChannel chan<- entities.WaitReport) { + waitChannel := make(chan entities.WaitReport, 1) + waitFunction := func(ctx context.Context, nameOrId string, options *containers.WaitOptions, waitChannel chan<- entities.WaitReport) { response := entities.WaitReport{} exitCode, err := containers.Wait(ic.ClientCtx, nameOrId, options) if err != nil { @@ -210,9 +210,7 @@ func (ic *ContainerEngine) ContainerKill(_ context.Context, namesOrIds []string, } func (ic *ContainerEngine) ContainerRestart(_ context.Context, namesOrIds []string, opts entities.RestartOptions) ([]*entities.RestartReport, error) { - var ( - reports = []*entities.RestartReport{} - ) + reports := []*entities.RestartReport{} options := new(containers.RestartOptions) if to := opts.Timeout; to != nil { timeout := util.ConvertTimeout(int(*to)) @@ -777,7 +775,7 @@ func logIfRmError(id string, err error, reports []*reports.RmReport) { func (ic *ContainerEngine) ContainerStart(_ context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) { reports := []*entities.ContainerStartReport{} - var exitCode = define.ExecErrorCodeGeneric + exitCode := define.ExecErrorCodeGeneric ctrs, rawInputs, err := getContainersAndInputByContext(ic.ClientCtx, options.All, len(options.Filters) > 0, namesOrIds, options.Filters) if err != nil { return nil, err diff --git a/pkg/domain/infra/tunnel/farm.go b/pkg/domain/infra/tunnel/farm.go index b4e9105c463..694a26b8c11 100644 --- a/pkg/domain/infra/tunnel/farm.go +++ b/pkg/domain/infra/tunnel/farm.go @@ -39,8 +39,10 @@ func (ir *ImageEngine) FarmNodeInspect(ctx context.Context) (*entities.FarmInspe ir.platforms.Do(func() { ir.os, ir.arch, ir.variant, ir.nativePlatforms, ir.platformsErr = ir.fetchInfo(ctx) }) - return &entities.FarmInspectReport{NativePlatforms: ir.nativePlatforms, - OS: ir.os, - Arch: ir.arch, - Variant: ir.variant}, ir.platformsErr + return &entities.FarmInspectReport{ + NativePlatforms: ir.nativePlatforms, + OS: ir.os, + Arch: ir.arch, + Variant: ir.variant, + }, ir.platformsErr } diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go index 2d841232c6a..c8430345b89 100644 --- a/pkg/domain/infra/tunnel/images.go +++ b/pkg/domain/infra/tunnel/images.go @@ -145,9 +145,7 @@ func (ir *ImageEngine) Pull(_ context.Context, rawImage string, opts entities.Im func (ir *ImageEngine) Tag(_ context.Context, nameOrID string, tags []string, _ entities.ImageTagOptions) error { options := new(images.TagOptions) for _, newTag := range tags { - var ( - tag, repo string - ) + var tag, repo string ref, err := reference.Parse(newTag) if err != nil { return fmt.Errorf("parsing reference %q: %w", newTag, err) @@ -175,9 +173,7 @@ func (ir *ImageEngine) Untag(_ context.Context, nameOrID string, tags []string, } for _, newTag := range tags { - var ( - tag, repo string - ) + var tag, repo string ref, err := reference.Parse(newTag) if err != nil { return fmt.Errorf("parsing reference %q: %w", newTag, err) diff --git a/pkg/domain/utils/utils.go b/pkg/domain/utils/utils.go index df0bd798fef..68070ebffcf 100644 --- a/pkg/domain/utils/utils.go +++ b/pkg/domain/utils/utils.go @@ -29,7 +29,7 @@ func ToLibpodFilters(f url.Values) (filters []string) { for k, v := range f { filters = append(filters, k+"="+v[0]) } - return + return filters } func ToURLValues(f []string) (filters url.Values) { @@ -38,7 +38,7 @@ func ToURLValues(f []string) (filters url.Values) { key, val, _ := strings.Cut(v, "=") filters.Add(key, val) } - return + return filters } // ParseAnnotations takes a string slice of options, expected to be "key=val" and returns diff --git a/pkg/k8s.io/api/core/v1/types.go b/pkg/k8s.io/api/core/v1/types.go index ea8d3d99ddb..9197de4b174 100644 --- a/pkg/k8s.io/api/core/v1/types.go +++ b/pkg/k8s.io/api/core/v1/types.go @@ -566,7 +566,7 @@ type SecretVolumeSource struct { } const ( - SecretVolumeSourceDefaultMode int32 = 0644 + SecretVolumeSourceDefaultMode int32 = 0o644 ) // Adapts a secret into a projected volume. @@ -623,7 +623,7 @@ type ConfigMapVolumeSource struct { } const ( - ConfigMapVolumeSourceDefaultMode int32 = 0644 + ConfigMapVolumeSourceDefaultMode int32 = 0o644 ) // Adapts a ConfigMap into a projected volume. @@ -707,7 +707,7 @@ type VolumeProjection struct { } const ( - ProjectedVolumeSourceDefaultMode int32 = 0644 + ProjectedVolumeSourceDefaultMode int32 = 0o644 ) // Maps a string key to a path within a volume. @@ -4321,7 +4321,7 @@ type DownwardAPIVolumeSource struct { } const ( - DownwardAPIVolumeSourceDefaultMode int32 = 0644 + DownwardAPIVolumeSourceDefaultMode int32 = 0o644 ) // DownwardAPIVolumeFile represents information to create the file containing the pod field @@ -5456,7 +5456,6 @@ type SuccessPolicyRule struct { // JobSpec describes how the job execution will look like. type JobSpec struct { - // Specifies the maximum desired number of pods the job should // run at any given time. The actual number of pods running in steady state will // be less than this number when ((.spec.completions - .status.successful) < .spec.parallelism), diff --git a/pkg/k8s.io/apimachinery/pkg/api/resource/math.go b/pkg/k8s.io/apimachinery/pkg/api/resource/math.go index 5df189a1750..68e94b93049 100644 --- a/pkg/k8s.io/apimachinery/pkg/api/resource/math.go +++ b/pkg/k8s.io/apimachinery/pkg/api/resource/math.go @@ -43,8 +43,10 @@ var ( maxAllowed = infDecAmount{inf.NewDec((1<<63)-1, 0)} // == max int64 ) -const mostNegative = -(mostPositive + 1) -const mostPositive = 1<<63 - 1 +const ( + mostNegative = -(mostPositive + 1) + mostPositive = 1<<63 - 1 +) // int64Add returns a+b, or false if that would overflow int64. func int64Add(a, b int64) (int64, bool) { diff --git a/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go b/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go index 6e7f0c47618..b8fc531ad8d 100644 --- a/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go +++ b/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go @@ -175,7 +175,7 @@ Zeroes: if i >= end { num = "0" value = num - return + return positive, value, num, denom, suffix, err } switch str[i] { case '0': @@ -191,7 +191,7 @@ Num: if i >= end { num = str[pos:end] value = str[0:end] - return + return positive, value, num, denom, suffix, err } switch str[i] { case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': @@ -215,7 +215,7 @@ Num: if i >= end { denom = str[pos:end] value = str[0:end] - return + return positive, value, num, denom, suffix, err } switch str[i] { case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': @@ -238,7 +238,7 @@ Num: for i := pos; ; i++ { if i >= end { suffix = str[suffixStart:end] - return + return positive, value, num, denom, suffix, err } if !strings.ContainsAny(str[i:i+1], "eEinumkKMGTP") { pos = i @@ -255,7 +255,7 @@ Suffix: for i := pos; ; i++ { if i >= end { suffix = str[suffixStart:end] - return + return positive, value, num, denom, suffix, err } switch str[i] { case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': @@ -267,7 +267,7 @@ Suffix: // was not a valid exponent err = ErrFormatWrong //nolint:nakedret - return + return positive, value, num, denom, suffix, err } // ParseQuantity turns str into a Quantity, or returns an error. diff --git a/pkg/k8s.io/apimachinery/pkg/api/resource/suffix.go b/pkg/k8s.io/apimachinery/pkg/api/resource/suffix.go index 88fc9fd9b59..70980d2a450 100644 --- a/pkg/k8s.io/apimachinery/pkg/api/resource/suffix.go +++ b/pkg/k8s.io/apimachinery/pkg/api/resource/suffix.go @@ -68,12 +68,12 @@ func (ls *listSuffixer) lookup(s suffix) (base, exponent int32, ok bool) { func (ls *listSuffixer) construct(base, exponent int32) (s suffix, ok bool) { s, ok = ls.beToSuffix[bePair{base, exponent}] - return + return s, ok } func (ls *listSuffixer) constructBytes(base, exponent int32) (s []byte, ok bool) { s, ok = ls.beToSuffixBytes[bePair{base, exponent}] - return + return s, ok } type suffixHandler struct { diff --git a/pkg/machine/apple/apple.go b/pkg/machine/apple/apple.go index 53d22e472e8..24a9c9b701b 100644 --- a/pkg/machine/apple/apple.go +++ b/pkg/machine/apple/apple.go @@ -141,9 +141,7 @@ func GenerateSystemDFilesForVirtiofsMounts(mounts []machine.VirtIoFs) ([]ignitio // StartGenericAppleVM is wrapped by apple provider methods and starts the vm func StartGenericAppleVM(mc *vmconfigs.MachineConfig, cmdBinary string, bootloader vfConfig.Bootloader, endpoint string) (func() error, func() error, error) { - var ( - ignitionSocket *define.VMFile - ) + var ignitionSocket *define.VMFile // Add networking netDevice, err := vfConfig.VirtioNetNew(applehvMACAddress) diff --git a/pkg/machine/applehv/stubber.go b/pkg/machine/applehv/stubber.go index 19b24b5c2b6..ef50d9f7613 100644 --- a/pkg/machine/applehv/stubber.go +++ b/pkg/machine/applehv/stubber.go @@ -22,9 +22,7 @@ import ( // applehcMACAddress is a pre-defined mac address that vfkit recognizes // and is required for network flow -var ( - vfkitCommand = "vfkit" -) +var vfkitCommand = "vfkit" type AppleHVStubber struct { vmconfigs.AppleHVConfig diff --git a/pkg/machine/compression/compression_test.go b/pkg/machine/compression/compression_test.go index b0b6b8d29f7..0cbd43354a9 100644 --- a/pkg/machine/compression/compression_test.go +++ b/pkg/machine/compression/compression_test.go @@ -13,7 +13,7 @@ func Test_compressionFromFile(t *testing.T) { type args struct { path string } - var tests = []struct { + tests := []struct { name string args args want ImageCompression diff --git a/pkg/machine/define/config.go b/pkg/machine/define/config.go index b6c07342c15..32d401d8626 100644 --- a/pkg/machine/define/config.go +++ b/pkg/machine/define/config.go @@ -12,9 +12,7 @@ const ( // Ref: https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta const MountTag = "rosetta" -var ( - DefaultFilePerm os.FileMode = 0644 -) +var DefaultFilePerm os.FileMode = 0o644 type CreateVMOpts struct { Name string diff --git a/pkg/machine/define/image_format_test.go b/pkg/machine/define/image_format_test.go index fe7c80e7396..214269d0e2e 100644 --- a/pkg/machine/define/image_format_test.go +++ b/pkg/machine/define/image_format_test.go @@ -58,7 +58,8 @@ func TestImageFormat_KindWithCompression(t *testing.T) { name: "raw", imf: Raw, want: "raw.zst", - }, { + }, + { name: "tar.zst", imf: Tar, want: "tar.zst", diff --git a/pkg/machine/define/machine_artifact_test.go b/pkg/machine/define/machine_artifact_test.go index 187bf145025..3e0fa183fb8 100644 --- a/pkg/machine/define/machine_artifact_test.go +++ b/pkg/machine/define/machine_artifact_test.go @@ -19,7 +19,8 @@ func Test_artifact_String(t *testing.T) { name: "hyperv", a: HyperV, want: "hyperv", - }, { + }, + { name: "applehv", a: AppleHV, want: "applehv", diff --git a/pkg/machine/e2e/api_test.go b/pkg/machine/e2e/api_test.go index f5dda2f39c0..b723e6358ad 100644 --- a/pkg/machine/e2e/api_test.go +++ b/pkg/machine/e2e/api_test.go @@ -19,7 +19,6 @@ const ( ) var _ = Describe("run podman API test calls", func() { - It("client connect to machine socket", func() { if runtime.GOOS == "windows" { Skip("Go docker client doesn't support unix socket on Windows") diff --git a/pkg/machine/e2e/basic_test.go b/pkg/machine/e2e/basic_test.go index 27a2df09eb8..ac3242c06ff 100644 --- a/pkg/machine/e2e/basic_test.go +++ b/pkg/machine/e2e/basic_test.go @@ -23,7 +23,6 @@ import ( const TESTIMAGE = "quay.io/libpod/testimage:20241011" var _ = Describe("run basic podman commands", func() { - It("Basic ops", func() { name := randomString() i := new(initMachine) @@ -189,9 +188,11 @@ var _ = Describe("run basic podman commands", func() { ctrName := "test" bm := basicMachine{} - runAlp, err := mb.setCmd(bm.withPodmanCommand([]string{"run", "-dt", "--name", ctrName, "-p", "62544:80", + runAlp, err := mb.setCmd(bm.withPodmanCommand([]string{ + "run", "-dt", "--name", ctrName, "-p", "62544:80", "--stop-signal", "SIGKILL", TESTIMAGE, - "/bin/busybox-extras", "httpd", "-f", "-p", "80"})).run() + "/bin/busybox-extras", "httpd", "-f", "-p", "80", + })).run() Expect(err).ToNot(HaveOccurred()) Expect(runAlp).To(Exit(0)) _, id, _ := strings.Cut(TESTIMAGE, ":") diff --git a/pkg/machine/e2e/compose_test.go b/pkg/machine/e2e/compose_test.go index 88154ce099a..853bc85c512 100644 --- a/pkg/machine/e2e/compose_test.go +++ b/pkg/machine/e2e/compose_test.go @@ -14,7 +14,6 @@ import ( ) var _ = Describe("podman machine compose", func() { - It("compose test environment variable setup", func() { name := randomString() i := new(initMachine) @@ -44,5 +43,4 @@ var _ = Describe("podman machine compose", func() { } Expect(strings.TrimSuffix(lines[1], "\r")).To(Equal("0")) }) - }) diff --git a/pkg/machine/e2e/config_set_test.go b/pkg/machine/e2e/config_set_test.go index 09e71f00f85..c0c8b8f014a 100644 --- a/pkg/machine/e2e/config_set_test.go +++ b/pkg/machine/e2e/config_set_test.go @@ -40,6 +40,7 @@ func (i *setMachine) withCPUs(num uint) *setMachine { i.cpus = &num return i } + func (i *setMachine) withDiskSize(size uint) *setMachine { i.diskSize = &size return i diff --git a/pkg/machine/e2e/cp_test.go b/pkg/machine/e2e/cp_test.go index 851f2e3f75d..7494e0f5eef 100644 --- a/pkg/machine/e2e/cp_test.go +++ b/pkg/machine/e2e/cp_test.go @@ -169,7 +169,7 @@ var _ = Describe("run cp commands", func() { // Write a directory header to the tar err = tw.WriteHeader(&tar.Header{ Name: stdinDirectory, - Mode: int64(0640 | fs.ModeDir), + Mode: int64(0o640 | fs.ModeDir), Gid: 1000, ModTime: now, ChangeTime: now, diff --git a/pkg/machine/e2e/info_test.go b/pkg/machine/e2e/info_test.go index 289b5c5d862..7f4c4a444f1 100644 --- a/pkg/machine/e2e/info_test.go +++ b/pkg/machine/e2e/info_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("podman machine info", func() { - It("machine info", func() { info := new(infoMachine) infoSession, err := mb.setCmd(info).run() diff --git a/pkg/machine/e2e/init_windows_test.go b/pkg/machine/e2e/init_windows_test.go index 88f78679f64..5112ba35b0a 100644 --- a/pkg/machine/e2e/init_windows_test.go +++ b/pkg/machine/e2e/init_windows_test.go @@ -15,7 +15,6 @@ import ( ) var _ = Describe("podman machine init - windows only", func() { - It("init with user mode networking", func() { if testProvider.VMType() != define.WSLVirt { Skip("test is only supported by WSL") diff --git a/pkg/machine/e2e/inspect_test.go b/pkg/machine/e2e/inspect_test.go index dc52663ed77..de53634d6d9 100644 --- a/pkg/machine/e2e/inspect_test.go +++ b/pkg/machine/e2e/inspect_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("podman inspect stop", func() { - It("inspect bad name", func() { i := inspectMachine{} reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" diff --git a/pkg/machine/e2e/list_test.go b/pkg/machine/e2e/list_test.go index 15a56279c4c..ca54de5f414 100644 --- a/pkg/machine/e2e/list_test.go +++ b/pkg/machine/e2e/list_test.go @@ -14,7 +14,6 @@ import ( ) var _ = Describe("podman machine list", func() { - It("list machine", func() { list := new(listMachine) firstList, err := mb.setCmd(list).run() diff --git a/pkg/machine/e2e/proxy_test.go b/pkg/machine/e2e/proxy_test.go index 92820529e5b..b6c23ebc7fd 100644 --- a/pkg/machine/e2e/proxy_test.go +++ b/pkg/machine/e2e/proxy_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("podman machine proxy settings propagation", func() { - It("ssh to running machine and check proxy settings", func() { defer func() { os.Unsetenv("HTTP_PROXY") diff --git a/pkg/machine/e2e/reset_test.go b/pkg/machine/e2e/reset_test.go index f997bf864c8..0226b94e5b8 100644 --- a/pkg/machine/e2e/reset_test.go +++ b/pkg/machine/e2e/reset_test.go @@ -7,7 +7,6 @@ import ( ) var _ = Describe("podman machine reset", func() { - It("starting from scratch should not error", func() { i := resetMachine{} session, err := mb.setCmd(i.withForce()).run() @@ -73,5 +72,4 @@ var _ = Describe("podman machine reset", func() { Expect(afterSession).To(Exit(0)) Expect(afterSession.outputToStringSlice()).To(BeEmpty()) }) - }) diff --git a/pkg/machine/e2e/rm_test.go b/pkg/machine/e2e/rm_test.go index 48484924032..f95f6c1d3a3 100644 --- a/pkg/machine/e2e/rm_test.go +++ b/pkg/machine/e2e/rm_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("podman machine rm", func() { - It("bad init name", func() { i := rmMachine{} reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" diff --git a/pkg/machine/e2e/set_test.go b/pkg/machine/e2e/set_test.go index 387d2bb8f66..f0a4b3dade5 100644 --- a/pkg/machine/e2e/set_test.go +++ b/pkg/machine/e2e/set_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("podman machine set", func() { - It("set machine cpus, disk, memory", func() { skipIfWSL("WSL cannot change set properties of disk, processor, or memory") name := randomString() diff --git a/pkg/machine/e2e/ssh_test.go b/pkg/machine/e2e/ssh_test.go index 86585649e1f..c9143764dd1 100644 --- a/pkg/machine/e2e/ssh_test.go +++ b/pkg/machine/e2e/ssh_test.go @@ -8,7 +8,6 @@ import ( ) var _ = Describe("podman machine ssh", func() { - It("bad machine name", func() { name := randomString() ssh := &sshMachine{} diff --git a/pkg/machine/e2e/stop_test.go b/pkg/machine/e2e/stop_test.go index 780858344dd..e026386622a 100644 --- a/pkg/machine/e2e/stop_test.go +++ b/pkg/machine/e2e/stop_test.go @@ -10,7 +10,6 @@ import ( ) var _ = Describe("podman machine stop", func() { - It("stop bad name", func() { i := stopMachine{} reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" diff --git a/pkg/machine/hyperv/stubber.go b/pkg/machine/hyperv/stubber.go index 0c7aed16008..b0a2a51fada 100644 --- a/pkg/machine/hyperv/stubber.go +++ b/pkg/machine/hyperv/stubber.go @@ -41,9 +41,7 @@ func (h HyperVStubber) RequireExclusiveActive() bool { } func (h HyperVStubber) CreateVM(_ define.CreateVMOpts, mc *vmconfigs.MachineConfig, builder *ignition.IgnitionBuilder) error { - var ( - err error - ) + var err error callbackFuncs := machine.CleanUp() defer callbackFuncs.CleanIfErr(&err) go callbackFuncs.CleanOnSignal() @@ -169,9 +167,7 @@ func (h HyperVStubber) StartNetworking(mc *vmconfigs.MachineConfig, cmd *gvproxy } func (h HyperVStubber) StartVM(mc *vmconfigs.MachineConfig) (func() error, func() error, error) { - var ( - err error - ) + var err error _, vm, err := GetVMFromMC(mc) if err != nil { @@ -291,9 +287,7 @@ func stateConversion(s hypervctl.EnabledState) (define.Status, error) { } func (h HyperVStubber) SetProviderAttrs(mc *vmconfigs.MachineConfig, opts define.SetOptions) error { - var ( - cpuChanged, memoryChanged bool - ) + var cpuChanged, memoryChanged bool _, vm, err := GetVMFromMC(mc) if err != nil { diff --git a/pkg/machine/ignition/ignition.go b/pkg/machine/ignition/ignition.go index fd80989afea..57897c834ab 100644 --- a/pkg/machine/ignition/ignition.go +++ b/pkg/machine/ignition/ignition.go @@ -79,9 +79,7 @@ func (ign *DynamicIgnition) Write() error { } func (ign *DynamicIgnition) getUsers() []PasswdUser { - var ( - users []PasswdUser - ) + var users []PasswdUser isCoreUser := ign.Name == DefaultIgnitionUserName @@ -109,7 +107,8 @@ func (ign *DynamicIgnition) getUsers() []PasswdUser { Group("sudo"), Group("adm"), Group("wheel"), - Group("systemd-journal")} + Group("systemd-journal"), + } } // set root SSH key @@ -232,9 +231,7 @@ func getDirs(usrName string) []Directory { "/home/" + usrName + "/.config/systemd", "/home/" + usrName + "/.config/systemd/user", } - var ( - dirs = make([]Directory, len(newDirs)) - ) + dirs := make([]Directory, len(newDirs)) for i, d := range newDirs { newDir := Directory{ Node: Node{ @@ -411,9 +408,7 @@ pids_limit=0 } func getCerts(certsDir string, isDir bool) []File { - var ( - files []File - ) + var files []File if isDir { err := filepath.WalkDir(certsDir, func(path string, d fs.DirEntry, err error) error { diff --git a/pkg/machine/ocipull/pull.go b/pkg/machine/ocipull/pull.go index 22699da9612..59b5ae4a4d1 100644 --- a/pkg/machine/ocipull/pull.go +++ b/pkg/machine/ocipull/pull.go @@ -27,17 +27,13 @@ type PullOptions struct { Quiet bool } -var ( - // noSignaturePolicy is a default policy if policy.json is not found on - // the host machine. - noSignaturePolicy string = `{"default":[{"type":"insecureAcceptAnything"}]}` -) +// noSignaturePolicy is a default policy if policy.json is not found on +// the host machine. +var noSignaturePolicy string = `{"default":[{"type":"insecureAcceptAnything"}]}` // Pull `imageInput` from a container registry to `sourcePath`. func Pull(ctx context.Context, imageInput types.ImageReference, localDestPath *define.VMFile, options *PullOptions) error { - var ( - policy *signature.Policy - ) + var policy *signature.Policy destRef, err := layout.ParseReference(localDestPath.GetPath()) if err != nil { return err diff --git a/pkg/machine/ocipull/source.go b/pkg/machine/ocipull/source.go index 0fe242bd207..7d3174f49de 100644 --- a/pkg/machine/ocipull/source.go +++ b/pkg/machine/ocipull/source.go @@ -57,9 +57,7 @@ func GetDiskArtifactReference(ctx context.Context, imgSrc types.ImageSource, opt return "", fmt.Errorf("failed to parse manifest list from blob: %q", err) } - var ( - artifactDigest digest.Digest - ) + var artifactDigest digest.Digest for _, d := range mannyFestList.Instances() { bar, err := mannyFestList.Instance(d) if err != nil { diff --git a/pkg/machine/os/ostree.go b/pkg/machine/os/ostree.go index f9f5353676f..1b09a1fe0e0 100644 --- a/pkg/machine/os/ostree.go +++ b/pkg/machine/os/ostree.go @@ -15,8 +15,7 @@ import ( ) // OSTree deals with operations on ostree based os's -type OSTree struct { -} +type OSTree struct{} // Apply takes an OCI image and does an rpm-ostree rebase on the image // If no containers-transport is specified, diff --git a/pkg/machine/ports/ports_unix.go b/pkg/machine/ports/ports_unix.go index 82b61f000fc..d670c5187e7 100644 --- a/pkg/machine/ports/ports_unix.go +++ b/pkg/machine/ports/ports_unix.go @@ -22,7 +22,7 @@ func getPortCheckListenConfig() *net.ListenConfig { }); err != nil { cerr = err } - return + return cerr }, } } diff --git a/pkg/machine/ports/ports_windows.go b/pkg/machine/ports/ports_windows.go index 810631fd4e5..9839e142bff 100644 --- a/pkg/machine/ports/ports_windows.go +++ b/pkg/machine/ports/ports_windows.go @@ -22,7 +22,7 @@ func getPortCheckListenConfig() *net.ListenConfig { }); err != nil { cerr = err } - return + return cerr }, } } diff --git a/pkg/machine/qemu/command/qemu_command_test.go b/pkg/machine/qemu/command/qemu_command_test.go index ca847fd383e..7d431e856b6 100644 --- a/pkg/machine/qemu/command/qemu_command_test.go +++ b/pkg/machine/qemu/command/qemu_command_test.go @@ -65,7 +65,8 @@ func TestQemuCmd(t *testing.T) { "-device", "virtserialport,chardev=atest-machine_ready,name=org.fedoraproject.port.0", "-pidfile", vmPidFilePath, "-drive", fmt.Sprintf("if=virtio,file=%s", bootableImagePath), - "-display", "none"} + "-display", "none", + } require.Equal(t, cmd.Build(), expected) } diff --git a/pkg/machine/qemu/options_freebsd_amd64.go b/pkg/machine/qemu/options_freebsd_amd64.go index 37ade8eddb9..d29a190fd56 100644 --- a/pkg/machine/qemu/options_freebsd_amd64.go +++ b/pkg/machine/qemu/options_freebsd_amd64.go @@ -2,9 +2,7 @@ package qemu -var ( - QemuCommand = "qemu-system-x86_64" -) +var QemuCommand = "qemu-system-x86_64" func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string { opts := []string{"-machine", "q35,accel=hvf:tcg", "-cpu", "host"} diff --git a/pkg/machine/qemu/options_freebsd_arm64.go b/pkg/machine/qemu/options_freebsd_arm64.go index 6aab9b06695..673a2da73d0 100644 --- a/pkg/machine/qemu/options_freebsd_arm64.go +++ b/pkg/machine/qemu/options_freebsd_arm64.go @@ -2,14 +2,13 @@ package qemu -var ( - QemuCommand = "qemu-system-aarch64" -) +var QemuCommand = "qemu-system-aarch64" func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string { opts := []string{ "-machine", "virt", "-accel", "tcg", - "-cpu", "host"} + "-cpu", "host", + } return opts } diff --git a/pkg/machine/qemu/options_linux_amd64.go b/pkg/machine/qemu/options_linux_amd64.go index 67b6c61fee2..30a66e04d94 100644 --- a/pkg/machine/qemu/options_linux_amd64.go +++ b/pkg/machine/qemu/options_linux_amd64.go @@ -2,9 +2,7 @@ package qemu -var ( - QemuCommand = "qemu-system-x86_64" -) +var QemuCommand = "qemu-system-x86_64" func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string { opts := []string{ diff --git a/pkg/machine/qemu/options_linux_arm64.go b/pkg/machine/qemu/options_linux_arm64.go index c11f6a3d6a9..da842089b0f 100644 --- a/pkg/machine/qemu/options_linux_arm64.go +++ b/pkg/machine/qemu/options_linux_arm64.go @@ -8,9 +8,7 @@ import ( "go.podman.io/storage/pkg/fileutils" ) -var ( - QemuCommand = "qemu-system-aarch64" -) +var QemuCommand = "qemu-system-aarch64" func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string { opts := []string{ diff --git a/pkg/machine/qemu/options_windows_amd64.go b/pkg/machine/qemu/options_windows_amd64.go index 6e0ba0271aa..96ca711ea30 100644 --- a/pkg/machine/qemu/options_windows_amd64.go +++ b/pkg/machine/qemu/options_windows_amd64.go @@ -2,9 +2,7 @@ package qemu -var ( - QemuCommand = "qemu-system-x86_64w" -) +var QemuCommand = "qemu-system-x86_64w" func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string { // "qemu64" level is used, because "host" is not supported with "whpx" acceleration. diff --git a/pkg/machine/qemu/options_windows_arm64.go b/pkg/machine/qemu/options_windows_arm64.go index e823b19a158..d8d88e84a18 100644 --- a/pkg/machine/qemu/options_windows_arm64.go +++ b/pkg/machine/qemu/options_windows_arm64.go @@ -2,9 +2,7 @@ package qemu -var ( - QemuCommand = "qemu-system-aarch64w" -) +var QemuCommand = "qemu-system-aarch64w" func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string { // stub to fix compilation issues diff --git a/pkg/machine/shim/networking.go b/pkg/machine/shim/networking.go index 151e03657e0..616ea1659ad 100644 --- a/pkg/machine/shim/networking.go +++ b/pkg/machine/shim/networking.go @@ -158,7 +158,7 @@ func conductVMReadinessCheck(mc *vmconfigs.MachineConfig, maxBackoffs int, backo sshError = nil break } - return + return connected, sshError, err } func reassignSSHPort(mc *vmconfigs.MachineConfig, provider vmconfigs.VMProvider) error { diff --git a/pkg/machine/ssh.go b/pkg/machine/ssh.go index 9c0389f1fe5..fb0b5557c0c 100644 --- a/pkg/machine/ssh.go +++ b/pkg/machine/ssh.go @@ -155,5 +155,6 @@ func LocalhostSSHArgs() []string { "-o", "UserKnownHostsFile=" + os.DevNull, "-o", "CheckHostIP=no", "-o", "LogLevel=ERROR", - "-o", "SetEnv=LC_ALL="} + "-o", "SetEnv=LC_ALL=", + } } diff --git a/pkg/machine/stdpull/url.go b/pkg/machine/stdpull/url.go index fc574b71ed3..d676ef278da 100644 --- a/pkg/machine/stdpull/url.go +++ b/pkg/machine/stdpull/url.go @@ -26,9 +26,7 @@ type DiskFromURL struct { } func NewDiskFromURL(inputPath string, finalPath *define.VMFile, tempDir *define.VMFile, optionalTempFileName *string, cache bool) (*DiskFromURL, error) { - var ( - err error - ) + var err error u, err := url2.Parse(inputPath) if err != nil { return nil, err diff --git a/pkg/machine/vmconfigs/arch_test.go b/pkg/machine/vmconfigs/arch_test.go index 7be635209df..498ccd9fa28 100644 --- a/pkg/machine/vmconfigs/arch_test.go +++ b/pkg/machine/vmconfigs/arch_test.go @@ -6,7 +6,7 @@ func TestNormalizeMachineArch(t *testing.T) { type args struct { arch string } - var tests = []struct { + tests := []struct { name string args args want string diff --git a/pkg/machine/vmconfigs/config_common.go b/pkg/machine/vmconfigs/config_common.go index 6d1548b6cfb..7939611c08d 100644 --- a/pkg/machine/vmconfigs/config_common.go +++ b/pkg/machine/vmconfigs/config_common.go @@ -17,10 +17,12 @@ type QEMUConfig struct { } // Stubs -type AppleHVConfig struct{} -type HyperVConfig struct{} -type LibKrunConfig struct{} -type WSLConfig struct{} +type ( + AppleHVConfig struct{} + HyperVConfig struct{} + LibKrunConfig struct{} + WSLConfig struct{} +) func getHostUID() int { return os.Getuid() diff --git a/pkg/machine/vmconfigs/config_darwin.go b/pkg/machine/vmconfigs/config_darwin.go index e149bfe88b9..dc3e923e367 100644 --- a/pkg/machine/vmconfigs/config_darwin.go +++ b/pkg/machine/vmconfigs/config_darwin.go @@ -16,9 +16,11 @@ type LibKrunConfig struct { } // Stubs -type HyperVConfig struct{} -type WSLConfig struct{} -type QEMUConfig struct{} +type ( + HyperVConfig struct{} + WSLConfig struct{} + QEMUConfig struct{} +) func getHostUID() int { return os.Getuid() diff --git a/pkg/machine/vmconfigs/config_windows.go b/pkg/machine/vmconfigs/config_windows.go index 0e9554aeaf8..f0ab9194bbc 100644 --- a/pkg/machine/vmconfigs/config_windows.go +++ b/pkg/machine/vmconfigs/config_windows.go @@ -27,8 +27,10 @@ type QEMUConfig struct { } // Stubs -type AppleHVConfig struct{} -type LibKrunConfig struct{} +type ( + AppleHVConfig struct{} + LibKrunConfig struct{} +) func getHostUID() int { return 1000 diff --git a/pkg/machine/wsl/declares.go b/pkg/machine/wsl/declares.go index aed26c998a9..05e80e746e8 100644 --- a/pkg/machine/wsl/declares.go +++ b/pkg/machine/wsl/declares.go @@ -142,6 +142,7 @@ ExecStop=umount /mnt/wsl/podman-sockets/%[1]s/podman-user.sock const bindMountFsTab = `/run/user/1000/podman/podman.sock /mnt/wsl/podman-sockets/%s/podman-user.sock none noauto,user,bind,defaults 0 0 ` + const ( defaultTargetWants = "default.target.wants" userSystemdPath = "/home/%[1]s/.config/systemd/user" diff --git a/pkg/machine/wsl/machine.go b/pkg/machine/wsl/machine.go index 795c84468d9..1a4ecff46d5 100644 --- a/pkg/machine/wsl/machine.go +++ b/pkg/machine/wsl/machine.go @@ -527,7 +527,7 @@ func setupWslProxyEnv() (hasProxy bool) { if hasProxy { os.Setenv("WSLENV", current) } - return + return hasProxy } //nolint:unused @@ -651,7 +651,6 @@ func isRunning(name string) (bool, error) { sysd := false if wsl { sysd, err = isSystemdRunning(dist) - if err != nil { return false, err } @@ -754,5 +753,5 @@ func getResources(mc *vmconfigs.MachineConfig) (resources vmconfigs.ResourceConf resources.CPUs, _ = getCPUs(mc.Name) resources.Memory, _ = getMem(mc.Name) resources.DiskSize = getDiskSize(mc.Name) - return + return resources } diff --git a/pkg/machine/wsl/stubber.go b/pkg/machine/wsl/stubber.go index 7f6220a41cf..edf4edbd745 100644 --- a/pkg/machine/wsl/stubber.go +++ b/pkg/machine/wsl/stubber.go @@ -25,9 +25,7 @@ type WSLStubber struct { } func (w WSLStubber) CreateVM(opts define.CreateVMOpts, mc *vmconfigs.MachineConfig, _ *ignition.IgnitionBuilder) error { - var ( - err error - ) + var err error // cleanup half-baked files if init fails at any point callbackFuncs := machine.CleanUp() defer callbackFuncs.CleanIfErr(&err) @@ -235,9 +233,7 @@ func (w WSLStubber) State(mc *vmconfigs.MachineConfig, _ bool) (define.Status, e } func (w WSLStubber) StopVM(mc *vmconfigs.MachineConfig, _ bool) error { - var ( - err error - ) + var err error if running, err := isRunning(mc.Name); !running { return err diff --git a/pkg/machine/wsl/usermodenet.go b/pkg/machine/wsl/usermodenet.go index 01be8ab7b7f..55c3af7a9bc 100644 --- a/pkg/machine/wsl/usermodenet.go +++ b/pkg/machine/wsl/usermodenet.go @@ -324,7 +324,6 @@ func cleanupAndCountNetEntries() (uint, error) { func obtainUserModeNetLock() (*fileLock, error) { dir, err := getUserModeNetDir() - if err != nil { return nil, err } diff --git a/pkg/parallel/ctr/ctr.go b/pkg/parallel/ctr/ctr.go index 4a42e6aac71..1b2af480223 100644 --- a/pkg/parallel/ctr/ctr.go +++ b/pkg/parallel/ctr/ctr.go @@ -19,9 +19,8 @@ func ContainerOp(ctx context.Context, ctrs []*libpod.Container, applyFunc func(* // just use a lock on a normal map... // The expectation is that most of the time is spent in applyFunc // anyways. - var ( - errMap = make(map[*libpod.Container]<-chan error) - ) + + errMap := make(map[*libpod.Container]<-chan error) for _, ctr := range ctrs { c := ctr diff --git a/pkg/ps/ps.go b/pkg/ps/ps.go index 34941418718..4ef38af95aa 100644 --- a/pkg/ps/ps.go +++ b/pkg/ps/ps.go @@ -30,9 +30,7 @@ import ( type ExternalContainerFilter func(*entities.ListContainer) bool func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOptions) ([]entities.ListContainer, error) { - var ( - pss = []entities.ListContainer{} - ) + pss := []entities.ListContainer{} filterFuncs := make([]libpod.ContainerFilter, 0, len(options.Filters)) filterExtFuncs := make([]entities.ExternalContainerFilter, 0, len(options.Filters)) all := options.All || options.Last > 0 @@ -122,9 +120,7 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp // GetExternalContainerLists returns list of external containers for e.g. created by buildah func GetExternalContainerLists(runtime *libpod.Runtime, filterExtFuncs ...entities.ExternalContainerFilter) ([]entities.ListContainer, error) { - var ( - pss = []*entities.ListContainer{} - ) + pss := []*entities.ListContainer{} externCons, err := runtime.StorageContainers() if err != nil { diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go index 98ac9fd36c8..e04c791ff87 100644 --- a/pkg/rootless/rootless_linux.go +++ b/pkg/rootless/rootless_linux.go @@ -88,7 +88,7 @@ func GetRootlessGID() int { } func tryMappingTool(uid bool, pid int, hostID int, mappings []idtools.IDMap) error { - var tool = "newuidmap" + tool := "newuidmap" mode := os.ModeSetuid cap := capability.CAP_SETUID idtype := "setuid" diff --git a/pkg/signal/signal_common.go b/pkg/signal/signal_common.go index 34e5b494e57..0e190d4f4ac 100644 --- a/pkg/signal/signal_common.go +++ b/pkg/signal/signal_common.go @@ -76,7 +76,7 @@ func ParseSysSignalToName(s syscall.Signal) (string, error) { } func ToDockerFormat(s uint) string { - var signalStr, err = ParseSysSignalToName(syscall.Signal(s)) + signalStr, err := ParseSysSignalToName(syscall.Signal(s)) if err != nil { return strconv.FormatUint(uint64(s), 10) } diff --git a/pkg/specgen/generate/config_common.go b/pkg/specgen/generate/config_common.go index 1a95618e34a..7455270a69e 100644 --- a/pkg/specgen/generate/config_common.go +++ b/pkg/specgen/generate/config_common.go @@ -48,7 +48,7 @@ func ParseDevice(device string) (string, string, string, error) { // IsValidDeviceMode checks if the mode for device is valid or not. // IsValid mode is a composition of r (read), w (write), and m (mknod). func IsValidDeviceMode(mode string) bool { - var legalDeviceMode = map[rune]bool{ + legalDeviceMode := map[rune]bool{ 'r': true, 'w': true, 'm': true, diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go index fb462b312de..d69b0f3f444 100644 --- a/pkg/specgen/generate/container_create.go +++ b/pkg/specgen/generate/container_create.go @@ -312,6 +312,7 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener } return runtimeSpec, s, options, err } + func ExecuteCreate(ctx context.Context, rt *libpod.Runtime, runtimeSpec *specs.Spec, s *specgen.SpecGenerator, infra bool, options ...libpod.CtrCreateOption) (*libpod.Container, error) { ctr, err := rt.NewContainer(ctx, runtimeSpec, s, infra, options...) if err != nil { diff --git a/pkg/specgen/generate/kube/volume.go b/pkg/specgen/generate/kube/volume.go index 020f01e9a7c..20d8d02f52a 100644 --- a/pkg/specgen/generate/kube/volume.go +++ b/pkg/specgen/generate/kube/volume.go @@ -21,9 +21,9 @@ import ( const ( // https://kubernetes.io/docs/concepts/storage/volumes/#hostpath - kubeDirectoryPermission = 0755 + kubeDirectoryPermission = 0o755 // https://kubernetes.io/docs/concepts/storage/volumes/#hostpath - kubeFilePermission = 0644 + kubeFilePermission = 0o644 ) type KubeVolumeType int diff --git a/pkg/specgen/generate/pod_create.go b/pkg/specgen/generate/pod_create.go index eb2b3a74daa..903ebe46371 100644 --- a/pkg/specgen/generate/pod_create.go +++ b/pkg/specgen/generate/pod_create.go @@ -115,9 +115,7 @@ func MakePod(p *entities.PodSpec, rt *libpod.Runtime) (_ *libpod.Pod, finalErr e } func createPodOptions(p *specgen.PodSpecGenerator) ([]libpod.PodCreateOption, error) { - var ( - options []libpod.PodCreateOption - ) + var options []libpod.PodCreateOption if p.ShareParent == nil || (p.ShareParent != nil && *p.ShareParent) { options = append(options, libpod.WithPodParent()) diff --git a/pkg/specgen/generate/pod_create_test.go b/pkg/specgen/generate/pod_create_test.go index 04f02096309..191b225e275 100644 --- a/pkg/specgen/generate/pod_create_test.go +++ b/pkg/specgen/generate/pod_create_test.go @@ -4,13 +4,12 @@ package generate import ( "net" + "testing" "github.com/containers/podman/v6/pkg/specgen" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.podman.io/common/libnetwork/types" - - "testing" ) var ( @@ -32,11 +31,14 @@ func TestMapSpecCopyPodSpecToInfraContainerSpec(t *testing.T) { infraImage := "someimage" conmonPidFile := "/var/run/conmon.pid" podSpec := specgen.PodSpecGenerator{ - PodBasicConfig: specgen.PodBasicConfig{InfraCommand: infraCommand, InfraImage: infraImage, - InfraConmonPidFile: conmonPidFile}, + PodBasicConfig: specgen.PodBasicConfig{ + InfraCommand: infraCommand, InfraImage: infraImage, + InfraConmonPidFile: conmonPidFile, + }, PodNetworkConfig: specgen.PodNetworkConfig{ PortMappings: portMappings, HostAdd: addedHosts, DNSServer: dnsServers, DNSOption: dnsOptions, DNSSearch: dnsSearch, - Networks: networks, NoManageResolvConf: true, NoManageHosts: true}, + Networks: networks, NoManageResolvConf: true, NoManageHosts: true, + }, PodCgroupConfig: specgen.PodCgroupConfig{}, PodResourceConfig: specgen.PodResourceConfig{}, PodStorageConfig: specgen.PodStorageConfig{}, @@ -114,7 +116,8 @@ func TestMapSpecNetworkOptions(t *testing.T) { name: "Private", podSpec: createPodSpec(specgen.Private), expectedNSMode: specgen.Private, - }, { + }, + { name: "Host", podSpec: createPodSpec(specgen.Host), expectedNSMode: specgen.Host, @@ -123,7 +126,8 @@ func TestMapSpecNetworkOptions(t *testing.T) { name: "Host but with port mappings", podSpec: createPodSpecWithPortMapping(specgen.Host), mustError: true, - }, { + }, + { name: "Host but with networks", podSpec: createPodSpecWithNetworks(specgen.Host), mustError: true, @@ -170,7 +174,8 @@ func TestMapSpecNetworkOptions(t *testing.T) { name: "FromContainer", podSpec: createPodSpec(specgen.FromContainer), mustError: true, - }, { + }, + { name: "FromPod", podSpec: createPodSpec(specgen.FromPod), mustError: true, diff --git a/pkg/specgen/generate/ports.go b/pkg/specgen/generate/ports.go index d60d81fd000..077ac9a4c53 100644 --- a/pkg/specgen/generate/ports.go +++ b/pkg/specgen/generate/ports.go @@ -25,7 +25,8 @@ const ( // joinTwoPortsToRangePortIfPossible will expect two ports the previous port one must have a lower or equal hostPort than the current port. func joinTwoPortsToRangePortIfPossible(ports *[]types.PortMapping, allHostPorts, allContainerPorts, currentHostPorts *[65536]bool, - previousPort *types.PortMapping, port types.PortMapping) (*types.PortMapping, error) { + previousPort *types.PortMapping, port types.PortMapping, +) (*types.PortMapping, error) { // no previous port just return the current one if previousPort == nil { return &port, nil @@ -59,7 +60,8 @@ func joinTwoPortsToRangePortIfPossible(ports *[]types.PortMapping, allHostPorts, // // the previous port one must have a lower or equal containerPort than the current port. func joinTwoContainerPortsToRangePortIfPossible(ports *[]types.PortMapping, allHostPorts, allContainerPorts, currentHostPorts *[65536]bool, - previousPort *types.PortMapping, port types.PortMapping) (*types.PortMapping, error) { + previousPort *types.PortMapping, port types.PortMapping, +) (*types.PortMapping, error) { // no previous port just return the current one if previousPort == nil { return &port, nil diff --git a/pkg/specgen/namespaces.go b/pkg/specgen/namespaces.go index 128089768bd..f9bb4ef6f0e 100644 --- a/pkg/specgen/namespaces.go +++ b/pkg/specgen/namespaces.go @@ -428,8 +428,10 @@ func ParseNetworkFlag(networks []string) (Namespace, map[string]types.PerNetwork if name == "" { return toReturn, nil, nil, fmt.Errorf("network name cannot be empty: %w", define.ErrInvalidArg) } - if slices.Contains([]string{string(Bridge), string(Slirp), string(Pasta), string(FromPod), string(NoNetwork), - string(Default), string(Private), string(Path), string(FromContainer), string(Host)}, name) { + if slices.Contains([]string{ + string(Bridge), string(Slirp), string(Pasta), string(FromPod), string(NoNetwork), + string(Default), string(Private), string(Path), string(FromContainer), string(Host), + }, name) { return toReturn, nil, nil, fmt.Errorf("can only set extra network names, selected mode %s conflicts with bridge: %w", name, define.ErrInvalidArg) } netOpts := types.PerNetworkOptions{} diff --git a/pkg/specgen/pod_validate.go b/pkg/specgen/pod_validate.go index a2732eeb231..636de85c6b6 100644 --- a/pkg/specgen/pod_validate.go +++ b/pkg/specgen/pod_validate.go @@ -5,11 +5,10 @@ import ( "fmt" ) -var ( - // ErrInvalidPodSpecConfig describes an error given when the podspecgenerator is invalid - ErrInvalidPodSpecConfig = errors.New("invalid pod spec") - // containerConfig has the default configurations defined in containers.conf -) +// ErrInvalidPodSpecConfig describes an error given when the podspecgenerator is invalid +var ErrInvalidPodSpecConfig = errors.New("invalid pod spec") + +// containerConfig has the default configurations defined in containers.conf func exclusivePodOptions(opt1, opt2 string) error { return fmt.Errorf("%s and %s are mutually exclusive pod options: %w", opt1, opt2, ErrInvalidPodSpecConfig) diff --git a/pkg/specgenutil/specgen.go b/pkg/specgenutil/specgen.go index 6699d74fa81..73a2f0dbf98 100644 --- a/pkg/specgenutil/specgen.go +++ b/pkg/specgenutil/specgen.go @@ -569,7 +569,6 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions // SHM Size if c.ShmSize != "" { val, err := units.RAMInBytes(c.ShmSize) - if err != nil { return fmt.Errorf("unable to translate --shm-size: %w", err) } diff --git a/pkg/specgenutil/specgenutil_test.go b/pkg/specgenutil/specgenutil_test.go index a1f03dd9e9a..5f7645b094b 100644 --- a/pkg/specgenutil/specgenutil_test.go +++ b/pkg/specgenutil/specgenutil_test.go @@ -46,7 +46,8 @@ func TestWinPath(t *testing.T) { sg := specgen.NewSpecGenerator("nothing", false) err := FillOutSpecGen(sg, &entities.ContainerCreateOptions{ ImageVolume: "ignore", - Volume: []string{vol}}, []string{}, + Volume: []string{vol}, + }, []string{}, ) machine.Enabled, machine.Type = oldEnable, oldType return sg, err diff --git a/pkg/specgenutil/specgenutil_windows_test.go b/pkg/specgenutil/specgenutil_windows_test.go index 7c270b32d57..2136867d249 100644 --- a/pkg/specgenutil/specgenutil_windows_test.go +++ b/pkg/specgenutil/specgenutil_windows_test.go @@ -38,7 +38,8 @@ func TestSeccompProfilePath(t *testing.T) { f := func(secopt string) (*specgen.SpecGenerator, error) { sg := specgen.NewSpecGenerator("nothing", false) err := FillOutSpecGen(sg, &entities.ContainerCreateOptions{ - SecurityOpt: []string{secopt}}, []string{}, + SecurityOpt: []string{secopt}, + }, []string{}, ) return sg, err } diff --git a/pkg/specgenutil/util.go b/pkg/specgenutil/util.go index b1d5efddbdb..8e4d95fc723 100644 --- a/pkg/specgenutil/util.go +++ b/pkg/specgenutil/util.go @@ -273,7 +273,8 @@ func CreateExitCommandArgs(storageConfig storageTypes.StoreOptions, config *conf return nil, err } - command := []string{podmanPath, + command := []string{ + podmanPath, "--root", storageConfig.GraphRoot, "--runroot", storageConfig.RunRoot, "--log-level", logrus.GetLevel().String(), diff --git a/pkg/specgenutilexternal/mount.go b/pkg/specgenutilexternal/mount.go index eb48ab7fb90..3ffa4bde1e8 100644 --- a/pkg/specgenutilexternal/mount.go +++ b/pkg/specgenutilexternal/mount.go @@ -32,5 +32,5 @@ func FindMountType(input string) (mountType string, tokens []string, err error) if !found { mountType = "volume" } - return + return mountType, tokens, err } diff --git a/pkg/systemd/generate/containers_test.go b/pkg/systemd/generate/containers_test.go index ee6dbf526c2..4229061cf67 100644 --- a/pkg/systemd/generate/containers_test.go +++ b/pkg/systemd/generate/containers_test.go @@ -1035,8 +1035,8 @@ WantedBy=default.target wantErr bool template bool }{ - - {"good with id", + { + "good with id", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401", @@ -1054,7 +1054,8 @@ WantedBy=default.target false, false, }, - {"good with noHeader", + { + "good with noHeader", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401", @@ -1072,7 +1073,8 @@ WantedBy=default.target false, false, }, - {"good with name", + { + "good with name", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-foobar", @@ -1090,7 +1092,8 @@ WantedBy=default.target false, false, }, - {"good with name and wants", + { + "good with name and wants", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-foobar", @@ -1109,7 +1112,8 @@ WantedBy=default.target false, false, }, - {"good with name and after", + { + "good with name and after", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-foobar", @@ -1128,7 +1132,8 @@ WantedBy=default.target false, false, }, - {"good with name and requires", + { + "good with name and requires", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-foobar", @@ -1147,7 +1152,8 @@ WantedBy=default.target false, false, }, - {"good with name and dependencies", + { + "good with name and dependencies", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-foobar", @@ -1168,7 +1174,8 @@ WantedBy=default.target false, false, }, - {"good with name and bound to", + { + "good with name and bound to", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-foobar", @@ -1187,7 +1194,8 @@ WantedBy=default.target false, false, }, - {"good with name and generic", + { + "good with name and generic", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1206,7 +1214,8 @@ WantedBy=default.target false, false, }, - {"good with name and --sdnotify=container", + { + "good with name and --sdnotify=container", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1225,7 +1234,8 @@ WantedBy=default.target false, false, }, - {"good with name and --sdnotify container", + { + "good with name and --sdnotify container", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1244,7 +1254,8 @@ WantedBy=default.target false, false, }, - {"good with name and --sdnotify=ignore", + { + "good with name and --sdnotify=ignore", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1263,7 +1274,8 @@ WantedBy=default.target false, false, }, - {"good with name and --sdnotify ignore", + { + "good with name and --sdnotify ignore", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1282,7 +1294,8 @@ WantedBy=default.target false, false, }, - {"good with explicit short detach param", + { + "good with explicit short detach param", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1301,7 +1314,8 @@ WantedBy=default.target false, false, }, - {"good with explicit short detach param and podInfo", + { + "good with explicit short detach param and podInfo", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1323,7 +1337,8 @@ WantedBy=default.target false, false, }, - {"good with explicit full detach param", + { + "good with explicit full detach param", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1342,7 +1357,8 @@ WantedBy=default.target false, false, }, - {"good with id and no param", + { + "good with id and no param", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401", @@ -1361,7 +1377,8 @@ WantedBy=default.target false, false, }, - {"good with explicit detach=true param", + { + "good with explicit detach=true param", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1380,7 +1397,8 @@ WantedBy=default.target false, false, }, - {"good with explicit detach=false param", + { + "good with explicit detach=false param", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1399,7 +1417,8 @@ WantedBy=default.target false, false, }, - {"good with explicit detach=false param", + { + "good with explicit detach=false param", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1418,7 +1437,8 @@ WantedBy=default.target false, false, }, - {"good with multiple detach=false params", + { + "good with multiple detach=false params", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1437,7 +1457,8 @@ WantedBy=default.target false, false, }, - {"good with multiple shorthand params detach first", + { + "good with multiple shorthand params detach first", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1456,7 +1477,8 @@ WantedBy=default.target false, false, }, - {"good with multiple shorthand params detach last", + { + "good with multiple shorthand params detach last", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1475,7 +1497,8 @@ WantedBy=default.target false, false, }, - {"good with container create", + { + "good with container create", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1494,7 +1517,8 @@ WantedBy=default.target false, false, }, - {"good with journald log tag (see #9034)", + { + "good with journald log tag (see #9034)", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1513,7 +1537,8 @@ WantedBy=default.target false, false, }, - {"good with special chars", + { + "good with special chars", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1532,7 +1557,8 @@ WantedBy=default.target false, false, }, - {"good with ID files", + { + "good with ID files", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1551,7 +1577,8 @@ WantedBy=default.target false, false, }, - {"good with pod ID files", + { + "good with pod ID files", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1573,7 +1600,8 @@ WantedBy=default.target false, false, }, - {"good with container environment variables", + { + "good with container environment variables", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1593,7 +1621,8 @@ WantedBy=default.target false, false, }, - {"good with systemd environment variables", + { + "good with systemd environment variables", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-foobar", @@ -1612,7 +1641,8 @@ WantedBy=default.target false, false, }, - {"good with restart policy", + { + "good with restart policy", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1631,7 +1661,8 @@ WantedBy=default.target false, false, }, - {"good with -h hostname", + { + "good with -h hostname", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "jadda-jadda", @@ -1650,7 +1681,8 @@ WantedBy=default.target false, false, }, - {"good template", + { + "good template", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-foo", @@ -1668,7 +1700,8 @@ WantedBy=default.target false, true, }, - {"good with name and empty container-prefix", + { + "good with name and empty container-prefix", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "foobar", @@ -1686,7 +1719,8 @@ WantedBy=default.target false, false, }, - {"good with RestartSec", + { + "good with RestartSec", containerInfo{ Executable: "/usr/bin/podman", ServiceName: "container-foobar", diff --git a/pkg/systemd/generate/pods_test.go b/pkg/systemd/generate/pods_test.go index f34edebe4c6..99bd702b006 100644 --- a/pkg/systemd/generate/pods_test.go +++ b/pkg/systemd/generate/pods_test.go @@ -477,7 +477,8 @@ WantedBy=default.target noHeader bool wantErr bool }{ - {"pod", + { + "pod", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -495,7 +496,8 @@ WantedBy=default.target false, false, }, - {"pod", + { + "pod", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -509,14 +511,16 @@ WantedBy=default.target Wants: []string{"a.service", "b.service", "c.target"}, CreateCommand: []string{ "podman", "pod", "create", "--name", "foo", "--wants", "a.service", - "--wants", "b.service", "--wants", "c.target", "bar=arg with space"}, + "--wants", "b.service", "--wants", "c.target", "bar=arg with space", + }, }, podGoodCustomWants, false, false, false, }, - {"pod", + { + "pod", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -530,14 +534,16 @@ WantedBy=default.target After: []string{"a.service", "b.service", "c.target"}, CreateCommand: []string{ "podman", "pod", "create", "--name", "foo", "--after", "a.service", - "--after", "b.service", "--after", "c.target", "bar=arg with space"}, + "--after", "b.service", "--after", "c.target", "bar=arg with space", + }, }, podGoodCustomAfter, false, false, false, }, - {"pod", + { + "pod", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -551,14 +557,16 @@ WantedBy=default.target Requires: []string{"a.service", "b.service", "c.target"}, CreateCommand: []string{ "podman", "pod", "create", "--name", "foo", "--requires", "a.service", - "--requires", "b.service", "--requires", "c.target", "bar=arg with space"}, + "--requires", "b.service", "--requires", "c.target", "bar=arg with space", + }, }, podGoodCustomRequires, false, false, false, }, - {"pod", + { + "pod", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -576,14 +584,16 @@ WantedBy=default.target "podman", "pod", "create", "--name", "foo", "--wants", "a.service", "--wants", "b.service", "--wants", "c.target", "--after", "a.service", "--after", "b.service", "--after", "c.target", "--requires", "a.service", - "--requires", "b.service", "--requires", "c.target", "bar=arg with space"}, + "--requires", "b.service", "--requires", "c.target", "bar=arg with space", + }, }, podGoodCustomDependencies, false, false, false, }, - {"pod without --name", + { + "pod without --name", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -600,7 +610,8 @@ WantedBy=default.target false, false, }, - {"pod restartSec", + { + "pod restartSec", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -619,7 +630,8 @@ WantedBy=default.target false, false, }, - {"pod noHeader", + { + "pod noHeader", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -637,7 +649,8 @@ WantedBy=default.target true, false, }, - {"pod with root args", + { + "pod with root args", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -655,7 +668,8 @@ WantedBy=default.target false, false, }, - {"pod --new", + { + "pod --new", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -673,7 +687,8 @@ WantedBy=default.target false, false, }, - {"pod --new with root args", + { + "pod --new with root args", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -691,7 +706,8 @@ WantedBy=default.target false, false, }, - {"pod --new with --replace=false", + { + "pod --new with --replace=false", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -709,7 +725,8 @@ WantedBy=default.target false, false, }, - {"pod --new with double curly braces", + { + "pod --new with double curly braces", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -727,7 +744,8 @@ WantedBy=default.target false, false, }, - {"pod --new with ID files", + { + "pod --new with ID files", podInfo{ Executable: "/usr/bin/podman", ServiceName: "pod-123abc", @@ -745,7 +763,8 @@ WantedBy=default.target false, false, }, - {"pod with empty pod-prefix", + { + "pod with empty pod-prefix", podInfo{ Executable: "/usr/bin/podman", ServiceName: "123abc", diff --git a/pkg/systemd/parser/split.go b/pkg/systemd/parser/split.go index 5c62bc7feea..54deb174fb5 100644 --- a/pkg/systemd/parser/split.go +++ b/pkg/systemd/parser/split.go @@ -55,8 +55,8 @@ func isValidUnicode(c uint32) bool { /* This is based on code from systemd (src/basic/escape.c), marked LGPL-2.1-or-later and is copyrighted by the systemd developers */ func cUnescapeOne(p string, acceptNul bool) (int, rune, bool) { - var count = 1 - var eightBit = false + count := 1 + eightBit := false var ret rune // Unescapes C style. Returns the unescaped character in ret. @@ -290,7 +290,7 @@ loop1: } if flags&(SplitCUnescape|SplitUnescapeSeparators) != 0 { - var r = -1 + r := -1 var u rune if flags&SplitCUnescape != 0 { diff --git a/pkg/systemd/parser/split_test.go b/pkg/systemd/parser/split_test.go index 657fff78534..e02d76631ea 100644 --- a/pkg/systemd/parser/split_test.go +++ b/pkg/systemd/parser/split_test.go @@ -72,8 +72,10 @@ func TestCUnescapeOne(t *testing.T) { func TestExtractFirstWordUnescapes(t *testing.T) { input := `\a \b \f \n \r \t \v \\ \" \' \s \x50odman is \U0001F51F/\u0031\u0030 \110ello \127orld` - expected := []string{"\a", "\b", "\f", "\n", "\r", "\t", "\v", "\\", "\"", "'", " ", - "Podman", "is", "🔟/10", "Hello", "World"} + expected := []string{ + "\a", "\b", "\f", "\n", "\r", "\t", "\v", "\\", "\"", "'", " ", + "Podman", "is", "🔟/10", "Hello", "World", + } next := input for i := range expected { diff --git a/pkg/systemd/quadlet/quadlet_common.go b/pkg/systemd/quadlet/quadlet_common.go index 05087b678e3..768bac83f21 100644 --- a/pkg/systemd/quadlet/quadlet_common.go +++ b/pkg/systemd/quadlet/quadlet_common.go @@ -1,16 +1,14 @@ package quadlet -var ( - // Key: Extension - // Value: Processing order for resource naming dependencies - SupportedExtensions = map[string]int{ - ".artifact": 1, - ".container": 4, - ".volume": 2, - ".kube": 4, - ".network": 2, - ".image": 1, - ".build": 3, - ".pod": 5, - } -) +// Key: Extension +// Value: Processing order for resource naming dependencies +var SupportedExtensions = map[string]int{ + ".artifact": 1, + ".container": 4, + ".volume": 2, + ".kube": 4, + ".network": 2, + ".image": 1, + ".build": 3, + ".pod": 5, +} diff --git a/pkg/trust/trust_test.go b/pkg/trust/trust_test.go index c95b838c046..6c046cf0538 100644 --- a/pkg/trust/trust_test.go +++ b/pkg/trust/trust_test.go @@ -107,7 +107,8 @@ func TestPolicyDescription(t *testing.T) { Type: "signed", SignatureStore: "https://registry.redhat.io/containers/sigstore", GPGId: "redhat, redhat-beta", - }, { + }, + { Transport: "repository", Name: "registry.redhat.io", RepoName: "registry.redhat.io", @@ -261,7 +262,8 @@ func TestDescriptionsOfPolicyRequirements(t *testing.T) { GPGId: "2, 3", }, }, - }, { + }, + { "quay.io/sigstore-signed", signature.PolicyRequirements{ xNewPRSigstoreSignedKeyPath(t, "/1.pub", signature.NewPRMMatchRepoDigestOrExact()), diff --git a/pkg/util/mount_opts.go b/pkg/util/mount_opts.go index ba8388a5763..e20a6334ae5 100644 --- a/pkg/util/mount_opts.go +++ b/pkg/util/mount_opts.go @@ -33,9 +33,7 @@ func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string } func processOptionsInternal(options []string, isTmpfs bool, sourcePath string, getDefaultMountOptions getDefaultMountOptionsFn) ([]string, error) { - var ( - foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ, foundU, foundOverlay, foundIdmap, foundCopy, foundNoSwap, foundNoDereference bool - ) + var foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ, foundU, foundOverlay, foundIdmap, foundCopy, foundNoSwap, foundNoDereference bool recursiveBind := true diff --git a/pkg/util/mount_opts_other.go b/pkg/util/mount_opts_other.go index 18a4c0e4fe3..84d1d701f97 100644 --- a/pkg/util/mount_opts_other.go +++ b/pkg/util/mount_opts_other.go @@ -3,5 +3,5 @@ package util func getDefaultMountOptions(_ string) (opts defaultMountOptions, err error) { - return + return opts, err } diff --git a/pkg/util/utils.go b/pkg/util/utils.go index c7327918c4b..058894d2498 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -1044,8 +1044,10 @@ func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []strin // returns a time format and error. The input is compared to known time formats // or a duration which implies no-duration func ParseInputTime(inputTime string, since bool) (time.Time, error) { - timeFormats := []string{time.RFC3339Nano, time.RFC3339, "2006-01-02T15:04:05", "2006-01-02T15:04:05.999999999", - "2006-01-02Z07:00", "2006-01-02"} + timeFormats := []string{ + time.RFC3339Nano, time.RFC3339, "2006-01-02T15:04:05", "2006-01-02T15:04:05.999999999", + "2006-01-02Z07:00", "2006-01-02", + } // iterate the supported time formats for _, tf := range timeFormats { t, err := time.Parse(tf, inputTime) diff --git a/pkg/util/utils_linux.go b/pkg/util/utils_linux.go index 65a9b2d7139..262004ec873 100644 --- a/pkg/util/utils_linux.go +++ b/pkg/util/utils_linux.go @@ -19,9 +19,7 @@ import ( "golang.org/x/sys/unix" ) -var ( - errNotADevice = errors.New("not a device node") -) +var errNotADevice = errors.New("not a device node") // GetContainerPidInformationDescriptors returns a string slice of all supported // format descriptors of GetContainerPidInformation. diff --git a/test/e2e/artifact_created_test.go b/test/e2e/artifact_created_test.go index c88534ec2f4..c410d3139e2 100644 --- a/test/e2e/artifact_created_test.go +++ b/test/e2e/artifact_created_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("Podman artifact created timestamp", func() { - createArtifactFile := func(size int) (string, error) { artifactFile := filepath.Join(podmanTest.TempDir, RandomString(12)) f, err := os.Create(artifactFile) diff --git a/test/e2e/artifact_test.go b/test/e2e/artifact_test.go index 71fc6c16418..4e82cc05e69 100644 --- a/test/e2e/artifact_test.go +++ b/test/e2e/artifact_test.go @@ -159,7 +159,6 @@ var _ = Describe("Podman artifact", func() { failSession = podmanTest.Podman([]string{"artifact", "add", "--annotation", annotation3, artifact3Name, artifact1File, artifact2File}) failSession.WaitWithDefaultTimeout() Expect(failSession).Should(ExitWithError(125, "Error: duplicate layers org.opencontainers.image.title labels within an artifact not allowed")) - }) It("podman artifact add multiple", func() { diff --git a/test/e2e/attach_test.go b/test/e2e/attach_test.go index 73fff1b92f6..d6be0159ac2 100644 --- a/test/e2e/attach_test.go +++ b/test/e2e/attach_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman attach", func() { - It("podman attach to bogus container", func() { session := podmanTest.Podman([]string{"attach", "foobar"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index f85875cce97..d859fec0055 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -882,7 +882,6 @@ RUN echo hello`, CITEST_IMAGE) inspect = podmanTest.Podman([]string{"image", "inspect", "--format", "{{ .Os }}", "test"}) inspect.WaitWithDefaultTimeout() Expect(inspect.OutputToString()).To(Equal("bar")) - }) It("podman build --os windows flag", func() { @@ -901,7 +900,6 @@ RUN echo hello`, CITEST_IMAGE) inspect = podmanTest.Podman([]string{"image", "inspect", "--format", "{{ .Os }}", "test"}) inspect.WaitWithDefaultTimeout() Expect(inspect.OutputToString()).To(Equal("windows")) - }) It("podman build device test", func() { diff --git a/test/e2e/checkpoint_image_test.go b/test/e2e/checkpoint_image_test.go index bb483053eb4..4adbbc04355 100644 --- a/test/e2e/checkpoint_image_test.go +++ b/test/e2e/checkpoint_image_test.go @@ -15,7 +15,6 @@ import ( ) var _ = Describe("Podman checkpoint", func() { - BeforeEach(func() { SkipIfRootless("checkpoint not supported in rootless mode") // Check if the runtime implements checkpointing. Currently only diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index 6714b128153..d28c15b2a64 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -32,7 +32,6 @@ func getRunString(input []string) []string { } var _ = Describe("Podman checkpoint", func() { - BeforeEach(func() { SkipIfRootless("checkpoint not supported in rootless mode") @@ -247,7 +246,6 @@ var _ = Describe("Podman checkpoint", func() { result.WaitWithDefaultTimeout() Expect(result).Should(ExitCleanly()) Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - }) It("podman checkpoint latest running container", func() { diff --git a/test/e2e/cleanup_test.go b/test/e2e/cleanup_test.go index 0b3ffd39af8..ed8effd5099 100644 --- a/test/e2e/cleanup_test.go +++ b/test/e2e/cleanup_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman container cleanup", func() { - BeforeEach(func() { SkipIfRemote("podman container cleanup is not supported in remote") }) diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go index 1cff91e3104..825db0cb02a 100644 --- a/test/e2e/commit_test.go +++ b/test/e2e/commit_test.go @@ -14,7 +14,6 @@ import ( ) var _ = Describe("Podman commit", func() { - It("podman commit container", func() { _, ec, _ := podmanTest.RunLsContainer("test1") Expect(ec).To(Equal(0)) @@ -347,7 +346,6 @@ var _ = Describe("Podman commit", func() { session = podmanTest.Podman([]string{"run", "foobar.com/test1-image:latest", "cat", "/run/secrets/mysecret"}) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError(1, "can't open '/run/secrets/mysecret': No such file or directory")) - }) It("podman commit should not commit env secret", func() { diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index e4242e56b13..e5a29931d2e 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -781,7 +781,7 @@ func (p *PodmanTestIntegration) RunTopContainer(name string) *PodmanSessionInteg // runs top. If the name passed != "", it will have a name, command args can also be passed in func (p *PodmanTestIntegration) RunTopContainerWithArgs(name string, args []string) *PodmanSessionIntegration { // In proxy environment, some tests need to the --http-proxy=false option (#16684) - var podmanArgs = []string{"run", "--http-proxy=false"} + podmanArgs := []string{"run", "--http-proxy=false"} if name != "" { podmanArgs = append(podmanArgs, "--name", name) } @@ -800,7 +800,7 @@ func (p *PodmanTestIntegration) RunTopContainerWithArgs(name string, args []stri // RunLsContainer runs a simple container in the background that // simply runs ls. If the name passed != "", it will have a name func (p *PodmanTestIntegration) RunLsContainer(name string) (*PodmanSessionIntegration, int, string) { - var podmanArgs = []string{"run"} + podmanArgs := []string{"run"} if name != "" { podmanArgs = append(podmanArgs, "--name", name) } @@ -819,7 +819,7 @@ func (p *PodmanTestIntegration) RunLsContainer(name string) (*PodmanSessionInteg // RunNginxWithHealthCheck runs the alpine nginx container with an optional name and adds a healthcheck into it func (p *PodmanTestIntegration) RunNginxWithHealthCheck(name string) (*PodmanSessionIntegration, string) { - var podmanArgs = []string{"run"} + podmanArgs := []string{"run"} if name != "" { podmanArgs = append(podmanArgs, "--name", name) } @@ -832,7 +832,7 @@ func (p *PodmanTestIntegration) RunNginxWithHealthCheck(name string) (*PodmanSes // RunContainerWithNetworkTest runs the fedoraMinimal curl with the specified network mode. func (p *PodmanTestIntegration) RunContainerWithNetworkTest(mode string) *PodmanSessionIntegration { - var podmanArgs = []string{"run"} + podmanArgs := []string{"run"} if mode != "" { podmanArgs = append(podmanArgs, "--network", mode) } @@ -842,7 +842,7 @@ func (p *PodmanTestIntegration) RunContainerWithNetworkTest(mode string) *Podman } func (p *PodmanTestIntegration) RunLsContainerInPod(name, pod string) (*PodmanSessionIntegration, int, string) { - var podmanArgs = []string{"run", "--pod", pod} + podmanArgs := []string{"run", "--pod", pod} if name != "" { podmanArgs = append(podmanArgs, "--name", name) } @@ -1003,7 +1003,7 @@ func (s *PodmanSessionIntegration) InspectPodArrToJSON() []define.InspectPodData // CreatePod creates a pod with no infra container // it optionally takes a pod name func (p *PodmanTestIntegration) CreatePod(options map[string][]string) (*PodmanSessionIntegration, int, string) { - var args = []string{"pod", "create", "--infra=false", "--share", ""} + args := []string{"pod", "create", "--infra=false", "--share", ""} for k, values := range options { for _, v := range values { args = append(args, k+"="+v) @@ -1016,7 +1016,7 @@ func (p *PodmanTestIntegration) CreatePod(options map[string][]string) (*PodmanS } func (p *PodmanTestIntegration) CreateVolume(options map[string][]string) (*PodmanSessionIntegration, int, string) { - var args = []string{"volume", "create"} + args := []string{"volume", "create"} for k, values := range options { for _, v := range values { args = append(args, k+"="+v) @@ -1379,8 +1379,10 @@ func (p *PodmanTestIntegration) makeOptions(args []string, options PodmanExecOpt podmanOptions = append(podmanOptions, strings.Split(p.StorageOptions, " ")...) if !options.NoCache { - cacheOptions := []string{"--storage-opt", - fmt.Sprintf("%s.imagestore=%s", p.PodmanTest.ImageCacheFS, p.PodmanTest.ImageCacheDir)} + cacheOptions := []string{ + "--storage-opt", + fmt.Sprintf("%s.imagestore=%s", p.PodmanTest.ImageCacheFS, p.PodmanTest.ImageCacheDir), + } podmanOptions = append(cacheOptions, podmanOptions...) } podmanOptions = append(podmanOptions, args...) diff --git a/test/e2e/container_clone_test.go b/test/e2e/container_clone_test.go index 17716227ff6..c19b27b4c4d 100644 --- a/test/e2e/container_clone_test.go +++ b/test/e2e/container_clone_test.go @@ -140,7 +140,6 @@ var _ = Describe("Podman container clone", func() { Expect(cloneInspect).To(ExitCleanly()) cloneData = cloneInspect.InspectContainerToJSON() Expect(cloneData[0].HostConfig).To(HaveField("MemorySwappiness", int64(0))) - }) It("podman container clone in a pod", func() { @@ -248,7 +247,6 @@ var _ = Describe("Podman container clone", func() { clone = podmanTest.Podman([]string{"container", "clone", "-f", run.OutputToString()}) clone.WaitWithDefaultTimeout() Expect(clone).ToNot(ExitCleanly()) - }) It("podman container clone network passing", func() { @@ -302,7 +300,6 @@ var _ = Describe("Podman container clone", func() { session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).Should(ContainSubstring("12=3")) - }) It("podman container clone container with healthcheck", func() { @@ -331,6 +328,5 @@ var _ = Describe("Podman container clone", func() { Expect(parentData.Config.HealthLogDestination).To(Equal(cloneData.Config.HealthLogDestination)) Expect(parentData.Config.HealthMaxLogCount).To(Equal(cloneData.Config.HealthMaxLogCount)) Expect(parentData.Config.HealthMaxLogSize).To(Equal(cloneData.Config.HealthMaxLogSize)) - }) }) diff --git a/test/e2e/container_create_volume_test.go b/test/e2e/container_create_volume_test.go index fc7b9b855bd..a2a44b89ca4 100644 --- a/test/e2e/container_create_volume_test.go +++ b/test/e2e/container_create_volume_test.go @@ -70,7 +70,6 @@ func checkDataVolumeContainer(pTest *PodmanTestIntegration, image, cont, dest, d } var _ = Describe("Podman create data volume", func() { - It("podman create with volume data copy turned off", func() { imgName, volData, volDest := "dataimg", "dummy", "/test" diff --git a/test/e2e/container_iface_name_test.go b/test/e2e/container_iface_name_test.go index fc2b01de6bf..ba43883f533 100644 --- a/test/e2e/container_iface_name_test.go +++ b/test/e2e/container_iface_name_test.go @@ -37,7 +37,6 @@ func createContainersConfFileWithDeviceIfaceName(pTest *PodmanTestIntegration) { } var _ = Describe("Podman container interface name", func() { - It("podman container interface name for bridge network", func() { // Assert that the network interface name inside container for // bridge network is ethX regardless of interface_name setting diff --git a/test/e2e/container_inspect_test.go b/test/e2e/container_inspect_test.go index e2592b9c72b..95832854154 100644 --- a/test/e2e/container_inspect_test.go +++ b/test/e2e/container_inspect_test.go @@ -15,7 +15,6 @@ import ( ) var _ = Describe("Podman container inspect", func() { - It("podman inspect a container for the container manager annotation", func() { const testContainer = "container-inspect-test-1" setup := podmanTest.RunTopContainer(testContainer) diff --git a/test/e2e/containers_conf_test.go b/test/e2e/containers_conf_test.go index 4ddd5f7ec34..314c434c524 100644 --- a/test/e2e/containers_conf_test.go +++ b/test/e2e/containers_conf_test.go @@ -20,7 +20,6 @@ import ( ) var _ = Describe("Verify podman containers.conf usage", func() { - BeforeEach(func() { confPath, err := filepath.Abs("config/containers.conf") Expect(err).ToNot(HaveOccurred()) @@ -28,7 +27,6 @@ var _ = Describe("Verify podman containers.conf usage", func() { if IsRemote() { podmanTest.RestartRemoteService() } - }) It("limits test", func() { @@ -55,7 +53,6 @@ var _ = Describe("Verify podman containers.conf usage", func() { } else { Expect(session.OutputToString()).To(Not(Equal("500"))) } - }) It("oom-score-adj", func() { @@ -85,9 +82,7 @@ var _ = Describe("Verify podman containers.conf usage", func() { } else { Expect(session.OutputToString()).To(ContainSubstring("0")) } - } - }) It("cgroup_conf in containers.conf", func() { @@ -812,7 +807,6 @@ var _ = Describe("Verify podman containers.conf usage", func() { } It("podman containers.conf container_name_as_hostname", func() { - // With default containers.conf // Start container with no options diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go index 223cc1907b4..3000a54ee07 100644 --- a/test/e2e/cp_test.go +++ b/test/e2e/cp_test.go @@ -19,7 +19,6 @@ import ( // rather than e2e tests. System tests are used in RHEL gating. var _ = Describe("Podman cp", func() { - // Copy a file to the container, then back to the host and make sure // that the contents match. It("podman cp file", func() { diff --git a/test/e2e/create_staticip_test.go b/test/e2e/create_staticip_test.go index c2a038a5991..5d414ce14d9 100644 --- a/test/e2e/create_staticip_test.go +++ b/test/e2e/create_staticip_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman create with --ip flag", func() { - It("Podman create --ip with garbage address", func() { result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", "114232346", ALPINE, "ls"}) result.WaitWithDefaultTimeout() diff --git a/test/e2e/create_staticmac_test.go b/test/e2e/create_staticmac_test.go index cbcf905864c..92291c0a418 100644 --- a/test/e2e/create_staticmac_test.go +++ b/test/e2e/create_staticmac_test.go @@ -10,7 +10,6 @@ import ( ) var _ = Describe("Podman run with --mac-address flag", func() { - It("Podman run --mac-address", func() { result := podmanTest.Podman([]string{"run", "--mac-address", "92:d0:c6:0a:29:34", ALPINE, "ip", "addr"}) result.WaitWithDefaultTimeout() diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index f610f768189..4eb42140de0 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -18,7 +18,6 @@ import ( ) var _ = Describe("Podman create", func() { - It("podman create container based on a local image", func() { session := podmanTest.Podman([]string{"create", "--name", "local_image_test", ALPINE, "ls"}) session.WaitWithDefaultTimeout() @@ -687,7 +686,6 @@ var _ = Describe("Podman create", func() { create.WaitWithDefaultTimeout() Expect(create).ShouldNot(ExitCleanly()) Expect(create.ErrorToString()).To(ContainSubstring("cannot specify a new uid/gid map when entering a pod with an infra container")) - }) It("podman create --chrootdirs inspection test", func() { diff --git a/test/e2e/diff_test.go b/test/e2e/diff_test.go index e2570400112..ce2904737f6 100644 --- a/test/e2e/diff_test.go +++ b/test/e2e/diff_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("Podman diff", func() { - It("podman diff of image", func() { session := podmanTest.Podman([]string{"diff", ALPINE}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go index 236120a86aa..f3e9243e617 100644 --- a/test/e2e/events_test.go +++ b/test/e2e/events_test.go @@ -17,7 +17,6 @@ import ( ) var _ = Describe("Podman events", func() { - // For most, all, of these tests we do not "live" test following a log because it may make a fragile test // system more complex. Instead we run the "events" and then verify that the events are processed correctly. // Perhaps a future version of this test would put events in a go func and send output back over a channel @@ -308,5 +307,4 @@ var _ = Describe("Podman events", func() { Expect(result).Should(ExitCleanly()) Expect(result.OutputToStringArray()).ToNot(BeEmpty(), "Number of health_status events") }) - }) diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index 15df46fc3aa..d3d43da33bd 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -15,7 +15,6 @@ import ( ) var _ = Describe("Podman exec", func() { - It("podman exec into bogus container", func() { session := podmanTest.Podman([]string{"exec", "foobar", "ls"}) session.WaitWithDefaultTimeout() @@ -195,7 +194,6 @@ var _ = Describe("Podman exec", func() { session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(bndPerms)) - }) It("podman exec --privileged", func() { diff --git a/test/e2e/exists_test.go b/test/e2e/exists_test.go index ff9022ff5f9..20799413e49 100644 --- a/test/e2e/exists_test.go +++ b/test/e2e/exists_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman image|container exists", func() { - It("podman image exists in local storage by fq name", func() { session := podmanTest.Podman([]string{"image", "exists", ALPINE}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/export_test.go b/test/e2e/export_test.go index 2d199d95323..7960491b07a 100644 --- a/test/e2e/export_test.go +++ b/test/e2e/export_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman export", func() { - It("podman export output flag", func() { _, ec, cid := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) diff --git a/test/e2e/farm_test.go b/test/e2e/farm_test.go index c9944e75c57..a953210dc06 100644 --- a/test/e2e/farm_test.go +++ b/test/e2e/farm_test.go @@ -31,7 +31,6 @@ func setupContainersConfWithSystemConnections() { } var _ = Describe("podman farm", func() { - BeforeEach(setupContainersConfWithSystemConnections) Context("without running API service", func() { diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go index 909c49d6b3e..bc3fd5fe4e3 100644 --- a/test/e2e/generate_kube_test.go +++ b/test/e2e/generate_kube_test.go @@ -21,7 +21,6 @@ import ( ) var _ = Describe("Podman kube generate", func() { - It("pod on bogus object", func() { session := podmanTest.Podman([]string{"generate", "kube", "foobarpod"}) session.WaitWithDefaultTimeout() @@ -90,7 +89,6 @@ var _ = Describe("Podman kube generate", func() { err = yaml.Unmarshal(kube.Out.Contents(), pod) Expect(err).ToNot(HaveOccurred()) Expect(kube.OutputToString()).To(ContainSubstring("type: spc_t")) - }) It("service kube on container with --security-opt type", func() { @@ -353,7 +351,8 @@ var _ = Describe("Podman kube generate", func() { It("on pod with hostAliases", func() { podName := "testHost" testIP := "127.0.0.1" - podSession := podmanTest.Podman([]string{"pod", "create", "--name", podName, + podSession := podmanTest.Podman([]string{ + "pod", "create", "--name", podName, "--add-host", "test1.podman.io" + ":" + testIP, "--add-host", "test2.podman.io" + ":" + testIP, }) @@ -511,7 +510,7 @@ var _ = Describe("Podman kube generate", func() { }) It("on pod with restartPolicy set for container in a pod", func() { - //TODO: v5.0 - change/remove test once we block --restart on container when it is in a pod + // TODO: v5.0 - change/remove test once we block --restart on container when it is in a pod // podName, set, expect testSli := [][]string{ {"testPod1", "", ""}, // some pod create from cmdline, so set it to an empty string and let k8s default it to Always @@ -529,8 +528,10 @@ var _ = Describe("Podman kube generate", func() { Expect(podSession).Should(ExitCleanly()) ctrName := "ctr" + strconv.Itoa(k) - ctr1Session := podmanTest.Podman([]string{"create", "--name", ctrName, "--pod", podName, - "--restart", v[1], CITEST_IMAGE, "top"}) + ctr1Session := podmanTest.Podman([]string{ + "create", "--name", ctrName, "--pod", podName, + "--restart", v[1], CITEST_IMAGE, "top", + }) ctr1Session.WaitWithDefaultTimeout() Expect(ctr1Session).Should(ExitCleanly()) @@ -641,14 +642,18 @@ var _ = Describe("Podman kube generate", func() { Expect(podSession).Should(ExitCleanly()) ctr1Name := "ctr1" - ctr1Session := podmanTest.Podman([]string{"create", "--name", ctr1Name, "--pod", podName, - "--cpus", "0.5", CITEST_IMAGE, "top"}) + ctr1Session := podmanTest.Podman([]string{ + "create", "--name", ctr1Name, "--pod", podName, + "--cpus", "0.5", CITEST_IMAGE, "top", + }) ctr1Session.WaitWithDefaultTimeout() Expect(ctr1Session).Should(ExitCleanly()) ctr2Name := "ctr2" - ctr2Session := podmanTest.Podman([]string{"create", "--name", ctr2Name, "--pod", podName, - "--cpu-period", "100000", "--cpu-quota", "50000", CITEST_IMAGE, "top"}) + ctr2Session := podmanTest.Podman([]string{ + "create", "--name", ctr2Name, "--pod", podName, + "--cpu-period", "100000", "--cpu-quota", "50000", CITEST_IMAGE, "top", + }) ctr2Session.WaitWithDefaultTimeout() Expect(ctr2Session).Should(ExitCleanly()) @@ -905,10 +910,12 @@ var _ = Describe("Podman kube generate", func() { // Fixes https://github.com/containers/podman/issues/9764 ctrName := "mount-root-ctr" - session1 := podmanTest.Podman([]string{"run", "-d", "--pod", "new:mount-root-conflict", "--name", ctrName, + session1 := podmanTest.Podman([]string{ + "run", "-d", "--pod", "new:mount-root-conflict", "--name", ctrName, "-v", "/:/volume1/", "-v", "/root:/volume2/", - CITEST_IMAGE, "top"}) + CITEST_IMAGE, "top", + }) session1.WaitWithDefaultTimeout() Expect(session1).Should(ExitCleanly()) @@ -921,7 +928,6 @@ var _ = Describe("Podman kube generate", func() { Expect(err).ToNot(HaveOccurred()) Expect(pod.Spec.Volumes).To(HaveLen(2)) - }) It("with persistent volume claim", func() { @@ -1418,10 +1424,12 @@ USER test1` ctrName := "gen-kube-env-ctr" podName := "gen-kube-env" // In proxy environment, this test needs to the --http-proxy=false option (#16684) - session1 := podmanTest.Podman([]string{"run", "-d", "--http-proxy=false", "--pod", "new:" + podName, "--name", ctrName, + session1 := podmanTest.Podman([]string{ + "run", "-d", "--http-proxy=false", "--pod", "new:" + podName, "--name", ctrName, "-e", "FOO=bar", "-e", "HELLO=WORLD", - CITEST_IMAGE, "top"}) + CITEST_IMAGE, "top", + }) session1.WaitWithDefaultTimeout() Expect(session1).Should(ExitCleanly()) diff --git a/test/e2e/generate_spec_test.go b/test/e2e/generate_spec_test.go index f078e5e60b7..aebb364913b 100644 --- a/test/e2e/generate_spec_test.go +++ b/test/e2e/generate_spec_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman generate spec", func() { - BeforeEach(func() { SkipIfRemote("podman generate spec is not supported on the remote client") }) @@ -50,7 +49,6 @@ var _ = Describe("Podman generate spec", func() { exec.WaitWithDefaultTimeout() Expect(exec.OutputToString()).Should(ContainSubstring("specgen-clone")) Expect(exec.OutputToString()).Should(ContainSubstring("500000")) - }) It("generate spec pod", func() { diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go index 0e4376a3918..1d2202914ac 100644 --- a/test/e2e/generate_systemd_test.go +++ b/test/e2e/generate_systemd_test.go @@ -14,7 +14,6 @@ import ( ) var _ = Describe("Podman generate systemd", func() { - It("podman generate systemd on bogus container/pod", func() { session := podmanTest.Podman([]string{"generate", "systemd", "foobar"}) session.WaitWithDefaultTimeout() @@ -167,7 +166,8 @@ var _ = Describe("Podman generate systemd", func() { "generate", "systemd", "--wants", "foobar.service", "--wants", "barfoo.service", "--after", "foobar.service", "--after", "barfoo.service", - "--requires", "foobar.service", "--requires", "barfoo.service", "nginx"}) + "--requires", "foobar.service", "--requires", "barfoo.service", "nginx", + }) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) @@ -285,7 +285,8 @@ var _ = Describe("Podman generate systemd", func() { "generate", "systemd", "--name", "--wants", "foobar.service", "--wants", "barfoo.service", "--after", "foobar.service", "--after", "barfoo.service", - "--requires", "foobar.service", "--requires", "barfoo.service", "foo"}) + "--requires", "foobar.service", "--requires", "barfoo.service", "foo", + }) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) @@ -420,7 +421,6 @@ var _ = Describe("Podman generate systemd", func() { // Grepping the output (in addition to unit tests) Expect(session.OutputToString()).To(ContainSubstring("# con-foo.service")) - }) It("podman generate systemd --container-prefix ''", func() { @@ -434,7 +434,6 @@ var _ = Describe("Podman generate systemd", func() { // Grepping the output (in addition to unit tests) Expect(session.OutputToString()).To(ContainSubstring("# foo.service")) - }) It("podman generate systemd --separator _", func() { @@ -534,7 +533,6 @@ var _ = Describe("Podman generate systemd", func() { Expect(session2.OutputToString()).To(ContainSubstring("# foo-1.service")) Expect(session2.OutputToString()).To(ContainSubstring("# foo-2.service")) Expect(session2.OutputToString()).To(ContainSubstring("BindsTo=foo.service")) - }) It("podman generate systemd pod with containers --new", func() { diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go index 56f2697d0be..bdc677e9b76 100644 --- a/test/e2e/healthcheck_run_test.go +++ b/test/e2e/healthcheck_run_test.go @@ -16,7 +16,6 @@ import ( ) var _ = Describe("Podman healthcheck run", func() { - It("podman healthcheck run bogus container", func() { session := podmanTest.Podman([]string{"healthcheck", "run", "foobar"}) session.WaitWithDefaultTimeout() @@ -57,9 +56,11 @@ var _ = Describe("Podman healthcheck run", func() { }) It("podman run healthcheck and logs should contain healthcheck output", func() { - session := podmanTest.Podman([]string{"run", "--name", "test-logs", "-dt", "--health-interval", "1s", + session := podmanTest.Podman([]string{ + "run", "--name", "test-logs", "-dt", "--health-interval", "1s", // echo -n is important for https://github.com/containers/podman/issues/23332 - "--health-cmd", "echo -n working", ALPINE, "sleep", "3600"}) + "--health-cmd", "echo -n working", ALPINE, "sleep", "3600", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) diff --git a/test/e2e/history_test.go b/test/e2e/history_test.go index 66b987c70b5..872f3ec6daa 100644 --- a/test/e2e/history_test.go +++ b/test/e2e/history_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman history", func() { - It("podman history output flag", func() { session := podmanTest.Podman([]string{"history", ALPINE}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/image_scp_test.go b/test/e2e/image_scp_test.go index c673f4a15e8..6c96e1627d0 100644 --- a/test/e2e/image_scp_test.go +++ b/test/e2e/image_scp_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("podman image scp", func() { - BeforeEach(setupConnectionsConf) It("podman image scp bogus image", func() { @@ -31,7 +30,8 @@ var _ = Describe("podman image scp", func() { ensureImage.WaitWithDefaultTimeout() Expect(ensureImage).Should(ExitCleanly()) - cmd := []string{"system", "connection", "add", + cmd := []string{ + "system", "connection", "add", "--default", "QA", "ssh://root@podman.test:2222/run/podman/podman.sock", @@ -47,5 +47,4 @@ var _ = Describe("podman image scp", func() { // The error given should either be a missing image (due to testing suite complications) or a no such host timeout on ssh Expect(scp).Should(ExitWithError(125, "failed to connect: dial tcp: lookup ")) }) - }) diff --git a/test/e2e/image_sign_test.go b/test/e2e/image_sign_test.go index 8ed437b8a38..21ab46b2a4a 100644 --- a/test/e2e/image_sign_test.go +++ b/test/e2e/image_sign_test.go @@ -27,7 +27,6 @@ var _ = Describe("Podman image sign", Serial, func() { origGNUPGHOME = os.Getenv("GNUPGHOME") err = os.Setenv("GNUPGHOME", tempGNUPGHOME) Expect(err).ToNot(HaveOccurred()) - }) AfterEach(func() { diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 41698d55fab..54db7f42173 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -15,7 +15,6 @@ import ( ) var _ = Describe("Podman images", func() { - It("podman images", func() { session := podmanTest.Podman([]string{"images"}) session.WaitWithDefaultTimeout() @@ -474,7 +473,6 @@ RUN > file2 // check if really abc is removed result = podmanTest.Podman([]string{"image", "list", "--filter", "label=abc"}) Expect(result.OutputToStringArray()).To(BeEmpty()) - }) It("podman builder prune", func() { @@ -495,7 +493,6 @@ RUN > file2 // check if really abc is removed result = podmanTest.Podman([]string{"image", "list", "--filter", "label=abc"}) Expect(result.OutputToStringArray()).To(BeEmpty()) - }) It("podman images filter should be AND logic", func() { @@ -546,5 +543,4 @@ LABEL xyz="bar" Expect(session.OutputToStringArray()).To(HaveLen(2)) Expect(session.OutputToString()).To(ContainSubstring("test-abc-xyz")) }) - }) diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go index b443aea85b8..fdaae33a8a4 100644 --- a/test/e2e/import_test.go +++ b/test/e2e/import_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman import", func() { - It("podman import with source and reference", func() { outfile := filepath.Join(podmanTest.TempDir, "container.tar") _, ec, cid := podmanTest.RunLsContainer("") diff --git a/test/e2e/init_test.go b/test/e2e/init_test.go index 49dfe0873b7..9f1b0a09146 100644 --- a/test/e2e/init_test.go +++ b/test/e2e/init_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Podman init", func() { - It("podman init bogus container", func() { session := podmanTest.Podman([]string{"start", "123456"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go index 94828cb1f88..52ad61270ba 100644 --- a/test/e2e/inspect_test.go +++ b/test/e2e/inspect_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman inspect", func() { - It("podman inspect alpine image", func() { session := podmanTest.Podman([]string{"inspect", "--format=json", ALPINE}) session.WaitWithDefaultTimeout() @@ -135,7 +134,6 @@ var _ = Describe("Podman inspect", func() { }) It("podman inspect with mount filters", func() { - ctrSession := podmanTest.Podman([]string{"create", "--name", "test", "-v", "/tmp:/test1", ALPINE, "top"}) ctrSession.WaitWithDefaultTimeout() Expect(ctrSession).Should(ExitCleanly()) @@ -276,7 +274,8 @@ var _ = Describe("Podman inspect", func() { "--security-opt", "seccomp=unconfined", "--security-opt", "label=type:spc_t", "--security-opt", "label=level:s0", - ALPINE, "sh"}) + ALPINE, "sh", + }) create.WaitWithDefaultTimeout() Expect(create).Should(ExitCleanly()) @@ -638,5 +637,4 @@ var _ = Describe("Podman inspect", func() { rm.WaitWithDefaultTimeout() Expect(rm).Should(ExitCleanly()) }) - }) diff --git a/test/e2e/kill_test.go b/test/e2e/kill_test.go index ed463c45386..7c8a4a7f8db 100644 --- a/test/e2e/kill_test.go +++ b/test/e2e/kill_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Podman kill", func() { - It("podman kill bogus container", func() { session := podmanTest.Podman([]string{"kill", "foobar"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index 5ec118d30f6..e1bdee3a21e 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("Podman load", func() { - BeforeEach(func() { podmanTest.AddImageToRWStore(ALPINE) }) diff --git a/test/e2e/login_logout_test.go b/test/e2e/login_logout_test.go index 2187e2e67d1..d4788b75682 100644 --- a/test/e2e/login_logout_test.go +++ b/test/e2e/login_logout_test.go @@ -59,12 +59,14 @@ var _ = Describe("Podman login and logout", func() { setup := SystemExec("cp", []string{filepath.Join(certPath, "domain.crt"), filepath.Join(certDirPath, "ca.crt")}) setup.WaitWithDefaultTimeout() - session := podmanTest.Podman([]string{"run", "-d", "-p", strings.Join([]string{strconv.Itoa(port), strconv.Itoa(port)}, ":"), + session := podmanTest.Podman([]string{ + "run", "-d", "-p", strings.Join([]string{strconv.Itoa(port), strconv.Itoa(port)}, ":"), "-e", strings.Join([]string{"REGISTRY_HTTP_ADDR=0.0.0.0", strconv.Itoa(port)}, ":"), "--name", "registry", "-v", strings.Join([]string{authPath, "/auth:Z"}, ":"), "-e", "REGISTRY_AUTH=htpasswd", "-e", "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm", "-e", "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd", "-v", strings.Join([]string{certPath, "/certs:Z"}, ":"), "-e", "REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt", - "-e", "REGISTRY_HTTP_TLS_KEY=/certs/domain.key", REGISTRY_IMAGE}) + "-e", "REGISTRY_HTTP_TLS_KEY=/certs/domain.key", REGISTRY_IMAGE, + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -214,8 +216,10 @@ var _ = Describe("Podman login and logout", func() { err = os.WriteFile(compatAuthFile, []byte("{}"), 0o700) Expect(err).ToNot(HaveOccurred()) - session = podmanTest.Podman([]string{"login", "--username", "podmantest", "--password", "test", - "--authfile", authFile, "--compat-auth-file", compatAuthFile, server}) + session = podmanTest.Podman([]string{ + "login", "--username", "podmantest", "--password", "test", + "--authfile", authFile, "--compat-auth-file", compatAuthFile, server, + }) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError(125, "options for paths to the credential file and to the Docker-compatible credential file can not be set simultaneously")) @@ -308,11 +312,13 @@ var _ = Describe("Podman login and logout", func() { // N/B: This second registry container shares the same auth and cert dirs // as the registry started from BeforeEach(). Since this one starts // second, re-labeling the volumes should keep SELinux happy. - session := podmanTest.Podman([]string{"run", "-d", "-p", "9001:9001", "-e", "REGISTRY_HTTP_ADDR=0.0.0.0:9001", "--name", "registry1", "-v", + session := podmanTest.Podman([]string{ + "run", "-d", "-p", "9001:9001", "-e", "REGISTRY_HTTP_ADDR=0.0.0.0:9001", "--name", "registry1", "-v", strings.Join([]string{authPath, "/auth:z"}, ":"), "-e", "REGISTRY_AUTH=htpasswd", "-e", "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm", "-e", "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd", "-v", strings.Join([]string{certPath, "/certs:z"}, ":"), "-e", "REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt", - "-e", "REGISTRY_HTTP_TLS_KEY=/certs/domain.key", REGISTRY_IMAGE}) + "-e", "REGISTRY_HTTP_TLS_KEY=/certs/domain.key", REGISTRY_IMAGE, + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -426,7 +432,6 @@ var _ = Describe("Podman login and logout", func() { }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - }) It("podman login and logout with repository with fallback", func() { diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index 4427c62cbfb..39f62acd8ca 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -27,7 +27,6 @@ func isEventBackendJournald(podmanTest *PodmanTestIntegration) bool { } var _ = Describe("Podman logs", func() { - It("podman logs on not existent container", func() { results := podmanTest.Podman([]string{"logs", "notexist"}) results.WaitWithDefaultTimeout() diff --git a/test/e2e/manifest_test.go b/test/e2e/manifest_test.go index 8ed6c9955ad..718698d7315 100644 --- a/test/e2e/manifest_test.go +++ b/test/e2e/manifest_test.go @@ -72,7 +72,6 @@ func verifyInstanceCompression(descriptor []imgspecv1.Descriptor, compression st } var _ = Describe("Podman manifest", func() { - const ( imageList = "docker://quay.io/libpod/testimage:00000004" imageListInstance = "docker://quay.io/libpod/testimage@sha256:1385ce282f3a959d0d6baf45636efe686c1e14c3e7240eb31907436f7bc531fa" diff --git a/test/e2e/mount_rootless_test.go b/test/e2e/mount_rootless_test.go index a56bf960b27..04d30ecb0ba 100644 --- a/test/e2e/mount_rootless_test.go +++ b/test/e2e/mount_rootless_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Podman mount", func() { - BeforeEach(func() { SkipIfNotRootless("This function is not enabled for rootful podman") SkipIfRemote("Podman mount not supported for remote connections") diff --git a/test/e2e/mount_test.go b/test/e2e/mount_test.go index 46eed8df5d2..e02bd2f04c7 100644 --- a/test/e2e/mount_test.go +++ b/test/e2e/mount_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman mount", func() { - BeforeEach(func() { SkipIfRemote("Podman mount not supported for remote connections") SkipIfRootless("Podman mount requires podman unshare first to work") @@ -169,7 +168,6 @@ var _ = Describe("Podman mount", func() { }) It("podman list running container", func() { - setup := podmanTest.Podman([]string{"run", "-dt", ALPINE, "top"}) setup.WaitWithDefaultTimeout() Expect(setup).Should(ExitCleanly()) @@ -189,7 +187,6 @@ var _ = Describe("Podman mount", func() { }) It("podman list multiple mounted containers", func() { - setup := podmanTest.Podman([]string{"create", ALPINE, "ls"}) setup.WaitWithDefaultTimeout() Expect(setup).Should(ExitCleanly()) @@ -229,11 +226,9 @@ var _ = Describe("Podman mount", func() { lmount.WaitWithDefaultTimeout() Expect(lmount).Should(ExitCleanly()) Expect(lmount.OutputToString()).To(Equal("")) - }) It("podman list mounted container", func() { - setup := podmanTest.Podman([]string{"create", ALPINE, "ls"}) setup.WaitWithDefaultTimeout() Expect(setup).Should(ExitCleanly()) diff --git a/test/e2e/negative_test.go b/test/e2e/negative_test.go index a06d557a2a3..0b344a8704f 100644 --- a/test/e2e/negative_test.go +++ b/test/e2e/negative_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Podman negative command-line", func() { - It("podman snuffleupagus exits non-zero", func() { session := podmanTest.Podman([]string{"snuffleupagus"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/network_connect_disconnect_test.go b/test/e2e/network_connect_disconnect_test.go index ed733f7f1ba..301f6b82027 100644 --- a/test/e2e/network_connect_disconnect_test.go +++ b/test/e2e/network_connect_disconnect_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("Podman network connect and disconnect", func() { - It("bad network name in disconnect should result in error", func() { dis := podmanTest.Podman([]string{"network", "disconnect", "foobar", "test"}) dis.WaitWithDefaultTimeout() diff --git a/test/e2e/network_create_test.go b/test/e2e/network_create_test.go index 6a7344530b6..e48d3c0c036 100644 --- a/test/e2e/network_create_test.go +++ b/test/e2e/network_create_test.go @@ -22,7 +22,6 @@ func removeNetworkDevice(name string) { } var _ = Describe("Podman network create", func() { - It("podman network create with name and subnet", func() { netName := "subnet-" + stringid.GenerateRandomID() nc := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.12.0/24", "--ip-range", "10.11.12.0/26", netName}) @@ -104,7 +103,6 @@ var _ = Describe("Podman network create", func() { // Once a container executes a new network, the nic will be created. We should clean those up // best we can defer removeNetworkDevice(result.NetworkInterface) - }) It("podman network create with name and subnet and static route and metric", func() { @@ -145,7 +143,6 @@ var _ = Describe("Podman network create", func() { // Once a container executes a new network, the nic will be created. We should clean those up // best we can defer removeNetworkDevice(result.NetworkInterface) - }) It("podman network create with name and subnet and two static routes", func() { @@ -192,7 +189,6 @@ var _ = Describe("Podman network create", func() { // Once a container executes a new network, the nic will be created. We should clean those up // best we can defer removeNetworkDevice(result.NetworkInterface) - }) It("podman network create with name and subnet and static route (ipv6)", func() { @@ -233,7 +229,6 @@ var _ = Describe("Podman network create", func() { // Once a container executes a new network, the nic will be created. We should clean those up // best we can defer removeNetworkDevice(result.NetworkInterface) - }) It("podman network create with name and subnet with --opt no_default_route=1", func() { @@ -272,7 +267,6 @@ var _ = Describe("Podman network create", func() { // Once a container executes a new network, the nic will be created. We should clean those up // best we can defer removeNetworkDevice(result.NetworkInterface) - }) It("podman network create with name and IPv6 subnet", func() { @@ -441,7 +435,6 @@ var _ = Describe("Podman network create", func() { nc = podmanTest.Podman([]string{"network", "create", "--gateway", "10.11.12.256"}) nc.WaitWithDefaultTimeout() Expect(nc).To(ExitWithError(125, `invalid argument "10.11.12.256" for "--gateway" flag: invalid string being converted to IP address: 10.11.12.256`)) - }) It("podman network create with invalid gateway for subnet", func() { diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index 0ef04303dce..1648e8c5ce3 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -18,7 +18,6 @@ import ( ) var _ = Describe("Podman network", func() { - It("podman --cni-config-dir backwards compat", func() { SkipIfRemote("--cni-config-dir only works locally") netDir := filepath.Join(podmanTest.TempDir, "networks123") @@ -211,7 +210,6 @@ var _ = Describe("Podman network", func() { session := podmanTest.Podman([]string{"network", rm}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitWithError(125, "requires at least 1 arg(s), only received 0")) - }) It(fmt.Sprintf("podman network %s", rm), func() { diff --git a/test/e2e/pause_test.go b/test/e2e/pause_test.go index 457d5dfee55..c70b6f95838 100644 --- a/test/e2e/pause_test.go +++ b/test/e2e/pause_test.go @@ -32,7 +32,6 @@ var _ = Describe("Podman pause", func() { Skip("freezer controller not available on the current kernel") } } - }) It("podman pause bogus container", func() { @@ -110,7 +109,6 @@ var _ = Describe("Podman pause", func() { Expect(result).Should(ExitWithError(125, fmt.Sprintf(`"%s" is not paused, can't unpause: container state improper`, cid))) Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) - }) It("podman remove a paused container by id without force", func() { @@ -194,7 +192,6 @@ var _ = Describe("Podman pause", func() { result.WaitWithDefaultTimeout() Expect(result).Should(ExitCleanly()) Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - }) It("podman pause a running container by name", func() { @@ -246,7 +243,6 @@ var _ = Describe("Podman pause", func() { result.WaitWithDefaultTimeout() Expect(result).Should(ExitCleanly()) Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - }) It("Unpause all containers (no paused containers exist)", func() { diff --git a/test/e2e/play_build_test.go b/test/e2e/play_build_test.go index d1551629ec8..60658402056 100644 --- a/test/e2e/play_build_test.go +++ b/test/e2e/play_build_test.go @@ -15,8 +15,7 @@ import ( ) var _ = Describe("Podman play kube with build", func() { - - var testYAML = ` + testYAML := ` apiVersion: v1 kind: Pod metadata: @@ -49,17 +48,17 @@ spec: status: {} ` - var playBuildFile = ` + playBuildFile := ` FROM ` + CITEST_IMAGE + ` LABEL homer=dad COPY copyfile /copyfile ` - var prebuiltImage = ` + prebuiltImage := ` FROM ` + CITEST_IMAGE + ` LABEL marge=mom ` - var copyFile = `just a text file + copyFile := `just a text file ` It("Check that image is built using Dockerfile", func() { @@ -286,7 +285,7 @@ LABEL marge=mom Expect(inspectData[0].Config.Labels).To(Not(HaveKey("marge"))) }) - var testYAMLForEnvExpand = ` + testYAMLForEnvExpand := ` apiVersion: v1 kind: Pod metadata: diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index ae2a34e11ac..49da5b69c09 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -399,6 +399,7 @@ spec: shareProcessNamespace: true status: {} ` + var livenessProbePodYaml = ` apiVersion: apps/v1 kind: Deployment @@ -431,6 +432,7 @@ spec: initialDelaySeconds: 5 periodSeconds: 5 ` + var livenessProbeUnhealthyPodYaml = ` apiVersion: apps/v1 kind: Deployment @@ -966,6 +968,7 @@ spec: {{ end }} {{ end }} ` + var deploymentYamlTemplate = ` apiVersion: v1 kind: Deployment @@ -3638,7 +3641,6 @@ spec: inspect.WaitWithDefaultTimeout() Expect(inspect).Should(ExitCleanly()) Expect(inspect.OutputToString()).To(ContainSubstring(strings.Join(defaultCtrCmd, " "))) - }) It("job sanity", func() { @@ -3701,7 +3703,6 @@ spec: inspect.WaitWithDefaultTimeout() Expect(inspect).Should(ExitCleanly()) Expect(inspect.OutputToString()).To(Equal(macs[i])) - }) It("with multiple networks", func() { @@ -3965,7 +3966,6 @@ VOLUME %s`, CITEST_IMAGE, hostPathDir+"/") ctrJSON := inspect.InspectContainerToJSON() Expect(ctrJSON[0].Mounts).To(HaveLen(1)) Expect(ctrJSON[0].Mounts[0]).To(HaveField("Type", define.TypeBind)) - }) It("test with PersistentVolumeClaim volume", func() { @@ -4223,7 +4223,6 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`) Expect(inspect.OutputToString()).To(ContainSubstring(fmt.Sprintf("%s: %d", "CpuQuota", expectedCPUQuota))) Expect(inspect.OutputToString()).To(ContainSubstring("MemoryReservation: " + expectedMemoryRequest)) Expect(inspect.OutputToString()).To(ContainSubstring("Memory: " + expectedMemoryLimit)) - }) It("allows setting resource limits with --cpus 1", func() { @@ -4231,9 +4230,7 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`) SkipIfRootless("CPU limits require root") podmanTest.CgroupManager = "systemd" - var ( - expectedCPULimit = "1" - ) + expectedCPULimit := "1" deployment := getDeployment( withPod(getPod(withCtr(getCtr( @@ -4250,7 +4247,6 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`) Expect(parts).To(HaveLen(2)) Expect(parts[0]).To(Equal(parts[1])) - }) It("reports invalid image name", func() { @@ -4505,7 +4501,8 @@ spec: // add services yamlDocs = append([]string{ fmt.Sprintf(serviceTemplate, podName, podName), - fmt.Sprintf(serviceTemplate, deploymentPodName, deploymentPodName)}, yamlDocs...) + fmt.Sprintf(serviceTemplate, deploymentPodName, deploymentPodName), + }, yamlDocs...) // add pods k, err := getKubeYaml("pod", pod) @@ -4669,7 +4666,6 @@ invalid kube kind }) It("teardown volume --force", func() { - volName := RandomString(12) volDevice := define.TypeTmpfs volType := define.TypeTmpfs @@ -4699,7 +4695,6 @@ invalid kube kind }) It("after teardown with volume reuse", func() { - volName := RandomString(12) volDevice := define.TypeTmpfs volType := define.TypeTmpfs @@ -4939,7 +4934,6 @@ ENV OPENJ9_JAVA_OPTIONS=%q podmanTest.PodmanExitCleanly("kube", "play", kubeYaml) inspect := podmanTest.PodmanExitCleanly("inspect", fmt.Sprintf("%s-%s-%s", deployment.Name, "pod", defaultCtrName), "--format", "'{{ .Config }}'") Expect(inspect.OutputToString()).To(ContainSubstring(`FOO=foo`)) - }) It("uses env value from configmap for HTTP API client", func() { @@ -5355,7 +5349,6 @@ ENV OPENJ9_JAVA_OPTIONS=%q exec = podmanTest.PodmanExitCleanly("exec", "mypod2-myctr", "cat", "/etc/baz/plain_note") Expect(exec.OutputToString()).Should(ContainSubstring("This is a test")) - }) It("secret as volume support - optional field", func() { @@ -5413,7 +5406,6 @@ ENV OPENJ9_JAVA_OPTIONS=%q secretData = podmanTest.Podman([]string{"exec", getCtrNameInPod(pod), "cat", "/test/FOO"}) secretData.WaitWithDefaultTimeout() Expect(secretData).Should(Not(ExitCleanly())) - }) It("secret as volume with defaultMode set", func() { @@ -5601,7 +5593,6 @@ spec: }) It("with graceful shutdown", func() { - podmanTest.PodmanExitCleanly("volume", "create", "testvol") err = writeYaml(signalTest, kubeYaml) Expect(err).ToNot(HaveOccurred()) @@ -6071,7 +6062,6 @@ spec: podmanTest.PodmanExitCleanly("kube", "play", outputFile) inspect := podmanTest.PodmanExitCleanly("inspect", "-f", "{{ .HostConfig.ContainerIDFile }}", ctrNameInKubePod) Expect(inspect.OutputToString()).To(Equal(cidFile)) - }) It("test with reserved Seccomp annotation in yaml", func() { @@ -6333,7 +6323,6 @@ spec: }) It("test Lifecycle stopSignal", func() { - // Default StopSignal SIGTERM err = writeYaml(simplePodYaml, kubeYaml) Expect(err).ToNot(HaveOccurred()) diff --git a/test/e2e/pod_clone_test.go b/test/e2e/pod_clone_test.go index a1e3afc7f86..a7633b494c7 100644 --- a/test/e2e/pod_clone_test.go +++ b/test/e2e/pod_clone_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Podman pod clone", func() { - hostname, _ := os.Hostname() BeforeEach(func() { @@ -82,7 +81,6 @@ var _ = Describe("Podman pod clone", func() { Expect(podInspect).To(ExitCleanly()) data := podInspect.InspectPodToJSON() Expect(data.State).To(ContainSubstring("Running")) - }) It("podman pod clone destroy test", func() { @@ -174,5 +172,4 @@ var _ = Describe("Podman pod clone", func() { podJSON := podInspect.InspectPodToJSON() Expect(podJSON.InfraConfig).To(HaveField("UtsNS", ns)) }) - }) diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index dac75749401..60b0677351d 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -768,7 +768,6 @@ ENTRYPOINT ["sleep","99999"] // Too complicated to differentiate in test context, so we ignore the first part // and just check for the "no container" substring, which is common to both. Expect(podCreate).Should(ExitWithError(125, `no container with name or ID "randomfakeid" found: no such container`)) - }) It("podman pod create with --userns=keep-id", func() { @@ -1045,7 +1044,6 @@ ENTRYPOINT ["sleep","99999"] session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(Equal("1:3")) - }) It("podman pod create --volumes-from", func() { @@ -1154,7 +1152,6 @@ ENTRYPOINT ["sleep","99999"] inspect := podmanTest.InspectContainer(ctrCreate.OutputToString()) Expect(inspect[0]).To(HaveField("AppArmorProfile", apparmor.Profile)) - }) It("podman pod create --sysctl test", func() { @@ -1192,7 +1189,6 @@ ENTRYPOINT ["sleep","99999"] session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).NotTo(ContainSubstring("kernel.msgmax = 65535")) - }) It("podman pod create --share-parent test", func() { @@ -1236,7 +1232,6 @@ ENTRYPOINT ["sleep","99999"] podCreate3 := podmanTest.Podman([]string{"pod", "create", "--share", "cgroup"}) podCreate3.WaitWithDefaultTimeout() Expect(podCreate3).ShouldNot(ExitCleanly()) - }) It("podman pod create infra inheritance test", func() { diff --git a/test/e2e/pod_infra_container_test.go b/test/e2e/pod_infra_container_test.go index 199f83bb429..c4ec7634fae 100644 --- a/test/e2e/pod_infra_container_test.go +++ b/test/e2e/pod_infra_container_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman pod create", func() { - It("podman create infra container", func() { session := podmanTest.Podman([]string{"pod", "create"}) session.WaitWithDefaultTimeout() @@ -127,7 +126,6 @@ var _ = Describe("Podman pod create", func() { session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).Should(Equal("''")) // no network path... host - }) It("podman pod correctly sets up IPCNS", func() { @@ -428,5 +426,4 @@ var _ = Describe("Podman pod create", func() { Expect(session.OutputToString()).Should(Equal("0")) }) } - }) diff --git a/test/e2e/pod_initcontainers_test.go b/test/e2e/pod_initcontainers_test.go index 6b52870aabc..f23cce6b75f 100644 --- a/test/e2e/pod_initcontainers_test.go +++ b/test/e2e/pod_initcontainers_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("Podman init containers", func() { - It("podman create init container without --pod should fail", func() { session := podmanTest.Podman([]string{"create", "--init-ctr", "always", ALPINE, "top"}) session.WaitWithDefaultTimeout() @@ -104,7 +103,6 @@ var _ = Describe("Podman init containers", func() { doubleCheck := podmanTest.Podman([]string{"exec", verify.OutputToString(), "cat", filename}) doubleCheck.WaitWithDefaultTimeout() Expect(doubleCheck).Should(ExitWithError(1, fmt.Sprintf("cat: can't open '%s': No such file or directory", filename))) - }) It("podman ensure always init containers always run", func() { @@ -141,5 +139,4 @@ var _ = Describe("Podman init containers", func() { // Dates should not match Expect(firstResult).ToNot(Equal(secondCheckLog.OutputToString())) }) - }) diff --git a/test/e2e/pod_inspect_test.go b/test/e2e/pod_inspect_test.go index 20a42e3883d..db61f8ba6e7 100644 --- a/test/e2e/pod_inspect_test.go +++ b/test/e2e/pod_inspect_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman pod inspect", func() { - It("podman inspect bogus pod", func() { session := podmanTest.Podman([]string{"pod", "inspect", "foobar"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/pod_kill_test.go b/test/e2e/pod_kill_test.go index af0a4db72ef..83f2d6a470e 100644 --- a/test/e2e/pod_kill_test.go +++ b/test/e2e/pod_kill_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman pod kill", func() { - It("podman pod kill bogus", func() { session := podmanTest.Podman([]string{"pod", "kill", "foobar"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/pod_pod_namespaces_test.go b/test/e2e/pod_pod_namespaces_test.go index 740c51a2c40..c8e3fbb5b01 100644 --- a/test/e2e/pod_pod_namespaces_test.go +++ b/test/e2e/pod_pod_namespaces_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman pod create", func() { - It("podman pod container share Namespaces", func() { session := podmanTest.Podman([]string{"pod", "create"}) session.WaitWithDefaultTimeout() @@ -82,5 +81,4 @@ var _ = Describe("Podman pod create", func() { GinkgoWriter.Println("NAMESPACE2:", NAMESPACE2) Expect(NAMESPACE1).To(Not(Equal(NAMESPACE2))) }) - }) diff --git a/test/e2e/pod_prune_test.go b/test/e2e/pod_prune_test.go index 120fa6fe56f..659851a995d 100644 --- a/test/e2e/pod_prune_test.go +++ b/test/e2e/pod_prune_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman pod prune", func() { - It("podman pod prune empty pod", func() { _, ec, _ := podmanTest.CreatePod(nil) Expect(ec).To(Equal(0)) diff --git a/test/e2e/pod_ps_test.go b/test/e2e/pod_ps_test.go index 35daa2c0cb7..fd8b2c2c5ae 100644 --- a/test/e2e/pod_ps_test.go +++ b/test/e2e/pod_ps_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("Podman ps", func() { - It("podman pod ps no pods", func() { session := podmanTest.Podman([]string{"pod", "ps"}) session.WaitWithDefaultTimeout() @@ -133,7 +132,6 @@ var _ = Describe("Podman ps", func() { session := podmanTest.Podman([]string{"pod", "ps", "-q", "--format", "{{.ID}}"}) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError(125, "quiet and format cannot be used together")) - }) It("podman pod ps --sort by name", func() { @@ -376,5 +374,4 @@ var _ = Describe("Podman ps", func() { Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(MatchRegexp(`^POD ID\s+NAME\s+STATUS\s+CREATED\s+INFRA ID\s+IDS\s+NAMES\s+STATUS\s+CGROUP\s+NAMESPACES$`)) }) - }) diff --git a/test/e2e/pod_restart_test.go b/test/e2e/pod_restart_test.go index a1e44c20cab..d43aee1bbd9 100644 --- a/test/e2e/pod_restart_test.go +++ b/test/e2e/pod_restart_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Podman pod restart", func() { - It("podman pod restart bogus pod", func() { session := podmanTest.Podman([]string{"pod", "restart", "123"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/pod_rm_test.go b/test/e2e/pod_rm_test.go index 1931c3c834b..4373a86d894 100644 --- a/test/e2e/pod_rm_test.go +++ b/test/e2e/pod_rm_test.go @@ -16,7 +16,6 @@ import ( ) var _ = Describe("Podman pod rm", func() { - It("podman pod rm empty pod", func() { _, ec, podid := podmanTest.CreatePod(nil) Expect(ec).To(Equal(0)) @@ -211,7 +210,6 @@ var _ = Describe("Podman pod rm", func() { }) It("podman rm --ignore bogus pod and a running pod", func() { - _, ec, podid1 := podmanTest.CreatePod(nil) Expect(ec).To(Equal(0)) diff --git a/test/e2e/pod_stats_test.go b/test/e2e/pod_stats_test.go index b97c87a1858..c6054ac7942 100644 --- a/test/e2e/pod_stats_test.go +++ b/test/e2e/pod_stats_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman pod stats", func() { - BeforeEach(func() { SkipIfRootlessCgroupsV1("Tests fail with both CGv1 + required --cgroup-manager=cgroupfs") if isContainerized() { diff --git a/test/e2e/pod_stop_test.go b/test/e2e/pod_stop_test.go index 1ab17eb5075..d5e2d64dd25 100644 --- a/test/e2e/pod_stop_test.go +++ b/test/e2e/pod_stop_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman pod stop", func() { - It("podman pod stop bogus pod", func() { session := podmanTest.Podman([]string{"pod", "stop", "123"}) session.WaitWithDefaultTimeout() @@ -24,7 +23,6 @@ var _ = Describe("Podman pod stop", func() { }) It("podman pod stop --ignore bogus pod", func() { - session := podmanTest.Podman([]string{"pod", "stop", "--ignore", "123"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -48,7 +46,6 @@ var _ = Describe("Podman pod stop", func() { }) It("podman stop --ignore bogus pod and a running pod", func() { - _, ec, podid1 := podmanTest.CreatePod(nil) Expect(ec).To(Equal(0)) diff --git a/test/e2e/pod_top_test.go b/test/e2e/pod_top_test.go index 4ae26fcef16..2ed8a0fddd5 100644 --- a/test/e2e/pod_top_test.go +++ b/test/e2e/pod_top_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman top", func() { - It("podman pod top without pod name or id", func() { result := podmanTest.Podman([]string{"pod", "top"}) result.WaitWithDefaultTimeout() diff --git a/test/e2e/port_test.go b/test/e2e/port_test.go index 227478166ad..77a2c795c9a 100644 --- a/test/e2e/port_test.go +++ b/test/e2e/port_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman port", func() { - It("podman port all and latest", func() { result := podmanTest.Podman([]string{"port", "-a", "-l"}) result.WaitWithDefaultTimeout() diff --git a/test/e2e/prune_test.go b/test/e2e/prune_test.go index eadf8b2539d..20419f84291 100644 --- a/test/e2e/prune_test.go +++ b/test/e2e/prune_test.go @@ -32,7 +32,6 @@ RUN echo "Hello, World!" RUN RUN echo "Please use signal 9 this will never ends" && sleep 10000s`, ALPINE) var _ = Describe("Podman prune", func() { - It("podman container prune containers", func() { top := podmanTest.RunTopContainer("") top.WaitWithDefaultTimeout() @@ -531,7 +530,6 @@ var _ = Describe("Podman prune", func() { dirents, err = os.ReadDir(containerStorageDir) Expect(err).ToNot(HaveOccurred()) Expect(dirents).To(HaveLen(3)) - }) It("podman system prune --external removes unreferenced containers", func() { diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index 6c1af5f12f1..06890552767 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -17,7 +17,6 @@ import ( ) var _ = Describe("Podman ps", func() { - It("podman ps no containers", func() { session := podmanTest.Podman([]string{"ps"}) session.WaitWithDefaultTimeout() @@ -226,8 +225,10 @@ var _ = Describe("Podman ps", func() { session := podmanTest.RunTopContainer("test1") session.WaitWithDefaultTimeout() - result := podmanTest.Podman([]string{"ps", "-a", "--ns", "--format", - "{{with .Namespaces}}{{.Cgroup}}:{{.IPC}}:{{.MNT}}:{{.NET}}:{{.PIDNS}}:{{.User}}:{{.UTS}}{{end}}"}) + result := podmanTest.Podman([]string{ + "ps", "-a", "--ns", "--format", + "{{with .Namespaces}}{{.Cgroup}}:{{.IPC}}:{{.MNT}}:{{.NET}}:{{.PIDNS}}:{{.User}}:{{.UTS}}{{end}}", + }) result.WaitWithDefaultTimeout() Expect(result).Should(ExitCleanly()) // it must contains `::` when some ns is null. If it works normally, it should be "$num1:$num2:$num3" @@ -505,7 +506,6 @@ var _ = Describe("Podman ps", func() { size2, _ := units.FromHumanSize(matches2[1]) return size1 < size2 })).To(BeTrue(), "slice is sorted") - }) It("podman --sort by command", func() { @@ -597,7 +597,8 @@ var _ = Describe("Podman ps", func() { "-p", "30080:30080", "-p", "30443:30443", "-p", "8000:8080", - ALPINE, "top"}, + ALPINE, "top", + }, ) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -702,14 +703,18 @@ var _ = Describe("Podman ps", func() { }) It("podman ps filter test", func() { - session := podmanTest.Podman([]string{"run", "-d", "--name", "test1", "--label", "foo=1", - "--label", "bar=2", "--volume", "volume1:/test", ALPINE, "top"}) + session := podmanTest.Podman([]string{ + "run", "-d", "--name", "test1", "--label", "foo=1", + "--label", "bar=2", "--volume", "volume1:/test", ALPINE, "top", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) cid1 := session.OutputToString() - session = podmanTest.Podman([]string{"run", "--name", "test2", "--label", "foo=1", - ALPINE, "ls", "/fail"}) + session = podmanTest.Podman([]string{ + "run", "--name", "test2", "--label", "foo=1", + ALPINE, "ls", "/fail", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitWithError(1, "ls: /fail: No such file or directory")) @@ -717,8 +722,10 @@ var _ = Describe("Podman ps", func() { session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - session = podmanTest.Podman([]string{"run", "--name", "test4", "--volume", "volume1:/test1", - "--volume", "/:/test2", ALPINE, "ls"}) + session = podmanTest.Podman([]string{ + "run", "--name", "test4", "--volume", "volume1:/test1", + "--volume", "/:/test2", ALPINE, "ls", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -870,7 +877,6 @@ var _ = Describe("Podman ps", func() { Expect(session.OutputToStringArray()).To(HaveLen(4)) Expect(session.OutputToStringArray()).To(ContainElement(con1.OutputToString())) Expect(session.OutputToStringArray()).To(ContainElement(con2.OutputToString())) - }) It("podman ps filter network", func() { @@ -972,7 +978,6 @@ var _ = Describe("Podman ps", func() { output := session.OutputToStringArray() Expect(output).To(HaveLen(1)) - }) // This test checks ps filtering of external container by container id @@ -1046,5 +1051,4 @@ var _ = Describe("Podman ps", func() { Expect(output).To(HaveLen(1)) Expect(output).Should(ContainElement(ContainSubstring("late"))) }) - }) diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index 88ad61dfeb7..b807c07056b 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -15,7 +15,6 @@ import ( ) var _ = Describe("Podman pull", func() { - It("podman pull multiple images with/without tag/digest", func() { session := podmanTest.Podman([]string{"pull", "-q", "busybox:musl", "alpine", "alpine:latest", "quay.io/libpod/cirros", "quay.io/libpod/testdigest_v2s2@sha256:755f4d90b3716e2bf57060d249e2cd61c9ac089b1233465c5c2cb2d7ee550fdb"}) session.WaitWithDefaultTimeout() @@ -124,8 +123,10 @@ var _ = Describe("Podman pull", func() { err = os.WriteFile(configPath, storageConf, os.ModePerm) Expect(err).ToNot(HaveOccurred()) - session = podmanTest.Podman([]string{"run", "--name", "test", "--rm", - imgName, "echo", "helloworld"}) + session = podmanTest.Podman([]string{ + "run", "--name", "test", "--rm", + imgName, "echo", "helloworld", + }) session.WaitWithDefaultTimeout() Expect(session).Should(Exit(0)) Expect(session.OutputToString()).To(ContainSubstring("helloworld")) @@ -602,7 +603,6 @@ var _ = Describe("Podman pull", func() { }) Describe("podman pull and decrypt", func() { - decryptionTestHelper := func(imgPath string) *PodmanSessionIntegration { bitSize := 1024 keyFileName := filepath.Join(podmanTest.TempDir, "key,withcomma") @@ -688,5 +688,4 @@ var _ = Describe("Podman pull", func() { Expect(session.LineInOutputContainsTag(imgPath, "latest")).To(BeTrue()) }) }) - }) diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go index e674723c03f..b00d5fbea13 100644 --- a/test/e2e/push_test.go +++ b/test/e2e/push_test.go @@ -21,7 +21,6 @@ import ( const testSequoiaKeyFingerprint = "50DDE898DF4E48755C8C2B7AF6F908B6FA48A229" var _ = Describe("Podman push", func() { - BeforeEach(func() { podmanTest.AddImageToRWStore(ALPINE) }) @@ -40,14 +39,18 @@ var _ = Describe("Podman push", func() { It("podman push to dir", func() { SkipIfRemote("Remote push does not support dir transport") bbdir := filepath.Join(podmanTest.TempDir, "busybox") - session := podmanTest.Podman([]string{"push", "-q", "--remove-signatures", ALPINE, - fmt.Sprintf("dir:%s", bbdir)}) + session := podmanTest.Podman([]string{ + "push", "-q", "--remove-signatures", ALPINE, + fmt.Sprintf("dir:%s", bbdir), + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) bbdir = filepath.Join(podmanTest.TempDir, "busybox") - session = podmanTest.Podman([]string{"push", "-q", "--format", "oci", ALPINE, - fmt.Sprintf("dir:%s", bbdir)}) + session = podmanTest.Podman([]string{ + "push", "-q", "--format", "oci", ALPINE, + fmt.Sprintf("dir:%s", bbdir), + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) }) @@ -61,8 +64,10 @@ var _ = Describe("Podman push", func() { session.WaitWithDefaultTimeout() Expect(session).Should(ExitWithError(125, "writing blob: happened during read: gzip: invalid compression level: 40")) - session = podmanTest.Podman([]string{"push", "-q", "--compression-format=zstd", "--remove-signatures", ALPINE, - fmt.Sprintf("oci:%s", bbdir)}) + session = podmanTest.Podman([]string{ + "push", "-q", "--compression-format=zstd", "--remove-signatures", ALPINE, + fmt.Sprintf("oci:%s", bbdir), + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -248,7 +253,7 @@ var _ = Describe("Podman push", func() { registriesDFragment, err := os.ReadFile("testdata/sigstore-registries.d-fragment.yaml") Expect(err).ToNot(HaveOccurred()) registriesDFragment = bytes.ReplaceAll(registriesDFragment, []byte("@lookasideDir@"), []byte(lookasideDir)) - err = os.WriteFile(systemRegistriesDAddition, registriesDFragment, 0644) + err = os.WriteFile(systemRegistriesDAddition, registriesDFragment, 0o644) if err != nil { GinkgoWriter.Printf("Skipping sigstore tests because /etc/containers/registries.d isn’t writable: %s\n", err) } else { @@ -380,11 +385,13 @@ var _ = Describe("Podman push", func() { err = f.Sync() Expect(err).ToNot(HaveOccurred()) - session := podmanTest.Podman([]string{"run", "-d", "-p", "5004:5000", "--name", "registry", "-v", + session := podmanTest.Podman([]string{ + "run", "-d", "-p", "5004:5000", "--name", "registry", "-v", strings.Join([]string{authPath, "/auth", "z"}, ":"), "-e", "REGISTRY_AUTH=htpasswd", "-e", "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm", "-e", "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd", "-v", strings.Join([]string{certPath, "/certs", "z"}, ":"), "-e", "REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt", - "-e", "REGISTRY_HTTP_TLS_KEY=/certs/domain.key", REGISTRY_IMAGE}) + "-e", "REGISTRY_HTTP_TLS_KEY=/certs/domain.key", REGISTRY_IMAGE, + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -453,8 +460,10 @@ var _ = Describe("Podman push", func() { It("podman push to docker-archive", func() { SkipIfRemote("Remote push does not support docker-archive transport") tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") - session := podmanTest.Podman([]string{"push", "-q", ALPINE, - fmt.Sprintf("docker-archive:%s:latest", tarfn)}) + session := podmanTest.Podman([]string{ + "push", "-q", ALPINE, + fmt.Sprintf("docker-archive:%s:latest", tarfn), + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) }) @@ -490,8 +499,10 @@ var _ = Describe("Podman push", func() { It("podman push to oci-archive", func() { SkipIfRemote("Remote push does not support oci-archive transport") tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") - session := podmanTest.Podman([]string{"push", "-q", ALPINE, - fmt.Sprintf("oci-archive:%s:latest", tarfn)}) + session := podmanTest.Podman([]string{ + "push", "-q", ALPINE, + fmt.Sprintf("oci-archive:%s:latest", tarfn), + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) }) @@ -499,8 +510,10 @@ var _ = Describe("Podman push", func() { It("podman push to docker-archive no reference", func() { SkipIfRemote("Remote push does not support docker-archive transport") tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") - session := podmanTest.Podman([]string{"push", "-q", ALPINE, - fmt.Sprintf("docker-archive:%s", tarfn)}) + session := podmanTest.Podman([]string{ + "push", "-q", ALPINE, + fmt.Sprintf("docker-archive:%s", tarfn), + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) }) @@ -508,11 +521,12 @@ var _ = Describe("Podman push", func() { It("podman push to oci-archive no reference", func() { SkipIfRemote("Remote push does not support oci-archive transport") ociarc := filepath.Join(podmanTest.TempDir, "alp-oci") - session := podmanTest.Podman([]string{"push", "-q", ALPINE, - fmt.Sprintf("oci-archive:%s", ociarc)}) + session := podmanTest.Podman([]string{ + "push", "-q", ALPINE, + fmt.Sprintf("oci-archive:%s", ociarc), + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) }) - }) diff --git a/test/e2e/rename_test.go b/test/e2e/rename_test.go index 01c18f3b56e..7349ea13390 100644 --- a/test/e2e/rename_test.go +++ b/test/e2e/rename_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("podman rename", func() { - It("podman rename on non-existent container", func() { session := podmanTest.Podman([]string{"rename", "doesNotExist", "aNewName"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index 7cbe73cd1ef..6f3ca5fadec 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -14,7 +14,6 @@ import ( ) var _ = Describe("Podman restart", func() { - It("podman restart bogus container", func() { session := podmanTest.Podman([]string{"start", "123"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go index 0605da8dbc7..f6dfa1c63b6 100644 --- a/test/e2e/rm_test.go +++ b/test/e2e/rm_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman rm", func() { - It("podman rm stopped container", func() { _, ec, cid := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go index 6582e949b2c..db24cb64b63 100644 --- a/test/e2e/rmi_test.go +++ b/test/e2e/rmi_test.go @@ -12,12 +12,10 @@ import ( ) var _ = Describe("Podman rmi", func() { - It("podman rmi bogus image", func() { session := podmanTest.Podman([]string{"rmi", "debian:6.0.10"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitWithError(1, "debian:6.0.10: image not known")) - }) It("podman rmi with fq name", func() { @@ -25,7 +23,6 @@ var _ = Describe("Podman rmi", func() { session := podmanTest.Podman([]string{"rmi", ALPINE}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - }) It("podman rmi with short name", func() { @@ -33,7 +30,6 @@ var _ = Describe("Podman rmi", func() { session := podmanTest.Podman([]string{"rmi", "cirros"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - }) It("podman rmi all images", func() { @@ -43,7 +39,6 @@ var _ = Describe("Podman rmi", func() { images := podmanTest.Podman([]string{"images"}) images.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - }) It("podman rmi all images forcibly with short options", func() { @@ -51,7 +46,6 @@ var _ = Describe("Podman rmi", func() { session := podmanTest.Podman([]string{"rmi", "-fa"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - }) It("podman rmi tagged image", func() { diff --git a/test/e2e/run_aardvark_test.go b/test/e2e/run_aardvark_test.go index 7832e7b1504..a8df796474f 100644 --- a/test/e2e/run_aardvark_test.go +++ b/test/e2e/run_aardvark_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman run networking", func() { - BeforeEach(func() { SkipIfCNI(podmanTest) }) @@ -44,7 +43,6 @@ var _ = Describe("Podman run networking", func() { Expect(revListArray).Should(HaveLen(2)) Expect(strings.TrimRight(revListArray[0], ".")).To(Equal("aone")) Expect(strings.TrimRight(revListArray[1], ".")).To(Equal(cid[:12])) - }) It("Aardvark Test 2: Two containers, same subnet", func() { @@ -95,7 +93,6 @@ var _ = Describe("Podman run networking", func() { Expect(revListArray21).Should(HaveLen(2)) Expect(strings.TrimRight(revListArray21[0], ".")).To(Equal("aone")) Expect(strings.TrimRight(revListArray21[1], ".")).To(Equal(cid1[:12])) - }) It("Aardvark Test 3: Two containers, same subnet w/aliases", func() { @@ -136,7 +133,6 @@ var _ = Describe("Podman run networking", func() { digShort("atwo", "alias_a1", cip1, podmanTest) digShort("atwo", "alias_1a", cip1, podmanTest) - }) It("Aardvark Test 4: Two containers, different subnets", func() { @@ -290,5 +286,4 @@ var _ = Describe("Podman run networking", func() { digShort("cone", "testB1_nw", cipAB1, podmanTest) }) - }) diff --git a/test/e2e/run_apparmor_test.go b/test/e2e/run_apparmor_test.go index aa825886c5d..39fcedb6773 100644 --- a/test/e2e/run_apparmor_test.go +++ b/test/e2e/run_apparmor_test.go @@ -19,6 +19,7 @@ func skipIfAppArmorEnabled() { Skip("Apparmor is enabled") } } + func skipIfAppArmorDisabled() { if !apparmor.IsEnabled() { Skip("Apparmor is not enabled") @@ -26,7 +27,6 @@ func skipIfAppArmorDisabled() { } var _ = Describe("Podman run", func() { - It("podman run apparmor default", func() { skipIfAppArmorDisabled() session := podmanTest.Podman([]string{"create", ALPINE, "ls"}) diff --git a/test/e2e/run_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go index 83e2a36edbd..50c9376ccef 100644 --- a/test/e2e/run_cgroup_parent_test.go +++ b/test/e2e/run_cgroup_parent_test.go @@ -16,7 +16,6 @@ import ( const cgroupRoot = "/sys/fs/cgroup" var _ = Describe("Podman run with --cgroup-parent", func() { - BeforeEach(func() { SkipIfRootlessCgroupsV1("cgroup parent is not supported in cgroups v1") }) diff --git a/test/e2e/run_cleanup_test.go b/test/e2e/run_cleanup_test.go index f9818a821e5..74fc66281f7 100644 --- a/test/e2e/run_cleanup_test.go +++ b/test/e2e/run_cleanup_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman run exit", func() { - It("podman run -d mount cleanup test", func() { SkipIfRemote("podman-remote does not support mount") SkipIfRootless("rootless podman mount requires podman unshare first") diff --git a/test/e2e/run_cpu_test.go b/test/e2e/run_cpu_test.go index a05d72ba87a..aa76aa9b630 100644 --- a/test/e2e/run_cpu_test.go +++ b/test/e2e/run_cpu_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman run cpu", func() { - BeforeEach(func() { SkipIfRootlessCgroupsV1("Setting CPU not supported on cgroupv1 for rootless users") diff --git a/test/e2e/run_device_test.go b/test/e2e/run_device_test.go index 665e9d860cf..62d11eab773 100644 --- a/test/e2e/run_device_test.go +++ b/test/e2e/run_device_test.go @@ -37,7 +37,6 @@ func createContainersConfFileWithDevices(pTest *PodmanTestIntegration, devices s } var _ = Describe("Podman run device", func() { - It("podman run bad device test", func() { session := podmanTest.Podman([]string{"run", "-q", "--device", "/dev/baddevice", ALPINE, "true"}) session.WaitWithDefaultTimeout() @@ -168,5 +167,4 @@ var _ = Describe("Podman run device", func() { session.WaitWithDefaultTimeout() Expect(session).To(ExitWithErrorRegex(1, "head: /dev-host/kmsg: (Operation not permitted|Permission denied)")) }) - }) diff --git a/test/e2e/run_dns_test.go b/test/e2e/run_dns_test.go index 3bd584e5443..9b50aa7fda5 100644 --- a/test/e2e/run_dns_test.go +++ b/test/e2e/run_dns_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman run dns", func() { - It("podman run add search domain", func() { session := podmanTest.Podman([]string{"run", "--dns-search=foobar.com", ALPINE, "cat", "/etc/resolv.conf"}) session.WaitWithDefaultTimeout() @@ -35,7 +34,6 @@ var _ = Describe("Podman run dns", func() { session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("nameserver 1.2.3.4"))) - }) It("podman run add dns option", func() { diff --git a/test/e2e/run_entrypoint_test.go b/test/e2e/run_entrypoint_test.go index cc839479afa..7c51e6e8dae 100644 --- a/test/e2e/run_entrypoint_test.go +++ b/test/e2e/run_entrypoint_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman run entrypoint", func() { - It("podman run no command, entrypoint, or cmd", func() { dockerfile := `FROM quay.io/libpod/alpine:latest ENTRYPOINT [] diff --git a/test/e2e/run_env_test.go b/test/e2e/run_env_test.go index cf8dd0eadce..c5b56cba2fb 100644 --- a/test/e2e/run_env_test.go +++ b/test/e2e/run_env_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Podman run", func() { - It("podman run environment test", func() { session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "HOME"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/run_exit_test.go b/test/e2e/run_exit_test.go index 2e945e40c40..33dc7694308 100644 --- a/test/e2e/run_exit_test.go +++ b/test/e2e/run_exit_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman run exit", func() { - It("podman run exit define.ExecErrorCodeGeneric", func() { result := podmanTest.Podman([]string{"run", "--foobar", ALPINE, "ls", "$tmp"}) result.WaitWithDefaultTimeout() diff --git a/test/e2e/run_memory_test.go b/test/e2e/run_memory_test.go index 40eb76f343e..ba821589a31 100644 --- a/test/e2e/run_memory_test.go +++ b/test/e2e/run_memory_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Podman run memory", func() { - BeforeEach(func() { SkipIfRootlessCgroupsV1("Setting Memory not supported on cgroupv1 for rootless users") }) diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 3088c6011ad..ba8b1b91ef4 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -24,7 +24,6 @@ import ( ) var _ = Describe("Podman run networking", func() { - hostname, _ := os.Hostname() It("podman verify network scoped DNS server and also verify updating network dns server", func() { @@ -106,8 +105,10 @@ var _ = Describe("Podman run networking", func() { Expect(session.OutputToString()).To(ContainSubstring("Non-authoritative answer: Name: google.com Address:")) // Update DNS server - session = podmanTest.Podman([]string{"network", "update", net, "--dns-drop=1.1.1.1,8.8.8.8", - "--dns-drop", "8.4.4.8", "--dns-add", "127.0.0.253,127.0.0.254", "--dns-add", "127.0.0.255"}) + session = podmanTest.Podman([]string{ + "network", "update", net, "--dns-drop=1.1.1.1,8.8.8.8", + "--dns-drop", "8.4.4.8", "--dns-add", "127.0.0.253,127.0.0.254", "--dns-add", "127.0.0.255", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -928,7 +929,6 @@ EXPOSE 2004-2005/tcp`, ALPINE) Expect(inspectOut[0].NetworkSettings.AdditionalMacAddresses).To(HaveLen(1)) Expect(inspectOut[0].NetworkSettings.AdditionalMacAddresses[0]).To(Equal("56:6e:35:5d:3e:a8")) Expect(inspectOut[0].NetworkSettings).To(HaveField("Gateway", "10.25.40.0")) - } It("podman run network inspect fails gracefully on non-reachable network ns", func() { @@ -1227,8 +1227,10 @@ EXPOSE 2004-2005/tcp`, ALPINE) Expect(session).Should(ExitCleanly()) // use options and search to make sure we get the same resolv.conf everywhere - run := podmanTest.Podman([]string{"run", "--network", net, "--dns", "127.0.0.128", - "--dns-option", "ndots:1", "--dns-search", ".", ALPINE, "cat", "/etc/resolv.conf"}) + run := podmanTest.Podman([]string{ + "run", "--network", net, "--dns", "127.0.0.128", + "--dns-option", "ndots:1", "--dns-search", ".", ALPINE, "cat", "/etc/resolv.conf", + }) run.WaitWithDefaultTimeout() Expect(run).Should(ExitCleanly()) Expect(string(run.Out.Contents())).To(Equal(`nameserver 127.0.0.128 diff --git a/test/e2e/run_ns_test.go b/test/e2e/run_ns_test.go index 6f0cffb44de..1882b7d2ad7 100644 --- a/test/e2e/run_ns_test.go +++ b/test/e2e/run_ns_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman run ns", func() { - It("podman run pidns test", func() { SkipIfRootlessCgroupsV1("Not supported for rootless + CgroupsV1") session := podmanTest.Podman([]string{"run", fedoraMinimal, "bash", "-c", "echo $$"}) @@ -121,5 +120,4 @@ var _ = Describe("Podman run ns", func() { Expect(hostPidNS).To(Equal(ctrPidNS)) Expect(hostIpcNS).To(Equal(ctrIpcNS)) }) - }) diff --git a/test/e2e/run_passwd_test.go b/test/e2e/run_passwd_test.go index 090a7ecdf90..d19b005e77d 100644 --- a/test/e2e/run_passwd_test.go +++ b/test/e2e/run_passwd_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Podman run passwd", func() { - It("podman run no user specified ", func() { session := podmanTest.Podman([]string{"run", "--read-only", BB, "mount"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/run_privileged_test.go b/test/e2e/run_privileged_test.go index 20bcb7d09ca..967168d123b 100644 --- a/test/e2e/run_privileged_test.go +++ b/test/e2e/run_privileged_test.go @@ -37,7 +37,6 @@ func containerCapMatchesHost(ctrCap string, hostCap string) { } var _ = Describe("Podman privileged container tests", func() { - It("podman privileged make sure sys is mounted rw", func() { session := podmanTest.Podman([]string{"run", "--privileged", BB, "mount"}) session.WaitWithDefaultTimeout() @@ -156,5 +155,4 @@ var _ = Describe("Podman privileged container tests", func() { noprivs := strings.Split(session.OutputToString(), ":") Expect(privs[1]).To(Not(Equal(noprivs[1]))) }) - }) diff --git a/test/e2e/run_restart_test.go b/test/e2e/run_restart_test.go index 4d70159be10..9ecfa72aa61 100644 --- a/test/e2e/run_restart_test.go +++ b/test/e2e/run_restart_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman run restart containers", func() { - It("Podman start after successful run", func() { session := podmanTest.Podman([]string{"run", "--name", "test", ALPINE, "ls"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/run_seccomp_test.go b/test/e2e/run_seccomp_test.go index 40942ad3bb0..c904c6553d2 100644 --- a/test/e2e/run_seccomp_test.go +++ b/test/e2e/run_seccomp_test.go @@ -26,7 +26,6 @@ func makeLabeledImage(seccompLabel string) string { } var _ = Describe("Podman run", func() { - It("podman run --seccomp-policy default", func() { session := podmanTest.Podman([]string{"run", "-q", "--seccomp-policy", "default", CITEST_IMAGE, "ls"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/run_security_labels_test.go b/test/e2e/run_security_labels_test.go index 7d90a14a0bd..6a42b973dbd 100644 --- a/test/e2e/run_security_labels_test.go +++ b/test/e2e/run_security_labels_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("Podman generate kube", func() { - It("podman empty security labels", func() { test1 := podmanTest.Podman([]string{"create", "--label", "io.containers.capabilities=", "--name", "test1", "alpine", "echo", "test1"}) test1.WaitWithDefaultTimeout() @@ -119,7 +118,6 @@ var _ = Describe("Podman generate kube", func() { ctr := inspect.InspectContainerToJSON() caps := strings.Join(ctr[0].EffectiveCaps, ",") Expect(caps).To(Equal("CAP_SETGID,CAP_SETUID")) - }) It("podman --privileged security labels", func() { @@ -157,5 +155,4 @@ LABEL io.containers.capabilities=chown,kill`, ALPINE) caps := strings.Join(ctr[0].EffectiveCaps, ",") Expect(caps).To(Equal("CAP_CHOWN,CAP_KILL")) }) - }) diff --git a/test/e2e/run_signal_test.go b/test/e2e/run_signal_test.go index ffd9030d10a..d92d4b17c2b 100644 --- a/test/e2e/run_signal_test.go +++ b/test/e2e/run_signal_test.go @@ -17,11 +17,12 @@ import ( "golang.org/x/sys/unix" ) -const sigCatch = "trap \"echo FOO >> /h/fifo \" 8; echo READY >> /h/fifo; while :; do sleep 0.25; done" -const sigCatch2 = "trap \"echo Received\" SIGFPE; while :; do sleep 0.25; done" +const ( + sigCatch = "trap \"echo FOO >> /h/fifo \" 8; echo READY >> /h/fifo; while :; do sleep 0.25; done" + sigCatch2 = "trap \"echo Received\" SIGFPE; while :; do sleep 0.25; done" +) var _ = Describe("Podman run with --sig-proxy", func() { - Specify("signals are forwarded to container using sig-proxy", func() { if podmanTest.Host.Arch == "ppc64le" { Skip("Doesn't work on ppc64le") @@ -115,5 +116,4 @@ var _ = Describe("Podman run with --sig-proxy", func() { Expect(session).To(Or(ExitWithError(2, errorMsg), ExitWithError(134, errorMsg))) Expect(session.OutputToString()).To(Not(ContainSubstring("Received"))) }) - }) diff --git a/test/e2e/run_staticip_test.go b/test/e2e/run_staticip_test.go index a18222c1543..8f4d0ece5c4 100644 --- a/test/e2e/run_staticip_test.go +++ b/test/e2e/run_staticip_test.go @@ -14,7 +14,6 @@ import ( ) var _ = Describe("Podman run with --ip flag", func() { - BeforeEach(func() { SkipIfRootless("rootless does not support --ip without network") }) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index e49336692ee..b80ef3332f9 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -25,7 +25,6 @@ import ( ) var _ = Describe("Podman run", func() { - It("podman run a container based on local image", func() { session := podmanTest.Podman([]string{"run", ALPINE, "ls"}) session.WaitWithDefaultTimeout() @@ -228,7 +227,6 @@ var _ = Describe("Podman run", func() { Expect(session).Should(Exit(0)) Expect(session.ErrorToString()).To(ContainSubstring("Trying to pull " + BB_GLIBC)) Expect(session.ErrorToString()).To(ContainSubstring("Writing manifest to image destination")) - }) It("podman run --tls-verify", func() { @@ -274,8 +272,10 @@ var _ = Describe("Podman run", func() { Expect(err).ShouldNot(HaveOccurred()) // Change image in predictable way to validate export - csession := podmanTest.Podman([]string{"run", "--name", uniqueString, ALPINE, - "/bin/sh", "-c", fmt.Sprintf("echo %s > %s", uniqueString, testFilePath)}) + csession := podmanTest.Podman([]string{ + "run", "--name", uniqueString, ALPINE, + "/bin/sh", "-c", fmt.Sprintf("echo %s > %s", uniqueString, testFilePath), + }) csession.WaitWithDefaultTimeout() Expect(csession).Should(ExitCleanly()) @@ -292,8 +292,10 @@ var _ = Describe("Podman run", func() { Expect(filepath.Join(rootfs, uls)).Should(BeADirectory()) // Other tests confirm SELinux types, just confirm --rootfs is working. - session := podmanTest.Podman([]string{"run", "-i", "--security-opt", "label=disable", - "--rootfs", rootfs, "cat", testFilePath}) + session := podmanTest.Podman([]string{ + "run", "-i", "--security-opt", "label=disable", + "--rootfs", rootfs, "cat", testFilePath, + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -309,15 +311,19 @@ var _ = Describe("Podman run", func() { } // Test --rootfs with an external overlay // use --rm to remove container and confirm if we did not leak anything - osession := podmanTest.Podman([]string{"run", "-i", "--rm", "--security-opt", "label=disable", - "--rootfs", rootfs + ":O", "cat", testFilePath}) + osession := podmanTest.Podman([]string{ + "run", "-i", "--rm", "--security-opt", "label=disable", + "--rootfs", rootfs + ":O", "cat", testFilePath, + }) osession.WaitWithDefaultTimeout() Expect(osession).Should(ExitCleanly()) Expect(osession.OutputToString()).To(Equal(uniqueString)) // Test podman start stop with overlay - osession = podmanTest.Podman([]string{"run", "--name", "overlay-foo", "--security-opt", "label=disable", - "--rootfs", rootfs + ":O", "echo", "hello"}) + osession = podmanTest.Podman([]string{ + "run", "--name", "overlay-foo", "--security-opt", "label=disable", + "--rootfs", rootfs + ":O", "echo", "hello", + }) osession.WaitWithDefaultTimeout() Expect(osession).Should(ExitCleanly()) Expect(osession.OutputToString()).To(Equal("hello")) @@ -335,15 +341,19 @@ var _ = Describe("Podman run", func() { Expect(osession).Should(ExitCleanly()) // Test --rootfs with an external overlay with --uidmap - osession = podmanTest.Podman([]string{"run", "--uidmap", "0:1234:5678", "--rm", "--security-opt", "label=disable", - "--rootfs", rootfs + ":O", "cat", "/proc/self/uid_map"}) + osession = podmanTest.Podman([]string{ + "run", "--uidmap", "0:1234:5678", "--rm", "--security-opt", "label=disable", + "--rootfs", rootfs + ":O", "cat", "/proc/self/uid_map", + }) osession.WaitWithDefaultTimeout() Expect(osession).Should(ExitCleanly()) Expect(osession.OutputToString()).To(Equal("0 1234 5678")) // Test --rootfs with an external overlay with --userns=auto - osession = podmanTest.Podman([]string{"run", "--userns=auto", "--rm", "--security-opt", "label=disable", - "--rootfs", rootfs + ":O", "cat", "/proc/self/uid_map"}) + osession = podmanTest.Podman([]string{ + "run", "--userns=auto", "--rm", "--security-opt", "label=disable", + "--rootfs", rootfs + ":O", "cat", "/proc/self/uid_map", + }) osession.WaitWithDefaultTimeout() Expect(osession).Should(ExitCleanly()) Expect(osession.OutputToString()).To(ContainSubstring("1024")) @@ -513,7 +523,6 @@ var _ = Describe("Podman run", func() { }) It("podman run security-opt unmask on /sys/fs/cgroup", func() { - SkipIfCgroupV1("podman umask on /sys/fs/cgroup will fail with cgroups V1") SkipIfRootless("/sys/fs/cgroup rw access is needed") rwOnCgroups := "/sys/fs/cgroup cgroup2 rw" @@ -1665,7 +1674,6 @@ VOLUME %s`, ALPINE, volPath, volPath) session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError(125, "--no-hosts and --hosts-file cannot be set together")) }) - }) It("podman run with restart-policy always restarts containers", func() { @@ -1822,7 +1830,7 @@ VOLUME %s`, ALPINE, volPath, volPath) curCgroupsBytes, err := os.ReadFile("/proc/self/cgroup") Expect(err).ToNot(HaveOccurred()) - var curCgroups = string(curCgroupsBytes) + curCgroups := string(curCgroupsBytes) GinkgoWriter.Printf("Output:\n%s\n", curCgroups) Expect(curCgroups).To(Not(Equal(""))) @@ -1839,7 +1847,7 @@ VOLUME %s`, ALPINE, volPath, volPath) ctrCgroupsBytes, err := os.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid)) Expect(err).ToNot(HaveOccurred()) - var ctrCgroups = string(ctrCgroupsBytes) + ctrCgroups := string(ctrCgroupsBytes) GinkgoWriter.Printf("Output\n:%s\n", ctrCgroups) Expect(curCgroups).To(Not(Equal(ctrCgroups))) }) @@ -1959,7 +1967,6 @@ VOLUME %s`, ALPINE, volPath, volPath) h := strconv.Itoa(t.Hour()) Expect(session.OutputToString()).To(ContainSubstring(z)) Expect(session.OutputToString()).To(ContainSubstring(h)) - }) It("podman run verify pids-limit", func() { @@ -2091,7 +2098,6 @@ WORKDIR /madethis`, BB) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("mysecret")) - }) It("podman run --secret source=mysecret,type=mount", func() { @@ -2113,7 +2119,6 @@ WORKDIR /madethis`, BB) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("mysecret")) - }) It("podman run --secret source=mysecret,type=mount with target", func() { @@ -2135,7 +2140,6 @@ WORKDIR /madethis`, BB) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("mysecret_target")) - }) It("podman run --secret source=mysecret,type=mount with target at /tmp", func() { @@ -2157,7 +2161,6 @@ WORKDIR /madethis`, BB) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("mysecret_target2")) - }) It("podman run --secret source=mysecret,type=env", func() { diff --git a/test/e2e/run_transient_test.go b/test/e2e/run_transient_test.go index 4d5189863c1..ba55e683fd2 100644 --- a/test/e2e/run_transient_test.go +++ b/test/e2e/run_transient_test.go @@ -87,5 +87,4 @@ var _ = Describe("Podman run with volumes", func() { Expect(filepath.Join(runDBDir, "bolt_state.db")).Should(BeARegularFile()) } }) - }) diff --git a/test/e2e/run_userns_test.go b/test/e2e/run_userns_test.go index 3dff18598aa..2d207fd5208 100644 --- a/test/e2e/run_userns_test.go +++ b/test/e2e/run_userns_test.go @@ -376,7 +376,6 @@ var _ = Describe("Podman UserNS support", func() { Expect(inspectGID).Should(ExitCleanly()) Expect(inspectGID.OutputToString()).To(Equal(tt.gid)) } - }) It("podman --userns= conflicts with ui[dg]map and sub[ug]idname", func() { diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index f87de2d886d..8baa09c673f 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -24,7 +24,6 @@ import ( const dest = "/unique/path" var _ = Describe("Podman run with volumes", func() { - // Returns the /proc/self/mountinfo line for a given mount point getMountInfo := func(volume string) []string { containerDir := strings.SplitN(volume, ":", 3)[1] @@ -283,7 +282,6 @@ var _ = Describe("Podman run with volumes", func() { session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(Not(ContainSubstring("overlay"))) Expect(session.OutputToString()).To(ContainSubstring("test")) - }) It("podman support overlay on named volume with custom upperdir and workdir", func() { @@ -332,7 +330,6 @@ var _ = Describe("Podman run with volumes", func() { Expect(session.OutputToString()).To(Not(ContainSubstring("overlay"))) // this should be there since `test` was written on actual volume not on any overlay Expect(session.OutputToString()).To(ContainSubstring("test")) - }) It("podman support overlay volume with custom upperdir and workdir", func() { @@ -372,7 +369,6 @@ var _ = Describe("Podman run with volumes", func() { session.WaitWithDefaultTimeout() // must not contain `overlay` file which was on custom upper and workdir since we have not specified any upper or workdir Expect(session.OutputToString()).To(Not(ContainSubstring("overlay"))) - }) It("podman run with noexec can't exec", func() { @@ -916,7 +912,6 @@ USER testuser`, CITEST_IMAGE) test2.WaitWithDefaultTimeout() Expect(test2).Should(ExitCleanly()) Expect(test2.OutputToString()).To(ContainSubstring(testString)) - }) It("podman run with named volume check if we honor permission of target dir", func() { diff --git a/test/e2e/run_working_dir_test.go b/test/e2e/run_working_dir_test.go index 1d73aeb86b7..91c1f6bf287 100644 --- a/test/e2e/run_working_dir_test.go +++ b/test/e2e/run_working_dir_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("Podman run", func() { - It("podman run a container without workdir", func() { session := podmanTest.Podman([]string{"run", ALPINE, "pwd"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go index c1bd0b7b19a..bbc4a584c0f 100644 --- a/test/e2e/runlabel_test.go +++ b/test/e2e/runlabel_test.go @@ -23,7 +23,6 @@ FROM %s LABEL RUN podman run --name NAME IMAGE`, ALPINE) var _ = Describe("podman container runlabel", func() { - BeforeEach(func() { SkipIfRemote("runlabel is not supported for remote connections") }) diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index 8243977874d..38e0e4ac486 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -16,7 +16,6 @@ import ( ) var _ = Describe("Podman save", func() { - It("podman save output flag", func() { outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") @@ -109,7 +108,6 @@ var _ = Describe("Podman save", func() { save = podmanTest.Podman([]string{"save", "-q", "--compress", "--format", "oci-archive", "-o", outdir, ALPINE}) save.WaitWithDefaultTimeout() Expect(save).To(ExitWithError(125, "--compress can only be set when --format is 'docker-dir'")) - }) It("podman save bad filename", func() { diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 4e7f2f85ea1..ba71f79b46e 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -27,7 +27,6 @@ func (e *endpoint) Address() string { } var _ = Describe("Podman search", func() { - const regFileContents = ` [registries.search] registries = ['{{.Host}}:{{.Port}}'] @@ -49,9 +48,11 @@ registries = []` Skip("No registry image for ppc64le") } port := GetPort() - fakereg := podmanTest.Podman([]string{"run", "-d", "--name", name, + fakereg := podmanTest.Podman([]string{ + "run", "-d", "--name", name, "-p", fmt.Sprintf("%d:5000", port), - REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml"}) + REGISTRY_IMAGE, "/entrypoint.sh", "/etc/docker/registry/config.yml", + }) fakereg.WaitWithDefaultTimeout() Expect(fakereg).Should(ExitCleanly()) @@ -224,7 +225,6 @@ registries = []` search := podmanTest.PodmanExitCleanly("search", "--limit", "100", "--tls-verify=false", registryAddress+"/podman") Expect(len(search.OutputToStringArray())).To(BeNumerically("<=", 101)) }) - }) Context("podman search with container-based registries", func() { diff --git a/test/e2e/secret_test.go b/test/e2e/secret_test.go index c09b1b9c1e9..e7554c84257 100644 --- a/test/e2e/secret_test.go +++ b/test/e2e/secret_test.go @@ -14,7 +14,6 @@ import ( ) var _ = Describe("Podman secret", func() { - AfterEach(func() { podmanTest.CleanupSecrets() }) @@ -212,7 +211,6 @@ var _ = Describe("Podman secret", func() { list.WaitWithDefaultTimeout() Expect(list).Should(ExitCleanly()) Expect(list.OutputToStringArray()).To(HaveLen(2)) - }) It("podman secret ls --quiet", func() { @@ -242,7 +240,6 @@ var _ = Describe("Podman secret", func() { list.WaitWithDefaultTimeout() Expect(list).Should(ExitCleanly()) Expect(list.OutputToString()).To(Equal(secretName)) - }) It("podman secret ls with filters", func() { @@ -473,7 +470,6 @@ var _ = Describe("Podman secret", func() { inspect.WaitWithDefaultTimeout() Expect(inspect).Should(ExitCleanly()) Expect(inspect.OutputToString()).To(Equal("map[]")) - }) It("podman secret exists should return true if secret exists", func() { diff --git a/test/e2e/start_test.go b/test/e2e/start_test.go index 7d06fd864ac..4ac516fe7a8 100644 --- a/test/e2e/start_test.go +++ b/test/e2e/start_test.go @@ -15,7 +15,6 @@ import ( ) var _ = Describe("Podman start", func() { - It("podman start bogus container", func() { session := podmanTest.Podman([]string{"start", "123"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/stats_test.go b/test/e2e/stats_test.go index fa6b026f56e..c87c6dfd06a 100644 --- a/test/e2e/stats_test.go +++ b/test/e2e/stats_test.go @@ -15,7 +15,6 @@ import ( // TODO: we need to check the output. Currently, we only check the exit codes // which is not enough. var _ = Describe("Podman stats", func() { - BeforeEach(func() { SkipIfRootlessCgroupsV1("stats not supported on cgroupv1 for rootless users") if isContainerized() { diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go index 53d48fc78f3..a597b6150b1 100644 --- a/test/e2e/stop_test.go +++ b/test/e2e/stop_test.go @@ -14,7 +14,6 @@ import ( ) var _ = Describe("Podman stop", func() { - It("podman stop bogus container", func() { session := podmanTest.Podman([]string{"stop", "foobar"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/system_df_test.go b/test/e2e/system_df_test.go index 4af544f5bb4..7dc87ef39ad 100644 --- a/test/e2e/system_df_test.go +++ b/test/e2e/system_df_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("podman system df", func() { - It("podman system df", func() { session := podmanTest.Podman([]string{"create", ALPINE}) session.WaitWithDefaultTimeout() @@ -58,7 +57,6 @@ var _ = Describe("podman system df", func() { volumes = strings.Fields(session.OutputToStringArray()[3]) // percentages on volumes were being calculated incorrectly. Make sure we only report 100% and not above Expect(volumes[6]).To(Equal("(100%)"), "percentage usage expected") - }) It("podman system df image with no tag", func() { @@ -91,7 +89,6 @@ var _ = Describe("podman system df", func() { for i, out := range session.OutputToStringArray() { Expect(out).To(BeValidJSON(), "line %d failed to be parsed", i) } - }) It("podman system df --format with --verbose", func() { @@ -112,5 +109,4 @@ var _ = Describe("podman system df", func() { Expect(session.OutputToString()).To(ContainSubstring("Reclaimable")) Expect(session.OutputToString()).To(BeValidJSON()) }) - }) diff --git a/test/e2e/system_dial_stdio_test.go b/test/e2e/system_dial_stdio_test.go index 8d0a96e3fa5..4c5695d6fcf 100644 --- a/test/e2e/system_dial_stdio_test.go +++ b/test/e2e/system_dial_stdio_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("podman system dial-stdio", func() { - It("podman system dial-stdio help", func() { session := podmanTest.Podman([]string{"system", "dial-stdio", "--help"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/system_reset_test.go b/test/e2e/system_reset_test.go index 48aebbc4cc2..f6297d31d36 100644 --- a/test/e2e/system_reset_test.go +++ b/test/e2e/system_reset_test.go @@ -12,7 +12,6 @@ import ( // system reset must run serial: https://github.com/containers/podman/issues/17903 var _ = Describe("podman system reset", Serial, func() { - It("podman system reset", func() { SkipIfRemote("system reset not supported on podman --remote") // system reset will not remove additional store images, so need to grab length diff --git a/test/e2e/systemd_activate_test.go b/test/e2e/systemd_activate_test.go index 396d4c57c53..016c81508bc 100644 --- a/test/e2e/systemd_activate_test.go +++ b/test/e2e/systemd_activate_test.go @@ -35,7 +35,7 @@ var _ = Describe("Systemd activate", func() { switch { case errors.Is(err, fs.ErrNotExist): Skip(activate + " required for systemd activation tests") - case stat.Mode()&0111 == 0: + case stat.Mode()&0o111 == 0: Skip("Unable to execute " + activate) case err != nil: Skip(err.Error()) @@ -56,7 +56,8 @@ var _ = Describe("Systemd activate", func() { "-E", "HTTP_PROXY", "-E", "HTTPS_PROXY", "-E", "NO_PROXY", "-E", "XDG_RUNTIME_DIR", "--listen", addr, - podmanTest.PodmanBinary} + podmanTest.PodmanBinary, + } systemdArgs = append(systemdArgs, podmanOptions...) systemdArgs = append(systemdArgs, "system", "service", "--time=0") diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go index e2dac181e45..f8d15e12fb4 100644 --- a/test/e2e/systemd_test.go +++ b/test/e2e/systemd_test.go @@ -15,7 +15,6 @@ import ( ) var _ = Describe("Podman systemd", func() { - It("podman run container with systemd PID1", func() { ctrName := "testSystemd" run := podmanTest.Podman([]string{"run", "--name", ctrName, "-t", "-i", "-d", SYSTEMD_IMAGE, "/sbin/init"}) diff --git a/test/e2e/tag_test.go b/test/e2e/tag_test.go index b50bc32f003..23944e060a4 100644 --- a/test/e2e/tag_test.go +++ b/test/e2e/tag_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman tag", func() { - BeforeEach(func() { podmanTest.AddImageToRWStore(ALPINE) }) diff --git a/test/e2e/toolbox_test.go b/test/e2e/toolbox_test.go index 83ed3d60f48..49eadd3d7b4 100644 --- a/test/e2e/toolbox_test.go +++ b/test/e2e/toolbox_test.go @@ -43,18 +43,21 @@ import ( ) var _ = Describe("Toolbox-specific testing", func() { - It("podman run --dns=none - allows self-management of /etc/resolv.conf", func() { - session := podmanTest.Podman([]string{"run", "--dns", "none", ALPINE, "sh", "-c", - "rm -f /etc/resolv.conf; touch -d '1970-01-01 00:02:03' /etc/resolv.conf; stat -c %s:%Y /etc/resolv.conf"}) + session := podmanTest.Podman([]string{ + "run", "--dns", "none", ALPINE, "sh", "-c", + "rm -f /etc/resolv.conf; touch -d '1970-01-01 00:02:03' /etc/resolv.conf; stat -c %s:%Y /etc/resolv.conf", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0:123")) }) It("podman run --no-hosts - allows self-management of /etc/hosts", func() { - session := podmanTest.Podman([]string{"run", "--no-hosts", ALPINE, "sh", "-c", - "rm -f /etc/hosts; touch -d '1970-01-01 00:02:03' /etc/hosts; stat -c %s:%Y /etc/hosts"}) + session := podmanTest.Podman([]string{ + "run", "--no-hosts", ALPINE, "sh", "-c", + "rm -f /etc/hosts; touch -d '1970-01-01 00:02:03' /etc/hosts; stat -c %s:%Y /etc/hosts", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("0:123")) @@ -78,8 +81,10 @@ var _ = Describe("Toolbox-specific testing", func() { Expect(err).ToNot(HaveOccurred()) GinkgoWriter.Printf("Expected value: %d", rlimit.Max) - session = podmanTest.Podman([]string{"create", "--name", "test", "--ulimit", "host", ALPINE, - "sleep", "1000"}) + session = podmanTest.Podman([]string{ + "create", "--name", "test", "--ulimit", "host", ALPINE, + "sleep", "1000", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -87,8 +92,10 @@ var _ = Describe("Toolbox-specific testing", func() { session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - session = podmanTest.Podman([]string{"exec", "test", "sh", "-c", - "ulimit -H -n"}) + session = podmanTest.Podman([]string{ + "exec", "test", "sh", "-c", + "ulimit -H -n", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) containerHardLimit, err = strconv.Atoi(strings.Trim(session.OutputToString(), "\n")) @@ -119,8 +126,10 @@ var _ = Describe("Toolbox-specific testing", func() { hostShmSize, err = strconv.Atoi(fields[1]) Expect(err).ToNot(HaveOccurred()) - session = podmanTest.Podman([]string{"create", "--name", "test", "--ipc=host", "--pid=host", ALPINE, - "sleep", "1000"}) + session = podmanTest.Podman([]string{ + "create", "--name", "test", "--ipc=host", "--pid=host", ALPINE, + "sleep", "1000", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -128,8 +137,10 @@ var _ = Describe("Toolbox-specific testing", func() { session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - session = podmanTest.Podman([]string{"exec", "test", - "df", "/dev/shm"}) + session = podmanTest.Podman([]string{ + "exec", "test", + "df", "/dev/shm", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) lines = session.OutputToStringArray() @@ -145,8 +156,10 @@ var _ = Describe("Toolbox-specific testing", func() { It("podman create --userns=keep-id --user root:root - entrypoint - entrypoint is executed as root", func() { SkipIfNotRootless("only meaningful when run rootless") - session := podmanTest.Podman([]string{"run", "--userns=keep-id", "--user", "root:root", ALPINE, - "id"}) + session := podmanTest.Podman([]string{ + "run", "--userns=keep-id", "--user", "root:root", ALPINE, + "id", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring("uid=0(root) gid=0(root)")) @@ -163,8 +176,10 @@ var _ = Describe("Toolbox-specific testing", func() { currentGroup, err := user.LookupGroupId(currentUser.Gid) Expect(err).ToNot(HaveOccurred()) - session = podmanTest.Podman([]string{"create", "--name", "test", "--userns=keep-id", ALPINE, - "sleep", "1000"}) + session = podmanTest.Podman([]string{ + "create", "--name", "test", "--userns=keep-id", ALPINE, + "sleep", "1000", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(err).ToNot(HaveOccurred()) @@ -177,8 +192,10 @@ var _ = Describe("Toolbox-specific testing", func() { currentUser.Uid, currentUser.Username, currentGroup.Gid, currentGroup.Name) - session = podmanTest.Podman([]string{"exec", "test", - "id"}) + session = podmanTest.Podman([]string{ + "exec", "test", + "id", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(expectedOutput)) @@ -189,9 +206,11 @@ var _ = Describe("Toolbox-specific testing", func() { groupLine := "testuser:x:1001:" // ensure that the container can edit passwd and group files - session := podmanTest.Podman([]string{"run", "--log-driver", "k8s-file", "--name", "test", "--userns=keep-id", + session := podmanTest.Podman([]string{ + "run", "--log-driver", "k8s-file", "--name", "test", "--userns=keep-id", "--user", "root:root", ALPINE, "sh", "-c", - fmt.Sprintf("echo %s > /etc/passwd && echo %s > /etc/group && cat /etc/passwd && cat /etc/group", passwdLine, groupLine)}) + fmt.Sprintf("echo %s > /etc/passwd && echo %s > /etc/group && cat /etc/passwd && cat /etc/group", passwdLine, groupLine), + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).Should(ContainSubstring(passwdLine)) @@ -202,13 +221,17 @@ var _ = Describe("Toolbox-specific testing", func() { SkipIfNotRootless("only meaningful when run rootless") var session *PodmanSessionIntegration - session = podmanTest.Podman([]string{"run", "--privileged", "--userns=keep-id", "--user", "root:root", ALPINE, - "mount", "-t", define.TypeTmpfs, define.TypeTmpfs, "/tmp"}) + session = podmanTest.Podman([]string{ + "run", "--privileged", "--userns=keep-id", "--user", "root:root", ALPINE, + "mount", "-t", define.TypeTmpfs, define.TypeTmpfs, "/tmp", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) - session = podmanTest.Podman([]string{"run", "--privileged", "--userns=keep-id", "--user", "root:root", ALPINE, - "mount", "--rbind", "/tmp", "/var/tmp"}) + session = podmanTest.Podman([]string{ + "run", "--privileged", "--userns=keep-id", "--user", "root:root", ALPINE, + "mount", "--rbind", "/tmp", "/var/tmp", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) }) @@ -218,7 +241,8 @@ var _ = Describe("Toolbox-specific testing", func() { // These should be most of the switches that Toolbox uses to create a "toolbox" container // https://github.com/containers/toolbox/blob/main/src/cmd/create.go - session := podmanTest.Podman([]string{"create", + session := podmanTest.Podman([]string{ + "create", "--log-driver", "k8s-file", "--dns", "none", "--hostname", "toolbox", @@ -233,7 +257,8 @@ var _ = Describe("Toolbox-specific testing", func() { "--ulimit", "host", "--userns=keep-id", "--user", "root:root", - ALPINE, "sh", "-c", "echo READY"}) + ALPINE, "sh", "-c", "echo READY", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -256,13 +281,14 @@ var _ = Describe("Toolbox-specific testing", func() { location := path.Dir(currentUser.HomeDir) volumeArg := fmt.Sprintf("%s:%s", location, location) - session = podmanTest.Podman([]string{"run", + session = podmanTest.Podman([]string{ + "run", "--userns=keep-id", "--volume", volumeArg, - ALPINE, "sh", "-c", "echo $HOME"}) + ALPINE, "sh", "-c", "echo $HOME", + }) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) Expect(session.OutputToString()).To(ContainSubstring(currentUser.HomeDir)) }) - }) diff --git a/test/e2e/top_test.go b/test/e2e/top_test.go index fa09fa4f00d..9f2503a420c 100644 --- a/test/e2e/top_test.go +++ b/test/e2e/top_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman top", func() { - It("podman top without container name or id", func() { result := podmanTest.Podman([]string{"top"}) result.WaitWithDefaultTimeout() diff --git a/test/e2e/tree_test.go b/test/e2e/tree_test.go index 6bb1d4385d1..d5cbe08c862 100644 --- a/test/e2e/tree_test.go +++ b/test/e2e/tree_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman image tree", func() { - BeforeEach(func() { podmanTest.AddImageToRWStore(BB) }) diff --git a/test/e2e/trust_test.go b/test/e2e/trust_test.go index 68e0c48c4bb..c8ca66620a0 100644 --- a/test/e2e/trust_test.go +++ b/test/e2e/trust_test.go @@ -14,7 +14,6 @@ import ( // Without Ordered, tests flake with "Getting key identity" (#18358) var _ = Describe("Podman trust", Ordered, func() { - BeforeEach(func() { SkipIfRemote("podman-remote does not support image trust") }) diff --git a/test/e2e/untag_test.go b/test/e2e/untag_test.go index 384be919434..e83f98bec28 100644 --- a/test/e2e/untag_test.go +++ b/test/e2e/untag_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman untag", func() { - It("podman untag all", func() { podmanTest.AddImageToRWStore(CIRROS_IMAGE) tags := []string{CIRROS_IMAGE, "registry.com/foo:bar", "localhost/foo:bar"} @@ -72,5 +71,4 @@ var _ = Describe("Podman untag", func() { Expect(session).Should(ExitWithError(1, "")) } }) - }) diff --git a/test/e2e/update_test.go b/test/e2e/update_test.go index 988aa0335c0..c86782cc2aa 100644 --- a/test/e2e/update_test.go +++ b/test/e2e/update_test.go @@ -12,7 +12,6 @@ import ( ) var _ = Describe("Podman update", func() { - It("podman update container all options v1", func() { SkipIfCgroupV2("testing flags that only work in cgroup v1") SkipIfRootless("many of these handlers are not enabled while rootless in CI") @@ -32,7 +31,8 @@ var _ = Describe("Podman update", func() { "--memory-swap", "2G", "--memory-reservation", "2G", "--memory-swappiness", "50", - "--pids-limit", "123", ctrID} + "--pids-limit", "123", ctrID, + } session = podmanTest.Podman(commonArgs) session.WaitWithDefaultTimeout() @@ -72,7 +72,8 @@ var _ = Describe("Podman update", func() { commonArgs := []string{ "update", "--cpus", "5", - ctrID} + ctrID, + } session = podmanTest.Podman(commonArgs) session.WaitWithDefaultTimeout() @@ -109,7 +110,8 @@ var _ = Describe("Podman update", func() { "--device-read-iops", "/dev/nullb0:1000", "--device-write-iops", "/dev/nullb0:1000", "--pids-limit", "123", - ctrID} + ctrID, + } session = podmanTest.Podman(commonArgs) session.WaitWithDefaultTimeout() diff --git a/test/e2e/version_test.go b/test/e2e/version_test.go index dd7ac3634db..0340413f554 100644 --- a/test/e2e/version_test.go +++ b/test/e2e/version_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("Podman version", func() { - It("podman version", func() { session := podmanTest.Podman([]string{"version"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/volume_create_test.go b/test/e2e/volume_create_test.go index ba6003f6d8e..4cb289dd6e7 100644 --- a/test/e2e/volume_create_test.go +++ b/test/e2e/volume_create_test.go @@ -13,7 +13,6 @@ import ( ) var _ = Describe("Podman volume create", func() { - AfterEach(func() { podmanTest.CleanupVolume() }) diff --git a/test/e2e/volume_exists_test.go b/test/e2e/volume_exists_test.go index d959d668bf2..85d4f70c6a7 100644 --- a/test/e2e/volume_exists_test.go +++ b/test/e2e/volume_exists_test.go @@ -10,7 +10,6 @@ import ( ) var _ = Describe("Podman volume exists", func() { - AfterEach(func() { podmanTest.CleanupVolume() }) diff --git a/test/e2e/volume_inspect_test.go b/test/e2e/volume_inspect_test.go index 49407811846..4d9346368fa 100644 --- a/test/e2e/volume_inspect_test.go +++ b/test/e2e/volume_inspect_test.go @@ -10,7 +10,6 @@ import ( ) var _ = Describe("Podman volume inspect", func() { - AfterEach(func() { podmanTest.CleanupVolume() }) diff --git a/test/e2e/volume_ls_test.go b/test/e2e/volume_ls_test.go index 9db0eeb39f4..7a3a1eeb7a4 100644 --- a/test/e2e/volume_ls_test.go +++ b/test/e2e/volume_ls_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Podman volume ls", func() { - AfterEach(func() { podmanTest.CleanupVolume() }) diff --git a/test/e2e/volume_plugin_test.go b/test/e2e/volume_plugin_test.go index 28df87c5dc6..b4df0cd07e5 100644 --- a/test/e2e/volume_plugin_test.go +++ b/test/e2e/volume_plugin_test.go @@ -207,8 +207,10 @@ testvol5 = "/run/docker/plugins/testvol5.sock"`), 0o644) // Keep this distinct within tests to avoid multiple tests using the same plugin. pluginName := "testvol5" ctrName := "pluginCtr" - plugin := podmanTest.Podman([]string{"run", "--name", ctrName, "--security-opt", "label=disable", "-v", "/run/docker/plugins:/run/docker/plugins", - "-v", fmt.Sprintf("%v:%v", pluginStatePath, pluginStatePath), "-d", volumeTest, "--sock-name", pluginName, "--path", pluginStatePath}) + plugin := podmanTest.Podman([]string{ + "run", "--name", ctrName, "--security-opt", "label=disable", "-v", "/run/docker/plugins:/run/docker/plugins", + "-v", fmt.Sprintf("%v:%v", pluginStatePath, pluginStatePath), "-d", volumeTest, "--sock-name", pluginName, "--path", pluginStatePath, + }) plugin.WaitWithDefaultTimeout() Expect(plugin).Should(ExitCleanly()) diff --git a/test/e2e/volume_prune_test.go b/test/e2e/volume_prune_test.go index d59dafd9883..0453fcd2516 100644 --- a/test/e2e/volume_prune_test.go +++ b/test/e2e/volume_prune_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("Podman volume prune", func() { - AfterEach(func() { podmanTest.CleanupVolume() }) diff --git a/test/e2e/volume_rm_test.go b/test/e2e/volume_rm_test.go index c2de1538329..fda75ce50b0 100644 --- a/test/e2e/volume_rm_test.go +++ b/test/e2e/volume_rm_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Podman volume rm", func() { - AfterEach(func() { podmanTest.CleanupVolume() }) diff --git a/test/e2e/wait_test.go b/test/e2e/wait_test.go index c7bc2fe300b..76cdd0717c3 100644 --- a/test/e2e/wait_test.go +++ b/test/e2e/wait_test.go @@ -9,12 +9,10 @@ import ( ) var _ = Describe("Podman wait", func() { - It("podman wait on bogus container", func() { session := podmanTest.Podman([]string{"wait", "1234"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitWithError(125, `no container with name or ID "1234" found: no such container`)) - }) It("podman wait on a stopped container", func() { diff --git a/test/utils/common_function_test.go b/test/utils/common_function_test.go index 8db40bf1f08..45b262ae917 100644 --- a/test/utils/common_function_test.go +++ b/test/utils/common_function_test.go @@ -140,5 +140,4 @@ var _ = Describe("Common functions test", func() { Expect(err).ToNot(HaveOccurred(), "Cannot find the private key file after we write it.") defer read.Close() }) - }) diff --git a/test/utils/podmansession_test.go b/test/utils/podmansession_test.go index 807dcc23912..275cd6717cd 100644 --- a/test/utils/podmansession_test.go +++ b/test/utils/podmansession_test.go @@ -38,7 +38,6 @@ var _ = Describe("PodmanSession test", func() { match, backStr = session.GrepString("I am not here") Expect(match).To(Not(BeTrue())) Expect(backStr).To(BeNil()) - }) It("Test ErrorGrepString", func() { @@ -49,7 +48,6 @@ var _ = Describe("PodmanSession test", func() { match, backStr = session.ErrorGrepString("I am not here") Expect(match).To(Not(BeTrue())) Expect(backStr).To(BeNil()) - }) It("Test LineInOutputStartsWith", func() { @@ -86,5 +84,4 @@ var _ = Describe("PodmanSession test", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).Should(Equal(0)) }) - }) diff --git a/test/utils/podmantest_test.go b/test/utils/podmantest_test.go index 26e89490caa..94c297cc871 100644 --- a/test/utils/podmantest_test.go +++ b/test/utils/podmantest_test.go @@ -58,5 +58,4 @@ var _ = Describe("PodmanTest test", func() { FakeOutputs["logs testimage"] = []string{"I am ready"} Expect(WaitContainerReady(podmanTest, "testimage", "", 2, 1)).To(BeTrue()) }) - }) diff --git a/test/utils/utils_suite_test.go b/test/utils/utils_suite_test.go index 7d790e3b74b..35c2d6c6775 100644 --- a/test/utils/utils_suite_test.go +++ b/test/utils/utils_suite_test.go @@ -12,8 +12,10 @@ import ( "github.com/onsi/gomega/gexec" ) -var FakeOutputs map[string][]string -var GoechoPath = "../goecho/goecho" +var ( + FakeOutputs map[string][]string + GoechoPath = "../goecho/goecho" +) type FakePodmanTest struct { PodmanTest