Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCL Top Level Object Array #60

Closed
derekdowling opened this issue Nov 18, 2015 · 6 comments
Closed

HCL Top Level Object Array #60

derekdowling opened this issue Nov 18, 2015 · 6 comments

Comments

@derekdowling
Copy link
Contributor

Unfortunately due to a lack of pinning, I don't know exactly when this changed, but decoding a top level array of objects no longer works. Any suggestions on how to fix or get around this?

Example:

type Template struct {
    Source string
    Destination string
    Command string
}

templates := struct {
    Templates []*Template `hcl:"template"`
}

err := hcl.Decode(&templates, `
template {
    source = "blah"
    destination = "foo"
    command = "baz"
}

template {
    source = "blahblah"
    destination = "foofoo"
    command = "bazbaz"
}`)

Currently it fails with: Error: root.template[0]: not an object type for struct (*ast.LiteralType)

@sethvargo
Copy link
Contributor

@derekdowling we do this in Consul Template and it appears to be working fine:

find . -type f -name '.DS_Store' -delete
go generate ./...
go test ./...  -timeout=30s -parallel=4
ok      github.com/hashicorp/consul-template    4.470s
ok      github.com/hashicorp/consul-template/dependency 4.284s
ok      github.com/hashicorp/consul-template/logging    0.010s
?       github.com/hashicorp/consul-template/test   [no test files]
ok      github.com/hashicorp/consul-template/watch  0.173s

Did you run make updatedeps on CT?

@derekdowling
Copy link
Contributor Author

Yup, I just tried that, and I am on master as well. Do you mean HCL, not CT(assuming consul-templates)? Because my issue is unrelated to Consul if so.

screen shot 2015-11-18 at 4 15 20 pm

@fd
Copy link

fd commented Nov 22, 2015

I'm having the same problem...

@derekdowling
Copy link
Contributor Author

@sethvargo any news on how to fix this?

@advdv
Copy link

advdv commented Mar 10, 2016

I'm having the same issue, not just on the root

@sethvargo
Copy link
Contributor

^

apparentlymart pushed a commit that referenced this issue Sep 9, 2019
Fix import for howett.net/plist, and update go.mod.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants