mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-16 14:40:28 +00:00
fix: improve manual install argument handling (#940)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user