Skip to content

Commit d3260bf

Browse files
authored
[MAINT] Convert all usage of deprecated ValidateFunc to ValidateDiagFunc (#3195)
* Convert all usage of deprecated `ValidateFunc` to `ValidateDiagFunc` Signed-off-by: Timo Sand <timo.sand@f-secure.com> * replace homebrew `toDiagFunc` with `validation.ToDiagFunc` Signed-off-by: Timo Sand <timo.sand@f-secure.com> * fixup! Correct test after validation simplification Signed-off-by: Timo Sand <timo.sand@f-secure.com> * fixup! Fix GH Tead DS test Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Fix repo test Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Fix failing test Signed-off-by: Timo Sand <timo.sand@f-secure.com> * Remove unnecessary abstraction with `reconfigureVisibility` Signed-off-by: Timo Sand <timo.sand@f-secure.com> --------- Signed-off-by: Timo Sand <timo.sand@f-secure.com>
1 parent 8646f3c commit d3260bf

File tree

36 files changed

+107
-182
lines changed

36 files changed

+107
-182
lines changed

github/data_source_github_collaborators.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ func dataSourceGithubCollaborators() *schema.Resource {
2424
},
2525
"affiliation": {
2626
Type: schema.TypeString,
27-
ValidateDiagFunc: toDiagFunc(validation.StringInSlice([]string{
27+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{
2828
"all",
2929
"direct",
3030
"outside",
31-
}, false), "affiliation"),
31+
}, false)),
3232
Optional: true,
3333
Default: "all",
3434
},
3535
"permission": {
3636
Type: schema.TypeString,
37-
ValidateDiagFunc: toDiagFunc(validation.StringInSlice([]string{
37+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{
3838
"pull",
3939
"triage",
4040
"push",
4141
"maintain",
4242
"admin",
43-
}, false), "permission"),
43+
}, false)),
4444
Optional: true,
4545
Default: "",
4646
},

github/data_source_github_organization_teams.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func dataSourceGithubOrganizationTeams() *schema.Resource {
2929
Type: schema.TypeInt,
3030
Optional: true,
3131
Default: 100,
32-
ValidateDiagFunc: toDiagFunc(validation.IntBetween(0, 100), "results_per_page"),
32+
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 100)),
3333
},
3434
"teams": {
3535
Type: schema.TypeList,

github/data_source_github_release.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ func dataSourceGithubRelease() *schema.Resource {
3131
Type: schema.TypeString,
3232
Required: true,
3333
Description: "Describes how to fetch the release. Valid values are `id`, `tag`, `latest`.",
34-
ValidateDiagFunc: toDiagFunc(validation.StringInSlice([]string{
34+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{
3535
"latest",
3636
"id",
3737
"tag",
38-
}, false), "retrieve_by"),
38+
}, false)),
3939
},
4040
"release_tag": {
4141
Type: schema.TypeString,

github/data_source_github_repositories.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func dataSourceGithubRepositories() *schema.Resource {
2121
Type: schema.TypeString,
2222
Default: "updated",
2323
Optional: true,
24-
ValidateDiagFunc: toDiagFunc(validation.StringInSlice([]string{"stars", "fork", "updated"}, false), "sort"),
24+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"stars", "fork", "updated"}, false)),
2525
},
2626
"include_repo_id": {
2727
Type: schema.TypeBool,
@@ -32,7 +32,7 @@ func dataSourceGithubRepositories() *schema.Resource {
3232
Type: schema.TypeInt,
3333
Optional: true,
3434
Default: 100,
35-
ValidateDiagFunc: toDiagFunc(validation.IntBetween(0, 1000), "results_per_page"),
35+
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 1000)),
3636
},
3737
"full_names": {
3838
Type: schema.TypeList,

github/data_source_github_repository_pull_requests.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ func dataSourceGithubRepositoryPullRequests() *schema.Resource {
3434
Type: schema.TypeString,
3535
Optional: true,
3636
Default: "created",
37-
ValidateDiagFunc: toDiagFunc(validation.StringInSlice([]string{"created", "updated", "popularity", "long-running"}, false), "sort_by"),
37+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"created", "updated", "popularity", "long-running"}, false)),
3838
},
3939
"sort_direction": {
4040
Type: schema.TypeString,
4141
Optional: true,
4242
Default: "asc",
43-
ValidateDiagFunc: toDiagFunc(validation.StringInSlice([]string{"asc", "desc"}, false), "sort_direction"),
43+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"asc", "desc"}, false)),
4444
},
4545
"state": {
4646
Type: schema.TypeString,
4747
Default: "open",
4848
Optional: true,
49-
ValidateDiagFunc: toDiagFunc(validation.StringInSlice([]string{"open", "closed", "all"}, false), "state"),
49+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"open", "closed", "all"}, false)),
5050
},
5151
"results": {
5252
Type: schema.TypeList,

github/data_source_github_team.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func dataSourceGithubTeam() *schema.Resource {
8282
Type: schema.TypeString,
8383
Default: "all",
8484
Optional: true,
85-
ValidateDiagFunc: toDiagFunc(validation.StringInSlice([]string{"all", "immediate"}, false), "membership_type"),
85+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"all", "immediate"}, false)),
8686
},
8787
"summary_only": {
8888
Type: schema.TypeBool,
@@ -93,7 +93,7 @@ func dataSourceGithubTeam() *schema.Resource {
9393
Type: schema.TypeInt,
9494
Optional: true,
9595
Default: 100,
96-
ValidateDiagFunc: toDiagFunc(validation.IntBetween(0, 100), "results_per_page"),
96+
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 100)),
9797
Deprecated: "This is deprecated and will be removed in a future release.",
9898
},
9999
},

