Skip to content

Commit

Permalink
Consolidate how we import resource pair IDs across resources
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed May 8, 2023
1 parent d0573e4 commit f198556
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 329 deletions.
3 changes: 2 additions & 1 deletion internal/auth0/connection/resource_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/auth0/terraform-provider-auth0/internal/mutex"
internalSchema "github.com/auth0/terraform-provider-auth0/internal/schema"
)

var (
Expand Down Expand Up @@ -49,7 +50,7 @@ func NewClientResource() *schema.Resource {
ReadContext: readConnectionClient,
DeleteContext: deleteConnectionClient,
Importer: &schema.ResourceImporter{
StateContext: importConnectionClient,
StateContext: internalSchema.ImportResourcePairID("connection_id", "client_id"),
},
Description: "With this resource, you can enable a single client on a connection.",
}
Expand Down
36 changes: 0 additions & 36 deletions internal/auth0/connection/resource_client_import.go

This file was deleted.

61 changes: 0 additions & 61 deletions internal/auth0/connection/resource_client_import_test.go

This file was deleted.

3 changes: 2 additions & 1 deletion internal/auth0/organization/resource_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/auth0/terraform-provider-auth0/internal/mutex"
internalSchema "github.com/auth0/terraform-provider-auth0/internal/schema"
)

var (
Expand All @@ -27,7 +28,7 @@ func NewConnectionResource() *schema.Resource {
UpdateContext: updateOrganizationConnection,
DeleteContext: deleteOrganizationConnection,
Importer: &schema.ResourceImporter{
StateContext: importOrganizationConnection,
StateContext: internalSchema.ImportResourcePairID("organization_id", "connection_id"),
},
Schema: map[string]*schema.Schema{
"organization_id": {
Expand Down
63 changes: 0 additions & 63 deletions internal/auth0/organization/resource_import.go

This file was deleted.

112 changes: 0 additions & 112 deletions internal/auth0/organization/resource_import_test.go

This file was deleted.

8 changes: 2 additions & 6 deletions internal/auth0/organization/resource_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/auth0/terraform-provider-auth0/internal/mutex"
internalSchema "github.com/auth0/terraform-provider-auth0/internal/schema"
"github.com/auth0/terraform-provider-auth0/internal/value"
)

var (
errEmptyOrganizationMemberID = fmt.Errorf("ID cannot be empty")
errInvalidOrganizationMemberIDFormat = fmt.Errorf("ID must be formated as <organizationID>:<userID>")
)

// NewMemberResource will return a new auth0_organization_member resource.
func NewMemberResource() *schema.Resource {
return &schema.Resource{
Expand All @@ -27,7 +23,7 @@ func NewMemberResource() *schema.Resource {
UpdateContext: updateOrganizationMember,
DeleteContext: deleteOrganizationMember,
Importer: &schema.ResourceImporter{
StateContext: importOrganizationMember,
StateContext: internalSchema.ImportResourcePairID("organization_id", "user_id"),
},
Schema: map[string]*schema.Schema{
"organization_id": {
Expand Down
Loading

0 comments on commit f198556

Please sign in to comment.