diff --git a/pkg/yqlib/candidate_node_yaml.go b/pkg/yqlib/candidate_node_yaml.go index 14beb073..03b137a4 100644 --- a/pkg/yqlib/candidate_node_yaml.go +++ b/pkg/yqlib/candidate_node_yaml.go @@ -3,7 +3,7 @@ package yqlib import ( "fmt" - yaml "go.yaml.in/yaml/v3" + yaml "go.yaml.in/yaml/v4" ) func MapYamlStyle(original yaml.Style) Style { diff --git a/pkg/yqlib/decoder_yaml.go b/pkg/yqlib/decoder_yaml.go index 070b1658..5e92b14c 100644 --- a/pkg/yqlib/decoder_yaml.go +++ b/pkg/yqlib/decoder_yaml.go @@ -8,7 +8,7 @@ import ( "regexp" "strings" - yaml "go.yaml.in/yaml/v3" + yaml "go.yaml.in/yaml/v4" ) type yamlDecoder struct { diff --git a/pkg/yqlib/doc/operators/anchor-and-alias-operators.md b/pkg/yqlib/doc/operators/anchor-and-alias-operators.md index cfdc8579..ab5a6572 100644 --- a/pkg/yqlib/doc/operators/anchor-and-alias-operators.md +++ b/pkg/yqlib/doc/operators/anchor-and-alias-operators.md @@ -198,12 +198,6 @@ then yq 'explode(.f)' sample.yml ``` will output -```yaml -f: - a: cat - cat: b -``` - ## Dereference and update a field Use explode with multiply to dereference an object @@ -345,139 +339,3 @@ x: 1 y: 2 ``` -## FIXED: Explode with merge anchors -Set `--yaml-fix-merge-anchor-to-spec=true` to get this correct merge behaviour (flag will default to true in late 2025). -Observe that foobarList.b property is still foobarList_b. - -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 '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: foobarList_b - a: foo_a - thing: foo_thing - c: foobarList_c -foobar: - c: foobar_c - a: foo_a - thing: foobar_thing -``` - -## FIXED: Merge multiple maps -Set `--yaml-fix-merge-anchor-to-spec=true` to get this correct merge behaviour (flag will default to true in late 2025). -Taken from https://yaml.org/type/merge.html. Same values as legacy, but with the correct key order. - -Given a sample.yml file of: -```yaml -- &CENTER - x: 1 - y: 2 -- &LEFT - x: 0 - y: 2 -- &BIG - r: 10 -- &SMALL - r: 1 -- !!merge <<: - - *CENTER - - *BIG -``` -then -```bash -yq '.[4] | explode(.)' sample.yml -``` -will output -```yaml -x: 1 -y: 2 -r: 10 -``` - -## FIXED: Override -Set `--yaml-fix-merge-anchor-to-spec=true` to get this correct merge behaviour (flag will default to true in late 2025). -Taken from https://yaml.org/type/merge.html. Same values as legacy, but with the correct key order. - -Given a sample.yml file of: -```yaml -- &CENTER - x: 1 - y: 2 -- &LEFT - x: 0 - y: 2 -- &BIG - r: 10 -- &SMALL - r: 1 -- !!merge <<: - - *BIG - - *LEFT - - *SMALL - x: 1 -``` -then -```bash -yq '.[4] | explode(.)' sample.yml -``` -will output -```yaml -r: 10 -y: 2 -x: 1 -``` - -## Exploding inline merge anchor -Set `--yaml-fix-merge-anchor-to-spec=true` to get this correct merge behaviour (flag will default to true in late 2025). - - -Given a sample.yml file of: -```yaml -a: - b: &b 42 -!!merge <<: - c: *b -``` -then -```bash -yq 'explode(.) | sort_keys(.)' sample.yml -``` -will output -```yaml -a: - b: 42 -c: 42 -``` - diff --git a/pkg/yqlib/encoder_yaml.go b/pkg/yqlib/encoder_yaml.go index 8c65899f..3b6b92b5 100644 --- a/pkg/yqlib/encoder_yaml.go +++ b/pkg/yqlib/encoder_yaml.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/fatih/color" - "go.yaml.in/yaml/v3" + "go.yaml.in/yaml/v4" ) type yamlEncoder struct { diff --git a/pkg/yqlib/operator_anchors_aliases_test.go b/pkg/yqlib/operator_anchors_aliases_test.go index 4b4832e6..32f7d2ec 100644 --- a/pkg/yqlib/operator_anchors_aliases_test.go +++ b/pkg/yqlib/operator_anchors_aliases_test.go @@ -464,7 +464,7 @@ var anchorOperatorScenarios = []expressionScenario{ }, { skipDoc: true, - document: `{f : {a: &a cat, b: &b {foo: *a}, *a: *b}}`, + document: `{f : {a: &a cat, b: &b {foo: *a}, *a : *b}}`, expression: `explode(.f)`, expected: []string{ "D0, P[], (!!map)::{f: {a: cat, b: {foo: cat}, cat: {foo: cat}}}\n", diff --git a/pkg/yqlib/printer_node_info.go b/pkg/yqlib/printer_node_info.go index cd047aee..0bc8b09a 100644 --- a/pkg/yqlib/printer_node_info.go +++ b/pkg/yqlib/printer_node_info.go @@ -5,7 +5,7 @@ import ( "container/list" "io" - "go.yaml.in/yaml/v3" + "go.yaml.in/yaml/v4" ) type nodeInfoPrinter struct {