v0.1.0

cue-lang/cue Released

A release of CUE OSS · its page on GitHub

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.data

interprets 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.yaml

will 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.yaml

puts 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.cue

specifies 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.yaml

will 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+yaml

writes 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 helpers
  • cue/literal: Added CUE number parsing utilities
  • cue: Added LookupDef, Dereference, IsClosed and various other methods.
  • cue: Fill now accepts Value.

CUE API various additions to

  • pkg/encoding/yaml
  • pkg/file
  • pkg/list
  • pkg/math
  • pkg/regexp
  • pkg/tool/exec
  • pkg/tool/os

Language Changes

  • Added attribute declarations (@foo(bar) can be used as a declaration.)

Backwards-incompatible changes

Changes in flags:

  • The --attributes flag has been renamed to --show-attributes to be consistent with the --show-hidden and --show-optional flags.
  • The -e flag for cue vet has been renamed to -d. The -e flag was already used for other commands and means something similar, but different. This allows -e and -d to be simulatenously supported.
  • The -o flag now always defines an output file and the -out flag 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.Name was changed to Instance.PkgName.
  • cue: Iterator is now returned as a pointer.
  • cue: Syntax now 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 .proto files. It previously adopted the Go convention, mapping all types to the top-level.

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 flag0846b93
  • cmd/cue/cmdadd --with-context flag for importd10e59f
  • cmd/cue/cmdadd def command116e9fd
  • cmd/cue/cmdadd injection help topicaf71ef2
  • cmd/cue/cmdadd safeguard to trim operation5208956
  • cmd/cue/cmdallow commands to be documented by comments67d084a
  • cmd/cue/cmdallow decoding JSON Schema and OpenAPIf89aa48
  • cmd/cue/cmdallow mix of data and package filesa920a11
  • cmd/cue/cmdallow specifying field type for path flag694303f
  • cmd/cue/cmdallow task hierarchy4d5f5c7
  • cmd/cue/cmdallow top-level tasks511584e
  • cmd/cue/cmdbail out from errors earlier38a114d
  • cmd/cue/cmdconsolidate placement logic to single file4d6e269
  • cmd/cue/cmdcontrol task dependency using before and after fieldse3a7a72
  • cmd/cue/cmdenable placement logic for vet, export, and eval4616a3b
  • cmd/cue/cmderr on space-separated syntax3b17f6a
  • cmd/cue/cmdeval flag changes67e25d4
  • cmd/cue/cmdfactor out common flag codeeb7c51d
  • cmd/cue/cmdfail in case flag evaluation fails7a02899
  • cmd/cue/cmdfix Windows compatibility of test5a8279f
  • cmd/cue/cmdfix crash00757a9
  • cmd/cue/cmdfix description for --show-optional flag8af2efe
  • cmd/cue/cmdfix export status and output27b9ca3
  • cmd/cue/cmdfix stdin usage for import485f389
  • cmd/cue/cmdharmonize output flags6eed1e9
  • cmd/cue/cmdhoist expression logic into iteratore7e0139
  • cmd/cue/cmdimprove $after semantics and errors8fbf67e
  • cmd/cue/cmdintroduce config struct1974705
  • cmd/cue/cmdintroduce help topics for new CLI2beaa9c
  • cmd/cue/cmdmake error messages identical on Windowsde9cc69
  • cmd/cue/cmdmake eval use output flags6dfecc3
  • cmd/cue/cmdmake task references absolutedd87908
  • cmd/cue/cmdmove export to filetypesed5689f
  • cmd/cue/cmdmove fmt to new infrastructure337e2d1
  • cmd/cue/cmdmove get to to use the ast6e48383
  • cmd/cue/cmdmove import to filetypesabb5401
  • cmd/cue/cmdmove vet to filetypes01fbfa1
  • cmd/cue/cmdprevent infinite loops while building dependency graphbfdc423
  • cmd/cue/cmdrequire imports for toolingc82a793
  • cmd/cue/cmdsimplify usage of --path flagf8afaed
  • cmd/cue/cmdstreaming instance iterationf733746
  • cmd/cue/cmdsupport -e for exportdcffaef
  • cmd/cue/cmdsupport import of proto and openapid4ce8ef
  • cmd/cue/cmdsupport openapi out and proto in77ffe9d
  • cmd/cue/cmdtrack dependencies in definitionsa32d5dd
  • cmd/cue/cmdunshadow type names in get god8757db
  • cmd/cue/cmdupdate cmd documentation882d88d
  • cmd/cue/cmefix import error message regression88b9bd5
  • cmd/cuefix cue import -pbd5faf9
  • cmd/cuemake fmt work on tool files3db1509
  • cmd/cueuse module information if no -X version information specified6ad04b3

