X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm%2Fconfig%2Fgroups.go;h=a1dd83a0164267a0f24a351a74966fd108300323;hb=5d6cc7f14a4bacc36bf3a23cd735a75ad4a90f1d;hp=5af3be09990115740b0ed7f4e9c941b185b87477;hpb=4473e968425319e6beae558643bb047a6b01c17a;p=safcm%2Fsafcm.git diff --git a/cmd/safcm/config/groups.go b/cmd/safcm/config/groups.go index 5af3be0..a1dd83a 100644 --- a/cmd/safcm/config/groups.go +++ b/cmd/safcm/config/groups.go @@ -34,7 +34,7 @@ const ( GroupRemoveSuffix = GroupSpecialSeparator + "remove" ) -// Keep in sync with sync_info.go:infoGroupDetectedRegexp +// Keep in sync with cmd/safcm/sync_info.go:infoGroupDetectedRegexp var groupNameRegexp = regexp.MustCompile(`^[a-z0-9_-]+$`) func LoadGroups(cfg *Config, hosts *Hosts) (map[string][]string, error) { @@ -60,7 +60,9 @@ func LoadGroups(cfg *Config, hosts *Hosts) (map[string][]string, error) { "%s conflict with pre-defined group %q", errPrefix, name) } - if hosts.Map[name] != nil { + if hosts.Map[name] != nil || + hosts.Map[strings.TrimSuffix(name, + GroupRemoveSuffix)] != nil { return nil, fmt.Errorf( "%s conflict with existing host", errPrefix) @@ -84,6 +86,8 @@ func LoadGroups(cfg *Config, hosts *Hosts) (map[string][]string, error) { if x == GroupAll { continue } + // Don't validate against groupNameRegexp because + // hosts have less strict restrictions. if strings.Contains(x, GroupSpecialSeparator) { return nil, fmt.Errorf( "%s member %q must not contain %q", @@ -95,14 +99,14 @@ func LoadGroups(cfg *Config, hosts *Hosts) (map[string][]string, error) { if hosts.Map[x] != nil || groups[x] != nil { continue } - return nil, fmt.Errorf("%s group %q not found", + return nil, fmt.Errorf("%s member %q not found", errPrefix, x) } } // Sanity check for global configuration - for _, x := range cfg.GroupOrder { - const errPrefix = "config.yaml: group_order:" + for _, x := range cfg.GroupPriority { + const errPrefix = "config.yaml: group_priority:" if x == GroupAll { continue