Skip to content
Permalink
Browse files

all: update to new syntax

  • Loading branch information
mpvl committed Feb 10, 2020
1 parent 42fa00d commit ed20e368cb6888a20ff4bba3736b0e8e44094890
@@ -175,7 +175,7 @@ For instance,
could be represented as
```
"a": 3
"b" "c": "foo
"b": "c": "foo
```
All the information of the original JSON file is retained in this
representation.
@@ -212,7 +212,7 @@ jobs: {
one can write

```
jobs <JobName>: acmeMonitoring
jobs: [string]: acmeMonitoring
jobs: {
foo: { /* ... */ }
@@ -688,7 +688,7 @@ One can even say on a single line that a collection of
fields must mix in a template.
For instance,
```
jobs <JobName>: acmeMonitoring
jobs: [string]: acmeMonitoring
```
tells CUE that _all_ jobs in `jobs` must mix in `acmeMonitoring`.
There is no need to repeat this at every node.
@@ -65,7 +65,7 @@ all services in our configuration are of type `v1.Service`.
{{< highlight go >}}
import "k8s.io/api/core/v1"

services <Name>: v1.Service
services: [string]: v1.Service
{{< /highlight >}}

You can download definitions from any Go project like this.
@@ -221,7 +221,7 @@ It does so by lining up the top-level CUE names with Go definitions.
The CUE code can use field tags, similar to those used in Go,
to override the naming.
```go
b, err := Generate("path/to/go/pkg", instance, nil)
b, err := gocode.Generate("path/to/go/pkg", instance, nil)
if err != nil {
// handle error
}
@@ -62,7 +62,7 @@ The builtin `encoding/json.Marshal` generates JSON from within CUE.
{{< highlight none >}}
import "encoding/json"

configMap data "point.json":
configMap: data: "point.json":
json.Marshal({
x: 4.5
y: 2.34
@@ -123,11 +123,11 @@ Dimensions :: {
}

// Validate JSON configurations embedded strings.
configs <_>: json.Validate(Dimensions)
configs: [string]: json.Validate(Dimensions)

configs bed: #"{ "width": 2, "height": 0.1, "depth": 2 }"#
configs table: #"{ "width": "34", "height": 23, "depth": 0.2 }"#
configs painting: #"{ "width": 34, "height": 12, "depht": 0.2 }"#
configs: bed: #"{ "width": 2, "height": 0.1, "depth": 2 }"#
configs: table: #"{ "width": "34", "height": 23, "depth": 0.2 }"#
configs: painting: #"{ "width": 34, "height": 12, "depht": 0.2 }"#
{{< /highlight >}}

{{< highlight none >}}
@@ -34,7 +34,7 @@ Adjusted to CUE:
message | struct | Message fields become CUE fields, whereby names are mapped to lowerCamelCase.
enum | e1 | e2 | ... | Where ex are strings. A separate mapping is
| | generated to obtain the numeric values.
map<K, V> | { <>: V } | All keys are converted to strings.
map<K, V> | { [string]: V } | All keys are converted to strings.
repeated V | [...V] | null is accepted as the empty list [].
bool | bool
string | string
@@ -90,7 +90,7 @@ import "encoding/yaml"
// Phrases defines a schema for a valid phrase.
Phrases :: {
phrases: { <_>: Phrase }
phrases: [string]: Phrase
Phrase :: {
lang: LanguageTag
@@ -140,7 +140,7 @@ The builtin `encoding/yaml.Marshal` generates YAML from within CUE.
{{< highlight none >}}
import "encoding/yaml"
configMap data "point.yaml":
configMap: data: "point.yaml":
yaml.Marshal({
x: 4.5
y: 2.34
@@ -58,8 +58,8 @@ spec: Spec
spec: {
knid: "Homo Sapiens" // error, misspelled field
name first: "Jane"
name last: "Doe"
name: first: "Jane"
name: last: "Doe"
}
```

0 comments on commit ed20e36

Please sign in to comment.
You can’t perform that action at this time.