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 0d11e4d
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 341 deletions.
9 changes: 2 additions & 7 deletions internal/auth0/connection/resource_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package connection

import (
"context"
"fmt"
"net/http"

"github.com/auth0/go-auth0/management"
Expand All @@ -11,11 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

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

var (
errEmptyConnectionClientID = fmt.Errorf("ID cannot be empty")
errInvalidConnectionClientIDFormat = fmt.Errorf("ID must be formated as <connectionID>:<clientID>")
internalSchema "github.com/auth0/terraform-provider-auth0/internal/schema"
)

// NewClientResource will return a new auth0_connection_client (1:1) resource.
Expand Down Expand Up @@ -49,7 +44,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.

9 changes: 2 additions & 7 deletions internal/auth0/organization/resource_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package organization

import (
"context"
"fmt"
"net/http"

"github.com/auth0/go-auth0/management"
Expand All @@ -11,11 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

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

var (
errEmptyOrganizationConnectionID = fmt.Errorf("ID cannot be empty")
errInvalidOrganizationConnectionIDFormat = fmt.Errorf("ID must be formated as <organizationID>:<connectionID>")
internalSchema "github.com/auth0/terraform-provider-auth0/internal/schema"
)

// NewConnectionResource will return a new auth0_organization_connection resource.
Expand All @@ -27,7 +22,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 0d11e4d

Please sign in to comment.