github/data_source_github_team_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ func TestAccGithubTeamDataSource(t *testing.T) {
170170
171171
resource "github_team" "test" {
172172
name = "%s"
173+
description = "test"
173174
}
174175
175176
resource "github_team_repository" "test" {

github/resource_github_actions_environment_secret_migration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func resourceGithubActionsEnvironmentSecretV0() *schema.Resource {
3838
ForceNew: true,
3939
Description: "Encrypted value of the secret using the GitHub public key in Base64 format.",
4040
ConflictsWith: []string{"plaintext_value"},
41-
ValidateDiagFunc: toDiagFunc(validation.StringIsBase64, "encrypted_value"),
41+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsBase64),
4242
},
4343
"plaintext_value": {
4444
Type: schema.TypeString,

github/resource_github_actions_hosted_runner.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ func resourceGithubActionsHostedRunner() *schema.Resource {
3434
"name": {
3535
Type: schema.TypeString,
3636
Required: true,
37-
ValidateFunc: validation.All(
37+
ValidateDiagFunc: validation.ToDiagFunc(validation.All(
3838
validation.StringLenBetween(1, 64),
3939
validation.StringMatch(
4040
regexp.MustCompile(`^[a-zA-Z0-9._-]+$`),
4141
"name may only contain alphanumeric characters, '.', '-', and '_'",
4242
),
43-
),
43+
)),
4444
Description: "Name of the hosted runner. Must be between 1 and 64 characters and may only contain upper and lowercase letters a-z, numbers 0-9, '.', '-', and '_'.",
4545
},
4646
"image": {
@@ -56,11 +56,11 @@ func resourceGithubActionsHostedRunner() *schema.Resource {
5656
Description: "The image ID.",
5757
},
5858
"source": {
59-
Type: schema.TypeString,
60-
Optional: true,
61-
Default: "github",
62-
ValidateFunc: validation.StringInSlice([]string{"github", "partner", "custom"}, false),
63-
Description: "The image source (github, partner, or custom).",
59+
Type: schema.TypeString,
60+
Optional: true,
61+
Default: "github",
62+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"github", "partner", "custom"}, false)),
63+
Description: "The image source (github, partner, or custom).",
6464
},
6565
"size_gb": {
6666
Type: schema.TypeInt,
@@ -82,11 +82,11 @@ func resourceGithubActionsHostedRunner() *schema.Resource {
8282
Description: "The runner group ID.",
8383
},
8484
"maximum_runners": {
85-
Type: schema.TypeInt,
86-
Optional: true,
87-
Computed: true,
88-
ValidateFunc: validation.IntAtLeast(1),
89-
Description: "Maximum number of runners to scale up to.",
85+
Type: schema.TypeInt,
86+
Optional: true,
87+
Computed: true,
88+
ValidateDiagFunc: validation.ToDiagFunc(validation.IntAtLeast(1)),
89+
Description: "Maximum number of runners to scale up to.",
9090
},
9191
"public_ip_enabled": {
9292
Type: schema.TypeBool,

github/resource_github_actions_organization_permissions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ func resourceGithubActionsOrganizationPermissions() *schema.Resource {
2525
Type: schema.TypeString,
2626
Optional: true,
2727
Description: "The permissions policy that controls the actions that are allowed to run. Can be one of: 'all', 'local_only', or 'selected'.",
28-
ValidateDiagFunc: toDiagFunc(validation.StringInSlice([]string{"all", "local_only", "selected"}, false), "allowed_actions"),
28+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"all", "local_only", "selected"}, false)),
2929
},
3030
"enabled_repositories": {
3131
Type: schema.TypeString,
3232
Required: true,
3333
Description: "The policy that controls the repositories in the organization that are allowed to run GitHub Actions. Can be one of: 'all', 'none', or 'selected'.",
34-
ValidateDiagFunc: toDiagFunc(validation.StringInSlice([]string{"all", "none", "selected"}, false), "enabled_repositories"),
34+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"all", "none", "selected"}, false)),
3535
},
3636
"allowed_actions_config": {
3737
Type: schema.TypeList,

0 commit comments

Comments
 (0)