Skip to content
Open
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
13 changes: 9 additions & 4 deletions pkg/connector/invitation.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (i *invitationResourceType) CreateAccount(
annotations.Annotations,
error,
) {
params, err := getCreateUserParams(accountInfo)
params, err := getCreateUserParams(accountInfo, i.orgs)
if err != nil {
return nil, nil, nil, fmt.Errorf("github-connectorv2: failed to get CreateUserParams: %w", err)
}
Expand Down Expand Up @@ -206,10 +206,15 @@ type createUserParams struct {
email *string
}

func getCreateUserParams(accountInfo *v2.AccountInfo) (*createUserParams, error) {
func getCreateUserParams(accountInfo *v2.AccountInfo, configuredOrgs []string) (*createUserParams, error) {
pMap := accountInfo.Profile.AsMap()
org, ok := pMap["org"].(string)
if !ok || org == "" {

// Use org from account info profile if provided, otherwise fall back to the connector's configured org.
org, _ := pMap["org"].(string)
if org == "" && len(configuredOrgs) > 0 {
org = configuredOrgs[0]
}
if org == "" {
return nil, fmt.Errorf("org is required")
}

Expand Down
Loading