Skip to content

Commit 90d2508

Browse files
author
Andy Gertjejansen
committed
Add validation package to allow the use of IntBetween.
1 parent 34b2b07 commit 90d2508

File tree

3 files changed

+280
-13
lines changed

3 files changed

+280
-13
lines changed

github/resource_github_branch_protection.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/google/go-github/github"
1111
"github.com/hashicorp/terraform/helper/schema"
12+
"github.com/hashicorp/terraform/helper/validation"
1213
)
1314

1415
func resourceGithubBranchProtection() *schema.Resource {
@@ -97,19 +98,11 @@ func resourceGithubBranchProtection() *schema.Resource {
9798
Optional: true,
9899
},
99100
"required_approving_review_count": {
100-
Type: schema.TypeInt,
101-
Optional: true,
102-
Description: "Number of approvals required to merge a pull request",
103-
Default: 1,
104-
// Old version of terraform, could not utilize validation.IntBetween
105-
ValidateFunc: func(i interface{}, k string) (s []string, es []error) {
106-
v := i.(int)
107-
if v < 1 || v > 6 {
108-
es = append(es, errors.New("required_pull_request_reviews.required_approving_review_count must be an integer between 1 - 6"))
109-
}
110-
111-
return
112-
},
101+
Type: schema.TypeInt,
102+
Optional: true,
103+
Description: "Number of approvals required to merge a pull request",
104+
Default: 1,
105+
ValidateFunc: validation.IntBetween(1, 6),
113106
},
114107
},
115108
},

vendor/github.com/hashicorp/terraform/helper/validation/validation.go

Lines changed: 268 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/vendor.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,12 @@
533533
"version": "v0.11.7",
534534
"versionExact": "v0.11.7"
535535
},
536+
{
537+
"checksumSHA1": "nEC56vB6M60BJtGPe+N9rziHqLg=",
538+
"path": "github.com/hashicorp/terraform/helper/validation",
539+
"revision": "c64d8bdf354eb27125416de89ee199a740ff8d35",
540+
"revisionTime": "2018-09-10T19:16:45Z"
541+
},
536542
{
537543
"checksumSHA1": "kD1ayilNruf2cES1LDfNZjYRscQ=",
538544
"path": "github.com/hashicorp/terraform/httpclient",

0 commit comments

Comments
 (0)