@@ -171,11 +171,26 @@ func validateConditionsFieldForBranchAndTagTargets(ctx context.Context, target g
171171 return fmt .Errorf ("ref_name must be set for %s target" , target )
172172 }
173173
174- // Repository rulesets don't have repository_name or repository_id, only org rulesets do.
174+ // Repository rulesets don't have repository_name, repository_id, or repository_property - only org rulesets do.
175175 if isOrg {
176- if (conditions ["repository_name" ] == nil || len (conditions ["repository_name" ].([]any )) == 0 ) && (conditions ["repository_id" ] == nil || len (conditions ["repository_id" ].([]any )) == 0 ) {
177- tflog .Debug (ctx , fmt .Sprintf ("Missing repository_name or repository_id for %s target" , target ), map [string ]any {"target" : target })
178- return fmt .Errorf ("either repository_name or repository_id must be set for %s target" , target )
176+ hasRepoName := conditions ["repository_name" ] != nil && len (conditions ["repository_name" ].([]any )) > 0
177+ hasRepoId := conditions ["repository_id" ] != nil && len (conditions ["repository_id" ].([]any )) > 0
178+ hasRepoProp := conditions ["repository_property" ] != nil && len (conditions ["repository_property" ].([]any )) > 0
179+
180+ repoTargetingCount := 0
181+ if hasRepoName {
182+ repoTargetingCount ++
183+ }
184+ if hasRepoId {
185+ repoTargetingCount ++
186+ }
187+ if hasRepoProp {
188+ repoTargetingCount ++
189+ }
190+
191+ if repoTargetingCount != 1 {
192+ tflog .Debug (ctx , fmt .Sprintf ("Invalid repository targeting for %s target" , target ), map [string ]any {"target" : target })
193+ return fmt .Errorf ("exactly one of repository_name, repository_id, or repository_property must be set for %s target" , target )
179194 }
180195 }
181196 tflog .Debug (ctx , fmt .Sprintf ("Conditions validation passed for %s target" , target ))
0 commit comments