1 // Config: parse config.yaml
3 // SPDX-License-Identifier: GPL-3.0-or-later
4 // Copyright (C) 2021-2024 Simon Ruderich
14 "ruderich.org/simon/safcm"
18 DryRun bool `yaml:"-"` // set via command line
19 Quiet bool `yaml:"-"` // set via command line
20 LogLevel safcm.LogLevel `yaml:"-"` // set via command line
21 SshConfig string `yaml:"-"` // set via command line
23 DetectGroups []string `yaml:"detect_groups"`
24 GroupPriority []string `yaml:"group_priority"`
26 SshUser string `yaml:"ssh_user"`
29 func LoadConfig() (*Config, error) {
30 const path = "config.yaml"
33 x, err := os.ReadFile(path)
35 // This file is optional
36 if os.IsNotExist(err) {
41 err = yaml.UnmarshalStrict(x, &cfg)
43 return nil, fmt.Errorf("%s: failed to load: %v", path, err)