1
0
mirror of https://github.com/containers/buildah.git synced 2025-07-31 15:24:26 +03:00

Add Quiet to PullOptions and PushOptions

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Add Quiet to the PullOptions and PushOptions structures.
If set to true output will be in 'quiet' mode.  This
will primarily be used by callers such as OpenShift.

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1302
Approved by: rhatdan
This commit is contained in:
TomSweeneyRedHat
2019-01-23 13:33:09 -05:00
committed by Atomic Bot
parent 4bcddb7cbe
commit f1cec509e0
2 changed files with 14 additions and 0 deletions

View File

@ -101,6 +101,10 @@ type PushOptions struct {
// regenerate from on-disk layers, substituting them in the list of // regenerate from on-disk layers, substituting them in the list of
// blobs to copy whenever possible. // blobs to copy whenever possible.
BlobDirectory string BlobDirectory string
// Quiet is a boolean value that determines if minimal output to
// the user will be displayed, this is best used for logging.
// The default is false.
Quiet bool
} }
// Commit writes the contents of the container, along with its updated // Commit writes the contents of the container, along with its updated
@ -228,6 +232,9 @@ func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options
func Push(ctx context.Context, image string, dest types.ImageReference, options PushOptions) (reference.Canonical, digest.Digest, error) { func Push(ctx context.Context, image string, dest types.ImageReference, options PushOptions) (reference.Canonical, digest.Digest, error) {
systemContext := getSystemContext(options.SystemContext, options.SignaturePolicyPath) systemContext := getSystemContext(options.SystemContext, options.SignaturePolicyPath)
if options.Quiet {
options.ReportWriter = nil // Turns off logging output
}
blocked, err := isReferenceBlocked(dest, systemContext) blocked, err := isReferenceBlocked(dest, systemContext)
if err != nil { if err != nil {
return nil, "", errors.Wrapf(err, "error checking if pushing to registry for %q is blocked", transports.ImageName(dest)) return nil, "", errors.Wrapf(err, "error checking if pushing to registry for %q is blocked", transports.ImageName(dest))

View File

@ -51,6 +51,10 @@ type PullOptions struct {
// AllTags is a boolean value that determines if all tagged images // AllTags is a boolean value that determines if all tagged images
// will be downloaded from the repository. The default is false. // will be downloaded from the repository. The default is false.
AllTags bool AllTags bool
// Quiet is a boolean value that determines if minimal output to
// the user will be displayed, this is best used for logging.
// The default is false.
Quiet bool
} }
func localImageNameForReference(ctx context.Context, store storage.Store, srcRef types.ImageReference, spec string) (string, error) { func localImageNameForReference(ctx context.Context, store storage.Store, srcRef types.ImageReference, spec string) (string, error) {
@ -167,6 +171,9 @@ func Pull(ctx context.Context, imageName string, options PullOptions) error {
} }
srcRef = srcRef2 srcRef = srcRef2
} }
if options.Quiet {
options.ReportWriter = nil // Turns off logging output
}
var names []string var names []string
if options.AllTags { if options.AllTags {
if srcRef.DockerReference() == nil { if srcRef.DockerReference() == nil {