diff --git a/internal/configs/import.go b/internal/configs/import.go index 69ba049a8d..3811cde5bd 100644 --- a/internal/configs/import.go +++ b/internal/configs/import.go @@ -131,7 +131,7 @@ func decodeImportBlock(block *hcl.Block) (*Import, hcl.Diagnostics) { imp.ForEach = attr.Expr } - // We need atleast one of ID or Identity to be set + // We need at least one of ID or Identity to be set if !idExists && !identityExists { diags = append(diags, &hcl.Diagnostic{ Severity: hcl.DiagError, diff --git a/internal/plugin/convert/schema.go b/internal/plugin/convert/schema.go index 8628985c4f..e0f62b19d0 100644 --- a/internal/plugin/convert/schema.go +++ b/internal/plugin/convert/schema.go @@ -61,16 +61,16 @@ func ConfigSchemaToProto(b *configschema.Block) *proto.Schema_Block { return block } -func ProtoToResourceIdentitySchema(s *proto.ResourceIdentitySchema) *providers.ResourceIdentitySchema { +func ProtoToResourceIdentitySchema(schema *proto.ResourceIdentitySchema) *providers.ResourceIdentitySchema { // This method is taking a similar approach to ProtoToConfigSchema below, basically - // We cant convert these, and so we should return nil here. - if s == nil { + // We can't convert these, and so we should return nil here. + if schema == nil { return nil } - attributes := make(map[string]*configschema.Attribute, len(s.IdentityAttributes)) - for _, a := range s.IdentityAttributes { + attributes := make(map[string]*configschema.Attribute, len(schema.IdentityAttributes)) + for _, a := range schema.IdentityAttributes { attribute := &configschema.Attribute{ Description: a.Description, Required: a.RequiredForImport, @@ -88,11 +88,11 @@ func ProtoToResourceIdentitySchema(s *proto.ResourceIdentitySchema) *providers.R } return &providers.ResourceIdentitySchema{ - Version: s.Version, + Version: schema.Version, Body: &configschema.Object{ Attributes: attributes, - Nesting: configschema.NestingSingle, // We dont allow nested schema here, hence we're using an Object and not a Block + Nesting: configschema.NestingSingle, // We don't allow nested schema here, hence we're using an Object and not a Block }, } } diff --git a/internal/plugin6/convert/schema.go b/internal/plugin6/convert/schema.go index 5d91bf03b5..1e874cf1d6 100644 --- a/internal/plugin6/convert/schema.go +++ b/internal/plugin6/convert/schema.go @@ -111,7 +111,7 @@ func ProtoToProviderSchema(s *proto.Schema) providers.Schema { func ProtoToResourceIdentitySchema(s *proto.ResourceIdentitySchema) *providers.ResourceIdentitySchema { // This method is taking a similar approach to ProtoToConfigSchema below, basically - // We cant convert these + // We can't convert these if s == nil { return nil } @@ -138,7 +138,7 @@ func ProtoToResourceIdentitySchema(s *proto.ResourceIdentitySchema) *providers.R Body: &configschema.Object{ Attributes: attributes, - Nesting: configschema.NestingSingle, // We dont allow nested schema here, hence we're using an Object and not a Block + Nesting: configschema.NestingSingle, // We don't allow nested schema here, hence we're using an Object and not a Block }, } } diff --git a/internal/plugin6/grpc_provider_test.go b/internal/plugin6/grpc_provider_test.go index 1177760b6f..6e7b5c924e 100644 --- a/internal/plugin6/grpc_provider_test.go +++ b/internal/plugin6/grpc_provider_test.go @@ -199,9 +199,10 @@ func TestGRPCProvider_GetSchema(t *testing.T) { } } +// TestGRPCProvider_GetSchema_WithResourceIdentitySchemas ensures that the provider client correctly +// attaches the resource identities to the resource schemas +// when you call GetProviderSchema. func TestGRPCProvider_GetSchema_WithResourceIdentitySchemas(t *testing.T) { - // This test ensures that the provider client correctly attaches the resource identities to the resource schemas - // when you call GetProviderSchema. ctrl := gomock.NewController(t) client := mockproto.NewMockProviderClient(ctrl) diff --git a/internal/states/instance_object.go b/internal/states/instance_object.go index a24c7401ed..4943e8bcf4 100644 --- a/internal/states/instance_object.go +++ b/internal/states/instance_object.go @@ -33,7 +33,7 @@ type ResourceInstanceObject struct { // a provider can use it for retaining any necessary private state. Private []byte - // TODO: godoc + // Identity is the resource identity for this instance Identity cty.Value // Status represents the "readiness" of the object as of the last time diff --git a/internal/states/instance_object_src.go b/internal/states/instance_object_src.go index 0ed4f11745..605c98bb80 100644 --- a/internal/states/instance_object_src.go +++ b/internal/states/instance_object_src.go @@ -74,10 +74,10 @@ type ResourceInstanceObjectSrc struct { CreateBeforeDestroy bool SkipDestroy bool - // TODO: godoc - IdentityJSON []byte - - // TODO: godoc + // IdentityJSON contains a JSON-encoded representation of the resourcde identity for this + // resource instance. Similar to AttrsJSON, this is handled in JSON format because + // schema versions change over time. + IdentityJSON []byte IdentitySchemaVersion *uint64 } diff --git a/internal/tofu/provider_for_test_framework.go b/internal/tofu/provider_for_test_framework.go index e63511572b..7f7a426b95 100644 --- a/internal/tofu/provider_for_test_framework.go +++ b/internal/tofu/provider_for_test_framework.go @@ -109,7 +109,7 @@ func (p providerForTest) ApplyResourceChange(_ context.Context, r providers.Appl func (p providerForTest) ReadDataSource(_ context.Context, r providers.ReadDataSourceRequest) providers.ReadDataSourceResponse { resSchema, _ := p.schema.SchemaForResourceType(addrs.DataResourceMode, r.TypeName) - + var resp providers.ReadDataSourceResponse resp.State, resp.Diagnostics = newMockValueComposer(r.TypeName).ComposeBySchema(resSchema.Block, r.Config, p.overrideValues) @@ -150,7 +150,6 @@ func (p providerForTest) GetProviderSchema(ctx context.Context) providers.GetPro } func (p providerForTest) GetResourceIdentitySchemas(ctx context.Context) providers.GetResourceIdentitySchemasResponse { - // TODO: Check if this is the correct way to handle this, im 95% certain it is return p.internal.GetResourceIdentitySchemas(ctx) }