Skip to content

Creating multiple validators for a plugin not supported #328

@martinm82

Description

@martinm82

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.

this.overridevalidators[validator.plugin] = { canOverride: f, error: validator.error }

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions