github-community-projects / github-community-projects/safe-settings

Creating multiple validators for a plugin not supported

Open
#328 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
921
Forks
226
Avg merge
18h 3m
Merged PRs (30d)
14

Description

## Problem Description

### What is actually happening

When defining multiple validators for one plugin, only one of the validators is taken into account.

The `deployment-settings.yml` allows to define multiple `configvalidators` and `overridevalidators for each plugin. But within the `settings.js` file, a dict is used which basically takes only the last validator of a plugin into account.

https://github.com/github/safe-settings/blob/045579288ff2444e3948584559f57a7f05ca5529/lib/settings.js#L62

### What is the expected behavior

It should be possible to define multiple validators for one plugin, like in the following example:

Example
```
overridevalidators:
- plugin: branches
error: |
`Branch protection required_approving_review_count cannot be overidden to a lower value`
script: |
console.log(`baseConfig ${JSON.stringify(baseconfig)}`)
console.log(`overrideConfig ${JSON.stringify(overrideconfig)}`)
if (baseconfig && overrideconfig && baseconfig.protection.required_pull_request_reviews.required_approving_review_count && overrideconfig.protection.required_pull_request_reviews.required_approving_review_count ) {
return overrideconfig.protection.required_pull_request_reviews.required_approving_review_count >= baseconfig.protection.required_pull_request_reviews.required_approving_review_count
}
return true

- plugin: branches
error: |
`Allow force pushes on default branch cannot be overridden`
script: |
console.log(`baseConfig ${JSON.stringify(baseconfig)}`)
console.log(`overrideConfig ${JSON.stringify(overrideconfig)}`)
if (overrideconfig && overrideconfig.protection) {
return overrideconfig.protection.allow_force_pushes != true
}
return true
```

### Error output, if available

## Context

### Are you using the hosted instance of probot/settings or running your own?
Self-hosted

### If running your own instance, are you using it with github.com or GitHub Enterprise?
GitHub.com

#### Version of probot/settings
2.0.17

#### Version of GitHub Enterprise

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.