Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/557.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
resource/schema/planmodifier: New package which contains type-specific schema plan modifier interfaces
```
82 changes: 82 additions & 0 deletions internal/fwschema/fwxschema/attribute_plan_modification.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fwxschema

import (
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
)

Expand All @@ -17,3 +18,84 @@ type AttributeWithPlanModifiers interface {
// the tfsdk.Attribute field name.
GetPlanModifiers() tfsdk.AttributePlanModifiers
}

// AttributeWithBoolPlanModifiers is an optional interface on Attribute which
// enables Bool plan modifier support.
type AttributeWithBoolPlanModifiers interface {
fwschema.Attribute

// BoolPlanModifiers should return a list of Bool plan modifiers.
BoolPlanModifiers() []planmodifier.Bool
}

// AttributeWithFloat64PlanModifiers is an optional interface on Attribute which
// enables Float64 plan modifier support.
type AttributeWithFloat64PlanModifiers interface {
fwschema.Attribute

// Float64PlanModifiers should return a list of Float64 plan modifiers.
Float64PlanModifiers() []planmodifier.Float64
}

// AttributeWithInt64PlanModifiers is an optional interface on Attribute which
// enables Int64 plan modifier support.
type AttributeWithInt64PlanModifiers interface {
fwschema.Attribute

// Int64PlanModifiers should return a list of Int64 plan modifiers.
Int64PlanModifiers() []planmodifier.Int64
}

// AttributeWithListPlanModifiers is an optional interface on Attribute which
// enables List plan modifier support.
type AttributeWithListPlanModifiers interface {
fwschema.Attribute

// ListPlanModifiers should return a list of List plan modifiers.
ListPlanModifiers() []planmodifier.List
}

// AttributeWithMapPlanModifiers is an optional interface on Attribute which
// enables Map plan modifier support.
type AttributeWithMapPlanModifiers interface {
fwschema.Attribute

// MapPlanModifiers should return a list of Map plan modifiers.
MapPlanModifiers() []planmodifier.Map
}

// AttributeWithNumberPlanModifiers is an optional interface on Attribute which
// enables Number plan modifier support.
type AttributeWithNumberPlanModifiers interface {
fwschema.Attribute

// NumberPlanModifiers should return a list of Number plan modifiers.
NumberPlanModifiers() []planmodifier.Number
}

// AttributeWithObjectPlanModifiers is an optional interface on Attribute which
// enables Object plan modifier support.
type AttributeWithObjectPlanModifiers interface {
fwschema.Attribute

// ObjectPlanModifiers should return a list of Object plan modifiers.
ObjectPlanModifiers() []planmodifier.Object
}

// AttributeWithSetPlanModifiers is an optional interface on Attribute which
// enables Set plan modifier support.
type AttributeWithSetPlanModifiers interface {
fwschema.Attribute

// SetPlanModifiers should return a list of Set plan modifiers.
SetPlanModifiers() []planmodifier.Set
}

// AttributeWithStringPlanModifiers is an optional interface on Attribute which
// enables String plan modifier support.
type AttributeWithStringPlanModifiers interface {
fwschema.Attribute

// StringPlanModifiers should return a list of String plan modifiers.
StringPlanModifiers() []planmodifier.String
}
28 changes: 28 additions & 0 deletions internal/fwschema/fwxschema/block_plan_modification.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fwxschema

import (
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
)

Expand All @@ -17,3 +18,30 @@ type BlockWithPlanModifiers interface {
// the tfsdk.Block field name.
GetPlanModifiers() tfsdk.AttributePlanModifiers
}

// BlockWithListPlanModifiers is an optional interface on Block which
// enables List plan modifier support.
type BlockWithListPlanModifiers interface {
fwschema.Block

// ListPlanModifiers should return a list of List plan modifiers.
ListPlanModifiers() []planmodifier.List
}

// BlockWithObjectPlanModifiers is an optional interface on Block which
// enables Object plan modifier support.
type BlockWithObjectPlanModifiers interface {
fwschema.Block

// ObjectPlanModifiers should return a list of Object plan modifiers.
ObjectPlanModifiers() []planmodifier.Object
}

// BlockWithSetPlanModifiers is an optional interface on Block which
// enables Set plan modifier support.
type BlockWithSetPlanModifiers interface {
fwschema.Block

// SetPlanModifiers should return a list of Set plan modifiers.
SetPlanModifiers() []planmodifier.Set
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package fwxschema

import (
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)

// NestedAttributeObjectWithPlanModifiers is an optional interface on
// NestedAttributeObject which enables Object plan modification support.
type NestedAttributeObjectWithPlanModifiers interface {
fwschema.NestedAttributeObject

// ObjectPlanModifiers should return a list of Object plan modifiers.
ObjectPlanModifiers() []planmodifier.Object
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package fwxschema

import (
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)

// NestedBlockObjectWithPlanModifiers is an optional interface on
// NestedBlockObject which enables Object plan modification support.
type NestedBlockObjectWithPlanModifiers interface {
fwschema.NestedBlockObject

// ObjectPlanModifiers should return a list of Object plan modifiers.
ObjectPlanModifiers() []planmodifier.Object
}
Loading