cue67

  • cue/ast/astutilcatch cycle for label expressions2b93e11
  • cue/ast/astutilimprove LabelName logice076cd1
  • cue/astadd NewBinExpr helper8c70185
  • cue/astadd NewBool helpere2650e0
  • cue/astadd NewLit helpere803ab8
  • cue/astadd NewStruct helperb236d4a
  • cue/astadd PackageName methodd4faf4b
  • cue/astallow CommentGroups in NewStructe2e548b
  • cue/buildremove unnecessary duplicate initialized8e11671
  • cue/cmd/cuehoist placeOrphan from import6409c68
  • cue/cmd/cuehoist placement logic from import33c7705
  • cue/errorsmake compile again with Go 1.12442518f
  • cue/errorsremove unnecessary first slice length on list.Reset()a96b3bb
  • cue/formatalways remove space before ':'e7f46c0
  • cue/formatfix simplification bugd05ea95
  • cue/formatfix string label rewritingaf31654
  • cue/formatonly format valid identifiers78c24c5
  • cue/formatprint empty struct on one line by defaultffd21e6
  • cue/formatreplace bulk labels with ellipsis if possible9b2f6b0
  • cue/literalfactor out number parsing codecb1baf4
  • cue/loadallow mixing anonymous packages in files modefcdf3fe
  • cue/loadallow using path:pkgname on command line28d5c83
  • cue/loadexpose error types1288f89
  • cue/loadfactor out addFiles.4fd96d9
  • cue/loadfix test breakage for Windows86a67bc
  • cue/loadremove unnecessary colon checkf6f7791
  • cue/loadremove unnecessary import alias104d266
  • cue/loaduse build.File to support "-"334313c
  • cue/parserfix parsing buga16973a
  • cue/scannercompletely remove block comment support9b301e4
  • cueadd '-local cuelang.org/go' flag for buildins.go83fa8f4
  • cueadd Dereference and fix value paths024f1f5
  • cueadd IsClosed method53ca13f
  • cueadd Subsume to replace Subsumesc7c70a6
  • cueadd __foo variants for predeclared identifiers060a3c8
  • cueadd a test case for list.Equals2ca34b3
  • cueadd fallback mode for unresolved disjunctionsd56457f
  • cueallow a Value to be passed to Filld9e4b53
  • cueallow alias reuse in subscopes2540e8a
  • cueallow export of schema and other options72d8a92
  • cueallow schema mode in subsumptionb9d22d6
  • cuedefine Fill on Value, LookupDef and bug fixes58ada0e
  • cuedetect incomplete value for value method1fecca8
  • cuedo not evaluate list elem for evalPartialcc60dee
  • cuefail when converting invalid UTF-8 to a CUE string1e76e22
  • cuefix Issue 289847d37b
  • cuefix Value.Subsumes example to correct function naming convention76a47bc
  • cuefix bug that dropped optional fields in def5119440
  • cuefix compiler bug and improve debug printe084198
  • cuefix crash if yielded value is a disjunction5ad8510
  • cuefix detection of incomplete valueab2c7e5
  • cuefix export bug8108ef2
  • cuefix handling of incomplete calls8398107
  • cuefix import usage detection for partially resolved files76252f4
  • cuefix marshaling bug72dba3d
  • cuefix number outputd06f2d4
  • cuefix struct instance matching of referencesaa5e0c7
  • cueimplement attribute declarations0a6f7c9
  • cueinterpret nil as _ or top442bf2d
  • cuekeep path in API error valuec3c1624
  • cuelimit number of position errors1ffc615
  • cueprioritize missing field over incomplete errorsb992abe
  • cuerename Name to PkgName and add DisplayNamefe9722f
  • cuereturn pointer from Struct.Fields.31206eb
  • cuesimplify numLitb0678ab
  • cuesupport export package clause and docsf4649b2
  • cuetrack incompleteness across marshal errorsa805655

doc9

  • doc/ref/spec.mdreformat to deal with Hugo bug0cb140e
  • doc/ref/specattribute changes4dd9630
  • doc/reffix a go-ism in the spec107863a
  • doc/tutorial/basicschange title of section6320089
  • doc/tutorial/basicsremove reference to % operator0e4130f
  • doc/tutorial/kubernetesa few fixes275105a
  • doc/tutorial/kubernetesfix eval command typos7e3bdda
  • doc/tutorials/basicsremove duplicate text3171634
  • doc/tutorials/basicstypo7739e72

