Skip to content

Commit

Permalink
fix: set default empty string for prefect_workspace_role.description (
Browse files Browse the repository at this point in the history
#114)

* fix: make prefect_workspace_role description required

* make optional, with default
  • Loading branch information
parkedwards authored Nov 7, 2023
1 parent 6d42153 commit 3d685fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/api/workspace_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type WorkspaceRole struct {
// when creating or updating a workspace role.
type WorkspaceRoleUpsert struct {
Name string `json:"name"`
Description *string `json:"description"`
Description string `json:"description"`
Scopes []string `json:"scopes"`
InheritedRoleID *uuid.UUID `json:"inherited_role_id"`
}
Expand Down
7 changes: 5 additions & 2 deletions internal/provider/resources/workspace_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"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/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/prefecthq/terraform-provider-prefect/internal/api"
Expand Down Expand Up @@ -100,7 +101,9 @@ func (r *WorkspaceRoleResource) Schema(_ context.Context, _ resource.SchemaReque
},
"description": schema.StringAttribute{
Optional: true,
Computed: true,
Description: "Description of the Workspace Role",
Default: stringdefault.StaticString(""),
},
"scopes": schema.ListAttribute{
Description: "List of scopes linked to the Workspace Role",
Expand Down Expand Up @@ -177,7 +180,7 @@ func (r *WorkspaceRoleResource) Create(ctx context.Context, req resource.CreateR

role, err := client.Create(ctx, api.WorkspaceRoleUpsert{
Name: model.Name.ValueString(),
Description: model.Description.ValueStringPointer(),
Description: model.Description.ValueString(),
Scopes: scopes,
InheritedRoleID: model.InheritedRoleID.ValueUUIDPointer(),
})
Expand Down Expand Up @@ -289,7 +292,7 @@ func (r *WorkspaceRoleResource) Update(ctx context.Context, req resource.UpdateR

err = client.Update(ctx, roleID, api.WorkspaceRoleUpsert{
Name: model.Name.ValueString(),
Description: model.Description.ValueStringPointer(),
Description: model.Description.ValueString(),
Scopes: scopes,
InheritedRoleID: model.InheritedRoleID.ValueUUIDPointer(),
})
Expand Down

0 comments on commit 3d685fa

Please sign in to comment.