kinvolk / lokomotive

🪦 DISCONTINUED Further Lokomotive development has been discontinued. Lokomotive is a 100% open-source, easy to use and secure Kubernetes distribution from the volks at Kinvolk
https://kinvolk.io/lokomotive-kubernetes/
Apache License 2.0
320 stars 49 forks source link

Improve error message when variable has no value set #699

Open invidian opened 4 years ago

invidian commented 4 years ago

Currently, it is quite confusing: #698.

Applying component 'metallb'...
cluster.lokocfg:77,18-39: Unsupported attribute; This object does not have an attribute named "metallb_address_pool"., and 1 other diagnostic(s)
FATA[0736] Applying component configuration failed: cluster.lokocfg:77,18-39: Unsupported attribute; This object does not have an attribute named "metallb_address_pool"., and 1 other diagnostic(s)  args="[]" command="lokoctl cluster apply"
margamanterola commented 4 years ago

I tried to find the code that generates these errors and I went down a long rabbit hole that yielded no good things.

I'm pretty sure this is where the error is generated: https://github.com/hashicorp/hcl2/blob/master/hcl/ops.go#L183

But I don't know what lokomotive is doing to get that error when the variable is empty.

It's interesting that hcl2 is supposed to not be used and it should just be hcl, but the relevant string is not present in the hcl repo...

invidian commented 4 years ago

@marga-kinvolk thanks for looking into it. The right place to look is https://github.com/hashicorp/hcl/tree/hcl2 though.

I suspect it's bug in our variable implementation, that we hit that in HCL, in the code where we parse and merge variables (ugly, ugly, ugly).