client: Add functions to support compose testing

Also adds new types to weldr/json.go to support them.
ComposeEntry had to be duplicated instead of used as-is because it
enforces image type strings that do not match what the API uses (the API
types are all lower case, the internal names are capitalized).
This commit is contained in:
Brian C. Lane 2020-04-09 13:58:48 -07:00 committed by Tom Gundersen
parent 7c86dc533c
commit f960985c17
3 changed files with 615 additions and 0 deletions

View file

@ -3,7 +3,10 @@
package weldr
import (
"github.com/google/uuid"
"github.com/osbuild/osbuild-composer/internal/blueprint"
"github.com/osbuild/osbuild-composer/internal/common"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/store"
)
@ -156,3 +159,75 @@ type ModulesListV0 struct {
type ModulesInfoV0 struct {
Modules []rpmmd.PackageInfo `json:"modules"`
}
type ComposeRequestV0 struct {
BlueprintName string `json:"blueprint_name"`
ComposeType string `json:"compose_type"`
Branch string `json:"branch"`
}
type ComposeResponseV0 struct {
BuildID uuid.UUID `json:"build_id"`
Status bool `json:"status"`
}
// This is similar to weldr.ComposeEntry but different because internally the image types are capitalized
type ComposeEntryV0 struct {
ID uuid.UUID `json:"id"`
Blueprint string `json:"blueprint"`
Version string `json:"version"`
ComposeType string `json:"compose_type"`
ImageSize uint64 `json:"image_size"` // This is user-provided image size, not actual file size
QueueStatus common.ImageBuildState `json:"queue_status"`
JobCreated float64 `json:"job_created"`
JobStarted float64 `json:"job_started,omitempty"`
JobFinished float64 `json:"job_finished,omitempty"`
Uploads []uploadResponse `json:"uploads,omitempty"`
}
type ComposeFinishedResponseV0 struct {
Finished []ComposeEntryV0 `json:"finished"`
}
type ComposeFailedResponseV0 struct {
Failed []ComposeEntryV0 `json:"failed"`
}
type ComposeStatusResponseV0 struct {
UUIDs []ComposeEntryV0 `json:"uuids"`
}
type ComposeTypeV0 struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
}
type ComposeTypesResponseV0 struct {
Types []ComposeTypeV0 `json:"types"`
}
type DeleteComposeStatusV0 struct {
UUID uuid.UUID `json:"uuid"`
Status bool `json:"status"`
}
type DeleteComposeResponseV0 struct {
UUIDs []DeleteComposeStatusV0 `json:"uuids"`
Errors []ResponseError `json:"errors"`
}
// NOTE: This does not include the lorax-composer specific 'config' field
type ComposeInfoResponseV0 struct {
ID uuid.UUID `json:"id"`
Blueprint *blueprint.Blueprint `json:"blueprint"` // blueprint not frozen!
Commit string `json:"commit"` // empty for now
Deps struct {
Packages []rpmmd.Package `json:"packages"`
} `json:"deps"`
ComposeType string `json:"compose_type"`
QueueStatus string `json:"queue_status"`
ImageSize uint64 `json:"image_size"`
Uploads []uploadResponse `json:"uploads,omitempty"`
}
type ComposeQueueResponseV0 struct {
New []ComposeEntryV0 `json:"new"`
Run []ComposeEntryV0 `json:"run"`
}