summaryrefslogtreecommitdiff
path: root/pkg/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/bindings')
-rw-r--r--pkg/bindings/connection.go32
-rw-r--r--pkg/bindings/containers/attach.go3
-rw-r--r--pkg/bindings/containers/types.go5
-rw-r--r--pkg/bindings/containers/types_resizetty_options.go16
-rw-r--r--pkg/bindings/images/build.go6
-rw-r--r--pkg/bindings/images/images.go6
-rw-r--r--pkg/bindings/images/rm.go4
-rw-r--r--pkg/bindings/images/types.go4
-rw-r--r--pkg/bindings/test/containers_test.go22
9 files changed, 56 insertions, 42 deletions
diff --git a/pkg/bindings/connection.go b/pkg/bindings/connection.go
index 21a8e7a8b..fd93c5ac7 100644
--- a/pkg/bindings/connection.go
+++ b/pkg/bindings/connection.go
@@ -22,14 +22,6 @@ import (
"golang.org/x/crypto/ssh/agent"
)
-var (
- BasePath = &url.URL{
- Scheme: "http",
- Host: "d",
- Path: "/v" + version.APIVersion[version.Libpod][version.CurrentAPI].String() + "/libpod",
- }
-)
-
type APIResponse struct {
*http.Response
Request *http.Request
@@ -318,16 +310,24 @@ func (c *Connection) DoRequest(httpBody io.Reader, httpMethod, endpoint string,
err error
response *http.Response
)
- safePathValues := make([]interface{}, len(pathValues))
- // Make sure path values are http url safe
+
+ params := make([]interface{}, len(pathValues)+3)
+
+ // Including the semver suffices breaks older services... so do not include them
+ v := version.APIVersion[version.Libpod][version.CurrentAPI]
+ params[0] = v.Major
+ params[1] = v.Minor
+ params[2] = v.Patch
for i, pv := range pathValues {
- safePathValues[i] = url.PathEscape(pv)
+ // url.URL lacks the semantics for escaping embedded path parameters... so we manually
+ // escape each one and assume the caller included the correct formatting in "endpoint"
+ params[i+3] = url.PathEscape(pv)
}
- // Lets eventually use URL for this which might lead to safer
- // usage
- safeEndpoint := fmt.Sprintf(endpoint, safePathValues...)
- e := BasePath.String() + safeEndpoint
- req, err := http.NewRequest(httpMethod, e, httpBody)
+
+ uri := fmt.Sprintf("http://d/v%d.%d.%d/libpod"+endpoint, params...)
+ logrus.Debugf("DoRequest Method: %s URI: %v", httpMethod, uri)
+
+ req, err := http.NewRequest(httpMethod, uri, httpBody)
if err != nil {
return nil, err
}
diff --git a/pkg/bindings/containers/attach.go b/pkg/bindings/containers/attach.go
index f48b99a95..fd8a7011d 100644
--- a/pkg/bindings/containers/attach.go
+++ b/pkg/bindings/containers/attach.go
@@ -307,6 +307,7 @@ func resizeTTY(ctx context.Context, endpoint string, height *int, width *int) er
if width != nil {
params.Set("w", strconv.Itoa(*width))
}
+ params.Set("running", "true")
rsp, err := conn.DoRequest(nil, http.MethodPost, endpoint, params, nil)
if err != nil {
return err
@@ -336,7 +337,7 @@ func attachHandleResize(ctx, winCtx context.Context, winChange chan os.Signal, i
case <-winCtx.Done():
return
case <-winChange:
- h, w, err := terminal.GetSize(int(file.Fd()))
+ w, h, err := terminal.GetSize(int(file.Fd()))
if err != nil {
logrus.Warnf("failed to obtain TTY size: %v", err)
}
diff --git a/pkg/bindings/containers/types.go b/pkg/bindings/containers/types.go
index 2d0e65bb4..f63e35bf1 100644
--- a/pkg/bindings/containers/types.go
+++ b/pkg/bindings/containers/types.go
@@ -210,8 +210,9 @@ type RenameOptions struct {
// ResizeTTYOptions are optional options for resizing
// container TTYs
type ResizeTTYOptions struct {
- Height *int
- Width *int
+ Height *int
+ Width *int
+ Running *bool
}
//go:generate go run ../generator/generator.go ResizeExecTTYOptions
diff --git a/pkg/bindings/containers/types_resizetty_options.go b/pkg/bindings/containers/types_resizetty_options.go
index 68527b330..94946692f 100644
--- a/pkg/bindings/containers/types_resizetty_options.go
+++ b/pkg/bindings/containers/types_resizetty_options.go
@@ -51,3 +51,19 @@ func (o *ResizeTTYOptions) GetWidth() int {
}
return *o.Width
}
+
+// WithRunning
+func (o *ResizeTTYOptions) WithRunning(value bool) *ResizeTTYOptions {
+ v := &value
+ o.Running = v
+ return o
+}
+
+// GetRunning
+func (o *ResizeTTYOptions) GetRunning() bool {
+ var running bool
+ if o.Running == nil {
+ return running
+ }
+ return *o.Running
+}
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go
index 9d77883f9..c79d79136 100644
--- a/pkg/bindings/images/build.go
+++ b/pkg/bindings/images/build.go
@@ -15,7 +15,6 @@ import (
"strconv"
"strings"
- "github.com/containers/buildah"
"github.com/containers/podman/v3/pkg/auth"
"github.com/containers/podman/v3/pkg/bindings"
"github.com/containers/podman/v3/pkg/domain/entities"
@@ -175,9 +174,8 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
if len(platform) > 0 {
params.Set("platform", platform)
}
- if options.PullPolicy == buildah.PullAlways {
- params.Set("pull", "1")
- }
+ params.Set("pullpolicy", options.PullPolicy.String())
+
if options.Quiet {
params.Set("q", "1")
}
diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go
index 1be2bdfdd..8680d6baa 100644
--- a/pkg/bindings/images/images.go
+++ b/pkg/bindings/images/images.go
@@ -8,7 +8,7 @@ import (
"net/url"
"strconv"
- "github.com/containers/podman/v3/pkg/api/handlers"
+ "github.com/containers/podman/v3/pkg/api/handlers/types"
"github.com/containers/podman/v3/pkg/auth"
"github.com/containers/podman/v3/pkg/bindings"
"github.com/containers/podman/v3/pkg/domain/entities"
@@ -96,12 +96,12 @@ func Tree(ctx context.Context, nameOrID string, options *TreeOptions) (*entities
}
// History returns the parent layers of an image.
-func History(ctx context.Context, nameOrID string, options *HistoryOptions) ([]*handlers.HistoryResponse, error) {
+func History(ctx context.Context, nameOrID string, options *HistoryOptions) ([]*types.HistoryResponse, error) {
if options == nil {
options = new(HistoryOptions)
}
_ = options
- var history []*handlers.HistoryResponse
+ var history []*types.HistoryResponse
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, err
diff --git a/pkg/bindings/images/rm.go b/pkg/bindings/images/rm.go
index beecce7bf..e45e583f4 100644
--- a/pkg/bindings/images/rm.go
+++ b/pkg/bindings/images/rm.go
@@ -4,7 +4,7 @@ import (
"context"
"net/http"
- "github.com/containers/podman/v3/pkg/api/handlers"
+ "github.com/containers/podman/v3/pkg/api/handlers/types"
"github.com/containers/podman/v3/pkg/bindings"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/errorhandling"
@@ -19,7 +19,7 @@ func Remove(ctx context.Context, images []string, options *RemoveOptions) (*enti
// FIXME - bindings tests are missing for this endpoint. Once the CI is
// re-enabled for bindings, we need to add them. At the time of writing,
// the tests don't compile.
- var report handlers.LibpodImagesRemoveReport
+ var report types.LibpodImagesRemoveReport
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, []error{err}
diff --git a/pkg/bindings/images/types.go b/pkg/bindings/images/types.go
index 7bf70c82b..1f3e46729 100644
--- a/pkg/bindings/images/types.go
+++ b/pkg/bindings/images/types.go
@@ -1,7 +1,7 @@
package images
import (
- "github.com/containers/buildah/imagebuildah"
+ buildahDefine "github.com/containers/buildah/define"
)
//go:generate go run ../generator/generator.go RemoveOptions
@@ -162,7 +162,7 @@ type PullOptions struct {
//BuildOptions are optional options for building images
type BuildOptions struct {
- imagebuildah.BuildOptions
+ buildahDefine.BuildOptions
}
//go:generate go run ../generator/generator.go ExistsOptions
diff --git a/pkg/bindings/test/containers_test.go b/pkg/bindings/test/containers_test.go
index b0ddc7862..4f049d18b 100644
--- a/pkg/bindings/test/containers_test.go
+++ b/pkg/bindings/test/containers_test.go
@@ -550,26 +550,24 @@ var _ = Describe("Podman containers ", func() {
filtersIncorrect := map[string][]string{
"status": {"dummy"},
}
- pruneResponse, err := containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect))
+ _, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect))
Expect(err).ToNot(BeNil())
- // Mismatched filter params no container should be pruned.
+ // List filter params should not work with prune.
filtersIncorrect = map[string][]string{
- "name": {"r"},
+ "name": {"top"},
}
- pruneResponse, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect))
- Expect(err).To(BeNil())
- Expect(len(reports.PruneReportsIds(pruneResponse))).To(Equal(0))
- Expect(len(reports.PruneReportsErrs(pruneResponse))).To(Equal(0))
+ _, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect))
+ Expect(err).ToNot(BeNil())
- // Valid filter params container should be pruned now.
- filters := map[string][]string{
- "name": {"top"},
+ // Mismatched filter params no container should be pruned.
+ filtersIncorrect = map[string][]string{
+ "label": {"xyz"},
}
- pruneResponse, err = containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filters))
+ pruneResponse, err := containers.Prune(bt.conn, new(containers.PruneOptions).WithFilters(filtersIncorrect))
Expect(err).To(BeNil())
+ Expect(len(reports.PruneReportsIds(pruneResponse))).To(Equal(0))
Expect(len(reports.PruneReportsErrs(pruneResponse))).To(Equal(0))
- Expect(len(reports.PruneReportsIds(pruneResponse))).To(Equal(1))
})
It("podman prune running containers", func() {