Marcel van Lohuizen | 36d889f | 2018-12-16 10:43:17 +0100 | [diff] [blame] | 1 | <!-- |
| 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 Lohuizen | 9fc5089 | 2019-06-18 17:40:04 +0200 | [diff] [blame] | 16 | [](https://godoc.org/cuelang.org/go) |
| 17 | [](https://ci.appveyor.com/project/mpvl/cue) |
| 18 | [](https://goreportcard.com/report/github.com/cuelang/cue) |
Marcel van Lohuizen | 295d20d | 2019-06-18 19:54:55 +0200 | [diff] [blame] | 19 | [](https://golang.org/dl/) |
| 20 | []() |
Marcel van Lohuizen | 36d889f | 2018-12-16 10:43:17 +0100 | [diff] [blame] | 21 | |
| 22 | |
Marcel van Lohuizen | 5953c66 | 2019-01-26 13:26:04 +0100 | [diff] [blame] | 23 | # The CUE Data Constraint Language |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 24 | |
| 25 | _Configure, Unify, Execute_ |
| 26 | |
Marcel van Lohuizen | 5953c66 | 2019-01-26 13:26:04 +0100 | [diff] [blame] | 27 | CUE is an open source data constraint language which aims |
| 28 | to simplify tasks involving defining and using data. |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 29 | |
Marcel van Lohuizen | 8dfef67 | 2019-03-14 17:23:01 +0100 | [diff] [blame] | 30 | It is a superset of JSON, |
| 31 | allowing users familiar with JSON to get started quickly. |
Marcel van Lohuizen | 36d889f | 2018-12-16 10:43:17 +0100 | [diff] [blame] | 32 | |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 33 | |
Marcel van Lohuizen | 8dfef67 | 2019-03-14 17:23:01 +0100 | [diff] [blame] | 34 | ### What is it for? |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 35 | |
Marcel van Lohuizen | 8dfef67 | 2019-03-14 17:23:01 +0100 | [diff] [blame] | 36 | You 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 | |
| 48 | CUE merges the notion of schema and data. |
0xflotus | 8b4cab6 | 2019-09-03 14:06:40 +0000 | [diff] [blame] | 49 | The same CUE definition can simultaneously be used for validating data |
Marcel van Lohuizen | 8dfef67 | 2019-03-14 17:23:01 +0100 | [diff] [blame] | 50 | and act as a template to reduce boilerplate. |
| 51 | Schema definition is enriched with fine-grained value definitions |
| 52 | and default values. |
| 53 | At the same time, |
| 54 | data can be simplified by removing values implied by such detailed definitions. |
| 55 | The merging of these two concepts enables |
| 56 | many tasks to be handled in a principled way. |
| 57 | |
| 58 | |
| 59 | Constraints provide a simple and well-defined, yet powerful, alternative |
| 60 | to inheritance, |
| 61 | a common source of complexity with configuration languages. |
| 62 | |
| 63 | |
| 64 | ### CUE Scripting |
| 65 | |
| 66 | The CUE scripting layer defines declarative scripting, expressed in CUE, |
| 67 | on top of data. |
| 68 | This solves three problems: |
| 69 | working around the closedness of CUE definitions (we say CUE is hermetic), |
| 70 | providing an easy way to share common scripts and workflows for using data, |
| 71 | and giving CUE the knowledge of how data is used to optimize validation. |
| 72 | |
| 73 | There are many tools that interpret data or use a specialized language for |
| 74 | a specific domain (Kustomize, Ksonnet). |
| 75 | This solves dealing with data on one level, but the problem it solves may repeat |
| 76 | itself at a higher level when integrating other systems in a workflow. |
| 77 | CUE scripting is generic and allows users to define any workflow. |
| 78 | |
| 79 | |
| 80 | ### Tooling |
| 81 | |
| 82 | CUE is designed for automation. |
| 83 | Some aspects of this are: |
| 84 | |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 85 | - convert existing YAML and JSON |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 86 | - automatically simplify configurations |
Marcel van Lohuizen | 8dfef67 | 2019-03-14 17:23:01 +0100 | [diff] [blame] | 87 | - rich APIs designed for automated tooling |
Marcel van Lohuizen | 36d889f | 2018-12-16 10:43:17 +0100 | [diff] [blame] | 88 | - formatter |
| 89 | - arbitrary-precision arithmetic |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 90 | - generate CUE templates from source code |
Marcel van Lohuizen | 8dfef67 | 2019-03-14 17:23:01 +0100 | [diff] [blame] | 91 | - generate source code from CUE definitions (TODO) |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 92 | |
| 93 | |
| 94 | ### Download and Install |
| 95 | |
Joel Longtine | 3056594 | 2019-08-25 12:47:15 +0000 | [diff] [blame] | 96 | #### Install using Homebrew |
| 97 | |
| 98 | Using [Homebrew](https://brew.sh), you can install using the CUE Homebrew tap: |
| 99 | |
| 100 | `brew install cuelang/tap/cue` |
| 101 | |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 102 | #### Install From Source |
| 103 | |
| 104 | If you already have Go installed, the short version is: |
| 105 | |
| 106 | ``` |
| 107 | go get -u cuelang.org/go/cmd/cue |
| 108 | ``` |
| 109 | |
| 110 | This will install the `cue` command line tool. |
| 111 | |
Marcel van Lohuizen | 36d889f | 2018-12-16 10:43:17 +0100 | [diff] [blame] | 112 | For more details see [Installing CUE](./doc/install.md). |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 113 | |
| 114 | |
| 115 | ### Learning CUE |
| 116 | |
Marcel van Lohuizen | 75cb003 | 2019-01-11 12:10:48 +0100 | [diff] [blame] | 117 | The fastest way to learn the basics is to follow the |
| 118 | [tutorial on basic language constructs](./doc/tutorial/basics/Readme.md). |
| 119 | |
| 120 | A more elaborate tutorial demonstrating of how to convert and restructure |
| 121 | an existing set of Kubernetes configurations is available in |
Marcel van Lohuizen | 02173f8 | 2018-12-20 13:27:07 +0100 | [diff] [blame] | 122 | [written form](./doc/tutorial/kubernetes/README.md). |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 123 | |
| 124 | ### References |
| 125 | |
Marcel van Lohuizen | 36d889f | 2018-12-16 10:43:17 +0100 | [diff] [blame] | 126 | - [Language Specification](./doc/ref/spec.md): official CUE Language specification. |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 127 | |
| 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 Lohuizen | 36d889f | 2018-12-16 10:43:17 +0100 | [diff] [blame] | 132 | - [`cue` Command line reference](./doc/cmd/cue.md): the `cue` command |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 133 | |
| 134 | |
| 135 | ### Contributing |
| 136 | |
| 137 | Our canonical Git repository is located at https://cue.googlesource.com. |
| 138 | |
Marcel van Lohuizen | 5727103 | 2018-12-20 21:23:10 +0100 | [diff] [blame] | 139 | To contribute, please read the [Contribution Guide](./doc/contribute.md). |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 140 | |
Jonathan Amsterdam | 32c5d9f | 2019-02-10 05:52:32 -0500 | [diff] [blame] | 141 | To report issues or make a feature request, use the |
| 142 | [issue tracker](https://github.com/cuelang/cue/issues). |
| 143 | |
Marcel van Lohuizen | 2839c25 | 2019-06-18 17:39:52 +0200 | [diff] [blame] | 144 | Changes can be contributed using Gerrit or Github pull requests. |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 145 | |
xinau | 980b30c | 2019-07-26 22:30:26 +0000 | [diff] [blame] | 146 | |
| 147 | ### Contact |
| 148 | |
| 149 | You can get in touch with the cuelang community in the following ways: |
| 150 | |
| 151 | - Chat with us on our |
xinau | 7f9d026 | 2019-08-28 11:19:06 +0000 | [diff] [blame] | 152 | [Slack workspace](https://join.slack.com/t/cuelang/shared_invite/enQtNzQwODc3NzYzNTA0LTAxNWQwZGU2YWFiOWFiOWQ4MjVjNGQ2ZTNlMmIxODc4MDVjMDg5YmIyOTMyMjQ2MTkzMTU5ZjA1OGE0OGE1NmE). |
xinau | 980b30c | 2019-07-26 22:30:26 +0000 | [diff] [blame] | 153 | |
| 154 | |
| 155 | --- |
| 156 | |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 157 | Unless otherwise noted, the CUE source files are distributed |
| 158 | under the Apache 2.0 license found in the LICENSE file. |
| 159 | |
Marcel van Lohuizen | 58b7c32 | 2018-12-28 14:46:39 +0100 | [diff] [blame] | 160 | This is not an officially supported Google product. |
Marcel van Lohuizen | 969a783 | 2018-11-22 19:43:51 +0100 | [diff] [blame] | 161 | |