Add the rhsm.facts stage.
We initially provide a Facts file that stores the `ApiType`. This is the API that was used to request the compose.
This commit is contained in:
parent
dba76a1204
commit
c5f335bceb
9 changed files with 111 additions and 16 deletions
24
Schutzfile
24
Schutzfile
|
|
@ -2,7 +2,7 @@
|
||||||
"fedora-35": {
|
"fedora-35": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"osbuild": {
|
"osbuild": {
|
||||||
"commit": "376cbffd136bc4ba86fc7c63697fa5b88fe3acef"
|
"commit": "ba218f781d4c7455cd995eea55be09e902370905"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repos": [
|
"repos": [
|
||||||
|
|
@ -79,7 +79,7 @@
|
||||||
"fedora-36": {
|
"fedora-36": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"osbuild": {
|
"osbuild": {
|
||||||
"commit": "376cbffd136bc4ba86fc7c63697fa5b88fe3acef"
|
"commit": "ba218f781d4c7455cd995eea55be09e902370905"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repos": [
|
"repos": [
|
||||||
|
|
@ -156,21 +156,21 @@
|
||||||
"rhel-8.4": {
|
"rhel-8.4": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"osbuild": {
|
"osbuild": {
|
||||||
"commit": "376cbffd136bc4ba86fc7c63697fa5b88fe3acef"
|
"commit": "ba218f781d4c7455cd995eea55be09e902370905"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rhel-8.6": {
|
"rhel-8.6": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"osbuild": {
|
"osbuild": {
|
||||||
"commit": "376cbffd136bc4ba86fc7c63697fa5b88fe3acef"
|
"commit": "ba218f781d4c7455cd995eea55be09e902370905"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rhel-8.7": {
|
"rhel-8.7": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"osbuild": {
|
"osbuild": {
|
||||||
"commit": "376cbffd136bc4ba86fc7c63697fa5b88fe3acef"
|
"commit": "ba218f781d4c7455cd995eea55be09e902370905"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repos": [
|
"repos": [
|
||||||
|
|
@ -216,14 +216,14 @@
|
||||||
"rhel-9.0": {
|
"rhel-9.0": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"osbuild": {
|
"osbuild": {
|
||||||
"commit": "376cbffd136bc4ba86fc7c63697fa5b88fe3acef"
|
"commit": "ba218f781d4c7455cd995eea55be09e902370905"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rhel-9.1": {
|
"rhel-9.1": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"osbuild": {
|
"osbuild": {
|
||||||
"commit": "376cbffd136bc4ba86fc7c63697fa5b88fe3acef"
|
"commit": "ba218f781d4c7455cd995eea55be09e902370905"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repos": [
|
"repos": [
|
||||||
|
|
@ -269,21 +269,21 @@
|
||||||
"centos-8": {
|
"centos-8": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"osbuild": {
|
"osbuild": {
|
||||||
"commit": "376cbffd136bc4ba86fc7c63697fa5b88fe3acef"
|
"commit": "ba218f781d4c7455cd995eea55be09e902370905"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"centos-9": {
|
"centos-9": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"osbuild": {
|
"osbuild": {
|
||||||
"commit": "376cbffd136bc4ba86fc7c63697fa5b88fe3acef"
|
"commit": "ba218f781d4c7455cd995eea55be09e902370905"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"centos-stream-9": {
|
"centos-stream-9": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"osbuild": {
|
"osbuild": {
|
||||||
"commit": "376cbffd136bc4ba86fc7c63697fa5b88fe3acef"
|
"commit": "ba218f781d4c7455cd995eea55be09e902370905"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repos": [
|
"repos": [
|
||||||
|
|
@ -329,7 +329,7 @@
|
||||||
"centos-stream-8": {
|
"centos-stream-8": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"osbuild": {
|
"osbuild": {
|
||||||
"commit": "376cbffd136bc4ba86fc7c63697fa5b88fe3acef"
|
"commit": "ba218f781d4c7455cd995eea55be09e902370905"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repos": [
|
"repos": [
|
||||||
|
|
@ -386,4 +386,4 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,10 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
imageOptions := distro.ImageOptions{Size: imageType.Size(0)}
|
imageOptions := distro.ImageOptions{Size: imageType.Size(0)}
|
||||||
|
imageOptions.Facts = &distro.FactsImageOptions{
|
||||||
|
ApiType: "cloudapi-v2",
|
||||||
|
}
|
||||||
|
|
||||||
if request.Customizations != nil && request.Customizations.Subscription != nil {
|
if request.Customizations != nil && request.Customizations.Subscription != nil {
|
||||||
imageOptions.Subscription = &distro.SubscriptionImageOptions{
|
imageOptions.Subscription = &distro.SubscriptionImageOptions{
|
||||||
Organization: request.Customizations.Subscription.Organization,
|
Organization: request.Customizations.Subscription.Organization,
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@ type ImageOptions struct {
|
||||||
OSTree ostree.RequestParams
|
OSTree ostree.RequestParams
|
||||||
Size uint64
|
Size uint64
|
||||||
Subscription *SubscriptionImageOptions
|
Subscription *SubscriptionImageOptions
|
||||||
|
Facts *FactsImageOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
// The SubscriptionImageOptions specify subscription-specific image options
|
// The SubscriptionImageOptions specify subscription-specific image options
|
||||||
|
|
@ -142,6 +143,12 @@ type SubscriptionImageOptions struct {
|
||||||
Insights bool
|
Insights bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The FactsImageOptions specify things to be stored into the Insights facts
|
||||||
|
// storage. This mostly relates to how the build of the image was performed.
|
||||||
|
type FactsImageOptions struct {
|
||||||
|
ApiType string
|
||||||
|
}
|
||||||
|
|
||||||
type BasePartitionTableMap map[string]disk.PartitionTable
|
type BasePartitionTableMap map[string]disk.PartitionTable
|
||||||
|
|
||||||
// A Manifest is an opaque JSON object, which is a valid input to osbuild
|
// A Manifest is an opaque JSON object, which is a valid input to osbuild
|
||||||
|
|
|
||||||
|
|
@ -690,6 +690,14 @@ func osPipeline(t *imageType,
|
||||||
p.AddStage(osbuild.NewSELinuxStage(selinuxStageOptions(false)))
|
p.AddStage(osbuild.NewSELinuxStage(selinuxStageOptions(false)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.Facts != nil {
|
||||||
|
p.AddStage(osbuild.NewRHSMFactsStage(&osbuild.RHSMFactsStageOptions{
|
||||||
|
Facts: osbuild.RHSMFacts{
|
||||||
|
ApiType: options.Facts.ApiType,
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
if t.rpmOstree {
|
if t.rpmOstree {
|
||||||
p.AddStage(osbuild.NewOSTreePrepTreeStage(&osbuild.OSTreePrepTreeStageOptions{
|
p.AddStage(osbuild.NewOSTreePrepTreeStage(&osbuild.OSTreePrepTreeStageOptions{
|
||||||
EtcGroupMembers: []string{
|
EtcGroupMembers: []string{
|
||||||
|
|
|
||||||
|
|
@ -688,6 +688,14 @@ func osPipeline(t *imageType,
|
||||||
p.AddStage(osbuild.NewSELinuxStage(selinuxStageOptions(false)))
|
p.AddStage(osbuild.NewSELinuxStage(selinuxStageOptions(false)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.Facts != nil {
|
||||||
|
p.AddStage(osbuild.NewRHSMFactsStage(&osbuild.RHSMFactsStageOptions{
|
||||||
|
Facts: osbuild.RHSMFacts{
|
||||||
|
ApiType: options.Facts.ApiType,
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
if t.rpmOstree {
|
if t.rpmOstree {
|
||||||
p.AddStage(osbuild.NewOSTreePrepTreeStage(&osbuild.OSTreePrepTreeStageOptions{
|
p.AddStage(osbuild.NewOSTreePrepTreeStage(&osbuild.OSTreePrepTreeStageOptions{
|
||||||
EtcGroupMembers: []string{
|
EtcGroupMembers: []string{
|
||||||
|
|
|
||||||
19
internal/osbuild/rhsm_facts_stage.go
Normal file
19
internal/osbuild/rhsm_facts_stage.go
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
package osbuild
|
||||||
|
|
||||||
|
type RHSMFactsStageOptions struct {
|
||||||
|
Facts RHSMFacts `json:"facts"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type RHSMFacts struct {
|
||||||
|
ApiType string `json:"image-builder.osbuild-composer.api-type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (RHSMFactsStageOptions) isStageOptions() {}
|
||||||
|
|
||||||
|
// NewRHSMFactsStage creates a new RHSM stage
|
||||||
|
func NewRHSMFactsStage(options *RHSMFactsStageOptions) *Stage {
|
||||||
|
return &Stage{
|
||||||
|
Type: "org.osbuild.rhsm.facts",
|
||||||
|
Options: options,
|
||||||
|
}
|
||||||
|
}
|
||||||
46
internal/osbuild/rhsm_facts_stage_test.go
Normal file
46
internal/osbuild/rhsm_facts_stage_test.go
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
package osbuild
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNewRHSMFactsStage(t *testing.T) {
|
||||||
|
expectedStage := &Stage{
|
||||||
|
Type: "org.osbuild.rhsm.facts",
|
||||||
|
Options: &RHSMFactsStageOptions{},
|
||||||
|
}
|
||||||
|
actualStage := NewRHSMFactsStage(&RHSMFactsStageOptions{})
|
||||||
|
assert.Equal(t, expectedStage, actualStage)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRHSMFactsStageJson(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
Options RHSMFactsStageOptions
|
||||||
|
JsonString string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
Options: RHSMFactsStageOptions{
|
||||||
|
Facts: RHSMFacts{
|
||||||
|
ApiType: "test-api",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
JsonString: fmt.Sprintf(`{"facts":{"image-builder.osbuild-composer.api-type":"%s"}}`, "test-api"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range tests {
|
||||||
|
marshaledJson, err := json.Marshal(test.Options)
|
||||||
|
require.NoError(t, err, "failed to marshal JSON")
|
||||||
|
require.Equal(t, test.JsonString, string(marshaledJson))
|
||||||
|
|
||||||
|
var jsonOptions RHSMFactsStageOptions
|
||||||
|
err = json.Unmarshal([]byte(test.JsonString), &jsonOptions)
|
||||||
|
require.NoError(t, err, "failed to parse JSON")
|
||||||
|
require.True(t, reflect.DeepEqual(test.Options, jsonOptions))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2351,6 +2351,9 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
||||||
URL: cr.OSTree.URL,
|
URL: cr.OSTree.URL,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
options.Facts = &distro.FactsImageOptions{
|
||||||
|
ApiType: "weldr",
|
||||||
|
}
|
||||||
|
|
||||||
packageSets, err := api.depsolveBlueprintForImageType(*bp, options, imageType)
|
packageSets, err := api.depsolveBlueprintForImageType(*bp, options, imageType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -309,10 +309,10 @@ The core osbuild-composer binary. This is suitable both for spawning in containe
|
||||||
Summary: The worker for osbuild-composer
|
Summary: The worker for osbuild-composer
|
||||||
Requires: systemd
|
Requires: systemd
|
||||||
Requires: qemu-img
|
Requires: qemu-img
|
||||||
Requires: osbuild >= 62
|
Requires: osbuild >= 63
|
||||||
Requires: osbuild-ostree >= 62
|
Requires: osbuild-ostree >= 63
|
||||||
Requires: osbuild-lvm2 >= 62
|
Requires: osbuild-lvm2 >= 63
|
||||||
Requires: osbuild-luks2 >= 62
|
Requires: osbuild-luks2 >= 63
|
||||||
Requires: %{name}-dnf-json = %{version}-%{release}
|
Requires: %{name}-dnf-json = %{version}-%{release}
|
||||||
|
|
||||||
%description worker
|
%description worker
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue