v0.3.1

cue-lang/cue Released

A release of CUE OSS · its page on GitHub

This release contains several bug fixes, API additions, some API deprecations, and a language addition. One of the bug fixes may lead to unexpected behavior (see below).

Backwards Incompatible Bug Fix

One common use case of cmd/cue involves combining CUE and non-CUE files. Consider the following example:

// check.cue
package check

map: {for n in nodes {"\(n.name)": n}}
# data.yaml
nodes:
- name: bar
  parent: foo

- name: baz
  parent: foo

With v0.3.0 and earlier, cue eval would happily combine these two files:

$ cue eval data.yaml check.cue
map: {
    bar: {
        name:   "bar"
        parent: "foo"
    }
    baz: {
        name:   "baz"
        parent: "foo"
    }
}
nodes: [{
    name:   "bar"
    parent: "foo"
}, {
    name:   "baz"
    parent: "foo"
}]

But cue vet would complain:

$ cue vet data.yaml check.cue
map: reference "nodes" not found:
    ./check.cue:3:16

cue vet is actually correct here. Identifier resolution should only happen across files that belong to the same package: non-CUE files are equivalent to a CUE file without a package clause or an anonymous package clause (package _), hence cue eval should really fail in this instance.

v0.3.1 makes cue eval and other commands consistent with cue vet. This was deemed a sufficiently breaking change to warrant its own release.

The fix in this case is to define nodes in the scope of package check:

// check.cue

package check

nodes: _
map: {for n in nodes {"\(n.name)": n}}

at which point cue eval succeeds as before.

An upcoming change will also ensure this condition of identifier resolution is satisfied for all non-package CUE file arguments.

API changes

The cue.Selector model has been extended to allow querying optional fields and arbitrary elements.

Deprecations

The following methods of Value have now been deprecated: FieldByName Elem Template

Really, you should only need LookupPath for your lookup needs. For the most part, these old methods have been reimplemented using the new API.

Also, updated the doc that one really, really should not use Merge.

If you are a user of the API we strongly recommend running staticcheck: it will raise errors where you are using deprecated parts of the API.

Language Additions

CUE now allows parenthesized expressions as labels. This is not (yet) published in the spec, but part of the query proposal. So "\(x)": foo, where x is a string, may now be written as (x): foo.

All changes

13 changesby area

cue10

  • cue/astallow parentheses as labels460357b
  • cue/buildremove unused Scope fielde70a1db
  • cuedeprecate Value.Elem and Value.Templatef0adb4e
  • cuedeprecate Value.FieldByNamef063a61
  • cuemove LookupPath to query6a1ae9c
  • cueremove error type aliasese440183
  • cueresolve identifiers in an ast.Expr for FillPath4459434
  • cueseparate closedness for lists and structsc505c19
  • cuesupport optional field lookup in LookupPath957003c
  • cueupdate Merge comment to REALLY NOT USE ITad4d1a1

Other3

  • cmd/cue/cmdallow "exec" in commands for TestXa8ae7d1
  • internal/coredon't resolve values into anonymous packages5c2b281
  • internal/difffix printing and top-level diffs72e8fb4

Downloads

Every file this release published on GitHub, with its SHA-256. Most people install CUE as Installing CUE describes, which also shows how to check a download.

Archives

PlatformFile and SHA-256
macOS, Intelcue_v0.3.1_darwin_amd64.tar.gzc98e3f139418325f7b33e209cd1c41013c77270349225515e328a2918beaefb1
Linux, x86-64cue_v0.3.1_linux_amd64.tar.gza63533b74708c57e325ccfbefd717876205cb64d67166b6de2a27f5408577825
Linux, Arm64cue_v0.3.1_linux_arm64.tar.gza1e7f1f7f84a6d3df4532b5197c4d76ced37b2889505f88b8760d92c57a05f02
Windows, x86-64cue_v0.3.1_windows_amd64.zip23e7e57021a921cc5fb1d9a23dea4d430766e23e628e6ba7099f0f5ed39dc82f

SHA-256 checksums for all of these: checksums.txt

Install CUE