Debian Codegraph @

parsing/hcl/reader.go

raw symbols SCIP
1 package hclscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.25 fmt/"
5
6 "github.com/hashicorp/hcl/v2scip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2`/"
7 "github.com/hashicorp/hcl/v2/gohclscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/gohcl`/"
8 "github.com/hashicorp/hcl/v2/hclsyntaxscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/"
9 "github.com/tomwright/dasel/v3/modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/"
10 "github.com/tomwright/dasel/v3/parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/"
11 "github.com/zclconf/go-cty/ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/"
12 )
13
14 func newHCLReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/newHCLReader().(options parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.ReaderOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/ReaderOptions#) (parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.Readerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Reader#, error) {
15 return &hclReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#{
16 alwaysReadLabelsToSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#alwaysReadLabelsToSlice.: options.Extscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/ReaderOptions#Ext.["hcl-block-format"] == "array",
17 }, nil
18 }
19
20 type hclReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader# struct {
21 alwaysReadLabelsToSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#alwaysReadLabelsToSlice. bool
22 }
23
24 // Read reads a value from a byte slice.
25 // Reads the HCL data into a model that follows the HCL JSON spec.
26 // See https://github.com/hashicorp/hcl/blob/main/json%2Fspec.md
27 func (r *hclReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#) Readscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#Read().(data []byte) (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) {
28 f, _ := hclsyntaxscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/.ParseConfigscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/ParseConfig().(data, "input", hclscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2`/.InitialPosscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2`/InitialPos.)
29
30 body, ok := f.Bodyscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2`/File#Body..(*hclsyntaxscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/.Bodyscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Body#)
31 if !ok {
32 return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to assert file body type")
33 }
34
35 return r.decodeHCLBodyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeHCLBody().(body)
36 }
37
38 func (r *hclReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#) decodeHCLBodyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeHCLBody().(body *hclsyntaxscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/.Bodyscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Body#) (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) {
39 res := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewMapValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewMapValue().()
40 var err error
41
42 for _, attr := range body.Attributesscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Body#Attributes. {
43 val, err := r.decodeHCLExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeHCLExpr().(attr.Exprscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Attribute#Expr.)
44 if err != nil {
45 return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to decode attr %q: %w", attr.Namescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Attribute#Name., err)
46 }
47
48 if err := res.SetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#SetMapKey().(attr.Namescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Attribute#Name., val); err != nil {
49 return nil, err
50 }
51 }
52
53 res, err = r.decodeHCLBodyBlocksscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeHCLBodyBlocks().(body, res)
54 if err != nil {
55 return nil, err
56 }
57
58 return res, nil
59 }
60
61 func (r *hclReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#) decodeHCLBodyBlocksscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeHCLBodyBlocks().(body *hclsyntaxscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/.Bodyscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Body#, res *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) {
62 for _, block := range body.Blocksscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Body#Blocks. {
63 if err := r.decodeHCLBlockscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeHCLBlock().(block, res); err != nil {
64 return nil, err
65 }
66 }
67 return res, nil
68 }
69
70 func (r *hclReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#) decodeHCLBlockscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeHCLBlock().(block *hclsyntaxscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/.Blockscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Block#, res *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#) error {
71 key := block.Typescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Block#Type.
72 v := res
73 for _, label := range block.Labelsscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Block#Labels. {
74 exists, err := v.MapKeyExistsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#MapKeyExists().(key)
75 if err != nil {
76 return err
77 }
78
79 if exists {
80 keyV, err := v.GetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GetMapKey().(key)
81 if err != nil {
82 return err
83 }
84 v = keyV
85 } else {
86 keyV := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewMapValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewMapValue().()
87 if err := v.SetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#SetMapKey().(key, keyV); err != nil {
88 return err
89 }
90 v = keyV
91 }
92
93 key = label
94 }
95
96 body, err := r.decodeHCLBodyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeHCLBody().(block.Bodyscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclsyntax`/Block#Body.)
97 if err != nil {
98 return err
99 }
100
101 exists, err := v.MapKeyExistsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#MapKeyExists().(key)
102 if err != nil {
103 return err
104 }
105 if exists {
106 keyV, err := v.GetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#GetMapKey().(key)
107 if err != nil {
108 return err
109 }
110
111 switch keyV.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().() {
112 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeSlice.:
113 if err := keyV.Appendscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Append().(body); err != nil {
114 return err
115 }
116 case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeMap.:
117 // Previous value was a map.
118 // Create a new slice containing the previous map and the new map.
119 newKeyV := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewSliceValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewSliceValue().()
120 previousKeyV, err := keyV.Copyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Copy().()
121 if err != nil {
122 return err
123 }
124 if err := newKeyV.Appendscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Append().(previousKeyV); err != nil {
125 return err
126 }
127 if err := newKeyV.Appendscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Append().(body); err != nil {
128 return err
129 }
130 if err := keyV.Setscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Set().(newKeyV); err != nil {
131 return err
132 }
133 default:
134 return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("unexpected type: %s", keyV.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().())
135 }
136 } else {
137 if r.alwaysReadLabelsToSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#alwaysReadLabelsToSlice. {
138 slice := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewSliceValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewSliceValue().()
139 if err := slice.Appendscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Append().(body); err != nil {
140 return err
141 }
142 if err := v.SetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#SetMapKey().(key, slice); err != nil {
143 return err
144 }
145 } else {
146 if err := v.SetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#SetMapKey().(key, body); err != nil {
147 return err
148 }
149 }
150 }
151
152 return nil
153 }
154
155 func (r *hclReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#) decodeHCLExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeHCLExpr().(expr hclscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2`/.Expressionscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2`/Expression#) (*modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, error) {
156 source := ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#{}
157 _ = gohclscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/gohcl`/.DecodeExpressionscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/gohcl`/DecodeExpression().(expr, nil, &source)
158
159 return r.decodeCtyValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeCtyValue().(source)
160 }
161
162 func (r *hclReaderscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#) decodeCtyValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeCtyValue().(source ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#) (res *modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#, err error) {
163 defer func() {
164 r := recover()
165 if r != nil {
166 err = fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to decode: %v", r)
167 return
168 }
169 }()
170 if source.IsNullscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#IsNull().() {
171 return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewNullValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewNullValue().(), nil
172 }
173
174 sourceT := source.Typescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#Type().()
175 if sourceT.HasDynamicTypesscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Type#HasDynamicTypes().() {
176 // TODO : Handle DynamicPseudoType.
177 // I haben't found a clear way to do this.
178 return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewNullValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewNullValue().(), nil
179 }
180 switch {
181 case sourceT.IsListTypescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Type#IsListType().(), sourceT.IsTupleTypescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Type#IsTupleType().():
182 res = modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewSliceValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewSliceValue().()
183 it := source.ElementIteratorscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#ElementIterator().()
184 for it.Nextscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/ElementIterator#Next().() {
185 k, v := it.Elementscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/ElementIterator#Element().()
186 // We don't need the index as they should be in order.
187 // Just validates the key is correct.
188 _, _ = k.AsBigFloatscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#AsBigFloat().().Float64scip-go gomod github.com/golang/go/src go1.25 `math/big`/Float#Float64().()
189
190 val, err := r.decodeCtyValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeCtyValue().(v)
191 if err != nil {
192 return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to decode tuple value: %w", err)
193 }
194
195 if err := res.Appendscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Append().(val); err != nil {
196 return nil, err
197 }
198 }
199 return res, nil
200 case sourceT.IsMapTypescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Type#IsMapType().(), sourceT.IsObjectTypescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Type#IsObjectType().(), sourceT.IsSetTypescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Type#IsSetType().():
201 v := modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewMapValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewMapValue().()
202 it := source.ElementIteratorscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#ElementIterator().()
203 for it.Nextscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/ElementIterator#Next().() {
204 k, el := it.Elementscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/ElementIterator#Element().()
205 if k.Typescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#Type().() != ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/String. {
206 return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("object key must be a string")
207 }
208 kStr := k.AsStringscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#AsString().()
209
210 elVal, err := r.decodeCtyValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclReader#decodeCtyValue().(el)
211 if err != nil {
212 return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("failed to decode object value: %w", err)
213 }
214
215 if err := v.SetMapKeyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#SetMapKey().(kStr, elVal); err != nil {
216 return nil, err
217 }
218 }
219 return v, nil
220 case sourceT.IsPrimitiveTypescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Type#IsPrimitiveType().():
221 switch sourceT {
222 case ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Stringscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/String.:
223 v := source.AsStringscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#AsString().()
224 return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewStringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewStringValue().(v), nil
225 case ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Boolscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Bool.:
226 v := source.Truescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#True().()
227 return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewBoolValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewBoolValue().(v), nil
228 case ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.Numberscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Number.:
229 v := source.AsBigFloatscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#AsBigFloat().()
230 f64, _ := v.Float64scip-go gomod github.com/golang/go/src go1.25 `math/big`/Float#Float64().()
231 if v.IsIntscip-go gomod github.com/golang/go/src go1.25 `math/big`/Float#IsInt().() {
232 return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewIntValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewIntValue().(int64(f64)), nil
233 }
234 return modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.NewFloatValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/NewFloatValue().(f64), nil
235 default:
236 return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("unhandled primitive type %q", source.Typescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Value#Type().())
237 }
238 default:
239 return nil, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("unsupported type: %s", sourceT.FriendlyNamescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/Type#FriendlyName().())
240 }
241 }