Skip to content

Commit a932007

Browse files
committed
Add KYAML support
KYAML is a strict subset of YAML, which is sort of halfway between YAML and JSON. It has the following properties: * Does not depend on whitespace (easier to text-patch and template). * Always quotes value strings (no ambiguity aroud things like "no"). * Allows quoted keys, but does not require them, and only quotes them if they are not obviously safe (e.g. "no" would always be quoted). * Always uses {} for structs and maps (no more obscure errors about mapping values). * Always uses [] for lists (no more trying to figure out if a dash changes the meaning). * When printing, it includes a header which makes it clear this is YAML and not ill-formed JSON. * Allows trailing commas * Allows comments, * Tries to economize on vertical space by "cuddling" some kinds of brackets together. * Retains comments. Examples: A struct: ```yaml metadata: { creationTimestamp: "2024-12-11T00:10:11Z", labels: { app: "hostnames", }, name: "hostnames", namespace: "default", resourceVersion: "15231643", uid: "f64dbcba-9c58-40b0-bbe7-70495efb5202", } ``` A list of primitves: ```yaml ipFamilies: [ "IPv4", "IPv6", ] ``` A list of structs: ```yaml ports: [{ port: 80, protocol: "TCP", targetPort: 80, }, { port: 443, protocol: "TCP", targetPort: 443, }] ``` A multi-document stream: ```yaml --- { foo: "bar", } --- { qux: "zrb", } ```
1 parent 0f318dc commit a932007

File tree

5 files changed

+2777
-2
lines changed

5 files changed

+2777
-2
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ require (
66
github.com/google/go-cmp v0.5.9
77
go.yaml.in/yaml/v2 v2.4.2
88
go.yaml.in/yaml/v3 v3.0.3
9+
sigs.k8s.io/randfill v1.0.0
910
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
44
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
55
go.yaml.in/yaml/v3 v3.0.3 h1:bXOww4E/J3f66rav3pX3m8w6jDE4knZjGOw8b5Y6iNE=
66
go.yaml.in/yaml/v3 v3.0.3/go.mod h1:tBHosrYAkRZjRAOREWbDnBXUf08JOwYq++0QNwQiWzI=
7-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
8-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
7+
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
8+
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=

0 commit comments

Comments
 (0)