From 100044871faa0e1de2f62728c3d5b83e1ce41176 Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Mon, 25 Mar 2019 10:34:02 +0100 Subject: New upstream version 1.0.0+git20190319.cf3fc48 --- actions/ostree_commit_action.go | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'actions/ostree_commit_action.go') diff --git a/actions/ostree_commit_action.go b/actions/ostree_commit_action.go index a0d8333..85b3fda 100644 --- a/actions/ostree_commit_action.go +++ b/actions/ostree_commit_action.go @@ -8,6 +8,13 @@ Yaml syntax: repository: repository name branch: branch name subject: commit message + collection-id: org.apertis.example + ref-binding: + - branch1 + - branch2 + metadata: + key: value + vendor.key: somevalue Mandatory properties: @@ -22,10 +29,18 @@ type (https://ostree.readthedocs.io/en/latest/manual/repo/#repository-types-and- Optional properties: - subject -- one line message with commit description. + +- collection-id -- Collection ID ref binding (requires libostree 2018.6). + +- ref-binding -- enforce that the commit was retrieved from one of the branch names in this array. + If 'collection-id' is set and 'ref-binding' is empty, will default to the branch name. + +- metadata -- key-value pairs of meta information to be added into commit. */ package actions import ( + "fmt" "log" "os" "path" @@ -40,6 +55,9 @@ type OstreeCommitAction struct { Branch string Subject string Command string + CollectionID string `yaml:"collection-id"` + RefBinding []string `yaml:"ref-binding"` + Metadata map[string]string } func emptyDir(dir string) { @@ -54,7 +72,7 @@ func emptyDir(dir string) { for _, f := range files { err := os.RemoveAll(path.Join(dir, f)) if err != nil { - log.Fatalf("Failed to remove file: %v", err) + log.Fatalf("Failed to remove file: %v", err) } } } @@ -77,6 +95,22 @@ func (ot *OstreeCommitAction) Run(context *debos.DebosContext) error { opts := otbuiltin.NewCommitOptions() opts.Subject = ot.Subject + for k, v := range ot.Metadata { + str := fmt.Sprintf("%s=%s", k, v) + opts.AddMetadataString = append(opts.AddMetadataString, str) + } + + if ot.CollectionID != "" { + opts.CollectionID = ot.CollectionID + if len(ot.RefBinding) == 0 { + // Add current branch if not explitely set via 'ref-binding' + opts.RefBinding = append(opts.RefBinding, ot.Branch) + } + } + + // Add values from 'ref-binding' if any + opts.RefBinding = append(opts.RefBinding, ot.RefBinding...) + ret, err := repo.Commit(context.Rootdir, ot.Branch, opts) if err != nil { return err -- cgit v1.2.3