cue
cue copied to clipboard
cue/load/tags: add `arch` to set of injectable system variables
This adds to the set of system-derived variables that are provided iff
the user requests them. It expands the set from 6 to 7, introducing the
variable arch as an exact counterpart to the existing os variable.
The overhead for providing this is minimal, as the runtime package is
already imported and in scope due to the os variable.
Adding this variable does not seem to be opening the door to an
expectation that the set of system variables is expandable to meet
individual users' needs. Instead, adding this system variable merely
completes the exposure of the high-level set of variables that are
already available to the Go-based consumer, but are not trivially
available to the CLI-based CUE consumer. Of the 2-of-3 variables exposed
by https://pkg.go.dev/runtime#pkg-constants but not exposed by CUE,
only arch reflects the system on which the CUE CLI is being executed.
The cue injection help text has been updated to reflect the full set
of possible values arch values, taken from
https://go.googlesource.com/go/+/ec5170397c724a8ae440b2bc529f857c86f0e6b1/src/go/build/syslist.go#11,
which was the commit that released go1.17 - the currently required CUE
go version in go.mod. This list has been reformatted upstream since
then, but the contents (most recently as at
https://go.googlesource.com/go/+/3c6a5cdb9a29c0e3b12cdaa8ab81ba22d989e3b0/src/go/build/syslist.go#50)
are unchanged.
No tests have been added in this commit. This is for a few reasons:
- the existing
osvariable appears to have no direct tests, so a pattern for testing relatively hard-to-mock, machine-specific interfaces wasn't available to copy. - I'm unsure how this would be testable, without the test merely becoming a pass-through test of what runtime.GOARCH returns.
- the not-directly-tested nature of the existing
osvariable suggests that testing this kind of runtime-derived variable was considered non-trivial, non-critical, or both.
Accepting this PR would resolve #1692.
Signed-off-by: Jonathan Matthews [email protected]
Friendly ping @jpluscplusm; we can merge as soon as the nits above are resolved :)
Apologies for the radio silence on this PR. I'll push some commits to bring it up to scratch later ~today~ tomorrow.
👋 @mvdan @myitcv PR and commit updated to resolve issues, hopefully!
Thank you - still looks good :) I will be importing to Gerrit shortly.
Now imported as https://review.gerrithub.io/c/cue-lang/cue/+/543335 and running CI. The only change made to the commit is that I added a "fixes" line at the end.