Skip to content

Commit

Permalink
Remove resource ID validations
Browse files Browse the repository at this point in the history
These validations exists at the API level and are not useful in the provider itself
  • Loading branch information
joekarl committed Jul 12, 2024
1 parent bd54d4f commit 3d1d448
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 28 deletions.
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 3d1d448

Please sign in to comment.