diff --git a/internal/provider_convert/single_nested_block_test.go b/internal/provider_convert/single_nested_block_test.go index 027e8408..6fd0f837 100644 --- a/internal/provider_convert/single_nested_block_test.go +++ b/internal/provider_convert/single_nested_block_test.go @@ -218,9 +218,9 @@ func TestConvertSingleNestedBlock(t *testing.T) { NestedObject: provider.NestedBlockObject{ Attributes: []provider.Attribute{ { - Name: "nested_bool", + Name: "bool_attribute", Bool: &provider.BoolAttribute{ - OptionalRequired: "computed", + OptionalRequired: "optional", }, }, }, @@ -253,9 +253,9 @@ func TestConvertSingleNestedBlock(t *testing.T) { SingleNested: &provider.SingleNestedBlock{ Attributes: []provider.Attribute{ { - Name: "nested_bool", + Name: "bool_attribute", Bool: &provider.BoolAttribute{ - OptionalRequired: "computed", + OptionalRequired: "optional", }, }, }, diff --git a/internal/resource_convert/bool_attribute_test.go b/internal/resource_convert/bool_attribute_test.go index ff490f7c..595bf5e8 100644 --- a/internal/resource_convert/bool_attribute_test.go +++ b/internal/resource_convert/bool_attribute_test.go @@ -152,7 +152,7 @@ func TestConvertBoolAttribute(t *testing.T) { }, "plan-modifiers": { input: &resource.BoolAttribute{ - PlanModifiers: []specschema.BoolPlanModifier{ + PlanModifiers: specschema.BoolPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ @@ -166,7 +166,7 @@ func TestConvertBoolAttribute(t *testing.T) { }, }, expected: resource_generate.GeneratorBoolAttribute{ - PlanModifiers: []specschema.BoolPlanModifier{ + PlanModifiers: specschema.BoolPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ diff --git a/internal/resource_convert/float64_attribute_test.go b/internal/resource_convert/float64_attribute_test.go index db33fb2c..576ef09c 100644 --- a/internal/resource_convert/float64_attribute_test.go +++ b/internal/resource_convert/float64_attribute_test.go @@ -152,7 +152,7 @@ func TestConvertFloat64Attribute(t *testing.T) { }, "plan-modifiers": { input: &resource.Float64Attribute{ - PlanModifiers: []specschema.Float64PlanModifier{ + PlanModifiers: specschema.Float64PlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ @@ -166,7 +166,7 @@ func TestConvertFloat64Attribute(t *testing.T) { }, }, expected: resource_generate.GeneratorFloat64Attribute{ - PlanModifiers: []specschema.Float64PlanModifier{ + PlanModifiers: specschema.Float64PlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ diff --git a/internal/resource_convert/int64_attribute_test.go b/internal/resource_convert/int64_attribute_test.go index c5fc163c..9addbccd 100644 --- a/internal/resource_convert/int64_attribute_test.go +++ b/internal/resource_convert/int64_attribute_test.go @@ -152,7 +152,7 @@ func TestConvertInt64Attribute(t *testing.T) { }, "plan-modifiers": { input: &resource.Int64Attribute{ - PlanModifiers: []specschema.Int64PlanModifier{ + PlanModifiers: specschema.Int64PlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ @@ -166,7 +166,7 @@ func TestConvertInt64Attribute(t *testing.T) { }, }, expected: resource_generate.GeneratorInt64Attribute{ - PlanModifiers: []specschema.Int64PlanModifier{ + PlanModifiers: specschema.Int64PlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ diff --git a/internal/resource_convert/number_attribute_test.go b/internal/resource_convert/number_attribute_test.go index 421e3421..c722740d 100644 --- a/internal/resource_convert/number_attribute_test.go +++ b/internal/resource_convert/number_attribute_test.go @@ -152,7 +152,7 @@ func TestConvertNumberAttribute(t *testing.T) { }, "plan-modifiers": { input: &resource.NumberAttribute{ - PlanModifiers: []specschema.NumberPlanModifier{ + PlanModifiers: specschema.NumberPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ @@ -166,7 +166,7 @@ func TestConvertNumberAttribute(t *testing.T) { }, }, expected: resource_generate.GeneratorNumberAttribute{ - PlanModifiers: []specschema.NumberPlanModifier{ + PlanModifiers: specschema.NumberPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ diff --git a/internal/resource_convert/single_nested_block_test.go b/internal/resource_convert/single_nested_block_test.go index 1aa11fe3..202c8122 100644 --- a/internal/resource_convert/single_nested_block_test.go +++ b/internal/resource_convert/single_nested_block_test.go @@ -218,9 +218,9 @@ func TestConvertSingleNestedBlock(t *testing.T) { NestedObject: resource.NestedBlockObject{ Attributes: []resource.Attribute{ { - Name: "nested_bool", + Name: "bool_attribute", Bool: &resource.BoolAttribute{ - ComputedOptionalRequired: "computed", + ComputedOptionalRequired: "optional", }, }, }, @@ -253,9 +253,9 @@ func TestConvertSingleNestedBlock(t *testing.T) { SingleNested: &resource.SingleNestedBlock{ Attributes: []resource.Attribute{ { - Name: "nested_bool", + Name: "bool_attribute", Bool: &resource.BoolAttribute{ - ComputedOptionalRequired: "computed", + ComputedOptionalRequired: "optional", }, }, }, diff --git a/internal/resource_convert/string_attribute_test.go b/internal/resource_convert/string_attribute_test.go index 74bea78a..6eb668ec 100644 --- a/internal/resource_convert/string_attribute_test.go +++ b/internal/resource_convert/string_attribute_test.go @@ -152,7 +152,7 @@ func TestConvertStringAttribute(t *testing.T) { }, "plan-modifiers": { input: &resource.StringAttribute{ - PlanModifiers: []specschema.StringPlanModifier{ + PlanModifiers: specschema.StringPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ @@ -166,7 +166,7 @@ func TestConvertStringAttribute(t *testing.T) { }, }, expected: resource_generate.GeneratorStringAttribute{ - PlanModifiers: []specschema.StringPlanModifier{ + PlanModifiers: specschema.StringPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ diff --git a/internal/resource_generate/bool_attribute.go b/internal/resource_generate/bool_attribute.go index fa7c6097..d7177241 100644 --- a/internal/resource_generate/bool_attribute.go +++ b/internal/resource_generate/bool_attribute.go @@ -25,7 +25,7 @@ type GeneratorBoolAttribute struct { // because support for extracting custom import information is required. CustomType *specschema.CustomType Default *specschema.BoolDefault - PlanModifiers []specschema.BoolPlanModifier + PlanModifiers specschema.BoolPlanModifiers Validators specschema.BoolValidators } @@ -73,6 +73,14 @@ func (g GeneratorBoolAttribute) Equal(ga generatorschema.GeneratorAttribute) boo return false } + if !g.Default.Equal(h.Default) { + return false + } + + if !g.PlanModifiers.Equal(h.PlanModifiers) { + return false + } + if !g.Validators.Equal(h.Validators) { return false } diff --git a/internal/resource_generate/bool_attribute_test.go b/internal/resource_generate/bool_attribute_test.go index 99eb164f..ff402c37 100644 --- a/internal/resource_generate/bool_attribute_test.go +++ b/internal/resource_generate/bool_attribute_test.go @@ -143,7 +143,7 @@ func TestGeneratorBoolAttribute_Imports(t *testing.T) { }, "plan-modifier-custom-nil": { input: GeneratorBoolAttribute{ - PlanModifiers: []specschema.BoolPlanModifier{ + PlanModifiers: specschema.BoolPlanModifiers{ { Custom: nil, }, @@ -156,7 +156,7 @@ func TestGeneratorBoolAttribute_Imports(t *testing.T) { }, "plan-modifier-custom-import-nil": { input: GeneratorBoolAttribute{ - PlanModifiers: []specschema.BoolPlanModifier{ + PlanModifiers: specschema.BoolPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{}, @@ -171,7 +171,7 @@ func TestGeneratorBoolAttribute_Imports(t *testing.T) { }, "plan-modifiers-custom-import-empty-string": { input: GeneratorBoolAttribute{ - PlanModifiers: []specschema.BoolPlanModifier{ + PlanModifiers: specschema.BoolPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ @@ -190,7 +190,7 @@ func TestGeneratorBoolAttribute_Imports(t *testing.T) { }, "plan-modifier-custom-import": { input: GeneratorBoolAttribute{ - PlanModifiers: []specschema.BoolPlanModifier{ + PlanModifiers: specschema.BoolPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ Imports: []code.Import{ @@ -446,7 +446,7 @@ my_other_validator.Validate(), "plan-modifiers": { input: GeneratorBoolAttribute{ - PlanModifiers: []specschema.BoolPlanModifier{ + PlanModifiers: specschema.BoolPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ SchemaDefinition: "my_plan_modifier.Modify()", diff --git a/internal/resource_generate/float64_attribute.go b/internal/resource_generate/float64_attribute.go index dc8c73e6..ba672a71 100644 --- a/internal/resource_generate/float64_attribute.go +++ b/internal/resource_generate/float64_attribute.go @@ -26,7 +26,7 @@ type GeneratorFloat64Attribute struct { // because support for extracting custom import information is required. CustomType *specschema.CustomType Default *specschema.Float64Default - PlanModifiers []specschema.Float64PlanModifier + PlanModifiers specschema.Float64PlanModifiers Validators specschema.Float64Validators } @@ -74,6 +74,14 @@ func (g GeneratorFloat64Attribute) Equal(ga generatorschema.GeneratorAttribute) return false } + if !g.Default.Equal(h.Default) { + return false + } + + if !g.PlanModifiers.Equal(h.PlanModifiers) { + return false + } + if !g.Validators.Equal(h.Validators) { return false } diff --git a/internal/resource_generate/float64_attribute_test.go b/internal/resource_generate/float64_attribute_test.go index 303b81e6..920153d5 100644 --- a/internal/resource_generate/float64_attribute_test.go +++ b/internal/resource_generate/float64_attribute_test.go @@ -133,7 +133,7 @@ my_other_validator.Validate(), "plan-modifiers": { input: GeneratorFloat64Attribute{ - PlanModifiers: []specschema.Float64PlanModifier{ + PlanModifiers: specschema.Float64PlanModifiers{ { Custom: &specschema.CustomPlanModifier{ SchemaDefinition: "my_plan_modifier.Modify()", diff --git a/internal/resource_generate/int64_attribute.go b/internal/resource_generate/int64_attribute.go index 19b6f97c..b941a4c9 100644 --- a/internal/resource_generate/int64_attribute.go +++ b/internal/resource_generate/int64_attribute.go @@ -25,7 +25,7 @@ type GeneratorInt64Attribute struct { // because support for extracting custom import information is required. CustomType *specschema.CustomType Default *specschema.Int64Default - PlanModifiers []specschema.Int64PlanModifier + PlanModifiers specschema.Int64PlanModifiers Validators specschema.Int64Validators } @@ -73,6 +73,14 @@ func (g GeneratorInt64Attribute) Equal(ga generatorschema.GeneratorAttribute) bo return false } + if !g.Default.Equal(h.Default) { + return false + } + + if !g.PlanModifiers.Equal(h.PlanModifiers) { + return false + } + if !g.Validators.Equal(h.Validators) { return false } diff --git a/internal/resource_generate/int64_attribute_test.go b/internal/resource_generate/int64_attribute_test.go index d8e9ffac..93c5fdac 100644 --- a/internal/resource_generate/int64_attribute_test.go +++ b/internal/resource_generate/int64_attribute_test.go @@ -133,7 +133,7 @@ my_other_validator.Validate(), "plan-modifiers": { input: GeneratorInt64Attribute{ - PlanModifiers: []specschema.Int64PlanModifier{ + PlanModifiers: specschema.Int64PlanModifiers{ { Custom: &specschema.CustomPlanModifier{ SchemaDefinition: "my_plan_modifier.Modify()", diff --git a/internal/resource_generate/list_attribute.go b/internal/resource_generate/list_attribute.go index a9d66e98..a172cc42 100644 --- a/internal/resource_generate/list_attribute.go +++ b/internal/resource_generate/list_attribute.go @@ -77,10 +77,18 @@ func (g GeneratorListAttribute) Equal(ga generatorschema.GeneratorAttribute) boo return false } + if !g.Default.Equal(h.Default) { + return false + } + if !g.ElementType.Equal(h.ElementType) { return false } + if !g.PlanModifiers.Equal(h.PlanModifiers) { + return false + } + if !g.Validators.Equal(h.Validators) { return false } diff --git a/internal/resource_generate/map_attribute.go b/internal/resource_generate/map_attribute.go index 6c61c51d..c0e5d03e 100644 --- a/internal/resource_generate/map_attribute.go +++ b/internal/resource_generate/map_attribute.go @@ -77,10 +77,18 @@ func (g GeneratorMapAttribute) Equal(ga generatorschema.GeneratorAttribute) bool return false } + if !g.Default.Equal(h.Default) { + return false + } + if !g.ElementType.Equal(h.ElementType) { return false } + if !g.PlanModifiers.Equal(h.PlanModifiers) { + return false + } + if !g.Validators.Equal(h.Validators) { return false } diff --git a/internal/resource_generate/number_attribute.go b/internal/resource_generate/number_attribute.go index dd5633fa..e677af53 100644 --- a/internal/resource_generate/number_attribute.go +++ b/internal/resource_generate/number_attribute.go @@ -23,7 +23,7 @@ type GeneratorNumberAttribute struct { // because support for extracting custom import information is required. CustomType *specschema.CustomType Default *specschema.NumberDefault - PlanModifiers []specschema.NumberPlanModifier + PlanModifiers specschema.NumberPlanModifiers Validators specschema.NumberValidators } @@ -65,6 +65,14 @@ func (g GeneratorNumberAttribute) Equal(ga generatorschema.GeneratorAttribute) b return false } + if !g.Default.Equal(h.Default) { + return false + } + + if !g.PlanModifiers.Equal(h.PlanModifiers) { + return false + } + if !g.Validators.Equal(h.Validators) { return false } diff --git a/internal/resource_generate/number_attribute_test.go b/internal/resource_generate/number_attribute_test.go index f7d48c17..5ee50110 100644 --- a/internal/resource_generate/number_attribute_test.go +++ b/internal/resource_generate/number_attribute_test.go @@ -133,7 +133,7 @@ my_other_validator.Validate(), "plan-modifiers": { input: GeneratorNumberAttribute{ - PlanModifiers: []specschema.NumberPlanModifier{ + PlanModifiers: specschema.NumberPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ SchemaDefinition: "my_plan_modifier.Modify()", diff --git a/internal/resource_generate/object_attribute.go b/internal/resource_generate/object_attribute.go index b2584666..81ec683c 100644 --- a/internal/resource_generate/object_attribute.go +++ b/internal/resource_generate/object_attribute.go @@ -75,6 +75,14 @@ func (g GeneratorObjectAttribute) Equal(ga generatorschema.GeneratorAttribute) b return false } + if !g.Default.Equal(h.Default) { + return false + } + + if !g.PlanModifiers.Equal(h.PlanModifiers) { + return false + } + if !g.Validators.Equal(h.Validators) { return false } diff --git a/internal/resource_generate/set_attribute.go b/internal/resource_generate/set_attribute.go index 9bddd717..daced641 100644 --- a/internal/resource_generate/set_attribute.go +++ b/internal/resource_generate/set_attribute.go @@ -77,10 +77,18 @@ func (g GeneratorSetAttribute) Equal(ga generatorschema.GeneratorAttribute) bool return false } + if !g.Default.Equal(h.Default) { + return false + } + if !g.ElementType.Equal(h.ElementType) { return false } + if !g.PlanModifiers.Equal(h.PlanModifiers) { + return false + } + if !g.Validators.Equal(h.Validators) { return false } diff --git a/internal/resource_generate/single_nested_block.go b/internal/resource_generate/single_nested_block.go index b4afc56e..98f44dc3 100644 --- a/internal/resource_generate/single_nested_block.go +++ b/internal/resource_generate/single_nested_block.go @@ -73,25 +73,48 @@ func (g GeneratorSingleNestedBlock) Imports() *generatorschema.Imports { func (g GeneratorSingleNestedBlock) Equal(ga generatorschema.GeneratorBlock) bool { h, ok := ga.(GeneratorSingleNestedBlock) + if !ok { return false } + for k := range g.Attributes { + if _, ok := h.Attributes[k]; !ok { + return false + } + + if !g.Attributes[k].Equal(h.Attributes[k]) { + return false + } + } + + for k := range g.Blocks { + if _, ok := h.Blocks[k]; !ok { + return false + } + + if !g.Blocks[k].Equal(h.Blocks[k]) { + return false + } + } + + if !g.AssociatedExternalType.Equal(h.AssociatedExternalType) { + return false + } + if !g.CustomType.Equal(h.CustomType) { return false } - if !g.Validators.Equal(h.Validators) { + if !g.PlanModifiers.Equal(h.PlanModifiers) { return false } - for k, a := range g.Attributes { - if !a.Equal(h.Attributes[k]) { - return false - } + if !g.Validators.Equal(h.Validators) { + return false } - return true + return g.SingleNestedBlock.Equal(h.SingleNestedBlock) } func (g GeneratorSingleNestedBlock) ToString(name string) (string, error) { diff --git a/internal/resource_generate/string_attribute.go b/internal/resource_generate/string_attribute.go index 9263d6df..43595cf2 100644 --- a/internal/resource_generate/string_attribute.go +++ b/internal/resource_generate/string_attribute.go @@ -25,7 +25,7 @@ type GeneratorStringAttribute struct { // because support for extracting custom import information is required. CustomType *specschema.CustomType Default *specschema.StringDefault - PlanModifiers []specschema.StringPlanModifier + PlanModifiers specschema.StringPlanModifiers Validators specschema.StringValidators } @@ -73,6 +73,14 @@ func (g GeneratorStringAttribute) Equal(ga generatorschema.GeneratorAttribute) b return false } + if !g.Default.Equal(h.Default) { + return false + } + + if !g.PlanModifiers.Equal(h.PlanModifiers) { + return false + } + if !g.Validators.Equal(h.Validators) { return false } diff --git a/internal/resource_generate/string_attribute_test.go b/internal/resource_generate/string_attribute_test.go index c76f407a..84257a71 100644 --- a/internal/resource_generate/string_attribute_test.go +++ b/internal/resource_generate/string_attribute_test.go @@ -133,7 +133,7 @@ my_other_validator.Validate(), "plan-modifiers": { input: GeneratorStringAttribute{ - PlanModifiers: []specschema.StringPlanModifier{ + PlanModifiers: specschema.StringPlanModifiers{ { Custom: &specschema.CustomPlanModifier{ SchemaDefinition: "my_plan_modifier.Modify()",