mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-06-03 01:44:53 +00:00
Fix a small issue with common flag
Put it properly in the value instead of leaving the value empty. Also cleans a bit the target dir for sysext checking Signed-off-by: Itxaka <itxakaserrano@gmail.com>
This commit is contained in:
parent
e3d2a860d0
commit
3e9dbe4a61
14
main.go
14
main.go
@ -855,11 +855,15 @@ The validate command expects a configuration file as its only argument. Local fi
|
||||
}
|
||||
var bootState string
|
||||
|
||||
if c.Bool("active") {
|
||||
bootState = "active"
|
||||
}
|
||||
if c.Bool("passive") {
|
||||
bootState = "passive"
|
||||
for k, v := range map[string]bool{
|
||||
"active": c.Bool("active"),
|
||||
"passive": c.Bool("passive"),
|
||||
"common": c.Bool("common"),
|
||||
} {
|
||||
if v {
|
||||
bootState = k
|
||||
break
|
||||
}
|
||||
}
|
||||
out, err := action.ListSystemExtensions(cfg, bootState)
|
||||
if err != nil {
|
||||
|
@ -46,26 +46,25 @@ func (s *SysExtension) String() string {
|
||||
return s.Name
|
||||
}
|
||||
|
||||
|
||||
func dirFromBootState(bootState string) string {
|
||||
switch bootState {
|
||||
case "active":
|
||||
return sysextDirActive
|
||||
case "passive":
|
||||
return sysextDirPassive
|
||||
case "recovery":
|
||||
return sysextDirRecovery
|
||||
case "common":
|
||||
return sysextDirCommon
|
||||
default:
|
||||
return sysextDir
|
||||
}
|
||||
}
|
||||
// ListSystemExtensions lists the system extensions in the given directory
|
||||
// If none is passed then it shows the generic ones
|
||||
func ListSystemExtensions(cfg *config.Config, bootState string) ([]SysExtension, error) {
|
||||
switch bootState {
|
||||
case "active":
|
||||
cfg.Logger.Debug("Listing active system extensions")
|
||||
return getDirExtensions(cfg, sysextDirActive)
|
||||
case "passive":
|
||||
cfg.Logger.Debug("Listing passive system extensions")
|
||||
return getDirExtensions(cfg, sysextDirPassive)
|
||||
case "recovery":
|
||||
cfg.Logger.Debug("Listing recovery system extensions")
|
||||
return getDirExtensions(cfg, sysextDirRecovery)
|
||||
case "common":
|
||||
cfg.Logger.Debug("Listing common system extensions")
|
||||
return getDirExtensions(cfg, sysextDirCommon)
|
||||
default:
|
||||
cfg.Logger.Debug("Listing all system extensions (Enabled or not)")
|
||||
return getDirExtensions(cfg, sysextDir)
|
||||
}
|
||||
return getDirExtensions(cfg, dirFromBootState(bootState))
|
||||
}
|
||||
|
||||
// getDirExtensions lists the system extensions in the given directory
|
||||
@ -126,19 +125,7 @@ func EnableSystemExtension(cfg *config.Config, ext, bootState string, now bool)
|
||||
return err
|
||||
}
|
||||
|
||||
var targetDir string
|
||||
switch bootState {
|
||||
case "active":
|
||||
targetDir = sysextDirActive
|
||||
case "passive":
|
||||
targetDir = sysextDirPassive
|
||||
case "recovery":
|
||||
targetDir = sysextDirRecovery
|
||||
case "common":
|
||||
targetDir = sysextDirCommon
|
||||
default:
|
||||
return fmt.Errorf("boot state %s not supported", bootState)
|
||||
}
|
||||
targetDir := dirFromBootState(bootState)
|
||||
|
||||
// Check if the target dir exists and create it if it doesn't
|
||||
if _, err := cfg.Fs.Stat(targetDir); os.IsNotExist(err) {
|
||||
@ -194,19 +181,7 @@ func EnableSystemExtension(cfg *config.Config, ext, bootState string, now bool)
|
||||
// DisableSystemExtension disables a system extension that is already in the system for a given bootstate
|
||||
// It removes the symlink from the target dir according to the bootstate given
|
||||
func DisableSystemExtension(cfg *config.Config, ext string, bootState string, now bool) error {
|
||||
var targetDir string
|
||||
switch bootState {
|
||||
case "active":
|
||||
targetDir = sysextDirActive
|
||||
case "passive":
|
||||
targetDir = sysextDirPassive
|
||||
case "recovery":
|
||||
targetDir = sysextDirRecovery
|
||||
case "common":
|
||||
targetDir = sysextDirCommon
|
||||
default:
|
||||
return fmt.Errorf("boot state %s not supported", bootState)
|
||||
}
|
||||
targetDir := dirFromBootState(bootState)
|
||||
|
||||
// Check if the target dir exists
|
||||
if _, err := cfg.Fs.Stat(targetDir); os.IsNotExist(err) {
|
||||
|
Loading…
Reference in New Issue
Block a user