mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-31 18:02:48 -04:00
feedback addressing
Signed-off-by: James Humphries <james@james-humphries.co.uk>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user