blob: f44710db512c17aa89c237c764b6263f15de0c90 [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.
49The same CUE defintion can simultaneously be used for validating data
50and 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
96#### Install From Source
97
98If you already have Go installed, the short version is:
99
100```
101go get -u cuelang.org/go/cmd/cue
102```
103
104This will install the `cue` command line tool.
105
Marcel van Lohuizen36d889f2018-12-16 10:43:17 +0100106For more details see [Installing CUE](./doc/install.md).
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100107
108
109### Learning CUE
110
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +0100111The fastest way to learn the basics is to follow the
112[tutorial on basic language constructs](./doc/tutorial/basics/Readme.md).
113
114A more elaborate tutorial demonstrating of how to convert and restructure
115an existing set of Kubernetes configurations is available in
Marcel van Lohuizen02173f82018-12-20 13:27:07 +0100116[written form](./doc/tutorial/kubernetes/README.md).
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100117
118### References
119
Marcel van Lohuizen36d889f2018-12-16 10:43:17 +0100120- [Language Specification](./doc/ref/spec.md): official CUE Language specification.
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100121
122- [API](https://godoc.org/cuelang.org/go/cue): the API on godoc.org
123
124- [Builtin packages](https://godoc.org/cuelang.org/go/pkg): builtins available from CUE programs
125
Marcel van Lohuizen36d889f2018-12-16 10:43:17 +0100126- [`cue` Command line reference](./doc/cmd/cue.md): the `cue` command
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100127
128
129### Contributing
130
131Our canonical Git repository is located at https://cue.googlesource.com.
132
Marcel van Lohuizen57271032018-12-20 21:23:10 +0100133To contribute, please read the [Contribution Guide](./doc/contribute.md).
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100134
Jonathan Amsterdam32c5d9f2019-02-10 05:52:32 -0500135To report issues or make a feature request, use the
136[issue tracker](https://github.com/cuelang/cue/issues).
137
Marcel van Lohuizen2839c252019-06-18 17:39:52 +0200138Changes can be contributed using Gerrit or Github pull requests.
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100139
xinau980b30c2019-07-26 22:30:26 +0000140
141### Contact
142
143You can get in touch with the cuelang community in the following ways:
144
145- Chat with us on our
146 [Slack workspace](https://join.slack.com/t/cuelang/shared_invite/enQtNjk1NzU1MzMwMjI2LWQ0ZDA2OTRjYTQ0MGUyZDBiYWIzZjVhZGI1YWVlNTVmMWU3MTFhY2MxZmRmMjBiMTA5MGQ1YzUyMmMzN2IxYzc).
147
148
149---
150
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100151Unless otherwise noted, the CUE source files are distributed
152under the Apache 2.0 license found in the LICENSE file.
153
Marcel van Lohuizen58b7c322018-12-28 14:46:39 +0100154This is not an officially supported Google product.
Marcel van Lohuizen969a7832018-11-22 19:43:51 +0100155