Skip to content

Commit 0fcd39d

Browse files
apparentlymartpaultyng
authored andcommitted
internal/configs: Remove HCL-based functionality
The SDK doesn't work with HCL so the HCL-related parts of this package are not necessary here, and removing them gives the freedom to switch away from using cty as the value representation in a later commit. The ImpliedType method was previously implemented in terms of the hcldec package and the DecoderSpec method, so this includes a new version of ImpliedType that just works directly with cty and doesn't go through the hcldec ImpliedType function. The existing ImpliedType tests show no change in behavior, and for good measure I added some type consistency checks to the tests for two other methods that are unchanged by this commit that show that the ImpliedType result remains compatible with them.
1 parent 7c30943 commit 0fcd39d

File tree

7 files changed

+80
-925
lines changed

7 files changed

+80
-925
lines changed

internal/configs/configschema/coerce_value_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package configschema
33
import (
44
"testing"
55

6+
"github.com/davecgh/go-spew/spew"
67
"github.com/zclconf/go-cty/cty"
78

89
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/tfdiags"
@@ -559,6 +560,14 @@ func TestCoerceValue(t *testing.T) {
559560
if !gotValue.RawEquals(test.WantValue) {
560561
t.Errorf("wrong result\ninput: %#v\ngot: %#v\nwant: %#v", test.Input, gotValue, test.WantValue)
561562
}
563+
564+
// The coerced value must always conform to the implied type of
565+
// the schema.
566+
wantTy := test.Schema.ImpliedType()
567+
gotTy := gotValue.Type()
568+
if errs := gotTy.TestConformance(wantTy); len(errs) > 0 {
569+
t.Errorf("empty value has incorrect type\ngot: %#v\nwant: %#v\nerrors: %s", gotTy, wantTy, spew.Sdump(errs))
570+
}
562571
})
563572
}
564573
}

internal/configs/configschema/decoder_spec.go

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)