Skip to content

Commit

Permalink
fix: refactor BranchProtectionRule to have a common schema for the …
Browse files Browse the repository at this point in the history
…different rule types (#696)
  • Loading branch information
wolfy1339 committed Aug 17, 2022
1 parent f0a02ae commit 25f4b0a
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@
"admin_enforced": {
"type": "object",
"required": ["from"],
"properties": { "from": { "type": "boolean" } },
"properties": {
"from": {
"$ref": "common/branch-protection-rule-boolean.schema.json"
}
},
"additionalProperties": false
},
"allow_deletions_enforcement_level": {
"type": "object",
"required": ["from"],
"properties": {
"from": {
"type": ["string", "null"],
"enum": ["off", "non_admins", "everyone"]
"oneOf": [
{
"$ref": "common/branch-protection-rule-enforcement-level.schema.json"
},
{ "type": "null" }
]
}
},
"additionalProperties": false
Expand All @@ -33,68 +41,90 @@
"required": ["from"],
"properties": {
"from": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "common/branch-protection-rule-enforcement-level.schema.json"
}
},
"additionalProperties": false
},
"authorized_actors_only": {
"type": "object",
"required": ["from"],
"properties": { "from": { "type": "boolean" } },
"properties": {
"from": {
"$ref": "common/branch-protection-rule-boolean.schema.json"
}
},
"additionalProperties": false
},
"authorized_actor_names": {
"type": "object",
"required": ["from"],
"properties": {
"from": { "type": "array", "items": { "type": "string" } }
"from": {
"$ref": "common/branch-protection-rule-array.schema.json"
}
},
"additionalProperties": false
},
"authorized_dismissal_actors_only": {
"type": "object",
"required": ["from"],
"properties": { "from": { "type": ["boolean", "null"] } },
"properties": {
"from": {
"oneOf": [
{ "$ref": "common/branch-protection-rule-boolean.schema.json" },
{ "type": "null" }
]
}
},
"additionalProperties": false
},
"dismiss_stale_reviews_on_push": {
"type": "object",
"required": ["from"],
"properties": { "from": { "type": "boolean" } },
"properties": {
"from": {
"$ref": "common/branch-protection-rule-boolean.schema.json"
}
},
"additionalProperties": false
},
"pull_request_reviews_enforcement_level": {
"type": "object",
"required": ["from"],
"properties": {
"from": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "common/branch-protection-rule-enforcement-level.schema.json"
}
},
"additionalProperties": false
},
"require_code_owner_review": {
"type": "object",
"required": ["from"],
"properties": { "from": { "type": ["boolean"] } },
"properties": {
"from": {
"$ref": "common/branch-protection-rule-boolean.schema.json"
}
},
"additionalProperties": false
},
"required_approving_review_count": {
"type": "object",
"required": ["from"],
"properties": { "from": { "type": "integer" } },
"properties": {
"from": {
"$ref": "common/branch-protection-rule-number.schema.json"
}
},
"additionalProperties": false
},
"required_conversation_resolution_level": {
"type": "object",
"required": ["from"],
"properties": {
"from": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "common/branch-protection-rule-enforcement-level.schema.json"
}
},
"additionalProperties": false
Expand All @@ -104,8 +134,7 @@
"required": ["from"],
"properties": {
"from": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "common/branch-protection-rule-enforcement-level.schema.json"
}
},
"additionalProperties": false
Expand All @@ -114,7 +143,9 @@
"type": "object",
"required": ["from"],
"properties": {
"from": { "type": "array", "items": { "type": "string" } }
"from": {
"$ref": "common/branch-protection-rule-array.schema.json"
}
},
"additionalProperties": false
},
Expand All @@ -123,8 +154,7 @@
"required": ["from"],
"properties": {
"from": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "common/branch-protection-rule-enforcement-level.schema.json"
}
},
"additionalProperties": false
Expand All @@ -134,8 +164,7 @@
"required": ["from"],
"properties": {
"from": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "common/branch-protection-rule-enforcement-level.schema.json"
}
},
"additionalProperties": false
Expand All @@ -145,8 +174,7 @@
"required": ["from"],
"properties": {
"from": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "common/branch-protection-rule-enforcement-level.schema.json"
}
},
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "common/branch-protection-rule-array.schema.json",
"type": "array",
"items": { "type": "string" },
"title": "Branch Protection Rule Array"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "common/branch-protection-rule-boolean.schema.json",
"type": "boolean",
"title": "Branch protection rule boolean"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "common/branch-protection-rule-enforcement-level.schema.json",
"type": "string",
"enum": ["off", "non_admins", "everyone"],
"title": "Branch protection rule enforcement level"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "common/branch-protection-rule-number.schema.json",
"type": "integer",
"title": "Branch protection rule number"
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,55 +36,65 @@
"created_at": { "type": "string", "format": "date-time" },
"updated_at": { "type": "string", "format": "date-time" },
"pull_request_reviews_enforcement_level": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
},
"required_approving_review_count": { "type": "integer" },
"dismiss_stale_reviews_on_push": { "type": "boolean" },
"require_code_owner_review": { "type": "boolean" },
"authorized_dismissal_actors_only": { "type": "boolean" },
"ignore_approvals_from_contributors": { "type": "boolean" },
"$ref": "branch-protection-rule-enforcement-level.schema.json"
},
"required_approving_review_count": {
"$ref": "branch-protection-rule-number.schema.json"
},
"dismiss_stale_reviews_on_push": {
"$ref": "branch-protection-rule-boolean.schema.json"
},
"require_code_owner_review": {
"$ref": "branch-protection-rule-boolean.schema.json"
},
"authorized_dismissal_actors_only": {
"$ref": "branch-protection-rule-boolean.schema.json"
},
"ignore_approvals_from_contributors": {
"$ref": "branch-protection-rule-boolean.schema.json"
},
"required_status_checks": {
"type": "array",
"items": { "type": "string" }
"$ref": "branch-protection-rule-array.schema.json"
},
"required_status_checks_enforcement_level": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "branch-protection-rule-enforcement-level.schema.json"
},
"strict_required_status_checks_policy": {
"$ref": "branch-protection-rule-boolean.schema.json"
},
"strict_required_status_checks_policy": { "type": "boolean" },
"signature_requirement_enforcement_level": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "branch-protection-rule-enforcement-level.schema.json"
},
"linear_history_requirement_enforcement_level": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "branch-protection-rule-enforcement-level.schema.json"
},
"admin_enforced": {
"$ref": "branch-protection-rule-boolean.schema.json"
},
"create_protected": {
"$ref": "branch-protection-rule-boolean.schema.json"
},
"admin_enforced": { "type": "boolean" },
"create_protected": { "type": "boolean" },
"allow_force_pushes_enforcement_level": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "branch-protection-rule-enforcement-level.schema.json"
},
"allow_deletions_enforcement_level": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "branch-protection-rule-enforcement-level.schema.json"
},
"merge_queue_enforcement_level": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "branch-protection-rule-enforcement-level.schema.json"
},
"required_deployments_enforcement_level": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "branch-protection-rule-enforcement-level.schema.json"
},
"required_conversation_resolution_level": {
"type": "string",
"enum": ["off", "non_admins", "everyone"]
"$ref": "branch-protection-rule-enforcement-level.schema.json"
},
"authorized_actors_only": {
"$ref": "branch-protection-rule-boolean.schema.json"
},
"authorized_actors_only": { "type": "boolean" },
"authorized_actor_names": { "type": "array", "items": { "type": "string" } }
"authorized_actor_names": {
"$ref": "branch-protection-rule-array.schema.json"
}
},
"additionalProperties": false,
"title": "branch protection rule"
Expand Down

0 comments on commit 25f4b0a

Please sign in to comment.