Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4741cda
Define schema for repository_property
Moser-ss Aug 6, 2024
cf40809
Apply format in the code base
Moser-ss Nov 18, 2025
dc56e34
Fix repository_property validation and docs
Moser-ss Jan 18, 2026
391654c
Support repository_property in push rulesets
Moser-ss Jan 19, 2026
a39240d
Remove unused customdiff imports
Moser-ss Feb 4, 2026
80b1eed
Replace custom validation with built-in ExactlyOneOf for repo targeting
Moser-ss Feb 13, 2026
542c225
Rever unintencial change
Moser-ss Feb 13, 2026
395de90
Add tests, docs, and fix default handling for repository_property
Moser-ss Feb 13, 2026
e9ca474
Apply suggestions from PR comment
Moser-ss Feb 14, 2026
3dbbcb1
Add unit tests
Moser-ss Feb 14, 2026
d446359
Remove redundant condition
Moser-ss Feb 17, 2026
981d1e8
Updated description based in the GitHub API docs
Moser-ss Feb 17, 2026
d1fdf0a
Apply linter and fmt
Moser-ss Feb 17, 2026
cfca003
Remove unnecessary checks
Moser-ss Feb 17, 2026
ce28407
Remove tests
Moser-ss Feb 17, 2026
478b3a6
Improve syntax for include and exclude property
Moser-ss Feb 17, 2026
1218be1
Use t context
Moser-ss Feb 23, 2026
5c341fa
Rewrite tests using the resource_github_organization_custom_properties
Moser-ss Feb 23, 2026
b47419f
Refactor repository property names in organization ruleset tests for …
Moser-ss Feb 23, 2026
d8bbf2b
Refactor tests to use state checks for repository property validation…
Moser-ss Feb 23, 2026
28a0de8
Update repository property references to use default_branch in organi…
Moser-ss Mar 4, 2026
1a1c5c6
Fix: Replace ExactlyOneOf with ConflictsWith/AtLeastOneOf for reposit…
Moser-ss Mar 20, 2026
1bf703e
Apply lint
Moser-ss Mar 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 84 additions & 10 deletions github/resource_github_organization_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "Parameters for an organization ruleset condition. `ref_name` is required for `branch` and `tag` targets, but must not be set for `push` targets. One of `repository_name` or `repository_id` is always required.",
Description: "Parameters for an organization ruleset condition.The branch and tag rulesets conditions object should contain both repository_name and ref_name properties, or both repository_id and ref_name properties, or both repository_property and ref_name properties. The push rulesets conditions object does not require the ref_name property.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ref_name": {
Expand Down Expand Up @@ -123,13 +123,85 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
},
},
},
"repository_property": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
ConflictsWith: []string{"conditions.0.repository_id", "conditions.0.repository_name"},
AtLeastOneOf: []string{"conditions.0.repository_name", "conditions.0.repository_id", "conditions.0.repository_property"},
Description: "Conditions to target repositories by custom or system properties.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"include": {
Type: schema.TypeList,
Optional: true,
ConfigMode: schema.SchemaConfigModeAttr,
Description: "The repository properties and values to include. All of these properties must match for the condition to pass.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: "The name of the repository property to target.",
},
"property_values": {
Type: schema.TypeList,
Required: true,
Description: "The values to match for the repository property.",
Elem: &schema.Schema{
Type: schema.TypeString,
},
Comment thread
Moser-ss marked this conversation as resolved.
},
"source": {
Type: schema.TypeString,
Optional: true,
Description: "The source of the repository property. Defaults to 'custom' if not specified. Can be one of: custom, system",
Default: "custom",
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"custom", "system"}, false)),
},
},
},
},
"exclude": {
Type: schema.TypeList,
Optional: true,
ConfigMode: schema.SchemaConfigModeAttr,
Description: "The repository properties and values to exclude. The ruleset will not apply if any of these properties match.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: "The name of the repository property to target.",
},
"property_values": {
Type: schema.TypeList,
Required: true,
Description: "The values to match for the repository property.",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"source": {
Type: schema.TypeString,
Optional: true,
Description: "The source of the repository property. Defaults to 'custom' if not specified. Can be one of: custom, system",
Default: "custom",
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"custom", "system"}, false)),
},
},
},
},
},
},
},
"repository_name": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "Targets repositories that match the specified name patterns.",
ExactlyOneOf: []string{"conditions.0.repository_id"},
AtLeastOneOf: []string{"conditions.0.repository_id"},
Comment thread
Moser-ss marked this conversation as resolved.
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
ConflictsWith: []string{"conditions.0.repository_id", "conditions.0.repository_property"},
AtLeastOneOf: []string{"conditions.0.repository_name", "conditions.0.repository_id", "conditions.0.repository_property"},
Description: "Targets repositories that match the specified name patterns.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"include": {
Expand Down Expand Up @@ -158,9 +230,11 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
},
},
"repository_id": {
Type: schema.TypeList,
Optional: true,
Description: "The repository IDs that the ruleset applies to. One of these IDs must match for the condition to pass.",
Type: schema.TypeList,
Optional: true,
ConflictsWith: []string{"conditions.0.repository_name", "conditions.0.repository_property"},
AtLeastOneOf: []string{"conditions.0.repository_name", "conditions.0.repository_id", "conditions.0.repository_property"},
Description: "The repository IDs that the ruleset applies to. One of these IDs must match for the ruleset to apply.",
Elem: &schema.Schema{
Type: schema.TypeInt,
},
Expand Down
Loading