]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/config/groups.go
config: use more explicit variable name in ResolveHostGroups()
[safcm/safcm.git] / cmd / safcm / config / groups.go
index 5f3f679f5a9bde9ec1368d3f705f08d313647094..c998fb8a96f44ed2d3f6db7bac7c153214465581 100644 (file)
@@ -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) {
@@ -86,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",
@@ -126,11 +128,10 @@ func LoadGroups(cfg *Config, hosts *Hosts) (map[string][]string, error) {
        return groups, nil
 }
 
-func ResolveHostGroups(host string,
-       groups map[string][]string,
+func ResolveHostGroups(host string, groups map[string][]string,
        detectedGroups []string) ([]string, error) {
 
-       const maxDepth = 100
+       const maxRecursionDepth = 100
 
        detectedGroupsMap := make(map[string]bool)
        for _, x := range detectedGroups {
@@ -142,7 +143,7 @@ func ResolveHostGroups(host string,
        // groups).
        var lookup func(string, int) bool
        lookup = func(group string, depth int) bool {
-               if depth > maxDepth {
+               if depth > maxRecursionDepth {
                        cycle = &group
                        return false
                }