mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-08-02 08:38:47 +00:00
Remove unecessary handling of config
As described here: https://github.com/kairos-io/kairos-agent/pull/499/files#r1735245329 the `unmarshallFullSpec` will take care of the `upgrade.entry` config so no need to handle it twice. Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
f9b6a529f3
commit
88c1e93d71
@ -324,7 +324,18 @@ func NewUpgradeSpec(cfg *Config) (*v1.UpgradeSpec, error) {
|
||||
}
|
||||
}
|
||||
|
||||
entry := findUpgradeEntryFromConfig(cfg)
|
||||
// Deep look to see if upgrade.recovery == true in the config
|
||||
// if yes, we set the upgrade spec "Entry" to "recovery"
|
||||
entry := ""
|
||||
_, ok := cfg.Config["upgrade"]
|
||||
if ok {
|
||||
_, ok = cfg.Config["upgrade"].(collector.Config)["recovery"]
|
||||
if ok {
|
||||
if cfg.Config["upgrade"].(collector.Config)["recovery"].(bool) {
|
||||
entry = constants.BootEntryRecovery
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spec := &v1.UpgradeSpec{
|
||||
Entry: entry,
|
||||
@ -1015,28 +1026,3 @@ func DetectPreConfiguredDevice(logger sdkTypes.KairosLogger) (string, error) {
|
||||
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// findUpgradeEntryFromConfig checks the passed config for one of the following ways
|
||||
// to set the upgrade entry.
|
||||
// - One way is to use the cli arg "--recovery" which makes config.upgrade.entry be "recovery"
|
||||
// - Another way is by setting the cli arg "boot-entry" which set it to the specified value.
|
||||
// - Lastly, user can set "upgrade.recovery: true" in the kairos config, which should result in entry being "recovery".
|
||||
func findUpgradeEntryFromConfig(cfg *Config) string {
|
||||
if _, ok := cfg.Config["upgrade"]; !ok {
|
||||
return ""
|
||||
}
|
||||
|
||||
// check value from --recovery and --boot-entry
|
||||
if entryIface, ok := cfg.Config["upgrade"].(collector.Config)["entry"]; ok {
|
||||
return entryIface.(string)
|
||||
}
|
||||
|
||||
// check for "upgrade.recovery: true" in the kairos config
|
||||
if _, ok := cfg.Config["upgrade"].(collector.Config)["recovery"]; ok {
|
||||
if cfg.Config["upgrade"].(collector.Config)["recovery"].(bool) {
|
||||
return constants.BootEntryRecovery
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user