Skip to content

Commit 7de3e8b

Browse files
mvo5supakeen
authored andcommitted
main: update for v0.177 API changes
This includes: - disk.ParitioningMode->parition.PartitioningMode - anaconda.AdditionalModules -> anaconda.EnabledModules - use of new InstallerCustomizations - aws uploader needs arch.Arch
1 parent 96ccef3 commit 7de3e8b

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

bib/cmd/bootc-image-builder/image.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/osbuild/images/pkg/customizations/kickstart"
2020
"github.com/osbuild/images/pkg/customizations/users"
2121
"github.com/osbuild/images/pkg/disk"
22+
"github.com/osbuild/images/pkg/disk/partition"
2223
"github.com/osbuild/images/pkg/image"
2324
"github.com/osbuild/images/pkg/manifest"
2425
"github.com/osbuild/images/pkg/osbuild"
@@ -132,10 +133,10 @@ func checkMountpoints(filesystems []blueprint.FilesystemCustomization, policy *p
132133
return nil
133134
}
134135

135-
func checkFilesystemCustomizations(fsCustomizations []blueprint.FilesystemCustomization, ptmode disk.PartitioningMode) error {
136+
func checkFilesystemCustomizations(fsCustomizations []blueprint.FilesystemCustomization, ptmode partition.PartitioningMode) error {
136137
var policy *pathpolicy.PathPolicies
137138
switch ptmode {
138-
case disk.BtrfsPartitioningMode:
139+
case partition.BtrfsPartitioningMode:
139140
// btrfs subvolumes are not supported at build time yet, so we only
140141
// allow / and /boot to be customized when building a btrfs disk (the
141142
// minimal policy)
@@ -327,9 +328,9 @@ func genPartitionTableFsCust(c *ManifestConfig, fsCust []blueprint.FilesystemCus
327328
return nil, fmt.Errorf("pipelines: no partition tables defined for %s", c.Architecture)
328329
}
329330

330-
partitioningMode := disk.RawPartitioningMode
331+
partitioningMode := partition.RawPartitioningMode
331332
if c.RootFSType == "btrfs" {
332-
partitioningMode = disk.BtrfsPartitioningMode
333+
partitioningMode = partition.BtrfsPartitioningMode
333334
}
334335
if err := checkFilesystemCustomizations(fsCust, partitioningMode); err != nil {
335336
return nil, err
@@ -523,7 +524,7 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro
523524
if c.Config != nil {
524525
customizations = c.Config.Customizations
525526
}
526-
img.FIPS = customizations.GetFIPS()
527+
img.InstallerCustomizations.FIPS = customizations.GetFIPS()
527528
img.Kickstart, err = kickstart.New(customizations)
528529
if err != nil {
529530
return nil, err
@@ -539,10 +540,10 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro
539540
return nil, err
540541
}
541542
if instCust != nil && instCust.Modules != nil {
542-
img.AdditionalAnacondaModules = append(img.AdditionalAnacondaModules, instCust.Modules.Enable...)
543-
img.DisabledAnacondaModules = append(img.DisabledAnacondaModules, instCust.Modules.Disable...)
543+
img.InstallerCustomizations.EnabledAnacondaModules = append(img.InstallerCustomizations.EnabledAnacondaModules, instCust.Modules.Enable...)
544+
img.InstallerCustomizations.DisabledAnacondaModules = append(img.InstallerCustomizations.DisabledAnacondaModules, instCust.Modules.Disable...)
544545
}
545-
img.AdditionalAnacondaModules = append(img.AdditionalAnacondaModules,
546+
img.InstallerCustomizations.EnabledAnacondaModules = append(img.InstallerCustomizations.EnabledAnacondaModules,
546547
anaconda.ModuleUsers,
547548
anaconda.ModuleServices,
548549
anaconda.ModuleSecurity,
@@ -551,7 +552,7 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro
551552
img.Kickstart.OSTree = &kickstart.OSTree{
552553
OSName: "default",
553554
}
554-
img.UseRHELLoraxTemplates = needsRHELLoraxTemplates(c.SourceInfo.OSRelease)
555+
img.InstallerCustomizations.UseRHELLoraxTemplates = needsRHELLoraxTemplates(c.SourceInfo.OSRelease)
555556

556557
switch c.Architecture {
557558
case arch.ARCH_X86_64:
@@ -562,7 +563,7 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro
562563
BIOS: true,
563564
UEFIVendor: c.SourceInfo.UEFIVendor,
564565
}
565-
img.ISOBoot = manifest.Grub2ISOBoot
566+
img.InstallerCustomizations.ISOBoot = manifest.Grub2ISOBoot
566567
case arch.ARCH_AARCH64:
567568
// aarch64 always uses UEFI, so let's enforce the vendor
568569
if c.SourceInfo.UEFIVendor == "" {
@@ -599,7 +600,7 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro
599600
return nil, fmt.Errorf("unsupported architecture %v", c.Architecture)
600601
}
601602
// see https://github.com/osbuild/bootc-image-builder/issues/733
602-
img.RootfsType = manifest.SquashfsRootfs
603+
img.InstallerCustomizations.ISORootfsType = manifest.SquashfsRootfs
603604
img.Filename = "install.iso"
604605

605606
installRootfsType, err := disk.NewFSType(c.RootFSType)

bib/cmd/bootc-image-builder/image_test.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/osbuild/images/pkg/arch"
1212
"github.com/osbuild/images/pkg/datasizes"
1313
"github.com/osbuild/images/pkg/disk"
14+
"github.com/osbuild/images/pkg/disk/partition"
1415
"github.com/osbuild/images/pkg/manifest"
1516
"github.com/osbuild/images/pkg/runner"
1617

@@ -64,7 +65,7 @@ func TestGetDistroAndRunner(t *testing.T) {
6465
func TestCheckFilesystemCustomizationsValidates(t *testing.T) {
6566
for _, tc := range []struct {
6667
fsCust []blueprint.FilesystemCustomization
67-
ptmode disk.PartitioningMode
68+
ptmode partition.PartitioningMode
6869
expectedErr string
6970
}{
7071
// happy
@@ -74,21 +75,21 @@ func TestCheckFilesystemCustomizationsValidates(t *testing.T) {
7475
},
7576
{
7677
fsCust: []blueprint.FilesystemCustomization{},
77-
ptmode: disk.BtrfsPartitioningMode,
78+
ptmode: partition.BtrfsPartitioningMode,
7879
expectedErr: "",
7980
},
8081
{
8182
fsCust: []blueprint.FilesystemCustomization{
8283
{Mountpoint: "/"}, {Mountpoint: "/boot"},
8384
},
84-
ptmode: disk.RawPartitioningMode,
85+
ptmode: partition.RawPartitioningMode,
8586
expectedErr: "",
8687
},
8788
{
8889
fsCust: []blueprint.FilesystemCustomization{
8990
{Mountpoint: "/"}, {Mountpoint: "/boot"},
9091
},
91-
ptmode: disk.BtrfsPartitioningMode,
92+
ptmode: partition.BtrfsPartitioningMode,
9293
expectedErr: "",
9394
},
9495
{
@@ -106,31 +107,31 @@ func TestCheckFilesystemCustomizationsValidates(t *testing.T) {
106107
{Mountpoint: "/"},
107108
{Mountpoint: "/ostree"},
108109
},
109-
ptmode: disk.RawPartitioningMode,
110+
ptmode: partition.RawPartitioningMode,
110111
expectedErr: "the following errors occurred while validating custom mountpoints:\npath \"/ostree\" is not allowed",
111112
},
112113
{
113114
fsCust: []blueprint.FilesystemCustomization{
114115
{Mountpoint: "/"},
115116
{Mountpoint: "/var"},
116117
},
117-
ptmode: disk.RawPartitioningMode,
118+
ptmode: partition.RawPartitioningMode,
118119
expectedErr: "the following errors occurred while validating custom mountpoints:\npath \"/var\" is not allowed",
119120
},
120121
{
121122
fsCust: []blueprint.FilesystemCustomization{
122123
{Mountpoint: "/"},
123124
{Mountpoint: "/var/data"},
124125
},
125-
ptmode: disk.BtrfsPartitioningMode,
126+
ptmode: partition.BtrfsPartitioningMode,
126127
expectedErr: "the following errors occurred while validating custom mountpoints:\npath \"/var/data\" is not allowed",
127128
},
128129
{
129130
fsCust: []blueprint.FilesystemCustomization{
130131
{Mountpoint: "/"},
131132
{Mountpoint: "/boot/"},
132133
},
133-
ptmode: disk.BtrfsPartitioningMode,
134+
ptmode: partition.BtrfsPartitioningMode,
134135
expectedErr: "the following errors occurred while validating custom mountpoints:\npath \"/boot/\" must be canonical",
135136
},
136137
{
@@ -139,7 +140,7 @@ func TestCheckFilesystemCustomizationsValidates(t *testing.T) {
139140
{Mountpoint: "/boot/"},
140141
{Mountpoint: "/opt"},
141142
},
142-
ptmode: disk.BtrfsPartitioningMode,
143+
ptmode: partition.BtrfsPartitioningMode,
143144
expectedErr: "the following errors occurred while validating custom mountpoints:\npath \"/boot/\" must be canonical\npath \"/opt\" is not allowed",
144145
},
145146
} {
@@ -202,7 +203,7 @@ func TestLocalMountpointPolicy(t *testing.T) {
202203

203204
for _, tc := range testCases {
204205
t.Run(tc.path, func(t *testing.T) {
205-
err := bib.CheckFilesystemCustomizations([]blueprint.FilesystemCustomization{{Mountpoint: tc.path}}, disk.RawPartitioningMode)
206+
err := bib.CheckFilesystemCustomizations([]blueprint.FilesystemCustomization{{Mountpoint: tc.path}}, partition.RawPartitioningMode)
206207
if err != nil && tc.allowed {
207208
t.Errorf("expected %s to be allowed, but got error: %v", tc.path, err)
208209
} else if err == nil && !tc.allowed {

bib/cmd/bootc-image-builder/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,17 @@ func handleAWSFlags(cmd *cobra.Command) (cloud.Uploader, error) {
379379
}
380380
bucketName, _ := cmd.Flags().GetString("aws-bucket")
381381
imageName, _ := cmd.Flags().GetString("aws-ami-name")
382-
targetArch, _ := cmd.Flags().GetString("target-arch")
382+
targetArchStr, _ := cmd.Flags().GetString("target-arch")
383383

384384
if !slices.Contains(imgTypes, "ami") {
385385
return nil, fmt.Errorf("aws flags set for non-ami image type (type is set to %s)", strings.Join(imgTypes, ","))
386386
}
387387

388388
// check as many permission prerequisites as possible before starting
389+
targetArch, err := arch.FromString(targetArchStr)
390+
if err != nil {
391+
return nil, err
392+
}
389393
uploaderOpts := &awscloud.UploaderOptions{
390394
TargetArch: targetArch,
391395
}

0 commit comments

Comments
 (0)