fix: improve manual install argument handling (#940)

This commit is contained in:
Itxaka
2025-08-26 11:59:56 +02:00
committed by GitHub
parent 44594db812
commit 543a4630e2

View File

@@ -115,6 +115,7 @@ func Install(sourceImgURL string, dir ...string) error {
cc, err = config.Scan(collector.Directories(dir...), cc, err = config.Scan(collector.Directories(dir...),
collector.Readers(strings.NewReader(cliConf)), collector.Readers(strings.NewReader(cliConf)),
collector.MergeBootLine) collector.MergeBootLine)
if err == nil && cc.Install != nil && cc.Install.Auto { if err == nil && cc.Install != nil && cc.Install.Auto {
err = RunInstall(cc) err = RunInstall(cc)
if err != nil { if err != nil {
@@ -380,15 +381,21 @@ func generateInstallConfForCLIArgs(sourceImageURL string) string {
// generateInstallConfForManualCLIArgs creates a kairos configuration for flags passed via manual install // generateInstallConfForManualCLIArgs creates a kairos configuration for flags passed via manual install
func generateInstallConfForManualCLIArgs(device string, reboot, poweroff bool) string { func generateInstallConfForManualCLIArgs(device string, reboot, poweroff bool) string {
cfg := fmt.Sprintf(`install: // if no options were passed, return empty string
reboot: %t if !reboot && !poweroff && device == "" {
poweroff: %t return ""
`, reboot, poweroff) }
cfg := "install:\n"
// Only add those options if they are set to true, otherwise it gets the default values from the config
if reboot {
cfg += " reboot: true\n"
}
if poweroff {
cfg += " poweroff: true\n"
}
if device != "" { if device != "" {
cfg += fmt.Sprintf(` cfg += fmt.Sprintf(" device: %s\n", device)
device: %s
`, device)
} }
return cfg return cfg
} }