mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-06-03 01:44:53 +00:00
Remove unecessary assignments and add NoFormat to UKI
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
d8df60c315
commit
571f10d900
@ -144,7 +144,6 @@ func (i InstallAction) Run() (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check no-format flag
|
||||
if i.spec.NoFormat {
|
||||
i.cfg.Logger.Infof("NoFormat is true, skipping format and partitioning")
|
||||
// Check force flag against current device
|
||||
@ -153,7 +152,9 @@ func (i InstallAction) Run() (err error) {
|
||||
return fmt.Errorf("use `force` flag to run an installation over the current running deployment")
|
||||
}
|
||||
|
||||
if i.spec.Target == "" {
|
||||
if i.spec.Target == "" || i.spec.Target == "auto" {
|
||||
// This needs to run after the pre-install stage to give the user the
|
||||
// opportunity to prepare the target disk in the pre-install stage.
|
||||
device, err := config.DetectPreConfiguredDevice(i.cfg.Logger)
|
||||
if err != nil {
|
||||
return fmt.Errorf("no target device specified and no device found: %s", err)
|
||||
|
@ -567,26 +567,10 @@ func ReadInstallSpecFromConfig(c *Config) (*v1.InstallSpec, error) {
|
||||
}
|
||||
installSpec := sp.(*v1.InstallSpec)
|
||||
|
||||
// TODO: Do the same for UKI
|
||||
if installSpec.Target == "" || installSpec.Target == "auto" {
|
||||
if (installSpec.Target == "" || installSpec.Target == "auto") && !installSpec.NoFormat {
|
||||
installSpec.Target = detectLargestDevice()
|
||||
}
|
||||
|
||||
if installSpec.NoFormat {
|
||||
installSpec.Target = ""
|
||||
}
|
||||
|
||||
// Workaround!
|
||||
// If we set the "auto" for the device in the cloudconfig the value will be proper in the Config.Install.Device
|
||||
// But on the cloud-config it will still appear as "auto" as we dont modify that
|
||||
// Unfortunately as we load the full cloud-config and unmarshall it into our spec, we cannot infer from there
|
||||
// What device was choosen, and re-choosing again could lead to different results
|
||||
// So instead we do the check here and override the installSpec.Target with the Config.Install.Device
|
||||
// as its the soonest we have access to both
|
||||
if installSpec.Target == "auto" {
|
||||
installSpec.Target = c.Install.Device
|
||||
}
|
||||
|
||||
return installSpec, nil
|
||||
}
|
||||
|
||||
@ -678,15 +662,8 @@ func ReadUkiInstallSpecFromConfig(c *Config) (*v1.InstallUkiSpec, error) {
|
||||
}
|
||||
installSpec := sp.(*v1.InstallUkiSpec)
|
||||
|
||||
// Workaround!
|
||||
// If we set the "auto" for the device in the cloudconfig the value will be proper in the Config.Install.Device
|
||||
// But on the cloud-config it will still appear as "auto" as we dont modify that
|
||||
// Unfortunately as we load the full cloud-config and unmarshall it into our spec, we cannot infer from there
|
||||
// What device was choosen, and re-choosing again could lead to different results
|
||||
// So instead we do the check here and override the installSpec.Target with the Config.Install.Device
|
||||
// as its the soonest we have access to both
|
||||
if installSpec.Target == "auto" {
|
||||
installSpec.Target = c.Install.Device
|
||||
if (installSpec.Target == "" || installSpec.Target == "auto") && !installSpec.NoFormat {
|
||||
installSpec.Target = detectLargestDevice()
|
||||
}
|
||||
|
||||
return installSpec, nil
|
||||
|
@ -510,6 +510,7 @@ type InstallUkiSpec struct {
|
||||
PowerOff bool `yaml:"poweroff,omitempty" mapstructure:"poweroff"`
|
||||
Partitions ElementalPartitions `yaml:"partitions,omitempty" mapstructure:"partitions"`
|
||||
ExtraPartitions PartitionList `yaml:"extra-partitions,omitempty" mapstructure:"extra-partitions"`
|
||||
NoFormat bool `yaml:"no-format,omitempty" mapstructure:"no-format"`
|
||||
CloudInit []string `yaml:"cloud-init,omitempty" mapstructure:"cloud-init"`
|
||||
SkipEntries []string `yaml:"skip-entries,omitempty" mapstructure:"skip-entries"`
|
||||
}
|
||||
|
@ -40,17 +40,32 @@ func (i *InstallAction) Run() (err error) {
|
||||
i.cfg.Logger.Errorf("running kairos-uki-install.pre hook script: %s", err.Error())
|
||||
}
|
||||
|
||||
// Deactivate any active volume on target
|
||||
err = e.DeactivateDevices()
|
||||
if err != nil {
|
||||
i.cfg.Logger.Errorf("deactivating devices: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
// Partition device
|
||||
err = e.PartitionAndFormatDevice(i.spec)
|
||||
if err != nil {
|
||||
i.cfg.Logger.Errorf("partitioning and formating devices: %s", err.Error())
|
||||
return err
|
||||
if i.spec.NoFormat {
|
||||
i.cfg.Logger.Infof("NoFormat is true, skipping format and partitioning")
|
||||
if i.spec.Target == "" || i.spec.Target == "auto" {
|
||||
// This needs to run after the pre-install stage to give the user the
|
||||
// opportunity to prepare the target disk in the pre-install stage.
|
||||
device, err := config.DetectPreConfiguredDevice(i.cfg.Logger)
|
||||
if err != nil {
|
||||
return fmt.Errorf("no target device specified and no device found: %s", err)
|
||||
}
|
||||
i.cfg.Logger.Infof("No target device specified, using pre-configured device: %s", device)
|
||||
i.spec.Target = device
|
||||
}
|
||||
} else {
|
||||
// Deactivate any active volume on target
|
||||
err = e.DeactivateDevices()
|
||||
if err != nil {
|
||||
i.cfg.Logger.Errorf("deactivating devices: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
// Partition device
|
||||
err = e.PartitionAndFormatDevice(i.spec)
|
||||
if err != nil {
|
||||
i.cfg.Logger.Errorf("partitioning and formating devices: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = e.MountPartitions(i.spec.GetPartitions().PartitionsByMountPoint(false))
|
||||
|
Loading…
Reference in New Issue
Block a user