1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/yaml.md

118 lines
2.2 KiB
Markdown
Raw Normal View History

2020-07-30 16:20:24 -07:00
2020-02-03 16:20:38 -08:00
# jc.parsers.yaml
jc - JSON CLI output utility YAML Parser
Usage:
specify --yaml as the first argument if the piped input is coming from a YAML file
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
Examples:
2020-02-03 21:38:21 -08:00
$ cat istio-mtls-permissive.yaml
apiVersion: "authentication.istio.io/v1alpha1"
kind: "Policy"
metadata:
name: "default"
namespace: "default"
spec:
peers:
- mtls: {}
---
apiVersion: "networking.istio.io/v1alpha3"
kind: "DestinationRule"
metadata:
name: "default"
namespace: "default"
spec:
host: "*.default.svc.cluster.local"
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
$ cat istio-mtls-permissive.yaml | jc --yaml -p
2020-02-03 16:20:38 -08:00
[
2020-02-03 21:38:21 -08:00
{
"apiVersion": "authentication.istio.io/v1alpha1",
"kind": "Policy",
"metadata": {
"name": "default",
"namespace": "default"
2020-02-03 16:20:38 -08:00
},
2020-02-03 21:38:21 -08:00
"spec": {
"peers": [
{
"mtls": {}
}
]
2020-02-03 16:20:38 -08:00
}
2020-02-03 21:38:21 -08:00
},
{
"apiVersion": "networking.istio.io/v1alpha3",
"kind": "DestinationRule",
"metadata": {
"name": "default",
"namespace": "default"
},
"spec": {
"host": "*.default.svc.cluster.local",
"trafficPolicy": {
"tls": {
"mode": "ISTIO_MUTUAL"
}
}
}
}
2020-02-03 16:20:38 -08:00
]
2020-07-30 16:20:24 -07:00
2020-02-03 16:20:38 -08:00
## info
```python
2020-07-30 16:20:24 -07:00
info()
2020-02-03 16:20:38 -08:00
```
2020-07-30 16:20:24 -07:00
2020-02-03 16:20:38 -08:00
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (dictionary) raw structured data to process
Returns:
List of dictionaries. Each dictionary represents a YAML document:
[
{
YAML Document converted to a Dictionary
See https://pypi.org/project/ruamel.yaml for details
}
]
2020-07-30 16:20:24 -07:00
2020-02-03 16:20:38 -08:00
## parse
```python
parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
Returns:
List of dictionaries. Raw or processed structured data.