osbuild2: new org.osbuild.ostree.passwd stage

Add support for the `org.osbuild.ostree.passwd` and with it also
support for the `org.osbuild.ostree.checkout` input.
This stage can be used to pre-load the user and groups database
from an existing commit to ensure that uids/gids are stable.
This commit is contained in:
Christian Kellner 2021-08-23 22:07:19 +00:00 committed by Tom Gundersen
parent 7059995268
commit f8c8f28ac8
3 changed files with 51 additions and 0 deletions

View file

@ -13,3 +13,30 @@ func NewOSTreeInput() *OSTreeInput {
input.Origin = "org.osbuild.source"
return input
}
// Inputs of type org.osbuild.ostree.checkout
type OSTreeCheckoutInput struct {
inputCommon
References OSTreeCheckoutReferences `json:"references"`
}
func (OSTreeCheckoutInput) isStageInput() {}
type OSTreeCheckoutReferences []string
func (OSTreeCheckoutReferences) isReferences() {}
// NewOSTreeCommitsInput creates a new OSTreeCommitsInputs
// where `origin` is either "org.osbuild.source" or "org.osbuild.pipeline
// `name` is the id of the commit, i.e. its digest or the pipeline name that
// produced it)
func NewOSTreeCheckoutInput(origin, name string) *OSTreeCheckoutInput {
input := new(OSTreeCheckoutInput)
input.Type = "org.osbuild.ostree.checkout"
input.Origin = origin
inputRefs := make([]string, 1)
inputRefs[0] = name
input.References = inputRefs
return input
}

View file

@ -0,0 +1,21 @@
package osbuild2
// The org.osbuild.ostree.passwd stage has no options so far.
type OSTreePasswdStageOptions struct {
}
func (s *OSTreePasswdStageOptions) isStageOptions() {}
type OSTreePasswdStageInputs struct {
Commits *OSTreeCheckoutInput `json:"commits"`
}
func (OSTreePasswdStageInputs) isStageInputs() {}
// A new org.osbuild.ostree.passwd stage to pre-fill the user and group databases
func NewOSTreePasswdStage(origin, name string) *Stage {
return &Stage{
Type: "org.osbuild.ostree.passwd",
Inputs: &OSTreePasswdStageInputs{Commits: NewOSTreeCheckoutInput(origin, name)},
}
}

View file

@ -100,6 +100,9 @@ func (stage *Stage) UnmarshalJSON(data []byte) error {
case "org.osbuild.ostree.commit":
options = new(OSTreeCommitStageOptions)
inputs = new(OSTreeCommitStageInputs)
case "org.osbuild.ostree.passwd":
options = new(OSTreePasswdStageOptions)
inputs = new(OSTreePasswdStageInputs)
case "org.osbuild.ostree.pull":
options = new(OSTreePullStageOptions)
inputs = new(OSTreePullStageInputs)