Merge pull request #9331 from Luap99/lint

Enable more golangci-lint linters
This commit is contained in:
OpenShift Merge Robot 2021-02-12 11:30:00 -05:00 committed by GitHub
commit 291f59600b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
189 changed files with 71 additions and 368 deletions

View File

@ -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

View File

@ -804,5 +804,4 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) {
"Configure cgroup v2 (key=value)",
)
_ = cmd.RegisterFlagCompletionFunc(cgroupConfFlagName, completion.AutocompleteNone)
}

View File

@ -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 {

View File

@ -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
}

View File

@ -68,7 +68,6 @@ func init() {
})
attachFlags(containerAttachCommand)
validate.AddLatestFlag(containerAttachCommand, &attachOpts.Latest)
}
func attach(cmd *cobra.Command, args []string) error {

View File

@ -251,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()

View File

@ -118,5 +118,4 @@ func restore(_ *cobra.Command, args []string) error {
}
}
return errs.PrintErrors()
}

View File

@ -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() {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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")
}

View File

@ -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:

View File

@ -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 {

View File

@ -80,7 +80,6 @@ func init() {
Parent: networkCmd,
})
networkCreateFlags(networkCreateCommand)
}
func networkCreate(cmd *cobra.Command, args []string) error {

View File

@ -39,5 +39,4 @@ func init() {
func networkInspect(_ *cobra.Command, args []string) error {
inspectOpts.Type = inspect.NetworkType
return inspect.Inspect(args, *inspectOpts)
}

View File

@ -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() {

View File

@ -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)

View File

@ -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")
}

View File

@ -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 {

View File

@ -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)
}

View File

@ -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

View File

@ -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 {

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -1057,7 +1057,6 @@ func (c *Container) NetworkDisabled() (bool, error) {
return container.NetworkDisabled()
}
return networkDisabled(c)
}
func networkDisabled(c *Container) (bool, error) {

View File

@ -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.

View File

@ -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:".

View File

@ -266,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

View File

@ -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
}
}

View File

@ -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)
}

View File

@ -97,7 +97,6 @@ func newEventFromJSONString(event string) (*Event, error) {
return nil, err
}
return &e, nil
}
// ToString converts a Type to a string

View File

@ -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)
}
}

View File

@ -39,7 +39,6 @@ func (e EventLogFile) Write(ee Event) error {
return err
}
return nil
}
// Reads from the log file

View File

@ -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

View File

@ -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

View File

@ -66,7 +66,6 @@ func makeLocalMatrix(b, bg *Image) []localImageTest {
l = append(l, busybox, busyboxGlibc)
return l
}
func TestMain(m *testing.M) {

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -75,7 +75,6 @@ func validateBridgeOptions(options entities.NetworkCreateOptions) error {
}
return nil
}
// parseMTU parses the mtu option

View File

@ -8,7 +8,6 @@ import (
)
func Test_validateBridgeOptions(t *testing.T) {
tests := []struct {
name string
subnet net.IPNet

View File

@ -7,7 +7,6 @@ import (
)
func TestNewIPAMDefaultRoute(t *testing.T) {
tests := []struct {
name string
isIPv6 bool

View File

@ -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
}

View File

@ -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
}
}
}

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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 &&

View File

@ -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
}

View File

@ -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")

View File

@ -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

View File

@ -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 {

View File

@ -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
}

View File

@ -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)

View File

@ -111,7 +111,6 @@ func GetEvents(w http.ResponseWriter, r *http.Request) {
Until: query.Until,
}
errorChannel <- runtime.Events(r.Context(), readOpts)
}()
var flush = func() {}

View File

@ -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) {

View File

@ -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 {

View File

@ -54,5 +54,4 @@ func RemoveImage(w http.ResponseWriter, r *http.Request) {
}
utils.WriteResponse(w, http.StatusOK, response)
}

View File

@ -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)
}

View File

@ -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) {

View File

@ -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, "")

View File

@ -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,

View File

@ -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)

View File

@ -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) {

View File

@ -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

View File

@ -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
}

View File

@ -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)
}

View File

@ -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 {

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

Some files were not shown because too many files have changed in this diff Show More