Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't override imported connection_client id #562

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions internal/auth0/attackprotection/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func dataSourceSchema() map[string]*schema.Schema {
}

func readAttackProtectionForDataSource(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics {
// This resource is not identified by an id in the Auth0 management API.
data.SetId(id.UniqueId())
return readAttackProtection(ctx, data, meta)
}
1 change: 1 addition & 0 deletions internal/auth0/branding/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func dataSourceSchema() map[string]*schema.Schema {
}

func readBrandingForDataSource(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics {
// This resource is not identified by an id in the Auth0 management API.
data.SetId(id.UniqueId())

api := meta.(*management.Management)
Expand Down
3 changes: 0 additions & 3 deletions internal/auth0/connection/resource_client_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strings"

"github.com/hashicorp/go-multierror"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/id"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -33,7 +32,5 @@ func importConnectionClient(
data.Set("client_id", idPair[1]),
)

data.SetId(id.UniqueId())

return []*schema.ResourceData{data}, result.ErrorOrNil()
}
2 changes: 1 addition & 1 deletion internal/auth0/connection/resource_client_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestImportConnectionClient(t *testing.T) {

assert.Equal(t, actualData[0].Get("connection_id").(string), testCase.expectedConnectionID)
assert.Equal(t, actualData[0].Get("client_id").(string), testCase.expectedClientID)
assert.NotEqual(t, actualData[0].Id(), testCase.givenID)
assert.Equal(t, actualData[0].Id(), testCase.givenID)
})
}
}
5 changes: 0 additions & 5 deletions internal/auth0/organization/resource_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strings"

"github.com/hashicorp/go-multierror"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/id"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -33,8 +32,6 @@ func importOrganizationConnection(
data.Set("connection_id", idPair[1]),
)

data.SetId(id.UniqueId())

return []*schema.ResourceData{data}, result.ErrorOrNil()
}

Expand Down Expand Up @@ -62,7 +59,5 @@ func importOrganizationMember(
data.Set("user_id", idPair[1]),
)

data.SetId(id.UniqueId())

return []*schema.ResourceData{data}, result.ErrorOrNil()
}
4 changes: 2 additions & 2 deletions internal/auth0/organization/resource_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestImportOrganizationConnection(t *testing.T) {

assert.Equal(t, actualData[0].Get("organization_id").(string), testCase.expectedOrganizationID)
assert.Equal(t, actualData[0].Get("connection_id").(string), testCase.expectedConnectionID)
assert.NotEqual(t, actualData[0].Id(), testCase.givenID)
assert.Equal(t, actualData[0].Id(), testCase.givenID)
})
}
}
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestImportOrganizationMember(t *testing.T) {

assert.Equal(t, actualData[0].Get("organization_id").(string), testCase.expectedOrganizationID)
assert.Equal(t, actualData[0].Get("user_id").(string), testCase.expectedUserID)
assert.NotEqual(t, actualData[0].Id(), testCase.givenID)
assert.Equal(t, actualData[0].Id(), testCase.givenID)
})
}
}
1 change: 1 addition & 0 deletions internal/auth0/tenant/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func readTenantForDataSource(ctx context.Context, data *schema.ResourceData, met
return diag.FromErr(fmt.Errorf("unable to determine management API URL: %w", err))
}

// This resource is not identified by an id in the Auth0 management API.
data.SetId(id.UniqueId())

result := multierror.Append(
Expand Down