hcl
hcl copied to clipboard
Allow decoding labels to pointers
Supporting having the label field to be a pointer (e.g. *string
).
Hi @notnoop,
What you implemented here seems technically correct but I find myself curious as to why this would be necessary. In what situation would you have a pointer to a string representing a block label?
In Nomad, we opted to target the existing public/exported config structs, with backward compatibility constraints. The existing "label" fields have *string
type, e.g. https://github.com/hashicorp/nomad/blob/v1.0.2/api/tasks.go#L414 . This change seemed small enough, lets us keep backward compatibility, and avoids having to maintain a duplicate structs that better adhere to gohcl patterns.
I agree that for new code, label fields shouldn't be pointers as labels are required.
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement
Learn more about why HashiCorp requires a CLA and what the CLA includes
Mahmood Ali seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you already have a GitHub account, please add the email address used for this commit to your account.
Have you signed the CLA already but the status is still pending? Recheck it.
I also ran into a similar usecase, what harm does this do ? It is a small enough change and it makes everything behaves the same way since all other fields can already be pointers. having the label being an exception is counterintuitive and the label could also be optional.