aboutsummaryrefslogtreecommitdiff
path: root/pkg/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/bindings')
-rw-r--r--pkg/bindings/images/build.go16
-rw-r--r--pkg/bindings/images/types.go2
-rw-r--r--pkg/bindings/manifests/manifests.go91
-rw-r--r--pkg/bindings/network/network.go4
-rw-r--r--pkg/bindings/test/containers_test.go34
-rw-r--r--pkg/bindings/test/manifests_test.go2
-rw-r--r--pkg/bindings/test/pods_test.go6
-rw-r--r--pkg/bindings/test/volumes_test.go13
8 files changed, 49 insertions, 119 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/manifests/manifests.go b/pkg/bindings/manifests/manifests.go
index 70b3819f5..828f4922c 100644
--- a/pkg/bindings/manifests/manifests.go
+++ b/pkg/bindings/manifests/manifests.go
@@ -2,13 +2,11 @@ package manifests
import (
"context"
- "fmt"
"io/ioutil"
"net/http"
"strconv"
"strings"
- "github.com/blang/semver"
"github.com/containers/image/v5/manifest"
imageTypes "github.com/containers/image/v5/types"
"github.com/containers/podman/v4/pkg/api/handlers"
@@ -17,7 +15,6 @@ import (
"github.com/containers/podman/v4/pkg/bindings/images"
"github.com/containers/podman/v4/pkg/domain/entities"
"github.com/containers/podman/v4/pkg/errorhandling"
- "github.com/containers/podman/v4/version"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
)
@@ -95,65 +92,23 @@ func Add(ctx context.Context, name string, options *AddOptions) (string, error)
options = new(AddOptions)
}
- if bindings.ServiceVersion(ctx).GTE(semver.MustParse("4.0.0")) {
- optionsv4 := ModifyOptions{
- All: options.All,
- Annotations: options.Annotation,
- Arch: options.Arch,
- Features: options.Features,
- Images: options.Images,
- OS: options.OS,
- OSFeatures: nil,
- OSVersion: options.OSVersion,
- Variant: options.Variant,
- Username: options.Username,
- Password: options.Password,
- Authfile: options.Authfile,
- SkipTLSVerify: options.SkipTLSVerify,
- }
- optionsv4.WithOperation("update")
- return Modify(ctx, name, options.Images, &optionsv4)
- }
-
- // API Version < 4.0.0
- conn, err := bindings.GetClient(ctx)
- if err != nil {
- return "", err
- }
- opts, err := jsoniter.MarshalToString(options)
- if err != nil {
- return "", err
- }
- reader := strings.NewReader(opts)
-
- header, err := auth.MakeXRegistryAuthHeader(&imageTypes.SystemContext{AuthFilePath: options.GetAuthfile()}, options.GetUsername(), options.GetPassword())
- if err != nil {
- return "", err
- }
-
- params, err := options.ToParams()
- if err != nil {
- return "", err
- }
- // SkipTLSVerify is special. We need to delete the param added by
- // ToParams() and change the key and flip the bool
- if options.SkipTLSVerify != nil {
- params.Del("SkipTLSVerify")
- params.Set("tlsVerify", strconv.FormatBool(!options.GetSkipTLSVerify()))
- }
-
- v := version.APIVersion[version.Libpod][version.MinimalAPI]
- header.Add("API-Version",
- fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Patch))
-
- response, err := conn.DoRequest(ctx, reader, http.MethodPost, "/manifests/%s/add", params, header, name)
- if err != nil {
- return "", err
- }
- defer response.Body.Close()
-
- var idr handlers.IDResponse
- return idr.ID, response.Process(&idr)
+ optionsv4 := ModifyOptions{
+ All: options.All,
+ Annotations: options.Annotation,
+ Arch: options.Arch,
+ Features: options.Features,
+ Images: options.Images,
+ OS: options.OS,
+ OSFeatures: nil,
+ OSVersion: options.OSVersion,
+ Variant: options.Variant,
+ Username: options.Username,
+ Password: options.Password,
+ Authfile: options.Authfile,
+ SkipTLSVerify: options.SkipTLSVerify,
+ }
+ optionsv4.WithOperation("update")
+ return Modify(ctx, name, options.Images, &optionsv4)
}
// Remove deletes a manifest entry from a manifest list. Both name and the digest to be
@@ -185,9 +140,6 @@ func Push(ctx context.Context, name, destination string, options *images.PushOpt
if err != nil {
return "", err
}
- v := version.APIVersion[version.Libpod][version.MinimalAPI]
- header.Add("API-Version",
- fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Patch))
params, err := options.ToParams()
if err != nil {
@@ -200,14 +152,7 @@ func Push(ctx context.Context, name, destination string, options *images.PushOpt
params.Set("tlsVerify", strconv.FormatBool(!options.GetSkipTLSVerify()))
}
- var response *bindings.APIResponse
- if bindings.ServiceVersion(ctx).GTE(semver.MustParse("4.0.0")) {
- response, err = conn.DoRequest(ctx, nil, http.MethodPost, "/manifests/%s/registry/%s", params, header, name, destination)
- } else {
- params.Set("image", name)
- params.Set("destination", destination)
- response, err = conn.DoRequest(ctx, nil, http.MethodPost, "/manifests/%s/push", params, header, name)
- }
+ response, err := conn.DoRequest(ctx, nil, http.MethodPost, "/manifests/%s/registry/%s", params, header, name, destination)
if err != nil {
return "", err
}
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/manifests_test.go b/pkg/bindings/test/manifests_test.go
index 64becda43..e6c93817d 100644
--- a/pkg/bindings/test/manifests_test.go
+++ b/pkg/bindings/test/manifests_test.go
@@ -96,7 +96,7 @@ var _ = Describe("podman manifest", func() {
Expect(err).To(HaveOccurred())
code, _ = bindings.CheckResponseCode(err)
- Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
+ Expect(code).To(BeNumerically("==", http.StatusBadRequest))
})
It("remove digest", func() {
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()
})