osbuild: fix tree input schema

The references field in org.osbuild.tree inputs currently supports one
of three forms, all of which are functionally equivalent:
- Array of one string
- Array of one object with key "id" and string value
- Single object with no properties (only key/name)

We use the first form which is the simplest.

The string should refer to a pipeline by name (as name:<pipelinename>),
which means the input refer to the final tree of the named pipeline.
This commit is contained in:
Achilleas Koutsou 2022-09-20 16:24:12 +02:00 committed by Christian Kellner
parent f0b212e18a
commit 58966e4b13

View file

@ -3,13 +3,18 @@ package osbuild
// Tree inputs
type TreeInput struct {
inputCommon
References []string `json:"references"`
}
func (TreeInput) isInput() {}
func NewTreeInput() *TreeInput {
// NewTreeInput creates an org.osbuild.tree input for an osbuild stage.
// The input is the final tree from a pipeline that should be referenced as
// 'name:<pipelinename>' in the reference argument.
func NewTreeInput(reference string) *TreeInput {
input := new(TreeInput)
input.Type = "org.osbuild.tree"
input.Origin = "org.osbuild.pipeline"
input.References = []string{reference}
return input
}