From 79a0d36bf4ccd72a44be6fb4aa28afc0f267e3fd Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Mon, 23 Jan 2023 20:32:09 +0100 Subject: [PATCH] distro/rhel7: move qcow2 image type definition to top of file Moved the qcow2 image type definition to the top of the file for consistency with the other image type files. Separated the default image config struct from the base image type definition to make it easier to read. --- internal/distro/rhel7/qcow2.go | 121 ++++++++++++++++----------------- 1 file changed, 60 insertions(+), 61 deletions(-) diff --git a/internal/distro/rhel7/qcow2.go b/internal/distro/rhel7/qcow2.go index 4ec016ae9..6ee43a0ea 100644 --- a/internal/distro/rhel7/qcow2.go +++ b/internal/distro/rhel7/qcow2.go @@ -10,6 +10,66 @@ import ( "github.com/osbuild/osbuild-composer/internal/rpmmd" ) +var qcow2ImgType = imageType{ + name: "qcow2", + filename: "disk.qcow2", + mimeType: "application/x-qemu-disk", + kernelOptions: "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto", + packageSets: map[string]packageSetFunc{ + buildPkgsKey: distroBuildPackageSet, + osPkgsKey: qcow2CommonPackageSet, + }, + defaultImageConfig: qcow2DefaultImgConfig, + bootable: true, + defaultSize: 10 * common.GibiByte, + pipelines: qcow2Pipelines, + buildPipelines: []string{"build"}, + payloadPipelines: []string{"os", "image", "qcow2"}, + exports: []string{"qcow2"}, + basePartitionTables: defaultBasePartitionTables, +} + +var qcow2DefaultImgConfig = &distro.ImageConfig{ + DefaultTarget: common.ToPtr("multi-user.target"), + Sysconfig: []*osbuild.SysconfigStageOptions{ + { + Kernel: &osbuild.SysconfigKernelOptions{ + UpdateDefault: true, + DefaultKernel: "kernel", + }, + Network: &osbuild.SysconfigNetworkOptions{ + Networking: true, + NoZeroConf: true, + }, + NetworkScripts: &osbuild.NetworkScriptsOptions{ + IfcfgFiles: map[string]osbuild.IfcfgFile{ + "eth0": { + Device: "eth0", + Bootproto: osbuild.IfcfgBootprotoDHCP, + OnBoot: common.ToPtr(true), + Type: osbuild.IfcfgTypeEthernet, + UserCtl: common.ToPtr(true), + PeerDNS: common.ToPtr(true), + IPv6Init: common.ToPtr(false), + }, + }, + }, + }, + }, + RHSMConfig: map[distro.RHSMSubscriptionStatus]*osbuild.RHSMStageOptions{ + distro.RHSMConfigNoSubscription: { + YumPlugins: &osbuild.RHSMStageOptionsDnfPlugins{ + ProductID: &osbuild.RHSMStageOptionsDnfPlugin{ + Enabled: false, + }, + SubscriptionManager: &osbuild.RHSMStageOptionsDnfPlugin{ + Enabled: false, + }, + }, + }, + }, +} + func qcow2CommonPackageSet(t *imageType) rpmmd.PackageSet { ps := rpmmd.PackageSet{ Include: []string{ @@ -92,64 +152,3 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti return pipelines, nil } - -var qcow2ImgType = imageType{ - name: "qcow2", - filename: "disk.qcow2", - mimeType: "application/x-qemu-disk", - kernelOptions: "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto", - packageSets: map[string]packageSetFunc{ - buildPkgsKey: distroBuildPackageSet, - osPkgsKey: qcow2CommonPackageSet, - }, - packageSetChains: map[string][]string{ - osPkgsKey: {osPkgsKey, blueprintPkgsKey}, - }, - defaultImageConfig: &distro.ImageConfig{ - DefaultTarget: common.ToPtr("multi-user.target"), - Sysconfig: []*osbuild.SysconfigStageOptions{ - { - Kernel: &osbuild.SysconfigKernelOptions{ - UpdateDefault: true, - DefaultKernel: "kernel", - }, - Network: &osbuild.SysconfigNetworkOptions{ - Networking: true, - NoZeroConf: true, - }, - NetworkScripts: &osbuild.NetworkScriptsOptions{ - IfcfgFiles: map[string]osbuild.IfcfgFile{ - "eth0": { - Device: "eth0", - Bootproto: osbuild.IfcfgBootprotoDHCP, - OnBoot: common.ToPtr(true), - Type: osbuild.IfcfgTypeEthernet, - UserCtl: common.ToPtr(true), - PeerDNS: common.ToPtr(true), - IPv6Init: common.ToPtr(false), - }, - }, - }, - }, - }, - RHSMConfig: map[distro.RHSMSubscriptionStatus]*osbuild.RHSMStageOptions{ - distro.RHSMConfigNoSubscription: { - YumPlugins: &osbuild.RHSMStageOptionsDnfPlugins{ - ProductID: &osbuild.RHSMStageOptionsDnfPlugin{ - Enabled: false, - }, - SubscriptionManager: &osbuild.RHSMStageOptionsDnfPlugin{ - Enabled: false, - }, - }, - }, - }, - }, - bootable: true, - defaultSize: 10 * common.GibiByte, - pipelines: qcow2Pipelines, - buildPipelines: []string{"build"}, - payloadPipelines: []string{"os", "image", "qcow2"}, - exports: []string{"qcow2"}, - basePartitionTables: defaultBasePartitionTables, -}