diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-04-27 04:50:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-27 04:50:01 -0400 |
commit | 053b09660ffbe2df2104186c67e39be70764ff63 (patch) | |
tree | b9d8d32e146eb1ca1a3385e61b24d276dabc1cf0 /pkg/bindings | |
parent | 5ac00a7287e4a9e6292f4a6ca5dfa9a02e5ca907 (diff) | |
parent | 4f8ece76fff31d31570af56e0ec4a4092e015b33 (diff) | |
download | podman-053b09660ffbe2df2104186c67e39be70764ff63.tar.gz podman-053b09660ffbe2df2104186c67e39be70764ff63.tar.bz2 podman-053b09660ffbe2df2104186c67e39be70764ff63.zip |
Merge pull request #13997 from Luap99/gocritic
enable gocritic linter
Diffstat (limited to 'pkg/bindings')
-rw-r--r-- | pkg/bindings/images/build.go | 16 | ||||
-rw-r--r-- | pkg/bindings/images/types.go | 2 | ||||
-rw-r--r-- | pkg/bindings/network/network.go | 4 | ||||
-rw-r--r-- | pkg/bindings/test/containers_test.go | 34 | ||||
-rw-r--r-- | pkg/bindings/test/pods_test.go | 6 | ||||
-rw-r--r-- | pkg/bindings/test/volumes_test.go | 13 |
6 files changed, 30 insertions, 45 deletions
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index 1729bd922..9e0a0d798 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -225,10 +225,8 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO platform = "linux" } platform += "/" + options.Architecture - } else { - if len(platform) > 0 { - platform += "/" + runtime.GOARCH - } + } else if len(platform) > 0 { + platform += "/" + runtime.GOARCH } if len(platform) > 0 { params.Set("platform", platform) @@ -447,7 +445,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO } } } - secretsForRemote = append(secretsForRemote, strings.Join(modifiedOpt[:], ",")) + secretsForRemote = append(secretsForRemote, strings.Join(modifiedOpt, ",")) } } @@ -603,8 +601,8 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) { // are required to visit all files. :( return nil } - - if d.Type().IsRegular() { // add file item + switch { + case d.Type().IsRegular(): // add file item info, err := d.Info() if err != nil { return err @@ -644,7 +642,7 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) { seen[di] = name } return err - } else if d.IsDir() { // add folders + case d.IsDir(): // add folders info, err := d.Info() if err != nil { return err @@ -658,7 +656,7 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) { if lerr := tw.WriteHeader(hdr); lerr != nil { return lerr } - } else if d.Type()&os.ModeSymlink != 0 { // add symlinks as it, not content + case d.Type()&os.ModeSymlink != 0: // add symlinks as it, not content link, err := os.Readlink(path) if err != nil { return err diff --git a/pkg/bindings/images/types.go b/pkg/bindings/images/types.go index 75cb38a0a..8e5e7ee92 100644 --- a/pkg/bindings/images/types.go +++ b/pkg/bindings/images/types.go @@ -177,7 +177,7 @@ type PullOptions struct { Variant *string } -//BuildOptions are optional options for building images +// BuildOptions are optional options for building images type BuildOptions struct { buildahDefine.BuildOptions } diff --git a/pkg/bindings/network/network.go b/pkg/bindings/network/network.go index 6c7777fdd..83641f677 100644 --- a/pkg/bindings/network/network.go +++ b/pkg/bindings/network/network.go @@ -101,7 +101,7 @@ func List(ctx context.Context, options *ListOptions) ([]types.Network, error) { } // 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) } @@ -114,7 +114,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 diff --git a/pkg/bindings/test/containers_test.go b/pkg/bindings/test/containers_test.go index bf627fdba..090dd294c 100644 --- a/pkg/bindings/test/containers_test.go +++ b/pkg/bindings/test/containers_test.go @@ -104,9 +104,9 @@ var _ = Describe("Podman containers ", func() { // Pause by name err = containers.Pause(bt.conn, name, nil) Expect(err).To(BeNil(), "error from containers.Pause()") - //paused := "paused" - //_, err = containers.Wait(bt.conn, cid, &paused) - //Expect(err).To(BeNil()) + // paused := "paused" + // _, err = containers.Wait(bt.conn, cid, &paused) + // Expect(err).To(BeNil()) err = containers.Unpause(bt.conn, name, nil) Expect(err).To(BeNil()) @@ -332,8 +332,8 @@ var _ = Describe("Podman containers ", func() { // TODO for the life of me, i cannot get this to work. maybe another set // of eyes will // successful healthcheck - //status := define.HealthCheckHealthy - //for i:=0; i < 10; i++ { + // status := define.HealthCheckHealthy + // for i:=0; i < 10; i++ { // result, err := containers.RunHealthCheck(connText, "hc") // Expect(err).To(BeNil()) // if result.Status != define.HealthCheckHealthy { @@ -343,18 +343,18 @@ var _ = Describe("Podman containers ", func() { // } // status = result.Status // break - //} - //Expect(status).To(Equal(define.HealthCheckHealthy)) + // } + // Expect(status).To(Equal(define.HealthCheckHealthy)) // TODO enable this when wait is working // healthcheck on a stopped container should be a 409 - //err = containers.Stop(connText, "hc", nil) - //Expect(err).To(BeNil()) - //_, err = containers.Wait(connText, "hc") - //Expect(err).To(BeNil()) - //_, err = containers.RunHealthCheck(connText, "hc") - //code, _ = bindings.CheckResponseCode(err) - //Expect(code).To(BeNumerically("==", http.StatusConflict)) + // err = containers.Stop(connText, "hc", nil) + // Expect(err).To(BeNil()) + // _, err = containers.Wait(connText, "hc") + // Expect(err).To(BeNil()) + // _, err = containers.RunHealthCheck(connText, "hc") + // code, _ = bindings.CheckResponseCode(err) + // Expect(code).To(BeNumerically("==", http.StatusConflict)) }) It("logging", func() { @@ -490,7 +490,7 @@ var _ = Describe("Podman containers ", func() { }) It("podman kill a running container by bogus signal", func() { - //Killing a running container by bogus signal should fail + // Killing a running container by bogus signal should fail var name = "top" cid, err := bt.RunTopContainer(&name, nil) Expect(err).To(BeNil()) @@ -580,7 +580,7 @@ var _ = Describe("Podman containers ", func() { // Valid filter params container should be pruned now. filters := map[string][]string{ - "until": {"5000000000"}, //Friday, June 11, 2128 + "until": {"5000000000"}, // Friday, June 11, 2128 } pruneResponse, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filters)) Expect(err).To(BeNil()) @@ -594,7 +594,7 @@ var _ = Describe("Podman containers ", func() { Expect(err).To(BeNil()) filters := map[string][]string{ - "until": {"5000000000"}, //Friday, June 11, 2128 + "until": {"5000000000"}, // Friday, June 11, 2128 } c, err := containers.List(bt.conn, new(containers.ListOptions).WithFilters(filters).WithAll(true)) Expect(err).To(BeNil()) diff --git a/pkg/bindings/test/pods_test.go b/pkg/bindings/test/pods_test.go index 1c93c5595..d47e9ee0e 100644 --- a/pkg/bindings/test/pods_test.go +++ b/pkg/bindings/test/pods_test.go @@ -43,13 +43,13 @@ var _ = Describe("Podman pods", func() { }) It("inspect pod", func() { - //Inspect an invalid pod name + // Inspect an invalid pod name _, err := pods.Inspect(bt.conn, "dummyname", nil) Expect(err).ToNot(BeNil()) code, _ := bindings.CheckResponseCode(err) Expect(code).To(BeNumerically("==", http.StatusNotFound)) - //Inspect an valid pod name + // Inspect an valid pod name response, err := pods.Inspect(bt.conn, newpod, nil) Expect(err).To(BeNil()) Expect(response.Name).To(Equal(newpod)) @@ -57,7 +57,7 @@ var _ = Describe("Podman pods", func() { // Test validates the list all api returns It("list pod", func() { - //List all the pods in the current instance + // List all the pods in the current instance podSummary, err := pods.List(bt.conn, nil) Expect(err).To(BeNil()) Expect(len(podSummary)).To(Equal(1)) diff --git a/pkg/bindings/test/volumes_test.go b/pkg/bindings/test/volumes_test.go index c0d01439b..8ae93eed9 100644 --- a/pkg/bindings/test/volumes_test.go +++ b/pkg/bindings/test/volumes_test.go @@ -18,9 +18,6 @@ import ( var _ = Describe("Podman volumes", func() { var ( - //tempdir string - //err error - //podmanTest *PodmanTestIntegration bt *bindingTest s *gexec.Session connText context.Context @@ -28,13 +25,6 @@ var _ = Describe("Podman volumes", func() { ) BeforeEach(func() { - //tempdir, err = CreateTempDirInTempDir() - //if err != nil { - // os.Exit(1) - //} - //podmanTest = PodmanTestCreate(tempdir) - //podmanTest.Setup() - //podmanTest.SeedImages() bt = newBindingTest() bt.RestoreImagesFromCache() s = bt.startAPIService() @@ -44,9 +34,6 @@ var _ = Describe("Podman volumes", func() { }) AfterEach(func() { - //podmanTest.Cleanup() - //f := CurrentGinkgoTestDescription() - //processTestResult(f) s.Kill() bt.cleanup() }) |