cncf / sheriff

Controls and monitors organization permissions across GitHub, Slack and GSuite. Built with ❤️ by The Electron Team

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a PR validation check to block invalid config.yaml

RobertKielty opened this issue · comments

Sheriff uses joi for validation of the config.yaml

Example throwing a data validation error
For the following team...

- name: cncf-tech-docs
    members:
      - nate-double-u
      - amye
      - caniszczyk
      - chalin
      - idvoretskyi
      - thisisobate
    

from ...
validateConfigFast around a required maintainers field.

we get the error ...

Error [ValidationError]: child "teams" fails because ["teams" at position 0 fails because [child "maintainers" fails because ["maintainers" is required]]]

run.ts

https://github.com/cncf/sheriff/blob/main/src/permissions/run.ts#L58 now

run.ts

Schema for teams is hard-coded here

src/permissions/run.ts#L91

  // Ensure the object looks right
  await Joi.validate(config, {
    organization: Joi.string().min(1).required(),
    repository_defaults: Joi.object({
      has_wiki: Joi.boolean().required(),
    }).required(),
    teams: Joi.array()
      .items({
        name: Joi.string().min(1).required(),
        displayName: Joi.string().min(1).optional(),
        parent: Joi.string().min(1).optional(),
        secret: Joi.bool().optional(),
        members: Joi.array().items(Joi.string().min(1)).min(0).required(),
        maintainers: Joi.array().items(Joi.string().min(1)).min(1).required(),
        gsuite: Joi.object({
          privacy: Joi.string().only('internal', 'external').required(),
        }).optional(),
        slack: Joi.string().min(1).allow(true).allow(false).optional(),
      })
      .required(),

Let's add this as a check so that we get that validation before the PR is merged on cncf/people

Looks like this is already in place but it is not running to completion

https://github.com/cncf/people/actions/runs/4499716045/jobs/7917924965?pr=150

Closing.