Skip to content

Commit 4b58364

Browse files
committed
Fix copilot
1 parent 544e905 commit 4b58364

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

internal/provider/roles/common.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const (
2929
ResourceTypeWorkspaceGroup ResourceType = "WorkspaceGroup"
3030
ResourceTypeTeam ResourceType = "Team"
3131
ResourceTypeSecret ResourceType = "Secret"
32+
ResourceTypeUnknown ResourceType = "Unknown"
3233
)
3334

3435
var ResourceTypeList = []ResourceType{
@@ -50,7 +51,7 @@ func ResourceTypeString(provider types.String) ResourceType {
5051
}
5152
}
5253

53-
panic(fmt.Sprintf("unknown resource type: %s", provider.ValueString()))
54+
return ResourceTypeUnknown
5455
}
5556

5657
func RoleAttributesSchema() map[string]schema.Attribute {
@@ -221,6 +222,8 @@ func modifyAccessControlsForResource(ctx context.Context, r management.ClientWit
221222
return applyTeamAccessControls(ctx, r, resourceID, grants, revokes)
222223
case ResourceTypeSecret:
223224
return applySecretAccessControls(ctx, r, resourceID, grants, revokes)
225+
case ResourceTypeUnknown:
226+
return false, fmt.Errorf("wrong resource type marked as: %s", resourceType)
224227
default:
225228
return false, fmt.Errorf("unsupported resource type: %s", resourceType)
226229
}
@@ -320,15 +323,15 @@ func IsRoleChanged(plan, state RoleAttributesModel) bool {
320323
func SubtractRoles(a, b []RoleAttributesModel) []RoleAttributesModel {
321324
var result []RoleAttributesModel
322325
for _, role := range a {
323-
found := true
326+
notFound := true
324327
for _, stateRole := range b {
325328
if !IsRoleChanged(role, stateRole) {
326-
found = false
329+
notFound = false
327330

328331
break
329332
}
330333
}
331-
if found {
334+
if notFound {
332335
result = append(result, role)
333336
}
334337
}

0 commit comments

Comments
 (0)