Skip to content

cmd/cue: add environment to tag variables #3811

@myitcv

Description

@myitcv

What version of CUE are you using (cue version)?

$ cue version
cue version v0.13.0-0.dev.0.20250310212608-931fecbeb96f

go version go1.24.0
      -buildmode exe
       -compiler gc
  DefaultGODEBUG gotestjsonbuildtext=1,multipathtcp=0,randseednop=0,rsa1024min=0,tlsmlkem=0,x509rsacrt=0,x509usepolicies=0
     CGO_ENABLED 1
          GOARCH arm64
            GOOS linux
         GOARM64 v8.0
             vcs git
    vcs.revision 931fecbeb96facac2299e450a79ac1813acfce24
        vcs.time 2025-03-10T21:26:08Z
    vcs.modified false
cue.lang.version v0.13.0

Does this issue reproduce with the latest release?

Yes

What did you do?

Looked at https://cuelang.org/docs/reference/command/cue-help-injection/ for details on how to pass in the current environment (i.e. the set of k=v environment variables for the process in which CUE is evaluating)

What did you expect to see?

Something telling me how to do this.

What did you see instead?

No mention of environment variables. Whilst on https://cuelang.org/docs/reference/command/cue-help-injection/ we can link to an as-yet-not-created page about using -t with individual environment variables, it seems to make sense to me to offer a tag variable for the entire [string]: string environment.

So whilst we could improve the documentation around the -t method of passing in individual values, it seems like it would be a quick and easy win to pass the entire environment as a {[string]: string} as an tag variable. So something like:

v: {[string]: string} @tag(v, var=env)

Such that indexing v would then yield a value for that key/variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions