Skip to content

Commit

Permalink
[uki] improve spec load and spec generation
Browse files Browse the repository at this point in the history
load the uki spec from the same key in the config that normal actions
generate proper disk spec for uki install

Signed-off-by: Itxaka <[email protected]>
  • Loading branch information
Itxaka committed Sep 19, 2023
1 parent 9121336 commit 6a0827f
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions pkg/config/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,37 +475,30 @@ func NewUkiInstallSpec(cfg *Config) *v1.InstallUkiSpec {
}

// Calculate the partitions afterwards so they use the image sizes for the final partition sizes
spec.Partitions = NewUkiInstallElementalPartitions(spec)

return spec
}

func NewUkiInstallElementalPartitions(spec *v1.InstallUkiSpec) v1.ElementalPartitions {
pt := v1.ElementalPartitions{}
pt.EFI = &v1.Partition{
spec.Partitions.BIOS = &v1.Partition{
FilesystemLabel: constants.EfiLabel,
Size: constants.ImgSize, // TODO: Fix this
Size: constants.ImgSize, // TODO: Fix this and set proper size based on the source size
Name: constants.EfiPartName,
FS: "fat32",
FS: constants.EfiFs,
}
pt.OEM = &v1.Partition{
spec.Partitions.OEM = &v1.Partition{
FilesystemLabel: constants.OEMLabel,
Size: constants.OEMSize,
Name: constants.OEMPartName,
FS: constants.LinuxFs,
MountPoint: constants.OEMDir,
Flags: []string{},
}

pt.Persistent = &v1.Partition{
spec.Partitions.Persistent = &v1.Partition{
FilesystemLabel: constants.PersistentLabel,
Size: constants.PersistentSize,
Name: constants.PersistentPartName,
FS: constants.LinuxFs,
MountPoint: constants.PersistentDir,
Flags: []string{},
}
return pt

return spec
}

// ReadUkiInstallSpecFromConfig will return a proper v1.InstallUkiSpec based on an agent Config
Expand Down Expand Up @@ -614,7 +607,8 @@ func ReadSpecFromCloudConfig(r *Config, spec string) (v1.Spec, error) {
}
viper.SetConfigType("yaml")
viper.ReadConfig(strings.NewReader(ccString))
vp := viper.Sub(spec)
// Change the spec into normal spec without the '-uki' so we load the same vars from the config as the normal actions
vp := viper.Sub(strings.ReplaceAll(spec, "-uki", ""))
if vp == nil {
vp = viper.New()
}
Expand Down

0 comments on commit 6a0827f

Please sign in to comment.