mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-17 07:17:41 +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...),
|
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
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user