feat: add repository_property condition support for organization rulesets#3235
Open
mkushakov wants to merge 2 commits intointegrations:mainfrom
Open
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 |
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)