mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-06-03 01:44:53 +00:00
Add a scanner for config with nulllogger (#262)
To create a new config but discards the logs Signed-off-by: Itxaka <itxaka@kairos.io>
This commit is contained in:
parent
4a5a3e9bd0
commit
4e264a13b7
2
main.go
2
main.go
@ -351,7 +351,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.Scan(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs, collector.StrictValidation(c.Bool("strict-validation")))
|
||||
config, err := agentConfig.ScanNoLogs(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs, collector.StrictValidation(c.Bool("strict-validation")))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -329,10 +329,22 @@ func FilterKeys(d []byte) ([]byte, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func Scan(opts ...collector.Option) (c *Config, err error) {
|
||||
// Init new config with some default options
|
||||
result := NewConfig()
|
||||
// ScanNoLogs is a wrapper around Scan that sets the logger to null
|
||||
func ScanNoLogs(opts ...collector.Option) (c *Config, err error) {
|
||||
log := sdkTypes.NewNullLogger()
|
||||
result := NewConfig(WithLogger(log))
|
||||
return scan(result, opts...)
|
||||
}
|
||||
|
||||
// Scan is a wrapper around collector.Scan that sets the logger to the default Kairos logger
|
||||
func Scan(opts ...collector.Option) (c *Config, err error) {
|
||||
result := NewConfig()
|
||||
return scan(result, opts...)
|
||||
}
|
||||
|
||||
// scan is the internal function that does the actual scanning of the configs
|
||||
func scan(result *Config, opts ...collector.Option) (c *Config, err error) {
|
||||
// Init new config with some default options
|
||||
o := &collector.Options{}
|
||||
if err := o.Apply(opts...); err != nil {
|
||||
return result, err
|
||||
|
Loading…
Reference in New Issue
Block a user