encoding24

  • encoding/gocodemake work for definitions0308a53
  • encoding/jsondon't simplify hidden fieldsb756712
  • encoding/jsonfix Doc comments for Extract and Decodee752347
  • encoding/jsonfix JSON import for numeric keysf81c40b
  • encoding/jsonschemaadd features to support OpenAPI671b956
  • encoding/jsonschemaexpose API of JSON Schema decoder47d9870
  • encoding/jsonschemafix Windows path issue60b4d91
  • encoding/jsonschemainitial JSON Schema to CUE conversion6cb0878
  • encoding/jsonschemarequire explicit package namebd98b13
  • encoding/openapiencode title, version, and contact as fields3c437bd
  • encoding/openapigenerate CUE expressionsf51c879
  • encoding/openapiimplement Extract64b39e6
  • encoding/openapimake API backwards compatible for Istio5c2b086
  • encoding/openapimore accurate handling of disjunctionseac3ea2
  • encoding/openapisort schema alphabetically56509a5
  • encoding/openapisupport nested defintitionsed90d00
  • encoding/openapisupported nested definitions439f857
  • encoding/protobufallow specifying package09ad0d2
  • encoding/protobufdefine messages as closedf9fa4d8
  • encoding/protobufdon't rely on verbatim Ident formatting0797e46
  • encoding/protobufgenerate nested definitionsc3efeb0
  • encoding/protobufproper encoding of oneOf0f03725
  • encoding/protobufremove dependency on load08c8a8f
  • encoding/yamleliminate use of ghodss yaml pkgcf72796

github4

  • githubcache ~/go/pkg/modede1e7d
  • githubenable docker featured9ca690
  • githubenable run goreleaser automatically when bump new tag2e67318
  • githubfix lack of v prefix on build_argsc24f394

internal19

  • internal/clihoist cli parsing code from tool/envaae80a0
  • internal/cmd/qgoupdate Copyright year to 20207988b62
  • internal/diffavoid cycle when diffing29e9d00
  • internal/difffix bug that caused hang5c3a17b
  • internal/encoding/jsonimplement Encode1d1295b
  • internal/encoding/yamlfix go1.12 breakage40cc12c
  • internal/encodingalways format with tabs975776e
  • internal/encodingsupport cue file type6e8fdd4
  • internal/encodingsupport input validation81a20d5
  • internal/filetypesadd auto interpretationf9f8e62
  • internal/filetypesadd options and mode defaults9b1dff7
  • internal/filetypesbetter error message for files without extension38362f8
  • internal/filetypesexpose package test internallybd2173e
  • internal/filetypesfix Windows breakage26e63ec
  • internal/filetypespackage for interpreting command line args429bd0f
  • internaladd MakeInstancec1b5e62
  • internaladd ToFile and ToExpr4805941
  • internalhoist attribute parsing logicb8cad1a
  • internalswitch defaullt GenPath to be in cue.moda494f2e

pkg17

  • pkg/encoding/yamlrequest concrete data for syntax9e71832
  • pkg/encoding/yamlvalidate using instance checka9b38db
  • pkg/fileFix file.Glob to generate correct CUE structure9242bf5
  • pkg/listadd sort functionalityc441dd3
  • pkg/listdocumentation fix.df7da7b
  • pkg/listfix typo0afa377
  • pkg/listpick default before flatteningfe7a58a
  • pkg/math/bitsreduce maximum bit index7008195
  • pkg/regexpadd Valid function2db865d
  • pkg/tool/execallow passing env vars in exec.Run72f8e8a
  • pkg/tool/execfix stdin processinga3a4b71
  • pkg/tool/execuse os.Stdin on null only05a3f7d
  • pkg/tool/osadd tasks for environment variables42346df
  • pkg/tool/osremove env manualipulate tasksc22d46d
  • pkg/toolimprove error reportinga7b4ca8
  • pkg/toolupdate documentation and remove $before2d8560d
  • pkg/tooluse $id instead of kind to identify task types44df1a8

tools3

  • tools/trimfix build breakaged1cfa57
  • tools/trimfix trimming bugc242505
  • tools/trimundo faulty optimizationfd90d12

Other11

  • .githubsmall improvements to the bug templatee6c7748
  • .githubupdate issue templates58cdb77
  • Add help text to show yaml export optionfb54e1b
  • Fix typos in 'cue mod'0227ac0
  • allgofmt -s066ede6
  • allmake goimports happy30a4bee
  • cirebuild tip.cuelang.org on master commits52cc7f1
  • depsupgrade cobra to v0.0.7 to use new SetIn/SetOut4ec09a4
  • dockeradd Dockerfile and .dockerignored64abbe
  • go.sumrun go tidyd0a6eef
  • moduleupdate google/go-cmp to v0.4.00198c89

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_0.1.0_Darwin_x86_64.tar.gz8a8353087f6f35221ca5cedd048925c817cd24e3fe3ff5d0fadaa90a2490f827
Linux, Arm64cue_0.1.0_Linux_arm64.tar.gz73a3045fa26ec21f94e324b545a5c1c713f798a30342c97e8ea375905b9dfad3
Linux, x86-64cue_0.1.0_Linux_x86_64.tar.gz73a9197645f4c6ae63ad20b5c1b4c9b970b633f56c66951f7d31e7b91bafa414
Windows, x86-64cue_0.1.0_Windows_x86_64.zipb1c361ee40e589d8ac1cb23a1282bf50f084ce0f53e53485ff3632d1439049cc

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

Install CUE