Skip to content

Commit

Permalink
misc: addressed lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sheensantoscapadngan committed Nov 4, 2024
1 parent bd8fc4d commit ca5c153
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
14 changes: 11 additions & 3 deletions internal/provider/resource/project_identity_specific_privilege.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ func (r *projectIdentitySpecificPrivilegeResourceResource) Schema(_ context.Cont
Attributes: map[string]schema.Attribute{
"action": schema.SetAttribute{
ElementType: types.StringType,
Description: fmt.Sprintf("Describe what actions an entity can take."),
Description: "Describe what actions an entity can take.",
Required: true,
},
"subject": schema.StringAttribute{
Description: fmt.Sprintf("Describe the entity the permission pertains to."),
Description: "Describe the entity the permission pertains to.",
Required: true,
},
"inverted": schema.BoolAttribute{
Expand Down Expand Up @@ -616,7 +616,15 @@ func (r *projectIdentitySpecificPrivilegeResourceResource) Read(ctx context.Cont
if actionRaw, ok := permMap["action"].([]interface{}); ok {
actions := make([]string, len(actionRaw))
for i, v := range actionRaw {
actions[i] = v.(string)
if strValue, ok := v.(string); ok {
actions[i] = strValue
} else {
resp.Diagnostics.AddError(
"Invalid Action Type",
fmt.Sprintf("Expected string type for action at index %d, got %T", i, v),
)
return
}
}

entry.Action, diags = types.SetValueFrom(ctx, types.StringType, actions)
Expand Down
14 changes: 11 additions & 3 deletions internal/provider/resource/project_role_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ func (r *projectRoleResource) Schema(_ context.Context, _ resource.SchemaRequest
Attributes: map[string]schema.Attribute{
"action": schema.SetAttribute{
ElementType: types.StringType,
Description: fmt.Sprintf("Describe what actions an entity can take."),
Description: "Describe what actions an entity can take.",
Required: true,
},
"subject": schema.StringAttribute{
Description: fmt.Sprintf("Describe the entity the permission pertains to."),
Description: "Describe the entity the permission pertains to.",
Required: true,
},
"inverted": schema.BoolAttribute{
Expand Down Expand Up @@ -537,7 +537,15 @@ func (r *projectRoleResource) Read(ctx context.Context, req resource.ReadRequest
if actionRaw, ok := permMap["action"].([]interface{}); ok {
actions := make([]string, len(actionRaw))
for i, v := range actionRaw {
actions[i] = v.(string)
if strValue, ok := v.(string); ok {
actions[i] = strValue
} else {
resp.Diagnostics.AddError(
"Invalid Action Type",
fmt.Sprintf("Expected string type for action at index %d, got %T", i, v),
)
return
}
}

entry.Action, diags = types.SetValueFrom(ctx, types.StringType, actions)
Expand Down

0 comments on commit ca5c153

Please sign in to comment.