Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add workspace_role resource #70

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

permissions are a deprecated version of scopes, and can be removed here

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
Loading