kubectl/pkg/cmd/util
Tim Hockin 02042ef887 Add KYAML support to kubectl
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",
}
```

Kubernetes-commit: 2cb955d8ccae30167b9610bfe51c2f86e83a1958
2025-07-14 09:24:18 -07:00
..
editor kubectl: remove subresource restrictions from all commands 2024-10-31 16:00:52 -07:00
podcmd cmd/kubectl: make 'kubectl logs' default to the first container when default container cannot be determined or found by annotations (#105964) 2022-01-07 09:40:41 +08:00
sanity Move pkg/kubectl/cmd/util and subdirs to staging 2019-07-28 21:29:36 -07:00
caching_verifier.go kubectl: Cache Verifier.HasSupport calls 2025-05-23 21:58:05 +02:00
caching_verifier_test.go kubectl: Cache Verifier.HasSupport calls 2025-05-23 21:58:05 +02:00
env_file.go Remove dependency of generators from create configmap 2021-01-10 18:47:32 -05:00
env_file_test.go Replace os.Setenv with testing.T.Setenv in tests 2023-04-15 10:09:47 -05:00
factory.go OpenAPIResourcesGetter allows lazy-loading OpenAPI V2 2023-03-13 20:28:40 -07:00
factory_client_access.go kubectl: Cache Verifier.HasSupport calls 2025-05-23 21:58:05 +02:00
helpers.go Add KYAML support to kubectl 2025-07-14 09:24:18 -07:00
helpers_test.go Negative index regression test for json-patch (#122625) 2024-01-18 09:58:32 +00:00
kubectl_match_version.go remove pkg/version and some of redundant copies of it 2019-09-10 14:42:55 -07:00
override_options.go Add --override-type flag to kubectl run and kubectl expose to allow the choice of using a JSON Patch or Strategic Merge Patch to apply the override to the generated output. 2021-11-05 07:10:47 -04:00
printing.go Move pkg/kubectl/cmd/util and subdirs to staging 2019-07-28 21:29:36 -07:00