1
0
mirror of https://github.com/containers/buildah.git synced 2025-07-30 04:23:09 +03:00

Add authentication to commit and push

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

Closes: #250
Approved by: rhatdan
This commit is contained in:
TomSweeneyRedHat
2017-08-24 17:44:32 -04:00
committed by Atomic Bot
parent f28dcb3751
commit c9c735e20d
9 changed files with 283 additions and 15 deletions

View File

@ -54,6 +54,9 @@ type CommitOptions struct {
// HistoryTimestamp is the timestamp used when creating new items in the
// image's history. If unset, the current time will be used.
HistoryTimestamp *time.Time
// github.com/containers/image/types SystemContext to hold credentials
// and other authentication/authorization information.
SystemContext *types.SystemContext
}
// PushOptions can be used to alter how an image is copied somewhere.
@ -73,6 +76,9 @@ type PushOptions struct {
ReportWriter io.Writer
// Store is the local storage store which holds the source image.
Store storage.Store
// github.com/containers/image/types SystemContext to hold credentials
// and other authentication/authorization information.
SystemContext *types.SystemContext
}
// shallowCopy copies the most recent layer, the configuration, and the manifest from one image to another.
@ -249,8 +255,7 @@ func (b *Builder) Commit(dest types.ImageReference, options CommitOptions) error
}
if exporting {
// Copy everything.
// TODO: add credsContext
err = cp.Image(policyContext, dest, src, getCopyOptions(options.ReportWriter, nil, nil))
err = cp.Image(policyContext, dest, src, getCopyOptions(options.ReportWriter, nil, options.SystemContext))
if err != nil {
return errors.Wrapf(err, "error copying layers and metadata")
}
@ -322,8 +327,7 @@ func Push(image string, dest types.ImageReference, options PushOptions) error {
return errors.Wrapf(err, "error recomputing layer digests and building metadata")
}
// Copy everything.
// TODO: add credsContext
err = cp.Image(policyContext, dest, src, getCopyOptions(options.ReportWriter, nil, nil))
err = cp.Image(policyContext, dest, src, getCopyOptions(options.ReportWriter, nil, options.SystemContext))
if err != nil {
return errors.Wrapf(err, "error copying layers and metadata")
}