|
15 | 15 | package sdkv2
|
16 | 16 |
|
17 | 17 | import (
|
18 |
| - "bytes" |
19 |
| - "encoding/json" |
20 | 18 | "strings"
|
21 | 19 |
|
22 |
| - "github.com/hashicorp/go-cty/cty" |
23 | 20 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
24 | 21 | "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
|
25 |
| - "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" |
26 | 22 | diff_reader "github.com/pulumi/terraform-diff-reader/sdk-v2"
|
27 | 23 |
|
28 | 24 | shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
|
@@ -67,34 +63,6 @@ func (s v2InstanceState) Object(sch shim.SchemaMap) (map[string]interface{}, err
|
67 | 63 | return s.objectV1(sch)
|
68 | 64 | }
|
69 | 65 |
|
70 |
| -// This is needed because json.Unmarshal uses float64 for numbers by default which truncates int64 numbers. |
71 |
| -func unmarshalJSON(data []byte, v interface{}) error { |
72 |
| - dec := json.NewDecoder(bytes.NewReader(data)) |
73 |
| - dec.UseNumber() |
74 |
| - return dec.Decode(v) |
75 |
| -} |
76 |
| - |
77 |
| -// objectFromCtyValue takes a cty.Value and converts it to JSON object. |
78 |
| -// We do not care about type checking the values, we just want to do our best to recursively convert |
79 |
| -// the cty.Value to the underlying value |
80 |
| -// |
81 |
| -// NOTE: one of the transforms this needs to handle is converting unknown values. |
82 |
| -// cty.Value that are also unknown cannot be converted to their underlying value. To get |
83 |
| -// around this we just convert to a sentinel, which so far does not seem to cause any issues downstream |
84 |
| -func objectFromCtyValue(v cty.Value) map[string]interface{} { |
85 |
| - var path cty.Path |
86 |
| - buf := &bytes.Buffer{} |
87 |
| - // The round trip here to JSON is redundant, we could instead convert from cty to map[string]interface{} directly |
88 |
| - err := marshal(v, v.Type(), path, buf) |
89 |
| - contract.AssertNoErrorf(err, "Failed to marshal cty.Value to a JSON string value") |
90 |
| - |
91 |
| - var m map[string]interface{} |
92 |
| - err = unmarshalJSON(buf.Bytes(), &m) |
93 |
| - contract.AssertNoErrorf(err, "failed to unmarshal: %s", buf.String()) |
94 |
| - |
95 |
| - return m |
96 |
| -} |
97 |
| - |
98 | 66 | // The legacy version of Object used custom Pulumi code forked from TF sources.
|
99 | 67 | func (s v2InstanceState) objectV1(sch shim.SchemaMap) (map[string]interface{}, error) {
|
100 | 68 | obj := make(map[string]interface{})
|
|
0 commit comments