in groups/reconcile.go [403:433]
func (gc *GroupsConfig) Load(rootDir string, restrictions *RestrictionsConfig) error {
log.Printf("reading groups.yaml files recursively at %s", rootDir)
return filepath.Walk(rootDir, func(path string, info os.FileInfo, _ error) error {
if filepath.Base(path) == "groups.yaml" {
cleanPath := strings.Trim(strings.TrimPrefix(path, rootDir), string(filepath.Separator))
log.Printf("groups: %s", cleanPath)
var (
groupsConfigAtPath GroupsConfig
content []byte
err error
)
if content, err = ioutil.ReadFile(path); err != nil {
return fmt.Errorf("error reading groups config file %s: %w", path, err)
}
if err = yaml.Unmarshal(content, &groupsConfigAtPath); err != nil {
return fmt.Errorf("error parsing groups config at %s: %w", path, err)
}
r := restrictions.GetRestrictionForPath(path, rootDir)
mergedGroups, err := mergeGroups(gc.Groups, groupsConfigAtPath.Groups, r)
if err != nil {
return fmt.Errorf("couldn't merge groups: %w", err)
}
gc.Groups = mergedGroups
}
return nil
})
}