Skip to content

Commit

Permalink
Switching to using schema <Type>PlanModifiers types for primitives an…
Browse files Browse the repository at this point in the history
…d adding missing equality checks in resource types
  • Loading branch information
bendbennett committed Sep 15, 2023
1 parent e0629f9 commit e00f454
Show file tree
Hide file tree
Showing 22 changed files with 133 additions and 38 deletions.
8 changes: 4 additions & 4 deletions internal/provider_convert/single_nested_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
Expand Down Expand Up @@ -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",
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions internal/resource_convert/bool_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions internal/resource_convert/float64_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions internal/resource_convert/int64_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions internal/resource_convert/number_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions internal/resource_convert/single_nested_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
Expand Down Expand Up @@ -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",
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions internal/resource_convert/string_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down
10 changes: 9 additions & 1 deletion internal/resource_generate/bool_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions internal/resource_generate/bool_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestGeneratorBoolAttribute_Imports(t *testing.T) {
},
"plan-modifier-custom-nil": {
input: GeneratorBoolAttribute{
PlanModifiers: []specschema.BoolPlanModifier{
PlanModifiers: specschema.BoolPlanModifiers{
{
Custom: nil,
},
Expand All @@ -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{},
Expand All @@ -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{
Expand All @@ -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{
Expand Down Expand Up @@ -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()",
Expand Down
10 changes: 9 additions & 1 deletion internal/resource_generate/float64_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/resource_generate/float64_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()",
Expand Down
10 changes: 9 additions & 1 deletion internal/resource_generate/int64_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/resource_generate/int64_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()",
Expand Down
8 changes: 8 additions & 0 deletions internal/resource_generate/list_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions internal/resource_generate/map_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 9 additions & 1 deletion internal/resource_generate/number_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/resource_generate/number_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()",
Expand Down
8 changes: 8 additions & 0 deletions internal/resource_generate/object_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions internal/resource_generate/set_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading

0 comments on commit e00f454

Please sign in to comment.