Skip to content

Commit

Permalink
Remove unused custom error and refactor unset account id into constant
Browse files Browse the repository at this point in the history
  • Loading branch information
bcmmbaga committed Oct 1, 2023
1 parent e04fb2e commit cc215ac
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 21 deletions.
4 changes: 1 addition & 3 deletions management/server/idp/authentik.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,7 @@ func (am *AuthentikManager) GetAllAccounts() (map[string][]*UserData, error) {
indexedUsers := make(map[string][]*UserData)
for _, user := range userList.Results {
userData := parseAuthentikUser(user)

accountID := "unset"
indexedUsers[accountID] = append(indexedUsers[accountID], userData)
indexedUsers[unsetAccountID] = append(indexedUsers[unsetAccountID], userData)
}

return indexedUsers, nil
Expand Down
4 changes: 1 addition & 3 deletions management/server/idp/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,7 @@ func (am *AzureManager) GetAllAccounts() (map[string][]*UserData, error) {
indexedUsers := make(map[string][]*UserData)
for _, profile := range profiles.Value {
userData := profile.userData()

accountID := "unset"
indexedUsers[accountID] = append(indexedUsers[accountID], userData)
indexedUsers[unsetAccountID] = append(indexedUsers[unsetAccountID], userData)
}

return indexedUsers, nil
Expand Down
4 changes: 2 additions & 2 deletions management/server/idp/google_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ func (gm *GoogleWorkspaceManager) GetAllAccounts() (map[string][]*UserData, erro

indexedUsers := make(map[string][]*UserData)
for _, user := range usersList.Users {
accountID := "unset"
indexedUsers[accountID] = append(indexedUsers[accountID], parseGoogleWorkspaceUser(user))
userData := parseGoogleWorkspaceUser(user)
indexedUsers[unsetAccountID] = append(indexedUsers[unsetAccountID], userData)
}

return indexedUsers, nil
Expand Down
10 changes: 3 additions & 7 deletions management/server/idp/idp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ import (
"github.com/netbirdio/netbird/management/server/telemetry"
)

type Error struct {
message string
}

func (e *Error) Error() string {
return e.message
}
const (
unsetAccountID = "unset"
)

// Manager idp manager interface
type Manager interface {
Expand Down
4 changes: 2 additions & 2 deletions management/server/idp/keycloak.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ func (km *KeycloakManager) GetAllAccounts() (map[string][]*UserData, error) {

indexedUsers := make(map[string][]*UserData)
for _, profile := range profiles {
accountID := "unset"
indexedUsers[accountID] = append(indexedUsers[accountID], profile.userData())
userData := profile.userData()
indexedUsers[unsetAccountID] = append(indexedUsers[unsetAccountID], userData)
}

return indexedUsers, nil
Expand Down
3 changes: 1 addition & 2 deletions management/server/idp/okta.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ func (om *OktaManager) GetAllAccounts() (map[string][]*UserData, error) {
return nil, err
}

accountID := "unset"
indexedUsers[accountID] = append(indexedUsers[accountID], userData)
indexedUsers[unsetAccountID] = append(indexedUsers[unsetAccountID], userData)
}

return indexedUsers, nil
Expand Down
4 changes: 2 additions & 2 deletions management/server/idp/zitadel.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ func (zm *ZitadelManager) GetAllAccounts() (map[string][]*UserData, error) {

indexedUsers := make(map[string][]*UserData)
for _, profile := range profiles.Result {
accountID := "unset"
indexedUsers[accountID] = append(indexedUsers[accountID], profile.userData())
userData := profile.userData()
indexedUsers[unsetAccountID] = append(indexedUsers[unsetAccountID], userData)
}

return indexedUsers, nil
Expand Down

0 comments on commit cc215ac

Please sign in to comment.