Skip to content

Commit

Permalink
fix: emails should be lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
Serpentiel committed Nov 16, 2023
1 parent 6365e9f commit 57e5b14
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion internal/sdkprovider/service/account/account_team_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package account
import (
"context"
"log"
"strings"

"github.com/aiven/aiven-go-client/v2"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -76,7 +77,7 @@ func resourceAccountTeamMemberCreate(ctx context.Context, d *schema.ResourceData
client := m.(*aiven.Client)
accountID := d.Get("account_id").(string)
teamID := d.Get("team_id").(string)
userEmail := d.Get("user_email").(string)
userEmail := strings.ToLower(d.Get("user_email").(string))

err := client.AccountTeamMembers.Invite(
ctx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package account

import (
"context"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand All @@ -21,7 +22,7 @@ func DatasourceAccountTeamMember() *schema.Resource {
func datasourceAccountTeamMemberRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountID := d.Get("account_id").(string)
teamID := d.Get("team_id").(string)
userEmail := d.Get("user_email").(string)
userEmail := strings.ToLower(d.Get("user_email").(string))

d.SetId(schemautil.BuildResourceID(accountID, teamID, userEmail))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package organization
import (
"context"
"log"
"strings"

"github.com/aiven/aiven-go-client/v2"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -70,7 +71,7 @@ eliminate the member from the organization if one has accepted an invitation pre
func resourceOrganizationUserCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
client := m.(*aiven.Client)
organizationID := d.Get("organization_id").(string)
userEmail := d.Get("user_email").(string)
userEmail := strings.ToLower(d.Get("user_email").(string))

err := client.OrganizationUserInvitations.Invite(ctx, organizationID, aiven.OrganizationUserInvitationAddRequest{
UserEmail: userEmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package organization

import (
"context"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand All @@ -22,7 +23,7 @@ func DatasourceOrganizationUser() *schema.Resource {

func datasourceOrganizationUserRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
organizationID := d.Get("organization_id").(string)
userEmail := d.Get("user_email").(string)
userEmail := strings.ToLower(d.Get("user_email").(string))

d.SetId(schemautil.BuildResourceID(organizationID, userEmail))

Expand Down
2 changes: 1 addition & 1 deletion internal/sdkprovider/service/project/project_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func isProjectUserAlreadyInvited(err error) bool {
func resourceProjectUserCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
client := m.(*aiven.Client)
projectName := d.Get("project").(string)
email := d.Get("email").(string)
email := strings.ToLower(d.Get("email").(string))
err := client.ProjectUsers.Invite(
ctx,
projectName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package project

import (
"context"
"strings"

"github.com/aiven/aiven-go-client/v2"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand All @@ -23,7 +24,7 @@ func datasourceProjectUserRead(ctx context.Context, d *schema.ResourceData, m in
client := m.(*aiven.Client)

projectName := d.Get("project").(string)
email := d.Get("email").(string)
email := strings.ToLower(d.Get("email").(string))

users, invitations, err := client.ProjectUsers.List(ctx, projectName)
if err != nil {
Expand Down

0 comments on commit 57e5b14

Please sign in to comment.