func()

in dev/codeowners/codeowners.go [172:209]


func (codeowners *githubOwners) checkManifest(path string) error {
	pkgDir := filepath.Dir(path)
	owners, found := codeowners.owners["/"+pkgDir]
	if !found {
		return fmt.Errorf("there is no owner for %q in %q", pkgDir, codeowners.path)
	}

	content, err := os.ReadFile(path)
	if err != nil {
		return err
	}

	var manifest struct {
		Owner struct {
			Github string `yaml:"github"`
		} `yaml:"owner"`
	}
	err = yaml.Unmarshal(content, &manifest)
	if err != nil {
		return err
	}

	if manifest.Owner.Github == "" {
		return fmt.Errorf("no owner specified in %q", path)
	}

	found = false
	for _, owner := range owners {
		if owner == "@"+manifest.Owner.Github {
			found = true
			break
		}
	}
	if !found {
		return fmt.Errorf("owner %q defined in %q is not in %q", manifest.Owner.Github, path, codeowners.path)
	}
	return nil
}