mirror of
https://github.com/containers/podman.git
synced 2025-06-25 20:26:51 +08:00
Merge pull request #15230 from YoitoFes/Issue-15211
pkg/bindings: Support writing image push progress to specified io.Writer
This commit is contained in:
@ -62,6 +62,8 @@ func Push(ctx context.Context, source string, destination string, options *PushO
|
|||||||
writer := io.Writer(os.Stderr)
|
writer := io.Writer(os.Stderr)
|
||||||
if options.GetQuiet() {
|
if options.GetQuiet() {
|
||||||
writer = ioutil.Discard
|
writer = ioutil.Discard
|
||||||
|
} else if progressWriter := options.GetProgressWriter(); progressWriter != nil {
|
||||||
|
writer = progressWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
dec := json.NewDecoder(response.Body)
|
dec := json.NewDecoder(response.Body)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package images
|
package images
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
buildahDefine "github.com/containers/buildah/define"
|
buildahDefine "github.com/containers/buildah/define"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -131,6 +133,10 @@ type PushOptions struct {
|
|||||||
Format *string
|
Format *string
|
||||||
// Password for authenticating against the registry.
|
// Password for authenticating against the registry.
|
||||||
Password *string
|
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 to skip HTTPS and certificate verification.
|
||||||
SkipTLSVerify *bool
|
SkipTLSVerify *bool
|
||||||
// RemoveSignatures Discard any pre-existing signatures in the image.
|
// RemoveSignatures Discard any pre-existing signatures in the image.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
package images
|
package images
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/containers/podman/v4/pkg/bindings/internal/util"
|
"github.com/containers/podman/v4/pkg/bindings/internal/util"
|
||||||
@ -107,6 +108,21 @@ func (o *PushOptions) GetPassword() string {
|
|||||||
return *o.Password
|
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
|
// WithSkipTLSVerify set field SkipTLSVerify to given value
|
||||||
func (o *PushOptions) WithSkipTLSVerify(value bool) *PushOptions {
|
func (o *PushOptions) WithSkipTLSVerify(value bool) *PushOptions {
|
||||||
o.SkipTLSVerify = &value
|
o.SkipTLSVerify = &value
|
||||||
|
@ -379,6 +379,10 @@ var _ = Describe("Podman images", func() {
|
|||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("Image Push", func() {
|
||||||
|
Skip("TODO: implement test for image push to registry")
|
||||||
|
})
|
||||||
|
|
||||||
It("Build no options", func() {
|
It("Build no options", func() {
|
||||||
results, err := images.Build(bt.conn, []string{"fixture/Containerfile"}, entities.BuildOptions{})
|
results, err := images.Build(bt.conn, []string{"fixture/Containerfile"}, entities.BuildOptions{})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
@ -240,7 +240,7 @@ func (ir *ImageEngine) Import(ctx context.Context, opts entities.ImageImportOpti
|
|||||||
|
|
||||||
func (ir *ImageEngine) Push(ctx context.Context, source string, destination string, opts entities.ImagePushOptions) error {
|
func (ir *ImageEngine) Push(ctx context.Context, source string, destination string, opts entities.ImagePushOptions) error {
|
||||||
options := new(images.PushOptions)
|
options := new(images.PushOptions)
|
||||||
options.WithAll(opts.All).WithCompress(opts.Compress).WithUsername(opts.Username).WithPassword(opts.Password).WithAuthfile(opts.Authfile).WithFormat(opts.Format).WithRemoveSignatures(opts.RemoveSignatures).WithQuiet(opts.Quiet).WithCompressionFormat(opts.CompressionFormat)
|
options.WithAll(opts.All).WithCompress(opts.Compress).WithUsername(opts.Username).WithPassword(opts.Password).WithAuthfile(opts.Authfile).WithFormat(opts.Format).WithRemoveSignatures(opts.RemoveSignatures).WithQuiet(opts.Quiet).WithCompressionFormat(opts.CompressionFormat).WithProgressWriter(opts.Writer)
|
||||||
|
|
||||||
if s := opts.SkipTLSVerify; s != types.OptionalBoolUndefined {
|
if s := opts.SkipTLSVerify; s != types.OptionalBoolUndefined {
|
||||||
if s == types.OptionalBoolTrue {
|
if s == types.OptionalBoolTrue {
|
||||||
|
Reference in New Issue
Block a user