in asfyaml/feature/github/deployment_environments.py [0:0]
def _validate_environment_configs(environments: Mapping[str, Any]) -> Mapping[str, list[str]]:
config_errors = {}
for env, env_config in environments.items():
env_errors = []
wait_timer = env_config.get("wait_timer")
if wait_timer is not None and wait_timer not in range(0, 43200):
env_errors.append("wait_timer must be between 0 and 43200")
required_reviewers = env_config.get("required_reviewers")
if required_reviewers is not None:
if len(required_reviewers) > 6:
env_errors.append("required_reviewers cannot contain more than 6 reviewers")
for reviewer in required_reviewers:
if reviewer["type"] not in ("User", "Team"):
reviewer_id = reviewer.get("id")
env_errors.append(
f"required_reviewer with id '{reviewer_id}' must have type of either 'User' or 'Team'"
)
deployment_branch_policy = env_config.get("deployment_branch_policy")
if deployment_branch_policy is not None:
protected_branches = deployment_branch_policy.get("protected_branches")
policies = deployment_branch_policy.get("policies", [])
if protected_branches and len(policies) > 0:
env_errors.append("protected_branches and policies cannot be enabled at the same time")
if not protected_branches and len(policies) == 0:
env_errors.append(
"either protected_branches or policies must be enabled when specifying a deployment branch policy"
)
for policy in policies:
if policy["type"] not in ("branch", "tag"):
env_errors.append(
f"deployment branch policy with name '{policy['name']}' must have type of either 'branch' or 'tag'"
)
if len(env_errors) > 0:
config_errors[env] = env_errors
return config_errors