diff options
202 files changed, 295 insertions, 431 deletions
diff --git a/.github/workflows/check_cirrus_cron.yml b/.github/workflows/check_cirrus_cron.yml index 86f8c26dc..d869576fd 100644 --- a/.github/workflows/check_cirrus_cron.yml +++ b/.github/workflows/check_cirrus_cron.yml @@ -6,6 +6,7 @@ name: check_cirrus_cron on: + # Note: This only applies to the master branch. schedule: # Assume cirrus cron jobs runs at least once per day - cron: '59 23 * * *' @@ -54,6 +55,7 @@ jobs: echo "# Source: ${{ github.workflow }} workflow on ${{ github.repository }}." # Separate content from sendgrid.com automatic footer. echo "" + echo "" ) > ./artifacts/email_body.txt - if: steps.cron.outputs.failures > 0 diff --git a/.golangci.yml b/.golangci.yml index 6e46d55cd..76cf0cad8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -20,7 +20,6 @@ linters: # All these break for one reason or another - nolintlint - gocognit - - stylecheck - testpackage - goerr113 - exhaustivestruct @@ -40,7 +39,6 @@ linters: - staticcheck - forbidigo - exhaustive - - whitespace - unparam - gofumpt - gci @@ -52,7 +50,6 @@ linters: - gochecknoinits - goconst - gocyclo - - golint - lll - structcheck - typecheck @@ -5,7 +5,7 @@ Podman (the POD MANager) is a tool for managing containers and images, volumes mounted into those containers, and pods made from groups of containers. Podman is based on libpod, a library for container lifecycle management that is also contained in this repository. The libpod library provides APIs for managing containers, pods, container images, and volumes. -* [Latest Version: 2.2.1](https://github.com/containers/podman/releases/latest) +* [Latest Version: 3.0.0](https://github.com/containers/podman/releases/latest) * Latest Remote client for Windows * Latest Remote client for MacOs * Latest Static Remote client for Linux diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 82ecd741a..17d90aeca 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -13,7 +13,10 @@ - The `podman container checkpoint` command now supports the `--with-previous` and `--pre-checkpoint` options, and the `podman container restore` command now support the `--import-previous` option. These add support for two-step checkpointing with lowered dump times. - The `podman push` command can now push manifest lists. Podman will first attempt to push as an image, then fall back to pushing as a manifest list if that fails. - The `podman generate kube` command can now be run on multiple containers at once, and will generate a single pod containing all of them. +- The `podman generate kube` and `podman play kube` commands now support Kubernetes DNS configuration, and will preserve custom DNS configuration when exporting or importing YAML ([#9132](https://github.com/containers/podman/issues/9132)). +- The `podman generate kube` command now properly supports generating YAML for containers and pods creating using host networking (`--net=host`) ([#9077](https://github.com/containers/podman/issues/9077)). - The `podman kill` command now supports a `--cidfile` option to kill containers given a file containing the container's ID ([#8443](https://github.com/containers/podman/issues/8443)). +- The `podman pod create` command now supports the `--net=none` option ([#9165](https://github.com/containers/podman/issues/9165)). - The `podman volume create` command can now specify volume UID and GID as options with the `UID` and `GID` fields passed to the the `--opt` option. - Initial support has been added for Docker Volume Plugins. Podman can now define available plugins in `containers.conf` and use them to create volumes with `podman volume create --driver`. - The `podman run` and `podman create` commands now support a new option, `--platform`, to specify the platform of the image to be used when creating the container. @@ -30,6 +33,10 @@ - The `podman image sign` command can now sign multi-arch images by producing a signature for each image in a given manifest list. - The `podman image sign` command, when run as rootless, now supports per-user registry configuration files in `$HOME/.config/containers/registries.d`. - Configuration options for `slirp4netns` can now be set system-wide via the `NetworkCmdOptions` configuration option in `containers.conf`. +- The MTU of `slirp4netns` can now be configured via the `mtu=` network command option (e.g. `podman run --net slirp4netns:mtu=9000`). + +### Security +- A fix for CVE-2021-20199 is included. Podman between v1.8.0 and v2.2.1 used `127.0.0.1` as the source address for all traffic forwarded into rootless containers by a forwarded port; this has been changed to address the issue. ### Changes - Shortname aliasing support has now been turned on by default. All Podman commands that must pull an image will, if a TTY is available, prompt the user about what image to pull. @@ -37,6 +44,7 @@ - The Go bindings for the HTTP API have been rewritten with a focus on limiting dependency footprint and improving extensibility. Read more [here](https://github.com/containers/podman/blob/v3.0/pkg/bindings/README.md). - The legacy Varlink API has been completely removed from Podman. - The default log level for Podman has been changed from Error to Warn. +- The `podman network create` command can now create `macvlan` networks using the `--driver macvlan` option for Docker compatibility. The existing `--macvlan` flag has been deprecated and will be removed in Podman 4.0 some time next year. - The `podman inspect` command has had the `LogPath` and `LogTag` fields moved into the `LogConfig` structure (from the root of the Inspect structure). The maximum size of the log file is also included. - The `podman generate systemd` command no longer generates unit files using the deprecated `KillMode=none` option ([#8615](https://github.com/containers/podman/issues/8615)). - The `podman stop` command now releases the container lock while waiting for it to stop - as such, commands like `podman ps` will no longer block until `podman stop` completes ([#8501](https://github.com/containers/podman/issues/8501)). @@ -53,6 +61,7 @@ - Fixed a bug where, under some circumstances, container working directories specified by the image (via the `WORKDIR` instruction) but not present in the image, would not be created ([#9040](https://github.com/containers/podman/issues/9040)). - Fixed a bug where the `podman generate systemd` command would generate invalid unit files if the container was creating using a command line that included doubled braces (`{{` and `}}`), e.g. `--log-opt-tag={{.Name}}` ([#9034](https://github.com/containers/podman/issues/9034)). - Fixed a bug where the `podman generate systemd --new` command could generate unit files including invalid Podman commands if the container was created using merged short options (e.g. `podman run -dt`) ([#8847](https://github.com/containers/podman/issues/8847)). +- Fixed a bug where the `podman generate systemd --new` command could generate unit files that did not handle Podman commands including some special characters (e.g. `$`) ([#9176](https://github.com/containers/podman/issues/9176) - Fixed a bug where rootless containers joining CNI networks could not set a static IP address ([#7842](https://github.com/containers/podman/issues/7842)). - Fixed a bug where rootless containers joining CNI networks could not set network aliases ([#8567](https://github.com/containers/podman/issues/8567)). - Fixed a bug where the remote client could, under some circumstances, not include the `Containerfile` when sending build context to the server ([#8374](https://github.com/containers/podman/issues/8374)). @@ -63,6 +72,8 @@ - Fixed a bug where the `podman play kube` command did not properly print errors that occurred when starting containers. - Fixed a bug where the `podman play kube` command errored when `hostNetwork` was used ([#8790](https://github.com/containers/podman/issues/8790)). - Fixed a bug where the `podman play kube` command would always pull images when the `:latest` tag was specified, even if the image was available locally ([#7838](https://github.com/containers/podman/issues/7838)). +- Fixed a bug where the `podman play kube` command did not properly handle SELinux configuration, rending YAML with custom SELinux configuration unusable ([#8710](https://github.com/containers/podman/issues/8710)). +- Fixed a bug where the `podman generate kube` command incorrectly populated the `args` and `command` fields of generated YAML ([#9211](https://github.com/containers/podman/issues/9211)). - Fixed a bug where containers in a pod would create a duplicate entry in the pod's shared `/etc/hosts` file every time the container restarted ([#8921](https://github.com/containers/podman/issues/8921)). - Fixed a bug where the `podman search --list-tags` command did not support the `--format` option ([#8740](https://github.com/containers/podman/issues/8740)). - Fixed a bug where the `http_proxy` option in `containers.conf` was not being respected, and instead was set unconditionally to true ([#8843](https://github.com/containers/podman/issues/8843)). @@ -96,8 +107,19 @@ - Fixed a bug where `--format` did not support JSON output for individual fields ([#8444](https://github.com/containers/podman/issues/8444)). - Fixed a bug where the `podman stats` command would fail when run on root containers using the `slirp4netns` network mode ([#7883](https://github.com/containers/podman/issues/7883)). - Fixed a bug where the Podman remote client would ask for a password even if the server's SSH daemon did not support password authentication ([#8498](https://github.com/containers/podman/issues/8498)). +- Fixed a bug where the `podman stats` command would fail if the system did not support one or more of the cgroup controllers Podman supports ([#8588](https://github.com/containers/podman/issues/8588)). +- Fixed a bug where the `--mount` option to `podman create` and `podman run` did not ignore the `consistency` mount option. +- Fixed a bug where failures during the resizing of a container's TTY would print the wrong error. +- Fixed a bug where the `podman network disconnect` command could cause the `podman inspect` command to fail for a container until it was restarted ([#9234](https://github.com/containers/podman/issues/9234)). +- Fixed a bug where containers created from a read-only rootfs (using the `--rootfs` option to `podman create` and `podman run`) would fail ([#9230](https://github.com/containers/podman/issues/9230)). +- Fixed a bug where specifying Go templates to the `--format` option to multiple Podman commands did not support the `join` function ([#8773](https://github.com/containers/podman/issues/8773)). +- Fixed a bug where the `podman rmi` command could, when run in parallel on multiple images, return `layer not known` errors ([#6510](https://github.com/containers/podman/issues/6510)). +- Fixed a bug where the `podman inspect` command on containers displayed unlimited ulimits incorrectly ([#9303](https://github.com/containers/podman/issues/9303)). +- Fixed a bug where Podman would fail to start when a volume was mounted over a directory in a container that contained symlinks that terminated outside the directory and its subdirectories ([#6003](https://github.com/containers/podman/issues/6003)). ### API +- Libpod API version has been bumped to v3.0.0. +- All Libpod Pod APIs have been modified to properly report errors with individual containers. Cases where the operation as a whole succeeded but individual containers failed now report an HTTP 409 error ([#8865](https://github.com/containers/podman/issues/8865)). - The Compat API for Containers now supports the Rename and Copy APIs. - Fixed a bug where the Compat Prune APIs (for volumes, containers, and images) did not return the amount of space reclaimed in their responses. - Fixed a bug where the Compat and Libpod Exec APIs for Containers would drop errors that occurred prior to the exec session successfully starting (e.g. a "no such file" error if an invalid executable was passed) ([#8281](https://github.com/containers/podman/issues/8281)) @@ -110,16 +132,19 @@ - Fixed a bug where the Libpod Pull endpoint for Images could fail with an `index out of range` error under certain circumstances ([#8870](https://github.com/containers/podman/issues/8870)). - Fixed a bug where the Libpod Exists endpoint for Images could panic. - Fixed a bug where the Compat List API for Containers did not support all filters ([#8860](https://github.com/containers/podman/issues/8860)). +- Fixed a bug where the Compat List API for Containers did not properly populate the Status field. - Fixed a bug where the Compat and Libpod Resize APIs for Containers ignored the height and width parameters ([#7102](https://github.com/containers/podman/issues/7102)). - Fixed a bug where the Compat Search API for Images returned an incorrectly-formatted JSON response ([#8758](https://github.com/containers/podman/pull/8758)). - Fixed a bug where the Compat Load API for Images did not properly clean up temporary files. - Fixed a bug where the Compat Create API for Networks could panic when an empty IPAM configuration was specified. - Fixed a bug where the Compat Inspect and List APIs for Networks did not include Scope. +- Fixed a bug where the Compat Wait endpoint for Containers did not support the same wait conditions that Docker did. ### Misc - Updated Buildah to v1.19.2 - Updated the containers/storage library to v1.24.5 -- Updated the containers/common library to v0.33.1 +- Updated the containers/image library to v5.10.2 +- Updated the containers/common library to v0.33.4 ## v2.2.1 ### Changes diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index d8935628e..fe43967a2 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -804,5 +804,4 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) { "Configure cgroup v2 (key=value)", ) _ = cmd.RegisterFlagCompletionFunc(cgroupConfFlagName, completion.AutocompleteNone) - } diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go index 67d40ac43..430354ee9 100644 --- a/cmd/podman/common/create_opts.go +++ b/cmd/podman/common/create_opts.go @@ -269,7 +269,6 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup endpointsConfig := cc.NetworkingConfig.EndpointsConfig cniNetworks := make([]string, 0, len(endpointsConfig)) for netName, endpoint := range endpointsConfig { - cniNetworks = append(cniNetworks, netName) if endpoint == nil { diff --git a/cmd/podman/common/createparse.go b/cmd/podman/common/createparse.go index 3a69f11b6..140518cf7 100644 --- a/cmd/podman/common/createparse.go +++ b/cmd/podman/common/createparse.go @@ -26,5 +26,4 @@ func (c *ContainerCLIOpts) validate() error { return errors.Errorf("invalid image-volume type %q. Pick one of bind, tmpfs, or ignore", c.ImageVolume) } return nil - } diff --git a/cmd/podman/containers/attach.go b/cmd/podman/containers/attach.go index f00c5378b..7c7d780bc 100644 --- a/cmd/podman/containers/attach.go +++ b/cmd/podman/containers/attach.go @@ -68,7 +68,6 @@ func init() { }) attachFlags(containerAttachCommand) validate.AddLatestFlag(containerAttachCommand, &attachOpts.Latest) - } func attach(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index 31f44d92f..bfb821159 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -142,11 +142,19 @@ func checkFlags(c *cobra.Command) error { } func jsonOut(responses []entities.ListContainer) error { - r := make([]entities.ListContainer, 0) + type jsonFormat struct { + entities.ListContainer + Created int64 + } + r := make([]jsonFormat, 0) for _, con := range responses { con.CreatedAt = units.HumanDuration(time.Since(con.Created)) + " ago" con.Status = psReporter{con}.Status() - r = append(r, con) + jf := jsonFormat{ + ListContainer: con, + Created: con.Created.UnixNano(), + } + r = append(r, jf) } b, err := json.MarshalIndent(r, "", " ") if err != nil { @@ -243,12 +251,12 @@ func ps(cmd *cobra.Command, _ []string) error { // responses will grow to the largest number of processes reported on, but will not thrash the gc var responses []psReporter for ; ; responses = responses[:0] { - if ctnrs, err := getResponses(); err != nil { + ctnrs, err := getResponses() + if err != nil { return err - } else { - for _, r := range ctnrs { - responses = append(responses, psReporter{r}) - } + } + for _, r := range ctnrs { + responses = append(responses, psReporter{r}) } tm.Clear() diff --git a/cmd/podman/containers/restore.go b/cmd/podman/containers/restore.go index 49c0be88e..61bd84219 100644 --- a/cmd/podman/containers/restore.go +++ b/cmd/podman/containers/restore.go @@ -118,5 +118,4 @@ func restore(_ *cobra.Command, args []string) error { } } return errs.PrintErrors() - } diff --git a/cmd/podman/containers/wait.go b/cmd/podman/containers/wait.go index 7a531b98a..7831ef1c9 100644 --- a/cmd/podman/containers/wait.go +++ b/cmd/podman/containers/wait.go @@ -56,7 +56,6 @@ func waitFlags(cmd *cobra.Command) { conditionFlagName := "condition" flags.StringVar(&waitCondition, conditionFlagName, "stopped", "Condition to wait on") _ = cmd.RegisterFlagCompletionFunc(conditionFlagName, common.AutocompleteWaitCondition) - } func init() { diff --git a/cmd/podman/generate/systemd.go b/cmd/podman/generate/systemd.go index f9099d3b8..7b2d9ebb7 100644 --- a/cmd/podman/generate/systemd.go +++ b/cmd/podman/generate/systemd.go @@ -128,7 +128,6 @@ func systemd(cmd *cobra.Command, args []string) error { default: return errors.Errorf("unknown --format argument: %s", format) } - } func printDefault(units map[string]string) error { diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go index 8a7951923..65486e3ba 100644 --- a/cmd/podman/images/list.go +++ b/cmd/podman/images/list.go @@ -275,7 +275,6 @@ func tokenRepoTag(ref string) (string, string, error) { } return name, tag, nil - } func sortFunc(key string, data []imageReporter) func(i, j int) bool { diff --git a/cmd/podman/images/prune.go b/cmd/podman/images/prune.go index 268a68681..8ded8d352 100644 --- a/cmd/podman/images/prune.go +++ b/cmd/podman/images/prune.go @@ -48,7 +48,6 @@ func init() { flags.StringArrayVar(&filter, filterFlagName, []string{}, "Provide filter values (e.g. 'label=<key>=<value>')") //TODO: add completion for filters _ = pruneCmd.RegisterFlagCompletionFunc(filterFlagName, completion.AutocompleteNone) - } func prune(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/images/pull.go b/cmd/podman/images/pull.go index fe92baebe..3b2595757 100644 --- a/cmd/podman/images/pull.go +++ b/cmd/podman/images/pull.go @@ -110,11 +110,9 @@ func pullFlags(cmd *cobra.Command) { _ = cmd.RegisterFlagCompletionFunc(authfileFlagName, completion.AutocompleteDefault) if !registry.IsRemote() { - certDirFlagName := "cert-dir" flags.StringVar(&pullOptions.CertDir, certDirFlagName, "", "`Pathname` of a directory containing TLS certificates and keys") _ = cmd.RegisterFlagCompletionFunc(certDirFlagName, completion.AutocompleteDefault) - } _ = flags.MarkHidden("signature-policy") } diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go index c8ea4b04a..b8274cfce 100644 --- a/cmd/podman/images/search.go +++ b/cmd/podman/images/search.go @@ -156,12 +156,12 @@ func imageSearch(cmd *cobra.Command, args []string) error { return errors.Errorf("filters are not applicable to list tags result") } if report.IsJSON(searchOptions.Format) { - listTagsEntries := buildListTagsJson(searchReport) - return printJson(listTagsEntries) + listTagsEntries := buildListTagsJSON(searchReport) + return printArbitraryJSON(listTagsEntries) } row = "{{.Name}}\t{{.Tag}}\n" case report.IsJSON(searchOptions.Format): - return printJson(searchReport) + return printArbitraryJSON(searchReport) case cmd.Flags().Changed("format"): renderHeaders = parse.HasTable(searchOptions.Format) row = report.NormalizeFormat(searchOptions.Format) @@ -186,7 +186,7 @@ func imageSearch(cmd *cobra.Command, args []string) error { return tmpl.Execute(w, searchReport) } -func printJson(v interface{}) error { +func printArbitraryJSON(v interface{}) error { prettyJSON, err := json.MarshalIndent(v, "", " ") if err != nil { return err @@ -195,7 +195,7 @@ func printJson(v interface{}) error { return nil } -func buildListTagsJson(searchReport []entities.ImageSearchReport) []listEntryTag { +func buildListTagsJSON(searchReport []entities.ImageSearchReport) []listEntryTag { entries := []listEntryTag{} ReportLoop: diff --git a/cmd/podman/images/trust_show.go b/cmd/podman/images/trust_show.go index dc35dc6a1..89733a1aa 100644 --- a/cmd/podman/images/trust_show.go +++ b/cmd/podman/images/trust_show.go @@ -42,7 +42,6 @@ func init() { _ = showFlags.MarkHidden("policypath") showFlags.StringVar(&showTrustOptions.RegistryPath, "registrypath", "", "") _ = showFlags.MarkHidden("registrypath") - } func showTrust(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/networks/create.go b/cmd/podman/networks/create.go index 1a091f111..d1cbe253f 100644 --- a/cmd/podman/networks/create.go +++ b/cmd/podman/networks/create.go @@ -80,7 +80,6 @@ func init() { Parent: networkCmd, }) networkCreateFlags(networkCreateCommand) - } func networkCreate(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/networks/inspect.go b/cmd/podman/networks/inspect.go index 671b0265f..bd9f76ea9 100644 --- a/cmd/podman/networks/inspect.go +++ b/cmd/podman/networks/inspect.go @@ -39,5 +39,4 @@ func init() { func networkInspect(_ *cobra.Command, args []string) error { inspectOpts.Type = inspect.NetworkType return inspect.Inspect(args, *inspectOpts) - } diff --git a/cmd/podman/networks/list.go b/cmd/podman/networks/list.go index 16ae980dc..6f63e97cc 100644 --- a/cmd/podman/networks/list.go +++ b/cmd/podman/networks/list.go @@ -51,7 +51,6 @@ func networkListFlags(flags *pflag.FlagSet) { filterFlagName := "filter" flags.StringArrayVarP(&filters, filterFlagName, "f", nil, "Provide filter values (e.g. 'name=podman')") _ = networklistCommand.RegisterFlagCompletionFunc(filterFlagName, common.AutocompleteNetworkFilters) - } func init() { diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go index 4c44fa30f..511e208cf 100644 --- a/cmd/podman/play/kube.go +++ b/cmd/podman/play/kube.go @@ -77,7 +77,6 @@ func init() { _ = kubeCmd.RegisterFlagCompletionFunc(authfileFlagName, completion.AutocompleteDefault) if !registry.IsRemote() { - certDirFlagName := "cert-dir" flags.StringVar(&kubeOptions.CertDir, certDirFlagName, "", "`Pathname` of a directory containing TLS certificates and keys") _ = kubeCmd.RegisterFlagCompletionFunc(certDirFlagName, completion.AutocompleteDefault) diff --git a/cmd/podman/pods/inspect.go b/cmd/podman/pods/inspect.go index e809be0c9..0fbb730ce 100644 --- a/cmd/podman/pods/inspect.go +++ b/cmd/podman/pods/inspect.go @@ -50,7 +50,6 @@ func init() { } func inspect(cmd *cobra.Command, args []string) error { - if len(args) < 1 && !inspectOptions.Latest { return errors.Errorf("you must provide the name or id of a running pod") } diff --git a/cmd/podman/secrets/create.go b/cmd/podman/secrets/create.go index ef5d703ca..8f3ebc3ec 100644 --- a/cmd/podman/secrets/create.go +++ b/cmd/podman/secrets/create.go @@ -59,7 +59,6 @@ func create(cmd *cobra.Command, args []string) error { } if (stat.Mode() & os.ModeNamedPipe) == 0 { return errors.New("if `-` is used, data must be passed into stdin") - } reader = os.Stdin } else { diff --git a/cmd/podman/secrets/list.go b/cmd/podman/secrets/list.go index dff4bfdca..d79e125e8 100644 --- a/cmd/podman/secrets/list.go +++ b/cmd/podman/secrets/list.go @@ -48,7 +48,6 @@ func init() { formatFlagName := "format" flags.StringVar(&listFlag.format, formatFlagName, "{{.ID}}\t{{.Name}}\t{{.Driver}}\t{{.CreatedAt}}\t{{.UpdatedAt}}\t\n", "Format volume output using Go template") _ = lsCmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteJSONFormat) - } func ls(cmd *cobra.Command, args []string) error { @@ -65,7 +64,6 @@ func ls(cmd *cobra.Command, args []string) error { UpdatedAt: units.HumanDuration(time.Since(response.UpdatedAt)) + " ago", Driver: response.Spec.Driver.Name, }) - } return outputTemplate(cmd, listed) } diff --git a/cmd/podman/shell_completion_test.go b/cmd/podman/shell_completion_test.go index d2b500b09..3f6f56fbe 100644 --- a/cmd/podman/shell_completion_test.go +++ b/cmd/podman/shell_completion_test.go @@ -26,14 +26,11 @@ import ( ) func TestShellCompletionFunctions(t *testing.T) { - rootCmd := parseCommands() checkCommand(t, rootCmd) - } func checkCommand(t *testing.T, cmd *cobra.Command) { - if cmd.HasSubCommands() { for _, childCmd := range cmd.Commands() { checkCommand(t, childCmd) @@ -46,7 +43,6 @@ func checkCommand(t *testing.T, cmd *cobra.Command) { // loop over all local flags cmd.LocalFlags().VisitAll(func(flag *pflag.Flag) { - // an error means that there is a completion function for this flag err := cmd.RegisterFlagCompletionFunc(flag.Name, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return nil, cobra.ShellCompDirectiveDefault diff --git a/cmd/podman/system/df.go b/cmd/podman/system/df.go index a9eab24bb..68b244e35 100644 --- a/cmd/podman/system/df.go +++ b/cmd/podman/system/df.go @@ -50,7 +50,6 @@ func init() { formatFlagName := "format" flags.StringVar(&dfOptions.Format, formatFlagName, "", "Pretty-print images using a Go template") _ = dfSystemCommand.RegisterFlagCompletionFunc(formatFlagName, completion.AutocompleteNone) - } func df(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go index 5e96a654a..7ec08366e 100644 --- a/cmd/podman/system/prune.go +++ b/cmd/podman/system/prune.go @@ -51,7 +51,6 @@ func init() { filterFlagName := "filter" flags.StringArrayVar(&filters, filterFlagName, []string{}, "Provide filter values (e.g. 'label=<key>=<value>')") _ = pruneCommand.RegisterFlagCompletionFunc(filterFlagName, completion.AutocompleteNone) - } func prune(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/system/renumber.go b/cmd/podman/system/renumber.go index b1683395f..37f9a5865 100644 --- a/cmd/podman/system/renumber.go +++ b/cmd/podman/system/renumber.go @@ -39,7 +39,6 @@ func init() { Command: renumberCommand, Parent: systemCmd, }) - } func renumber(cmd *cobra.Command, args []string) { // Shutdown all running engines, `renumber` will hijack all methods diff --git a/contrib/cirrus/cron-fail_addrs.csv b/contrib/cirrus/cron-fail_addrs.csv index c25fc1226..276158163 100644 --- a/contrib/cirrus/cron-fail_addrs.csv +++ b/contrib/cirrus/cron-fail_addrs.csv @@ -1 +1 @@ -rh.container.bot@gmail.com +rh.container.bot@gmail.com,podman-monitor@lists.podman.io diff --git a/libpod/boltdb_state.go b/libpod/boltdb_state.go index b2ee63b08..c9d214cd0 100644 --- a/libpod/boltdb_state.go +++ b/libpod/boltdb_state.go @@ -269,9 +269,9 @@ func (s *BoltState) Refresh() error { if err != nil { return err } - for _, execId := range toRemove { - if err := ctrExecBkt.Delete([]byte(execId)); err != nil { - return errors.Wrapf(err, "error removing exec session %s from container %s", execId, string(id)) + for _, execID := range toRemove { + if err := ctrExecBkt.Delete([]byte(execID)); err != nil { + return errors.Wrapf(err, "error removing exec session %s from container %s", execID, string(id)) } } } @@ -904,7 +904,6 @@ func (s *BoltState) ContainerInUse(ctr *Container) ([]string, error) { } return depCtrs, nil - } // AllContainers retrieves all the containers in the database @@ -962,7 +961,6 @@ func (s *BoltState) AllContainers() ([]*Container, error) { } return nil - }) }) if err != nil { @@ -2580,7 +2578,6 @@ func (s *BoltState) LookupVolume(name string) (*Volume, error) { } return volume, nil - } // HasVolume returns true if the given volume exists in the state, otherwise it returns false diff --git a/libpod/container.go b/libpod/container.go index e667cd991..613a02554 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -1057,7 +1057,6 @@ func (c *Container) NetworkDisabled() (bool, error) { return container.NetworkDisabled() } return networkDisabled(c) - } func networkDisabled(c *Container) (bool, error) { diff --git a/libpod/container_exec.go b/libpod/container_exec.go index 5aee847e1..0d18b55ca 100644 --- a/libpod/container_exec.go +++ b/libpod/container_exec.go @@ -78,9 +78,11 @@ type ExecConfig struct { type ExecSession struct { // Id is the ID of the exec session. // Named somewhat strangely to not conflict with ID(). + // nolint:stylecheck,golint Id string `json:"id"` // ContainerId is the ID of the container this exec session belongs to. // Named somewhat strangely to not conflict with ContainerID(). + // nolint:stylecheck,golint ContainerId string `json:"containerId"` // State is the state of the exec session. diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index f50c7dbfe..e87e26c61 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -796,7 +796,6 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named if c.config.UTSNsCtr != "" { utsMode = fmt.Sprintf("container:%s", c.config.UTSNsCtr) } else if ctrSpec.Linux != nil { - // Locate the spec's UTS namespace. // If there is none, it's uts=host. // If there is one and it has a path, it's "ns:". @@ -871,8 +870,8 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named for _, limit := range ctrSpec.Process.Rlimits { newLimit := define.InspectUlimit{} newLimit.Name = limit.Type - newLimit.Soft = limit.Soft - newLimit.Hard = limit.Hard + newLimit.Soft = int64(limit.Soft) + newLimit.Hard = int64(limit.Hard) hostConfig.Ulimits = append(hostConfig.Ulimits, newLimit) } } diff --git a/libpod/container_internal.go b/libpod/container_internal.go index b280e79d1..ced357096 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -13,6 +13,7 @@ import ( "strings" "time" + "github.com/containers/buildah/copier" "github.com/containers/common/pkg/secrets" "github.com/containers/podman/v2/libpod/define" "github.com/containers/podman/v2/libpod/events" @@ -265,7 +266,7 @@ func (c *Container) handleRestartPolicy(ctx context.Context) (_ bool, retErr err c.newContainerEvent(events.Restart) // Increment restart count - c.state.RestartCount += 1 + c.state.RestartCount++ logrus.Debugf("Container %s now on retry %d", c.ID(), c.state.RestartCount) if err := c.save(); err != nil { return false, err @@ -1582,18 +1583,8 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) return nil, err } - // HACK HACK HACK - copy up into a volume driver is 100% broken - // right now. - if vol.UsesVolumeDriver() { - logrus.Infof("Not copying up into volume %s as it uses a volume driver", vol.Name()) - return vol, nil - } - // If the volume is not empty, we should not copy up. - volMount, err := vol.MountPoint() - if err != nil { - return nil, err - } + volMount := vol.mountPoint() contents, err := ioutil.ReadDir(volMount) if err != nil { return nil, errors.Wrapf(err, "error listing contents of volume %s mountpoint when copying up from container %s", vol.Name(), c.ID()) @@ -1609,8 +1600,55 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) if err != nil { return nil, errors.Wrapf(err, "error calculating destination path to copy up container %s volume %s", c.ID(), vol.Name()) } - if err := c.copyWithTarFromImage(srcDir, volMount); err != nil && !os.IsNotExist(err) { - return nil, errors.Wrapf(err, "error copying content from container %s into volume %s", c.ID(), vol.Name()) + // Do a manual stat on the source directory to verify existence. + // Skip the rest if it exists. + // TODO: Should this be stat or lstat? I'm using lstat because I + // think copy-up doesn't happen when the source is a link. + srcStat, err := os.Lstat(srcDir) + if err != nil { + if os.IsNotExist(err) { + // Source does not exist, don't bother copying + // up. + return vol, nil + } + return nil, errors.Wrapf(err, "error identifying source directory for copy up into volume %s", vol.Name()) + } + // If it's not a directory we're mounting over it. + if !srcStat.IsDir() { + return vol, nil + } + + // Buildah Copier accepts a reader, so we'll need a pipe. + reader, writer := io.Pipe() + defer reader.Close() + + errChan := make(chan error, 1) + + logrus.Infof("About to copy up into volume %s", vol.Name()) + + // Copy, container side: get a tar archive of what needs to be + // streamed into the volume. + go func() { + defer writer.Close() + getOptions := copier.GetOptions{ + KeepDirectoryNames: false, + } + errChan <- copier.Get(mountpoint, "", getOptions, []string{v.Dest + "/."}, writer) + }() + + // Copy, volume side: stream what we've written to the pipe, into + // the volume. + copyOpts := copier.PutOptions{} + if err := copier.Put(volMount, "", copyOpts, reader); err != nil { + err2 := <-errChan + if err2 != nil { + logrus.Errorf("Error streaming contents of container %s directory for volume copy-up: %v", c.ID(), err2) + } + return nil, errors.Wrapf(err, "error copying up to volume %s", vol.Name()) + } + + if err := <-errChan; err != nil { + return nil, errors.Wrapf(err, "error streaming container content for copy up into volume %s", vol.Name()) } } return vol, nil @@ -2060,17 +2098,6 @@ func (c *Container) unmount(force bool) error { return nil } -// this should be from chrootarchive. -// Container MUST be mounted before calling. -func (c *Container) copyWithTarFromImage(source, dest string) error { - mappings := idtools.NewIDMappingsFromMaps(c.config.IDMappings.UIDMap, c.config.IDMappings.GIDMap) - a := archive.NewArchiver(mappings) - if err := c.copyOwnerAndPerms(source, dest); err != nil { - return err - } - return a.CopyWithTar(source, dest) -} - // checkReadyForRemoval checks whether the given container is ready to be // removed. // These checks are only used if force-remove is not specified. diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 3583f8fdd..a3476f42e 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -521,14 +521,14 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { }} } for _, gid := range execUser.Sgids { - isGidAvailable := false + isGIDAvailable := false for _, m := range gidMappings { if gid >= m.ContainerID && gid < m.ContainerID+m.Size { - isGidAvailable = true + isGIDAvailable = true break } } - if isGidAvailable { + if isGIDAvailable { g.AddProcessAdditionalGid(uint32(gid)) } else { logrus.Warnf("additional gid=%d is not present in the user namespace, skip setting it", gid) @@ -1614,7 +1614,6 @@ func (c *Container) makeBindMounts() error { return errors.Wrapf(err, "error setting timezone for container %s", c.ID()) } c.state.BindMounts["/etc/localtime"] = localtimePath - } } @@ -2278,23 +2277,6 @@ func (c *Container) generatePasswdAndGroup() (string, string, error) { return passwdPath, groupPath, nil } -func (c *Container) copyOwnerAndPerms(source, dest string) error { - info, err := os.Stat(source) - if err != nil { - if os.IsNotExist(err) { - return nil - } - return err - } - if err := os.Chmod(dest, info.Mode()); err != nil { - return err - } - if err := os.Chown(dest, int(info.Sys().(*syscall.Stat_t).Uid), int(info.Sys().(*syscall.Stat_t).Gid)); err != nil { - return err - } - return nil -} - // Get cgroup path in a format suitable for the OCI spec func (c *Container) getOCICgroupPath() (string, error) { unified, err := cgroups.IsCgroup2UnifiedMode() diff --git a/libpod/container_path_resolution.go b/libpod/container_path_resolution.go index 805b3b947..5245314ae 100644 --- a/libpod/container_path_resolution.go +++ b/libpod/container_path_resolution.go @@ -18,7 +18,7 @@ import ( // mountPoint (e.g., via a mount or volume), the resolved root (e.g., container // mount, bind mount or volume) and the resolved path on the root (absolute to // the host). -func (container *Container) resolvePath(mountPoint string, containerPath string) (string, string, error) { +func (c *Container) resolvePath(mountPoint string, containerPath string) (string, string, error) { // Let's first make sure we have a path relative to the mount point. pathRelativeToContainerMountPoint := containerPath if !filepath.IsAbs(containerPath) { @@ -26,7 +26,7 @@ func (container *Container) resolvePath(mountPoint string, containerPath string) // container's working dir. To be extra careful, let's first // join the working dir with "/", and the add the containerPath // to it. - pathRelativeToContainerMountPoint = filepath.Join(filepath.Join("/", container.WorkingDir()), containerPath) + pathRelativeToContainerMountPoint = filepath.Join(filepath.Join("/", c.WorkingDir()), containerPath) } resolvedPathOnTheContainerMountPoint := filepath.Join(mountPoint, pathRelativeToContainerMountPoint) pathRelativeToContainerMountPoint = strings.TrimPrefix(pathRelativeToContainerMountPoint, mountPoint) @@ -43,7 +43,7 @@ func (container *Container) resolvePath(mountPoint string, containerPath string) searchPath := pathRelativeToContainerMountPoint for { - volume, err := findVolume(container, searchPath) + volume, err := findVolume(c, searchPath) if err != nil { return "", "", err } @@ -74,7 +74,7 @@ func (container *Container) resolvePath(mountPoint string, containerPath string) return mountPoint, absolutePathOnTheVolumeMount, nil } - if mount := findBindMount(container, searchPath); mount != nil { + if mount := findBindMount(c, searchPath); mount != nil { logrus.Debugf("Container path %q resolved to bind mount %q:%q on path %q", containerPath, mount.Source, mount.Destination, searchPath) // We found a matching bind mount for searchPath. We // now need to first find the relative path of our @@ -86,14 +86,12 @@ func (container *Container) resolvePath(mountPoint string, containerPath string) return "", "", err } return mount.Source, absolutePathOnTheBindMount, nil - } if searchPath == "/" { // Cannot go beyond "/", so we're done. break } - // Walk *down* the path (e.g., "/foo/bar/x" -> "/foo/bar"). searchPath = filepath.Dir(searchPath) } diff --git a/libpod/define/container_inspect.go b/libpod/define/container_inspect.go index 2cdd53cbc..0f355d20a 100644 --- a/libpod/define/container_inspect.go +++ b/libpod/define/container_inspect.go @@ -122,9 +122,9 @@ type InspectUlimit struct { // Name is the name (type) of the ulimit. Name string `json:"Name"` // Soft is the soft limit that will be applied. - Soft uint64 `json:"Soft"` + Soft int64 `json:"Soft"` // Hard is the hard limit that will be applied. - Hard uint64 `json:"Hard"` + Hard int64 `json:"Hard"` } // InspectDevice is a single device that will be mounted into the container. diff --git a/libpod/events/events.go b/libpod/events/events.go index aa0401b62..01ea6a386 100644 --- a/libpod/events/events.go +++ b/libpod/events/events.go @@ -97,7 +97,6 @@ func newEventFromJSONString(event string) (*Event, error) { return nil, err } return &e, nil - } // ToString converts a Type to a string diff --git a/libpod/events/filters.go b/libpod/events/filters.go index 62891d32c..26e1e10ba 100644 --- a/libpod/events/filters.go +++ b/libpod/events/filters.go @@ -86,7 +86,6 @@ func generateEventSinceOption(timeSince time.Time) func(e *Event) bool { func generateEventUntilOption(timeUntil time.Time) func(e *Event) bool { return func(e *Event) bool { return e.Time.Before(timeUntil) - } } diff --git a/libpod/events/logfile.go b/libpod/events/logfile.go index 05ae3ce52..c5feabe66 100644 --- a/libpod/events/logfile.go +++ b/libpod/events/logfile.go @@ -39,7 +39,6 @@ func (e EventLogFile) Write(ee Event) error { return err } return nil - } // Reads from the log file diff --git a/libpod/healthcheck.go b/libpod/healthcheck.go index f77075893..6c5becd5b 100644 --- a/libpod/healthcheck.go +++ b/libpod/healthcheck.go @@ -190,7 +190,7 @@ func (c *Container) updateHealthCheckLog(hcl define.HealthCheckLog, inStartPerio } if !inStartPeriod { // increment failing streak - healthCheck.FailingStreak += 1 + healthCheck.FailingStreak++ // if failing streak > retries, then status to unhealthy if healthCheck.FailingStreak >= c.HealthCheckConfig().Retries { healthCheck.Status = define.HealthCheckUnhealthy diff --git a/libpod/image/image.go b/libpod/image/image.go index d732aecfe..8d8af0064 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -1688,7 +1688,6 @@ func (i *Image) GetConfigBlob(ctx context.Context) (*manifest.Schema2Image, erro return nil, errors.Wrapf(err, "unable to parse image blob for %s", i.ID()) } return &blob, nil - } // GetHealthCheck returns a HealthConfig for an image. This function only works with diff --git a/libpod/image/image_test.go b/libpod/image/image_test.go index 2704b8baf..8055ef7b1 100644 --- a/libpod/image/image_test.go +++ b/libpod/image/image_test.go @@ -66,7 +66,6 @@ func makeLocalMatrix(b, bg *Image) []localImageTest { l = append(l, busybox, busyboxGlibc) return l - } func TestMain(m *testing.M) { diff --git a/libpod/image/prune.go b/libpod/image/prune.go index 587c99333..6f026f630 100644 --- a/libpod/image/prune.go +++ b/libpod/image/prune.go @@ -52,7 +52,6 @@ func generatePruneFilterFuncs(filter, filterValue string) (ImageFilter, error) { } return false }, nil - } return nil, nil } @@ -170,7 +169,6 @@ func (ir *Runtime) PruneImages(ctx context.Context, all bool, filter []string) ( Size: uint64(imgSize), }) } - } return preports, nil } diff --git a/libpod/image/utils.go b/libpod/image/utils.go index 5e7fed5c6..8882adcc1 100644 --- a/libpod/image/utils.go +++ b/libpod/image/utils.go @@ -45,7 +45,6 @@ func findImageInRepotags(search imageParts, images []*Image) (*storage.Image, er } } if len(candidates) == 0 { - return nil, errors.Wrapf(define.ErrNoSuchImage, "unable to find a name and tag match for %s in repotags", searchName) } @@ -75,9 +74,8 @@ func findImageInRepotags(search imageParts, images []*Image) (*storage.Image, er } if rwImageCnt > 1 { return nil, errors.Wrapf(define.ErrMultipleImages, "found multiple read/write images %s", strings.Join(keys, ",")) - } else { - return nil, errors.Wrapf(define.ErrMultipleImages, "found multiple read/only images %s", strings.Join(keys, ",")) } + return nil, errors.Wrapf(define.ErrMultipleImages, "found multiple read/only images %s", strings.Join(keys, ",")) } return candidates[0].image.image, nil } diff --git a/libpod/info.go b/libpod/info.go index 1b3550abd..f5bfb122e 100644 --- a/libpod/info.go +++ b/libpod/info.go @@ -222,11 +222,11 @@ func (r *Runtime) getContainerStoreInfo() (define.ContainerStore, error) { } switch state { case define.ContainerStateRunning: - running += 1 + running++ case define.ContainerStatePaused: - paused += 1 + paused++ default: - stopped += 1 + stopped++ } } cs.Paused = paused diff --git a/libpod/network/create.go b/libpod/network/create.go index deacf487a..c58d62575 100644 --- a/libpod/network/create.go +++ b/libpod/network/create.go @@ -75,7 +75,6 @@ func validateBridgeOptions(options entities.NetworkCreateOptions) error { } return nil - } // parseMTU parses the mtu option diff --git a/libpod/network/create_test.go b/libpod/network/create_test.go index 0b828e635..017bf31fe 100644 --- a/libpod/network/create_test.go +++ b/libpod/network/create_test.go @@ -8,7 +8,6 @@ import ( ) func Test_validateBridgeOptions(t *testing.T) { - tests := []struct { name string subnet net.IPNet diff --git a/libpod/network/netconflist_test.go b/libpod/network/netconflist_test.go index 5ff733f0f..161764ed9 100644 --- a/libpod/network/netconflist_test.go +++ b/libpod/network/netconflist_test.go @@ -7,7 +7,6 @@ import ( ) func TestNewIPAMDefaultRoute(t *testing.T) { - tests := []struct { name string isIPv6 bool diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index 55d338e7d..de6f75d3e 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -480,9 +480,8 @@ func (r *Runtime) setupSlirp4netns(ctr *Container) error { if havePortMapping { if isSlirpHostForward { return r.setupRootlessPortMappingViaSlirp(ctr, cmd, apiSocket) - } else { - return r.setupRootlessPortMappingViaRLK(ctr, netnsPath) } + return r.setupRootlessPortMappingViaRLK(ctr, netnsPath) } return nil } diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go index 23bfb29d7..38ffba7d2 100644 --- a/libpod/oci_conmon_linux.go +++ b/libpod/oci_conmon_linux.go @@ -1228,7 +1228,6 @@ func prepareProcessExec(c *Container, options *ExecOptions, env []string, sessio if options.Cwd != "" { pspec.Cwd = options.Cwd - } var addGroups []string @@ -1798,5 +1797,4 @@ func httpAttachNonTerminalCopy(container *net.UnixConn, http *bufio.ReadWriter, return err } } - } diff --git a/libpod/oci_util.go b/libpod/oci_util.go index d40cf13bd..4ec050d6d 100644 --- a/libpod/oci_util.go +++ b/libpod/oci_util.go @@ -103,7 +103,6 @@ func bindPorts(ports []ocicni.PortMapping) ([]*os.File, error) { } default: return nil, fmt.Errorf("unknown protocol %s", i.Protocol) - } } return files, nil diff --git a/libpod/options.go b/libpod/options.go index 74ee60fef..8831f527e 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -1109,7 +1109,6 @@ func WithLogTag(tag string) CtrCreateOption { return nil } - } // WithCgroupsMode disables the creation of CGroups for the conmon process. @@ -1131,7 +1130,6 @@ func WithCgroupsMode(mode string) CtrCreateOption { return nil } - } // WithCgroupParent sets the Cgroup Parent of the new container. @@ -1430,7 +1428,6 @@ func WithOverlayVolumes(volumes []*ContainerOverlayVolume) CtrCreateOption { } for _, vol := range volumes { - ctr.config.OverlayVolumes = append(ctr.config.OverlayVolumes, &ContainerOverlayVolume{ Dest: vol.Dest, Source: vol.Source, diff --git a/libpod/plugin/volume_api.go b/libpod/plugin/volume_api.go index c5dec651c..79aebed43 100644 --- a/libpod/plugin/volume_api.go +++ b/libpod/plugin/volume_api.go @@ -241,9 +241,8 @@ func (p *VolumePlugin) makeErrorResponse(err, endpoint, volName string) error { } if volName != "" { return errors.Wrapf(errors.New(err), "error on %s on volume %s in volume plugin %s", endpoint, volName, p.Name) - } else { - return errors.Wrapf(errors.New(err), "error on %s in volume plugin %s", endpoint, p.Name) } + return errors.Wrapf(errors.New(err), "error on %s in volume plugin %s", endpoint, p.Name) } // Handle error responses from plugin diff --git a/libpod/reset.go b/libpod/reset.go index 24efeed40..3346f9d3f 100644 --- a/libpod/reset.go +++ b/libpod/reset.go @@ -16,7 +16,6 @@ import ( // Reset removes all storage func (r *Runtime) Reset(ctx context.Context) error { - pods, err := r.GetAllPods() if err != nil { return err diff --git a/libpod/runtime.go b/libpod/runtime.go index 1ad39fe2f..42af2046d 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -146,7 +146,6 @@ func NewRuntime(ctx context.Context, options ...RuntimeOption) (*Runtime, error) // An error will be returned if the configuration file at the given path does // not exist or cannot be loaded func NewRuntimeFromConfig(ctx context.Context, userConfig *config.Config, options ...RuntimeOption) (*Runtime, error) { - return newRuntimeFromConfig(ctx, userConfig, options...) } @@ -382,7 +381,6 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) { // Initialize remaining OCI runtimes for name, paths := range runtime.config.Engine.OCIRuntimes { - ociRuntime, err := newConmonOCIRuntime(name, paths, runtime.conmonPath, runtime.runtimeFlags, runtime.config) if err != nil { // Don't fatally error. @@ -437,7 +435,6 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) { // Set up the CNI net plugin if !rootless.IsRootless() { - netPlugin, err := ocicni.InitCNI(runtime.config.Network.DefaultNetwork, runtime.config.Network.NetworkConfigDir, runtime.config.Network.CNIPluginDirs...) if err != nil { return errors.Wrapf(err, "error configuring CNI network plugin") @@ -484,7 +481,6 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) { if became { os.Exit(ret) } - } // If the file doesn't exist, we need to refresh the state // This will trigger on first use as well, but refreshing an @@ -787,7 +783,6 @@ type DBConfig struct { // mergeDBConfig merges the configuration from the database. func (r *Runtime) mergeDBConfig(dbConfig *DBConfig) { - c := &r.config.Engine if !r.storageSet.RunRootSet && dbConfig.StorageTmp != "" { if r.storageConfig.RunRoot != dbConfig.StorageTmp && diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index 49cf42626..1b3532f1f 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -1139,7 +1139,6 @@ func (r *Runtime) IsStorageContainerMounted(id string) (bool, string, error) { // StorageContainers returns a list of containers from containers/storage that // are not currently known to Podman. func (r *Runtime) StorageContainers() ([]storage.Container, error) { - if r.store == nil { return nil, define.ErrStoreNotInitialized } diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index 2c5442bd2..f56fa8cce 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -313,9 +313,8 @@ func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io if err == nil && src != nil { if newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer); err == nil { return getImageNames(newImages), nil - } else { - saveErr = err } + saveErr = err } } return "", errors.Wrapf(saveErr, "error pulling image") diff --git a/libpod/runtime_img_test.go b/libpod/runtime_img_test.go index 6ca4d900b..40d5860cf 100644 --- a/libpod/runtime_img_test.go +++ b/libpod/runtime_img_test.go @@ -26,7 +26,6 @@ func createTmpFile(content []byte) (string, error) { if _, err := tmpfile.Write(content); err != nil { return "", err - } if err := tmpfile.Close(); err != nil { return "", err diff --git a/libpod/runtime_pod_infra_linux.go b/libpod/runtime_pod_infra_linux.go index 564851f4e..bc37bdb23 100644 --- a/libpod/runtime_pod_infra_linux.go +++ b/libpod/runtime_pod_infra_linux.go @@ -24,7 +24,6 @@ const ( ) func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, rawImageName, imgID string, config *v1.ImageConfig) (*Container, error) { - // Set up generator for infra container defaults g, err := generate.New("linux") if err != nil { diff --git a/libpod/volume.go b/libpod/volume.go index 4c137cb8e..5cc5e7e40 100644 --- a/libpod/volume.go +++ b/libpod/volume.go @@ -130,11 +130,18 @@ func (v *Volume) MountPoint() (string, error) { if err := v.update(); err != nil { return "", err } + } + + return v.mountPoint(), nil +} - return v.state.MountPoint, nil +// Internal-only helper for volume mountpoint +func (v *Volume) mountPoint() string { + if v.UsesVolumeDriver() { + return v.state.MountPoint } - return v.config.MountPoint, nil + return v.config.MountPoint } // Options return the volume's options diff --git a/libpod/volume_internal_linux.go b/libpod/volume_internal_linux.go index e184505e7..82c01be44 100644 --- a/libpod/volume_internal_linux.go +++ b/libpod/volume_internal_linux.go @@ -45,7 +45,7 @@ func (v *Volume) mount() error { // If the count is non-zero, the volume is already mounted. // Nothing to do. if v.state.MountCount > 0 { - v.state.MountCount += 1 + v.state.MountCount++ logrus.Debugf("Volume %s mount count now at %d", v.Name(), v.state.MountCount) return v.save() } @@ -67,7 +67,7 @@ func (v *Volume) mount() error { return err } - v.state.MountCount += 1 + v.state.MountCount++ v.state.MountPoint = mountPoint return v.save() } @@ -109,7 +109,7 @@ func (v *Volume) mount() error { logrus.Debugf("Mounted volume %s", v.Name()) // Increment the mount counter - v.state.MountCount += 1 + v.state.MountCount++ logrus.Debugf("Volume %s mount count now at %d", v.Name(), v.state.MountCount) return v.save() } @@ -152,7 +152,7 @@ func (v *Volume) unmount(force bool) error { } if !force { - v.state.MountCount -= 1 + v.state.MountCount-- } else { v.state.MountCount = 0 } diff --git a/pkg/api/handlers/compat/containers_archive.go b/pkg/api/handlers/compat/containers_archive.go index 083c72ce8..55bd62f90 100644 --- a/pkg/api/handlers/compat/containers_archive.go +++ b/pkg/api/handlers/compat/containers_archive.go @@ -62,7 +62,7 @@ func handleHeadAndGet(w http.ResponseWriter, r *http.Request, decoder *schema.De w.Header().Add(copy.XDockerContainerPathStatHeader, statHeader) } - if errors.Cause(err) == define.ErrNoSuchCtr || errors.Cause(err) == copy.ENOENT { + if errors.Cause(err) == define.ErrNoSuchCtr || errors.Cause(err) == copy.ErrENOENT { // 404 is returned for an absent container and path. The // clients must deal with it accordingly. utils.Error(w, "Not found.", http.StatusNotFound, err) diff --git a/pkg/api/handlers/compat/events.go b/pkg/api/handlers/compat/events.go index 82a74e419..7dad5f566 100644 --- a/pkg/api/handlers/compat/events.go +++ b/pkg/api/handlers/compat/events.go @@ -111,7 +111,6 @@ func GetEvents(w http.ResponseWriter, r *http.Request) { Until: query.Until, } errorChannel <- runtime.Events(r.Context(), readOpts) - }() var flush = func() {} diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 88c59b46a..85708912b 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -202,7 +202,6 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) { ProgressDetail: map[string]string{}, Id: iid, }) - } func CreateImageFromImage(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/api/handlers/compat/images_history.go b/pkg/api/handlers/compat/images_history.go index 3b72798e4..174bc6234 100644 --- a/pkg/api/handlers/compat/images_history.go +++ b/pkg/api/handlers/compat/images_history.go @@ -17,7 +17,6 @@ func HistoryImage(w http.ResponseWriter, r *http.Request) { if err != nil { utils.Error(w, "Something went wrong.", http.StatusNotFound, errors.Wrapf(err, "failed to find image %s", name)) return - } history, err := newImage.History(r.Context()) if err != nil { diff --git a/pkg/api/handlers/compat/images_remove.go b/pkg/api/handlers/compat/images_remove.go index 9731c521c..dd2d96bbb 100644 --- a/pkg/api/handlers/compat/images_remove.go +++ b/pkg/api/handlers/compat/images_remove.go @@ -54,5 +54,4 @@ func RemoveImage(w http.ResponseWriter, r *http.Request) { } utils.WriteResponse(w, http.StatusOK, response) - } diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index 85d2db87e..71b9d180d 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -277,10 +277,10 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) { return } body := struct { - Id string + ID string `json:"Id"` Warning []string }{ - Id: net.ID, + ID: net.ID, } utils.WriteResponse(w, http.StatusCreated, body) } @@ -400,6 +400,9 @@ func Prune(w http.ResponseWriter, r *http.Request) { utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err) return } + type response struct { + NetworksDeleted []string + } var prunedNetworks []string //nolint for _, pr := range pruneReports { if pr.Error != nil { @@ -408,5 +411,5 @@ func Prune(w http.ResponseWriter, r *http.Request) { } prunedNetworks = append(prunedNetworks, pr.Name) } - utils.WriteResponse(w, http.StatusOK, prunedNetworks) + utils.WriteResponse(w, http.StatusOK, response{NetworksDeleted: prunedNetworks}) } diff --git a/pkg/api/handlers/compat/secrets.go b/pkg/api/handlers/compat/secrets.go index ea2dfc707..571888eba 100644 --- a/pkg/api/handlers/compat/secrets.go +++ b/pkg/api/handlers/compat/secrets.go @@ -58,7 +58,6 @@ func InspectSecret(w http.ResponseWriter, r *http.Request) { return } utils.WriteResponse(w, http.StatusOK, reports[0]) - } func RemoveSecret(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/api/handlers/libpod/containers.go b/pkg/api/handlers/libpod/containers.go index 619cbfd8b..4e79e4a42 100644 --- a/pkg/api/handlers/libpod/containers.go +++ b/pkg/api/handlers/libpod/containers.go @@ -48,7 +48,6 @@ func ContainerExists(w http.ResponseWriter, r *http.Request) { } utils.InternalServerError(w, err) return - } if report.Value { utils.WriteResponse(w, http.StatusNoContent, "") @@ -162,7 +161,6 @@ func UnmountContainer(w http.ResponseWriter, r *http.Request) { utils.InternalServerError(w, err) } utils.WriteResponse(w, http.StatusNoContent, "") - } func MountContainer(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value("runtime").(*libpod.Runtime) @@ -361,7 +359,6 @@ func ShouldRestart(w http.ResponseWriter, r *http.Request) { } utils.InternalServerError(w, err) return - } if report.Value { utils.WriteResponse(w, http.StatusNoContent, "") diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go index 3b531652f..0d4160a6e 100644 --- a/pkg/api/handlers/libpod/images.go +++ b/pkg/api/handlers/libpod/images.go @@ -266,7 +266,6 @@ func ExportImages(w http.ResponseWriter, r *http.Request) { if len(query.References) > 1 && query.Format != define.V2s2Archive { utils.Error(w, "unsupported format", http.StatusInternalServerError, errors.Errorf("multi-image archives must use format of %s", define.V2s2Archive)) return - } switch query.Format { @@ -445,7 +444,6 @@ func PushImage(w http.ResponseWriter, r *http.Request) { if authconf != nil { username = authconf.Username password = authconf.Password - } options := entities.ImagePushOptions{ Authfile: authfile, diff --git a/pkg/api/handlers/libpod/networks.go b/pkg/api/handlers/libpod/networks.go index 998f89d96..8330b6a45 100644 --- a/pkg/api/handlers/libpod/networks.go +++ b/pkg/api/handlers/libpod/networks.go @@ -42,7 +42,6 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) { return } utils.WriteResponse(w, http.StatusOK, report) - } func ListNetworks(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value("runtime").(*libpod.Runtime) diff --git a/pkg/api/handlers/utils/containers.go b/pkg/api/handlers/utils/containers.go index 518309a03..ba202cad0 100644 --- a/pkg/api/handlers/utils/containers.go +++ b/pkg/api/handlers/utils/containers.go @@ -130,10 +130,9 @@ func WaitContainerLibpod(w http.ResponseWriter, r *http.Request) { if errors.Cause(err) == define.ErrNoSuchCtr { ContainerNotFound(w, name, err) return - } else { - InternalServerError(w, err) - return } + InternalServerError(w, err) + return } WriteResponse(w, http.StatusOK, strconv.Itoa(int(exitCode))) } @@ -141,7 +140,6 @@ func WaitContainerLibpod(w http.ResponseWriter, r *http.Request) { type containerWaitFn func(conditions ...define.ContainerStatus) (int32, error) func createContainerWaitFn(ctx context.Context, containerName string, interval time.Duration) containerWaitFn { - runtime := ctx.Value("runtime").(*libpod.Runtime) var containerEngine entities.ContainerEngine = &abi.ContainerEngine{Libpod: runtime} @@ -170,7 +168,6 @@ func isValidDockerCondition(cond string) bool { } func waitDockerCondition(ctx context.Context, containerName string, interval time.Duration, dockerCondition string) (int32, error) { - containerWait := createContainerWaitFn(ctx, containerName, interval) var err error @@ -200,9 +197,8 @@ func waitRemoved(ctrWait containerWaitFn) (int32, error) { code, err := ctrWait(define.ContainerStateUnknown) if err != nil && errors.Cause(err) == define.ErrNoSuchCtr { return code, nil - } else { - return code, err } + return code, err } func waitNextExit(ctrWait containerWaitFn) (int32, error) { diff --git a/pkg/api/server/register_ping.go b/pkg/api/server/register_ping.go index 446a12a68..0343d2608 100644 --- a/pkg/api/server/register_ping.go +++ b/pkg/api/server/register_ping.go @@ -8,7 +8,6 @@ import ( ) func (s *APIServer) registerPingHandlers(r *mux.Router) error { - r.Handle("/_ping", s.APIHandler(compat.Ping)).Methods(http.MethodGet, http.MethodHead) r.Handle(VersionedPath("/_ping"), s.APIHandler(compat.Ping)).Methods(http.MethodGet, http.MethodHead) // swagger:operation GET /libpod/_ping libpod libpodPingGet diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index 86d92c028..ecfa6651c 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -41,7 +41,6 @@ func GetCredentials(r *http.Request) (*types.DockerAuthConfig, string, HeaderAut case has(XRegistryAuthHeader): c, f, err := getAuthCredentials(r) return c, f, XRegistryAuthHeader, err - } return nil, "", "", nil } diff --git a/pkg/bindings/containers/archive.go b/pkg/bindings/containers/archive.go index d1bbc0b95..18871cfd1 100644 --- a/pkg/bindings/containers/archive.go +++ b/pkg/bindings/containers/archive.go @@ -30,7 +30,7 @@ func Stat(ctx context.Context, nameOrID string, path string) (*entities.Containe var finalErr error if response.StatusCode == http.StatusNotFound { - finalErr = copy.ENOENT + finalErr = copy.ErrENOENT } else if response.StatusCode != http.StatusOK { finalErr = errors.New(response.Status) } diff --git a/pkg/bindings/containers/containers.go b/pkg/bindings/containers/containers.go index 8e644b712..c84595011 100644 --- a/pkg/bindings/containers/containers.go +++ b/pkg/bindings/containers/containers.go @@ -137,7 +137,6 @@ func Kill(ctx context.Context, nameOrID string, options *KillOptions) error { return err } return response.Process(nil) - } // Pause pauses a given container. The nameOrID can be a container name @@ -270,8 +269,8 @@ func Top(ctx context.Context, nameOrID string, options *TopOptions) ([]string, e } params := url.Values{} if options.Changed("Descriptors") { - ps_args := strings.Join(options.GetDescriptors(), ",") - params.Add("ps_args", ps_args) + psArgs := strings.Join(options.GetDescriptors(), ",") + params.Add("ps_args", psArgs) } response, err := conn.DoRequest(nil, http.MethodGet, "/containers/%s/top", params, nil, nameOrID) if err != nil { diff --git a/pkg/bindings/containers/types_attach_options.go b/pkg/bindings/containers/types_attach_options.go index ab5a1615c..88ade89b4 100644 --- a/pkg/bindings/containers/types_attach_options.go +++ b/pkg/bindings/containers/types_attach_options.go @@ -60,7 +60,6 @@ func (o *AttachOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *AttachOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_checkpoint_options.go b/pkg/bindings/containers/types_checkpoint_options.go index d239c476f..002a08e00 100644 --- a/pkg/bindings/containers/types_checkpoint_options.go +++ b/pkg/bindings/containers/types_checkpoint_options.go @@ -60,7 +60,6 @@ func (o *CheckpointOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *CheckpointOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_commit_options.go b/pkg/bindings/containers/types_commit_options.go index 061f16e25..006fe7ae7 100644 --- a/pkg/bindings/containers/types_commit_options.go +++ b/pkg/bindings/containers/types_commit_options.go @@ -60,7 +60,6 @@ func (o *CommitOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *CommitOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_create_options.go b/pkg/bindings/containers/types_create_options.go index 8cde11335..914a6ed3e 100644 --- a/pkg/bindings/containers/types_create_options.go +++ b/pkg/bindings/containers/types_create_options.go @@ -60,7 +60,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_diff_options.go b/pkg/bindings/containers/types_diff_options.go index e912bf041..ebf3a7ad8 100644 --- a/pkg/bindings/containers/types_diff_options.go +++ b/pkg/bindings/containers/types_diff_options.go @@ -60,7 +60,6 @@ func (o *DiffOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *DiffOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_execinspect_options.go b/pkg/bindings/containers/types_execinspect_options.go index b870db46b..772318cd3 100644 --- a/pkg/bindings/containers/types_execinspect_options.go +++ b/pkg/bindings/containers/types_execinspect_options.go @@ -60,7 +60,6 @@ func (o *ExecInspectOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ExecInspectOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_execstart_options.go b/pkg/bindings/containers/types_execstart_options.go index 95f97b1d7..9a032d200 100644 --- a/pkg/bindings/containers/types_execstart_options.go +++ b/pkg/bindings/containers/types_execstart_options.go @@ -60,7 +60,6 @@ func (o *ExecStartOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ExecStartOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_execstartandattach_options.go b/pkg/bindings/containers/types_execstartandattach_options.go index 1981c319a..6bc288de3 100644 --- a/pkg/bindings/containers/types_execstartandattach_options.go +++ b/pkg/bindings/containers/types_execstartandattach_options.go @@ -62,7 +62,6 @@ func (o *ExecStartAndAttachOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -71,7 +70,6 @@ func (o *ExecStartAndAttachOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_exists_options.go b/pkg/bindings/containers/types_exists_options.go index a52777600..6a9086c78 100644 --- a/pkg/bindings/containers/types_exists_options.go +++ b/pkg/bindings/containers/types_exists_options.go @@ -60,7 +60,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_export_options.go b/pkg/bindings/containers/types_export_options.go index 3943a5a3b..595d2cf87 100644 --- a/pkg/bindings/containers/types_export_options.go +++ b/pkg/bindings/containers/types_export_options.go @@ -60,7 +60,6 @@ func (o *ExportOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ExportOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_healthcheck_options.go b/pkg/bindings/containers/types_healthcheck_options.go index a548232cd..3e2b445af 100644 --- a/pkg/bindings/containers/types_healthcheck_options.go +++ b/pkg/bindings/containers/types_healthcheck_options.go @@ -60,7 +60,6 @@ func (o *HealthCheckOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *HealthCheckOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_init_options.go b/pkg/bindings/containers/types_init_options.go index 92e8a6c17..5a107435e 100644 --- a/pkg/bindings/containers/types_init_options.go +++ b/pkg/bindings/containers/types_init_options.go @@ -60,7 +60,6 @@ func (o *InitOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *InitOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_inspect_options.go b/pkg/bindings/containers/types_inspect_options.go index fdb84bda8..347521488 100644 --- a/pkg/bindings/containers/types_inspect_options.go +++ b/pkg/bindings/containers/types_inspect_options.go @@ -60,7 +60,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_kill_options.go b/pkg/bindings/containers/types_kill_options.go index 45bd790a4..0fdbef2f1 100644 --- a/pkg/bindings/containers/types_kill_options.go +++ b/pkg/bindings/containers/types_kill_options.go @@ -60,7 +60,6 @@ func (o *KillOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *KillOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_list_options.go b/pkg/bindings/containers/types_list_options.go index 3293320ec..51ae98dac 100644 --- a/pkg/bindings/containers/types_list_options.go +++ b/pkg/bindings/containers/types_list_options.go @@ -60,7 +60,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_log_options.go b/pkg/bindings/containers/types_log_options.go index e78eb7bd0..51e01f1b4 100644 --- a/pkg/bindings/containers/types_log_options.go +++ b/pkg/bindings/containers/types_log_options.go @@ -60,7 +60,6 @@ func (o *LogOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *LogOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_mount_options.go b/pkg/bindings/containers/types_mount_options.go index cc8df1255..0fa028e72 100644 --- a/pkg/bindings/containers/types_mount_options.go +++ b/pkg/bindings/containers/types_mount_options.go @@ -60,7 +60,6 @@ func (o *MountOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *MountOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_mountedcontainerpaths_options.go b/pkg/bindings/containers/types_mountedcontainerpaths_options.go index 78fa2fca0..abfe9d95e 100644 --- a/pkg/bindings/containers/types_mountedcontainerpaths_options.go +++ b/pkg/bindings/containers/types_mountedcontainerpaths_options.go @@ -60,7 +60,6 @@ func (o *MountedContainerPathsOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *MountedContainerPathsOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_pause_options.go b/pkg/bindings/containers/types_pause_options.go index 55f14bef0..5f15035d9 100644 --- a/pkg/bindings/containers/types_pause_options.go +++ b/pkg/bindings/containers/types_pause_options.go @@ -60,7 +60,6 @@ func (o *PauseOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *PauseOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_prune_options.go b/pkg/bindings/containers/types_prune_options.go index 000c7c0bd..99a85584e 100644 --- a/pkg/bindings/containers/types_prune_options.go +++ b/pkg/bindings/containers/types_prune_options.go @@ -60,7 +60,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_remove_options.go b/pkg/bindings/containers/types_remove_options.go index dfb5367eb..99947f607 100644 --- a/pkg/bindings/containers/types_remove_options.go +++ b/pkg/bindings/containers/types_remove_options.go @@ -60,7 +60,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_rename_options.go b/pkg/bindings/containers/types_rename_options.go index f4f5d1426..05d7138cd 100644 --- a/pkg/bindings/containers/types_rename_options.go +++ b/pkg/bindings/containers/types_rename_options.go @@ -60,7 +60,6 @@ func (o *RenameOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *RenameOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_resizeexectty_options.go b/pkg/bindings/containers/types_resizeexectty_options.go index e63d965eb..554d6fb85 100644 --- a/pkg/bindings/containers/types_resizeexectty_options.go +++ b/pkg/bindings/containers/types_resizeexectty_options.go @@ -60,7 +60,6 @@ func (o *ResizeExecTTYOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ResizeExecTTYOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_resizetty_options.go b/pkg/bindings/containers/types_resizetty_options.go index 3170f4053..a018993eb 100644 --- a/pkg/bindings/containers/types_resizetty_options.go +++ b/pkg/bindings/containers/types_resizetty_options.go @@ -60,7 +60,6 @@ func (o *ResizeTTYOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ResizeTTYOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_restart_options.go b/pkg/bindings/containers/types_restart_options.go index d59176e67..fa1019a1f 100644 --- a/pkg/bindings/containers/types_restart_options.go +++ b/pkg/bindings/containers/types_restart_options.go @@ -60,7 +60,6 @@ func (o *RestartOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *RestartOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_restore_options.go b/pkg/bindings/containers/types_restore_options.go index e9f14fc47..793222af3 100644 --- a/pkg/bindings/containers/types_restore_options.go +++ b/pkg/bindings/containers/types_restore_options.go @@ -60,7 +60,6 @@ func (o *RestoreOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *RestoreOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_shouldrestart_options.go b/pkg/bindings/containers/types_shouldrestart_options.go index 49f943460..e9585dc61 100644 --- a/pkg/bindings/containers/types_shouldrestart_options.go +++ b/pkg/bindings/containers/types_shouldrestart_options.go @@ -60,7 +60,6 @@ func (o *ShouldRestartOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ShouldRestartOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_start_options.go b/pkg/bindings/containers/types_start_options.go index a0f0b3077..0ca2ee832 100644 --- a/pkg/bindings/containers/types_start_options.go +++ b/pkg/bindings/containers/types_start_options.go @@ -60,7 +60,6 @@ func (o *StartOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *StartOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_stats_options.go b/pkg/bindings/containers/types_stats_options.go index 79e35ba62..1ecd99536 100644 --- a/pkg/bindings/containers/types_stats_options.go +++ b/pkg/bindings/containers/types_stats_options.go @@ -60,7 +60,6 @@ func (o *StatsOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *StatsOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_stop_options.go b/pkg/bindings/containers/types_stop_options.go index f221b16e8..fcc5b1be8 100644 --- a/pkg/bindings/containers/types_stop_options.go +++ b/pkg/bindings/containers/types_stop_options.go @@ -60,7 +60,6 @@ func (o *StopOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *StopOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_top_options.go b/pkg/bindings/containers/types_top_options.go index 570dd4e90..2f04a2069 100644 --- a/pkg/bindings/containers/types_top_options.go +++ b/pkg/bindings/containers/types_top_options.go @@ -60,7 +60,6 @@ func (o *TopOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *TopOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_unmount_options.go b/pkg/bindings/containers/types_unmount_options.go index 24249073e..ede1dbdc7 100644 --- a/pkg/bindings/containers/types_unmount_options.go +++ b/pkg/bindings/containers/types_unmount_options.go @@ -60,7 +60,6 @@ func (o *UnmountOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *UnmountOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_unpause_options.go b/pkg/bindings/containers/types_unpause_options.go index 3b1d75001..0004219bf 100644 --- a/pkg/bindings/containers/types_unpause_options.go +++ b/pkg/bindings/containers/types_unpause_options.go @@ -60,7 +60,6 @@ func (o *UnpauseOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *UnpauseOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/containers/types_wait_options.go b/pkg/bindings/containers/types_wait_options.go index a3f1e3b8c..7ff6fc6f0 100644 --- a/pkg/bindings/containers/types_wait_options.go +++ b/pkg/bindings/containers/types_wait_options.go @@ -61,7 +61,6 @@ func (o *WaitOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -70,7 +69,6 @@ func (o *WaitOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/errors.go b/pkg/bindings/errors.go index e75ce898d..51ea487be 100644 --- a/pkg/bindings/errors.go +++ b/pkg/bindings/errors.go @@ -20,12 +20,12 @@ func handleError(data []byte) error { return e } -func (a APIResponse) Process(unmarshalInto interface{}) error { - data, err := ioutil.ReadAll(a.Response.Body) +func (h APIResponse) Process(unmarshalInto interface{}) error { + data, err := ioutil.ReadAll(h.Response.Body) if err != nil { return errors.Wrap(err, "unable to process API response") } - if a.IsSuccess() || a.IsRedirection() { + if h.IsSuccess() || h.IsRedirection() { if unmarshalInto != nil { return json.Unmarshal(data, unmarshalInto) } diff --git a/pkg/bindings/generate/types_kube_options.go b/pkg/bindings/generate/types_kube_options.go index 218d308e1..7d7b5d335 100644 --- a/pkg/bindings/generate/types_kube_options.go +++ b/pkg/bindings/generate/types_kube_options.go @@ -60,7 +60,6 @@ func (o *KubeOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *KubeOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/generate/types_systemd_options.go b/pkg/bindings/generate/types_systemd_options.go index faf981d1b..132904cf1 100644 --- a/pkg/bindings/generate/types_systemd_options.go +++ b/pkg/bindings/generate/types_systemd_options.go @@ -60,7 +60,6 @@ func (o *SystemdOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *SystemdOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/generator/generator.go b/pkg/bindings/generator/generator.go index dad154166..f65d136ea 100644 --- a/pkg/bindings/generator/generator.go +++ b/pkg/bindings/generator/generator.go @@ -71,7 +71,6 @@ func (o *{{.StructName}}) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -80,7 +79,6 @@ func (o *{{.StructName}}) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } @@ -239,7 +237,6 @@ func main() { os.Exit(1) } } - } return true }) diff --git a/pkg/bindings/images/pull.go b/pkg/bindings/images/pull.go index 5669c704e..9149b7445 100644 --- a/pkg/bindings/images/pull.go +++ b/pkg/bindings/images/pull.go @@ -93,7 +93,6 @@ func Pull(ctx context.Context, rawImage string, options *PullOptions) ([]string, default: return images, errors.New("failed to parse pull results stream, unexpected input") } - } return images, mErr } diff --git a/pkg/bindings/images/types_diff_options.go b/pkg/bindings/images/types_diff_options.go index edfc7bfa2..4f2bf0f6b 100644 --- a/pkg/bindings/images/types_diff_options.go +++ b/pkg/bindings/images/types_diff_options.go @@ -60,7 +60,6 @@ func (o *DiffOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *DiffOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_exists_options.go b/pkg/bindings/images/types_exists_options.go index 649be4862..689c80902 100644 --- a/pkg/bindings/images/types_exists_options.go +++ b/pkg/bindings/images/types_exists_options.go @@ -60,7 +60,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_export_options.go b/pkg/bindings/images/types_export_options.go index ebd053165..31361deb2 100644 --- a/pkg/bindings/images/types_export_options.go +++ b/pkg/bindings/images/types_export_options.go @@ -60,7 +60,6 @@ func (o *ExportOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ExportOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_get_options.go b/pkg/bindings/images/types_get_options.go index 33ebe2611..5eb178a74 100644 --- a/pkg/bindings/images/types_get_options.go +++ b/pkg/bindings/images/types_get_options.go @@ -60,7 +60,6 @@ func (o *GetOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *GetOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_history_options.go b/pkg/bindings/images/types_history_options.go index b2c37acea..becabaa59 100644 --- a/pkg/bindings/images/types_history_options.go +++ b/pkg/bindings/images/types_history_options.go @@ -60,7 +60,6 @@ func (o *HistoryOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *HistoryOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_import_options.go b/pkg/bindings/images/types_import_options.go index e2aed0866..6e9160b63 100644 --- a/pkg/bindings/images/types_import_options.go +++ b/pkg/bindings/images/types_import_options.go @@ -60,7 +60,6 @@ func (o *ImportOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ImportOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_list_options.go b/pkg/bindings/images/types_list_options.go index e194474b9..12d186f6b 100644 --- a/pkg/bindings/images/types_list_options.go +++ b/pkg/bindings/images/types_list_options.go @@ -60,7 +60,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_load_options.go b/pkg/bindings/images/types_load_options.go index 7e15d4e03..913568937 100644 --- a/pkg/bindings/images/types_load_options.go +++ b/pkg/bindings/images/types_load_options.go @@ -60,7 +60,6 @@ func (o *LoadOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *LoadOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_prune_options.go b/pkg/bindings/images/types_prune_options.go index f86676d53..dad83dd2f 100644 --- a/pkg/bindings/images/types_prune_options.go +++ b/pkg/bindings/images/types_prune_options.go @@ -60,7 +60,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_pull_options.go b/pkg/bindings/images/types_pull_options.go index 59e2b6354..c3c7a3dc4 100644 --- a/pkg/bindings/images/types_pull_options.go +++ b/pkg/bindings/images/types_pull_options.go @@ -60,7 +60,6 @@ func (o *PullOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *PullOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_push_options.go b/pkg/bindings/images/types_push_options.go index 85f1ffee5..26a8d7e91 100644 --- a/pkg/bindings/images/types_push_options.go +++ b/pkg/bindings/images/types_push_options.go @@ -60,7 +60,6 @@ func (o *PushOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *PushOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_remove_options.go b/pkg/bindings/images/types_remove_options.go index d79186565..fba4f63b6 100644 --- a/pkg/bindings/images/types_remove_options.go +++ b/pkg/bindings/images/types_remove_options.go @@ -60,7 +60,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_search_options.go b/pkg/bindings/images/types_search_options.go index a55c9ac89..812a9abd3 100644 --- a/pkg/bindings/images/types_search_options.go +++ b/pkg/bindings/images/types_search_options.go @@ -60,7 +60,6 @@ func (o *SearchOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *SearchOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_tag_options.go b/pkg/bindings/images/types_tag_options.go index b323ea41c..e1217a9aa 100644 --- a/pkg/bindings/images/types_tag_options.go +++ b/pkg/bindings/images/types_tag_options.go @@ -60,7 +60,6 @@ func (o *TagOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *TagOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_tree_options.go b/pkg/bindings/images/types_tree_options.go index 8e1b16c5c..0a574ffc1 100644 --- a/pkg/bindings/images/types_tree_options.go +++ b/pkg/bindings/images/types_tree_options.go @@ -60,7 +60,6 @@ func (o *TreeOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *TreeOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/images/types_untag_options.go b/pkg/bindings/images/types_untag_options.go index b28670134..ced84876e 100644 --- a/pkg/bindings/images/types_untag_options.go +++ b/pkg/bindings/images/types_untag_options.go @@ -60,7 +60,6 @@ func (o *UntagOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *UntagOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/manifests/types_add_options.go b/pkg/bindings/manifests/types_add_options.go index 61314c479..8947b1286 100644 --- a/pkg/bindings/manifests/types_add_options.go +++ b/pkg/bindings/manifests/types_add_options.go @@ -60,7 +60,6 @@ func (o *AddOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *AddOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/manifests/types_create_options.go b/pkg/bindings/manifests/types_create_options.go index 4c7c1397a..ee8b56df7 100644 --- a/pkg/bindings/manifests/types_create_options.go +++ b/pkg/bindings/manifests/types_create_options.go @@ -60,7 +60,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/manifests/types_exists_options.go b/pkg/bindings/manifests/types_exists_options.go index 2a4962ae6..16527660c 100644 --- a/pkg/bindings/manifests/types_exists_options.go +++ b/pkg/bindings/manifests/types_exists_options.go @@ -60,7 +60,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/manifests/types_inspect_options.go b/pkg/bindings/manifests/types_inspect_options.go index 0b82fc3cf..a2a40e6a4 100644 --- a/pkg/bindings/manifests/types_inspect_options.go +++ b/pkg/bindings/manifests/types_inspect_options.go @@ -60,7 +60,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/manifests/types_remove_options.go b/pkg/bindings/manifests/types_remove_options.go index 6ed0fd329..d3cac775e 100644 --- a/pkg/bindings/manifests/types_remove_options.go +++ b/pkg/bindings/manifests/types_remove_options.go @@ -60,7 +60,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/network/network.go b/pkg/bindings/network/network.go index 428e60cf2..8fdb28425 100644 --- a/pkg/bindings/network/network.go +++ b/pkg/bindings/network/network.go @@ -102,7 +102,7 @@ func List(ctx context.Context, options *ListOptions) ([]*entities.NetworkListRep } // Disconnect removes a container from a given network -func Disconnect(ctx context.Context, networkName string, ContainerNameOrId string, options *DisconnectOptions) error { +func Disconnect(ctx context.Context, networkName string, ContainerNameOrID string, options *DisconnectOptions) error { if options == nil { options = new(DisconnectOptions) } @@ -117,7 +117,7 @@ func Disconnect(ctx context.Context, networkName string, ContainerNameOrId strin Container string Force bool }{ - Container: ContainerNameOrId, + Container: ContainerNameOrID, } if force := options.GetForce(); options.Changed("Force") { disconnect.Force = force @@ -136,7 +136,7 @@ func Disconnect(ctx context.Context, networkName string, ContainerNameOrId strin } // Connect adds a container to a network -func Connect(ctx context.Context, networkName string, ContainerNameOrId string, options *ConnectOptions) error { +func Connect(ctx context.Context, networkName string, ContainerNameOrID string, options *ConnectOptions) error { if options == nil { options = new(ConnectOptions) } @@ -151,7 +151,7 @@ func Connect(ctx context.Context, networkName string, ContainerNameOrId string, Container string Aliases []string }{ - Container: ContainerNameOrId, + Container: ContainerNameOrID, } if aliases := options.GetAliases(); options.Changed("Aliases") { connect.Aliases = aliases diff --git a/pkg/bindings/network/types_connect_options.go b/pkg/bindings/network/types_connect_options.go index 4440bbed4..930fb5531 100644 --- a/pkg/bindings/network/types_connect_options.go +++ b/pkg/bindings/network/types_connect_options.go @@ -60,7 +60,6 @@ func (o *ConnectOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ConnectOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/network/types_create_options.go b/pkg/bindings/network/types_create_options.go index 5fbdce93a..4b4afc4a8 100644 --- a/pkg/bindings/network/types_create_options.go +++ b/pkg/bindings/network/types_create_options.go @@ -61,7 +61,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -70,7 +69,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/network/types_disconnect_options.go b/pkg/bindings/network/types_disconnect_options.go index 947f2f114..cbcea8f7e 100644 --- a/pkg/bindings/network/types_disconnect_options.go +++ b/pkg/bindings/network/types_disconnect_options.go @@ -60,7 +60,6 @@ func (o *DisconnectOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *DisconnectOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/network/types_exists_options.go b/pkg/bindings/network/types_exists_options.go index 2fad34789..0de2a00b5 100644 --- a/pkg/bindings/network/types_exists_options.go +++ b/pkg/bindings/network/types_exists_options.go @@ -60,7 +60,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/network/types_inspect_options.go b/pkg/bindings/network/types_inspect_options.go index 144ccbfae..3c69b37ec 100644 --- a/pkg/bindings/network/types_inspect_options.go +++ b/pkg/bindings/network/types_inspect_options.go @@ -60,7 +60,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/network/types_list_options.go b/pkg/bindings/network/types_list_options.go index 60632ce33..e00430809 100644 --- a/pkg/bindings/network/types_list_options.go +++ b/pkg/bindings/network/types_list_options.go @@ -60,7 +60,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/network/types_prune_options.go b/pkg/bindings/network/types_prune_options.go index c56dcd0d3..f9685a225 100644 --- a/pkg/bindings/network/types_prune_options.go +++ b/pkg/bindings/network/types_prune_options.go @@ -60,7 +60,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/network/types_remove_options.go b/pkg/bindings/network/types_remove_options.go index 4ad4a2301..f42f6c256 100644 --- a/pkg/bindings/network/types_remove_options.go +++ b/pkg/bindings/network/types_remove_options.go @@ -60,7 +60,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/play/types_kube_options.go b/pkg/bindings/play/types_kube_options.go index ea3872aae..649522908 100644 --- a/pkg/bindings/play/types_kube_options.go +++ b/pkg/bindings/play/types_kube_options.go @@ -60,7 +60,6 @@ func (o *KubeOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *KubeOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_create_options.go b/pkg/bindings/pods/types_create_options.go index cfa29c6be..90312e6e6 100644 --- a/pkg/bindings/pods/types_create_options.go +++ b/pkg/bindings/pods/types_create_options.go @@ -60,7 +60,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_exists_options.go b/pkg/bindings/pods/types_exists_options.go index 6149ab1cc..0a7fbe3c9 100644 --- a/pkg/bindings/pods/types_exists_options.go +++ b/pkg/bindings/pods/types_exists_options.go @@ -60,7 +60,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_inspect_options.go b/pkg/bindings/pods/types_inspect_options.go index 281717ff1..9913eaa50 100644 --- a/pkg/bindings/pods/types_inspect_options.go +++ b/pkg/bindings/pods/types_inspect_options.go @@ -60,7 +60,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_kill_options.go b/pkg/bindings/pods/types_kill_options.go index 4c310d50c..dac91840c 100644 --- a/pkg/bindings/pods/types_kill_options.go +++ b/pkg/bindings/pods/types_kill_options.go @@ -60,7 +60,6 @@ func (o *KillOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *KillOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_list_options.go b/pkg/bindings/pods/types_list_options.go index 20f3229e5..ab945c253 100644 --- a/pkg/bindings/pods/types_list_options.go +++ b/pkg/bindings/pods/types_list_options.go @@ -60,7 +60,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_pause_options.go b/pkg/bindings/pods/types_pause_options.go index 0f0f5bd97..177679e2a 100644 --- a/pkg/bindings/pods/types_pause_options.go +++ b/pkg/bindings/pods/types_pause_options.go @@ -60,7 +60,6 @@ func (o *PauseOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *PauseOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_prune_options.go b/pkg/bindings/pods/types_prune_options.go index ef8aae17f..389a95579 100644 --- a/pkg/bindings/pods/types_prune_options.go +++ b/pkg/bindings/pods/types_prune_options.go @@ -60,7 +60,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_remove_options.go b/pkg/bindings/pods/types_remove_options.go index f51f67129..dcb4106f8 100644 --- a/pkg/bindings/pods/types_remove_options.go +++ b/pkg/bindings/pods/types_remove_options.go @@ -60,7 +60,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_restart_options.go b/pkg/bindings/pods/types_restart_options.go index ec05e9fc9..61b06f70e 100644 --- a/pkg/bindings/pods/types_restart_options.go +++ b/pkg/bindings/pods/types_restart_options.go @@ -60,7 +60,6 @@ func (o *RestartOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *RestartOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_start_options.go b/pkg/bindings/pods/types_start_options.go index ec9f5b1de..80e3c04d5 100644 --- a/pkg/bindings/pods/types_start_options.go +++ b/pkg/bindings/pods/types_start_options.go @@ -60,7 +60,6 @@ func (o *StartOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *StartOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_stats_options.go b/pkg/bindings/pods/types_stats_options.go index 8be7d175d..c8be15ee9 100644 --- a/pkg/bindings/pods/types_stats_options.go +++ b/pkg/bindings/pods/types_stats_options.go @@ -60,7 +60,6 @@ func (o *StatsOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *StatsOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_stop_options.go b/pkg/bindings/pods/types_stop_options.go index fa3577e72..22b04012e 100644 --- a/pkg/bindings/pods/types_stop_options.go +++ b/pkg/bindings/pods/types_stop_options.go @@ -60,7 +60,6 @@ func (o *StopOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *StopOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_top_options.go b/pkg/bindings/pods/types_top_options.go index c3c701dad..da2457809 100644 --- a/pkg/bindings/pods/types_top_options.go +++ b/pkg/bindings/pods/types_top_options.go @@ -60,7 +60,6 @@ func (o *TopOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *TopOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/pods/types_unpause_options.go b/pkg/bindings/pods/types_unpause_options.go index 281f0ea8d..5e2c9454b 100644 --- a/pkg/bindings/pods/types_unpause_options.go +++ b/pkg/bindings/pods/types_unpause_options.go @@ -60,7 +60,6 @@ func (o *UnpauseOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *UnpauseOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/secrets/types_create_options.go b/pkg/bindings/secrets/types_create_options.go index 84cf38fa3..7629b3e5d 100644 --- a/pkg/bindings/secrets/types_create_options.go +++ b/pkg/bindings/secrets/types_create_options.go @@ -60,7 +60,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/secrets/types_inspect_options.go b/pkg/bindings/secrets/types_inspect_options.go index cd36b0531..8213c73bf 100644 --- a/pkg/bindings/secrets/types_inspect_options.go +++ b/pkg/bindings/secrets/types_inspect_options.go @@ -60,7 +60,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/secrets/types_list_options.go b/pkg/bindings/secrets/types_list_options.go index d313d8f73..eab0f5466 100644 --- a/pkg/bindings/secrets/types_list_options.go +++ b/pkg/bindings/secrets/types_list_options.go @@ -60,7 +60,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/secrets/types_remove_options.go b/pkg/bindings/secrets/types_remove_options.go index ca970e30e..151c1d90c 100644 --- a/pkg/bindings/secrets/types_remove_options.go +++ b/pkg/bindings/secrets/types_remove_options.go @@ -60,7 +60,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/system/types_disk_options.go b/pkg/bindings/system/types_disk_options.go index 6f0c3735a..77428c10c 100644 --- a/pkg/bindings/system/types_disk_options.go +++ b/pkg/bindings/system/types_disk_options.go @@ -60,7 +60,6 @@ func (o *DiskOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *DiskOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/system/types_events_options.go b/pkg/bindings/system/types_events_options.go index 401a9807e..dd7706178 100644 --- a/pkg/bindings/system/types_events_options.go +++ b/pkg/bindings/system/types_events_options.go @@ -60,7 +60,6 @@ func (o *EventsOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *EventsOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/system/types_info_options.go b/pkg/bindings/system/types_info_options.go index 7c07b5081..162ec3e88 100644 --- a/pkg/bindings/system/types_info_options.go +++ b/pkg/bindings/system/types_info_options.go @@ -60,7 +60,6 @@ func (o *InfoOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *InfoOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/system/types_prune_options.go b/pkg/bindings/system/types_prune_options.go index c677ccca6..f2ae5e657 100644 --- a/pkg/bindings/system/types_prune_options.go +++ b/pkg/bindings/system/types_prune_options.go @@ -60,7 +60,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/system/types_version_options.go b/pkg/bindings/system/types_version_options.go index 60ebfced9..b6026fa8c 100644 --- a/pkg/bindings/system/types_version_options.go +++ b/pkg/bindings/system/types_version_options.go @@ -60,7 +60,6 @@ func (o *VersionOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *VersionOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/volumes/types_create_options.go b/pkg/bindings/volumes/types_create_options.go index 2254f8c13..2dcbaf611 100644 --- a/pkg/bindings/volumes/types_create_options.go +++ b/pkg/bindings/volumes/types_create_options.go @@ -60,7 +60,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *CreateOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/volumes/types_exists_options.go b/pkg/bindings/volumes/types_exists_options.go index 9840b1bcd..ebfabc061 100644 --- a/pkg/bindings/volumes/types_exists_options.go +++ b/pkg/bindings/volumes/types_exists_options.go @@ -60,7 +60,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ExistsOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/volumes/types_inspect_options.go b/pkg/bindings/volumes/types_inspect_options.go index 51ac2d348..3176e0ef6 100644 --- a/pkg/bindings/volumes/types_inspect_options.go +++ b/pkg/bindings/volumes/types_inspect_options.go @@ -60,7 +60,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *InspectOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/volumes/types_list_options.go b/pkg/bindings/volumes/types_list_options.go index c96e647b0..e7770d5ee 100644 --- a/pkg/bindings/volumes/types_list_options.go +++ b/pkg/bindings/volumes/types_list_options.go @@ -60,7 +60,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *ListOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/volumes/types_prune_options.go b/pkg/bindings/volumes/types_prune_options.go index 06d16b659..78245f649 100644 --- a/pkg/bindings/volumes/types_prune_options.go +++ b/pkg/bindings/volumes/types_prune_options.go @@ -60,7 +60,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *PruneOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/bindings/volumes/types_remove_options.go b/pkg/bindings/volumes/types_remove_options.go index 4b0037234..13ac6a346 100644 --- a/pkg/bindings/volumes/types_remove_options.go +++ b/pkg/bindings/volumes/types_remove_options.go @@ -60,7 +60,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { iter := f.MapRange() for iter.Next() { lowerCaseKeys[iter.Key().Interface().(string)] = iter.Value().Interface().([]string) - } s, err := json.MarshalToString(lowerCaseKeys) if err != nil { @@ -69,7 +68,6 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { params.Set(fieldName, s) } - } return params, nil } diff --git a/pkg/cgroups/cpu.go b/pkg/cgroups/cpu.go index a73187dc8..05223c2e1 100644 --- a/pkg/cgroups/cpu.go +++ b/pkg/cgroups/cpu.go @@ -155,7 +155,6 @@ func GetSystemCPUUsage() (uint64, error) { } total += v * 1000 } - } return total, nil } diff --git a/pkg/copy/fileinfo.go b/pkg/copy/fileinfo.go index ddb9b629c..b95bcd90c 100644 --- a/pkg/copy/fileinfo.go +++ b/pkg/copy/fileinfo.go @@ -16,9 +16,9 @@ import ( // base64 encoded JSON payload of stating a path in a container. const XDockerContainerPathStatHeader = "X-Docker-Container-Path-Stat" -// ENOENT mimics the stdlib's ENOENT and can be used to implement custom logic +// ErrENOENT mimics the stdlib's ErrENOENT and can be used to implement custom logic // while preserving the user-visible error message. -var ENOENT = errors.New("No such file or directory") +var ErrENOENT = errors.New("No such file or directory") // FileInfo describes a file or directory and is returned by // (*CopyItem).Stat(). @@ -70,7 +70,7 @@ func ResolveHostPath(path string) (*FileInfo, error) { statInfo, err := os.Stat(resolvedHostPath) if err != nil { if os.IsNotExist(err) { - return nil, ENOENT + return nil, ErrENOENT } return nil, err } diff --git a/pkg/domain/entities/engine_container.go b/pkg/domain/entities/engine_container.go index d43b422a3..82e2f8eaf 100644 --- a/pkg/domain/entities/engine_container.go +++ b/pkg/domain/entities/engine_container.go @@ -91,7 +91,7 @@ type ContainerEngine interface { Unshare(ctx context.Context, args []string) error Version(ctx context.Context) (*SystemVersionReport, error) VolumeCreate(ctx context.Context, opts VolumeCreateOptions) (*IDOrNameResponse, error) - VolumeExists(ctx context.Context, namesOrId string) (*BoolReport, error) + VolumeExists(ctx context.Context, namesOrID string) (*BoolReport, error) VolumeInspect(ctx context.Context, namesOrIds []string, opts InspectOptions) ([]*VolumeInspectReport, []error, error) VolumeList(ctx context.Context, opts VolumeListOptions) ([]*VolumeListReport, error) VolumePrune(ctx context.Context, options VolumePruneOptions) ([]*reports.PruneReport, error) diff --git a/pkg/domain/entities/network.go b/pkg/domain/entities/network.go index 1859f920e..f66a7f575 100644 --- a/pkg/domain/entities/network.go +++ b/pkg/domain/entities/network.go @@ -31,6 +31,7 @@ type NetworkReloadOptions struct { // NetworkReloadReport describes the results of reloading a container network. type NetworkReloadReport struct { + // nolint:stylecheck,golint Id string Err error } diff --git a/pkg/domain/infra/abi/containers_stat.go b/pkg/domain/infra/abi/containers_stat.go index f3d0799a0..1844f4019 100644 --- a/pkg/domain/infra/abi/containers_stat.go +++ b/pkg/domain/infra/abi/containers_stat.go @@ -35,7 +35,7 @@ func (ic *ContainerEngine) containerStat(container *libpod.Container, containerM // ENOENT let's the API handlers return the correct status code // which is crucial for the remote client. if os.IsNotExist(err) || strings.Contains(statInfoErr.Error(), "o such file or directory") { - statInfoErr = copy.ENOENT + statInfoErr = copy.ErrENOENT } // If statInfo is nil, there's nothing we can do anymore. A // non-nil statInfo may indicate a symlink where we must have @@ -129,7 +129,7 @@ func secureStat(root string, path string) (*buildahCopiah.StatForItem, error) { stat, exists := globStats[0].Results[glob] // only one glob passed, so that's okay if !exists { - return nil, copy.ENOENT + return nil, copy.ErrENOENT } var statErr error diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go index f2d0f2c39..fb01c72b6 100644 --- a/pkg/domain/infra/abi/images.go +++ b/pkg/domain/infra/abi/images.go @@ -40,10 +40,9 @@ func (ir *ImageEngine) Exists(_ context.Context, nameOrID string) (*entities.Boo if err != nil { if errors.Cause(err) == define.ErrMultipleImages { return &entities.BoolReport{Value: true}, nil - } else { - if errors.Cause(err) != define.ErrNoSuchImage { - return nil, err - } + } + if errors.Cause(err) != define.ErrNoSuchImage { + return nil, err } } return &entities.BoolReport{Value: err == nil}, nil @@ -270,7 +269,6 @@ func pull(ctx context.Context, runtime *image.Runtime, rawImage string, options } if _, isTagged := namedRef.(reference.Tagged); isTagged { return nil, errors.New("--all-tags requires a reference without a tag") - } systemContext := image.GetSystemContext("", options.Authfile, false) @@ -503,7 +501,6 @@ func (ir *ImageEngine) Config(_ context.Context) (*config.Config, error) { } func (ir *ImageEngine) Build(ctx context.Context, containerFiles []string, opts entities.BuildOptions) (*entities.BuildReport, error) { - id, _, err := ir.Libpod.Build(ctx, opts.BuildOptions, containerFiles...) if err != nil { return nil, err diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index 70c7104f1..35a84106f 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -60,7 +60,6 @@ func (ic *ContainerEngine) PlayKube(ctx context.Context, path string, options en default: return nil, errors.Errorf("invalid YAML kind: %q. [Pod|Deployment] are the only supported Kubernetes Kinds", kubeObject.Kind) } - } func (ic *ContainerEngine) playKubeDeployment(ctx context.Context, deploymentYAML *v1apps.Deployment, options entities.PlayKubeOptions) (*entities.PlayKubeReport, error) { diff --git a/pkg/domain/infra/abi/secrets.go b/pkg/domain/infra/abi/secrets.go index b1fe60e01..355971a5b 100644 --- a/pkg/domain/infra/abi/secrets.go +++ b/pkg/domain/infra/abi/secrets.go @@ -65,7 +65,6 @@ func (ic *ContainerEngine) SecretInspect(ctx context.Context, nameOrIDs []string }, } reports = append(reports, report) - } return reports, errs, nil diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go index e9c513f8e..c2c282ef9 100644 --- a/pkg/domain/infra/tunnel/containers.go +++ b/pkg/domain/infra/tunnel/containers.go @@ -290,7 +290,6 @@ func (ic *ContainerEngine) ContainerCheckpoint(ctx context.Context, namesOrIds [ ctrs = append(ctrs, c) } } - } else { ctrs, err = getContainersByContext(ic.ClientCtx, false, false, namesOrIds) if err != nil { @@ -326,7 +325,6 @@ func (ic *ContainerEngine) ContainerRestore(ctx context.Context, namesOrIds []st ctrs = append(ctrs, c) } } - } else { ctrs, err = getContainersByContext(ic.ClientCtx, false, false, namesOrIds) if err != nil { @@ -570,7 +568,6 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri } // Start the container if it's not running already. if !ctrRunning { - err = containers.Start(ic.ClientCtx, name, new(containers.StartOptions).WithDetachKeys(options.DetachKeys)) if err != nil { if ctr.AutoRemove { diff --git a/pkg/domain/infra/tunnel/helpers.go b/pkg/domain/infra/tunnel/helpers.go index 0a806d860..e40e27596 100644 --- a/pkg/domain/infra/tunnel/helpers.go +++ b/pkg/domain/infra/tunnel/helpers.go @@ -55,7 +55,6 @@ func getContainersByContext(contextWithConnection context.Context, all, ignore b found = true break } - } if !found && !ignore { @@ -107,7 +106,6 @@ func getPodsByContext(contextWithConnection context.Context, all bool, namesOrID found = true break } - } if !found { diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go index daad911cd..c6faaa9bb 100644 --- a/pkg/domain/infra/tunnel/images.go +++ b/pkg/domain/infra/tunnel/images.go @@ -32,7 +32,6 @@ func (ir *ImageEngine) Remove(ctx context.Context, imagesArg []string, opts enti } func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) ([]*entities.ImageSummary, error) { - filters := make(map[string][]string, len(opts.Filter)) for _, filter := range opts.Filter { f := strings.Split(filter, "=") diff --git a/pkg/domain/infra/tunnel/secrets.go b/pkg/domain/infra/tunnel/secrets.go index f7c0f7d13..336297528 100644 --- a/pkg/domain/infra/tunnel/secrets.go +++ b/pkg/domain/infra/tunnel/secrets.go @@ -76,7 +76,6 @@ func (ic *ContainerEngine) SecretRm(ctx context.Context, nameOrIDs []string, opt Err: secrets.Remove(ic.ClientCtx, name), ID: secret.ID, }) - } return allRm, nil } diff --git a/pkg/lookup/lookup.go b/pkg/lookup/lookup.go index 8f241edf2..0b22a1974 100644 --- a/pkg/lookup/lookup.go +++ b/pkg/lookup/lookup.go @@ -66,7 +66,6 @@ func GetUserGroupInfo(containerMount, containerUser string, override *Overrides) // Gid: 0, // Home: "/", defaultExecUser = nil - } return user.GetExecUserPath(containerUser, defaultExecUser, passwdDest, groupDest) diff --git a/pkg/netns/netns_linux.go b/pkg/netns/netns_linux.go index 6817a3abd..95b50e073 100644 --- a/pkg/netns/netns_linux.go +++ b/pkg/netns/netns_linux.go @@ -51,7 +51,6 @@ func getNSRunDir() (string, error) { // NewNS creates a new persistent (bind-mounted) network namespace and returns // an object representing that namespace, without switching to it. func NewNS() (ns.NetNS, error) { - nsRunDir, err := getNSRunDir() if err != nil { return nil, err @@ -92,7 +91,6 @@ func NewNS() (ns.NetNS, error) { if err != nil { return nil, fmt.Errorf("mount --make-rshared %s failed: %q", nsRunDir, err) } - } nsName := fmt.Sprintf("cni-%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]) diff --git a/pkg/rootless/rootless.go b/pkg/rootless/rootless.go index df35c0d6b..b5538efc3 100644 --- a/pkg/rootless/rootless.go +++ b/pkg/rootless/rootless.go @@ -61,9 +61,9 @@ var ( gidMapOnce sync.Once ) -// GetAvailableUidMap returns the UID mappings in the +// GetAvailableUIDMap returns the UID mappings in the // current user namespace. -func GetAvailableUidMap() ([]user.IDMap, error) { +func GetAvailableUIDMap() ([]user.IDMap, error) { uidMapOnce.Do(func() { var err error uidMap, err = user.ParseIDMapFile("/proc/self/uid_map") @@ -75,9 +75,9 @@ func GetAvailableUidMap() ([]user.IDMap, error) { return uidMap, uidMapError } -// GetAvailableGidMap returns the GID mappings in the +// GetAvailableGIDMap returns the GID mappings in the // current user namespace. -func GetAvailableGidMap() ([]user.IDMap, error) { +func GetAvailableGIDMap() ([]user.IDMap, error) { gidMapOnce.Do(func() { var err error gidMap, err = user.ParseIDMapFile("/proc/self/gid_map") @@ -92,11 +92,11 @@ func GetAvailableGidMap() ([]user.IDMap, error) { // GetAvailableIDMaps returns the UID and GID mappings in the // current user namespace. func GetAvailableIDMaps() ([]user.IDMap, []user.IDMap, error) { - u, err := GetAvailableUidMap() + u, err := GetAvailableUIDMap() if err != nil { return nil, nil, err } - g, err := GetAvailableGidMap() + g, err := GetAvailableGIDMap() if err != nil { return nil, nil, err } @@ -114,7 +114,7 @@ func countAvailableIDs(mappings []user.IDMap) int64 { // GetAvailableUids returns how many UIDs are available in the // current user namespace. func GetAvailableUids() (int64, error) { - uids, err := GetAvailableUidMap() + uids, err := GetAvailableUIDMap() if err != nil { return -1, err } @@ -125,7 +125,7 @@ func GetAvailableUids() (int64, error) { // GetAvailableGids returns how many GIDs are available in the // current user namespace. func GetAvailableGids() (int64, error) { - gids, err := GetAvailableGidMap() + gids, err := GetAvailableGIDMap() if err != nil { return -1, err } diff --git a/pkg/rootlessport/rootlessport_linux.go b/pkg/rootlessport/rootlessport_linux.go index 80e1309a5..7cb54a7c3 100644 --- a/pkg/rootlessport/rootlessport_linux.go +++ b/pkg/rootlessport/rootlessport_linux.go @@ -64,7 +64,6 @@ func init() { os.Exit(1) } }) - } func loadConfig(r io.Reader) (*Config, io.ReadCloser, io.WriteCloser, error) { diff --git a/pkg/systemd/generate/common_test.go b/pkg/systemd/generate/common_test.go index a0691d1ad..3787e461e 100644 --- a/pkg/systemd/generate/common_test.go +++ b/pkg/systemd/generate/common_test.go @@ -8,7 +8,6 @@ import ( ) func TestFilterPodFlags(t *testing.T) { - tests := []struct { input []string }{ diff --git a/pkg/trust/trust.go b/pkg/trust/trust.go index a30611b74..18a6a1717 100644 --- a/pkg/trust/trust.go +++ b/pkg/trust/trust.go @@ -179,7 +179,6 @@ func CreateTmpFile(dir, pattern string, content []byte) (string, error) { if _, err := tmpfile.Write(content); err != nil { return "", err - } return tmpfile.Name(), nil } diff --git a/pkg/util/utils.go b/pkg/util/utils.go index e0f631eb4..32bb66332 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -388,7 +388,6 @@ func GetKeepIDMapping() (*storage.IDMappingOptions, int, int, error) { options.HostUIDMapping = false options.HostGIDMapping = false - } // Simply ignore the setting and do not setup an inner namespace for root as it is a no-op return &options, uid, gid, nil @@ -530,9 +529,9 @@ func ParseInputTime(inputTime string) (time.Time, error) { } } - unix_timestamp, err := strconv.ParseInt(inputTime, 10, 64) + unixTimestamp, err := strconv.ParseInt(inputTime, 10, 64) if err == nil { - return time.Unix(unix_timestamp, 0), nil + return time.Unix(unixTimestamp, 0), nil } // input might be a duration diff --git a/test/apiv2/rest_api/test_rest_v2_0_0.py b/test/apiv2/rest_api/test_rest_v2_0_0.py index 73db35cc1..05c24f2ea 100644 --- a/test/apiv2/rest_api/test_rest_v2_0_0.py +++ b/test/apiv2/rest_api/test_rest_v2_0_0.py @@ -483,8 +483,16 @@ class TestApi(unittest.TestCase): inspect = requests.get(PODMAN_URL + f"/v1.40/networks/{ident}") self.assertEqual(inspect.status_code, 404, inspect.content) + # network prune + prune_name = "Network_" + "".join(random.choice(string.ascii_letters) for i in range(10)) + prune_create = requests.post(PODMAN_URL + "/v1.40/networks/create", json={"Name": prune_name}) + self.assertEqual(create.status_code, 201, prune_create.content) + prune = requests.post(PODMAN_URL + "/v1.40/networks/prune") self.assertEqual(prune.status_code, 200, prune.content) + obj = json.loads(prune.content) + self.assertTrue(prune_name in obj["NetworksDeleted"]) + def test_volumes_compat(self): name = "Volume_" + "".join(random.choice(string.ascii_letters) for i in range(10)) diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 53810d882..d033cc646 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -619,6 +619,13 @@ func SkipIfNotRootless(reason string) { } } +func SkipIfNotSystemd(manager, reason string) { + checkReason(reason) + if manager != "systemd" { + ginkgo.Skip("[notSystemd]: " + reason) + } +} + func SkipIfNotFedora() { info := GetHostDistributionInfo() if info.Distribution != "fedora" { diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go index 8fc9721f9..12bc886a8 100644 --- a/test/e2e/inspect_test.go +++ b/test/e2e/inspect_test.go @@ -466,4 +466,28 @@ var _ = Describe("Podman inspect", func() { Expect(len(inspect)).To(Equal(1)) Expect(len(inspect[0].NetworkSettings.Networks)).To(Equal(1)) }) + + It("Container inspect with unlimited uilimits should be -1", func() { + ctrName := "testctr" + session := podmanTest.Podman([]string{"run", "-d", "--ulimit", "core=-1:-1", "--name", ctrName, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(BeZero()) + + inspect := podmanTest.Podman([]string{"inspect", ctrName}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(BeZero()) + + data := inspect.InspectContainerToJSON() + ulimits := data[0].HostConfig.Ulimits + Expect(len(ulimits)).To(BeNumerically(">", 0)) + found := false + for _, ulimit := range ulimits { + if ulimit.Name == "RLIMIT_CORE" { + found = true + Expect(ulimit.Soft).To(BeNumerically("==", -1)) + Expect(ulimit.Hard).To(BeNumerically("==", -1)) + } + } + Expect(found).To(BeTrue()) + }) }) diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index db3f7a36b..225bd538e 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -5,6 +5,7 @@ import ( "os" "regexp" "sort" + "strconv" "strings" . "github.com/containers/podman/v2/test/utils" @@ -210,6 +211,22 @@ var _ = Describe("Podman ps", func() { Expect(result.IsJSONOutputValid()).To(BeTrue()) }) + It("podman ps json format Created field is int64", func() { + session := podmanTest.RunTopContainer("test1") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + result := podmanTest.Podman([]string{"ps", "--format", "json"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + + // Make sure Created field is an int64 + created, err := result.jq(".[0].Created") + Expect(err).To(BeNil()) + _, err = strconv.ParseInt(created, 10, 64) + Expect(err).To(BeNil()) + }) + It("podman ps print a human-readable `Status` with json format", func() { _, ec, _ := podmanTest.RunLsContainer("test1") Expect(ec).To(Equal(0)) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 934b78202..18db63c15 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -1191,6 +1191,37 @@ USER mail` Expect(found).To(BeTrue()) }) + It("podman run with cgroups=split", func() { + SkipIfNotSystemd(podmanTest.CgroupManager, "do not test --cgroups=split if not running on systemd") + SkipIfRootlessCgroupsV1("Disable cgroups not supported on cgroupv1 for rootless users") + SkipIfRemote("--cgroups=split cannot be used in remote mode") + + container := podmanTest.Podman([]string{"run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"}) + container.WaitWithDefaultTimeout() + Expect(container.ExitCode()).To(Equal(0)) + lines := container.OutputToStringArray() + + cgroup := "" + for _, line := range lines { + parts := strings.SplitN(line, ":", 3) + if !CGROUPSV2 { + // ignore unified on cgroup v1 + // both runc and crun do not set it. + if parts[1] == "" { + continue + } + } + if parts[2] == "/" { + continue + } + if cgroup == "" { + cgroup = parts[2] + continue + } + Expect(cgroup).To(Equal(parts[2])) + } + }) + It("podman run with cgroups=disabled runs without cgroups", func() { SkipIfRootless("FIXME: I believe this should work but need to fix this test") SkipIfRootlessCgroupsV1("Disable cgroups not supported on cgroupv1 for rootless users") diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index bc89b59de..19d82c974 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -304,6 +304,24 @@ var _ = Describe("Podman run with volumes", func() { Expect(separateVolumeSession.OutputToString()).To(Equal(baselineOutput)) }) + It("podman named volume copyup symlink", func() { + imgName := "testimg" + dockerfile := `FROM alpine +RUN touch /testfile +RUN sh -c "cd /etc/apk && ln -s ../../testfile"` + podmanTest.BuildImage(dockerfile, imgName, "false") + + baselineSession := podmanTest.Podman([]string{"run", "--rm", "-t", "-i", imgName, "ls", "/etc/apk/"}) + baselineSession.WaitWithDefaultTimeout() + Expect(baselineSession.ExitCode()).To(Equal(0)) + baselineOutput := baselineSession.OutputToString() + + outputSession := podmanTest.Podman([]string{"run", "-t", "-i", "-v", "/etc/apk/", imgName, "ls", "/etc/apk/"}) + outputSession.WaitWithDefaultTimeout() + Expect(outputSession.ExitCode()).To(Equal(0)) + Expect(outputSession.OutputToString()).To(Equal(baselineOutput)) + }) + It("podman read-only tmpfs conflict with volume", func() { session := podmanTest.Podman([]string{"run", "--rm", "-t", "-i", "--read-only", "-v", "tmp_volume:" + dest, ALPINE, "touch", dest + "/a"}) session.WaitWithDefaultTimeout() diff --git a/utils/utils_supported.go b/utils/utils_supported.go index 6f517dc72..73313cf5e 100644 --- a/utils/utils_supported.go +++ b/utils/utils_supported.go @@ -81,16 +81,9 @@ func getCgroupProcess(procFile string) (string, error) { cgroup = line[3:] break } - // root cgroup, skip it - if parts[2] == "/" { - continue - } - // The process must have the same cgroup path for all controllers - // The OCI runtime spec file allow us to specify only one path. - if cgroup != "/" && cgroup != parts[2] { - return "", errors.Errorf("cgroup configuration not supported, the process is in two different cgroups") + if len(parts[2]) > len(cgroup) { + cgroup = parts[2] } - cgroup = parts[2] } if cgroup == "/" { return "", errors.Errorf("could not find cgroup mount in %q", procFile) @@ -150,6 +143,11 @@ func moveUnderCgroup(cgroup, subtree string, processes []uint32) error { // If it is not using unified mode, the cgroup v2 hierarchy is // usually mounted under /sys/fs/cgroup/unified cgroupRoot = filepath.Join(cgroupRoot, "unified") + + // Ignore the unified mount if it doesn't exist + if _, err := os.Stat(cgroupRoot); err != nil && os.IsNotExist(err) { + continue + } } else if parts[1] != "" { // Assume the controller is mounted at /sys/fs/cgroup/$CONTROLLER. controller := strings.TrimPrefix(parts[1], "name=") @@ -161,7 +159,7 @@ func moveUnderCgroup(cgroup, subtree string, processes []uint32) error { parentCgroup = parts[2] } newCgroup := filepath.Join(cgroupRoot, parentCgroup, subtree) - if err := os.Mkdir(newCgroup, 0755); err != nil && !os.IsExist(err) { + if err := os.MkdirAll(newCgroup, 0755); err != nil && !os.IsExist(err) { return err } @@ -183,6 +181,9 @@ func moveUnderCgroup(cgroup, subtree string, processes []uint32) error { return err } for _, pid := range bytes.Split(processesData, []byte("\n")) { + if len(pid) == 0 { + continue + } if _, err := f.Write(pid); err != nil { logrus.Warnf("Cannot move process %s to cgroup %q", string(pid), newCgroup) } |