Skip to content

Commit

Permalink
Merge pull request #1418 from hashicorp/kirch/remove-provider-id-vali…
Browse files Browse the repository at this point in the history
…dation

Remove resource ID validations
  • Loading branch information
joekarl committed Jul 12, 2024
2 parents bd54d4f + 1ecf2b3 commit 7821d3e
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ FEATURES:
* `d/tfe_organization_run_task_global_settings`: Add a datasource to retrieve the global settings of Run tasks, by @glennsarti [#1328](https://github.com/hashicorp/terraform-provider-tfe/pull/1330)
* `r/tfe_organization_run_task_global_settings`: Add a resource to manage the global settings of Run tasks, by @glennsarti [#1328](https://github.com/hashicorp/terraform-provider-tfe/pull/1330)
* `r/tfe_notification_configuration`: Add `workspace:auto_destroy_reminder` and `workspace:auto_destroy_run_results` as allowed notification configuration trigger types, by @notchairmk [#1394](https://github.com/hashicorp/terraform-provider-tfe/pull/1394)
* `r/tfe_workspace_settings`: Remove workspace and agent pool ID validations, by @joekarl [1418](https://github.com/hashicorp/terraform-provider-tfe/pull/1418)
* `r/tfe_team_project_access`: Remove project ID validation, by @joekarl [1418](https://github.com/hashicorp/terraform-provider-tfe/pull/1418)

DEPRECATIONS and BREAKING CHANGES:
* `r/_workspace_run_task`: The `stage` attribute has been deprecated in favor of the `stages` attribute, by @glennsarti [#1328](https://github.com/hashicorp/terraform-provider-tfe/pull/1330)
Expand Down
10 changes: 0 additions & 10 deletions internal/provider/provider_next.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ package provider

import (
"context"
"fmt"
"os"
"regexp"

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/provider"
Expand All @@ -25,14 +23,6 @@ type frameworkProvider struct{}
// Compile-time interface check
var _ provider.Provider = &frameworkProvider{}

// Can be used to construct ID regexp patterns
var base58Alphabet = "[1-9A-HJ-NP-Za-km-z]"

// IDPattern constructs a regexp pattern for HCP Terraform with the given prefix
func IDPattern(prefix string) *regexp.Regexp {
return regexp.MustCompile(fmt.Sprintf("^%s-%s{16}$", prefix, base58Alphabet))
}

// FrameworkProviderConfig is a helper type for extracting the provider
// configuration from the provider block.
type FrameworkProviderConfig struct {
Expand Down
2 changes: 0 additions & 2 deletions internal/provider/resource_tfe_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

var projectIDRegexp = regexp.MustCompile("^prj-[a-zA-Z0-9]{16}$")

func resourceTFEProject() *schema.Resource {
return &schema.Resource{
CreateContext: resourceTFEProjectCreate,
Expand Down
4 changes: 0 additions & 4 deletions internal/provider/resource_tfe_team_project_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ func resourceTFETeamProjectAccess() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(
projectIDRegexp,
"must be a valid project ID (prj-<RANDOM STRING>)",
),
},

"project_access": {
Expand Down
12 changes: 0 additions & 12 deletions internal/provider/resource_tfe_workspace_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,6 @@ func (r *workspaceSettings) Schema(ctx context.Context, req resource.SchemaReque
stringplanmodifier.RequiresReplace(),
stringplanmodifier.UseStateForUnknown(),
},
Validators: []validator.String{
stringvalidator.RegexMatches(
IDPattern("ws"),
"must be a valid workspace ID (ws-<RANDOM STRING>)",
),
},
},

"execution_mode": schema.StringAttribute{
Expand All @@ -228,12 +222,6 @@ func (r *workspaceSettings) Schema(ctx context.Context, req resource.SchemaReque
unknownIfExecutionModeUnset{},
validateAgentExecutionMode{},
},
Validators: []validator.String{
stringvalidator.RegexMatches(
IDPattern("apool"),
"must be a valid workspace ID (apool-<RANDOM STRING>)",
),
},
},

// ListAttribute was required here because we are still using plugin protocol v5.
Expand Down

0 comments on commit 7821d3e

Please sign in to comment.