v0.6.0-alpha.1
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 presentwhich 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-inalladd tests to cover HTML escaping via encoding/jsonallremove duplicate words in commentsallcorrect typos and duplicate words in commentsallremove support for ::
cmd12
cmd/cueremove skipped test scripts for fixing old definitionscmd/cue/cmdremove unused codecmd/cueavoid loading the current package incue helpcmd/cueremove fallback version code for Go 1.17cmd/cueremovego installlong testscmd/cueadd CUE_DEBUG_PARSER_TRACE environment variablecmd/cuerespect --exclude for constantscmd/cueadd test case for --excludecmd/cueremove use of stderr directivecmd/cueinclude Go in the version commandcmd/cuemention doc location for -l flagcmd/cueadd tests for issue 1926
cue25
cue/buildremove context.Context fieldcue/astfix IsValidIdent for _0cuemore support for required fields for selectorscuefail on required field in various casescueremove field typecueadd support for zero values in Value.Float64cue/load/tagsaddarchto set of injectable system variablescue/errorsremove redundant Sort call in list.sanitizecue/errorsbetter vetting of error formatscue/loadminimal module fetching implementationcue/loadavoid using ioutil.ReadDir to list directoriescue/astprepare for required fieldscue/loaddon't read parent directories in testscue/ast, cue/parserparse function typescue/contextsupport internal interpreterscue/load/internal/...copy pkgs from Go sourcecue/loadrefactor loadercue/loadmove code before refactoringcue/statsuse int64 for stats counterscue/testdata/benchmarksadd benchmark for sortcue/loadadd initial module.cue schemacue/loaduse cue package to interpret module.cue filecue/loadminor tweakscue/scannerremove block comment scanningcue/parserremove last vestiges of <foo>: T
doc3
doc/ref/spec.mdfix uint16 and uint32 values rangedoc/tutorial/kubernetesfix build breakagedoc/ref/spec.mdadd required fields
internal116
internal/ciuse go1.20.3 for releasesinternal/tdtestuse field name in default error messageinternal/core/adtfix Definition closedness bug in APIinternal/core/adtfix NotEqualOp for lists with differing lengthsinternal/diffremove unused codeinternal/core/adtfix let closedness issue with API useinternal/core/exportavoid introducing shadowinginternal/tdtestnew table-driven test packageinternal/corefail on missing required only when concreteinternal/core/adtadd wrapper for inline Vertexinternal/core/exportalways export required fieldsinternal/cifix cache evictioninternal/ciaddress review feedback from CL 551352internal/ciallow trybot workflows to be workflow_dispatch-edinternal/core/adtrequired fields checked for closednessinternal/cirefactor CI workflowsinternal/ciremove hard-codings in base packageinternal/core/adtchange addList signatureinternal/core/adtintroduce ArcNotPresentinternal/core/adtuse value array for Disjunctioninternal/core/adtspecialize injectComprehensioninternal/core/adthoist comprehension loop bodyinternal/cimove evict_caches to baseinternal/ciremove mention of matrix and runner from baseinternal/ciremove trybot from push branchesinternal/cirefactor base caching patterninternal/cidrop pullThroughProxy stepinternal/ciimprove push_tip_to_trybot defaultsinternal/ci/githubrename repo -> _repointernal/ciimport repo package once in github packageinternal/cidrop parameter from trybotDispatchWorkflowinternal/cibump GoReleaser to v1.16.2 ahead of v0.5.0 releaseinternal/cirename core -> repointernal/ciswitch to actions/setup-go@v4internal/cialways force push to trybot repointernal/ciuse unity and cuelang.org config from coreinternal/ciDRY up core based on new base defaultsinternal/ciestablish better defaults in baseinternal/cimove away from using defs in githubinternal/cimove away from using definitions in baseinternal/ciuse core directly instead of _base aliasinternal/cimove away from using defs as params in baseinternal/cicollapse gerrithub package into baseinternal/citweak gerrithub package "params" ahead of move to baseinternal/cisplit base into separate filesinternal/cirename base parameter field nameinternal/cimove pushTipToTryBot workflow to gerrithub packageinternal/cirename gerrithub #dispatchWorkflowinternal/ciremove hard-codings in gerrithub packageinternal/cimove configuration from workflows.cue to coreinternal/ciremove workflow files pre generateinternal/cisplit base into separate filesinternal/ciremove workflow files pre generateinternal/cirename gerrithub #dispatchWorkflowinternal/cimove configuration from workflows.cue to coreinternal/cirename base parameter field nameinternal/cimove pushTipToTryBot workflow to gerrithub packageinternal/cihoist dispatch keys to baseinternal/cimove workflows.cue defs to better placesinternal/cihoist cache steps to base packageinternal/ciimprove base package docsinternal/cimake our checkout step configurableinternal/cispecify githubRepositoryPath directlyinternal/cimove core._#URLPath to baseinternal/cimove core.#codeReview to baseinternal/cimove core package away from definitionsinternal/ciimprove core package docsinternal/cirefactor the way we declare workflowsinternal/core/adthoist value validationinternal/core/adthoist comprehension codeinternal/core/adtreorganize nodeContext fieldsinternal/core/adtunexport more methodsinternal/core/adtunexport VertexStatusinternal/core/adtremove state arg from Err, SetValue, and UpdateValueinternal/core/adtunexport Unifyinternal/core/adtclone arcMapinternal/ciremove the cachePost stepsinternal/cibump default of cue version to v0.5.0-beta.5internal/ciupdate base early git checks from alpha.cuelang.orginternal/core/adtallow required dynamic fieldsinternal/ciskip test cache on protected branchesinternal/core/adtimplement required fields.internal/core/adtmerge OptionalField and Field typesinternal/cibump pinned version of Go for releasesinternal/ciuse a group of cue commands for go:generateinternal/cirerun trybot workflows post evictioninternal/citidy up use of curl for GitHub API callsinternal/cido not evict caches on push to ci/testinternal/cievict workflow caches on a daily basisinternal/cibump to use ubuntu-22.04 as our linux machineinternal/ciuse actions/cache/restore for non-protected branchinternal/cireset git directory timestamps fasterinternal/cifix up modified times for all directoriesinternal/cirun long tests on linux when testing CLsinternal/cirestore git modified times after cloninginternal/core/adtuse ? in debug outputinternal/core/adtoptional field rewriteinternal/ci/gerrithubupdate comment to be clearerinternal/core/adtfinalize earlier for arcsinternal/core/adtpass member type to insertFieldinternal/core/adtremove duplicate statementinternal/core/adtexport arcType and friendsinternal/core/adtrevert fix for 2209internal/core/adtfix possible infinte loop for API usageinternal/core/adtfix regression in comparing to bottominternal/core/adtremove unnecessary checkinternal/core/adtdetect closed lists as fatal errorsinternal/core/adtsharpen condition for scalar settinginternal/cuetxtarconfigurable load.Configinternal/ciuse simpler "go get" to pull a version through the proxyinternal/cionly run release workflow on main repointernal/cido not release "zero" releases in release workflowinternal/cifix goreleaser in non-snapshot mode againinternal/cifix and test the release workflow on branchesinternal/core/adtfix 2235internal/core/adtadd tests for 2235
pkg3
pkg/toolsmall fixes to CUE docspkg/listsimply template for Ascendingpkg/listreimplement sort
Other11
- update txtpbfmt to drop indirect dependency on glog
- bump golang.org/x and go-internal deps
- start using Go 1.20, drop Go 1.18
- Revert "internal/ci: move pushTipToTryBot workflow to gerrithub package"
- Revert "internal/ci: rename base parameter field name"
- Revert "internal/ci: move configuration from workflows.cue to core"
- Revert "internal/ci: rename gerrithub #dispatchWorkflow"
- Revert "internal/ci: remove workflow files pre generate"
- Revert "internal/ci: split base into separate files"
.githubclarify what we mean by "latest release"- internal/encoding/{json|yaml}: disallow non-regular fields
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
| Platform | File and SHA-256 |
|---|---|
| macOS, Intel | cue_39846589363fd642d082561906894934d06fc6bde2fed9eef8f7ed9aec463a9f |
| macOS, Apple silicon | cue_bdc5a9b9feb3e310bd1261eb472a3b77df76a060dd65712409d716835afa3e1b |
| Linux, x86-64 | cue_2e3a75fc1a43622d851a389d66f505f8c30a43af9ec83181afadad168795acd8 |
| Linux, Arm64 | cue_2fb8807aa8d9ac5d1c8af3137f619e7fa769969cd3801dcb39f65b3c6672af5b |
| Windows, x86-64 | cue_670ad986473ce076d1837ce068bea9aae01994dc986433f89d393a476b7e428f |
| Windows, Arm64 | cue_73488be820c92ec48ca765dbcc1daf72fff9d60341edca3235a266ff2ed2ad8f |
SHA-256 checksums for all of these: checksums.txt