summaryrefslogtreecommitdiff
path: root/pkg/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/bindings')
-rw-r--r--pkg/bindings/connection.go4
-rw-r--r--pkg/bindings/containers/attach.go12
-rw-r--r--pkg/bindings/containers/containers.go2
-rw-r--r--pkg/bindings/images/images.go20
-rw-r--r--pkg/bindings/images/types.go7
-rw-r--r--pkg/bindings/images/types_remove_options.go15
-rw-r--r--pkg/bindings/images/types_scp_options.go12
-rw-r--r--pkg/bindings/manifests/manifests.go22
-rw-r--r--pkg/bindings/manifests/types.go22
-rw-r--r--pkg/bindings/manifests/types_modify_options.go8
-rw-r--r--pkg/bindings/test/manifests_test.go13
11 files changed, 111 insertions, 26 deletions
diff --git a/pkg/bindings/connection.go b/pkg/bindings/connection.go
index c21834e35..6b3576f31 100644
--- a/pkg/bindings/connection.go
+++ b/pkg/bindings/connection.go
@@ -95,7 +95,7 @@ func NewConnectionWithIdentity(ctx context.Context, uri string, identity string)
return nil, errors.Wrapf(err, "Value of CONTAINER_HOST is not a valid url: %s", uri)
}
- // Now we setup the http Client to use the connection above
+ // Now we set up the http Client to use the connection above
var connection Connection
switch _url.Scheme {
case "ssh":
@@ -164,7 +164,7 @@ func pingNewConnection(ctx context.Context) (*semver.Version, error) {
if response.StatusCode == http.StatusOK {
versionHdr := response.Header.Get("Libpod-API-Version")
if versionHdr == "" {
- logrus.Info("Service did not provide Libpod-API-Version Header")
+ logrus.Warn("Service did not provide Libpod-API-Version Header")
return new(semver.Version), nil
}
versionSrv, err := semver.ParseTolerant(versionHdr)
diff --git a/pkg/bindings/containers/attach.go b/pkg/bindings/containers/attach.go
index d84b47052..2bfccdd3b 100644
--- a/pkg/bindings/containers/attach.go
+++ b/pkg/bindings/containers/attach.go
@@ -14,9 +14,9 @@ import (
"strconv"
"time"
+ "github.com/containers/common/pkg/util"
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/bindings"
- "github.com/containers/podman/v4/utils"
"github.com/moby/term"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -54,8 +54,6 @@ func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Wri
stderr = (io.Writer)(nil)
}
- logrus.Infof("Going to attach to container %q", nameOrID)
-
conn, err := bindings.GetClient(ctx)
if err != nil {
return err
@@ -161,7 +159,7 @@ func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Wri
go func() {
logrus.Debugf("Copying STDIN to socket")
- _, err := utils.CopyDetachable(socket, stdin, detachKeysInBytes)
+ _, err := util.CopyDetachable(socket, stdin, detachKeysInBytes)
if err != nil && err != define.ErrDetach {
logrus.Errorf("Failed to write input to service: %v", err)
}
@@ -357,7 +355,7 @@ func attachHandleResize(ctx, winCtx context.Context, winChange chan os.Signal, i
resizeErr = ResizeContainerTTY(ctx, id, new(ResizeTTYOptions).WithHeight(h).WithWidth(w))
}
if resizeErr != nil {
- logrus.Infof("Failed to resize TTY: %v", resizeErr)
+ logrus.Debugf("Failed to resize TTY: %v", resizeErr)
}
}
@@ -499,7 +497,7 @@ func ExecStartAndAttach(ctx context.Context, sessionID string, options *ExecStar
if options.GetAttachInput() {
go func() {
logrus.Debugf("Copying STDIN to socket")
- _, err := utils.CopyDetachable(socket, options.InputStream, []byte{})
+ _, err := util.CopyDetachable(socket, options.InputStream, []byte{})
if err != nil {
logrus.Errorf("Failed to write input to service: %v", err)
}
@@ -520,7 +518,7 @@ func ExecStartAndAttach(ctx context.Context, sessionID string, options *ExecStar
return fmt.Errorf("exec session %s has a terminal and must have STDOUT enabled", sessionID)
}
// If not multiplex'ed, read from server and write to stdout
- _, err := utils.CopyDetachable(options.GetOutputStream(), socket, []byte{})
+ _, err := util.CopyDetachable(options.GetOutputStream(), socket, []byte{})
if err != nil {
return err
}
diff --git a/pkg/bindings/containers/containers.go b/pkg/bindings/containers/containers.go
index 2d3422411..ea01bc7d9 100644
--- a/pkg/bindings/containers/containers.go
+++ b/pkg/bindings/containers/containers.go
@@ -13,7 +13,6 @@ import (
"github.com/containers/podman/v4/pkg/domain/entities"
"github.com/containers/podman/v4/pkg/domain/entities/reports"
"github.com/pkg/errors"
- "github.com/sirupsen/logrus"
)
var (
@@ -201,7 +200,6 @@ func Start(ctx context.Context, nameOrID string, options *StartOptions) error {
if options == nil {
options = new(StartOptions)
}
- logrus.Infof("Going to start container %q", nameOrID)
conn, err := bindings.GetClient(ctx)
if err != nil {
return err
diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go
index 32372019b..57c8bd597 100644
--- a/pkg/bindings/images/images.go
+++ b/pkg/bindings/images/images.go
@@ -346,3 +346,23 @@ func Search(ctx context.Context, term string, options *SearchOptions) ([]entitie
return results, nil
}
+
+func Scp(ctx context.Context, source, destination *string, options ScpOptions) (reports.ScpReport, error) {
+ rep := reports.ScpReport{}
+
+ conn, err := bindings.GetClient(ctx)
+ if err != nil {
+ return rep, err
+ }
+ params, err := options.ToParams()
+ if err != nil {
+ return rep, err
+ }
+ response, err := conn.DoRequest(ctx, nil, http.MethodPost, fmt.Sprintf("/images/scp/%s", *source), params, nil)
+ if err != nil {
+ return rep, err
+ }
+ defer response.Body.Close()
+
+ return rep, response.Process(&rep)
+}
diff --git a/pkg/bindings/images/types.go b/pkg/bindings/images/types.go
index 16dbad380..3728ae5c0 100644
--- a/pkg/bindings/images/types.go
+++ b/pkg/bindings/images/types.go
@@ -13,6 +13,8 @@ type RemoveOptions struct {
Force *bool
// Ignore if a specified image does not exist and do not throw an error.
Ignore *bool
+ // Confirms if given name is a manifest list and removes it, otherwise returns error.
+ LookupManifest *bool
}
//go:generate go run ../generator/generator.go DiffOptions
@@ -188,3 +190,8 @@ type BuildOptions struct {
// ExistsOptions are optional options for checking if an image exists
type ExistsOptions struct {
}
+
+type ScpOptions struct {
+ Quiet *bool
+ Destination *string
+}
diff --git a/pkg/bindings/images/types_remove_options.go b/pkg/bindings/images/types_remove_options.go
index 613a33183..559ebcfd5 100644
--- a/pkg/bindings/images/types_remove_options.go
+++ b/pkg/bindings/images/types_remove_options.go
@@ -61,3 +61,18 @@ func (o *RemoveOptions) GetIgnore() bool {
}
return *o.Ignore
}
+
+// WithLookupManifest set field LookupManifest to given value
+func (o *RemoveOptions) WithLookupManifest(value bool) *RemoveOptions {
+ o.LookupManifest = &value
+ return o
+}
+
+// GetLookupManifest returns value of field LookupManifest
+func (o *RemoveOptions) GetLookupManifest() bool {
+ if o.LookupManifest == nil {
+ var z bool
+ return z
+ }
+ return *o.LookupManifest
+}
diff --git a/pkg/bindings/images/types_scp_options.go b/pkg/bindings/images/types_scp_options.go
new file mode 100644
index 000000000..5a1178cb1
--- /dev/null
+++ b/pkg/bindings/images/types_scp_options.go
@@ -0,0 +1,12 @@
+package images
+
+import (
+ "net/url"
+
+ "github.com/containers/podman/v4/pkg/bindings/internal/util"
+)
+
+// ToParams formats struct fields to be passed to API service
+func (o *ScpOptions) ToParams() (url.Values, error) {
+ return util.ToParams(o)
+}
diff --git a/pkg/bindings/manifests/manifests.go b/pkg/bindings/manifests/manifests.go
index feff5d6e8..a68dd5a4e 100644
--- a/pkg/bindings/manifests/manifests.go
+++ b/pkg/bindings/manifests/manifests.go
@@ -117,6 +117,26 @@ func Remove(ctx context.Context, name, digest string, _ *RemoveOptions) (string,
return Modify(ctx, name, []string{digest}, optionsv4)
}
+// Delete removes specified manifest from local storage.
+func Delete(ctx context.Context, name string) (*entities.ManifestRemoveReport, error) {
+ var report entities.ManifestRemoveReport
+ conn, err := bindings.GetClient(ctx)
+ if err != nil {
+ return nil, err
+ }
+ response, err := conn.DoRequest(ctx, nil, http.MethodDelete, "/manifests/%s", nil, nil, name)
+ if err != nil {
+ return nil, err
+ }
+ defer response.Body.Close()
+
+ if err := response.Process(&report); err != nil {
+ return nil, err
+ }
+
+ return &report, errorhandling.JoinErrors(errorhandling.StringsToErrors(report.Errors))
+}
+
// Push takes a manifest list and pushes to a destination. If the destination is not specified,
// the name will be used instead. If the optional all boolean is specified, all images specified
// in the list will be pushed as well.
@@ -211,7 +231,7 @@ func Modify(ctx context.Context, name string, images []string, options *ModifyOp
err = errorhandling.JoinErrors(report.Errors)
if err != nil {
errModel := errorhandling.ErrorModel{
- Because: (errors.Cause(err)).Error(),
+ Because: errorhandling.Cause(err).Error(),
Message: err.Error(),
ResponseCode: response.StatusCode,
}
diff --git a/pkg/bindings/manifests/types.go b/pkg/bindings/manifests/types.go
index d0b0b2e71..e23ef798d 100644
--- a/pkg/bindings/manifests/types.go
+++ b/pkg/bindings/manifests/types.go
@@ -44,16 +44,18 @@ type RemoveOptions struct {
type ModifyOptions struct {
// Operation values are "update", "remove" and "annotate". This allows the service to
// efficiently perform each update on a manifest list.
- Operation *string
- All *bool // All when true, operate on all images in a manifest list that may be included in Images
- Annotations map[string]string // Annotations to add to manifest list
- Arch *string // Arch overrides the architecture for the image
- Features []string // Feature list for the image
- Images []string // Images is an optional list of images to add/remove to/from manifest list depending on operation
- OS *string // OS overrides the operating system for the image
- OSFeatures []string // OS features for the image
- OSVersion *string // OSVersion overrides the operating system for the image
- Variant *string // Variant overrides the operating system variant for the image
+ Operation *string
+ All *bool // All when true, operate on all images in a manifest list that may be included in Images
+ Annotations map[string]string // Annotations to add to manifest list
+ Arch *string // Arch overrides the architecture for the image
+ Features []string // Feature list for the image
+ Images []string // Images is an optional list of images to add/remove to/from manifest list depending on operation
+ OS *string // OS overrides the operating system for the image
+ // OS features for the image
+ OSFeatures []string `json:"os_features" schema:"os_features"`
+ // OSVersion overrides the operating system for the image
+ OSVersion *string `json:"os_version" schema:"os_version"`
+ Variant *string // Variant overrides the operating system variant for the image
Authfile *string
Password *string
Username *string
diff --git a/pkg/bindings/manifests/types_modify_options.go b/pkg/bindings/manifests/types_modify_options.go
index 9d2ed2613..ab00cb2c5 100644
--- a/pkg/bindings/manifests/types_modify_options.go
+++ b/pkg/bindings/manifests/types_modify_options.go
@@ -122,13 +122,13 @@ func (o *ModifyOptions) GetOS() string {
return *o.OS
}
-// WithOSFeatures set oS features for the image
+// WithOSFeatures set field OSFeatures to given value
func (o *ModifyOptions) WithOSFeatures(value []string) *ModifyOptions {
o.OSFeatures = value
return o
}
-// GetOSFeatures returns value of oS features for the image
+// GetOSFeatures returns value of field OSFeatures
func (o *ModifyOptions) GetOSFeatures() []string {
if o.OSFeatures == nil {
var z []string
@@ -137,13 +137,13 @@ func (o *ModifyOptions) GetOSFeatures() []string {
return o.OSFeatures
}
-// WithOSVersion set oSVersion overrides the operating system for the image
+// WithOSVersion set field OSVersion to given value
func (o *ModifyOptions) WithOSVersion(value string) *ModifyOptions {
o.OSVersion = &value
return o
}
-// GetOSVersion returns value of oSVersion overrides the operating system for the image
+// GetOSVersion returns value of field OSVersion
func (o *ModifyOptions) GetOSVersion() string {
if o.OSVersion == nil {
var z string
diff --git a/pkg/bindings/test/manifests_test.go b/pkg/bindings/test/manifests_test.go
index e6c93817d..6a34ef5a6 100644
--- a/pkg/bindings/test/manifests_test.go
+++ b/pkg/bindings/test/manifests_test.go
@@ -62,6 +62,19 @@ var _ = Describe("podman manifest", func() {
Expect(len(list.Manifests)).To(BeNumerically("==", 1))
})
+ It("delete manifest", func() {
+ id, err := manifests.Create(bt.conn, "quay.io/libpod/foobar:latest", []string{}, nil)
+ Expect(err).ToNot(HaveOccurred(), err)
+ list, err := manifests.Inspect(bt.conn, id, nil)
+ Expect(err).ToNot(HaveOccurred())
+
+ Expect(len(list.Manifests)).To(BeZero())
+
+ removeReport, err := manifests.Delete(bt.conn, "quay.io/libpod/foobar:latest")
+ Expect(err).ToNot(HaveOccurred())
+ Expect(len(removeReport.Deleted)).To(BeNumerically("==", 1))
+ })
+
It("inspect", func() {
_, err := manifests.Inspect(bt.conn, "larry", nil)
Expect(err).To(HaveOccurred())