Skip to content
Merged
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
8 changes: 7 additions & 1 deletion internal/btpcli/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"net/url"
"os"
"slices"
"testing"

"github.com/SAP/terraform-exporter-btp/pkg/tfcleanup/testutils"
Expand Down Expand Up @@ -128,6 +129,11 @@ func GetDefaultRoleCollectionsByDirectory(directoryId string, client *ClientFaca
}

func GetDefaultRolesBySubaccount(subaccountId string, client *ClientFacade) (defaults []string, err error) {
// Role names that are provisioned by default but cannot be identified via standard configuration
var defaultRoleNameSubaccount = []string{
"Application_Frontend_Developer",
}

var roles []string

cliRes, _, err := client.Security.Role.ListBySubaccount(context.Background(), subaccountId)
Expand All @@ -138,7 +144,7 @@ func GetDefaultRolesBySubaccount(subaccountId string, client *ClientFacade) (def

for _, role := range cliRes {
// The roles that are marked as IsReadOnly and contain an empty attribute list are predefined and need not be exported
if role.IsReadOnly && len(role.AttributeList) == 0 {
if role.IsReadOnly && len(role.AttributeList) == 0 || role.IsReadOnly && slices.Contains(defaultRoleNameSubaccount, role.Name) {
roles = append(roles, role.Name)
}
}
Expand Down