From 3d1d44839073238c92641637fceff1d3219d89b3 Mon Sep 17 00:00:00 2001 From: Karl Kirch Date: Fri, 12 Jul 2024 09:55:02 -0500 Subject: [PATCH 1/2] Remove resource ID validations These validations exists at the API level and are not useful in the provider itself --- internal/provider/provider_next.go | 10 ---------- internal/provider/resource_tfe_project.go | 2 -- .../provider/resource_tfe_team_project_access.go | 4 ---- internal/provider/resource_tfe_workspace_settings.go | 12 ------------ 4 files changed, 28 deletions(-) diff --git a/internal/provider/provider_next.go b/internal/provider/provider_next.go index 5268194fb..3eb81c6fb 100644 --- a/internal/provider/provider_next.go +++ b/internal/provider/provider_next.go @@ -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" @@ -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 { diff --git a/internal/provider/resource_tfe_project.go b/internal/provider/resource_tfe_project.go index a7b1b6abe..6f4c3e4be 100644 --- a/internal/provider/resource_tfe_project.go +++ b/internal/provider/resource_tfe_project.go @@ -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, diff --git a/internal/provider/resource_tfe_team_project_access.go b/internal/provider/resource_tfe_team_project_access.go index ab1abe49e..c50c3bddc 100644 --- a/internal/provider/resource_tfe_team_project_access.go +++ b/internal/provider/resource_tfe_team_project_access.go @@ -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-)", - ), }, "project_access": { diff --git a/internal/provider/resource_tfe_workspace_settings.go b/internal/provider/resource_tfe_workspace_settings.go index f6fabaff6..91ebd0d8d 100644 --- a/internal/provider/resource_tfe_workspace_settings.go +++ b/internal/provider/resource_tfe_workspace_settings.go @@ -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-)", - ), - }, }, "execution_mode": schema.StringAttribute{ @@ -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-)", - ), - }, }, // ListAttribute was required here because we are still using plugin protocol v5. From 1ecf2b31dd4758cc1c7ecd64a6606f6f317590d8 Mon Sep 17 00:00:00 2001 From: Karl Kirch Date: Fri, 12 Jul 2024 11:03:18 -0500 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84c66392e..c1b0ed957 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)