2020-11-17 22:44:16 +00:00
|
|
|
Explodes (or dereferences) aliases and anchors.
|
2020-11-22 02:16:54 +00:00
|
|
|
## Explode alias and anchor
|
2020-11-17 22:44:16 +00:00
|
|
|
Given a sample.yml file of:
|
|
|
|
```yaml
|
|
|
|
f:
|
|
|
|
a: &a cat
|
|
|
|
b: *a
|
|
|
|
```
|
|
|
|
then
|
|
|
|
```bash
|
|
|
|
yq eval 'explode(.f)' sample.yml
|
|
|
|
```
|
|
|
|
will output
|
|
|
|
```yaml
|
2020-11-19 05:45:05 +00:00
|
|
|
f:
|
|
|
|
a: cat
|
|
|
|
b: cat
|
2020-11-17 22:44:16 +00:00
|
|
|
```
|
|
|
|
|
2020-11-22 02:16:54 +00:00
|
|
|
## Explode with no aliases or anchors
|
2020-11-17 22:44:16 +00:00
|
|
|
Given a sample.yml file of:
|
|
|
|
```yaml
|
|
|
|
a: mike
|
|
|
|
```
|
|
|
|
then
|
|
|
|
```bash
|
|
|
|
yq eval 'explode(.a)' sample.yml
|
|
|
|
```
|
|
|
|
will output
|
|
|
|
```yaml
|
|
|
|
a: mike
|
|
|
|
```
|
|
|
|
|
2020-11-22 02:16:54 +00:00
|
|
|
## Explode with alias keys
|
2020-11-17 22:44:16 +00:00
|
|
|
Given a sample.yml file of:
|
|
|
|
```yaml
|
|
|
|
f:
|
|
|
|
a: &a cat
|
|
|
|
*a: b
|
|
|
|
```
|
|
|
|
then
|
|
|
|
```bash
|
|
|
|
yq eval 'explode(.f)' sample.yml
|
|
|
|
```
|
|
|
|
will output
|
|
|
|
```yaml
|
2020-11-19 05:45:05 +00:00
|
|
|
f:
|
|
|
|
a: cat
|
|
|
|
cat: b
|
2020-11-17 22:44:16 +00:00
|
|
|
```
|
|
|
|
|
2020-11-22 02:16:54 +00:00
|
|
|
## Explode with merge anchors
|
2020-11-17 22:44:16 +00:00
|
|
|
Given a sample.yml file of:
|
|
|
|
```yaml
|
|
|
|
foo: &foo
|
|
|
|
a: foo_a
|
|
|
|
thing: foo_thing
|
|
|
|
c: foo_c
|
|
|
|
bar: &bar
|
|
|
|
b: bar_b
|
|
|
|
thing: bar_thing
|
|
|
|
c: bar_c
|
|
|
|
foobarList:
|
|
|
|
b: foobarList_b
|
|
|
|
!!merge <<:
|
|
|
|
- *foo
|
|
|
|
- *bar
|
|
|
|
c: foobarList_c
|
|
|
|
foobar:
|
|
|
|
c: foobar_c
|
|
|
|
!!merge <<: *foo
|
|
|
|
thing: foobar_thing
|
|
|
|
```
|
|
|
|
then
|
|
|
|
```bash
|
|
|
|
yq eval 'explode(.)' sample.yml
|
|
|
|
```
|
|
|
|
will output
|
|
|
|
```yaml
|
|
|
|
foo:
|
|
|
|
a: foo_a
|
|
|
|
thing: foo_thing
|
|
|
|
c: foo_c
|
|
|
|
bar:
|
|
|
|
b: bar_b
|
|
|
|
thing: bar_thing
|
|
|
|
c: bar_c
|
|
|
|
foobarList:
|
|
|
|
b: bar_b
|
|
|
|
a: foo_a
|
|
|
|
thing: bar_thing
|
|
|
|
c: foobarList_c
|
|
|
|
foobar:
|
|
|
|
c: foo_c
|
|
|
|
a: foo_a
|
|
|
|
thing: foobar_thing
|
|
|
|
```
|
|
|
|
|