summaryrefslogtreecommitdiff
path: root/pkg/bindings/images
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-08-09 18:49:26 +0000
committerGitHub <noreply@github.com>2022-08-09 18:49:26 +0000
commita2869c327eca50badc04e6f898f562e0560127f5 (patch)
tree23fe50cf2c3f71aa8ff6fca8609e19bb9f63f792 /pkg/bindings/images
parentc33dc90ace724f920c14e41769ce237f5c5d14ec (diff)
parentb1d1248a18525598d8468d30a176fd2eaadcfd97 (diff)
downloadpodman-a2869c327eca50badc04e6f898f562e0560127f5.tar.gz
podman-a2869c327eca50badc04e6f898f562e0560127f5.tar.bz2
podman-a2869c327eca50badc04e6f898f562e0560127f5.zip
Merge pull request #15230 from YoitoFes/Issue-15211
pkg/bindings: Support writing image push progress to specified io.Writer
Diffstat (limited to 'pkg/bindings/images')
-rw-r--r--pkg/bindings/images/push.go2
-rw-r--r--pkg/bindings/images/types.go6
-rw-r--r--pkg/bindings/images/types_push_options.go16
3 files changed, 24 insertions, 0 deletions
diff --git a/pkg/bindings/images/push.go b/pkg/bindings/images/push.go
index 8db3726e6..5069dd780 100644
--- a/pkg/bindings/images/push.go
+++ b/pkg/bindings/images/push.go
@@ -62,6 +62,8 @@ func Push(ctx context.Context, source string, destination string, options *PushO
writer := io.Writer(os.Stderr)
if options.GetQuiet() {
writer = ioutil.Discard
+ } else if progressWriter := options.GetProgressWriter(); progressWriter != nil {
+ writer = progressWriter
}
dec := json.NewDecoder(response.Body)
diff --git a/pkg/bindings/images/types.go b/pkg/bindings/images/types.go
index 9783a8e18..7b28c499e 100644
--- a/pkg/bindings/images/types.go
+++ b/pkg/bindings/images/types.go
@@ -1,6 +1,8 @@
package images
import (
+ "io"
+
buildahDefine "github.com/containers/buildah/define"
)
@@ -131,6 +133,10 @@ type PushOptions struct {
Format *string
// Password for authenticating against the registry.
Password *string
+ // ProgressWriter is a writer where push progress are sent.
+ // Since API handler for image push is quiet by default, WithQuiet(false) is necessary for
+ // the writer to receive progress messages.
+ ProgressWriter *io.Writer
// SkipTLSVerify to skip HTTPS and certificate verification.
SkipTLSVerify *bool
// RemoveSignatures Discard any pre-existing signatures in the image.
diff --git a/pkg/bindings/images/types_push_options.go b/pkg/bindings/images/types_push_options.go
index 1ae031824..817d873f8 100644
--- a/pkg/bindings/images/types_push_options.go
+++ b/pkg/bindings/images/types_push_options.go
@@ -2,6 +2,7 @@
package images
import (
+ "io"
"net/url"
"github.com/containers/podman/v4/pkg/bindings/internal/util"
@@ -107,6 +108,21 @@ func (o *PushOptions) GetPassword() string {
return *o.Password
}
+// WithProgressWriter set field ProgressWriter to given value
+func (o *PushOptions) WithProgressWriter(value io.Writer) *PushOptions {
+ o.ProgressWriter = &value
+ return o
+}
+
+// GetProgressWriter returns value of field ProgressWriter
+func (o *PushOptions) GetProgressWriter() io.Writer {
+ if o.ProgressWriter == nil {
+ var z io.Writer
+ return z
+ }
+ return *o.ProgressWriter
+}
+
// WithSkipTLSVerify set field SkipTLSVerify to given value
func (o *PushOptions) WithSkipTLSVerify(value bool) *PushOptions {
o.SkipTLSVerify = &value