v0.1.0
This release introduces various improvements to the cue command, including a streamlined CLI interface and improved interoperability between different file formats.
Many of the command-line flags were previously rather arbitrarily implemented for some commands and not others. This release fixes most of that. This release also makes it possible to convert between different formats, such as YAML, JSON, JSON Schema (input only), OpenAPI, and Protbuf (input only).
This release also starts a new versioning strategy. CUE exists of several fairly independent parts. Each next milestone focusses on a one of these parts. This round it was the cue command-line tool. Next round will be the evaluator. Each next minor version will correspond to one such milestone. This is not to say that upgrades and bug fixes cannot happen to other parts within a cycle—they can—but it helps focus.
The new strategy will also make it easier to do intermittent releases. We will use the minor releases to signify big additions and backwards-incompatible changes. Patch releases may include backwards-incompatible changes that include bug fixes or disabling previously deprecated features. We intent to follow this trategy until providing a general backwards-compatibility guarantee for v1.0.0. As usual, we intend to provide a smooth migration path for each incompatible language change.
As of this release, a Docker image is generated as part of the release process.
Define file types
A frequently asked feature was to be able to interpret files as anything. CUE now allows qualifiers to “cast” a file to any supported format. For instance,
$ cue eval json: foo.datainterprets foo.data as JSON and then prints it as CUE. This also shows that the input for eval no longer needs to be CUE but can be any format that is convertible to CUE.
This means that CUE can now also be used between non-CUE formats. For instance,
$ cue export foo.json -o foo.yamlwill convert JSON to YAML.
Packages can now be qualified by package name (for instance ./foo:bar), not just directory.
Run cue help inputs and cue help filetypes for more information.
Streamlined flags
The import command already had a set of flags that maps JSON and YAML files to a prescribed location within a CUE configuration. These flags are now also available for many other commands so that JSON and YAML files, as well as other formats, can be processed by the cue command without first having to convert them to CUE.
For instance,
$ cue eval -l 'strings.ToLower(kind)' -l name foo.yamlputs any document in foo.yaml at a path based on its kind and name fields.
Also the output flags (file and format), among others, have been harmonized across commands. This sometimes led to backwards-incompatible changes.
Run cue help flags for more information.
CUE as a data format
The qualifier mechanism can also be used to restrict what language constructions can be used in .cue files. Most notably,
$ cue eval data: foo.cuespecifies that the file foo.cue may only contain data fields, but no references, definitions, builtin invocations, or any other CUE construct other than simple data. In other words, this allows CUE to be used as an alternative JSON or YAML format.
In the future we may add a file extension to indicate this CUE dialect.
New cue def command
The cue eval command was configured to generate cue that seemed pleasing to read to humans, but it would generate something that is neither useful as data nor as a schema. cue export could already be used to generate data, but there was nothing to conveniently generate a schema.
cue def is also the command of choice converting schema-based formats to CUE.
Value injection
Many users have requested a convenient way to defining environment-specific variants of configurations and ways to inject values based on environemt variables and command line flags.
We have added support for environment variables at various points in the tooling layer. Due to their non-hermetic nature, though, environment variables are not an appropriate mechanism for CUE configurations in general.
An important criterion for allowing such injection was retaining the ability to analyze configurations and make intent of how to use a configuration explicit. Simultaneously, we did not want to impose on the structure of a configuration.
Our solution is to use attributes to explicitly mark injection points. A field that with a “tag” attribute of the following form:
environment: "prod" | "staging" @tag(env)can be set to "prod" on the command line using -t env=prod. The tag attribute may also explicitly define some shorthands. For instance, by specifying
environment: "prod" | "staging" @tag(env,short=prod|staging)the same can be accomplished using -t prod.
This mechanism makes it very clear to both the user and the cue tooling which non-concrete values may be set by the user and which should be resolved by values within a configuration.
In the future we may consider to also allow whole-file injection analogous to Go build tags.
This release does not include support for command-line flags in the tooling layer. This is still being considered for a future release.
Run cue help injection for more information.
OpenAPI support
The cue tool now has basic support for converting OpenAPI definitions to CUE. This is a first stab, does not yet support external references, and is not as feature rich as the CUE-to-OpenAPI Go API that is used by Istio to generate its OpenAPI. But it should be a good start.
OpenAPI definitions can be imported using cue import or just used on the fly using cue eval or cue def. OpenAPI can be defined in JSON or YAML. For instance:
$ cue def openapi: foo.yamlwill interpret the foo.yaml file as OpenAPI and generate corresponding CUE.
It is also possible to convert CUE to OpenAPI. OpenAPI can be represented in JSON, YAML, or even CUE. For instance,
$ cue def ./pkg -out openapi+yamlwrites the evaluated CUE as OpenAPI in YAML format to stdout.
JSON Schema support
The cue tool has very basic support for mapping JSON Schema to CUE. This is still experimental and the converse (mapping CUE to JSON Schema) is not yet supported. The typical conventions followed in OpenAPI make it easy to find a mapping from OpenAPI to CUE. The same does not hold for JSON Schema. This is partly complicated by fields and definitions sharing the same namespace in CUE. Also, the top-level schema of JSON Schema is unnamed, making it hard to find an appropriate destination.
There is a proposal for CUE to have definitions and fields live in a separate namespace. This will make such a mapping considerably easier. For now, consider the mapping experimental.
As with OpenAPI, external references and anchors are not yet supported.
Auto detection of file types
The cue tool now interprets files with a .json, .yaml and .yml extension as either data, OpenAPI, or JSON Schema based on markers in the data. For JSON Schema this is a $schema field that refers to a schema on json-schema.org. OpenAPI is selected if a file contains a top-level openapi field with major version 3, an info.title, and an info.version field.
The use of qualifiers disables auto detection. So auto detection for a JSON file, for instance, can be disabled using a json: or data: qualifier.
cue import modes
The cue import tool now has import modes that specify which kinds of files to import. The default is the old default: JSON and YAML files, but with auto detection enabled.
Run cue help import for more details.
Protobuf support
The new cue import proto command can import Protobuf definitions.
A successful run imports all transitive dependencies of a .proto file into a CUE module: .proto files located within the module are converted to a CUE package at that location. The package name is derived from the go_package option, if present. Imported .proto files that can be found in a given include directory are put in the corresponding path in the cue.mod/gen directory.
The existing Protobuf API has been modified to generate CUE types hierarchically (instead of mapping all files to the top level) to make them closely correspond to the Protobuf definitions.
Protobuf definitions can be annotated with CUE-specific options to specify additional constraints for fields.
Command and Task changes
The task section in commands is now optional. A task can be included anywhere in a command. So commands with a single task can now be written as
import "tool/cli"
command: echo: cli.Print & {
text: "Hello world!"
}The cue tool will look for tasks anywhere nested within the run command where each task is considered a leaf node in this nesting.
Tasks can also be defined at the top of the file. These will only be run if they are referenced by a task defined in an executed command
Sometimes task must run after another task, even though it does not depend on any of its outputs. The $after field can be used in that case to explicitly mark a dependency.
See https://pkg.go.dev/cuelang.org/go@v0.1.0/pkg/tool?tab=doc for more information.
Vet changes
In addition to the flag restructuring, it is now possible to check a data file against a CUE package.
A backwards-incompatible change is that one now needs to use the -d flag, instead of the -e flag, to select a schema against which to compare. The -e flag was used by other commands to mean something different and this was cleaned up for consistency sake.
Trim safeguard
The cue trim command now checks that the resulting rewrite results in the same output when exported. This prevents a bug in the trim algorithm from inadventently compromising a configuration.
Run the command with the -i flag to bypass this check.
API additions
Go API:
cue/ast: Many new AST construction helperscue/literal: Added CUE number parsing utilitiescue: AddedLookupDef,Dereference,IsClosedand various other methods.cue:Fillnow acceptsValue.
CUE API various additions to
pkg/encoding/yamlpkg/filepkg/listpkg/mathpkg/regexppkg/tool/execpkg/tool/os
Language Changes
- Added attribute declarations (
@foo(bar)can be used as a declaration.)
Backwards-incompatible changes
Changes in flags:
- The
--attributesflag has been renamed to--show-attributesto be consistent with the--show-hiddenand--show-optionalflags. - The
-eflag forcue vethas been renamed to-d. The-eflag was already used for other commands and means something similar, but different. This allows-eand-dto be simulatenously supported. - The
-oflag now always defines an output file and the-outflag now always defines an output format. - Block comment support was already deprecated for a while, but support has now been removed from the language.
API changes:
cue:Instance.Namewas changed toInstance.PkgName.cue:Iteratoris now returned as a pointer.cue:Syntaxnow includes a package clause if a package is defined.encoding/protobuf:- proper encoding of
oneOf, which previously required at least one of the one-of fields to be specified. - generated CUE types are now declared as definitions.
- generated CUE types are now organized hierarchically, mapping one-to-one to the hierarchy defined in the
.protofiles. It previously adopted the Go convention, mapping all types to the top-level.
- proper encoding of
Bug fixes and performance enhancements
There were several bug fixes. Some of them might break your configuration. For instance, a regression was introduced that allowed required imports to be omitted in *_tool.cue files.
All changes
205 changesby area
cmd51
cmd/cue/cmdadd --tags flagcmd/cue/cmdadd --with-context flag for importcmd/cue/cmdadd def commandcmd/cue/cmdadd injection help topiccmd/cue/cmdadd safeguard to trim operationcmd/cue/cmdallow commands to be documented by commentscmd/cue/cmdallow decoding JSON Schema and OpenAPIcmd/cue/cmdallow mix of data and package filescmd/cue/cmdallow specifying field type for path flagcmd/cue/cmdallow task hierarchycmd/cue/cmdallow top-level taskscmd/cue/cmdbail out from errors earliercmd/cue/cmdconsolidate placement logic to single filecmd/cue/cmdcontrol task dependency using before and after fieldscmd/cue/cmdenable placement logic for vet, export, and evalcmd/cue/cmderr on space-separated syntaxcmd/cue/cmdeval flag changescmd/cue/cmdfactor out common flag codecmd/cue/cmdfail in case flag evaluation failscmd/cue/cmdfix Windows compatibility of testcmd/cue/cmdfix crashcmd/cue/cmdfix description for --show-optional flagcmd/cue/cmdfix export status and outputcmd/cue/cmdfix stdin usage for importcmd/cue/cmdharmonize output flagscmd/cue/cmdhoist expression logic into iteratorcmd/cue/cmdimprove $after semantics and errorscmd/cue/cmdintroduce config structcmd/cue/cmdintroduce help topics for new CLIcmd/cue/cmdmake error messages identical on Windowscmd/cue/cmdmake eval use output flagscmd/cue/cmdmake task references absolutecmd/cue/cmdmove export to filetypescmd/cue/cmdmove fmt to new infrastructurecmd/cue/cmdmove get to to use the astcmd/cue/cmdmove import to filetypescmd/cue/cmdmove vet to filetypescmd/cue/cmdprevent infinite loops while building dependency graphcmd/cue/cmdrequire imports for toolingcmd/cue/cmdsimplify usage of --path flagcmd/cue/cmdstreaming instance iterationcmd/cue/cmdsupport -e for exportcmd/cue/cmdsupport import of proto and openapicmd/cue/cmdsupport openapi out and proto incmd/cue/cmdtrack dependencies in definitionscmd/cue/cmdunshadow type names in get gocmd/cue/cmdupdate cmd documentationcmd/cue/cmefix import error message regressioncmd/cuefix cue import -pcmd/cuemake fmt work on tool filescmd/cueuse module information if no -X version information specified
cue67
cue/ast/astutilcatch cycle for label expressionscue/ast/astutilimprove LabelName logiccue/astadd NewBinExpr helpercue/astadd NewBool helpercue/astadd NewLit helpercue/astadd NewStruct helpercue/astadd PackageName methodcue/astallow CommentGroups in NewStructcue/buildremove unnecessary duplicate initializedcue/cmd/cuehoist placeOrphan from importcue/cmd/cuehoist placement logic from importcue/errorsmake compile again with Go 1.12cue/errorsremove unnecessary first slice length on list.Reset()cue/formatalways remove space before ':'cue/formatfix simplification bugcue/formatfix string label rewritingcue/formatonly format valid identifierscue/formatprint empty struct on one line by defaultcue/formatreplace bulk labels with ellipsis if possiblecue/literalfactor out number parsing codecue/loadallow mixing anonymous packages in files modecue/loadallow usingpath:pkgnameon command linecue/loadexpose error typescue/loadfactor out addFiles.cue/loadfix test breakage for Windowscue/loadremove unnecessary colon checkcue/loadremove unnecessary import aliascue/loaduse build.File to support "-"cue/parserfix parsing bugcue/scannercompletely remove block comment supportcueadd '-local cuelang.org/go' flag for buildins.gocueadd Dereference and fix value pathscueadd IsClosed methodcueadd Subsume to replace Subsumescueadd __foo variants for predeclared identifierscueadd a test case forlist.Equalscueadd fallback mode for unresolved disjunctionscueallow a Value to be passed to Fillcueallow alias reuse in subscopescueallow export of schema and other optionscueallow schema mode in subsumptioncuedefine Fill on Value, LookupDef and bug fixescuedetect incomplete value for value methodcuedo not evaluate list elem for evalPartialcuefail when converting invalid UTF-8 to a CUE stringcuefix Issue 289cuefix Value.Subsumes example to correct function naming conventioncuefix bug that dropped optional fields in defcuefix compiler bug and improve debug printcuefix crash if yielded value is a disjunctioncuefix detection of incomplete valuecuefix export bugcuefix handling of incomplete callscuefix import usage detection for partially resolved filescuefix marshaling bugcuefix number outputcuefix struct instance matching of referencescueimplement attribute declarationscueinterpret nil as _ or topcuekeep path in API error valuecuelimit number of position errorscueprioritize missing field over incomplete errorscuerename Name to PkgName and add DisplayNamecuereturn pointer from Struct.Fields.cuesimplify numLitcuesupport export package clause and docscuetrack incompleteness across marshal errors
doc9
doc/ref/spec.mdreformat to deal with Hugo bugdoc/ref/specattribute changesdoc/reffix a go-ism in the specdoc/tutorial/basicschange title of sectiondoc/tutorial/basicsremove reference to % operatordoc/tutorial/kubernetesa few fixesdoc/tutorial/kubernetesfix eval command typosdoc/tutorials/basicsremove duplicate textdoc/tutorials/basicstypo
encoding24
encoding/gocodemake work for definitionsencoding/jsondon't simplify hidden fieldsencoding/jsonfix Doc comments for Extract and Decodeencoding/jsonfix JSON import for numeric keysencoding/jsonschemaadd features to support OpenAPIencoding/jsonschemaexpose API of JSON Schema decoderencoding/jsonschemafix Windows path issueencoding/jsonschemainitial JSON Schema to CUE conversionencoding/jsonschemarequire explicit package nameencoding/openapiencode title, version, and contact as fieldsencoding/openapigenerate CUE expressionsencoding/openapiimplement Extractencoding/openapimake API backwards compatible for Istioencoding/openapimore accurate handling of disjunctionsencoding/openapisort schema alphabeticallyencoding/openapisupport nested defintitionsencoding/openapisupported nested definitionsencoding/protobufallow specifying packageencoding/protobufdefine messages as closedencoding/protobufdon't rely on verbatim Ident formattingencoding/protobufgenerate nested definitionsencoding/protobufproper encoding of oneOfencoding/protobufremove dependency on loadencoding/yamleliminate use of ghodss yaml pkg
github4
githubcache ~/go/pkg/modgithubenable docker featuregithubenable run goreleaser automatically when bump new taggithubfix lack of v prefix on build_args
internal19
internal/clihoist cli parsing code from tool/envinternal/cmd/qgoupdate Copyright year to 2020internal/diffavoid cycle when diffinginternal/difffix bug that caused hanginternal/encoding/jsonimplement Encodeinternal/encoding/yamlfix go1.12 breakageinternal/encodingalways format with tabsinternal/encodingsupport cue file typeinternal/encodingsupport input validationinternal/filetypesadd auto interpretationinternal/filetypesadd options and mode defaultsinternal/filetypesbetter error message for files without extensioninternal/filetypesexpose package test internallyinternal/filetypesfix Windows breakageinternal/filetypespackage for interpreting command line argsinternaladd MakeInstanceinternaladd ToFile and ToExprinternalhoist attribute parsing logicinternalswitch defaullt GenPath to be in cue.mod
pkg17
pkg/encoding/yamlrequest concrete data for syntaxpkg/encoding/yamlvalidate using instance checkpkg/fileFix file.Glob to generate correct CUE structurepkg/listadd sort functionalitypkg/listdocumentation fix.pkg/listfix typopkg/listpick default before flatteningpkg/math/bitsreduce maximum bit indexpkg/regexpadd Valid functionpkg/tool/execallow passing env vars in exec.Runpkg/tool/execfix stdin processingpkg/tool/execuse os.Stdin on null onlypkg/tool/osadd tasks for environment variablespkg/tool/osremove env manualipulate taskspkg/toolimprove error reportingpkg/toolupdate documentation and remove $beforepkg/tooluse $id instead of kind to identify task types
tools3
tools/trimfix build breakagetools/trimfix trimming bugtools/trimundo faulty optimization
Other11
.githubsmall improvements to the bug template.githubupdate issue templates- Add help text to show yaml export option
- Fix typos in 'cue mod'
allgofmt -sallmake goimports happycirebuild tip.cuelang.org on master commitsdepsupgrade cobra to v0.0.7 to use new SetIn/SetOutdockeradd Dockerfile and .dockerignorego.sumrun go tidymoduleupdate google/go-cmp to v0.4.0
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_8a8353087f6f35221ca5cedd048925c817cd24e3fe3ff5d0fadaa90a2490f827 |
| Linux, Arm64 | cue_73a3045fa26ec21f94e324b545a5c1c713f798a30342c97e8ea375905b9dfad3 |
| Linux, x86-64 | cue_73a9197645f4c6ae63ad20b5c1b4c9b970b633f56c66951f7d31e7b91bafa414 |
| Windows, x86-64 | cue_b1c361ee40e589d8ac1cb23a1282bf50f084ce0f53e53485ff3632d1439049cc |
SHA-256 checksums for all of these: checksums.txt