From 543a4630e20ed556817db85a68451e57313aff02 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Tue, 26 Aug 2025 11:59:56 +0200 Subject: [PATCH] fix: improve manual install argument handling (#940) --- internal/agent/install.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/internal/agent/install.go b/internal/agent/install.go index adfa6c3..798a1a0 100644 --- a/internal/agent/install.go +++ b/internal/agent/install.go @@ -115,6 +115,7 @@ func Install(sourceImgURL string, dir ...string) error { cc, err = config.Scan(collector.Directories(dir...), collector.Readers(strings.NewReader(cliConf)), collector.MergeBootLine) + if err == nil && cc.Install != nil && cc.Install.Auto { err = RunInstall(cc) if err != nil { @@ -380,15 +381,21 @@ func generateInstallConfForCLIArgs(sourceImageURL string) string { // generateInstallConfForManualCLIArgs creates a kairos configuration for flags passed via manual install func generateInstallConfForManualCLIArgs(device string, reboot, poweroff bool) string { - cfg := fmt.Sprintf(`install: - reboot: %t - poweroff: %t -`, reboot, poweroff) + // if no options were passed, return empty string + if !reboot && !poweroff && device == "" { + return "" + } + 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 != "" { - cfg += fmt.Sprintf(` - device: %s -`, device) + cfg += fmt.Sprintf(" device: %s\n", device) } return cfg }