Skip to content

Commit

Permalink
Merge branch 'main' into add-convert-to-attribute
Browse files Browse the repository at this point in the history
# Conflicts:
#	internal/providers/pluginfw/tfschema/attribute_builder.go
#	internal/providers/pluginfw/tfschema/customizable_schema_test.go
  • Loading branch information
mgyucht committed Dec 3, 2024
2 parents 25ae4ba + 8e3117a commit 7ba55dd
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 66 deletions.
10 changes: 5 additions & 5 deletions internal/providers/pluginfw/tfschema/attribute_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ type AttributeBuilder interface {

// SetOptional sets the attribute as optional in the schema. This does not affect whether the attribute is computed.
// It fails if the attribute is already optional.
SetOptional() BaseSchemaBuilder
SetOptional() AttributeBuilder

// SetRequired sets the attribute as required in the schema. This does not affect whether the attribute is computed.
// It fails if the attribute is already required.
SetRequired() BaseSchemaBuilder
SetRequired() AttributeBuilder

// SetSensitive sets the attribute as sensitive in the schema. It fails if the attribute is already sensitive.
SetSensitive() BaseSchemaBuilder
SetSensitive() AttributeBuilder

// SetComputed sets the attribute as computed in the schema. It fails if the attribute is already computed.
SetComputed() BaseSchemaBuilder
SetComputed() AttributeBuilder

// Sets the attribute as read-only in the schema, i.e. computed and neither optional or required. It fails if the
// attribute is already read-only.
SetReadOnly() BaseSchemaBuilder
SetReadOnly() AttributeBuilder

BuildDataSourceAttribute() dataschema.Attribute
BuildResourceAttribute() schema.Attribute
Expand Down
14 changes: 7 additions & 7 deletions internal/providers/pluginfw/tfschema/bool_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (a BoolAttributeBuilder) BuildResourceAttribute() schema.Attribute {
}
}

