summaryrefslogtreecommitdiff
path: root/pkg/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/bindings')
-rw-r--r--pkg/bindings/connection.go7
-rw-r--r--pkg/bindings/containers/containers.go5
-rw-r--r--pkg/bindings/test/common_test.go5
-rw-r--r--pkg/bindings/test/containers_test.go7
-rw-r--r--pkg/bindings/test/pods_test.go2
-rw-r--r--pkg/bindings/test/volumes_test.go29
-rw-r--r--pkg/bindings/volumes/volumes.go6
7 files changed, 34 insertions, 27 deletions
diff --git a/pkg/bindings/connection.go b/pkg/bindings/connection.go
index 289debd8c..4fe4dd72d 100644
--- a/pkg/bindings/connection.go
+++ b/pkg/bindings/connection.go
@@ -165,8 +165,13 @@ func sshClient(_url *url.URL, identity string, secure bool) (*http.Client, error
}
}
+ port := _url.Port()
+ if port == "" {
+ port = "22"
+ }
+
bastion, err := ssh.Dial("tcp",
- net.JoinHostPort(_url.Hostname(), _url.Port()),
+ net.JoinHostPort(_url.Hostname(), port),
&ssh.ClientConfig{
User: _url.User.Username(),
Auth: []ssh.AuthMethod{auth},
diff --git a/pkg/bindings/containers/containers.go b/pkg/bindings/containers/containers.go
index f298dbba1..534555a00 100644
--- a/pkg/bindings/containers/containers.go
+++ b/pkg/bindings/containers/containers.go
@@ -7,6 +7,7 @@ import (
"strconv"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
lpapiv2 "github.com/containers/libpod/pkg/api/handlers/libpod"
"github.com/containers/libpod/pkg/bindings"
)
@@ -212,7 +213,7 @@ func Unpause(ctx context.Context, nameOrID string) error {
// Wait blocks until the given container reaches a condition. If not provided, the condition will
// default to stopped. If the condition is stopped, an exit code for the container will be provided. The
// nameOrID can be a container name or a partial/full ID.
-func Wait(ctx context.Context, nameOrID string, condition *string) (int32, error) {
+func Wait(ctx context.Context, nameOrID string, condition *define.ContainerStatus) (int32, error) { //nolint
var exitCode int32
conn, err := bindings.GetClient(ctx)
if err != nil {
@@ -220,7 +221,7 @@ func Wait(ctx context.Context, nameOrID string, condition *string) (int32, error
}
params := url.Values{}
if condition != nil {
- params.Set("condition", *condition)
+ params.Set("condition", condition.String())
}
response, err := conn.DoRequest(nil, http.MethodPost, "/containers/%s/wait", params, nameOrID)
if err != nil {
diff --git a/pkg/bindings/test/common_test.go b/pkg/bindings/test/common_test.go
index 409e620a3..6b8d6788c 100644
--- a/pkg/bindings/test/common_test.go
+++ b/pkg/bindings/test/common_test.go
@@ -3,6 +3,7 @@ package test_bindings
import (
"context"
"fmt"
+ "github.com/containers/libpod/libpod/define"
"io/ioutil"
"os"
"os/exec"
@@ -205,8 +206,8 @@ func (b *bindingTest) RunTopContainer(containerName *string, insidePod *bool, po
if err != nil {
return "", err
}
- waiting := "running"
- _, err = containers.Wait(b.conn, ctr.ID, &waiting)
+ wait := define.ContainerStateRunning
+ _, err = containers.Wait(b.conn, ctr.ID, &wait)
return ctr.ID, err
}
diff --git a/pkg/bindings/test/containers_test.go b/pkg/bindings/test/containers_test.go
index afb0cc19b..f5465c803 100644
--- a/pkg/bindings/test/containers_test.go
+++ b/pkg/bindings/test/containers_test.go
@@ -1,6 +1,7 @@
package test_bindings
import (
+ "github.com/containers/libpod/libpod/define"
"net/http"
"strconv"
"strings"
@@ -282,8 +283,8 @@ var _ = Describe("Podman containers ", func() {
var (
name = "top"
exitCode int32 = -1
- pause = "paused"
- unpause = "running"
+ pause = define.ContainerStatePaused
+ running = define.ContainerStateRunning
)
errChan := make(chan error)
_, err := bt.RunTopContainer(&name, nil, nil)
@@ -301,7 +302,7 @@ var _ = Describe("Podman containers ", func() {
errChan = make(chan error)
go func() {
- _, waitErr := containers.Wait(bt.conn, name, &unpause)
+ _, waitErr := containers.Wait(bt.conn, name, &running)
errChan <- waitErr
close(errChan)
}()
diff --git a/pkg/bindings/test/pods_test.go b/pkg/bindings/test/pods_test.go
index d7334e0e5..29cfcdbbc 100644
--- a/pkg/bindings/test/pods_test.go
+++ b/pkg/bindings/test/pods_test.go
@@ -84,7 +84,7 @@ var _ = Describe("Podman pods", func() {
trueFlag = true
)
bt.Podcreate(&newpod2)
- _, err = bt.RunTopContainer(nil, &trueFlag, &newpod)
+ _, err = bt.RunTopContainer(nil, &bindings.PTrue, &newpod)
Expect(err).To(BeNil())
// Expected err with invalid filter params
diff --git a/pkg/bindings/test/volumes_test.go b/pkg/bindings/test/volumes_test.go
index 1d5ae1329..9da034d24 100644
--- a/pkg/bindings/test/volumes_test.go
+++ b/pkg/bindings/test/volumes_test.go
@@ -6,11 +6,10 @@ import (
"net/http"
"time"
- "github.com/containers/libpod/pkg/api/handlers"
+ "github.com/containers/libpod/pkg/bindings"
"github.com/containers/libpod/pkg/bindings/containers"
"github.com/containers/libpod/pkg/bindings/volumes"
-
- "github.com/containers/libpod/pkg/bindings"
+ "github.com/containers/libpod/pkg/domain/entities"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
@@ -53,13 +52,13 @@ var _ = Describe("Podman volumes", func() {
It("create volume", func() {
// create a volume with blank config should work
- _, err := volumes.Create(connText, handlers.VolumeCreateConfig{})
+ _, err := volumes.Create(connText, entities.VolumeCreateOptions{})
Expect(err).To(BeNil())
- vcc := handlers.VolumeCreateConfig{
- Name: "foobar",
- Label: nil,
- Opts: nil,
+ vcc := entities.VolumeCreateOptions{
+ Name: "foobar",
+ Label: nil,
+ Options: nil,
}
vol, err := volumes.Create(connText, vcc)
Expect(err).To(BeNil())
@@ -73,7 +72,7 @@ var _ = Describe("Podman volumes", func() {
})
It("inspect volume", func() {
- vol, err := volumes.Create(connText, handlers.VolumeCreateConfig{})
+ vol, err := volumes.Create(connText, entities.VolumeCreateOptions{})
Expect(err).To(BeNil())
data, err := volumes.Inspect(connText, vol.Name)
Expect(err).To(BeNil())
@@ -87,13 +86,13 @@ var _ = Describe("Podman volumes", func() {
Expect(code).To(BeNumerically("==", http.StatusNotFound))
// Removing an unused volume should work
- vol, err := volumes.Create(connText, handlers.VolumeCreateConfig{})
+ vol, err := volumes.Create(connText, entities.VolumeCreateOptions{})
Expect(err).To(BeNil())
err = volumes.Remove(connText, vol.Name, nil)
Expect(err).To(BeNil())
// Removing a volume that is being used without force should be 409
- vol, err = volumes.Create(connText, handlers.VolumeCreateConfig{})
+ vol, err = volumes.Create(connText, entities.VolumeCreateOptions{})
Expect(err).To(BeNil())
session := bt.runPodman([]string{"run", "-dt", "-v", fmt.Sprintf("%s:/foobar", vol.Name), "--name", "vtest", alpine.name, "top"})
session.Wait(45)
@@ -119,7 +118,7 @@ var _ = Describe("Podman volumes", func() {
// create a bunch of named volumes and make verify with list
volNames := []string{"homer", "bart", "lisa", "maggie", "marge"}
for i := 0; i < 5; i++ {
- _, err = volumes.Create(connText, handlers.VolumeCreateConfig{Name: volNames[i]})
+ _, err = volumes.Create(connText, entities.VolumeCreateOptions{Name: volNames[i]})
Expect(err).To(BeNil())
}
vols, err = volumes.List(connText, nil)
@@ -152,15 +151,15 @@ var _ = Describe("Podman volumes", func() {
Expect(err).To(BeNil())
// Removing an unused volume should work
- _, err = volumes.Create(connText, handlers.VolumeCreateConfig{})
+ _, err = volumes.Create(connText, entities.VolumeCreateOptions{})
Expect(err).To(BeNil())
vols, err := volumes.Prune(connText)
Expect(err).To(BeNil())
Expect(len(vols)).To(BeNumerically("==", 1))
- _, err = volumes.Create(connText, handlers.VolumeCreateConfig{Name: "homer"})
+ _, err = volumes.Create(connText, entities.VolumeCreateOptions{Name: "homer"})
Expect(err).To(BeNil())
- _, err = volumes.Create(connText, handlers.VolumeCreateConfig{})
+ _, err = volumes.Create(connText, entities.VolumeCreateOptions{})
Expect(err).To(BeNil())
session := bt.runPodman([]string{"run", "-dt", "-v", fmt.Sprintf("%s:/homer", "homer"), "--name", "vtest", alpine.name, "top"})
session.Wait(45)
diff --git a/pkg/bindings/volumes/volumes.go b/pkg/bindings/volumes/volumes.go
index 0bc818605..a2164e0af 100644
--- a/pkg/bindings/volumes/volumes.go
+++ b/pkg/bindings/volumes/volumes.go
@@ -8,15 +8,15 @@ import (
"strings"
"github.com/containers/libpod/libpod"
- "github.com/containers/libpod/pkg/api/handlers"
"github.com/containers/libpod/pkg/bindings"
+ "github.com/containers/libpod/pkg/domain/entities"
jsoniter "github.com/json-iterator/go"
)
// Create creates a volume given its configuration.
-func Create(ctx context.Context, config handlers.VolumeCreateConfig) (*libpod.VolumeConfig, error) {
+func Create(ctx context.Context, config entities.VolumeCreateOptions) (*entities.VolumeConfigResponse, error) {
var (
- v libpod.VolumeConfig
+ v entities.VolumeConfigResponse
)
conn, err := bindings.GetClient(ctx)
if err != nil {