gucci icon indicating copy to clipboard operation
gucci copied to clipboard

toJson and mustToJson fail when presented with a "map[interface {}]interface {}"

Open drivera-armedia opened this issue 1 year ago • 0 comments

I'm unable to convert a (map) section of the values file to JSON because of this error:

$ gucci -f test.yaml < g.tpl 

    V (map):Failed to parse standard input: template: -:4:34: executing "-" at <mustToJson>: error calling mustToJson: json: unsupported type: map[interface {}]interface {}

This is on version v1.6.13, on linux-amd64. I realize this is probably a Strig thing, but maybe there's a newer version of Strig which can be used? Maybe there's a type cast that can be performed?

Here's the template file:

{{- $l := list $.testTwo $.testTwo -}}
{{- range $i := $l }}
  {{- range $j := $i }}
    V ({{ kindOf $j }}): {{ $j | mustToJson | nindent 2 }}
  {{- end }}
{{- end }}

And here's a YAML file that triggers the issue:

testOne:
- name: common
  type: common-use-stuff
  version: "1.0"
- name: shovel
  type: ""
  version: "2.0.0"
- name: gardener
  type: ""
  version: "3.1.0"

testTwo:
- name: common
  repository: "some stuff for common use"
  version: "3.1.0"
- name: shovel
  version: "2.1.0"
- name: gardener
  version: "3.2.0"
- name: chauncey
  version: "3.9.0"

Thanks!

drivera-armedia avatar Aug 23 '24 22:08 drivera-armedia