blob: b937228cd3b5b4a9a624f791829611ed4c8725da [file] [log] [blame] [view]
Marcel van Lohuizen36d889f2018-12-16 10:43:17 +01001<!--
2 Copyright 2018 The CUE Authors
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15-->
Marcel van Lohuizen9fc50892019-06-18 17:40:04 +020016[![GoDoc](https://godoc.org/cuelang.org/go?status.svg)](https://godoc.org/cuelang.org/go)
17[![Appveyor](https://ci.appveyor.com/api/projects/status/0v3ec7p5162hpwpe?svg=true)](https://ci.appveyor.com/project/mpvl/cue)
18[![Go Report Card](https://goreportcard.com/badge/github.com/cuelang/cue)](https://goreportcard.com/report/github.com/cuelang/cue)
Marcel van Lohuizen295d20d2019-06-18 19:54:55 +020019[![Go 1.12](https://img.shields.io/badge/go-1.12-9cf.svg)](https://golang.org/dl/)
20[![platforms](https://img.shields.io/badge/platforms-linux|windows|macos-inactive.svg)]()
Marcel van Lohuizen36d889f2018-12-16 10:43:17 +010021
22
Marcel van Lohuizen5953c662019-01-26 13:26:04 +010023# The CUE Data Constraint Language
Marcel van Lohuizen969a7832018-11-22 19:43:51 +010024
25_Configure, Unify, Execute_
26
Marcel van Lohuizen5953c662019-01-26 13:26:04 +010027CUE is an open source data constraint language which aims
28to simplify tasks involving defining and using data.
Marcel van Lohuizen969a7832018-11-22 19:43:51 +010029
Marcel van Lohuizen8dfef672019-03-14 17:23:01 +010030It is a superset of JSON,
31allowing users familiar with JSON to get started quickly.
Marcel van Lohuizen36d889f2018-12-16 10:43:17 +010032
Marcel van Lohuizen969a7832018-11-22 19:43:51 +010033
Marcel van Lohuizen8dfef672019-03-14 17:23:01 +010034### What is it for?
Marcel van Lohuizen969a7832018-11-22 19:43:51 +010035
Marcel van Lohuizen8dfef672019-03-14 17:23:01 +010036You can use CUE to
37
38- define a detailed validation schema for your data (manually or automatically from data)
39- reduce boilerplate in your data (manually or automatically from schema)
40- extract a schema from code
41- generate type definitions and validation code
42- merge JSON in a principled way
43- define and run declarative scripts
44
45
46### How?
47
48CUE merges the notion of schema and data.
0xflotus8b4cab62019-09-03 14:06:40 +000049The same CUE definition can simultaneously be used for validating data
Marcel van Lohuizen8dfef672019-03-14 17:23:01 +010050and act as a template to reduce boilerplate.
51Schema definition is enriched with fine-grained value definitions
52and default values.
53At the same time,
54data can be simplified by removing values implied by such detailed definitions.
55The merging of these two concepts enables
56many tasks to be handled in a principled way.
57
58
59Constraints provide a simple and well-defined, yet powerful, alternative
60to inheritance,
61a common source of complexity with configuration languages.
62
63
64### CUE Scripting
65
66The CUE scripting layer defines declarative scripting, expressed in CUE,
67on top of data.
68This solves three problems:
69working around the closedness of CUE definitions (we say CUE is hermetic),
70providing an easy way to share common scripts and workflows for using data,
71and giving CUE the knowledge of how data is used to optimize validation.
72
73There are many tools that interpret data or use a specialized language for
74a specific domain (Kustomize, Ksonnet).
75This solves dealing with data on one level, but the problem it solves may repeat
76itself at a higher level when integrating other systems in a workflow.
77CUE scripting is generic and allows users to define any workflow.
78
79
80### Tooling
81
82CUE is designed for automation.
83Some aspects of this are:
84
Marcel van Lohuizen969a7832018-11-22 19:43:51 +010085- convert existing YAML and JSON
Marcel van Lohuizen969a7832018-11-22 19:43:51 +010086- automatically simplify configurations
Marcel van Lohuizen8dfef672019-03-14 17:23:01 +010087- rich APIs designed for automated tooling
Marcel van Lohuizen36d889f2018-12-16 10:43:17 +010088- formatter
89- arbitrary-precision arithmetic
Marcel van Lohuizen969a7832018-11-22 19:43:51 +010090- generate CUE templates from source code
Marcel van Lohuizen8dfef672019-03-14 17:23:01 +010091- generate source code from CUE definitions (TODO)
Marcel van Lohuizen969a7832018-11-22 19:43:51 +010092
93
94### Download and Install
95
Joel Longtine30565942019-08-25 12:47:15 +000096#### Install using Homebrew
97
98Using [Homebrew](https://brew.sh), you can install using the CUE Homebrew tap:
99
100`brew install cuelang/tap/cue`
101
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100102#### Install From Source
103
104If you already have Go installed, the short version is:
105
106```
107go get -u cuelang.org/go/cmd/cue
108```
109
110This will install the `cue` command line tool.
111
Marcel van Lohuizen36d889f2018-12-16 10:43:17 +0100112For more details see [Installing CUE](./doc/install.md).
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100113
114
115### Learning CUE
116
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +0100117The fastest way to learn the basics is to follow the
118[tutorial on basic language constructs](./doc/tutorial/basics/Readme.md).
119
120A more elaborate tutorial demonstrating of how to convert and restructure
121an existing set of Kubernetes configurations is available in
Marcel van Lohuizen02173f82018-12-20 13:27:07 +0100122[written form](./doc/tutorial/kubernetes/README.md).
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100123
124### References
125
Marcel van Lohuizen36d889f2018-12-16 10:43:17 +0100126- [Language Specification](./doc/ref/spec.md): official CUE Language specification.
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100127
128- [API](https://godoc.org/cuelang.org/go/cue): the API on godoc.org
129
130- [Builtin packages](https://godoc.org/cuelang.org/go/pkg): builtins available from CUE programs
131
Marcel van Lohuizen36d889f2018-12-16 10:43:17 +0100132- [`cue` Command line reference](./doc/cmd/cue.md): the `cue` command
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100133
134
135### Contributing
136
137Our canonical Git repository is located at https://cue.googlesource.com.
138
Marcel van Lohuizen57271032018-12-20 21:23:10 +0100139To contribute, please read the [Contribution Guide](./doc/contribute.md).
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100140
Jonathan Amsterdam32c5d9f2019-02-10 05:52:32 -0500141To report issues or make a feature request, use the
142[issue tracker](https://github.com/cuelang/cue/issues).
143
Marcel van Lohuizen2839c252019-06-18 17:39:52 +0200144Changes can be contributed using Gerrit or Github pull requests.
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100145
xinau980b30c2019-07-26 22:30:26 +0000146
147### Contact
148
149You can get in touch with the cuelang community in the following ways:
150
151- Chat with us on our
xinau7f9d0262019-08-28 11:19:06 +0000152 [Slack workspace](https://join.slack.com/t/cuelang/shared_invite/enQtNzQwODc3NzYzNTA0LTAxNWQwZGU2YWFiOWFiOWQ4MjVjNGQ2ZTNlMmIxODc4MDVjMDg5YmIyOTMyMjQ2MTkzMTU5ZjA1OGE0OGE1NmE).
xinau980b30c2019-07-26 22:30:26 +0000153
154
155---
156
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100157Unless otherwise noted, the CUE source files are distributed
158under the Apache 2.0 license found in the LICENSE file.
159
Marcel van Lohuizen58b7c322018-12-28 14:46:39 +0100160This is not an officially supported Google product.
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100161