Skip to content

Commit 63bcd66

Browse files
rainkwanaustinvalle
authored andcommitted
Renaming the method and interface just for the resource
1 parent f2bb5ef commit 63bcd66

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

internal/fwserver/server_upgraderesourceidentity.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (s *Server) UpgradeResourceIdentity(ctx context.Context, req *UpgradeResour
9494
}
9595
}
9696

97-
resourceWithUpgradeResourceIdentity, ok := req.Resource.(resource.ResourceWithUpgradeResourceIdentity)
97+
resourceWithUpgradeResourceIdentity, ok := req.Resource.(resource.ResourceWithUpgradeIdentity)
9898

9999
if !ok {
100100
resp.Diagnostics.AddError(
@@ -106,11 +106,11 @@ func (s *Server) UpgradeResourceIdentity(ctx context.Context, req *UpgradeResour
106106
return
107107
}
108108

109-
logging.FrameworkTrace(ctx, "Resource implements ResourceWithUpgradeResourceIdentity")
109+
logging.FrameworkTrace(ctx, "Resource implements ResourceWithUpgradeIdentity")
110110

111-
logging.FrameworkTrace(ctx, "Calling provider defined Resource UpgradeResourceIdentity")
112-
resourceIdentityUpgraders := resourceWithUpgradeResourceIdentity.UpgradeResourceIdentity(ctx)
113-
logging.FrameworkTrace(ctx, "Called provider defined Resource UpgradeResourceIdentity")
111+
logging.FrameworkTrace(ctx, "Calling provider defined Resource UpgradeIdentity")
112+
resourceIdentityUpgraders := resourceWithUpgradeResourceIdentity.UpgradeIdentity(ctx)
113+
logging.FrameworkTrace(ctx, "Called provider defined Resource UpgradeIdentity")
114114

115115
// Panic prevention
116116
if resourceIdentityUpgraders == nil {
@@ -134,7 +134,7 @@ func (s *Server) UpgradeResourceIdentity(ctx context.Context, req *UpgradeResour
134134
}
135135

136136
if resourceIdentityUpgrader.PriorSchema != nil {
137-
logging.FrameworkTrace(ctx, "Initializing populated UpgradeResourceIdentityRequest Identity from provider defined prior schema and request RawState")
137+
logging.FrameworkTrace(ctx, "Initializing populated UpgradeIdentityRequest Identity from provider defined prior schema and request RawState")
138138

139139
priorSchemaType := resourceIdentityUpgrader.PriorSchema.Type().TerraformType(ctx)
140140

internal/testing/testprovider/resourcewithconfigureandupgradeidentity.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
var _ resource.Resource = &ResourceWithConfigureAndUpgradeResourceIdentity{}
1313
var _ resource.ResourceWithConfigure = &ResourceWithConfigureAndUpgradeResourceIdentity{}
14-
var _ resource.ResourceWithUpgradeResourceIdentity = &ResourceWithConfigureAndUpgradeResourceIdentity{}
14+
var _ resource.ResourceWithUpgradeIdentity = &ResourceWithConfigureAndUpgradeResourceIdentity{}
1515

1616
// Declarative resource.ResourceWithConfigureAndUpgradeResourceIdentity for unit testing.
1717
type ResourceWithConfigureAndUpgradeResourceIdentity struct {
@@ -34,7 +34,7 @@ func (r *ResourceWithConfigureAndUpgradeResourceIdentity) Configure(ctx context.
3434
}
3535

3636
// UpgradeResourceIdentity satisfies the resource.ResourceWithUpgradeResourceIdentity interface.
37-
func (r *ResourceWithConfigureAndUpgradeResourceIdentity) UpgradeResourceIdentity(ctx context.Context) map[int64]resource.IdentityUpgrader {
37+
func (r *ResourceWithConfigureAndUpgradeResourceIdentity) UpgradeIdentity(ctx context.Context) map[int64]resource.IdentityUpgrader {
3838
if r.UpgradeResourceIdentityMethod == nil {
3939
return nil
4040
}

internal/testing/testprovider/resourcewithupgradeidentity.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
var _ resource.Resource = &ResourceWithUpgradeResourceIdentity{}
13-
var _ resource.ResourceWithUpgradeResourceIdentity = &ResourceWithUpgradeResourceIdentity{}
13+
var _ resource.ResourceWithUpgradeIdentity = &ResourceWithUpgradeResourceIdentity{}
1414

1515
// Declarative resource.ResourceWithUpgradeResourceIdentity for unit testing.
1616
type ResourceWithUpgradeResourceIdentity struct {
@@ -24,7 +24,7 @@ type ResourceWithUpgradeResourceIdentity struct {
2424
}
2525

2626
// UpgradeResourceIdentity satisfies the resource.ResourceWithUpgradeResourceIdentity interface.
27-
func (p *ResourceWithUpgradeResourceIdentity) UpgradeResourceIdentity(ctx context.Context) map[int64]resource.IdentityUpgrader {
27+
func (p *ResourceWithUpgradeResourceIdentity) UpgradeIdentity(ctx context.Context) map[int64]resource.IdentityUpgrader {
2828
if p.UpgradeResourceIdentityMethod == nil {
2929
return nil
3030
}

resource/identity_upgrader.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ import (
88
"github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
99
)
1010

11-
// Implementation handler for an UpgradeResourceIdentity operation.
11+
// Implementation handler for an UpgradeIdentity operation.
1212
//
1313
// This is used to encapsulate all upgrade logic from a prior identity to the
1414
// current version when a Resource implements the
15-
// ResourceWithUpgradeResourceIdentity interface.
15+
// ResourceWithUpgradeIdentity interface.
1616
type IdentityUpgrader struct {
1717
// Schema information for the prior identity version. While not required,
18-
// setting this will populate the UpgradeResourceIdentityRequest type Identity
18+
// setting this will populate the UpgradeIdentityRequest type Identity
1919
// field similar to other Resource data types. This allows for easier data
2020
// handling such as calling Get() or GetAttribute().
2121
//
2222
// If not set, prior identity data is available in the
23-
// UpgradeResourceIdentityRequest type RawIdentity field.
23+
// UpgradeIdentityRequest type RawIdentity field.
2424
PriorSchema *identityschema.Schema
2525

2626
// Provider defined logic for upgrading a resource identity from the prior
@@ -29,11 +29,11 @@ type IdentityUpgrader struct {
2929
// The context.Context parameter contains framework-defined loggers and
3030
// supports request cancellation.
3131
//
32-
// The UpgradeResourceIdentityRequest parameter contains the prior identity data.
32+
// The UpgradeIdentityRequest parameter contains the prior identity data.
3333
// If PriorSchema was set, the Identity field will be available. Otherwise,
3434
// the RawIdentity must be used.
3535
//
36-
// The UpgradeResourceIdentityResponse parameter should contain the upgraded
36+
// The UpgradeIdentityResponse parameter should contain the upgraded
3737
// identity data and can be used to signal any logic warnings or errors.
3838
IdentityUpgrader func(context.Context, UpgradeIdentityRequest, *UpgradeIdentityResponse)
3939
}

resource/identityschema/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Schema struct {
2929

3030
// Version indicates the current version of the resource identity schema. Resource
3131
// identity schema versioning enables identity state upgrades in conjunction with the
32-
// [resource.ResourceWithUpgradeResourceIdentity] interface. Versioning is only
32+
// [resource.ResourceWithUpgradeIdentity] interface. Versioning is only
3333
// required if there is a breaking change involving existing identity state data,
3434
// such as changing an attribute type in a manner that is incompatible with the Terraform type.
3535
//

resource/resource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ type ResourceWithValidateConfig interface {
216216
// by the identity object via the ResourceWithImportState interface.
217217
// - The resource identity should not change during the lifecycle of the remote object. That is, from the
218218
// creation of the remote object in the remote system until its destruction. An exception to this rule
219-
// is an upgrade of the identity data after a schema change, via the ResourceWithUpgradeResourceIdentity interface.
219+
// is an upgrade of the identity data after a schema change, via the ResourceWithUpgradeIdentity interface.
220220
type ResourceWithIdentity interface {
221221
Resource
222222

223223
// IdentitySchema should return the identity schema for this resource.
224224
IdentitySchema(context.Context, IdentitySchemaRequest, *IdentitySchemaResponse)
225225
}
226226

227-
type ResourceWithUpgradeResourceIdentity interface {
227+
type ResourceWithUpgradeIdentity interface {
228228
Resource
229229

230230
// A mapping of the prior identity version to current identity upgrade
@@ -236,5 +236,5 @@ type ResourceWithUpgradeResourceIdentity interface {
236236
// Version keys begin at 0, which is the default schema version when
237237
// undefined. The framework will return an error diagnostic should the
238238
// requested identity version not be implemented.
239-
UpgradeResourceIdentity(context.Context) map[int64]IdentityUpgrader
239+
UpgradeIdentity(context.Context) map[int64]IdentityUpgrader
240240
}

0 commit comments

Comments
 (0)