func (a BoolAttributeBuilder) SetOptional() BaseSchemaBuilder {
func (a BoolAttributeBuilder) SetOptional() AttributeBuilder {
if a.Optional && !a.Required {
panic("attribute is already optional")
}
Expand All @@ -49,7 +49,7 @@ func (a BoolAttributeBuilder) SetOptional() BaseSchemaBuilder {
return a
}

func (a BoolAttributeBuilder) SetRequired() BaseSchemaBuilder {
func (a BoolAttributeBuilder) SetRequired() AttributeBuilder {
if !a.Optional && a.Required {
panic("attribute is already required")
}
Expand All @@ -58,23 +58,23 @@ func (a BoolAttributeBuilder) SetRequired() BaseSchemaBuilder {
return a
}

func (a BoolAttributeBuilder) SetSensitive() BaseSchemaBuilder {
func (a BoolAttributeBuilder) SetSensitive() AttributeBuilder {
if a.Sensitive {
panic("attribute is already sensitive")
}
a.Sensitive = true
return a
}

func (a BoolAttributeBuilder) SetComputed() BaseSchemaBuilder {
func (a BoolAttributeBuilder) SetComputed() AttributeBuilder {
if a.Computed {
panic("attribute is already computed")
}
a.Computed = true
return a
}

func (a BoolAttributeBuilder) SetReadOnly() BaseSchemaBuilder {
func (a BoolAttributeBuilder) SetReadOnly() AttributeBuilder {
if a.Computed && !a.Optional && !a.Required {
panic("attribute is already read only")
}
Expand All @@ -89,12 +89,12 @@ func (a BoolAttributeBuilder) SetDeprecated(msg string) BaseSchemaBuilder {
return a
}

func (a BoolAttributeBuilder) AddValidator(v validator.Bool) BaseSchemaBuilder {
func (a BoolAttributeBuilder) AddValidator(v validator.Bool) AttributeBuilder {
a.Validators = append(a.Validators, v)
return a
}

func (a BoolAttributeBuilder) AddPlanModifier(v planmodifier.Bool) BaseSchemaBuilder {
func (a BoolAttributeBuilder) AddPlanModifier(v planmodifier.Bool) AttributeBuilder {
a.PlanModifiers = append(a.PlanModifiers, v)
return a
}
14 changes: 7 additions & 7 deletions internal/providers/pluginfw/tfschema/float64_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (a Float64AttributeBuilder) BuildResourceAttribute() schema.Attribute {
}
}

func (a Float64AttributeBuilder) SetOptional() BaseSchemaBuilder {
func (a Float64AttributeBuilder) SetOptional() AttributeBuilder {
if a.Optional && !a.Required {
panic("attribute is already optional")
}
Expand All @@ -49,7 +49,7 @@ func (a Float64AttributeBuilder) SetOptional() BaseSchemaBuilder {
return a
}

func (a Float64AttributeBuilder) SetRequired() BaseSchemaBuilder {
func (a Float64AttributeBuilder) SetRequired() AttributeBuilder {
if !a.Optional && a.Required {
panic("attribute is already required")
}
Expand All @@ -58,23 +58,23 @@ func (a Float64AttributeBuilder) SetRequired() BaseSchemaBuilder {
return a
}

func (a Float64AttributeBuilder) SetSensitive() BaseSchemaBuilder {
func (a Float64AttributeBuilder) SetSensitive() AttributeBuilder {
if a.Sensitive {
panic("attribute is already sensitive")
}
a.Sensitive = true
return a
}

func (a Float64AttributeBuilder) SetComputed() BaseSchemaBuilder {
func (a Float64AttributeBuilder) SetComputed() AttributeBuilder {
if a.Computed {
panic("attribute is already computed")
}
a.Computed = true
return a
}

func (a Float64AttributeBuilder) SetReadOnly() BaseSchemaBuilder {
func (a Float64AttributeBuilder) SetReadOnly() AttributeBuilder {
if a.Computed && !a.Optional && !a.Required {
panic("attribute is already read only")
}
Expand All @@ -89,12 +89,12 @@ func (a Float64AttributeBuilder) SetDeprecated(msg string) BaseSchemaBuilder {
return a
}

func (a Float64AttributeBuilder) AddValidator(v validator.Float64) BaseSchemaBuilder {
func (a Float64AttributeBuilder) AddValidator(v validator.Float64) AttributeBuilder {
a.Validators = append(a.Validators, v)
return a
}

func (a Float64AttributeBuilder) AddPlanModifier(v planmodifier.Float64) BaseSchemaBuilder {
func (a Float64AttributeBuilder) AddPlanModifier(v planmodifier.Float64) AttributeBuilder {
a.PlanModifiers = append(a.PlanModifiers, v)
return a
}
14 changes: 7 additions & 7 deletions internal/providers/pluginfw/tfschema/int64_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (a Int64AttributeBuilder) BuildResourceAttribute() schema.Attribute {
}
}

func (a Int64AttributeBuilder) SetOptional() BaseSchemaBuilder {
func (a Int64AttributeBuilder) SetOptional() AttributeBuilder {
if a.Optional && !a.Required {
panic("attribute is already optional")
}
Expand All @@ -49,7 +49,7 @@ func (a Int64AttributeBuilder) SetOptional() BaseSchemaBuilder {
return a
}

func (a Int64AttributeBuilder) SetRequired() BaseSchemaBuilder {
func (a Int64AttributeBuilder) SetRequired() AttributeBuilder {
if !a.Optional && a.Required {
panic("attribute is already required")
}
Expand All @@ -58,23 +58,23 @@ func (a Int64AttributeBuilder) SetRequired() BaseSchemaBuilder {
return a
}

func (a Int64AttributeBuilder) SetSensitive() BaseSchemaBuilder {
func (a Int64AttributeBuilder) SetSensitive() AttributeBuilder {
if a.Sensitive {
panic("attribute is already sensitive")
}
a.Sensitive = true
return a
}

func (a Int64AttributeBuilder) SetComputed() BaseSchemaBuilder {
func (a Int64AttributeBuilder) SetComputed() AttributeBuilder {
if a.Computed {
panic("attribute is already computed")
}
a.Computed = true
return a
}

func (a Int64AttributeBuilder) SetReadOnly() BaseSchemaBuilder {
func (a Int64AttributeBuilder) SetReadOnly() AttributeBuilder {
if a.Computed && !a.Optional && !a.Required {
panic("attribute is already read only")
}
Expand All @@ -89,12 +89,12 @@ func (a Int64AttributeBuilder) SetDeprecated(msg string) BaseSchemaBuilder {
return a
}

func (a Int64AttributeBuilder) AddValidator(v validator.Int64) BaseSchemaBuilder {
func (a Int64AttributeBuilder) AddValidator(v validator.Int64) AttributeBuilder {
a.Validators = append(a.Validators, v)
return a
}

func (a Int64AttributeBuilder) AddPlanModifier(v planmodifier.Int64) BaseSchemaBuilder {
func (a Int64AttributeBuilder) AddPlanModifier(v planmodifier.Int64) AttributeBuilder {
a.PlanModifiers = append(a.PlanModifiers, v)
return a
}
14 changes: 7 additions & 7 deletions internal/providers/pluginfw/tfschema/list_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (a ListAttributeBuilder) BuildResourceAttribute() schema.Attribute {
}
}

func (a ListAttributeBuilder) SetOptional() BaseSchemaBuilder {
func (a ListAttributeBuilder) SetOptional() AttributeBuilder {
if a.Optional && !a.Required {
panic("attribute is already optional")
}
Expand All @@ -54,7 +54,7 @@ func (a ListAttributeBuilder) SetOptional() BaseSchemaBuilder {
return a
}

func (a ListAttributeBuilder) SetRequired() BaseSchemaBuilder {
func (a ListAttributeBuilder) SetRequired() AttributeBuilder {
if !a.Optional && a.Required {
panic("attribute is already required")
}
Expand All @@ -63,23 +63,23 @@ func (a ListAttributeBuilder) SetRequired() BaseSchemaBuilder {
return a
}

func (a ListAttributeBuilder) SetSensitive() BaseSchemaBuilder {
func (a ListAttributeBuilder) SetSensitive() AttributeBuilder {
if a.Sensitive {
panic("attribute is already sensitive")
}
a.Sensitive = true
return a
}

func (a ListAttributeBuilder) SetComputed() BaseSchemaBuilder {
func (a ListAttributeBuilder) SetComputed() AttributeBuilder {
if a.Computed {
panic("attribute is already computed")
}
a.Computed = true
return a
}

func (a ListAttributeBuilder) SetReadOnly() BaseSchemaBuilder {
func (a ListAttributeBuilder) SetReadOnly() AttributeBuilder {
if a.Computed && !a.Optional && !a.Required {
panic("attribute is already read only")
}
Expand All @@ -94,12 +94,12 @@ func (a ListAttributeBuilder) SetDeprecated(msg string) BaseSchemaBuilder {
return a
}

func (a ListAttributeBuilder) AddValidator(v validator.List) BaseSchemaBuilder {
func (a ListAttributeBuilder) AddValidator(v validator.List) AttributeBuilder {
a.Validators = append(a.Validators, v)
return a
}

func (a ListAttributeBuilder) AddPlanModifier(v planmodifier.List) BaseSchemaBuilder {
func (a ListAttributeBuilder) AddPlanModifier(v planmodifier.List) AttributeBuilder {
a.PlanModifiers = append(a.PlanModifiers, v)
return a
}
10 changes: 5 additions & 5 deletions internal/providers/pluginfw/tfschema/list_nested_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (a ListNestedAttributeBuilder) BuildResourceAttribute() schema.Attribute {
}
}

func (a ListNestedAttributeBuilder) SetOptional() BaseSchemaBuilder {
func (a ListNestedAttributeBuilder) SetOptional() AttributeBuilder {
if a.Optional && !a.Required {
panic("attribute is already optional")
}
Expand All @@ -53,7 +53,7 @@ func (a ListNestedAttributeBuilder) SetOptional() BaseSchemaBuilder {
return a
}

func (a ListNestedAttributeBuilder) SetRequired() BaseSchemaBuilder {
func (a ListNestedAttributeBuilder) SetRequired() AttributeBuilder {
if !a.Optional && a.Required {
panic("attribute is already required")
}
Expand All @@ -62,23 +62,23 @@ func (a ListNestedAttributeBuilder) SetRequired() BaseSchemaBuilder {
return a
}

func (a ListNestedAttributeBuilder) SetSensitive() BaseSchemaBuilder {
func (a ListNestedAttributeBuilder) SetSensitive() AttributeBuilder {
if a.Sensitive {
panic("attribute is already sensitive")
}
a.Sensitive = true
return a
}

func (a ListNestedAttributeBuilder) SetComputed() BaseSchemaBuilder {
func (a ListNestedAttributeBuilder) SetComputed() AttributeBuilder {
if a.Computed {
panic("attribute is already computed")
}
a.Computed = true
return a
}

func (a ListNestedAttributeBuilder) SetReadOnly() BaseSchemaBuilder {
func (a ListNestedAttributeBuilder) SetReadOnly() AttributeBuilder {
if a.Computed && !a.Optional && !a.Required {
panic("attribute is already read only")
}
Expand Down
14 changes: 7 additions & 7 deletions internal/providers/pluginfw/tfschema/map_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (a MapAttributeBuilder) BuildResourceAttribute() schema.Attribute {
}
}

func (a MapAttributeBuilder) SetOptional() BaseSchemaBuilder {
func (a MapAttributeBuilder) SetOptional() AttributeBuilder {
if a.Optional && !a.Required {
panic("attribute is already optional")
}
Expand All @@ -54,7 +54,7 @@ func (a MapAttributeBuilder) SetOptional() BaseSchemaBuilder {
return a
}

func (a MapAttributeBuilder) SetRequired() BaseSchemaBuilder {
func (a MapAttributeBuilder) SetRequired() AttributeBuilder {
if !a.Optional && a.Required {
panic("attribute is already required")
}
Expand All @@ -63,23 +63,23 @@ func (a MapAttributeBuilder) SetRequired() BaseSchemaBuilder {
return a
}

func (a MapAttributeBuilder) SetSensitive() BaseSchemaBuilder {
func (a MapAttributeBuilder) SetSensitive() AttributeBuilder {
if a.Sensitive {
panic("attribute is already sensitive")
}
a.Sensitive = true
return a
}

func (a MapAttributeBuilder) SetComputed() BaseSchemaBuilder {
func (a MapAttributeBuilder) SetComputed() AttributeBuilder {
if a.Computed {
panic("attribute is already computed")
}
a.Computed = true
return a
}

func (a MapAttributeBuilder) SetReadOnly() BaseSchemaBuilder {
func (a MapAttributeBuilder) SetReadOnly() AttributeBuilder {
if a.Computed && !a.Optional && !a.Required {
panic("attribute is already read only")
}
Expand All @@ -94,12 +94,12 @@ func (a MapAttributeBuilder) SetDeprecated(msg string) BaseSchemaBuilder {
return a
}

func (a MapAttributeBuilder) AddValidator(v validator.Map) BaseSchemaBuilder {
func (a MapAttributeBuilder) AddValidator(v validator.Map) AttributeBuilder {
a.Validators = append(a.Validators, v)
return a
}

func (a MapAttributeBuilder) AddPlanModifier(v planmodifier.Map) BaseSchemaBuilder {
func (a MapAttributeBuilder) AddPlanModifier(v planmodifier.Map) AttributeBuilder {
a.PlanModifiers = append(a.PlanModifiers, v)
return a
}
Loading

0 comments on commit 7ba55dd

Please sign in to comment.