| 1 | package hclscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.25 bytes/" |
| 5 | "fmtscip-go gomod github.com/golang/go/src go1.25 fmt/" |
| 6 | "github.com/hashicorp/hcl/v2/hclwritescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/" |
| 7 | "github.com/tomwright/dasel/v3/modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/" |
| 8 | "github.com/tomwright/dasel/v3/parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/" |
| 9 | "github.com/zclconf/go-cty/ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/" |
| 10 | ) |
| 11 | |
| 12 | func newHCLWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/newHCLWriter().(options parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.WriterOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#) (parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.Writerscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/Writer#, error) { |
| 13 | return &hclWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#{ |
| 14 | optionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#options.: options, |
| 15 | }, nil |
| 16 | } |
| 17 | |
| 18 | type hclWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter# struct { |
| 19 | optionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#options. parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.WriterOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions# |
| 20 | } |
| 21 | |
| 22 | // Write writes a value to a byte slice. |
| 23 | func (j *hclWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#) Writescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#Write().(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#) ([]byte, error) { |
| 24 | f, err := j.valueToFilescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#valueToFile().(value) |
| 25 | if err != nil { |
| 26 | return nil, err |
| 27 | } |
| 28 | |
| 29 | buf := new(bytesscip-go gomod github.com/golang/go/src go1.25 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25 bytes/Buffer#) |
| 30 | if _, err := f.WriteToscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/File#WriteTo().(buf); err != nil { |
| 31 | return nil, err |
| 32 | } |
| 33 | return buf.Bytesscip-go gomod github.com/golang/go/src go1.25 bytes/Buffer#Bytes().(), nil |
| 34 | } |
| 35 | |
| 36 | func (j *hclWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#) valueToFilescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#valueToFile().(v *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#) (*hclwritescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/.Filescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/File#, error) { |
| 37 | f := hclwritescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/.NewEmptyFilescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/NewEmptyFile().() |
| 38 | |
| 39 | body := f.Bodyscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/File#Body().() |
| 40 | |
| 41 | if err := j.addValueToBodyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#addValueToBody().(nil, v, body); err != nil { |
| 42 | return nil, err |
| 43 | } |
| 44 | |
| 45 | return f, nil |
| 46 | } |
| 47 | |
| 48 | func (j *hclWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#) addValueToBodyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#addValueToBody().(previousLabels []string, v *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#, body *hclwritescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/.Bodyscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/Body#) error { |
| 49 | if !v.IsMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IsMap().() { |
| 50 | return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("hcl body is expected to be a map, got %s", v.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().()) |
| 51 | } |
| 52 | |
| 53 | kvs, err := v.MapKeyValuesscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#MapKeyValues().() |
| 54 | if err != nil { |
| 55 | return err |
| 56 | } |
| 57 | |
| 58 | blocks := make([]*hclwritescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/.Blockscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/Block#, 0) |
| 59 | for _, kv := range kvs { |
| 60 | switch kv.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Value..Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().() { |
| 61 | 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.: |
| 62 | block, err := j.valueToBlockscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#valueToBlock().(kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., previousLabels, kv.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Value.) |
| 63 | if err != nil { |
| 64 | return 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 encode %q to hcl block: %w", kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., err) |
| 65 | } |
| 66 | blocks = append(blocks, block) |
| 67 | 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.: |
| 68 | vals := make([]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#, 0) |
| 69 | |
| 70 | allMaps := true |
| 71 | |
| 72 | if err := kv.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Value..RangeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeSlice().(func(_ int, 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 { |
| 73 | ctyVal, err := j.valueToCtyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#valueToCty().(value) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | vals = append(vals, ctyVal) |
| 78 | |
| 79 | if !value.IsMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IsMap().() { |
| 80 | allMaps = false |
| 81 | } |
| 82 | return nil |
| 83 | }); err != nil { |
| 84 | return err |
| 85 | } |
| 86 | |
| 87 | if allMaps { |
| 88 | if err := kv.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Value..RangeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeSlice().(func(_ int, 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 { |
| 89 | block, err := j.valueToBlockscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#valueToBlock().(kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., previousLabels, value) |
| 90 | if err != nil { |
| 91 | return 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 encode %q to hcl block: %w", kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., err) |
| 92 | } |
| 93 | blocks = append(blocks, block) |
| 94 | return nil |
| 95 | }); err != nil { |
| 96 | return err |
| 97 | } |
| 98 | } else { |
| 99 | body.SetAttributeValuescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/Body#SetAttributeValue().(kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.TupleValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/TupleVal().(vals)) |
| 100 | } |
| 101 | |
| 102 | default: |
| 103 | ctyVal, err := j.valueToCtyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#valueToCty().(kv.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Value.) |
| 104 | if err != nil { |
| 105 | return 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 encode attribute %q: %w", kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., err) |
| 106 | } |
| 107 | body.SetAttributeValuescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/Body#SetAttributeValue().(kv.Keyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/KeyValue#Key., ctyVal) |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | for _, block := range blocks { |
| 112 | body.AppendBlockscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/Body#AppendBlock().(block) |
| 113 | } |
| 114 | |
| 115 | return nil |
| 116 | } |
| 117 | |
| 118 | func (j *hclWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#) valueToCtyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#valueToCty().(v *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#) (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#, error) { |
| 119 | switch v.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().() { |
| 120 | case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeStringscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeString.: |
| 121 | val, err := v.StringValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#StringValue().() |
| 122 | if err != nil { |
| 123 | return 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#{}, err |
| 124 | } |
| 125 | return ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.StringValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/StringVal().(val), nil |
| 126 | case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeBoolscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeBool.: |
| 127 | val, err := v.BoolValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#BoolValue().() |
| 128 | if err != nil { |
| 129 | return 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#{}, err |
| 130 | } |
| 131 | return ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.BoolValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/BoolVal().(val), nil |
| 132 | case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeIntscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeInt.: |
| 133 | val, err := v.IntValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IntValue().() |
| 134 | if err != nil { |
| 135 | return 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#{}, err |
| 136 | } |
| 137 | return ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.NumberIntValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/NumberIntVal().(val), nil |
| 138 | case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeFloatscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeFloat.: |
| 139 | val, err := v.FloatValuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#FloatValue().() |
| 140 | if err != nil { |
| 141 | return 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#{}, err |
| 142 | } |
| 143 | return ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.NumberFloatValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/NumberFloatVal().(val), nil |
| 144 | case modelscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/.TypeNullscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/TypeNull.: |
| 145 | return ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.NullValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/NullVal().(ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.NilTypescip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/NilType.), nil |
| 146 | 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.: |
| 147 | var vals []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# |
| 148 | if err := v.RangeSlicescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeSlice().(func(_ int, 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 { |
| 149 | ctyVal, err := j.valueToCtyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#valueToCty().(value) |
| 150 | if err != nil { |
| 151 | return err |
| 152 | } |
| 153 | vals = append(vals, ctyVal) |
| 154 | return nil |
| 155 | }); err != nil { |
| 156 | return 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#{}, err |
| 157 | } |
| 158 | return ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.TupleValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/TupleVal().(vals), nil |
| 159 | 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.: |
| 160 | mapV := map[string]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#{} |
| 161 | if err := v.RangeMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#RangeMap().(func(s string, 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 { |
| 162 | ctyVal, err := j.valueToCtyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#valueToCty().(value) |
| 163 | if err != nil { |
| 164 | return err |
| 165 | } |
| 166 | mapV[s] = ctyVal |
| 167 | return nil |
| 168 | }); err != nil { |
| 169 | return 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#{}, err |
| 170 | } |
| 171 | return ctyscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/.ObjectValscip-go gomod github.com/zclconf/go-cty v1.17.0 `github.com/zclconf/go-cty/cty`/ObjectVal().(mapV), nil |
| 172 | default: |
| 173 | return 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#{}, fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("unhandled type when converting to cty value %q", v.Typescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#Type().()) |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | func (j *hclWriterscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#) valueToBlockscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#valueToBlock().(key string, labels []string, v *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#) (*hclwritescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/.Blockscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/Block#, error) { |
| 178 | if !v.IsMapscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/model`/Value#IsMap().() { |
| 179 | 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().("must be map") |
| 180 | } |
| 181 | |
| 182 | b := hclwritescip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/.NewBlockscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/NewBlock().(key, labels) |
| 183 | |
| 184 | if err := j.addValueToBodyscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing/hcl`/hclWriter#addValueToBody().(labels, v, b.Bodyscip-go gomod github.com/hashicorp/hcl/v2 v2.24.0 `github.com/hashicorp/hcl/v2/hclwrite`/Block#Body().()); err != nil { |
| 185 | return nil, err |
| 186 | } |
| 187 | |
| 188 | return b, nil |
| 189 | } |