feat: add repository_property condition support for organization rulesets#3235
Closed
mkushakov wants to merge 2 commits intointegrations:mainfrom
Closed
feat: add repository_property condition support for organization rulesets#3235mkushakov wants to merge 2 commits intointegrations:mainfrom
mkushakov wants to merge 2 commits intointegrations:mainfrom
Conversation
Add support for the repository_property condition type in organization rulesets, allowing users to target repositories based on custom or system properties instead of only by name or ID. Changes: - Add repository_property block to conditions schema with include/exclude sub-blocks supporting property_name, property_value, and source fields - Add expand logic in expandConditions to convert schema to API types - Add flatten logic in flattenConditions to convert API types back to schema - Fix condition constraints: replace broken ExactlyOneOf/AtLeastOneOf with proper ConflictsWith/AtLeastOneOf across repository_name, repository_id, and repository_property (exactly one of the three must be specified) Resolves integrations#2137 Resolves integrations#2594
|
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
1 task
|
I'm looking forward to this one 👀 |
Collaborator
|
Duplicate of #2356 |
4 tasks
Moser-ss
added a commit
to Pipedrive-OSS/terraform-provider-github
that referenced
this pull request
Mar 20, 2026
…ory conditions ExactlyOneOf has known issues with nested optional list blocks in Terraform SDK. Use ConflictsWith + AtLeastOneOf pattern for reliable "exactly one" validation across repository_name, repository_id, and repository_property conditions. Updated test expectations to match new error message format from ConflictsWith. Addresses feedback from PR integrations#2356 comment r2968116244, references fix from integrations#3235
stevehipwell
pushed a commit
that referenced
this pull request
Mar 23, 2026
…2356) * Define schema for repository_property Refactor expandConditions to reduce complexity Refactor logic to reduce the cognitive complexity and add logic to handle the repository_property field Flatten conditions for repository_property and fix schemas Add test case when ruleset use repository_property Refactor repository property conditions to make them optional Flatten update Target parameters to allow the detection of changes when remote resource is updated Update documentation * Apply format in the code base * Fix repository_property validation and docs - Add ValidateFunc to include.source field for consistency with exclude - Update docs to mention repository_property as third targeting option - Fix missing space in documentation * Support repository_property in push rulesets * Remove unused customdiff imports * Replace custom validation with built-in ExactlyOneOf for repo targeting Add ExactlyOneOf/AtLeastOneOf to repository_property, repository_name,repository_id fields. Remove manual validation counting in util_ruleset_validation.Add 3 validation tests for single/multiple/missing repo targeting options. Addresses PR #2356 review feedback - simplifies validation using schema constraints. * Rever unintencial change * Add tests, docs, and fix default handling for repository_property - Add doc example for repository_property usage - Add tests for exclude block, multiple properties, and updates - Fix source field default handling in flatten function to prevent diffs * Apply suggestions from PR comment * Add unit tests * Remove redundant condition * Updated description based in the GitHub API docs * Apply linter and fmt * Remove unnecessary checks * Remove tests These tests check validation that was handover to the Terraform built-in validation * Improve syntax for include and exclude property Improve e2e tests for the ruleset and improve documentation * Use t context * Rewrite tests using the resource_github_organization_custom_properties Setup the tests case using the config instead of using the API * Refactor repository property names in organization ruleset tests for consistency * Refactor tests to use state checks for repository property validation in organization ruleset * Update repository property references to use default_branch in organization ruleset tests * Fix: Replace ExactlyOneOf with ConflictsWith/AtLeastOneOf for repository conditions ExactlyOneOf has known issues with nested optional list blocks in Terraform SDK. Use ConflictsWith + AtLeastOneOf pattern for reliable "exactly one" validation across repository_name, repository_id, and repository_property conditions. Updated test expectations to match new error message format from ConflictsWith. Addresses feedback from PR #2356 comment r2968116244, references fix from #3235 * Apply lint
JiayangZhou
pushed a commit
to JiayangZhou/terraform-provider-github
that referenced
this pull request
Apr 16, 2026
…ntegrations#2356) * Define schema for repository_property Refactor expandConditions to reduce complexity Refactor logic to reduce the cognitive complexity and add logic to handle the repository_property field Flatten conditions for repository_property and fix schemas Add test case when ruleset use repository_property Refactor repository property conditions to make them optional Flatten update Target parameters to allow the detection of changes when remote resource is updated Update documentation * Apply format in the code base * Fix repository_property validation and docs - Add ValidateFunc to include.source field for consistency with exclude - Update docs to mention repository_property as third targeting option - Fix missing space in documentation * Support repository_property in push rulesets * Remove unused customdiff imports * Replace custom validation with built-in ExactlyOneOf for repo targeting Add ExactlyOneOf/AtLeastOneOf to repository_property, repository_name,repository_id fields. Remove manual validation counting in util_ruleset_validation.Add 3 validation tests for single/multiple/missing repo targeting options. Addresses PR integrations#2356 review feedback - simplifies validation using schema constraints. * Rever unintencial change * Add tests, docs, and fix default handling for repository_property - Add doc example for repository_property usage - Add tests for exclude block, multiple properties, and updates - Fix source field default handling in flatten function to prevent diffs * Apply suggestions from PR comment * Add unit tests * Remove redundant condition * Updated description based in the GitHub API docs * Apply linter and fmt * Remove unnecessary checks * Remove tests These tests check validation that was handover to the Terraform built-in validation * Improve syntax for include and exclude property Improve e2e tests for the ruleset and improve documentation * Use t context * Rewrite tests using the resource_github_organization_custom_properties Setup the tests case using the config instead of using the API * Refactor repository property names in organization ruleset tests for consistency * Refactor tests to use state checks for repository property validation in organization ruleset * Update repository property references to use default_branch in organization ruleset tests * Fix: Replace ExactlyOneOf with ConflictsWith/AtLeastOneOf for repository conditions ExactlyOneOf has known issues with nested optional list blocks in Terraform SDK. Use ConflictsWith + AtLeastOneOf pattern for reliable "exactly one" validation across repository_name, repository_id, and repository_property conditions. Updated test expectations to match new error message format from ConflictsWith. Addresses feedback from PR integrations#2356 comment r2968116244, references fix from integrations#3235 * Apply lint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for the
repository_propertycondition type in organization rulesets, allowing users to target repositories based on custom or system properties instead of only by name or ID.Resolves #2137
Resolves #2594
Motivation
Organization rulesets currently only support targeting repositories by
repository_nameorrepository_id. The GitHub API also supportsrepository_propertyconditions, which allow matching repositories based on their custom properties (e.g., targeting all repos withteam = "platform"orenvironment = "production").This is particularly useful for large organizations that use custom properties to categorize repositories, as it enables dynamic ruleset targeting without maintaining explicit name/ID lists.
Changes
Schema (
resource_github_organization_ruleset.go)repository_propertyblock to theconditionsschema with:include— list of property targets that must all matchexclude— list of property targets that must not matchproperty_name(string),property_value(list of strings), andsource(optional, "custom" or "system", defaults to "custom")ExactlyOneOf/AtLeastOneOfwith properConflictsWith/AtLeastOneOfacross all three condition types (repository_name,repository_id,repository_property) — exactly one of the three must be specifiedExpand/Flatten (
util_rules.go)expandConditionsto convert therepository_propertyschema block togithub.RepositoryRulesetRepositoryPropertyConditionParametersAPI typeflattenConditionsto convert the API response back to the schema formatExample Usage
Testing
go build ./...— passesgo vet ./...— passesRepositoryRulesetRepositoryPropertyConditionParameters,RepositoryRulesetRepositoryPropertyTargetParameters)