From 9108b4bcfac85652799b35b9700cb9dfc9b68515 Mon Sep 17 00:00:00 2001 From: Edward Park Date: Tue, 24 Oct 2023 16:26:38 -0700 Subject: [PATCH 1/3] remove Permissions, as they are deprecated --- internal/api/workspace_role.go | 1 - .../provider/datasources/workspace_role.go | 10 +- internal/provider/resources/workspace_role.go | 109 ++++++++++++++++++ 3 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 internal/provider/resources/workspace_role.go diff --git a/internal/api/workspace_role.go b/internal/api/workspace_role.go index 5e45f4b6..478cab60 100644 --- a/internal/api/workspace_role.go +++ b/internal/api/workspace_role.go @@ -19,7 +19,6 @@ type WorkspaceRole struct { BaseModel Name string `json:"name"` Description *string `json:"description"` - Permissions []string `json:"permissions"` Scopes []string `json:"scopes"` AccountID *uuid.UUID `json:"account_id"` // this is null for the default roles InheritedRoleID *uuid.UUID `json:"inherited_role_id"` diff --git a/internal/provider/datasources/workspace_role.go b/internal/provider/datasources/workspace_role.go index 5d3d85fe..602a18cd 100644 --- a/internal/provider/datasources/workspace_role.go +++ b/internal/provider/datasources/workspace_role.go @@ -28,7 +28,6 @@ type WorkspaceRoleDataSourceModel struct { Name types.String `tfsdk:"name"` Description types.String `tfsdk:"description"` - Permissions types.List `tfsdk:"permissions"` Scopes types.List `tfsdk:"scopes"` AccountID customtypes.UUIDValue `tfsdk:"account_id"` InheritedRoleID customtypes.UUIDValue `tfsdk:"inherited_role_id"` @@ -170,14 +169,7 @@ func (d *WorkspaceRoleDataSource) Read(ctx context.Context, req datasource.ReadR model.AccountID = customtypes.NewUUIDPointerValue(fetchedRole.AccountID) model.InheritedRoleID = customtypes.NewUUIDPointerValue(fetchedRole.InheritedRoleID) - list, diags := types.ListValueFrom(ctx, types.StringType, fetchedRole.Permissions) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - model.Permissions = list - - list, diags = types.ListValueFrom(ctx, types.StringType, fetchedRole.Scopes) + list, diags := types.ListValueFrom(ctx, types.StringType, fetchedRole.Scopes) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return diff --git a/internal/provider/resources/workspace_role.go b/internal/provider/resources/workspace_role.go new file mode 100644 index 00000000..6294b537 --- /dev/null +++ b/internal/provider/resources/workspace_role.go @@ -0,0 +1,109 @@ +package resources + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/prefecthq/terraform-provider-prefect/internal/api" + "github.com/prefecthq/terraform-provider-prefect/internal/provider/customtypes" +) + +var ( + _ = resource.ResourceWithConfigure(&WorkspaceRoleResource{}) + _ = resource.ResourceWithImportState(&WorkspaceRoleResource{}) +) + +// WorkspaceRoleResource contains state for the resource. +type WorkspaceRoleResource struct { + client api.PrefectClient +} + +// WorkspaceRoleResourceModel defines the Terraform resource model. +type WorkspaceRoleResourceModel struct { + ID customtypes.UUIDValue `tfsdk:"id"` + Created customtypes.TimestampValue `tfsdk:"created"` + Updated customtypes.TimestampValue `tfsdk:"updated"` + + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + Scopes types.List `tfsdk:"scopes"` + AccountID customtypes.UUIDValue `tfsdk:"account_id"` + InheritedRoleID customtypes.UUIDValue `tfsdk:"inherited_role_id"` +} + +// NewWorkspaceRoleResource returns a new WorkspaceRoleResource. +// +//nolint:ireturn // required by Terraform API +func NewWorkspaceRoleResource() resource.Resource { + return &WorkspaceRoleResource{} +} + +// Metadata returns the resource type name. +func (r *WorkspaceRoleResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_workspace_role" +} + +// Configure initializes runtime state for the resource. +func (r *WorkspaceRoleResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(api.PrefectClient) + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected api.PrefectClient, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client +} + +func (r *WorkspaceRoleResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Resource representing a Prefect Workspace Role", + Version: 0, + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + Description: "Workspace Role UUID", + // attributes which are not configurable + should not show updates from the existing state value + // should implement `UseStateForUnknown()` + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "created": schema.StringAttribute{ + Computed: true, + CustomType: customtypes.TimestampType{}, + Description: "Date and time of the Workspace Role creation in RFC 3339 format", + }, + "updated": schema.StringAttribute{ + Computed: true, + CustomType: customtypes.TimestampType{}, + Description: "Date and time that the Workspace Role was last updated in RFC 3339 format", + }, + "name": schema.StringAttribute{ + Required: true, + Description: "Name of the Workspace Role", + }, + "description": schema.StringAttribute{ + Optional: true, + Description: "Description of the Workspace Role", + }, + "account_id": schema.StringAttribute{ + CustomType: customtypes.UUIDType{}, + Description: "Account UUID, defaults to the account set in the provider", + Optional: true, + }, + }, + } +} From 0155df07e0b3654a8d2f6812b2fd05929b35c5b3 Mon Sep 17 00:00:00 2001 From: Edward Park Date: Tue, 24 Oct 2023 20:27:31 -0700 Subject: [PATCH 2/3] feat: workspace_role resource --- .../provider/datasources/workspace_role.go | 5 - internal/provider/provider.go | 1 + internal/provider/resources/workspace_role.go | 268 +++++++++++++++++- .../provider/resources/workspace_role_test.go | 63 ++++ internal/testutils/provider.go | 3 +- 5 files changed, 333 insertions(+), 7 deletions(-) create mode 100644 internal/provider/resources/workspace_role_test.go diff --git a/internal/provider/datasources/workspace_role.go b/internal/provider/datasources/workspace_role.go index 602a18cd..2a06c4f9 100644 --- a/internal/provider/datasources/workspace_role.go +++ b/internal/provider/datasources/workspace_role.go @@ -69,11 +69,6 @@ var workspaceRoleAttributes = map[string]schema.Attribute{ Optional: true, Description: "Description of the Workspace Role", }, - "permissions": schema.ListAttribute{ - Computed: true, - Description: "List of permissions linked to the Workspace Role", - ElementType: types.StringType, - }, "scopes": schema.ListAttribute{ Computed: true, Description: "List of scopes linked to the Workspace Role", diff --git a/internal/provider/provider.go b/internal/provider/provider.go index f45d1480..8201448e 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -220,5 +220,6 @@ func (p *PrefectProvider) Resources(_ context.Context) []func() resource.Resourc resources.NewWorkPoolResource, resources.NewWorkspaceResource, resources.NewServiceAccountResource, + resources.NewWorkspaceRoleResource, } } diff --git a/internal/provider/resources/workspace_role.go b/internal/provider/resources/workspace_role.go index 6294b537..0d52db44 100644 --- a/internal/provider/resources/workspace_role.go +++ b/internal/provider/resources/workspace_role.go @@ -4,6 +4,9 @@ import ( "context" "fmt" + "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" @@ -25,7 +28,7 @@ type WorkspaceRoleResource struct { // WorkspaceRoleResourceModel defines the Terraform resource model. type WorkspaceRoleResourceModel struct { - ID customtypes.UUIDValue `tfsdk:"id"` + ID types.String `tfsdk:"id"` Created customtypes.TimestampValue `tfsdk:"created"` Updated customtypes.TimestampValue `tfsdk:"updated"` @@ -99,11 +102,274 @@ func (r *WorkspaceRoleResource) Schema(_ context.Context, _ resource.SchemaReque Optional: true, Description: "Description of the Workspace Role", }, + "scopes": schema.ListAttribute{ + Description: "List of scopes linked to the Workspace Role", + ElementType: types.StringType, + Optional: true, + }, "account_id": schema.StringAttribute{ CustomType: customtypes.UUIDType{}, Description: "Account UUID, defaults to the account set in the provider", + Computed: true, + }, + "inherited_role_id": schema.StringAttribute{ + CustomType: customtypes.UUIDType{}, + Description: "Workspace Role UUID, whose permissions are inherited by this Workspace Role", Optional: true, }, }, } } + +// copyWorkspaceRoleToModel copies an api.WorkspaceRole to a WorkspaceRoleDataSourceModel. +func copyWorkspaceRoleToModel(ctx context.Context, role *api.WorkspaceRole, model *WorkspaceRoleResourceModel) diag.Diagnostics { + model.ID = types.StringValue(role.ID.String()) + model.Created = customtypes.NewTimestampPointerValue(role.Created) + model.Updated = customtypes.NewTimestampPointerValue(role.Updated) + + model.Name = types.StringValue(role.Name) + model.Description = types.StringPointerValue(role.Description) + model.AccountID = customtypes.NewUUIDPointerValue(role.AccountID) + model.InheritedRoleID = customtypes.NewUUIDPointerValue(role.InheritedRoleID) + + // NOTE: here, we'll omit updating the TF state with the scopes returned from the API + // as scopes in Prefect Cloud have a hierarchical structure. This means that children scopes + // can be returned based on what a practioner configures in TF / HCL, which will cause + // conflicts on apply, as the retrieved state from the API will vary slightly with + // the Terraform configuration. Therefore, the state will hold the user-defined scope parameters, + // which will include any children scopes on the Prefect Cloud side. + + // scopes, diags := types.ListValueFrom(ctx, types.StringType, role.Scopes) + // if diags.HasError() { + // return diags + // } + // model.Scopes = scopes + + return nil +} + +func (r *WorkspaceRoleResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var model WorkspaceRoleResourceModel + + // Populate the model from resource configuration and emit diagnostics on error + resp.Diagnostics.Append(req.Config.Get(ctx, &model)...) + if resp.Diagnostics.HasError() { + return + } + + var scopes []string + resp.Diagnostics.Append(model.Scopes.ElementsAs(ctx, &scopes, false)...) + if resp.Diagnostics.HasError() { + return + } + + client, err := r.client.WorkspaceRoles(model.AccountID.ValueUUID()) + if err != nil { + resp.Diagnostics.AddError( + "Error creating Workspace Role client", + fmt.Sprintf("Could not create Workspace Role client, unexpected error: %s. This is a bug in the provider, please report this to the maintainers.", err.Error()), + ) + + return + } + + role, err := client.Create(ctx, api.WorkspaceRoleUpsert{ + Name: model.Name.ValueString(), + Description: model.Description.ValueStringPointer(), + Scopes: scopes, + InheritedRoleID: model.InheritedRoleID.ValueUUIDPointer(), + }) + if err != nil { + resp.Diagnostics.AddError( + "Error creating Workspace Role", + fmt.Sprintf("Could not create Workspace Role, unexpected error: %s", err), + ) + + return + } + + resp.Diagnostics.Append(copyWorkspaceRoleToModel(ctx, role, &model)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &model)...) + if resp.Diagnostics.HasError() { + return + } +} + +// Read refreshes the Terraform state with the latest data. +func (r *WorkspaceRoleResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var model WorkspaceRoleResourceModel + + // Populate the model from state and emit diagnostics on error + resp.Diagnostics.Append(req.State.Get(ctx, &model)...) + if resp.Diagnostics.HasError() { + return + } + + // client, err := r.client.ServiceAccounts(model.AccountID.ValueUUID()) + client, err := r.client.WorkspaceRoles(model.AccountID.ValueUUID()) + if err != nil { + resp.Diagnostics.AddError( + "Error creating Workspace Role client", + fmt.Sprintf("Could not create Workspace Role client, unexpected error: %s. This is a bug in the provider, please report this to the maintainers.", err.Error()), + ) + + return + } + + roleID, err := uuid.Parse(model.ID.ValueString()) + if err != nil { + resp.Diagnostics.AddAttributeError( + path.Root("id"), + "Error parsing Workspace Role ID", + fmt.Sprintf("Could not parse Workspace Role ID to UUID, unexpected error: %s", err.Error()), + ) + } + + role, err := client.Get(ctx, roleID) + if err != nil { + resp.Diagnostics.AddError( + "Error refreshing Workspace Role state", + fmt.Sprintf("Could not read Workspace Role, unexpected error: %s", err), + ) + + return + } + + resp.Diagnostics.Append(copyWorkspaceRoleToModel(ctx, role, &model)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &model)...) + if resp.Diagnostics.HasError() { + return + } +} + +// Update updates the resource and sets the updated Terraform state on success. +func (r *WorkspaceRoleResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var model WorkspaceRoleResourceModel + + resp.Diagnostics.Append(req.Plan.Get(ctx, &model)...) + if resp.Diagnostics.HasError() { + return + } + + client, err := r.client.WorkspaceRoles(model.AccountID.ValueUUID()) + if err != nil { + resp.Diagnostics.AddError( + "Error creating Workspace Role client", + fmt.Sprintf("Could not create Workspace Role client, unexpected error: %s. This is a bug in the provider, please report this to the maintainers.", err.Error()), + ) + + return + } + + var scopes []string + resp.Diagnostics.Append(model.Scopes.ElementsAs(ctx, &scopes, false)...) + if resp.Diagnostics.HasError() { + return + } + + roleID, err := uuid.Parse(model.ID.ValueString()) + if err != nil { + resp.Diagnostics.AddAttributeError( + path.Root("id"), + "Error parsing Workspace Role ID", + fmt.Sprintf("Could not parse Workspace Role ID to UUID, unexpected error: %s", err.Error()), + ) + + return + } + + err = client.Update(ctx, roleID, api.WorkspaceRoleUpsert{ + Name: model.Name.ValueString(), + Description: model.Description.ValueStringPointer(), + Scopes: scopes, + InheritedRoleID: model.InheritedRoleID.ValueUUIDPointer(), + }) + if err != nil { + resp.Diagnostics.AddError( + "Error updating Workspace Role", + fmt.Sprintf("Could not update Workspace Role, unexpected error: %s", err), + ) + + return + } + + role, err := client.Get(ctx, roleID) + if err != nil { + resp.Diagnostics.AddError( + "Error refreshing Workspace Role state", + fmt.Sprintf("Could not read Workspace Role, unexpected error: %s", err.Error()), + ) + + return + } + + resp.Diagnostics.Append(copyWorkspaceRoleToModel(ctx, role, &model)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &model)...) + if resp.Diagnostics.HasError() { + return + } +} + +// Delete deletes the resource and removes the Terraform state on success. +func (r *WorkspaceRoleResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var model WorkspaceRoleResourceModel + + resp.Diagnostics.Append(req.State.Get(ctx, &model)...) + if resp.Diagnostics.HasError() { + return + } + + client, err := r.client.WorkspaceRoles(model.AccountID.ValueUUID()) + if err != nil { + resp.Diagnostics.AddError( + "Error creating Workspace Role client", + fmt.Sprintf("Could not create Workspace Role client, unexpected error: %s. This is a bug in the provider, please report this to the maintainers.", err.Error()), + ) + + return + } + + roleID, err := uuid.Parse(model.ID.ValueString()) + if err != nil { + resp.Diagnostics.AddAttributeError( + path.Root("id"), + "Error parsing Workspace Role ID", + fmt.Sprintf("Could not parse Workspace Role ID to UUID, unexpected error: %s", err.Error()), + ) + + return + } + + err = client.Delete(ctx, roleID) + if err != nil { + resp.Diagnostics.AddError( + "Error deleting Workspace Role", + fmt.Sprintf("Could not delete Workspace Role, unexpected error: %s", err), + ) + + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &model)...) + if resp.Diagnostics.HasError() { + return + } +} + +// ImportState allows Terraform to start managing a Workspace Role resource +func (r *WorkspaceRoleResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + // Retrieve import ID and save to id attribute + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} diff --git a/internal/provider/resources/workspace_role_test.go b/internal/provider/resources/workspace_role_test.go new file mode 100644 index 00000000..ad73d68b --- /dev/null +++ b/internal/provider/resources/workspace_role_test.go @@ -0,0 +1,63 @@ +package resources_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/prefecthq/terraform-provider-prefect/internal/testutils" +) + +//nolint:paralleltest // we use the resource.ParallelTest helper instead +func TestAccResource_workspace_role(t *testing.T) { + resourceName := "prefect_workspace_role.role" + randomName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) + resource.ParallelTest(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + // Check creation + existence of the workspace role resource + Config: testutils.ProviderConfig + fixtureAccWorkspaceRoleResource(randomName), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "name", randomName), + resource.TestCheckResourceAttr(resourceName, "description", fmt.Sprintf("%s description", randomName)), + resource.TestCheckResourceAttr(resourceName, "scopes.#", "2"), + resource.TestCheckResourceAttr(resourceName, "scopes.0", "manage_blocks"), + resource.TestCheckResourceAttr(resourceName, "scopes.1", "see_artifacts"), + ), + }, + { + // Check updates for the workspace role resource + Config: testutils.ProviderConfig + fixtureAccWorkspaceRoleReesourceUpdated(randomName), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "name", randomName), + resource.TestCheckResourceAttr(resourceName, "description", fmt.Sprintf("description for %s", randomName)), + resource.TestCheckResourceAttr(resourceName, "scopes.#", "3"), + resource.TestCheckResourceAttr(resourceName, "scopes.0", "write_workers"), + resource.TestCheckResourceAttr(resourceName, "scopes.1", "see_variables"), + resource.TestCheckResourceAttr(resourceName, "scopes.2", "manage_work_queues"), + ), + }, + }, + }) + +} + +func fixtureAccWorkspaceRoleResource(name string) string { + return fmt.Sprintf(` +resource "prefect_workspace_role" "role" { + name = "%s" + description = "%s description" + scopes = ["manage_blocks", "see_artifacts"] +}`, name, name) +} + +func fixtureAccWorkspaceRoleReesourceUpdated(name string) string { + return fmt.Sprintf(` +resource "prefect_workspace_role" "role" { + name = "%s" + description = "description for %s" + scopes = ["write_workers", "see_variables", "manage_work_queues"] +}`, name, name) +} diff --git a/internal/testutils/provider.go b/internal/testutils/provider.go index 33516304..7407f10a 100644 --- a/internal/testutils/provider.go +++ b/internal/testutils/provider.go @@ -20,6 +20,7 @@ provider "prefect" {} // acceptance testing. The factory function will be invoked for every Terraform // CLI command executed to create a provider server to which the CLI can // reattach. +var TestAccProvider = providerserver.NewProtocol6WithError(provider.New()) var TestAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ - "prefect": providerserver.NewProtocol6WithError(provider.New()), + "prefect": TestAccProvider, } From 84eb538acac9627acd51aeed711681a05b5ae10a Mon Sep 17 00:00:00 2001 From: Edward Park Date: Tue, 24 Oct 2023 20:41:23 -0700 Subject: [PATCH 3/3] lint --- internal/provider/resources/workspace_role.go | 8 ++++---- internal/provider/resources/workspace_role_test.go | 1 - internal/testutils/provider.go | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/provider/resources/workspace_role.go b/internal/provider/resources/workspace_role.go index 0d52db44..dbd3cbf4 100644 --- a/internal/provider/resources/workspace_role.go +++ b/internal/provider/resources/workspace_role.go @@ -122,7 +122,7 @@ func (r *WorkspaceRoleResource) Schema(_ context.Context, _ resource.SchemaReque } // copyWorkspaceRoleToModel copies an api.WorkspaceRole to a WorkspaceRoleDataSourceModel. -func copyWorkspaceRoleToModel(ctx context.Context, role *api.WorkspaceRole, model *WorkspaceRoleResourceModel) diag.Diagnostics { +func copyWorkspaceRoleToModel(_ context.Context, role *api.WorkspaceRole, model *WorkspaceRoleResourceModel) diag.Diagnostics { model.ID = types.StringValue(role.ID.String()) model.Created = customtypes.NewTimestampPointerValue(role.Created) model.Updated = customtypes.NewTimestampPointerValue(role.Updated) @@ -134,11 +134,12 @@ func copyWorkspaceRoleToModel(ctx context.Context, role *api.WorkspaceRole, mode // NOTE: here, we'll omit updating the TF state with the scopes returned from the API // as scopes in Prefect Cloud have a hierarchical structure. This means that children scopes - // can be returned based on what a practioner configures in TF / HCL, which will cause + // can be returned based on what a practitioner configures in TF / HCL, which will cause // conflicts on apply, as the retrieved state from the API will vary slightly with // the Terraform configuration. Therefore, the state will hold the user-defined scope parameters, // which will include any children scopes on the Prefect Cloud side. + //nolint:gocritic // scopes, diags := types.ListValueFrom(ctx, types.StringType, role.Scopes) // if diags.HasError() { // return diags @@ -209,7 +210,6 @@ func (r *WorkspaceRoleResource) Read(ctx context.Context, req resource.ReadReque return } - // client, err := r.client.ServiceAccounts(model.AccountID.ValueUUID()) client, err := r.client.WorkspaceRoles(model.AccountID.ValueUUID()) if err != nil { resp.Diagnostics.AddError( @@ -368,7 +368,7 @@ func (r *WorkspaceRoleResource) Delete(ctx context.Context, req resource.DeleteR } } -// ImportState allows Terraform to start managing a Workspace Role resource +// ImportState allows Terraform to start managing a Workspace Role resource. func (r *WorkspaceRoleResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { // Retrieve import ID and save to id attribute resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) diff --git a/internal/provider/resources/workspace_role_test.go b/internal/provider/resources/workspace_role_test.go index ad73d68b..40116e71 100644 --- a/internal/provider/resources/workspace_role_test.go +++ b/internal/provider/resources/workspace_role_test.go @@ -41,7 +41,6 @@ func TestAccResource_workspace_role(t *testing.T) { }, }, }) - } func fixtureAccWorkspaceRoleResource(name string) string { diff --git a/internal/testutils/provider.go b/internal/testutils/provider.go index 7407f10a..d89b126b 100644 --- a/internal/testutils/provider.go +++ b/internal/testutils/provider.go @@ -20,7 +20,7 @@ provider "prefect" {} // acceptance testing. The factory function will be invoked for every Terraform // CLI command executed to create a provider server to which the CLI can // reattach. -var TestAccProvider = providerserver.NewProtocol6WithError(provider.New()) var TestAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ "prefect": TestAccProvider, } +var TestAccProvider = providerserver.NewProtocol6WithError(provider.New())