mirror of
https://github.com/containers/buildah.git
synced 2025-07-30 04:23:09 +03:00
Add support for buildah bud --label
We want to be able to add labels when building a container image. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #698 Approved by: umohnani8
This commit is contained in:
committed by
Atomic Bot
parent
2749191a5f
commit
02cc30ba17
12
commit.go
12
commit.go
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
cp "github.com/containers/image/copy"
|
||||
@ -49,6 +50,8 @@ type CommitOptions struct {
|
||||
SystemContext *types.SystemContext
|
||||
// IIDFile tells the builder to write the image ID to the specified file
|
||||
IIDFile string
|
||||
// Labels metadata for an image
|
||||
Labels []string
|
||||
}
|
||||
|
||||
// PushOptions can be used to alter how an image is copied somewhere.
|
||||
@ -83,6 +86,15 @@ type PushOptions struct {
|
||||
func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options CommitOptions) (string, error) {
|
||||
var imgID string
|
||||
|
||||
for _, labelSpec := range options.Labels {
|
||||
label := strings.SplitN(labelSpec, "=", 2)
|
||||
if len(label) > 1 {
|
||||
b.SetLabel(label[0], label[1])
|
||||
} else {
|
||||
b.SetLabel(label[0], "")
|
||||
}
|
||||
}
|
||||
|
||||
systemContext := getSystemContext(options.SystemContext, options.SignaturePolicyPath)
|
||||
policy, err := signature.DefaultPolicy(systemContext)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user