From 268da1add3b94fdf73cb09d89309977381308128 Mon Sep 17 00:00:00 2001 From: Alberto Morgante Medina Date: Wed, 8 Nov 2023 11:55:04 +0100 Subject: [PATCH] modify platform openstack --- pkg/build/raw.go | 2 ++ pkg/build/scripts/modify-raw-image.sh.tpl | 3 +++ pkg/config/image.go | 9 +++++++-- pkg/config/image_test.go | 1 + pkg/config/testdata/valid_example.yaml | 2 ++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/build/raw.go b/pkg/build/raw.go index 6355ed10..a7c33d9d 100644 --- a/pkg/build/raw.go +++ b/pkg/build/raw.go @@ -51,9 +51,11 @@ func (b *Builder) writeModifyScript() error { values := struct { OutputImage string CombustionDir string + Platform string }{ OutputImage: b.generateOutputImageFilename(), CombustionDir: b.combustionDir, + Platform: b.imageConfig.OperatingSystem.Platform, } writtenFilename, err := b.writeBuildDirFile(modifyScriptName, modifyRawImageScript, &values) diff --git a/pkg/build/scripts/modify-raw-image.sh.tpl b/pkg/build/scripts/modify-raw-image.sh.tpl index ab715982..23f3609c 100644 --- a/pkg/build/scripts/modify-raw-image.sh.tpl +++ b/pkg/build/scripts/modify-raw-image.sh.tpl @@ -24,7 +24,10 @@ set -euo pipefail # - Resets the filesystem to read only guestfish --rw -a {{.OutputImage}} -i <<'EOF' + download /boot/grub2/grub.cfg /tmp/grub.cfg + ! sed -i 's/ignition.platform.id=metal/ignition.platform.id={{.Platform}}/' /tmp/grub.cfg sh "btrfs property set / ro false" + upload /tmp/grub.cfg /boot/grub2/grub.cfg copy-in {{.CombustionDir}} / sh "btrfs filesystem label / INSTALL" sh "btrfs property set / ro true" diff --git a/pkg/config/image.go b/pkg/config/image.go index 3547e62d..48ba9a9a 100644 --- a/pkg/config/image.go +++ b/pkg/config/image.go @@ -12,8 +12,13 @@ const ( ) type ImageConfig struct { - APIVersion string `yaml:"apiVersion"` - Image Image `yaml:"image"` + APIVersion string `yaml:"apiVersion"` + Image Image `yaml:"image"` + OperatingSystem OperatingSystem `yaml:"operatingSystem"` +} + +type OperatingSystem struct { + Platform string `yaml:"platform"` } type Image struct { diff --git a/pkg/config/image_test.go b/pkg/config/image_test.go index 883201b2..bde300b1 100644 --- a/pkg/config/image_test.go +++ b/pkg/config/image_test.go @@ -22,6 +22,7 @@ func TestParse(t *testing.T) { assert.Equal(t, "1.0", imageConfig.APIVersion) assert.Equal(t, "iso", imageConfig.Image.ImageType) assert.Equal(t, "slemicro5.5.iso", imageConfig.Image.BaseImage) + assert.Equal(t, "openstack", imageConfig.OperatingSystem.Platform) assert.Equal(t, "eibimage.iso", imageConfig.Image.OutputImageName) } diff --git a/pkg/config/testdata/valid_example.yaml b/pkg/config/testdata/valid_example.yaml index 3f59a8f8..1904dc78 100644 --- a/pkg/config/testdata/valid_example.yaml +++ b/pkg/config/testdata/valid_example.yaml @@ -3,3 +3,5 @@ image: imageType: iso baseImage: slemicro5.5.iso outputImageName: eibimage.iso +operatingSystem: + platform: openstack