Skip to content

Commit

Permalink
feat: add workspace_role resource (#70)
Browse files Browse the repository at this point in the history
* remove Permissions, as they are deprecated

* feat: workspace_role resource

* lint
  • Loading branch information
parkedwards authored Oct 25, 2023
1 parent a695b7c commit 6822a11
Show file tree
Hide file tree
Showing 6 changed files with 441 additions and 16 deletions.
1 change: 0 additions & 1 deletion internal/api/workspace_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
15 changes: 1 addition & 14 deletions internal/provider/datasources/workspace_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -70,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",
Expand Down Expand Up @@ -170,14 +164,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
Expand Down
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,6 @@ func (p *PrefectProvider) Resources(_ context.Context) []func() resource.Resourc
resources.NewWorkPoolResource,
resources.NewWorkspaceResource,
resources.NewServiceAccountResource,
resources.NewWorkspaceRoleResource,
}
}
Loading

0 comments on commit 6822a11

Please sign in to comment.