Skip to content

Commit 7147526

Browse files
committed
Use strings.Join to make Description of target dynamic
1 parent 229752f commit 7147526

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

github/resource_github_organization_ruleset.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"regexp"
99
"strconv"
10+
"strings"
1011

1112
"github.com/google/go-github/v82/github"
1213
"github.com/hashicorp/terraform-plugin-log/tflog"
@@ -15,6 +16,8 @@ import (
1516
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1617
)
1718

19+
var supportedOrgRulesetTargetTypes = []string{string(github.RulesetTargetBranch), string(github.RulesetTargetTag), string(github.RulesetTargetPush)}
20+
1821
func resourceGithubOrganizationRuleset() *schema.Resource {
1922
return &schema.Resource{
2023
CreateContext: resourceGithubOrganizationRulesetCreate,
@@ -40,8 +43,8 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
4043
Type: schema.TypeString,
4144
Required: true,
4245
// The API accepts an `repository` target, but we don't support it yet.
43-
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{string(github.RulesetTargetBranch), string(github.RulesetTargetTag), string(github.RulesetTargetPush)}, false)),
44-
Description: "The target of the ruleset. Possible values are `branch`, `tag` and `push`.",
46+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(supportedOrgRulesetTargetTypes, false)),
47+
Description: "The target of the ruleset. Possible values are " + strings.Join(supportedOrgRulesetTargetTypes[:len(supportedOrgRulesetTargetTypes)-1], ", ") + " and " + supportedOrgRulesetTargetTypes[len(supportedOrgRulesetTargetTypes)-1] + ".",
4548
},
4649
"enforcement": {
4750
Type: schema.TypeString,

0 commit comments

Comments
 (0)