Skip to content

Commit a580ec9

Browse files
remove redundant cty shim
1 parent fd00d4d commit a580ec9

File tree

2 files changed

+9
-192
lines changed

2 files changed

+9
-192
lines changed

pkg/valueshim/cty.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ import (
1919
"fmt"
2020
"math/big"
2121

22-
"github.com/zclconf/go-cty/cty"
23-
ctyjson "github.com/zclconf/go-cty/cty/json"
22+
"github.com/hashicorp/go-cty/cty"
23+
ctyjson "github.com/hashicorp/go-cty/cty/json"
2424
)
2525

2626
// Wrap a cty.Value as Value.
27-
func FromCtyValue(v cty.Value) Value {
27+
func FromHCtyValue(v cty.Value) Value {
2828
return ctyValueShim(v)
2929
}
3030

3131
// Wrap a cty.Type as Type.
32-
func FromCtyType(v cty.Type) Type {
32+
func FromHCtyType(v cty.Type) Type {
3333
return ctyTypeShim(v)
3434
}
3535

@@ -50,7 +50,7 @@ func (v ctyValueShim) GoString() string {
5050
}
5151

5252
func (v ctyValueShim) Type() Type {
53-
return FromCtyType(v.val().Type())
53+
return FromHCtyType(v.val().Type())
5454
}
5555

5656
func (v ctyValueShim) StringValue() string {
@@ -62,8 +62,7 @@ func (v ctyValueShim) BoolValue() bool {
6262
}
6363

6464
func (v ctyValueShim) NumberValue() float64 {
65-
bf := v.BigFloatValue()
66-
f, _ := bf.Float64()
65+
f, _ := v.val().AsBigFloat().Float64()
6766
return f
6867
}
6968

@@ -109,7 +108,7 @@ func (v ctyValueShim) Marshal(schemaType Type) (json.RawMessage, error) {
109108
tt, ok := schemaType.(ctyTypeShim)
110109
if !ok {
111110
return nil, fmt.Errorf("Cannot marshal to RawState: "+
112-
"expected schemaType to be of type ctyTypeShim, got %#T",
111+
"expected schemaType to be of type hctyTypeShim, got %#T",
113112
schemaType)
114113
}
115114
raw, err := ctyjson.Marshal(vv, tt.ty())
@@ -167,15 +166,15 @@ func (t ctyTypeShim) AttributeType(name string) (Type, bool) {
167166
if !tt.HasAttribute(name) {
168167
return nil, false
169168
}
170-
return FromCtyType(tt.AttributeType(name)), true
169+
return FromHCtyType(tt.AttributeType(name)), true
171170
}
172171

173172
func (t ctyTypeShim) ElementType() (Type, bool) {
174173
tt := t.ty()
175174
if !tt.IsCollectionType() {
176175
return nil, false
177176
}
178-
return FromCtyType(tt.ElementType()), true
177+
return FromHCtyType(tt.ElementType()), true
179178
}
180179

181180
func (t ctyTypeShim) GoString() string {

pkg/valueshim/hcty.go

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

0 commit comments

Comments
 (0)