You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func TestRscResourceSchema(ctx context.Context) schema.Schema {
return schema.Schema{
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Computed: true,
Description: "Unique identifier for the interface",
MarkdownDescription: "Unique identifier for the interface",
},
"parameter_map": schema.MapNestedAttribute{
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"custom_attributes_nested_map": schema.MapAttribute{
ElementType: types.StringType,
Optional: true,
Description: "Custom attributes",
MarkdownDescription: "Custom attributes",
},
"serial_number": schema.StringAttribute{
Required: true,
Description: "Serial number of switch to configure",
MarkdownDescription: "Serial number of switch to configure",
},
},
CustomType: ParameterMapType{
ObjectType: types.ObjectType{
AttrTypes: ParameterMapValue{}.AttributeTypes(ctx),
},
},
},
Required: true,
Description: "interfaces to configure",
MarkdownDescription: "interfaces to configure",
},
"policy": schema.StringAttribute{
Required: true,
Description: "Name of the policy. Examples: `int_trunk_host`, `int_access_host`",
MarkdownDescription: "Name of the policy. Examples: `int_trunk_host`, `int_access_host`",
Validators: []validator.String{
stringvalidator.OneOf("int_trunk_host", "int_access_host"),
},
},
},
}
}
Expected Behavior
In this given resource the attribute custom_attributes_nested_map is marked optional as its not used always.
Expecting the attribute custom_attributes_nested_map to contain valid key-value pairs or it can be empty.
Facing a problem when custom_attributes_nested_map is left empty and not mentioned in config file
Expecting the plan to be successful with an empty/null map generated for custom_attributes_nested_map as it is optional
Actual Behavior
Planning failed.
Terraform encountered an error while generating this plan.
│ Error: Provider produced invalid plan
│
│ Provider "registry.terraform.io/cisco/ndfc" planned an invalid value for ndfc_test_rsc.test.parameter_map.test1.custom_attributes_nested_map: planned value
│ cty.MapValEmpty(cty.String) for a non-computed attribute.
│
Terraform expects MapNull but it gets MapValEmpty (This is coming from ToObjectValue in generated code)
tfplugingen-framework CLI version
v0.4.0
Provider Code Spec File
Schema Generated
Expected Behavior
In this given resource the attribute
custom_attributes_nested_map
is markedoptional
as its not used always.Expecting the attribute
custom_attributes_nested_map
to contain valid key-value pairs or it can be empty.Facing a problem when
custom_attributes_nested_map
is left empty and not mentioned in config fileSample config
Expecting the plan to be successful with an empty/null map generated for
custom_attributes_nested_map
as it isoptional
Actual Behavior
Planning failed.
Terraform expects
MapNull
but it getsMapValEmpty
(This is coming fromToObjectValue
in generated code)Additional Information
Work around
custom_attributes_nested_map
or
2) Change the attribute
custom_attributes_nested_map
tooptional_computed
Possible Solution:
This can be solved if the generated function
func (v ParameterMapValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) {
can set
custom_attributes_nested_map
tomapNull
if the map is empty instead of creating an returning an empty map.Kindly suggest if
ToObjectValue
can be modified to return MapNull in this situation or need to flag this to terraform as an inconsistency issue.Code of Conduct
The text was updated successfully, but these errors were encountered: