distro: use pointers for basic types in ImageConfig
Using basic types as values in the `ImageConfig` structure makes it impossible to distinguish if the empty value for the type was set intentionally or if it is just the value the variable was initialized to. This is very bad especially for `bool` type. While working on unifying `vhd` and `azure-rhui` image types I found out, that some newly added variables in the `ImageConfig` structure were forgotten in the `InheritFrom()` method. This makes it impossible to inherit their values from a parent configuration. This is however required for the unification of `vhd` and `azure-rhui` image types. As described above, it would be impossible to decide whether a `bool` value should be inherited from the parent configuration or not. The only solution is to use a pointer to the type. For consistency, use pointer for all basic types. Adjust distro implementations accordingly.
This commit is contained in:
parent
ab3bd7d94f
commit
c8382f1654
12 changed files with 132 additions and 110 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/container"
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
|
|
@ -122,7 +123,7 @@ var (
|
|||
installerPkgsKey: iotInstallerPackageSet,
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
EnabledServices: iotServices,
|
||||
},
|
||||
rpmOstree: true,
|
||||
|
|
@ -141,7 +142,7 @@ var (
|
|||
osPkgsKey: qcow2CommonPackageSet,
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
EnabledServices: []string{
|
||||
"cloud-init.service",
|
||||
"cloud-config.service",
|
||||
|
|
@ -167,11 +168,11 @@ var (
|
|||
osPkgsKey: vhdCommonPackageSet,
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
EnabledServices: []string{
|
||||
"sshd",
|
||||
},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
DisabledServices: []string{
|
||||
"proc-sys-fs-binfmt_misc.mount",
|
||||
"loadmodules.service",
|
||||
|
|
@ -196,7 +197,7 @@ var (
|
|||
osPkgsKey: vmdkCommonPackageSet,
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
EnabledServices: []string{
|
||||
"cloud-init.service",
|
||||
"cloud-config.service",
|
||||
|
|
@ -222,7 +223,7 @@ var (
|
|||
osPkgsKey: openstackCommonPackageSet,
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
EnabledServices: []string{
|
||||
"cloud-init.service",
|
||||
"cloud-config.service",
|
||||
|
|
@ -242,7 +243,7 @@ var (
|
|||
|
||||
// default EC2 images config (common for all architectures)
|
||||
defaultEc2ImageConfig = &distro.ImageConfig{
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
}
|
||||
|
||||
amiImgType = imageType{
|
||||
|
|
@ -272,10 +273,10 @@ var (
|
|||
osPkgsKey: containerPackageSet,
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
NoSElinux: true,
|
||||
ExcludeDocs: true,
|
||||
Locale: "C.UTF-8",
|
||||
Timezone: "Etc/UTC",
|
||||
NoSElinux: common.BoolToPtr(true),
|
||||
ExcludeDocs: common.BoolToPtr(true),
|
||||
Locale: common.StringToPtr("C.UTF-8"),
|
||||
Timezone: common.StringToPtr("Etc/UTC"),
|
||||
},
|
||||
image: containerImage,
|
||||
bootable: false,
|
||||
|
|
@ -300,8 +301,8 @@ type distribution struct {
|
|||
|
||||
// Fedora based OS image configuration defaults
|
||||
var defaultDistroImageConfig = &distro.ImageConfig{
|
||||
Timezone: "UTC",
|
||||
Locale: "en_US",
|
||||
Timezone: common.StringToPtr("UTC"),
|
||||
Locale: common.StringToPtr("en_US"),
|
||||
}
|
||||
|
||||
// distribution objects without the arches > image types
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ func osCustomizations(
|
|||
osc.ExtraBaseRepos = osPackageSet.Repositories
|
||||
|
||||
osc.GPGKeyFiles = imageConfig.GPGKeyFiles
|
||||
osc.ExcludeDocs = imageConfig.ExcludeDocs
|
||||
if imageConfig.ExcludeDocs != nil {
|
||||
osc.ExcludeDocs = *imageConfig.ExcludeDocs
|
||||
}
|
||||
|
||||
if !t.bootISO {
|
||||
// don't put users and groups in the payload of an installer
|
||||
|
|
@ -52,15 +54,17 @@ func osCustomizations(
|
|||
|
||||
osc.EnabledServices = imageConfig.EnabledServices
|
||||
osc.DisabledServices = imageConfig.DisabledServices
|
||||
osc.DefaultTarget = imageConfig.DefaultTarget
|
||||
if imageConfig.DefaultTarget != nil {
|
||||
osc.DefaultTarget = *imageConfig.DefaultTarget
|
||||
}
|
||||
|
||||
osc.Firewall = c.GetFirewall()
|
||||
|
||||
language, keyboard := c.GetPrimaryLocale()
|
||||
if language != nil {
|
||||
osc.Language = *language
|
||||
} else {
|
||||
osc.Language = imageConfig.Locale
|
||||
} else if imageConfig.Locale != nil {
|
||||
osc.Language = *imageConfig.Locale
|
||||
}
|
||||
if keyboard != nil {
|
||||
osc.Keyboard = keyboard
|
||||
|
|
@ -77,8 +81,8 @@ func osCustomizations(
|
|||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
if timezone != nil {
|
||||
osc.Timezone = *timezone
|
||||
} else {
|
||||
osc.Timezone = imageConfig.Timezone
|
||||
} else if imageConfig.Timezone != nil {
|
||||
osc.Timezone = *imageConfig.Timezone
|
||||
}
|
||||
|
||||
if len(ntpServers) > 0 {
|
||||
|
|
@ -87,7 +91,8 @@ func osCustomizations(
|
|||
osc.NTPServers = imageConfig.TimeSynchronization.Timeservers
|
||||
}
|
||||
|
||||
if !imageConfig.NoSElinux {
|
||||
// Relabel the tree, unless the `NoSElinux` flag is explicitly set to `true`
|
||||
if imageConfig.NoSElinux == nil || imageConfig.NoSElinux != nil && !*imageConfig.NoSElinux {
|
||||
osc.SElinux = "targeted"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,23 +11,23 @@ const (
|
|||
|
||||
// ImageConfig represents a (default) configuration applied to the image
|
||||
type ImageConfig struct {
|
||||
Timezone string
|
||||
Timezone *string
|
||||
TimeSynchronization *osbuild.ChronyStageOptions
|
||||
Locale string
|
||||
Locale *string
|
||||
Keyboard *osbuild.KeymapStageOptions
|
||||
EnabledServices []string
|
||||
DisabledServices []string
|
||||
DefaultTarget string
|
||||
DefaultTarget *string
|
||||
Sysconfig []*osbuild.SysconfigStageOptions
|
||||
|
||||
// List of files from which to import GPG keys into the RPM database
|
||||
GPGKeyFiles []string
|
||||
|
||||
// Disable SELinux labelling
|
||||
NoSElinux bool
|
||||
NoSElinux *bool
|
||||
|
||||
// Disable documentation
|
||||
ExcludeDocs bool
|
||||
ExcludeDocs *bool
|
||||
|
||||
// for RHSM configuration, we need to potentially distinguish the case
|
||||
// when the user want the image to be subscribed on first boot and when not
|
||||
|
|
|
|||
|
|
@ -18,17 +18,17 @@ func TestImageConfigInheritFrom(t *testing.T) {
|
|||
{
|
||||
name: "inheritance with overridden values",
|
||||
distroConfig: &ImageConfig{
|
||||
Timezone: "America/New_York",
|
||||
Timezone: common.StringToPtr("America/New_York"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Timeservers: []string{"127.0.0.1"},
|
||||
},
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Keyboard: &osbuild.KeymapStageOptions{
|
||||
Keymap: "us",
|
||||
},
|
||||
EnabledServices: []string{"sshd"},
|
||||
DisabledServices: []string{"named"},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
Sysconfig: []*osbuild.SysconfigStageOptions{
|
||||
{
|
||||
Kernel: &osbuild.SysconfigKernelOptions{
|
||||
|
|
@ -56,7 +56,7 @@ func TestImageConfigInheritFrom(t *testing.T) {
|
|||
},
|
||||
},
|
||||
imageConfig: &ImageConfig{
|
||||
Timezone: "UTC",
|
||||
Timezone: common.StringToPtr("UTC"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Servers: []osbuild.ChronyConfigServer{
|
||||
{
|
||||
|
|
@ -71,7 +71,7 @@ func TestImageConfigInheritFrom(t *testing.T) {
|
|||
},
|
||||
},
|
||||
expectedConfig: &ImageConfig{
|
||||
Timezone: "UTC",
|
||||
Timezone: common.StringToPtr("UTC"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Servers: []osbuild.ChronyConfigServer{
|
||||
{
|
||||
|
|
@ -84,13 +84,13 @@ func TestImageConfigInheritFrom(t *testing.T) {
|
|||
},
|
||||
LeapsecTz: common.StringToPtr(""),
|
||||
},
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Keyboard: &osbuild.KeymapStageOptions{
|
||||
Keymap: "us",
|
||||
},
|
||||
EnabledServices: []string{"sshd"},
|
||||
DisabledServices: []string{"named"},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
Sysconfig: []*osbuild.SysconfigStageOptions{
|
||||
{
|
||||
Kernel: &osbuild.SysconfigKernelOptions{
|
||||
|
|
@ -121,91 +121,91 @@ func TestImageConfigInheritFrom(t *testing.T) {
|
|||
{
|
||||
name: "empty image type configuration",
|
||||
distroConfig: &ImageConfig{
|
||||
Timezone: "America/New_York",
|
||||
Timezone: common.StringToPtr("America/New_York"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Timeservers: []string{"127.0.0.1"},
|
||||
},
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Keyboard: &osbuild.KeymapStageOptions{
|
||||
Keymap: "us",
|
||||
},
|
||||
EnabledServices: []string{"sshd"},
|
||||
DisabledServices: []string{"named"},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
},
|
||||
imageConfig: &ImageConfig{},
|
||||
expectedConfig: &ImageConfig{
|
||||
Timezone: "America/New_York",
|
||||
Timezone: common.StringToPtr("America/New_York"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Timeservers: []string{"127.0.0.1"},
|
||||
},
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Keyboard: &osbuild.KeymapStageOptions{
|
||||
Keymap: "us",
|
||||
},
|
||||
EnabledServices: []string{"sshd"},
|
||||
DisabledServices: []string{"named"},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty distro configuration",
|
||||
distroConfig: &ImageConfig{},
|
||||
imageConfig: &ImageConfig{
|
||||
Timezone: "America/New_York",
|
||||
Timezone: common.StringToPtr("America/New_York"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Timeservers: []string{"127.0.0.1"},
|
||||
},
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Keyboard: &osbuild.KeymapStageOptions{
|
||||
Keymap: "us",
|
||||
},
|
||||
EnabledServices: []string{"sshd"},
|
||||
DisabledServices: []string{"named"},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
},
|
||||
expectedConfig: &ImageConfig{
|
||||
Timezone: "America/New_York",
|
||||
Timezone: common.StringToPtr("America/New_York"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Timeservers: []string{"127.0.0.1"},
|
||||
},
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Keyboard: &osbuild.KeymapStageOptions{
|
||||
Keymap: "us",
|
||||
},
|
||||
EnabledServices: []string{"sshd"},
|
||||
DisabledServices: []string{"named"},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty distro configuration",
|
||||
distroConfig: nil,
|
||||
imageConfig: &ImageConfig{
|
||||
Timezone: "America/New_York",
|
||||
Timezone: common.StringToPtr("America/New_York"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Timeservers: []string{"127.0.0.1"},
|
||||
},
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Keyboard: &osbuild.KeymapStageOptions{
|
||||
Keymap: "us",
|
||||
},
|
||||
EnabledServices: []string{"sshd"},
|
||||
DisabledServices: []string{"named"},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
},
|
||||
expectedConfig: &ImageConfig{
|
||||
Timezone: "America/New_York",
|
||||
Timezone: common.StringToPtr("America/New_York"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Timeservers: []string{"127.0.0.1"},
|
||||
},
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Keyboard: &osbuild.KeymapStageOptions{
|
||||
Keymap: "us",
|
||||
},
|
||||
EnabledServices: []string{"sshd"},
|
||||
DisabledServices: []string{"named"},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,8 +221,8 @@ var azureRhuiImgType = imageType{
|
|||
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Timezone: "Etc/UTC",
|
||||
Locale: "en_US.UTF-8",
|
||||
Timezone: common.StringToPtr("Etc/UTC"),
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
GPGKeyFiles: []string{
|
||||
"/etc/pki/rpm-gpg/RPM-GPG-KEY-microsoft-azure-release",
|
||||
"/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release",
|
||||
|
|
@ -402,7 +402,7 @@ var azureRhuiImgType = imageType{
|
|||
},
|
||||
},
|
||||
},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
},
|
||||
kernelOptions: "ro crashkernel=auto console=tty1 console=ttyS0 earlyprintk=ttyS0 rootdelay=300 scsi_mod.use_blk_mq=y",
|
||||
bootable: true,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/container"
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
|
|
@ -31,8 +32,8 @@ const (
|
|||
|
||||
// RHEL-based OS image configuration defaults
|
||||
var defaultDistroImageConfig = &distro.ImageConfig{
|
||||
Timezone: "America/New_York",
|
||||
Locale: "en_US.UTF-8",
|
||||
Timezone: common.StringToPtr("America/New_York"),
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
GPGKeyFiles: []string{
|
||||
"/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ func osPipeline(t *imageType,
|
|||
rpmOptions := osbuild.NewRPMStageOptions(repos)
|
||||
rpmOptions.GPGKeysFromTree = imageConfig.GPGKeyFiles
|
||||
|
||||
if imageConfig.ExcludeDocs {
|
||||
if imageConfig.ExcludeDocs != nil && *imageConfig.ExcludeDocs {
|
||||
if rpmOptions.Exclude == nil {
|
||||
rpmOptions.Exclude = &osbuild.Exclude{}
|
||||
}
|
||||
|
|
@ -60,8 +60,8 @@ func osPipeline(t *imageType,
|
|||
language, keyboard := c.GetPrimaryLocale()
|
||||
if language != nil {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: *language}))
|
||||
} else {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: imageConfig.Locale}))
|
||||
} else if imageConfig.Locale != nil {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: *imageConfig.Locale}))
|
||||
}
|
||||
if keyboard != nil {
|
||||
p.AddStage(osbuild.NewKeymapStage(&osbuild.KeymapStageOptions{Keymap: *keyboard}))
|
||||
|
|
@ -76,8 +76,8 @@ func osPipeline(t *imageType,
|
|||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
if timezone != nil {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{Zone: *timezone}))
|
||||
} else {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{Zone: imageConfig.Timezone}))
|
||||
} else if imageConfig.Timezone != nil {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{Zone: *imageConfig.Timezone}))
|
||||
}
|
||||
|
||||
if len(ntpServers) > 0 {
|
||||
|
|
@ -97,12 +97,16 @@ func osPipeline(t *imageType,
|
|||
}
|
||||
|
||||
if services := c.GetServices(); services != nil || imageConfig.EnabledServices != nil ||
|
||||
imageConfig.DisabledServices != nil || imageConfig.DefaultTarget != "" {
|
||||
imageConfig.DisabledServices != nil || imageConfig.DefaultTarget != nil {
|
||||
defaultTarget := ""
|
||||
if imageConfig.DefaultTarget != nil {
|
||||
defaultTarget = *imageConfig.DefaultTarget
|
||||
}
|
||||
p.AddStage(osbuild.NewSystemdStage(systemdStageOptions(
|
||||
imageConfig.EnabledServices,
|
||||
imageConfig.DisabledServices,
|
||||
services,
|
||||
imageConfig.DefaultTarget,
|
||||
defaultTarget,
|
||||
)))
|
||||
}
|
||||
|
||||
|
|
@ -292,7 +296,8 @@ func osPipeline(t *imageType,
|
|||
p.AddStage(bootloader)
|
||||
}
|
||||
|
||||
if !imageConfig.NoSElinux {
|
||||
// Relabel the tree, unless the `NoSElinux` flag is explicitly set to `true`
|
||||
if imageConfig.NoSElinux == nil || imageConfig.NoSElinux != nil && !*imageConfig.NoSElinux {
|
||||
p.AddStage(osbuild.NewSELinuxStage(selinuxStageOptions(false)))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ var qcow2ImgType = imageType{
|
|||
osPkgsKey: qcow2CommonPackageSet,
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
Sysconfig: []*osbuild.SysconfigStageOptions{
|
||||
{
|
||||
Kernel: &osbuild.SysconfigKernelOptions{
|
||||
|
|
|
|||
|
|
@ -106,8 +106,8 @@ type distribution struct {
|
|||
|
||||
// RHEL-based OS image configuration defaults
|
||||
var defaultDistroImageConfig = &distro.ImageConfig{
|
||||
Timezone: "America/New_York",
|
||||
Locale: "en_US.UTF-8",
|
||||
Timezone: common.StringToPtr("America/New_York"),
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Sysconfig: []*osbuild.SysconfigStageOptions{
|
||||
{
|
||||
Kernel: &osbuild.SysconfigKernelOptions{
|
||||
|
|
@ -939,7 +939,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
RHSMConfig: map[distro.RHSMSubscriptionStatus]*osbuild.RHSMStageOptions{
|
||||
distro.RHSMConfigNoSubscription: {
|
||||
DnfPlugins: &osbuild.RHSMStageOptionsDnfPlugins{
|
||||
|
|
@ -978,7 +978,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
"sshd",
|
||||
"waagent",
|
||||
},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
},
|
||||
kernelOptions: "ro biosdevname=0 rootdelay=300 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0",
|
||||
bootable: true,
|
||||
|
|
@ -1002,8 +1002,8 @@ func newDistro(distroName string) distro.Distro {
|
|||
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Timezone: "Etc/UTC",
|
||||
Locale: "en_US.UTF-8",
|
||||
Timezone: common.StringToPtr("Etc/UTC"),
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
GPGKeyFiles: []string{
|
||||
"/etc/pki/rpm-gpg/RPM-GPG-KEY-microsoft-azure-release",
|
||||
"/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release",
|
||||
|
|
@ -1179,7 +1179,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
},
|
||||
},
|
||||
},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
},
|
||||
kernelOptions: "ro crashkernel=auto console=tty1 console=ttyS0 earlyprintk=ttyS0 rootdelay=300",
|
||||
bootable: true,
|
||||
|
|
@ -1235,7 +1235,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
|
||||
// default EC2 images config (common for all architectures)
|
||||
defaultEc2ImageConfig := &distro.ImageConfig{
|
||||
Timezone: "UTC",
|
||||
Timezone: common.StringToPtr("UTC"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Servers: []osbuild.ChronyConfigServer{
|
||||
{
|
||||
|
|
@ -1266,7 +1266,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
"cloud-final",
|
||||
"reboot.target",
|
||||
},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
Sysconfig: []*osbuild.SysconfigStageOptions{
|
||||
{
|
||||
Kernel: &osbuild.SysconfigKernelOptions{
|
||||
|
|
@ -1673,7 +1673,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
|
||||
// GCE BYOS image
|
||||
defaultGceByosImageConfig := &distro.ImageConfig{
|
||||
Timezone: "UTC",
|
||||
Timezone: common.StringToPtr("UTC"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Timeservers: []string{"metadata.google.internal"},
|
||||
},
|
||||
|
|
@ -1689,8 +1689,8 @@ func newDistro(distroName string) distro.Distro {
|
|||
"sshd-keygen@",
|
||||
"reboot.target",
|
||||
},
|
||||
DefaultTarget: "multi-user.target",
|
||||
Locale: "en_US.UTF-8",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Keyboard: &osbuild.KeymapStageOptions{
|
||||
Keymap: "us",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ func osPipeline(t *imageType,
|
|||
rpmOptions := osbuild.NewRPMStageOptions(repos)
|
||||
rpmOptions.GPGKeysFromTree = imageConfig.GPGKeyFiles
|
||||
|
||||
if imageConfig.ExcludeDocs {
|
||||
if imageConfig.ExcludeDocs != nil && *imageConfig.ExcludeDocs {
|
||||
if rpmOptions.Exclude == nil {
|
||||
rpmOptions.Exclude = &osbuild.Exclude{}
|
||||
}
|
||||
|
|
@ -461,8 +461,8 @@ func osPipeline(t *imageType,
|
|||
language, keyboard := c.GetPrimaryLocale()
|
||||
if language != nil {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: *language}))
|
||||
} else {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: imageConfig.Locale}))
|
||||
} else if imageConfig.Locale != nil {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: *imageConfig.Locale}))
|
||||
}
|
||||
if keyboard != nil {
|
||||
p.AddStage(osbuild.NewKeymapStage(&osbuild.KeymapStageOptions{Keymap: *keyboard}))
|
||||
|
|
@ -477,8 +477,8 @@ func osPipeline(t *imageType,
|
|||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
if timezone != nil {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{Zone: *timezone}))
|
||||
} else {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{Zone: imageConfig.Timezone}))
|
||||
} else if imageConfig.Timezone != nil {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{Zone: *imageConfig.Timezone}))
|
||||
}
|
||||
|
||||
if len(ntpServers) > 0 {
|
||||
|
|
@ -514,12 +514,16 @@ func osPipeline(t *imageType,
|
|||
}
|
||||
|
||||
if services := c.GetServices(); services != nil || imageConfig.EnabledServices != nil ||
|
||||
imageConfig.DisabledServices != nil || imageConfig.DefaultTarget != "" {
|
||||
imageConfig.DisabledServices != nil || imageConfig.DefaultTarget != nil {
|
||||
defaultTarget := ""
|
||||
if imageConfig.DefaultTarget != nil {
|
||||
defaultTarget = *imageConfig.DefaultTarget
|
||||
}
|
||||
p.AddStage(osbuild.NewSystemdStage(systemdStageOptions(
|
||||
imageConfig.EnabledServices,
|
||||
imageConfig.DisabledServices,
|
||||
services,
|
||||
imageConfig.DefaultTarget,
|
||||
defaultTarget,
|
||||
)))
|
||||
}
|
||||
|
||||
|
|
@ -690,7 +694,8 @@ func osPipeline(t *imageType,
|
|||
p.AddStage(osbuild.NewOscapRemediationStage(remediationOptions))
|
||||
}
|
||||
|
||||
if !imageConfig.NoSElinux {
|
||||
// Relabel the tree, unless the `NoSElinux` flag is explicitly set to `true`
|
||||
if imageConfig.NoSElinux == nil || imageConfig.NoSElinux != nil && !*imageConfig.NoSElinux {
|
||||
p.AddStage(osbuild.NewSELinuxStage(selinuxStageOptions(false)))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ type distribution struct {
|
|||
|
||||
// RHEL-based OS image configuration defaults
|
||||
var defaultDistroImageConfig = &distro.ImageConfig{
|
||||
Timezone: "America/New_York",
|
||||
Locale: "C.UTF-8",
|
||||
Timezone: common.StringToPtr("America/New_York"),
|
||||
Locale: common.StringToPtr("C.UTF-8"),
|
||||
Sysconfig: []*osbuild.SysconfigStageOptions{
|
||||
{
|
||||
Kernel: &osbuild.SysconfigKernelOptions{
|
||||
|
|
@ -745,7 +745,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
buildPkgsKey: edgeRawImageBuildPackageSet,
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
},
|
||||
defaultSize: 10 * GigaByte,
|
||||
rpmOstree: true,
|
||||
|
|
@ -779,7 +779,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
EnabledServices: edgeServices,
|
||||
},
|
||||
rpmOstree: true,
|
||||
|
|
@ -833,7 +833,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
RHSMConfig: map[distro.RHSMSubscriptionStatus]*osbuild.RHSMStageOptions{
|
||||
distro.RHSMConfigNoSubscription: {
|
||||
DnfPlugins: &osbuild.RHSMStageOptionsDnfPlugins{
|
||||
|
|
@ -868,12 +868,12 @@ func newDistro(distroName string) distro.Distro {
|
|||
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
EnabledServices: []string{
|
||||
"sshd",
|
||||
"waagent",
|
||||
},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
},
|
||||
kernelOptions: "ro biosdevname=0 rootdelay=300 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0",
|
||||
bootable: true,
|
||||
|
|
@ -894,8 +894,8 @@ func newDistro(distroName string) distro.Distro {
|
|||
osPkgsKey: azureRhuiCommonPackageSet,
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Timezone: "Etc/UTC",
|
||||
Locale: "en_US.UTF-8",
|
||||
Timezone: common.StringToPtr("Etc/UTC"),
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
GPGKeyFiles: []string{
|
||||
"/etc/pki/rpm-gpg/RPM-GPG-KEY-microsoft-azure-release",
|
||||
"/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release",
|
||||
|
|
@ -1058,7 +1058,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
},
|
||||
},
|
||||
},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
},
|
||||
kernelOptions: "ro console=tty1 console=ttyS0 earlyprintk=ttyS0 rootdelay=300",
|
||||
bootable: true,
|
||||
|
|
@ -1082,7 +1082,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
},
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
|
|
@ -1106,7 +1106,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: "en_US.UTF-8",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
},
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
|
|
@ -1120,8 +1120,8 @@ func newDistro(distroName string) distro.Distro {
|
|||
|
||||
// default EC2 images config (common for all architectures)
|
||||
defaultEc2ImageConfig := &distro.ImageConfig{
|
||||
Locale: "en_US.UTF-8",
|
||||
Timezone: "UTC",
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Timezone: common.StringToPtr("UTC"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Servers: []osbuild.ChronyConfigServer{
|
||||
{
|
||||
|
|
@ -1153,7 +1153,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
"reboot.target",
|
||||
"tuned",
|
||||
},
|
||||
DefaultTarget: "multi-user.target",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
Sysconfig: []*osbuild.SysconfigStageOptions{
|
||||
{
|
||||
Kernel: &osbuild.SysconfigKernelOptions{
|
||||
|
|
@ -1559,7 +1559,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
}
|
||||
|
||||
defaultGceImageConfig := &distro.ImageConfig{
|
||||
Timezone: "UTC",
|
||||
Timezone: common.StringToPtr("UTC"),
|
||||
TimeSynchronization: &osbuild.ChronyStageOptions{
|
||||
Timeservers: []string{"metadata.google.internal"},
|
||||
},
|
||||
|
|
@ -1575,8 +1575,8 @@ func newDistro(distroName string) distro.Distro {
|
|||
"sshd-keygen@",
|
||||
"reboot.target",
|
||||
},
|
||||
DefaultTarget: "multi-user.target",
|
||||
Locale: "en_US.UTF-8",
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
Keyboard: &osbuild.KeymapStageOptions{
|
||||
Keymap: "us",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ func osPipeline(t *imageType,
|
|||
rpmOptions := osbuild.NewRPMStageOptions(repos)
|
||||
rpmOptions.GPGKeysFromTree = imageConfig.GPGKeyFiles
|
||||
|
||||
if imageConfig.ExcludeDocs {
|
||||
if imageConfig.ExcludeDocs != nil && *imageConfig.ExcludeDocs {
|
||||
if rpmOptions.Exclude == nil {
|
||||
rpmOptions.Exclude = &osbuild.Exclude{}
|
||||
}
|
||||
|
|
@ -453,8 +453,8 @@ func osPipeline(t *imageType,
|
|||
language, keyboard := c.GetPrimaryLocale()
|
||||
if language != nil {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: *language}))
|
||||
} else {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: imageConfig.Locale}))
|
||||
} else if imageConfig.Locale != nil {
|
||||
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: *imageConfig.Locale}))
|
||||
}
|
||||
if keyboard != nil {
|
||||
p.AddStage(osbuild.NewKeymapStage(&osbuild.KeymapStageOptions{Keymap: *keyboard}))
|
||||
|
|
@ -469,8 +469,8 @@ func osPipeline(t *imageType,
|
|||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
if timezone != nil {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{Zone: *timezone}))
|
||||
} else {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{Zone: imageConfig.Timezone}))
|
||||
} else if imageConfig.Timezone != nil {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{Zone: *imageConfig.Timezone}))
|
||||
}
|
||||
|
||||
if len(ntpServers) > 0 {
|
||||
|
|
@ -506,12 +506,16 @@ func osPipeline(t *imageType,
|
|||
}
|
||||
|
||||
if services := c.GetServices(); services != nil || imageConfig.EnabledServices != nil ||
|
||||
imageConfig.DisabledServices != nil || imageConfig.DefaultTarget != "" {
|
||||
imageConfig.DisabledServices != nil || imageConfig.DefaultTarget != nil {
|
||||
defaultTarget := ""
|
||||
if imageConfig.DefaultTarget != nil {
|
||||
defaultTarget = *imageConfig.DefaultTarget
|
||||
}
|
||||
p.AddStage(osbuild.NewSystemdStage(systemdStageOptions(
|
||||
imageConfig.EnabledServices,
|
||||
imageConfig.DisabledServices,
|
||||
services,
|
||||
imageConfig.DefaultTarget,
|
||||
defaultTarget,
|
||||
)))
|
||||
}
|
||||
|
||||
|
|
@ -688,7 +692,8 @@ func osPipeline(t *imageType,
|
|||
p.AddStage(osbuild.NewOscapRemediationStage(remediationOptions))
|
||||
}
|
||||
|
||||
if !imageConfig.NoSElinux {
|
||||
// Relabel the tree, unless the `NoSElinux` flag is explicitly set to `true`
|
||||
if imageConfig.NoSElinux == nil || imageConfig.NoSElinux != nil && !*imageConfig.NoSElinux {
|
||||
p.AddStage(osbuild.NewSELinuxStage(selinuxStageOptions(false)))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue