osbuild: add support for the first-boot stage
This commit is contained in:
parent
6bab73f378
commit
96c1de9f98
4 changed files with 58 additions and 2 deletions
|
|
@ -83,8 +83,9 @@ type ImageType interface {
|
|||
|
||||
// The ImageOptions specify options for a specific image build
|
||||
type ImageOptions struct {
|
||||
OSTree OSTreeImageOptions
|
||||
Size uint64
|
||||
OSTree OSTreeImageOptions
|
||||
Size uint64
|
||||
Subscription *SubscriptionImageOptions
|
||||
}
|
||||
|
||||
// The OSTreeImageOptions specify ostree-specific image options
|
||||
|
|
@ -93,6 +94,15 @@ type OSTreeImageOptions struct {
|
|||
Parent string
|
||||
}
|
||||
|
||||
// The SubscriptionImageOptions specify subscription-specific image options
|
||||
type SubscriptionImageOptions struct {
|
||||
Organization int
|
||||
ActivationKey string
|
||||
ServerUrl string
|
||||
BaseUrl string
|
||||
Insights bool
|
||||
}
|
||||
|
||||
// A Manifest is an opaque JSON object, which is a valid input to osbuild
|
||||
type Manifest []byte
|
||||
|
||||
|
|
|
|||
|
|
@ -310,6 +310,21 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp
|
|||
}))
|
||||
}
|
||||
|
||||
if options.Subscription != nil {
|
||||
commands := []string{
|
||||
fmt.Sprintf("/usr/sbin/subscription-manager register --org=%d --activationkey=%s --serverurl %s --baseurl %s", options.Subscription.Organization, options.Subscription.ActivationKey, options.Subscription.ServerUrl, options.Subscription.BaseUrl),
|
||||
}
|
||||
if options.Subscription.Insights {
|
||||
commands = append(commands, "/usr/bin/insights-client --register")
|
||||
}
|
||||
|
||||
p.AddStage(osbuild.NewFirstBootStage(&osbuild.FirstBootStageOptions{
|
||||
Commands: commands,
|
||||
WaitForNetwork: true,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
p.Assembler = t.assembler(t.arch.uefi, options, t.arch)
|
||||
|
||||
return p, nil
|
||||
|
|
|
|||
15
internal/osbuild/first_boot_stage.go
Normal file
15
internal/osbuild/first_boot_stage.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package osbuild
|
||||
|
||||
type FirstBootStageOptions struct {
|
||||
Commands []string `json:"commands"`
|
||||
WaitForNetwork bool `json:"wait_for_network,omitempty"`
|
||||
}
|
||||
|
||||
func (FirstBootStageOptions) isStageOptions() {}
|
||||
|
||||
func NewFirstBootStage(options *FirstBootStageOptions) *Stage {
|
||||
return &Stage{
|
||||
Name: "org.osbuild.first-boot",
|
||||
Options: options,
|
||||
}
|
||||
}
|
||||
16
internal/osbuild/first_boot_stage_test.go
Normal file
16
internal/osbuild/first_boot_stage_test.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package osbuild
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNewFirstBootStage(t *testing.T) {
|
||||
expectedStage := &Stage{
|
||||
Name: "org.osbuild.first-boot",
|
||||
Options: &FirstBootStageOptions{},
|
||||
}
|
||||
actualStage := NewFirstBootStage(&FirstBootStageOptions{})
|
||||
assert.Equal(t, expectedStage, actualStage)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue