v0.6.0-alpha.1

cue-lang/cue Pre-release Released

A release of CUE OSS · its page on GitHub

The main focus of this release is the introduction of required fields.

As a reminder: users can register their projects with unity, our regression and performance testing setup. unity is used to ensure that a project’s CUE evaluations do not unexpectedly stop working, or regress in terms of performance. unity continues to catch multiple issues with each release. Adding your project to unity not only guarantees that we will not break your tests (if we do, we will work with you to fix your CUE code), but it also helps to improve the quality of each CUE release. We are currently in the process of releasing Unity as a GitHub App on the public Marketplace. Sign up to receive updates; we will be in touch as soon as the GitHub App is ready.

Thank you to @4ad, @Abirdcfly, @alexandear, @joanlopez, @jpluscplusm, @kcburge, @mpvl, @mvdan, @myitcv, @rogpeppe, and @zeithaste for contributing to this release!

API

CL 543335 adds arch to set of injectable system variables understood by cue/load. The text at cue help injection explains how this in more detail.

CL 552142 adds support for zero values in cue.Value.Float64, which has the effect of fixing the error when attempting to use strconv.FormatFloat with a zero value.

CL 548783 fixes a long-standing bug to make HTML escaping in JSON an opt-in. This means that cue export now respects the --escape flag when set, and encoding/json only escapes HTML when HTMLEscape is used.

Language

Required fields

The main focus of the v0.6.0 release is the introduction of required fields.

CUE already supports the “optional field constraint”, denoted foo?: value.

Required fields add a “required field constraint”, denoted foo!: value, which is like foo?: value, but requires a regular field be provided for foo (a field foo: without !: or ?:).

We refer to optional field constraints and required field constraints collectively as “field constraints”.

As a general rule, all data and data templating should be defined with regular fields, whereas schemas would be defined in terms of field constraints. Of course, CUE being CUE, mixing these two fields is allowed: this rule is not a restriction but suggested as a matter of style and proper usage.

Here are some examples of how exclamation marks can be used to express things that were previously not possible.

#Def: {
	kind!: "def"
	intList!: [...int]
}

Using required fields can also result in better error messages. Consider this schema:

#Person: {
	name: string
	age?: int
}

Note that this is non-idiomatic, because our new guidelines suggest schemas should only be defined in terms of field constraints, but we will use this for illustration purposes.

Now consider this usage of #Person:

jack: #Person & {age: 3}

In data mode, the error message here is currently jack.name: incomplete value string, which does not provide much actionable information to the user to help them fix the problem.

Now consider how #Person looks with required fields, idiomatically only using field constraints:

#Person: {
	name!: string
	age?:  int
}

jack: #Person & {age: 3}

Now the error message reads:

jack.name: field is required but not present

which more closely reflects the underlying problem..

This error could be resolved by adding jack: name: "Jack".

For more details and background on the change, please see the original required fields proposal.

Other changes

CL 551207 adds support for making dynamic fields optional or required. For example, the following is now possible:

x:    "y"
(x):  "foo"
(x)?: "foo"
(x)!: "foo"

and yields:

x: "y"
y: "foo"

CL 546886 removes support for old-style :: definitions. This also includes deprecation support. In a similar vein, CL 547011 removes the last vestiges of <foo>: T. This was once the notation for pattern constraints.

Builtins

CL 549087 reimplements pkg/list.Sort. The resulting reduction in the number of allocations and other work gives rise to a ~80% reduction in running time against CUE benchmarks.

cmd/cue

CL 547212 improves the documentation for the -l flag passed to cue import. This addresses a frequent point of confusion in questions to GitHub Discussions and on Slack.

CL 550616 fixes cue get go to respect the --exclude flag for constants. This makes it possible to (for example) exclude all unexported identifiers from a cue get go run.

All changes

175 changesby area

all5

  • allmake HTML escaping in JSON an opt-in@mvdan48207fb
  • alladd tests to cover HTML escaping via encoding/json@mvdan1aefd09
  • allremove duplicate words in comments@Abirdcflyd8c71fa
  • allcorrect typos and duplicate words in comments@alexandear2e28b01
  • allremove support for ::@mpvla6055ea

cmd12

  • cmd/cueremove skipped test scripts for fixing old definitions@mvdan9505e90
  • cmd/cue/cmdremove unused code@rogpeppeaa8c66f
  • cmd/cueavoid loading the current package in cue help@mvdan143b102
  • cmd/cueremove fallback version code for Go 1.17@mvdane806bba
  • cmd/cueremove go install long tests@mvdanfa1f369
  • cmd/cueadd CUE_DEBUG_PARSER_TRACE environment variable@4ad34a27bb
  • cmd/cuerespect --exclude for constants@rogpeppeb44e16d
  • cmd/cueadd test case for --exclude@rogpeppe2fa4ee6
  • cmd/cueremove use of stderr directive@mpvl7d89acd
  • cmd/cueinclude Go in the version command@mvdan879f902
  • cmd/cuemention doc location for -l flag@rogpeppe56caeaf
  • cmd/cueadd tests for issue 1926@mpvl9b573be

cue25

  • cue/buildremove context.Context field@rogpeppe1932295
  • cue/astfix IsValidIdent for _0@rogpeppe9422314
  • cuemore support for required fields for selectors@mpvl0e16084
  • cuefail on required field in various cases@mpvle7d7c6a
  • cueremove field type@mpvld05d9c1
  • cueadd support for zero values in Value.Float64@kcburge8d31dad
  • cue/load/tagsadd arch to set of injectable system variables@jpluscplusm752b8e4
  • cue/errorsremove redundant Sort call in list.sanitize@zeithastef106acf
  • cue/errorsbetter vetting of error formats@rogpeppec630554
  • cue/loadminimal module fetching implementation@rogpeppecb9d6ed
  • cue/loadavoid using ioutil.ReadDir to list directories@mvdand077202
  • cue/astprepare for required fields@mpvl1da0fd9
  • cue/loaddon't read parent directories in tests@mvdan9e014c3
  • cue/ast, cue/parserparse function types@4ad8f0fe77
  • cue/contextsupport internal interpreters@mpvl7617de2
  • cue/load/internal/...copy pkgs from Go source@rogpeppe5723470
  • cue/loadrefactor loader@rogpeppec28d75a
  • cue/loadmove code before refactoring@rogpeppe87b91c9
  • cue/statsuse int64 for stats counters@mvdan7073554
  • cue/testdata/benchmarksadd benchmark for sort@mpvl9f538a6
  • cue/loadadd initial module.cue schema@rogpeppeb2087b9
  • cue/loaduse cue package to interpret module.cue file@rogpeppe1b6fb4e
  • cue/loadminor tweaks@rogpepped78f1a2
  • cue/scannerremove block comment scanning@mpvl5d0a6f2
  • cue/parserremove last vestiges of <foo>: T@mpvlfd170da

doc3

  • doc/ref/spec.mdfix uint16 and uint32 values range@joanlopezc67fe60
  • doc/tutorial/kubernetesfix build breakage@mpvlb05585b
  • doc/ref/spec.mdadd required fields@mpvl9a7c8fb

internal116

  • internal/ciuse go1.20.3 for releases@myitcv9db1b95
  • internal/tdtestuse field name in default error message@mpvl401cab2
  • internal/core/adtfix Definition closedness bug in API@mpvlc3c8eb7
  • internal/core/adtfix NotEqualOp for lists with differing lengths@mvdan6e185bb
  • internal/diffremove unused code@rogpeppe9e22283
  • internal/core/adtfix let closedness issue with API use@mpvl731ddd9
  • internal/core/exportavoid introducing shadowing@mpvl1c9a3b2
  • internal/tdtestnew table-driven test package@mpvl102150d
  • internal/corefail on missing required only when concrete@mpvlf85172a
  • internal/core/adtadd wrapper for inline Vertex@mpvl071c4ab
  • internal/core/exportalways export required fields@mpvld5dd9ec
  • internal/cifix cache eviction@myitcv53d3bc7
  • internal/ciaddress review feedback from CL 551352@myitcv06397b5
  • internal/ciallow trybot workflows to be workflow_dispatch-ed@myitcv09221a3
  • internal/core/adtrequired fields checked for closedness@mpvl42580d5
  • internal/cirefactor CI workflows@myitcvd71a76c
  • internal/ciremove hard-codings in base package@myitcvf881884
  • internal/core/adtchange addList signature@mpvl0c840f6
  • internal/core/adtintroduce ArcNotPresent@mpvle3a7fcf
  • internal/core/adtuse value array for Disjunction@mpvl166ac88
  • internal/core/adtspecialize injectComprehension@mpvlfa4f2d3
  • internal/core/adthoist comprehension loop body@mpvle0f5681
  • internal/cimove evict_caches to base@myitcvcef63a3
  • internal/ciremove mention of matrix and runner from base@myitcv3ed9f92
  • internal/ciremove trybot from push branches@myitcv5cd427a
  • internal/cirefactor base caching pattern@myitcv92b28c4
  • internal/cidrop pullThroughProxy step@myitcv79aceb7
  • internal/ciimprove push_tip_to_trybot defaults@myitcvbe0601b
  • internal/ci/githubrename repo -> _repo@myitcv646e965
  • internal/ciimport repo package once in github package@myitcv7aec30c
  • internal/cidrop parameter from trybotDispatchWorkflow@myitcv6318def
  • internal/cibump GoReleaser to v1.16.2 ahead of v0.5.0 release@myitcv5ec06d9
  • internal/cirename core -> repo@myitcv6d6ffb4
  • internal/ciswitch to actions/setup-go@v4@mvdand9c354b
  • internal/cialways force push to trybot repo@myitcved2a9c7
  • internal/ciuse unity and cuelang.org config from core@myitcv4cbb563
  • internal/ciDRY up core based on new base defaults@myitcv1195b3d
  • internal/ciestablish better defaults in base@myitcvaf02a2c
  • internal/cimove away from using defs in github@myitcv7a7ca81
  • internal/cimove away from using definitions in base@myitcvd7a1740
  • internal/ciuse core directly instead of _base alias@myitcvf446b87
  • internal/cimove away from using defs as params in base@myitcv305dc1d
  • internal/cicollapse gerrithub package into base@myitcv9729270
  • internal/citweak gerrithub package "params" ahead of move to base@myitcv1980621
  • internal/cisplit base into separate files@myitcv3a52c19
  • internal/cirename base parameter field name@myitcvcdd5730
  • internal/cimove pushTipToTryBot workflow to gerrithub package@myitcv0290e04
  • internal/cirename gerrithub #dispatchWorkflow@myitcv0cfd8c5
  • internal/ciremove hard-codings in gerrithub package@myitcvf5277b9
  • internal/cimove configuration from workflows.cue to core@myitcv1bb7e10
  • internal/ciremove workflow files pre generate@myitcvb418955
  • internal/cisplit base into separate files@myitcvd638a35
  • internal/ciremove workflow files pre generate@myitcvf723eb7
  • internal/cirename gerrithub #dispatchWorkflow@myitcvd276f58
  • internal/cimove configuration from workflows.cue to core@myitcv5a0922e
  • internal/cirename base parameter field name@myitcv584f3f0
  • internal/cimove pushTipToTryBot workflow to gerrithub package@myitcve440409
  • internal/cihoist dispatch keys to base@myitcve3ed297
  • internal/cimove workflows.cue defs to better places@myitcv0250807
  • internal/cihoist cache steps to base package@myitcv019f6dd
  • internal/ciimprove base package docs@myitcv57066d4
  • internal/cimake our checkout step configurable@myitcvee093e2
  • internal/cispecify githubRepositoryPath directly@myitcv9c075ca
  • internal/cimove core._#URLPath to base@myitcvdd965ad
  • internal/cimove core.#codeReview to base@myitcv8b14836
  • internal/cimove core package away from definitions@myitcv5475370
  • internal/ciimprove core package docs@myitcve1a8bee
  • internal/cirefactor the way we declare workflows@myitcv09b06ff
  • internal/core/adthoist value validation@mpvleea60b9
  • internal/core/adthoist comprehension code@mpvl47f0025
  • internal/core/adtreorganize nodeContext fields@mpvlf807ee8
  • internal/core/adtunexport more methods@mpvlce65141
  • internal/core/adtunexport VertexStatus@mpvl185eed7
  • internal/core/adtremove state arg from Err, SetValue, and UpdateValue@mpvl97904e3
  • internal/core/adtunexport Unify@mpvl7851142
  • internal/core/adtclone arcMap@mpvldbf7bb8
  • internal/ciremove the cachePost steps@myitcv6843415
  • internal/cibump default of cue version to v0.5.0-beta.5@myitcv3121a27
  • internal/ciupdate base early git checks from alpha.cuelang.org@myitcv4509e7f
  • internal/core/adtallow required dynamic fields@mpvlc3138e3
  • internal/ciskip test cache on protected branches@myitcv21f494d
  • internal/core/adtimplement required fields.@mpvl0b681f5
  • internal/core/adtmerge OptionalField and Field types@mpvl1822d52
  • internal/cibump pinned version of Go for releases@mvdane5cd9ac
  • internal/ciuse a group of cue commands for go:generate@mvdand16b575
  • internal/cirerun trybot workflows post eviction@myitcva632d16
  • internal/citidy up use of curl for GitHub API calls@myitcvf4d0802
  • internal/cido not evict caches on push to ci/test@myitcv254f0f1
  • internal/cievict workflow caches on a daily basis@myitcvee81e77
  • internal/cibump to use ubuntu-22.04 as our linux machine@myitcv4686700
  • internal/ciuse actions/cache/restore for non-protected branch@myitcv38ee1c2
  • internal/cireset git directory timestamps faster@mvdanc7fd893
  • internal/cifix up modified times for all directories@mvdane31b8f7
  • internal/cirun long tests on linux when testing CLs@mvdandaa4022
  • internal/cirestore git modified times after cloning@mvdan829bd64
  • internal/core/adtuse ? in debug output@mpvl5fe040a
  • internal/core/adtoptional field rewrite@mpvl19bfdb9
  • internal/ci/gerrithubupdate comment to be clearer@mvdan4fed730
  • internal/core/adtfinalize earlier for arcs@mpvlc80a690
  • internal/core/adtpass member type to insertField@mpvl27b096c
  • internal/core/adtremove duplicate statement@mpvl383ff3e
  • internal/core/adtexport arcType and friends@mpvl4f32fb4
  • internal/core/adtrevert fix for 2209@mpvlc8e580e
  • internal/core/adtfix possible infinte loop for API usage@mpvl782cae0
  • internal/core/adtfix regression in comparing to bottom@mpvl9954cc2
  • internal/core/adtremove unnecessary check@mpvl1a0a81b
  • internal/core/adtdetect closed lists as fatal errors@mpvl06fbefe
  • internal/core/adtsharpen condition for scalar setting@mpvl9b1f222
  • internal/cuetxtarconfigurable load.Config@rogpeppe7485f58
  • internal/ciuse simpler "go get" to pull a version through the proxy@mvdaneff0108
  • internal/cionly run release workflow on main repo@myitcvce37b63
  • internal/cido not release "zero" releases in release workflow@myitcv02e19c8
  • internal/cifix goreleaser in non-snapshot mode again@mvdanae0d7ca
  • internal/cifix and test the release workflow on branches@mvdan266bb32
  • internal/core/adtfix 2235@mpvl3c8f0ad
  • internal/core/adtadd tests for 2235@mpvl125e40b

pkg3

  • pkg/toolsmall fixes to CUE docs@mvdan3d08fb2
  • pkg/listsimply template for Ascending@mpvl9dbb373
  • pkg/listreimplement sort@mpvl2e70ac7

Other11

  • update txtpbfmt to drop indirect dependency on glog@mvdan410eea1
  • bump golang.org/x and go-internal deps@mvdan3f51337
  • start using Go 1.20, drop Go 1.18@mvdand1a6da8
  • Revert "internal/ci: move pushTipToTryBot workflow to gerrithub package"@myitcv87db1a5
  • Revert "internal/ci: rename base parameter field name"@myitcv2461c51
  • Revert "internal/ci: move configuration from workflows.cue to core"@myitcv26ff449
  • Revert "internal/ci: rename gerrithub #dispatchWorkflow"@myitcv38156f2
  • Revert "internal/ci: remove workflow files pre generate"@myitcv0d89b9b
  • Revert "internal/ci: split base into separate files"@myitcvee7509f
  • .githubclarify what we mean by "latest release"@mvdan03e8f29
  • internal/encoding/{json|yaml}: disallow non-regular fields@mpvl76e0be4

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.6.0-alpha.1_darwin_amd64.tar.gz39846589363fd642d082561906894934d06fc6bde2fed9eef8f7ed9aec463a9f
macOS, Apple siliconcue_v0.6.0-alpha.1_darwin_arm64.tar.gzbdc5a9b9feb3e310bd1261eb472a3b77df76a060dd65712409d716835afa3e1b
Linux, x86-64cue_v0.6.0-alpha.1_linux_amd64.tar.gz2e3a75fc1a43622d851a389d66f505f8c30a43af9ec83181afadad168795acd8
Linux, Arm64cue_v0.6.0-alpha.1_linux_arm64.tar.gz2fb8807aa8d9ac5d1c8af3137f619e7fa769969cd3801dcb39f65b3c6672af5b
Windows, x86-64cue_v0.6.0-alpha.1_windows_amd64.zip670ad986473ce076d1837ce068bea9aae01994dc986433f89d393a476b7e428f
Windows, Arm64cue_v0.6.0-alpha.1_windows_arm64.zip73488be820c92ec48ca765dbcc1daf72fff9d60341edca3235a266ff2ed2ad8f

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

Install CUE