osbuild1: store all stage result metadata
Currently, metadata from osbuild is discarded for all stages except RPM. Adding explicit support for the ostree.commit stage/assembler and storing the metadata in a known type. For all other stages, store the metadata directly without parsing. The rawAssemblerResult is removed. Assembler results are treated as stage results.
This commit is contained in:
parent
df5921403d
commit
72f0f7ffed
3 changed files with 37 additions and 16 deletions
|
|
@ -21,3 +21,21 @@ func NewOSTreeCommitAssembler(options *OSTreeCommitAssemblerOptions) *Assembler
|
||||||
Options: options,
|
Options: options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OSTreeCommitStageMetadata struct {
|
||||||
|
Compose struct {
|
||||||
|
Ref string `json:"ref"`
|
||||||
|
OSTreeNMetadataTotal int `json:"ostree-n-metadata-total"`
|
||||||
|
OSTreeNMetadataWritten int `json:"ostree-n-metadata-written"`
|
||||||
|
OSTreeNContentTotal int `json:"ostree-n-content-total"`
|
||||||
|
OSTreeNContentWritten int `json:"ostree-n-content-written"`
|
||||||
|
OSTreeNCacheHits int `json:"ostree-n-cache-hits"`
|
||||||
|
OSTreeContentBytesWritten int `json:"ostree-content-bytes-written"`
|
||||||
|
OSTreeCommit string `json:"ostree-commit"`
|
||||||
|
OSTreeContentChecksum string `json:"ostree-content-checksum"`
|
||||||
|
OSTreeTimestamp string `json:"ostree-timestamp"`
|
||||||
|
RPMOSTreeInputHash string `json:"rpm-ostree-inputhash"`
|
||||||
|
} `json:"compose"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (OSTreeCommitStageMetadata) isStageMetadata() {}
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,6 @@ import (
|
||||||
"github.com/osbuild/osbuild-composer/internal/osbuild2"
|
"github.com/osbuild/osbuild-composer/internal/osbuild2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type rawAssemblerResult struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Options json.RawMessage `json:"options"`
|
|
||||||
Success bool `json:"success"`
|
|
||||||
Output string `json:"output"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type StageResult struct {
|
type StageResult struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Options json.RawMessage `json:"options"`
|
Options json.RawMessage `json:"options"`
|
||||||
|
|
@ -29,6 +22,10 @@ type StageMetadata interface {
|
||||||
isStageMetadata()
|
isStageMetadata()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RawStageMetadata json.RawMessage
|
||||||
|
|
||||||
|
func (RawStageMetadata) isStageMetadata() {}
|
||||||
|
|
||||||
type rawStageResult struct {
|
type rawStageResult struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Options json.RawMessage `json:"options"`
|
Options json.RawMessage `json:"options"`
|
||||||
|
|
@ -44,12 +41,12 @@ type buildResult struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Result struct {
|
type Result struct {
|
||||||
TreeID string `json:"tree_id"`
|
TreeID string `json:"tree_id"`
|
||||||
OutputID string `json:"output_id"`
|
OutputID string `json:"output_id"`
|
||||||
Build *buildResult `json:"build"`
|
Build *buildResult `json:"build"`
|
||||||
Stages []StageResult `json:"stages"`
|
Stages []StageResult `json:"stages"`
|
||||||
Assembler *rawAssemblerResult `json:"assembler"`
|
Assembler *StageResult `json:"assembler"`
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (result *StageResult) UnmarshalJSON(data []byte) error {
|
func (result *StageResult) UnmarshalJSON(data []byte) error {
|
||||||
|
|
@ -66,8 +63,14 @@ func (result *StageResult) UnmarshalJSON(data []byte) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
case "org.osbuild.ostree.commit":
|
||||||
|
metadata = new(OSTreeCommitStageMetadata)
|
||||||
|
err = json.Unmarshal(rawStageResult.Metadata, metadata)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
metadata = nil
|
metadata = RawStageMetadata(rawStageResult.Metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Name = rawStageResult.Name
|
result.Name = rawStageResult.Name
|
||||||
|
|
@ -196,7 +199,7 @@ func (cr *Result) fromV2(crv2 osbuild2.Result) {
|
||||||
cr.Success = crv2.Success
|
cr.Success = crv2.Success
|
||||||
// Empty build and assembler results for new types of jobs
|
// Empty build and assembler results for new types of jobs
|
||||||
cr.Build = new(buildResult)
|
cr.Build = new(buildResult)
|
||||||
cr.Assembler = new(rawAssemblerResult)
|
cr.Assembler = new(StageResult)
|
||||||
|
|
||||||
// crv2.Log contains a map of pipelines. Unfortunately, Go doesn't
|
// crv2.Log contains a map of pipelines. Unfortunately, Go doesn't
|
||||||
// preserve the order of keys in a map. See:
|
// preserve the order of keys in a map. See:
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ func TestWriteFull(t *testing.T) {
|
||||||
Success: true,
|
Success: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
testAssembler := rawAssemblerResult{
|
testAssembler := StageResult{
|
||||||
Name: "testAssembler",
|
Name: "testAssembler",
|
||||||
Options: []byte(testOptions),
|
Options: []byte(testOptions),
|
||||||
Success: true,
|
Success: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue