mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-04-27 11:21:44 +00:00
Split yip config dirs from user config dirs
as per the comment here: https://github.com/kairos-io/kairos-agent/pull/550#discussion_r1776759001 Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
99e8509065
commit
d618ff72f3
20
main.go
20
main.go
@ -198,7 +198,7 @@ See https://kairos.io/docs/upgrade/manual/ for documentation.
|
||||
}
|
||||
|
||||
return agent.Upgrade(source, c.Bool("force"),
|
||||
c.Bool("strict-validation"), constants.GetConfigScanDirs(),
|
||||
c.Bool("strict-validation"), constants.GetUserConfigDirs(),
|
||||
upgradeEntry, c.Bool("pre"),
|
||||
)
|
||||
},
|
||||
@ -327,7 +327,7 @@ E.g. kairos-agent install-bundle container:quay.io/kairos/kairos...
|
||||
Description: "Show the runtime configuration of the machine. It will scan the machine for all the configuration and will return the config file processed and found.",
|
||||
Aliases: []string{"c"},
|
||||
Action: func(c *cli.Context) error {
|
||||
config, err := agentConfig.Scan(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs)
|
||||
config, err := agentConfig.Scan(collector.Directories(constants.GetUserConfigDirs()...), collector.NoLogs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -346,7 +346,7 @@ E.g. kairos-agent install-bundle container:quay.io/kairos/kairos...
|
||||
Description: "WARNING this command will be deprecated in v3.2.0. Use `config` without a subcommand instead.\n\n Show the runtime configuration of the machine. It will scan the machine for all the configuration and will return the config file processed and found.",
|
||||
Aliases: []string{},
|
||||
Action: func(c *cli.Context) error {
|
||||
config, err := agentConfig.Scan(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs)
|
||||
config, err := agentConfig.Scan(collector.Directories(constants.GetUserConfigDirs()...), collector.NoLogs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -375,7 +375,7 @@ enabled: true`,
|
||||
Description: "It allows to navigate the YAML config file by searching with 'yq' style keywords as `config get k3s` to retrieve the k3s config block",
|
||||
Aliases: []string{"g"},
|
||||
Action: func(c *cli.Context) error {
|
||||
config, err := agentConfig.ScanNoLogs(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs, collector.StrictValidation(c.Bool("strict-validation")))
|
||||
config, err := agentConfig.ScanNoLogs(collector.Directories(constants.GetUserConfigDirs()...), collector.NoLogs, collector.StrictValidation(c.Bool("strict-validation")))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -446,7 +446,7 @@ enabled: true`,
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
|
||||
config, err := agentConfig.ScanNoLogs(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs, collector.StrictValidation(c.Bool("strict-validation")))
|
||||
config, err := agentConfig.ScanNoLogs(collector.Directories(constants.GetUserConfigDirs()...), collector.NoLogs, collector.StrictValidation(c.Bool("strict-validation")))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -556,7 +556,7 @@ This command is meant to be used from the boot GRUB menu, but can be started man
|
||||
Action: func(c *cli.Context) error {
|
||||
source := c.String("source")
|
||||
|
||||
return agent.Install(source, constants.GetConfigScanDirs()...)
|
||||
return agent.Install(source, constants.GetUserConfigDirs()...)
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -600,7 +600,7 @@ This command is meant to be used from the boot GRUB menu, but can likely be used
|
||||
unattended := c.Bool("unattended")
|
||||
resetOem := c.Bool("reset-oem")
|
||||
|
||||
return agent.Reset(reboot, unattended, resetOem, constants.GetConfigScanDirs()...)
|
||||
return agent.Reset(reboot, unattended, resetOem, constants.GetUserConfigDirs()...)
|
||||
},
|
||||
Usage: "Starts kairos reset mode",
|
||||
Description: `
|
||||
@ -684,7 +684,7 @@ The validate command expects a configuration file as its only argument. Local fi
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
stage := c.Args().First()
|
||||
config, err := agentConfig.Scan(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs)
|
||||
config, err := agentConfig.Scan(collector.Directories(constants.GetYipConfigDirs()...), collector.NoLogs)
|
||||
config.Strict = c.Bool("strict")
|
||||
|
||||
if len(c.StringSlice("cloud-init-paths")) > 0 {
|
||||
@ -730,7 +730,7 @@ The validate command expects a configuration file as its only argument. Local fi
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid path %s", destination)
|
||||
}
|
||||
config, err := agentConfig.Scan(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs)
|
||||
config, err := agentConfig.Scan(collector.Directories(constants.GetUserConfigDirs()...), collector.NoLogs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -784,7 +784,7 @@ The validate command expects a configuration file as its only argument. Local fi
|
||||
return checkRoot()
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
cfg, err := agentConfig.Scan(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs)
|
||||
cfg, err := agentConfig.Scan(collector.Directories(constants.GetUserConfigDirs()...), collector.NoLogs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -169,10 +169,16 @@ func GetGrubModules() []string {
|
||||
return []string{"loopback.mod", "squash4.mod", "xzio.mod", "gzio.mod", "regexp.mod"}
|
||||
}
|
||||
|
||||
func GetConfigScanDirs() []string {
|
||||
// GetYipConfigDirs returns all the directories where "yip" configuration might
|
||||
// live. These include the directories were we store our system overlay files:
|
||||
// https://github.com/kairos-io/packages/tree/main/packages/static/kairos-overlay-files/files/system/oem
|
||||
func GetYipConfigDirs() []string {
|
||||
return append(GetUserConfigDirs(), "/system/oem")
|
||||
}
|
||||
|
||||
func GetUserConfigDirs() []string {
|
||||
return []string{
|
||||
"/oem",
|
||||
"/system/oem",
|
||||
"/usr/local/cloud-config",
|
||||
"/run/initramfs/live",
|
||||
"/etc/kairos", // Default system configuration file https://github.com/kairos-io/kairos/issues/2221
|
||||
|
Loading…
Reference in New Issue
Block a user