hcl icon indicating copy to clipboard operation
hcl copied to clipboard

Allow decoding labels to pointers

Open notnoop opened this issue 4 years ago • 4 comments

Supporting having the label field to be a pointer (e.g. *string).

notnoop avatar Oct 23 '20 12:10 notnoop

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?

apparentlymart avatar Dec 02 '20 23:12 apparentlymart

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.

notnoop avatar Jan 29 '21 14:01 notnoop

CLA assistant check

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.

hashicorp-cla avatar Sep 09 '21 10:09 hashicorp-cla

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.

schmurfy avatar Dec 29 '22 08:12 schmurfy