mirror of
https://github.com/containers/skopeo.git
synced 2026-02-03 07:48:30 +00:00
Pull most of the core logic from the CLI into a package that should be easier to consume as a library. Add a "config" command that updates the builder object's configuration. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
31 lines
749 B
Go
31 lines
749 B
Go
package buildah
|
|
|
|
import (
|
|
"github.com/containers/image/copy"
|
|
"github.com/containers/image/signature"
|
|
"github.com/containers/image/types"
|
|
"github.com/containers/storage/pkg/archive"
|
|
)
|
|
|
|
type CommitOptions struct {
|
|
Compression archive.Compression
|
|
SignaturePolicyPath string
|
|
}
|
|
|
|
func (b *Builder) Commit(dest types.ImageReference, options CommitOptions) error {
|
|
policy, err := signature.DefaultPolicy(getSystemContext(options.SignaturePolicyPath))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
policyContext, err := signature.NewPolicyContext(policy)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
src, err := b.makeContainerImageRef(options.Compression)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = copy.Image(policyContext, dest, src, getCopyOptions())
|
|
return err
|
|
}
|