mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-08-02 08:38:47 +00:00
Respect every way to set the upgrade entry
there are 3 ways: - cli arg: --recovery - cli arg: --boot-entry - config setting: upgrade.recovery: true We only checked the config setting Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
37bbaf32ce
commit
961e1ff9ae
@ -146,8 +146,8 @@ func generateUpgradeConfForCLIArgs(source, upgradeEntry string) (string, error)
|
|||||||
// have access to that yet, we just set both uri values which shouldn't matter
|
// have access to that yet, we just set both uri values which shouldn't matter
|
||||||
// anyway, the right one will be used later in the process.
|
// anyway, the right one will be used later in the process.
|
||||||
if source != "" {
|
if source != "" {
|
||||||
upgradeConfig.Upgrade.RecoverySystem.URI = source
|
upgradeConfig.Install.RecoverySystem.URI = source
|
||||||
upgradeConfig.Upgrade.System.URI = source
|
upgradeConfig.Install.System.URI = source
|
||||||
}
|
}
|
||||||
|
|
||||||
d, err := json.Marshal(upgradeConfig)
|
d, err := json.Marshal(upgradeConfig)
|
||||||
@ -238,12 +238,14 @@ func upgradeUki(source string, dirs []string, upgradeEntry string, strictValidat
|
|||||||
// ExtraConfigUpgrade is the struct that holds the upgrade options that come from flags and events
|
// ExtraConfigUpgrade is the struct that holds the upgrade options that come from flags and events
|
||||||
type ExtraConfigUpgrade struct {
|
type ExtraConfigUpgrade struct {
|
||||||
Upgrade struct {
|
Upgrade struct {
|
||||||
Entry string `json:"entry,omitempty"`
|
Entry string `json:"entry,omitempty"`
|
||||||
|
} `json:"upgrade,omitempty"`
|
||||||
|
Install struct {
|
||||||
RecoverySystem struct {
|
RecoverySystem struct {
|
||||||
URI string `json:"uri,omitempty"`
|
URI string `json:"uri,omitempty"`
|
||||||
} `json:"recovery-system,omitempty"`
|
} `json:"recovery-system,omitempty"`
|
||||||
System struct {
|
System struct {
|
||||||
URI string `json:"uri,omitempty"`
|
URI string `json:"uri,omitempty"`
|
||||||
} `json:"system,omitempty"`
|
} `json:"system,omitempty"`
|
||||||
} `json:"upgrade,omitempty"`
|
} `json:"install,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -334,11 +334,18 @@ func NewUpgradeSpec(cfg *Config) (*v1.UpgradeSpec, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deep look to see if upgrade.recovery == true in the config
|
// One way to set the entry is to use the cli arg "--recovery"
|
||||||
// if yes, we set the upgrade spec "Entry" to "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".
|
||||||
entry := ""
|
entry := ""
|
||||||
_, ok := cfg.Config["upgrade"]
|
_, ok := cfg.Config["upgrade"]
|
||||||
if ok {
|
if ok {
|
||||||
|
// check value from --recovery and --boot-entry
|
||||||
|
entry, _ = cfg.Config["upgrade"].(collector.Config)["entry"].(string)
|
||||||
|
// check for "upgrade.recovery: true" in the kairos config
|
||||||
_, ok = cfg.Config["upgrade"].(collector.Config)["recovery"]
|
_, ok = cfg.Config["upgrade"].(collector.Config)["recovery"]
|
||||||
if ok {
|
if ok {
|
||||||
if cfg.Config["upgrade"].(collector.Config)["recovery"].(bool) {
|
if cfg.Config["upgrade"].(collector.Config)["recovery"].(bool) {
|
||||||
|
@ -19,11 +19,12 @@ package elemental
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1"
|
|
||||||
"github.com/kairos-io/kairos-agent/v2/pkg/utils/fs"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1"
|
||||||
|
fsutils "github.com/kairos-io/kairos-agent/v2/pkg/utils/fs"
|
||||||
|
|
||||||
agentConfig "github.com/kairos-io/kairos-agent/v2/pkg/config"
|
agentConfig "github.com/kairos-io/kairos-agent/v2/pkg/config"
|
||||||
cnst "github.com/kairos-io/kairos-agent/v2/pkg/constants"
|
cnst "github.com/kairos-io/kairos-agent/v2/pkg/constants"
|
||||||
"github.com/kairos-io/kairos-agent/v2/pkg/partitioner"
|
"github.com/kairos-io/kairos-agent/v2/pkg/partitioner"
|
||||||
|
Loading…
Reference in New Issue
Block a user