From ad6a912af6c4fa9589d416a5acea75c233f3d1bf Mon Sep 17 00:00:00 2001 From: mikutas <23391543+mikutas@users.noreply.github.com> Date: Tue, 25 Mar 2025 19:34:42 +0900 Subject: [PATCH] fix: make repository argument required --- github/resource_github_repository_ruleset.go | 8 +++++--- website/docs/r/repository_ruleset.html.markdown | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/github/resource_github_repository_ruleset.go b/github/resource_github_repository_ruleset.go index cac6630249..6c31cce338 100644 --- a/github/resource_github_repository_ruleset.go +++ b/github/resource_github_repository_ruleset.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "net/http" + "regexp" "strconv" "github.com/google/go-github/v66/github" @@ -38,9 +39,10 @@ func resourceGithubRepositoryRuleset() *schema.Resource { Description: "Possible values are `branch` and `tag`.", }, "repository": { - Type: schema.TypeString, - Optional: true, - Description: "Name of the repository to apply rulset to.", + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: toDiagFunc(validation.StringMatch(regexp.MustCompile(`^[-a-zA-Z0-9_.]{1,100}$`), "must include only alphanumeric characters, underscores or hyphens and consist of 100 characters or less"), "name"), + Description: "Name of the repository to apply rulset to.", }, "enforcement": { Type: schema.TypeString, diff --git a/website/docs/r/repository_ruleset.html.markdown b/website/docs/r/repository_ruleset.html.markdown index 173ffcf234..d34a85614f 100644 --- a/website/docs/r/repository_ruleset.html.markdown +++ b/website/docs/r/repository_ruleset.html.markdown @@ -68,7 +68,7 @@ resource "github_repository_ruleset" "example" { * `conditions` - (Optional) (Block List, Max: 1) Parameters for a repository ruleset ref name condition. (see [below for nested schema](#conditions)) -* `repository` - (Optional) (String) Name of the repository to apply rulset to. +* `repository` - (Required) (String) Name of the repository to apply rulset to. #### Rules ####