Validate bypass_actors actor_type, bypass_mode and actor_id
Allowed values from integrations/github 6.13.0 github_repository_ruleset: actor_id is required for RepositoryRole, Integration and User and rejected for Team (resolved from team), OrganizationAdmin, EnterpriseOwner and DeployKey.
This commit is contained in:
@@ -59,6 +59,26 @@ variable "ruleset" {
|
||||
error_message = "pull_request and required_status_checks are branch-only rules, not allowed on tag rulesets: ${join(", ", [for k, rs in var.ruleset : k if rs.target != "branch" && (rs.rules.pull_request != null || rs.rules.required_status_checks != null)])}."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = alltrue(flatten([for rs in var.ruleset : [for a in rs.bypass_actors : contains(["RepositoryRole", "Team", "Integration", "OrganizationAdmin", "DeployKey", "EnterpriseOwner", "User"], a.actor_type)]]))
|
||||
error_message = "bypass_actors actor_type must be RepositoryRole, Team, Integration, OrganizationAdmin, DeployKey, EnterpriseOwner or User: ${join(", ", flatten([for k, rs in var.ruleset : [for a in rs.bypass_actors : "${k}/${a.actor_type}" if !contains(["RepositoryRole", "Team", "Integration", "OrganizationAdmin", "DeployKey", "EnterpriseOwner", "User"], a.actor_type)]]))}."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = alltrue(flatten([for rs in var.ruleset : [for a in rs.bypass_actors : contains(["always", "pull_request", "exempt"], a.bypass_mode)]]))
|
||||
error_message = "bypass_actors bypass_mode must be always, pull_request or exempt: ${join(", ", flatten([for k, rs in var.ruleset : [for a in rs.bypass_actors : "${k}/${a.actor_type}/${a.bypass_mode}" if !contains(["always", "pull_request", "exempt"], a.bypass_mode)]]))}."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = alltrue(flatten([for rs in var.ruleset : [for a in rs.bypass_actors : a.actor_id != null if contains(["RepositoryRole", "Integration", "User"], a.actor_type)]]))
|
||||
error_message = "bypass_actors actor_id is required for RepositoryRole, Integration and User: ${join(", ", flatten([for k, rs in var.ruleset : [for a in rs.bypass_actors : "${k}/${a.actor_type}" if contains(["RepositoryRole", "Integration", "User"], a.actor_type) && a.actor_id == null]]))}."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = alltrue(flatten([for rs in var.ruleset : [for a in rs.bypass_actors : a.actor_id == null if !contains(["RepositoryRole", "Integration", "User"], a.actor_type)]]))
|
||||
error_message = "bypass_actors actor_id must not be set for Team (use team), OrganizationAdmin, EnterpriseOwner or DeployKey: ${join(", ", flatten([for k, rs in var.ruleset : [for a in rs.bypass_actors : "${k}/${a.actor_type}" if !contains(["RepositoryRole", "Integration", "User"], a.actor_type) && a.actor_id != null]]))}."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = alltrue(flatten([for rs in var.ruleset : [for a in rs.bypass_actors : (a.actor_type == "Team") == (a.team != null)]]))
|
||||
error_message = "bypass_actors team must be set exactly when actor_type is Team: ${join(", ", flatten([for k, rs in var.ruleset : [for a in rs.bypass_actors : "${k}/${a.actor_type}" if(a.actor_type == "Team") != (a.team != null)]]))}."
|
||||
|
||||
Reference in New Issue
Block a user