Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
dab4f55
initial transcribing from core, supports single/list/map nested, and …
austinvalle May 24, 2024
75fae53
Initial single nested block implementation
SBGoods Oct 31, 2024
4afe448
Transcribe map tests
SBGoods Nov 4, 2024
1fd955b
Implement set nested blocks
SBGoods Nov 5, 2024
1209b79
Fix nested block support
SBGoods Nov 11, 2024
7d42616
Initial nested attribute support
SBGoods Nov 25, 2024
94fdb36
Add 'deeply nested set' test
SBGoods May 28, 2025
b0f78d1
Add 'expected null NestedTypes,' 'expected empty NestedTypes,' and 'o…
SBGoods Jun 2, 2025
0795937
Add 'prior null nested objects' test
SBGoods Jun 2, 2025
a78fade
Add 'unknown prior nested objects' test
SBGoods Jun 3, 2025
003856c
Finish transcription of tests
SBGoods Jun 3, 2025
4e161f9
Add `schema.EmptyValue()` implementation to `ephemeral/schema` and `r…
SBGoods Jun 3, 2025
b38f8b9
Add `t.Parallel()` to `TestSchemaProposeNewState`
SBGoods Jun 3, 2025
582c446
Implement proposed new for sets
SBGoods Jul 18, 2025
06909e8
Temporarily comment out failing Plan Resource Change tests
SBGoods Jul 22, 2025
1eb0679
Implement `EmptyValue()` in unlinked action and list schema implement…
SBGoods Jul 22, 2025
1947cf2
Implement map nested attribute logic
SBGoods Jul 22, 2025
097c21b
Add validate checks for all `tftypes.NewValue()` calls
SBGoods Jul 22, 2025
7940fa9
Add error handling
SBGoods Jul 23, 2025
fdb3bc4
Resolve linting errors
SBGoods Jul 23, 2025
0699b0e
Add copyright headers
SBGoods Jul 23, 2025
85fec93
Uncomment attribute round trip tests
SBGoods Aug 6, 2025
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
7 changes: 6 additions & 1 deletion action/schema/unlinked_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ package schema
import (
"context"

"github.com/hashicorp/terraform-plugin-go/tftypes"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-go/tftypes"
)

var _ SchemaType = UnlinkedSchema{}
Expand Down Expand Up @@ -60,6 +61,10 @@ type UnlinkedSchema struct {

func (s UnlinkedSchema) isActionSchemaType() {}

func (s UnlinkedSchema) EmptyValue(ctx context.Context) tftypes.Value {
return fwschema.EmptySchemaValue(ctx, s)
}

// ApplyTerraform5AttributePathStep applies the given AttributePathStep to the
// schema.
func (s UnlinkedSchema) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (any, error) {
Expand Down
4 changes: 4 additions & 0 deletions datasource/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ type Schema struct {
DeprecationMessage string
}

func (s Schema) EmptyValue(ctx context.Context) tftypes.Value {
return fwschema.EmptySchemaValue(ctx, s)
}

// ApplyTerraform5AttributePathStep applies the given AttributePathStep to the
// schema.
func (s Schema) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (any, error) {
Expand Down
4 changes: 4 additions & 0 deletions ephemeral/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ type Schema struct {
DeprecationMessage string
}

func (s Schema) EmptyValue(ctx context.Context) tftypes.Value {
return fwschema.EmptySchemaValue(ctx, s)
}

// ApplyTerraform5AttributePathStep applies the given AttributePathStep to the
// schema.
func (s Schema) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (any, error) {
Expand Down
3 changes: 2 additions & 1 deletion internal/fwschema/nested_block_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ package fwschema
import (
"fmt"

"github.com/hashicorp/terraform-plugin-go/tftypes"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-go/tftypes"
)

// NestedBlockObject represents the Object inside a Block.
Expand Down
16 changes: 16 additions & 0 deletions internal/fwschema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ type Schema interface {
// AttributeTypeAtPath should return the framework type of the Attribute at
// the given Terraform path or return an error.
TypeAtTerraformPath(context.Context, *tftypes.AttributePath) (attr.Type, error)

// EmptyValue should return an empty tftypes.Value of the schema's TerraformType
EmptyValue(context.Context) tftypes.Value
}

// SchemaApplyTerraform5AttributePathStep is a helper function to perform base
Expand Down Expand Up @@ -195,6 +198,19 @@ func SchemaTypeAtPath(ctx context.Context, s Schema, p path.Path) (attr.Type, di
return attrType, diags
}

func EmptySchemaValue(ctx context.Context, s Schema) tftypes.Value {
vals := make(map[string]tftypes.Value)
for name, attr := range s.GetAttributes() {
attr.GetType()
vals[name] = tftypes.NewValue(attr.GetType().TerraformType(ctx), nil)
}
for name, block := range s.GetBlocks() {
vals[name] = tftypes.NewValue(block.Type().TerraformType(ctx), nil)
}

return tftypes.NewValue(s.Type().TerraformType(ctx), vals)
}

// SchemaTypeAtTerraformPath is a helper function to perform base type handling
// using the tftypes.AttributePathStepper interface.
func SchemaTypeAtTerraformPath(ctx context.Context, s Schema, p *tftypes.AttributePath) (attr.Type, error) {
Expand Down
Loading
Loading