summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-07-11 05:44:12 -0500
committerbaude <bbaude@redhat.com>2019-07-21 14:22:39 -0500
commitdb826d5d75630cca784bd7092eba5b06601ae27f (patch)
treec60cc844e499d5d57752fdb92d4036ea0487ae3c /cmd
parenta5aa44c583612e210cf2ba44c3313a2ff27c94da (diff)
downloadpodman-db826d5d75630cca784bd7092eba5b06601ae27f.tar.gz
podman-db826d5d75630cca784bd7092eba5b06601ae27f.tar.bz2
podman-db826d5d75630cca784bd7092eba5b06601ae27f.zip
golangci-lint round #3
this is the third round of preparing to use the golangci-lint on our code base. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/build.go2
-rw-r--r--cmd/podman/cp.go7
-rw-r--r--cmd/podman/diff.go2
-rw-r--r--cmd/podman/history.go13
-rw-r--r--cmd/podman/images.go7
-rw-r--r--cmd/podman/info.go2
-rw-r--r--cmd/podman/inspect.go2
-rw-r--r--cmd/podman/pod_pause.go2
-rw-r--r--cmd/podman/pod_ps.go2
-rw-r--r--cmd/podman/pod_restart.go2
-rw-r--r--cmd/podman/pod_stats.go18
-rw-r--r--cmd/podman/pod_unpause.go2
-rw-r--r--cmd/podman/remoteclientconfig/configfile.go2
-rw-r--r--cmd/podman/search.go2
-rw-r--r--cmd/podman/shared/create.go6
-rw-r--r--cmd/podman/stats.go2
-rw-r--r--cmd/podman/system_df.go8
-rw-r--r--cmd/podman/trust_set_show.go18
-rw-r--r--cmd/podman/version.go2
-rw-r--r--cmd/podman/volume_ls.go2
20 files changed, 42 insertions, 61 deletions
diff --git a/cmd/podman/build.go b/cmd/podman/build.go
index bd7269390..5ee35dea0 100644
--- a/cmd/podman/build.go
+++ b/cmd/podman/build.go
@@ -313,7 +313,7 @@ func buildCmd(c *cliconfig.BuildValues) error {
// the urfavecli Tail method for args
func Tail(a []string) []string {
if len(a) >= 2 {
- return []string(a)[1:]
+ return a[1:]
}
return []string{}
}
diff --git a/cmd/podman/cp.go b/cmd/podman/cp.go
index 7c28edd26..bee7d2199 100644
--- a/cmd/podman/cp.go
+++ b/cmd/podman/cp.go
@@ -122,7 +122,7 @@ func copyBetweenHostAndContainer(runtime *libpod.Runtime, src string, dest strin
if errors.Cause(err) != define.ErrCtrStateInvalid {
return err
}
- } else if err == nil {
+ } else {
// Only add the defer if we actually paused
defer func() {
if err := ctr.Unpause(); err != nil {
@@ -486,10 +486,7 @@ func matchVolumePath(path, target string) bool {
for len(pathStr) > len(target) && strings.Contains(pathStr, string(os.PathSeparator)) {
pathStr = pathStr[:strings.LastIndex(pathStr, string(os.PathSeparator))]
}
- if pathStr == target {
- return true
- }
- return false
+ return pathStr == target
}
func pathWithBindMountSource(m specs.Mount, path string) (string, error) {
diff --git a/cmd/podman/diff.go b/cmd/podman/diff.go
index 2b0c1d398..f052b510d 100644
--- a/cmd/podman/diff.go
+++ b/cmd/podman/diff.go
@@ -136,5 +136,5 @@ func diffCmd(c *cliconfig.DiffValues) error {
} else {
out = stdoutStruct{output: diffOutput}
}
- return formats.Writer(out).Out()
+ return out.Out()
}
diff --git a/cmd/podman/history.go b/cmd/podman/history.go
index fea2219bc..a16aac8d8 100644
--- a/cmd/podman/history.go
+++ b/cmd/podman/history.go
@@ -141,11 +141,12 @@ func (h *historyTemplateParams) headerMap() map[string]string {
}
// getHistorytemplateOutput gets the modified history information to be printed in human readable format
-func getHistoryTemplateOutput(history []*image.History, opts historyOptions) (historyOutput []historyTemplateParams) {
+func getHistoryTemplateOutput(history []*image.History, opts historyOptions) []historyTemplateParams {
var (
- outputSize string
- createdTime string
- createdBy string
+ outputSize string
+ createdTime string
+ createdBy string
+ historyOutput []historyTemplateParams
)
for _, hist := range history {
imageID := hist.ID
@@ -175,7 +176,7 @@ func getHistoryTemplateOutput(history []*image.History, opts historyOptions) (hi
}
historyOutput = append(historyOutput, params)
}
- return
+ return historyOutput
}
// generateHistoryOutput generates the history based on the format given
@@ -194,5 +195,5 @@ func generateHistoryOutput(history []*image.History, opts historyOptions) error
out = formats.StdoutTemplateArray{Output: historyToGeneric(historyOutput, []*image.History{}), Template: opts.format, Fields: historyOutput[0].headerMap()}
}
- return formats.Writer(out).Out()
+ return out.Out()
}
diff --git a/cmd/podman/images.go b/cmd/podman/images.go
index 281d93e71..3b32ee3dd 100644
--- a/cmd/podman/images.go
+++ b/cmd/podman/images.go
@@ -248,7 +248,8 @@ func sortImagesOutput(sortBy string, imagesOutput imagesSorted) imagesSorted {
}
// getImagesTemplateOutput returns the images information to be printed in human readable format
-func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerImage, opts imagesOptions) (imagesOutput imagesSorted) {
+func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerImage, opts imagesOptions) imagesSorted {
+ var imagesOutput imagesSorted
for _, img := range images {
// If all is false and the image doesn't have a name, check to see if the top layer of the image is a parent
// to another image's top layer. If it is, then it is an intermediate image so don't print out if the --all flag
@@ -305,7 +306,7 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
// Sort images by created time
sortImagesOutput(opts.sort, imagesOutput)
- return
+ return imagesOutput
}
// getImagesJSONOutput returns the images information in its raw form
@@ -346,7 +347,7 @@ func generateImagesOutput(ctx context.Context, images []*adapter.ContainerImage,
imagesOutput := getImagesTemplateOutput(ctx, images, opts)
out = formats.StdoutTemplateArray{Output: imagesToGeneric(imagesOutput, []imagesJSONParams{}), Template: opts.outputformat, Fields: templateMap}
}
- return formats.Writer(out).Out()
+ return out.Out()
}
// GenImageOutputMap generates the map used for outputting the images header
diff --git a/cmd/podman/info.go b/cmd/podman/info.go
index ed60970b6..bf6dd4a8f 100644
--- a/cmd/podman/info.go
+++ b/cmd/podman/info.go
@@ -97,7 +97,7 @@ func infoCmd(c *cliconfig.InfoValues) error {
out = formats.StdoutTemplate{Output: info, Template: infoOutputFormat}
}
- return formats.Writer(out).Out()
+ return out.Out()
}
// top-level "debug" info
diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go
index 12d89764c..cff221cb0 100644
--- a/cmd/podman/inspect.go
+++ b/cmd/podman/inspect.go
@@ -127,7 +127,7 @@ func inspectCmd(c *cliconfig.InspectValues) error {
out = formats.JSONStructArray{Output: inspectedObjects}
}
- return formats.Writer(out).Out()
+ return out.Out()
}
// func iterateInput iterates the images|containers the user has requested and returns the inspect data and error
diff --git a/cmd/podman/pod_pause.go b/cmd/podman/pod_pause.go
index 75d179f52..45e1319ff 100644
--- a/cmd/podman/pod_pause.go
+++ b/cmd/podman/pod_pause.go
@@ -56,7 +56,7 @@ func podPauseCmd(c *cliconfig.PodPauseValues) error {
for _, p := range pauseIDs {
fmt.Println(p)
}
- if conErrors != nil && len(conErrors) > 0 {
+ if len(conErrors) > 0 {
for ctr, err := range conErrors {
if lastError != nil {
logrus.Errorf("%q", lastError)
diff --git a/cmd/podman/pod_ps.go b/cmd/podman/pod_ps.go
index fd8da53fb..bda447c57 100644
--- a/cmd/podman/pod_ps.go
+++ b/cmd/podman/pod_ps.go
@@ -561,5 +561,5 @@ func generatePodPsOutput(pods []*adapter.Pod, opts podPsOptions) error {
out = formats.StdoutTemplateArray{Output: podPsToGeneric(psOutput, []podPsJSONParams{}), Template: opts.Format, Fields: psOutput[0].podHeaderMap()}
}
- return formats.Writer(out).Out()
+ return out.Out()
}
diff --git a/cmd/podman/pod_restart.go b/cmd/podman/pod_restart.go
index 0b009e6c7..cc090bd6e 100644
--- a/cmd/podman/pod_restart.go
+++ b/cmd/podman/pod_restart.go
@@ -58,7 +58,7 @@ func podRestartCmd(c *cliconfig.PodRestartValues) error {
for _, p := range restartIDs {
fmt.Println(p)
}
- if conErrors != nil && len(conErrors) > 0 {
+ if len(conErrors) > 0 {
for ctr, err := range conErrors {
if lastError != nil {
logrus.Errorf("%q", lastError)
diff --git a/cmd/podman/pod_stats.go b/cmd/podman/pod_stats.go
index 7984f08ee..46cacc026 100644
--- a/cmd/podman/pod_stats.go
+++ b/cmd/podman/pod_stats.go
@@ -91,24 +91,6 @@ func podStatsCmd(c *cliconfig.PodStatsValues) error {
if err != nil {
return errors.Wrapf(err, "unable to get a list of pods")
}
- // First we need to get an initial pass of pod/ctr stats (these are not printed)
- var podStats []*adapter.PodContainerStats
- for _, p := range pods {
- cons, err := p.AllContainersByID()
- if err != nil {
- return err
- }
- emptyStats := make(map[string]*libpod.ContainerStats)
- // Iterate the pods container ids and make blank stats for them
- for _, c := range cons {
- emptyStats[c] = &libpod.ContainerStats{}
- }
- ps := adapter.PodContainerStats{
- Pod: p,
- ContainerStats: emptyStats,
- }
- podStats = append(podStats, &ps)
- }
// Create empty container stat results for our first pass
var previousPodStats []*adapter.PodContainerStats
diff --git a/cmd/podman/pod_unpause.go b/cmd/podman/pod_unpause.go
index 91c3bfdf8..833434c3f 100644
--- a/cmd/podman/pod_unpause.go
+++ b/cmd/podman/pod_unpause.go
@@ -57,7 +57,7 @@ func podUnpauseCmd(c *cliconfig.PodUnpauseValues) error {
for _, p := range unpauseIDs {
fmt.Println(p)
}
- if conErrors != nil && len(conErrors) > 0 {
+ if len(conErrors) > 0 {
for ctr, err := range conErrors {
if lastError != nil {
logrus.Errorf("%q", lastError)
diff --git a/cmd/podman/remoteclientconfig/configfile.go b/cmd/podman/remoteclientconfig/configfile.go
index 06e82b186..56a868733 100644
--- a/cmd/podman/remoteclientconfig/configfile.go
+++ b/cmd/podman/remoteclientconfig/configfile.go
@@ -35,6 +35,7 @@ func (r *RemoteConfig) GetDefault() (*RemoteConnection, error) {
return nil, ErrNoDefinedConnections
}
for _, v := range r.Connections {
+ v := v
if len(r.Connections) == 1 {
// if there is only one defined connection, we assume it is
// the default whether tagged as such or not
@@ -54,6 +55,7 @@ func (r *RemoteConfig) GetRemoteConnection(name string) (*RemoteConnection, erro
return nil, ErrNoDefinedConnections
}
for k, v := range r.Connections {
+ v := v
if k == name {
return &v, nil
}
diff --git a/cmd/podman/search.go b/cmd/podman/search.go
index be75b6e37..f4c51bff1 100644
--- a/cmd/podman/search.go
+++ b/cmd/podman/search.go
@@ -84,7 +84,7 @@ func searchCmd(c *cliconfig.SearchValues) error {
return nil
}
out := formats.StdoutTemplateArray{Output: searchToGeneric(results), Template: format, Fields: searchHeaderMap()}
- return formats.Writer(out).Out()
+ return out.Out()
}
// searchHeaderMap returns the headers of a SearchResult.
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go
index b14ce431d..815e2d304 100644
--- a/cmd/podman/shared/create.go
+++ b/cmd/podman/shared/create.go
@@ -217,7 +217,7 @@ func parseSecurityOpt(config *cc.CreateConfig, securityOpts []string, runtime *l
} else {
con := strings.SplitN(opt, "=", 2)
if len(con) != 2 {
- return fmt.Errorf("Invalid --security-opt 1: %q", opt)
+ return fmt.Errorf("invalid --security-opt 1: %q", opt)
}
switch con[0] {
@@ -228,7 +228,7 @@ func parseSecurityOpt(config *cc.CreateConfig, securityOpts []string, runtime *l
case "seccomp":
config.SeccompProfilePath = con[1]
default:
- return fmt.Errorf("Invalid --security-opt 2: %q", opt)
+ return fmt.Errorf("invalid --security-opt 2: %q", opt)
}
}
}
@@ -841,7 +841,7 @@ func makeHealthCheckFromCli(c *GenericCLIResults) (*manifest.Schema2HealthConfig
if err != nil {
return nil, errors.Wrapf(err, "invalid healthcheck-timeout %s", inTimeout)
}
- if timeoutDuration < time.Duration(time.Second*1) {
+ if timeoutDuration < time.Duration(1) {
return nil, errors.New("healthcheck-timeout must be at least 1 second")
}
hc.Timeout = timeoutDuration
diff --git a/cmd/podman/stats.go b/cmd/podman/stats.go
index 05e30f95f..3accae1b6 100644
--- a/cmd/podman/stats.go
+++ b/cmd/podman/stats.go
@@ -200,7 +200,7 @@ func outputStats(stats []*libpod.ContainerStats, format string) error {
}
out = formats.StdoutTemplateArray{Output: statsToGeneric(outputStats, []statsOutputParams{}), Template: format, Fields: mapOfHeaders}
}
- return formats.Writer(out).Out()
+ return out.Out()
}
func genStatsFormat(format string) string {
diff --git a/cmd/podman/system_df.go b/cmd/podman/system_df.go
index 5b5655dc9..6b9824a79 100644
--- a/cmd/podman/system_df.go
+++ b/cmd/podman/system_df.go
@@ -143,7 +143,7 @@ func generateSysDfOutput(systemDfDiskUsages []systemDfDiskUsage, format string)
"Reclaimable": "RECLAIMABLE",
}
out := formats.StdoutTemplateArray{Output: systemDfDiskUsageToGeneric(systemDfDiskUsages), Template: format, Fields: systemDfHeader}
- return formats.Writer(out).Out()
+ return out.Out()
}
func getDiskUsage(ctx context.Context, runtime *libpod.Runtime, metaData dfMetaData) ([]systemDfDiskUsage, error) {
@@ -557,7 +557,7 @@ func imagesVerboseOutput(ctx context.Context, metaData dfMetaData) error {
return err
}
out := formats.StdoutTemplateArray{Output: systemDfImageVerboseDiskUsageToGeneric(imagesVerboseDiskUsage), Template: imageVerboseFormat, Fields: imageVerboseHeader}
- return formats.Writer(out).Out()
+ return out.Out()
}
func containersVerboseOutput(ctx context.Context, metaData dfMetaData) error {
@@ -579,7 +579,7 @@ func containersVerboseOutput(ctx context.Context, metaData dfMetaData) error {
return err
}
out := formats.StdoutTemplateArray{Output: systemDfContainerVerboseDiskUsageToGeneric(containersVerboseDiskUsage), Template: containerVerboseFormat, Fields: containerVerboseHeader}
- return formats.Writer(out).Out()
+ return out.Out()
}
@@ -597,7 +597,7 @@ func volumesVerboseOutput(ctx context.Context, metaData dfMetaData) error {
return err
}
out := formats.StdoutTemplateArray{Output: systemDfVolumeVerboseDiskUsageToGeneric(volumesVerboseDiskUsage), Template: volumeVerboseFormat, Fields: volumeVerboseHeader}
- return formats.Writer(out).Out()
+ return out.Out()
}
func verboseOutput(ctx context.Context, metaData dfMetaData) error {
diff --git a/cmd/podman/trust_set_show.go b/cmd/podman/trust_set_show.go
index d6f0eabd8..7d2a5ddc3 100644
--- a/cmd/podman/trust_set_show.go
+++ b/cmd/podman/trust_set_show.go
@@ -118,7 +118,7 @@ func showTrustCmd(c *cliconfig.ShowTrustValues) error {
}
outjson = policyJSON
out := formats.JSONStruct{Output: outjson}
- return formats.Writer(out).Out()
+ return out.Out()
}
showOutputMap, err := getPolicyShowOutput(policyContentStruct, systemRegistriesDirPath)
@@ -126,7 +126,7 @@ func showTrustCmd(c *cliconfig.ShowTrustValues) error {
return errors.Wrapf(err, "could not show trust policies")
}
out := formats.StdoutTemplateArray{Output: showOutputMap, Template: "{{.Repo}}\t{{.Trusttype}}\t{{.GPGid}}\t{{.Sigstore}}"}
- return formats.Writer(out).Out()
+ return out.Out()
}
func setTrustCmd(c *cliconfig.SetTrustValues) error {
@@ -254,15 +254,12 @@ func getPolicyJSON(policyContentStruct trust.PolicyContent, systemRegistriesDirP
policyJSON[repo]["type"] = repoval[0].Type
policyJSON[repo]["transport"] = transname
keyarr := []string{}
- uids := []string{}
for _, repoele := range repoval {
if len(repoele.KeyPath) > 0 {
keyarr = append(keyarr, repoele.KeyPath)
- uids = append(uids, trust.GetGPGIdFromKeyPath(repoele.KeyPath)...)
}
if len(repoele.KeyData) > 0 {
- keyarr = append(keyarr, string(repoele.KeyData))
- uids = append(uids, trust.GetGPGIdFromKeyData(string(repoele.KeyData))...)
+ keyarr = append(keyarr, repoele.KeyData)
}
}
policyJSON[repo]["keys"] = keyarr
@@ -308,16 +305,17 @@ func getPolicyShowOutput(policyContentStruct trust.PolicyContent, systemRegistri
Repo: repo,
Trusttype: repoval[0].Type,
}
- keyarr := []string{}
+ // TODO - keyarr is not used and I don't know its intent; commenting out for now for someone to fix later
+ //keyarr := []string{}
uids := []string{}
for _, repoele := range repoval {
if len(repoele.KeyPath) > 0 {
- keyarr = append(keyarr, repoele.KeyPath)
+ //keyarr = append(keyarr, repoele.KeyPath)
uids = append(uids, trust.GetGPGIdFromKeyPath(repoele.KeyPath)...)
}
if len(repoele.KeyData) > 0 {
- keyarr = append(keyarr, string(repoele.KeyData))
- uids = append(uids, trust.GetGPGIdFromKeyData(string(repoele.KeyData))...)
+ //keyarr = append(keyarr, string(repoele.KeyData))
+ uids = append(uids, trust.GetGPGIdFromKeyData(repoele.KeyData)...)
}
}
tempTrustShowOutput.GPGid = strings.Join(uids, ", ")
diff --git a/cmd/podman/version.go b/cmd/podman/version.go
index 6a88993c1..314b2e266 100644
--- a/cmd/podman/version.go
+++ b/cmd/podman/version.go
@@ -57,7 +57,7 @@ func versionCmd(c *cliconfig.VersionValues) error {
default:
out = formats.StdoutTemplate{Output: clientVersion, Template: versionOutputFormat}
}
- return formats.Writer(out).Out()
+ return out.Out()
}
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
diff --git a/cmd/podman/volume_ls.go b/cmd/podman/volume_ls.go
index 7248caf0c..eda5685cf 100644
--- a/cmd/podman/volume_ls.go
+++ b/cmd/podman/volume_ls.go
@@ -238,7 +238,7 @@ func generateVolLsOutput(volumes []*adapter.Volume, opts volumeLsOptions) error
}
out = formats.StdoutTemplateArray{Output: volLsToGeneric(lsOutput, []volumeLsJSONParams{}), Template: opts.Format, Fields: lsOutput[0].volHeaderMap()}
}
- return formats.Writer(out).Out()
+ return out.Out()
}
// generateVolumeFilterFuncs returns the true if the volume matches the filter set, otherwise it returns false.