mattolenik / hclq

Command-line processor for HashiCorp config files, like sed for HCL — Terraform, Consul, Nomad, Vault
https://hclq.sh
The Unlicense
254 stars 23 forks source link

GetAsString: found but is of wrong type, query requested key/literal, found list" #17

Closed sebglon closed 5 years ago

sebglon commented 5 years ago

I use this code:

    tfParamPath := "module." + moduleName + "." + field
    hclDoc, err := hclq.FromFile(file)
    if err != nil {
        return []string{}, errors.Wrapf(err, "Failed to read terraform file: %s", file)
    }
    res, err := hclDoc.GetAsList(tfParamPath)

But it fail with error: key 'partner_ips' found but is of wrong type, query requested key/literal, found list

I use github.com/mattolenik/hclq v0.0.0-20190520172613-e55c48cdefcc

sebglon commented 5 years ago

Solved. Sorry i have lost [] at the end of the query

mattolenik commented 5 years ago

Well the error message certainly could be improved, so thanks for raising the issue! I opened #18 to track improving the message.