osbuild: add ostree.commit assembler
This adds the wrapper object and a simple test for the ostree.commit assembler. See the osbuild documentation for details. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
fd7320aaa1
commit
1c9cb20b77
3 changed files with 40 additions and 2 deletions
|
|
@ -32,12 +32,14 @@ func (assembler *Assembler) UnmarshalJSON(data []byte) error {
|
|||
}
|
||||
var options AssemblerOptions
|
||||
switch rawAssembler.Name {
|
||||
case "org.osbuild.tar":
|
||||
options = new(TarAssemblerOptions)
|
||||
case "org.osbuild.ostree.commit":
|
||||
options = new(OSTreeCommitAssemblerOptions)
|
||||
case "org.osbuild.qemu":
|
||||
options = new(QEMUAssemblerOptions)
|
||||
case "org.osbuild.rawfs":
|
||||
options = new(RawFSAssemblerOptions)
|
||||
case "org.osbuild.tar":
|
||||
options = new(TarAssemblerOptions)
|
||||
default:
|
||||
return errors.New("unexpected assembler name")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,19 @@ func TestAssembler_UnmarshalJSON(t *testing.T) {
|
|||
},
|
||||
data: []byte(`{"name":"org.osbuild.rawfs","options":{"filename":"filesystem.img","root_fs_uuid":"76a22bf4-f153-4541-b6c7-0332c0dfaeac","size":2147483648}}`),
|
||||
},
|
||||
{
|
||||
name: "ostree commit assembler",
|
||||
assembler: Assembler{
|
||||
Name: "org.osbuild.ostree.commit",
|
||||
Options: &OSTreeCommitAssemblerOptions{
|
||||
Ref: "foo",
|
||||
Tar: OSTreeCommitAssemblerTarOptions{
|
||||
Filename: "foo.tar",
|
||||
},
|
||||
},
|
||||
},
|
||||
data: []byte(`{"name":"org.osbuild.ostree.commit","options":{"ref":"foo","tar":{"filename":"foo.tar"}}}`),
|
||||
},
|
||||
}
|
||||
|
||||
assert := assert.New(t)
|
||||
|
|
|
|||
23
internal/osbuild/ostree_commit_assembler.go
Normal file
23
internal/osbuild/ostree_commit_assembler.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package osbuild
|
||||
|
||||
// OSTreeCommitAssemblerOptions desrcibe how to assemble a tree into an OSTree commit.
|
||||
type OSTreeCommitAssemblerOptions struct {
|
||||
Ref string `json:"ref"`
|
||||
Parent string `json:"parent,omitempty"`
|
||||
Tar OSTreeCommitAssemblerTarOptions `json:"tar"`
|
||||
}
|
||||
|
||||
// OSTreeCommitAssemblerTarOptions desrcibes the output tarball
|
||||
type OSTreeCommitAssemblerTarOptions struct {
|
||||
Filename string `json:"filename"`
|
||||
}
|
||||
|
||||
func (OSTreeCommitAssemblerOptions) isAssemblerOptions() {}
|
||||
|
||||
// NewOSTreeCommitAssembler creates a new OSTree Commit Assembler object.
|
||||
func NewOSTreeCommitAssembler(options *OSTreeCommitAssemblerOptions) *Assembler {
|
||||
return &Assembler{
|
||||
Name: "org.osbuild.ostree.commit",
|
||||
Options: options,
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue