...

Text file src/cuelang.org/go/README.md

Documentation: cuelang.org/go

     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-->
    16[![Go Reference](https://pkg.go.dev/badge/cuelang.org/go.svg)](https://pkg.go.dev/cuelang.org/go)
    17[![Github](https://github.com/cue-lang/cue/actions/workflows/trybot.yml/badge.svg)](https://github.com/cue-lang/cue/actions/workflows/trybot.yml?query=branch%3Amaster+event%3Apush)
    18[![Go 1.21+](https://img.shields.io/badge/go-1.21-9cf.svg)](https://golang.org/dl/)
    19[![platforms](https://img.shields.io/badge/platforms-linux|windows|macos-inactive.svg)]()
    20[![Docker Image](https://img.shields.io/docker/v/cuelang/cue?sort=semver&label=docker)](https://hub.docker.com/r/cuelang/cue)
    21
    22# The CUE Data Constraint Language
    23
    24_Configure, Unify, Execute_
    25
    26CUE is an open source data constraint language which aims
    27to simplify tasks involving defining and using data.
    28
    29It is a superset of JSON,
    30allowing users familiar with JSON to get started quickly.
    31
    32
    33### What is it for?
    34
    35You can use CUE to
    36
    37- define a detailed validation schema for your data (manually or automatically from data)
    38- reduce boilerplate in your data (manually or automatically from schema)
    39- extract a schema from code
    40- generate type definitions and validation code
    41- merge JSON in a principled way
    42- define and run declarative scripts
    43
    44
    45### How?
    46
    47CUE merges the notion of schema and data.
    48The same CUE definition can simultaneously be used for validating data
    49and act as a template to reduce boilerplate.
    50Schema definition is enriched with fine-grained value definitions
    51and default values.
    52At the same time,
    53data can be simplified by removing values implied by such detailed definitions.
    54The merging of these two concepts enables
    55many tasks to be handled in a principled way.
    56
    57Constraints provide a simple and well-defined, yet powerful, alternative
    58to inheritance,
    59a common source of complexity with configuration languages.
    60
    61
    62### CUE Scripting
    63
    64The CUE scripting layer defines declarative scripting, expressed in CUE,
    65on top of data.
    66This solves three problems:
    67working around the closedness of CUE definitions (we say CUE is hermetic),
    68providing an easy way to share common scripts and workflows for using data,
    69and giving CUE the knowledge of how data is used to optimize validation.
    70
    71There are many tools that interpret data or use a specialized language for
    72a specific domain (Kustomize, Ksonnet).
    73This solves dealing with data on one level, but the problem it solves may repeat
    74itself at a higher level when integrating other systems in a workflow.
    75CUE scripting is generic and allows users to define any workflow.
    76
    77
    78### Tooling
    79
    80CUE is designed for automation.
    81Some aspects of this are:
    82
    83- convert existing YAML and JSON
    84- automatically simplify configurations
    85- rich APIs designed for automated tooling
    86- formatter
    87- arbitrary-precision arithmetic
    88- generate CUE templates from source code
    89- generate source code from CUE definitions (TODO)
    90
    91
    92### Download and Install
    93
    94#### Release builds
    95
    96[Download](https://github.com/cue-lang/cue/releases) the latest release from GitHub.
    97
    98#### Run with Docker
    99
   100The release binaries are published as a Docker image described by our [Dockerfile](Dockerfile):
   101
   102	docker run cuelang/cue version
   103
   104#### Install using Homebrew
   105
   106Using [Homebrew](https://brew.sh), you can install using the CUE Homebrew tap:
   107
   108	brew install cue-lang/tap/cue
   109
   110#### Install from Source
   111
   112You need Go 1.21 or later to build CUE from source; follow the instructions at https://go.dev/doc/install.
   113
   114To download and install the `cue` command line tool, run:
   115
   116	go install cuelang.org/go/cmd/cue@latest
   117
   118### Learning CUE
   119
   120The fastest way to learn the basics is to follow the
   121[tutorial on basic language constructs](./doc/tutorial/basics/Readme.md).
   122
   123A more elaborate tutorial demonstrating how to convert and restructure
   124an existing set of Kubernetes configurations is available in
   125[written form](./doc/tutorial/kubernetes/README.md).
   126
   127### References
   128
   129- [Language Specification](./doc/ref/spec.md): official CUE Language specification.
   130
   131- [API](https://pkg.go.dev/cuelang.org/go/cue): the API on pkg.go.dev
   132
   133- [Builtin packages](https://pkg.go.dev/cuelang.org/go/pkg): builtins available from CUE programs
   134
   135- [`cue` Command line reference](./doc/cmd/cue.md): the `cue` command
   136
   137### Go release support policy
   138
   139As a general rule, we support the two most recent major releases of Go,
   140matching Go's [security policy](https://go.dev/doc/security/policy).
   141For example, if CUE v0.7.0 is released when Go's latest version is 1.21.5,
   142v0.7.x including any following bugfix releases will require Go 1.20 or later.
   143
   144### Contributing
   145
   146To contribute, please read the [Contribution Guide](CONTRIBUTING.md).
   147
   148## Code of Conduct
   149
   150Guidelines for participating in CUE community spaces and a reporting process for
   151handling issues can be found in the [Code of
   152Conduct](https://cuelang.org/docs/contribution_guidelines/conduct).
   153
   154## Contact
   155
   156You can get in touch with the cuelang community in the following ways:
   157
   158- Ask questions via [GitHub Discussions](https://github.com/cue-lang/cue/discussions)
   159- Chat with us on our [Slack workspace](https://join.slack.com/t/cuelang/shared_invite/enQtNzQwODc3NzYzNTA0LTAxNWQwZGU2YWFiOWFiOWQ4MjVjNGQ2ZTNlMmIxODc4MDVjMDg5YmIyOTMyMjQ2MTkzMTU5ZjA1OGE0OGE1NmE).
   160- Subscribe to our [Community Calendar](https://cuelang.org/s/community-calendar) for community calls, demos, office hours, etc
   161
   162---
   163
   164Unless otherwise noted, the CUE source files are distributed
   165under the Apache 2.0 license found in the LICENSE file.
   166

View as plain text