distro.Manifest: take Customizations rather than Blueprint as argument
This makes two changes simultaneously, to avoid too much churn: - move accessors from being on the blueprint struct to the customizations struct, and - pass the customizations struct rather than the whole blueprint as argumnet to distro.Manifest(). @larskarlitski pointed out in a previous review that it feels redundant to pass the whole blueprint as well as the list of packages to the Manifest funciton. Indeed it is, so this simplifies things a bit. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
5d179428be
commit
7957feff48
13 changed files with 172 additions and 172 deletions
|
|
@ -139,7 +139,7 @@ func main() {
|
|||
}
|
||||
} else {
|
||||
size := d.GetSizeForOutputType(imageType, 0)
|
||||
manifest, err := d.Manifest(blueprint, nil, packageSpecs, buildPackageSpecs, archArg, imageType, size)
|
||||
manifest, err := d.Manifest(blueprint.Customizations, nil, packageSpecs, buildPackageSpecs, archArg, imageType, size)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,112 +106,6 @@ func (b *Blueprint) GetPackages() []string {
|
|||
return packages
|
||||
}
|
||||
|
||||
func (b *Blueprint) GetHostname() *string {
|
||||
if b.Customizations == nil {
|
||||
return nil
|
||||
}
|
||||
return b.Customizations.Hostname
|
||||
}
|
||||
|
||||
func (b *Blueprint) GetPrimaryLocale() (*string, *string) {
|
||||
if b.Customizations == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if b.Customizations.Locale == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if len(b.Customizations.Locale.Languages) == 0 {
|
||||
return nil, b.Customizations.Locale.Keyboard
|
||||
}
|
||||
return &b.Customizations.Locale.Languages[0], b.Customizations.Locale.Keyboard
|
||||
}
|
||||
|
||||
func (b *Blueprint) GetTimezoneSettings() (*string, []string) {
|
||||
if b.Customizations == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if b.Customizations.Timezone == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return b.Customizations.Timezone.Timezone, b.Customizations.Timezone.NTPServers
|
||||
}
|
||||
|
||||
func (b *Blueprint) GetUsers() []UserCustomization {
|
||||
if b.Customizations == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
users := []UserCustomization{}
|
||||
|
||||
// prepend sshkey for backwards compat (overridden by users)
|
||||
if len(b.Customizations.SSHKey) > 0 {
|
||||
for _, c := range b.Customizations.SSHKey {
|
||||
users = append(users, UserCustomization{
|
||||
Name: c.User,
|
||||
Key: &c.Key,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return append(users, b.Customizations.User...)
|
||||
}
|
||||
|
||||
func (b *Blueprint) GetGroups() []GroupCustomization {
|
||||
if b.Customizations == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// This is for parity with lorax, which assumes that for each
|
||||
// user, a group with that name already exists. Thus, filter groups
|
||||
// named like an existing user.
|
||||
|
||||
groups := []GroupCustomization{}
|
||||
for _, group := range b.Customizations.Group {
|
||||
exists := false
|
||||
for _, user := range b.Customizations.User {
|
||||
if user.Name == group.Name {
|
||||
exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, key := range b.Customizations.SSHKey {
|
||||
if key.User == group.Name {
|
||||
exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !exists {
|
||||
groups = append(groups, group)
|
||||
}
|
||||
}
|
||||
|
||||
return groups
|
||||
}
|
||||
|
||||
func (b *Blueprint) GetKernel() *KernelCustomization {
|
||||
if b.Customizations == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return b.Customizations.Kernel
|
||||
}
|
||||
|
||||
func (b *Blueprint) GetFirewall() *FirewallCustomization {
|
||||
if b.Customizations == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return b.Customizations.Firewall
|
||||
}
|
||||
|
||||
func (b *Blueprint) GetServices() *ServicesCustomization {
|
||||
if b.Customizations == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return b.Customizations.Services
|
||||
}
|
||||
|
||||
func (p Package) ToNameVersion() string {
|
||||
// Omit version to prevent all packages with prefix of name to be installed
|
||||
if p.Version == "*" {
|
||||
|
|
|
|||
|
|
@ -70,3 +70,109 @@ type CustomizationError struct {
|
|||
func (e *CustomizationError) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
func (c *Customizations) GetHostname() *string {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.Hostname
|
||||
}
|
||||
|
||||
func (c *Customizations) GetPrimaryLocale() (*string, *string) {
|
||||
if c == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if c.Locale == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if len(c.Locale.Languages) == 0 {
|
||||
return nil, c.Locale.Keyboard
|
||||
}
|
||||
return &c.Locale.Languages[0], c.Locale.Keyboard
|
||||
}
|
||||
|
||||
func (c *Customizations) GetTimezoneSettings() (*string, []string) {
|
||||
if c == nil {
|
||||
return nil, nil
|
||||
}
|
||||
if c.Timezone == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return c.Timezone.Timezone, c.Timezone.NTPServers
|
||||
}
|
||||
|
||||
func (c *Customizations) GetUsers() []UserCustomization {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
users := []UserCustomization{}
|
||||
|
||||
// prepend sshkey for backwards compat (overridden by users)
|
||||
if len(c.SSHKey) > 0 {
|
||||
for _, c := range c.SSHKey {
|
||||
users = append(users, UserCustomization{
|
||||
Name: c.User,
|
||||
Key: &c.Key,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return append(users, c.User...)
|
||||
}
|
||||
|
||||
func (c *Customizations) GetGroups() []GroupCustomization {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// This is for parity with lorax, which assumes that for each
|
||||
// user, a group with that name already exists. Thus, filter groups
|
||||
// named like an existing user.
|
||||
|
||||
groups := []GroupCustomization{}
|
||||
for _, group := range c.Group {
|
||||
exists := false
|
||||
for _, user := range c.User {
|
||||
if user.Name == group.Name {
|
||||
exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, key := range c.SSHKey {
|
||||
if key.User == group.Name {
|
||||
exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !exists {
|
||||
groups = append(groups, group)
|
||||
}
|
||||
}
|
||||
|
||||
return groups
|
||||
}
|
||||
|
||||
func (c *Customizations) GetKernel() *KernelCustomization {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.Kernel
|
||||
}
|
||||
|
||||
func (c *Customizations) GetFirewall() *FirewallCustomization {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.Firewall
|
||||
}
|
||||
|
||||
func (c *Customizations) GetServices() *ServicesCustomization {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.Services
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ type Distro interface {
|
|||
// Returns an osbuild manifest, containing the sources and pipeline necessary
|
||||
// to generates an image in the given output format with all packages and
|
||||
// customizations specified in the given blueprint.
|
||||
Manifest(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, imageFormat string, size uint64) (*osbuild.Manifest, error)
|
||||
Manifest(b *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, imageFormat string, size uint64) (*osbuild.Manifest, error)
|
||||
|
||||
// Returns a osbuild runner that can be used on this distro.
|
||||
Runner() string
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ func TestDistro_Manifest(t *testing.T) {
|
|||
return
|
||||
}
|
||||
size := d.GetSizeForOutputType(tt.ComposeRequest.OutputFormat, 0)
|
||||
got, err := d.Manifest(tt.ComposeRequest.Blueprint,
|
||||
got, err := d.Manifest(tt.ComposeRequest.Blueprint.Customizations,
|
||||
nil,
|
||||
tt.RpmMD.Packages,
|
||||
tt.RpmMD.BuildPackages,
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ func (r *Fedora30) BuildPackages(outputArchitecture string) ([]string, error) {
|
|||
return append(r.buildPackages, arch.BuildPackages...), nil
|
||||
}
|
||||
|
||||
func (r *Fedora30) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
func (r *Fedora30) pipeline(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
output, exists := r.outputs[outputFormat]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
|
|
@ -404,7 +404,7 @@ func (r *Fedora30) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewFixBLSStage())
|
||||
|
||||
// TODO support setting all languages and install corresponding langpack-* package
|
||||
language, keyboard := b.GetPrimaryLocale()
|
||||
language, keyboard := c.GetPrimaryLocale()
|
||||
|
||||
if language != nil {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{*language}))
|
||||
|
|
@ -416,11 +416,11 @@ func (r *Fedora30) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewKeymapStage(&osbuild.KeymapStageOptions{*keyboard}))
|
||||
}
|
||||
|
||||
if hostname := b.GetHostname(); hostname != nil {
|
||||
if hostname := c.GetHostname(); hostname != nil {
|
||||
p.AddStage(osbuild.NewHostnameStage(&osbuild.HostnameStageOptions{*hostname}))
|
||||
}
|
||||
|
||||
timezone, ntpServers := b.GetTimezoneSettings()
|
||||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
|
||||
// TODO install chrony when this is set?
|
||||
if timezone != nil {
|
||||
|
|
@ -431,7 +431,7 @@ func (r *Fedora30) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewChronyStage(&osbuild.ChronyStageOptions{ntpServers}))
|
||||
}
|
||||
|
||||
if users := b.GetUsers(); len(users) > 0 {
|
||||
if users := c.GetUsers(); len(users) > 0 {
|
||||
options, err := r.userStageOptions(users)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -439,20 +439,20 @@ func (r *Fedora30) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewUsersStage(options))
|
||||
}
|
||||
|
||||
if groups := b.GetGroups(); len(groups) > 0 {
|
||||
if groups := c.GetGroups(); len(groups) > 0 {
|
||||
p.AddStage(osbuild.NewGroupsStage(r.groupStageOptions(groups)))
|
||||
}
|
||||
|
||||
if output.Bootable {
|
||||
p.AddStage(osbuild.NewFSTabStage(r.fsTabStageOptions(arch.UEFI)))
|
||||
}
|
||||
p.AddStage(osbuild.NewGRUB2Stage(r.grub2StageOptions(output.KernelOptions, b.GetKernel(), arch.UEFI)))
|
||||
p.AddStage(osbuild.NewGRUB2Stage(r.grub2StageOptions(output.KernelOptions, c.GetKernel(), arch.UEFI)))
|
||||
|
||||
if services := b.GetServices(); services != nil || output.EnabledServices != nil {
|
||||
if services := c.GetServices(); services != nil || output.EnabledServices != nil {
|
||||
p.AddStage(osbuild.NewSystemdStage(r.systemdStageOptions(output.EnabledServices, output.DisabledServices, services)))
|
||||
}
|
||||
|
||||
if firewall := b.GetFirewall(); firewall != nil {
|
||||
if firewall := c.GetFirewall(); firewall != nil {
|
||||
p.AddStage(osbuild.NewFirewallStage(r.firewallStageOptions(firewall)))
|
||||
}
|
||||
|
||||
|
|
@ -475,8 +475,8 @@ func (r *Fedora30) sources(packages []rpmmd.PackageSpec) *osbuild.Sources {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Fedora30) Manifest(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(b, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
func (r *Fedora30) Manifest(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(c, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ func (r *Fedora31) BuildPackages(outputArchitecture string) ([]string, error) {
|
|||
return append(r.buildPackages, arch.BuildPackages...), nil
|
||||
}
|
||||
|
||||
func (r *Fedora31) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
func (r *Fedora31) pipeline(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
output, exists := r.outputs[outputFormat]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
|
|
@ -404,7 +404,7 @@ func (r *Fedora31) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewFixBLSStage())
|
||||
|
||||
// TODO support setting all languages and install corresponding langpack-* package
|
||||
language, keyboard := b.GetPrimaryLocale()
|
||||
language, keyboard := c.GetPrimaryLocale()
|
||||
|
||||
if language != nil {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{*language}))
|
||||
|
|
@ -416,11 +416,11 @@ func (r *Fedora31) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewKeymapStage(&osbuild.KeymapStageOptions{*keyboard}))
|
||||
}
|
||||
|
||||
if hostname := b.GetHostname(); hostname != nil {
|
||||
if hostname := c.GetHostname(); hostname != nil {
|
||||
p.AddStage(osbuild.NewHostnameStage(&osbuild.HostnameStageOptions{*hostname}))
|
||||
}
|
||||
|
||||
timezone, ntpServers := b.GetTimezoneSettings()
|
||||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
|
||||
// TODO install chrony when this is set?
|
||||
if timezone != nil {
|
||||
|
|
@ -431,7 +431,7 @@ func (r *Fedora31) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewChronyStage(&osbuild.ChronyStageOptions{ntpServers}))
|
||||
}
|
||||
|
||||
if users := b.GetUsers(); len(users) > 0 {
|
||||
if users := c.GetUsers(); len(users) > 0 {
|
||||
options, err := r.userStageOptions(users)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -439,20 +439,20 @@ func (r *Fedora31) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewUsersStage(options))
|
||||
}
|
||||
|
||||
if groups := b.GetGroups(); len(groups) > 0 {
|
||||
if groups := c.GetGroups(); len(groups) > 0 {
|
||||
p.AddStage(osbuild.NewGroupsStage(r.groupStageOptions(groups)))
|
||||
}
|
||||
|
||||
if output.Bootable {
|
||||
p.AddStage(osbuild.NewFSTabStage(r.fsTabStageOptions(arch.UEFI)))
|
||||
}
|
||||
p.AddStage(osbuild.NewGRUB2Stage(r.grub2StageOptions(output.KernelOptions, b.GetKernel(), arch.UEFI)))
|
||||
p.AddStage(osbuild.NewGRUB2Stage(r.grub2StageOptions(output.KernelOptions, c.GetKernel(), arch.UEFI)))
|
||||
|
||||
if services := b.GetServices(); services != nil || output.EnabledServices != nil {
|
||||
if services := c.GetServices(); services != nil || output.EnabledServices != nil {
|
||||
p.AddStage(osbuild.NewSystemdStage(r.systemdStageOptions(output.EnabledServices, output.DisabledServices, services)))
|
||||
}
|
||||
|
||||
if firewall := b.GetFirewall(); firewall != nil {
|
||||
if firewall := c.GetFirewall(); firewall != nil {
|
||||
p.AddStage(osbuild.NewFirewallStage(r.firewallStageOptions(firewall)))
|
||||
}
|
||||
|
||||
|
|
@ -475,8 +475,8 @@ func (r *Fedora31) sources(packages []rpmmd.PackageSpec) *osbuild.Sources {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Fedora31) Manifest(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(b, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
func (r *Fedora31) Manifest(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(c, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ func (r *Fedora32) BuildPackages(outputArchitecture string) ([]string, error) {
|
|||
return append(r.buildPackages, arch.BuildPackages...), nil
|
||||
}
|
||||
|
||||
func (r *Fedora32) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
func (r *Fedora32) pipeline(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
output, exists := r.outputs[outputFormat]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
|
|
@ -404,7 +404,7 @@ func (r *Fedora32) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewFixBLSStage())
|
||||
|
||||
// TODO support setting all languages and install corresponding langpack-* package
|
||||
language, keyboard := b.GetPrimaryLocale()
|
||||
language, keyboard := c.GetPrimaryLocale()
|
||||
|
||||
if language != nil {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{*language}))
|
||||
|
|
@ -416,11 +416,11 @@ func (r *Fedora32) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewKeymapStage(&osbuild.KeymapStageOptions{*keyboard}))
|
||||
}
|
||||
|
||||
if hostname := b.GetHostname(); hostname != nil {
|
||||
if hostname := c.GetHostname(); hostname != nil {
|
||||
p.AddStage(osbuild.NewHostnameStage(&osbuild.HostnameStageOptions{*hostname}))
|
||||
}
|
||||
|
||||
timezone, ntpServers := b.GetTimezoneSettings()
|
||||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
|
||||
// TODO install chrony when this is set?
|
||||
if timezone != nil {
|
||||
|
|
@ -431,7 +431,7 @@ func (r *Fedora32) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewChronyStage(&osbuild.ChronyStageOptions{ntpServers}))
|
||||
}
|
||||
|
||||
if users := b.GetUsers(); len(users) > 0 {
|
||||
if users := c.GetUsers(); len(users) > 0 {
|
||||
options, err := r.userStageOptions(users)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -439,20 +439,20 @@ func (r *Fedora32) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
p.AddStage(osbuild.NewUsersStage(options))
|
||||
}
|
||||
|
||||
if groups := b.GetGroups(); len(groups) > 0 {
|
||||
if groups := c.GetGroups(); len(groups) > 0 {
|
||||
p.AddStage(osbuild.NewGroupsStage(r.groupStageOptions(groups)))
|
||||
}
|
||||
|
||||
if output.Bootable {
|
||||
p.AddStage(osbuild.NewFSTabStage(r.fsTabStageOptions(arch.UEFI)))
|
||||
}
|
||||
p.AddStage(osbuild.NewGRUB2Stage(r.grub2StageOptions(output.KernelOptions, b.GetKernel(), arch.UEFI)))
|
||||
p.AddStage(osbuild.NewGRUB2Stage(r.grub2StageOptions(output.KernelOptions, c.GetKernel(), arch.UEFI)))
|
||||
|
||||
if services := b.GetServices(); services != nil || output.EnabledServices != nil {
|
||||
if services := c.GetServices(); services != nil || output.EnabledServices != nil {
|
||||
p.AddStage(osbuild.NewSystemdStage(r.systemdStageOptions(output.EnabledServices, output.DisabledServices, services)))
|
||||
}
|
||||
|
||||
if firewall := b.GetFirewall(); firewall != nil {
|
||||
if firewall := c.GetFirewall(); firewall != nil {
|
||||
p.AddStage(osbuild.NewFirewallStage(r.firewallStageOptions(firewall)))
|
||||
}
|
||||
|
||||
|
|
@ -475,8 +475,8 @@ func (r *Fedora32) sources(packages []rpmmd.PackageSpec) *osbuild.Sources {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Fedora32) Manifest(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(b, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
func (r *Fedora32) Manifest(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(c, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func (d *FedoraTestDistro) BuildPackages(outputArchitecture string) ([]string, e
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, buildPackages, basePackages []rpmmd.PackageSpec, outputArch, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
func (d *FedoraTestDistro) pipeline(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, buildPackages, basePackages []rpmmd.PackageSpec, outputArch, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
if outputFormat == "qcow2" && outputArch == "x86_64" {
|
||||
return &osbuild.Pipeline{}, nil
|
||||
} else {
|
||||
|
|
@ -74,8 +74,8 @@ func (r *FedoraTestDistro) sources(packages []rpmmd.PackageSpec) *osbuild.Source
|
|||
return &osbuild.Sources{}
|
||||
}
|
||||
|
||||
func (r *FedoraTestDistro) Manifest(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(b, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
func (r *FedoraTestDistro) Manifest(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(c, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -525,7 +525,7 @@ func (r *RHEL81) BuildPackages(outputArchitecture string) ([]string, error) {
|
|||
return append(r.buildPackages, arch.BuildPackages...), nil
|
||||
}
|
||||
|
||||
func (r *RHEL81) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
func (r *RHEL81) pipeline(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
output, exists := r.outputs[outputFormat]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
|
|
@ -547,13 +547,13 @@ func (r *RHEL81) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoCo
|
|||
}
|
||||
|
||||
kernelOptions := output.KernelOptions
|
||||
if kernel := b.GetKernel(); kernel != nil {
|
||||
if kernel := c.GetKernel(); kernel != nil {
|
||||
kernelOptions += " " + kernel.Append
|
||||
}
|
||||
p.AddStage(osbuild.NewGRUB2Stage(r.grub2StageOptions(kernelOptions, arch.UEFI)))
|
||||
|
||||
// TODO support setting all languages and install corresponding langpack-* package
|
||||
language, keyboard := b.GetPrimaryLocale()
|
||||
language, keyboard := c.GetPrimaryLocale()
|
||||
|
||||
if language != nil {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{*language}))
|
||||
|
|
@ -565,11 +565,11 @@ func (r *RHEL81) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoCo
|
|||
p.AddStage(osbuild.NewKeymapStage(&osbuild.KeymapStageOptions{*keyboard}))
|
||||
}
|
||||
|
||||
if hostname := b.GetHostname(); hostname != nil {
|
||||
if hostname := c.GetHostname(); hostname != nil {
|
||||
p.AddStage(osbuild.NewHostnameStage(&osbuild.HostnameStageOptions{*hostname}))
|
||||
}
|
||||
|
||||
timezone, ntpServers := b.GetTimezoneSettings()
|
||||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
|
||||
// TODO install chrony when this is set?
|
||||
if timezone != nil {
|
||||
|
|
@ -580,7 +580,7 @@ func (r *RHEL81) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoCo
|
|||
p.AddStage(osbuild.NewChronyStage(&osbuild.ChronyStageOptions{ntpServers}))
|
||||
}
|
||||
|
||||
if users := b.GetUsers(); len(users) > 0 {
|
||||
if users := c.GetUsers(); len(users) > 0 {
|
||||
options, err := r.userStageOptions(users)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -588,15 +588,15 @@ func (r *RHEL81) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoCo
|
|||
p.AddStage(osbuild.NewUsersStage(options))
|
||||
}
|
||||
|
||||
if groups := b.GetGroups(); len(groups) > 0 {
|
||||
if groups := c.GetGroups(); len(groups) > 0 {
|
||||
p.AddStage(osbuild.NewGroupsStage(r.groupStageOptions(groups)))
|
||||
}
|
||||
|
||||
if services := b.GetServices(); services != nil || output.EnabledServices != nil {
|
||||
if services := c.GetServices(); services != nil || output.EnabledServices != nil {
|
||||
p.AddStage(osbuild.NewSystemdStage(r.systemdStageOptions(output.EnabledServices, output.DisabledServices, services, output.DefaultTarget)))
|
||||
}
|
||||
|
||||
if firewall := b.GetFirewall(); firewall != nil {
|
||||
if firewall := c.GetFirewall(); firewall != nil {
|
||||
p.AddStage(osbuild.NewFirewallStage(r.firewallStageOptions(firewall)))
|
||||
}
|
||||
|
||||
|
|
@ -619,8 +619,8 @@ func (r *RHEL81) sources(packages []rpmmd.PackageSpec) *osbuild.Sources {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *RHEL81) Manifest(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(b, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
func (r *RHEL81) Manifest(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(c, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -525,7 +525,7 @@ func (r *RHEL82) BuildPackages(outputArchitecture string) ([]string, error) {
|
|||
return append(r.buildPackages, arch.BuildPackages...), nil
|
||||
}
|
||||
|
||||
func (r *RHEL82) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
func (r *RHEL82) pipeline(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
output, exists := r.outputs[outputFormat]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
|
|
@ -547,13 +547,13 @@ func (r *RHEL82) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoCo
|
|||
}
|
||||
|
||||
kernelOptions := output.KernelOptions
|
||||
if kernel := b.GetKernel(); kernel != nil {
|
||||
if kernel := c.GetKernel(); kernel != nil {
|
||||
kernelOptions += " " + kernel.Append
|
||||
}
|
||||
p.AddStage(osbuild.NewGRUB2Stage(r.grub2StageOptions(kernelOptions, arch.UEFI)))
|
||||
|
||||
// TODO support setting all languages and install corresponding langpack-* package
|
||||
language, keyboard := b.GetPrimaryLocale()
|
||||
language, keyboard := c.GetPrimaryLocale()
|
||||
|
||||
if language != nil {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{*language}))
|
||||
|
|
@ -565,11 +565,11 @@ func (r *RHEL82) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoCo
|
|||
p.AddStage(osbuild.NewKeymapStage(&osbuild.KeymapStageOptions{*keyboard}))
|
||||
}
|
||||
|
||||
if hostname := b.GetHostname(); hostname != nil {
|
||||
if hostname := c.GetHostname(); hostname != nil {
|
||||
p.AddStage(osbuild.NewHostnameStage(&osbuild.HostnameStageOptions{*hostname}))
|
||||
}
|
||||
|
||||
timezone, ntpServers := b.GetTimezoneSettings()
|
||||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
|
||||
// TODO install chrony when this is set?
|
||||
if timezone != nil {
|
||||
|
|
@ -580,7 +580,7 @@ func (r *RHEL82) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoCo
|
|||
p.AddStage(osbuild.NewChronyStage(&osbuild.ChronyStageOptions{ntpServers}))
|
||||
}
|
||||
|
||||
if users := b.GetUsers(); len(users) > 0 {
|
||||
if users := c.GetUsers(); len(users) > 0 {
|
||||
options, err := r.userStageOptions(users)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -588,15 +588,15 @@ func (r *RHEL82) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoCo
|
|||
p.AddStage(osbuild.NewUsersStage(options))
|
||||
}
|
||||
|
||||
if groups := b.GetGroups(); len(groups) > 0 {
|
||||
if groups := c.GetGroups(); len(groups) > 0 {
|
||||
p.AddStage(osbuild.NewGroupsStage(r.groupStageOptions(groups)))
|
||||
}
|
||||
|
||||
if services := b.GetServices(); services != nil || output.EnabledServices != nil {
|
||||
if services := c.GetServices(); services != nil || output.EnabledServices != nil {
|
||||
p.AddStage(osbuild.NewSystemdStage(r.systemdStageOptions(output.EnabledServices, output.DisabledServices, services, output.DefaultTarget)))
|
||||
}
|
||||
|
||||
if firewall := b.GetFirewall(); firewall != nil {
|
||||
if firewall := c.GetFirewall(); firewall != nil {
|
||||
p.AddStage(osbuild.NewFirewallStage(r.firewallStageOptions(firewall)))
|
||||
}
|
||||
|
||||
|
|
@ -619,8 +619,8 @@ func (r *RHEL82) sources(packages []rpmmd.PackageSpec) *osbuild.Sources {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *RHEL82) Manifest(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(b, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
func (r *RHEL82) Manifest(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(c, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ func (d *TestDistro) BuildPackages(outputArchitecture string) ([]string, error)
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *TestDistro) pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArch, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
func (d *TestDistro) pipeline(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArch, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
if outputFormat == "test_output" && outputArch == "test_arch" {
|
||||
return &osbuild.Pipeline{}, nil
|
||||
}
|
||||
|
|
@ -66,8 +66,8 @@ func (d *TestDistro) sources(packages []rpmmd.PackageSpec) *osbuild.Sources {
|
|||
return &osbuild.Sources{}
|
||||
}
|
||||
|
||||
func (r *TestDistro) Manifest(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(b, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
func (r *TestDistro) Manifest(c *blueprint.Customizations, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
||||
pipeline, err := r.pipeline(c, additionalRepos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -621,7 +621,7 @@ func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, packag
|
|||
repos = append(repos, source.RepoConfig())
|
||||
}
|
||||
|
||||
manifestStruct, err := s.distro.Manifest(bp, repos, packages, buildPackages, arch, composeType, size)
|
||||
manifestStruct, err := s.distro.Manifest(bp.Customizations, repos, packages, buildPackages, arch, composeType, size)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -689,7 +689,7 @@ func (s *Store) PushComposeRequest(request ComposeRequest) error {
|
|||
if !exists {
|
||||
panic("fatal error, image type should exist but it does not")
|
||||
}
|
||||
manifestStruct, err := distroStruct.Manifest(&request.Blueprint, request.Repositories, nil, nil, arch, imgTypeCompatStr, 0)
|
||||
manifestStruct, err := distroStruct.Manifest(request.Blueprint.Customizations, request.Repositories, nil, nil, arch, imgTypeCompatStr, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue