mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22:38:04 +00:00
Minor typos (#1595)
* Remove extra backtick * Reword explanation of update * Reword explanation of relative update * Change "remaple" to "remain" * Change "clovver" to "clobber" * Reword explanation of update for comment operators * Reword explanation of relative update for comment operators * Change "array" to "expression" * Change "the golangs" to "Golang's" * Change "golangs" to "Golang's" * Change "can durations" to "can add durations" * Change "array scalars" to "arrays" * Change "beit" to "be it" * Fix typo in `eval` tip * Fix typo in header for `has` operation * Add space before pipe in `line` operator example * Fix typos in explanation of deep array merges * Change "is now used" to "is now used." * Change "object," to "object." * Changes "indexes" to "indices" * Remove extraneous copied text from `..` article * Reword explanation of `...` operator * Change "your are" to "you are" * Add link to `string` operator docs in `select` article * Change "is a" to "parameter specifies" in `string` operators article * Change "new line" to "newline" * Change "golang regex" to "Golang's regex" * Change "golang" to "Golang" * Add period * Remove comma in `subtract` article * Remove duplicate number subtraction example * Remove comma in `traverse` operator article * Clarify use of brackets when `read`ing with special characters
This commit is contained in:
parent
a6f0495b1f
commit
fa6fac1a76
@ -1,6 +1,6 @@
|
|||||||
# Development
|
# Development
|
||||||
|
|
||||||
1. Install (golang)[https://golang.org/]
|
1. Install (Golang)[https://golang.org/]
|
||||||
1. Run `scripts/devtools.sh` to install the required devtools
|
1. Run `scripts/devtools.sh` to install the required devtools
|
||||||
2. Run `make [local] vendor` to install the vendor dependencies
|
2. Run `make [local] vendor` to install the vendor dependencies
|
||||||
2. Run `make [local] test` to ensure you can run the existing tests
|
2. Run `make [local] test` to ensure you can run the existing tests
|
||||||
|
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -103,7 +103,7 @@ yq (4.16.2) focal; urgency=medium
|
|||||||
* Improved extract-checksum.sh
|
* Improved extract-checksum.sh
|
||||||
* Bump github.com/spf13/cobra from 1.2.1 to 1.3.0 (#1039)
|
* Bump github.com/spf13/cobra from 1.2.1 to 1.3.0 (#1039)
|
||||||
* enable more linters (#1043)
|
* enable more linters (#1043)
|
||||||
* Bump golang compiler #1037
|
* Bump Golang compiler #1037
|
||||||
|
|
||||||
-- Roberto Mier Escandon <rmescandon@gmail.com> Tue, 21 Dec 2021 09:41:44 +0000
|
-- Roberto Mier Escandon <rmescandon@gmail.com> Tue, 21 Dec 2021 09:41:44 +0000
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ foobar:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Dereference and update a field
|
## Dereference and update a field
|
||||||
`Use explode with multiply to dereference an object
|
Use explode with multiply to dereference an object
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
This operator is used to update node values. It can be used in either the:
|
This operator is used to update node values. It can be used in either the:
|
||||||
|
|
||||||
### plain form: `=`
|
### plain form: `=`
|
||||||
Which will assign the LHS node values to the RHS node values. The RHS expression is run against the matching nodes in the pipeline.
|
Which will set the LHS node values equal to the RHS node values. The RHS expression is run against the matching nodes in the pipeline.
|
||||||
|
|
||||||
### relative form: `|=`
|
### relative form: `|=`
|
||||||
This will do a similar thing to the plain form, however, the RHS expression is run against _the LHS nodes_. This is useful for updating values based on old values, e.g. increment.
|
This will do a similar thing to the plain form, but the RHS expression is run with _each LHS node as context_. This is useful for updating values based on old values, e.g. increment.
|
||||||
|
|
||||||
|
|
||||||
### Flags
|
### Flags
|
||||||
@ -203,7 +203,7 @@ a:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Update node value that has an anchor
|
## Update node value that has an anchor
|
||||||
Anchor will remaple
|
Anchor will remain
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
@ -250,7 +250,7 @@ a: !cat woof
|
|||||||
b: !dog woof
|
b: !dog woof
|
||||||
```
|
```
|
||||||
|
|
||||||
## Custom types: clovver
|
## Custom types: clobber
|
||||||
Use the `c` option to clobber custom tags
|
Use the `c` option to clobber custom tags
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
|
@ -5,10 +5,10 @@ Use these comment operators to set or retrieve comments. Note that line comments
|
|||||||
Like the `=` and `|=` assign operators, the same syntax applies when updating comments:
|
Like the `=` and `|=` assign operators, the same syntax applies when updating comments:
|
||||||
|
|
||||||
### plain form: `=`
|
### plain form: `=`
|
||||||
This will assign the LHS nodes comments to the expression on the RHS. The RHS is run against the matching nodes in the pipeline
|
This will set the LHS nodes' comments equal to the expression on the RHS. The RHS is run against the matching nodes in the pipeline
|
||||||
|
|
||||||
### relative form: `|=`
|
### relative form: `|=`
|
||||||
Similar to the plain form, however the RHS evaluates against each matching LHS node! This is useful if you want to set the comments as a relative expression of the node, for instance its value or path.
|
This is similar to the plain form, but it evaluates the RHS with _each matching LHS node as context_. This is useful if you want to set the comments as a relative expression of the node, for instance its value or path.
|
||||||
|
|
||||||
## Set line comment
|
## Set line comment
|
||||||
Set the comment on the key node for more reliability (see below).
|
Set the comment on the key node for more reliability (see below).
|
||||||
|
@ -4,7 +4,7 @@ This returns `true` if the context contains the passed in parameter, and false o
|
|||||||
|
|
||||||
{% hint style="warning" %}
|
{% hint style="warning" %}
|
||||||
|
|
||||||
_Note_ that, just like jq, when checking if an array of strings `contains` another, this will use `contains` and _not_ equals to check each string. This means an array like `contains(["cat"])` will return true for an array `["cats"]`.
|
_Note_ that, just like jq, when checking if an array of strings `contains` another, this will use `contains` and _not_ equals to check each string. This means an expression like `contains(["cat"])` will return true for an array `["cats"]`.
|
||||||
|
|
||||||
See the "Array has a subset array" example below on how to check for a subset.
|
See the "Array has a subset array" example below on how to check for a subset.
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
Various operators for parsing and manipulating dates.
|
Various operators for parsing and manipulating dates.
|
||||||
|
|
||||||
## Date time formattings
|
## Date time formattings
|
||||||
This uses the golangs built in time library for parsing and formatting date times.
|
This uses Golang's built in time library for parsing and formatting date times.
|
||||||
|
|
||||||
When not specified, the RFC3339 standard is assumed `2006-01-02T15:04:05Z07:00` for parsing.
|
When not specified, the RFC3339 standard is assumed `2006-01-02T15:04:05Z07:00` for parsing.
|
||||||
|
|
||||||
@ -17,13 +17,13 @@ See the [library docs](https://pkg.go.dev/time#pkg-constants) for examples of fo
|
|||||||
|
|
||||||
|
|
||||||
## Timezones
|
## Timezones
|
||||||
This uses golangs built in LoadLocation function to parse timezones strings. See the [library docs](https://pkg.go.dev/time#LoadLocation) for more details.
|
This uses Golang's built in LoadLocation function to parse timezones strings. See the [library docs](https://pkg.go.dev/time#LoadLocation) for more details.
|
||||||
|
|
||||||
|
|
||||||
## Durations
|
## Durations
|
||||||
Durations are parsed using golangs built in [ParseDuration](https://pkg.go.dev/time#ParseDuration) function.
|
Durations are parsed using Golang's built in [ParseDuration](https://pkg.go.dev/time#ParseDuration) function.
|
||||||
|
|
||||||
You can durations to time using the `+` operator.
|
You can add durations to time using the `+` operator.
|
||||||
|
|
||||||
## Format: from standard RFC3339 format
|
## Format: from standard RFC3339 format
|
||||||
Providing a single parameter assumes a standard RFC3339 datetime format. If the target format is not a valid yaml datetime format, the result will be a string tagged node.
|
Providing a single parameter assumes a standard RFC3339 datetime format. If the target format is not a valid yaml datetime format, the result will be a string tagged node.
|
||||||
|
@ -309,7 +309,7 @@ cat,"thing1,thing2",true,3.40
|
|||||||
dog,thing3,false,12
|
dog,thing3,false,12
|
||||||
```
|
```
|
||||||
|
|
||||||
## Encode array of array scalars as tsv string
|
## Encode array of arrays as tsv string
|
||||||
Scalars are strings, numbers and booleans.
|
Scalars are strings, numbers and booleans.
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
|
@ -67,7 +67,8 @@ a: 1
|
|||||||
b: 2
|
b: 2
|
||||||
```
|
```
|
||||||
|
|
||||||
## from_entries with numeric key indexes
|
## from_entries with numeric key indices
|
||||||
|
|
||||||
from_entries always creates a map, even for numeric keys
|
from_entries always creates a map, even for numeric keys
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
Use `eval` to dynamically process an expression - for instance from an environment variable.
|
Use `eval` to dynamically process an expression - for instance from an environment variable.
|
||||||
|
|
||||||
`eval` takes a single argument, and evaluates that as a `yq` expression. Any valid expression can be used, beit a path `.a.b.c | select(. == "cat")`, or an update `.a.b.c = "gogo"`.
|
`eval` takes a single argument, and evaluates that as a `yq` expression. Any valid expression can be used, be it a path `.a.b.c | select(. == "cat")`, or an update `.a.b.c = "gogo"`.
|
||||||
|
|
||||||
Tip: This can be useful way parameterise complex scripts.
|
Tip: This can be a useful way to parameterise complex scripts.
|
||||||
|
|
||||||
## Dynamically evaluate a path
|
## Dynamically evaluate a path
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Has
|
# Has
|
||||||
|
|
||||||
This is operation that returns true if the key exists in a map (or index in an array), false otherwise.
|
This operation returns true if the key exists in a map (or index in an array), false otherwise.
|
||||||
|
|
||||||
## Has map key
|
## Has map key
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
This operator is used to update node values. It can be used in either the:
|
This operator is used to update node values. It can be used in either the:
|
||||||
|
|
||||||
### plain form: `=`
|
### plain form: `=`
|
||||||
Which will assign the LHS node values to the RHS node values. The RHS expression is run against the matching nodes in the pipeline.
|
Which will set the LHS node values equal to the RHS node values. The RHS expression is run against the matching nodes in the pipeline.
|
||||||
|
|
||||||
### relative form: `|=`
|
### relative form: `|=`
|
||||||
This will do a similar thing to the plain form, however, the RHS expression is run against _the LHS nodes_. This is useful for updating values based on old values, e.g. increment.
|
This will do a similar thing to the plain form, but the RHS expression is run with _each LHS node as context_. This is useful for updating values based on old values, e.g. increment.
|
||||||
|
|
||||||
|
|
||||||
### Flags
|
### Flags
|
||||||
|
@ -5,7 +5,7 @@ Use these comment operators to set or retrieve comments. Note that line comments
|
|||||||
Like the `=` and `|=` assign operators, the same syntax applies when updating comments:
|
Like the `=` and `|=` assign operators, the same syntax applies when updating comments:
|
||||||
|
|
||||||
### plain form: `=`
|
### plain form: `=`
|
||||||
This will assign the LHS nodes comments to the expression on the RHS. The RHS is run against the matching nodes in the pipeline
|
This will set the LHS nodes' comments equal to the expression on the RHS. The RHS is run against the matching nodes in the pipeline
|
||||||
|
|
||||||
### relative form: `|=`
|
### relative form: `|=`
|
||||||
Similar to the plain form, however the RHS evaluates against each matching LHS node! This is useful if you want to set the comments as a relative expression of the node, for instance its value or path.
|
This is similar to the plain form, but it evaluates the RHS with _each matching LHS node as context_. This is useful if you want to set the comments as a relative expression of the node, for instance its value or path.
|
||||||
|
@ -4,7 +4,7 @@ This returns `true` if the context contains the passed in parameter, and false o
|
|||||||
|
|
||||||
{% hint style="warning" %}
|
{% hint style="warning" %}
|
||||||
|
|
||||||
_Note_ that, just like jq, when checking if an array of strings `contains` another, this will use `contains` and _not_ equals to check each string. This means an array like `contains(["cat"])` will return true for an array `["cats"]`.
|
_Note_ that, just like jq, when checking if an array of strings `contains` another, this will use `contains` and _not_ equals to check each string. This means an expression like `contains(["cat"])` will return true for an array `["cats"]`.
|
||||||
|
|
||||||
See the "Array has a subset array" example below on how to check for a subset.
|
See the "Array has a subset array" example below on how to check for a subset.
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
Various operators for parsing and manipulating dates.
|
Various operators for parsing and manipulating dates.
|
||||||
|
|
||||||
## Date time formattings
|
## Date time formattings
|
||||||
This uses the golangs built in time library for parsing and formatting date times.
|
This uses Golang's built in time library for parsing and formatting date times.
|
||||||
|
|
||||||
When not specified, the RFC3339 standard is assumed `2006-01-02T15:04:05Z07:00` for parsing.
|
When not specified, the RFC3339 standard is assumed `2006-01-02T15:04:05Z07:00` for parsing.
|
||||||
|
|
||||||
@ -17,10 +17,10 @@ See the [library docs](https://pkg.go.dev/time#pkg-constants) for examples of fo
|
|||||||
|
|
||||||
|
|
||||||
## Timezones
|
## Timezones
|
||||||
This uses golangs built in LoadLocation function to parse timezones strings. See the [library docs](https://pkg.go.dev/time#LoadLocation) for more details.
|
This uses Golang's built in LoadLocation function to parse timezones strings. See the [library docs](https://pkg.go.dev/time#LoadLocation) for more details.
|
||||||
|
|
||||||
|
|
||||||
## Durations
|
## Durations
|
||||||
Durations are parsed using golangs built in [ParseDuration](https://pkg.go.dev/time#ParseDuration) function.
|
Durations are parsed using Golang's built in [ParseDuration](https://pkg.go.dev/time#ParseDuration) function.
|
||||||
|
|
||||||
You can durations to time using the `+` operator.
|
You can add durations to time using the `+` operator.
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
Use `eval` to dynamically process an expression - for instance from an environment variable.
|
Use `eval` to dynamically process an expression - for instance from an environment variable.
|
||||||
|
|
||||||
`eval` takes a single argument, and evaluates that as a `yq` expression. Any valid expression can be used, beit a path `.a.b.c | select(. == "cat")`, or an update `.a.b.c = "gogo"`.
|
`eval` takes a single argument, and evaluates that as a `yq` expression. Any valid expression can be used, be it a path `.a.b.c | select(. == "cat")`, or an update `.a.b.c = "gogo"`.
|
||||||
|
|
||||||
Tip: This can be useful way parameterise complex scripts.
|
Tip: This can be a useful way to parameterise complex scripts.
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# Has
|
# Has
|
||||||
|
|
||||||
This is operation that returns true if the key exists in a map (or index in an array), false otherwise.
|
This operation returns true if the key exists in a map (or index in an array), false otherwise.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Recursive Descent (Glob)
|
# Recursive Descent (Glob)
|
||||||
|
|
||||||
This operator recursively matches (or globs) all children nodes given of a particular element, including that node itself. This is most often used to apply a filter recursively against all matches. It can be used in either the
|
This operator recursively matches (or globs) all children nodes given of a particular element, including that node itself. This is most often used to apply a filter recursively against all matches.
|
||||||
|
|
||||||
## match values form `..`
|
## match values form `..`
|
||||||
This will, like the `jq` equivalent, recursively match all _value_ nodes. Use it to find/manipulate particular values.
|
This will, like the `jq` equivalent, recursively match all _value_ nodes. Use it to find/manipulate particular values.
|
||||||
@ -12,7 +12,7 @@ yq '.. style= "flow"' file.yaml
|
|||||||
```
|
```
|
||||||
|
|
||||||
## match values and map keys form `...`
|
## match values and map keys form `...`
|
||||||
The also includes map keys in the results set. This is particularly useful in YAML as unlike JSON, map keys can have their own styling, tags and use anchors and aliases.
|
The also includes map keys in the results set. This is particularly useful in YAML as unlike JSON, map keys can have their own styling and tags and also use anchors and aliases.
|
||||||
|
|
||||||
For instance to set the `style` of all nodes in a yaml doc, including the map keys:
|
For instance to set the `style` of all nodes in a yaml doc, including the map keys:
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ yq -i -P 'sort_keys(..)' file2.yml
|
|||||||
diff file1.yml file2.yml
|
diff file1.yml file2.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that `yq` does not yet consider anchors when sorting by keys - this may result in invalid yaml documents if your are using merge anchors.
|
Note that `yq` does not yet consider anchors when sorting by keys - this may result in invalid yaml documents if you are using merge anchors.
|
||||||
|
|
||||||
For more advanced sorting, using `to_entries` to convert the map to an array, then sort/process the array as you like (e.g. using `sort_by`) and convert back to a map using `from_entries`.
|
For more advanced sorting, using `to_entries` to convert the map to an array, then sort/process the array as you like (e.g. using `sort_by`) and convert back to a map using `from_entries`.
|
||||||
See [here](https://mikefarah.gitbook.io/yq/operators/entries#custom-sort-map-keys) for an example.
|
See [here](https://mikefarah.gitbook.io/yq/operators/entries#custom-sort-map-keys) for an example.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# String Operators
|
# String Operators
|
||||||
|
|
||||||
## RegEx
|
## RegEx
|
||||||
This uses golangs native regex functions under the hood - See their [docs](https://github.com/google/re2/wiki/Syntax) for the supported syntax.
|
This uses Golang's native regex functions under the hood - See their [docs](https://github.com/google/re2/wiki/Syntax) for the supported syntax.
|
||||||
|
|
||||||
Case insensitive tip: prefix the regex with `(?i)` - e.g. `test("(?i)cats)"`.
|
Case insensitive tip: prefix the regex with `(?i)` - e.g. `test("(?i)cats)"`.
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ Capture returns named RegEx capture groups in a map. Can be more convenient than
|
|||||||
Returns true if the string matches the RegEx, false otherwise.
|
Returns true if the string matches the RegEx, false otherwise.
|
||||||
|
|
||||||
## sub(regEx, replacement)
|
## sub(regEx, replacement)
|
||||||
Substitutes matched substrings. The first parameter is the regEx to match substrings within the original string. The second is a what to replace those matches with. This can refer to capture groups from the first RegEx.
|
Substitutes matched substrings. The first parameter is the regEx to match substrings within the original string. The second parameter specifies what to replace those matches with. This can refer to capture groups from the first RegEx.
|
||||||
|
|
||||||
## String blocks, bash and newlines
|
## String blocks, bash and newlines
|
||||||
Bash is notorious for chomping on precious trailing newline characters, making it tricky to set strings with newlines properly. In particular, the `$( exp )` _will trim trailing newlines_.
|
Bash is notorious for chomping on precious trailing newline characters, making it tricky to set strings with newlines properly. In particular, the `$( exp )` _will trim trailing newlines_.
|
||||||
@ -27,7 +27,7 @@ a: |
|
|||||||
cat
|
cat
|
||||||
```
|
```
|
||||||
|
|
||||||
Using `$( exp )` wont work, as it will trim the trailing new line.
|
Using `$( exp )` wont work, as it will trim the trailing newline.
|
||||||
|
|
||||||
```
|
```
|
||||||
m=$(echo "cat\n") yq -n '.a = strenv(m)'
|
m=$(echo "cat\n") yq -n '.a = strenv(m)'
|
||||||
@ -49,7 +49,7 @@ a: |
|
|||||||
cat
|
cat
|
||||||
```
|
```
|
||||||
|
|
||||||
Similarly, if you're trying to set the content from a file, and want a trailing new line:
|
Similarly, if you're trying to set the content from a file, and want a trailing newline:
|
||||||
|
|
||||||
```
|
```
|
||||||
IFS= read -rd '' output < <(cat my_file)
|
IFS= read -rd '' output < <(cat my_file)
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# Subtract
|
# Subtract
|
||||||
|
|
||||||
You can use subtract to subtract numbers, as well as removing elements from an array.
|
You can use subtract to subtract numbers as well as remove elements from an array.
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# Traverse (Read)
|
# Traverse (Read)
|
||||||
|
|
||||||
This is the simplest (and perhaps most used) operator, it is used to navigate deeply into yaml structures.
|
This is the simplest (and perhaps most used) operator. It is used to navigate deeply into yaml structures.
|
||||||
|
@ -29,7 +29,7 @@ b:
|
|||||||
```
|
```
|
||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
yq '.b | key| line' sample.yml
|
yq '.b | key | line' sample.yml
|
||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -250,7 +250,7 @@ thing:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Merge, deeply merging arrays
|
## Merge, deeply merging arrays
|
||||||
Merging arrays deeply means arrays are merge like objects, with indexes as their key. In this case, we merge the first item in the array, and do nothing with the second.
|
Merging arrays deeply means arrays are merged like objects, with indices as their key. In this case, we merge the first item in the array and do nothing with the second.
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
@ -477,7 +477,7 @@ b: !goat
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Custom types: clobber tags
|
## Custom types: clobber tags
|
||||||
Use the `c` option to clobber custom tags. Note that the second tag is now used
|
Use the `c` option to clobber custom tags. Note that the second tag is now used.
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -123,7 +123,7 @@ a:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Set path to prune deep paths
|
## Set path to prune deep paths
|
||||||
Like pick but recursive. This uses `ireduce` to deeply set the selected paths into an empty object,
|
Like pick but recursive. This uses `ireduce` to deeply set the selected paths into an empty object.
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -27,7 +27,7 @@ myMap:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Pick indices from array
|
## Pick indices from array
|
||||||
Note that the order of the indexes matches the pick order and non existent indexes are skipped.
|
Note that the order of the indices matches the pick order and non existent indices are skipped.
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Recursive Descent (Glob)
|
# Recursive Descent (Glob)
|
||||||
|
|
||||||
This operator recursively matches (or globs) all children nodes given of a particular element, including that node itself. This is most often used to apply a filter recursively against all matches. It can be used in either the
|
This operator recursively matches (or globs) all children nodes given of a particular element, including that node itself. This is most often used to apply a filter recursively against all matches.
|
||||||
|
|
||||||
## match values form `..`
|
## match values form `..`
|
||||||
This will, like the `jq` equivalent, recursively match all _value_ nodes. Use it to find/manipulate particular values.
|
This will, like the `jq` equivalent, recursively match all _value_ nodes. Use it to find/manipulate particular values.
|
||||||
@ -12,7 +12,7 @@ yq '.. style= "flow"' file.yaml
|
|||||||
```
|
```
|
||||||
|
|
||||||
## match values and map keys form `...`
|
## match values and map keys form `...`
|
||||||
The also includes map keys in the results set. This is particularly useful in YAML as unlike JSON, map keys can have their own styling, tags and use anchors and aliases.
|
The also includes map keys in the results set. This is particularly useful in YAML as unlike JSON, map keys can have their own styling and tags and also use anchors and aliases.
|
||||||
|
|
||||||
For instance to set the `style` of all nodes in a yaml doc, including the map keys:
|
For instance to set the `style` of all nodes in a yaml doc, including the map keys:
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ going
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Select elements from array with regular expression
|
## Select elements from array with regular expression
|
||||||
See more regular expression examples under the `string` operator docs.
|
See more regular expression examples under the [`string` operator docs](https://mikefarah.gitbook.io/yq/operators/string-operators).
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -10,7 +10,7 @@ yq -i -P 'sort_keys(..)' file2.yml
|
|||||||
diff file1.yml file2.yml
|
diff file1.yml file2.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that `yq` does not yet consider anchors when sorting by keys - this may result in invalid yaml documents if your are using merge anchors.
|
Note that `yq` does not yet consider anchors when sorting by keys - this may result in invalid yaml documents if you are using merge anchors.
|
||||||
|
|
||||||
For more advanced sorting, using `to_entries` to convert the map to an array, then sort/process the array as you like (e.g. using `sort_by`) and convert back to a map using `from_entries`.
|
For more advanced sorting, using `to_entries` to convert the map to an array, then sort/process the array as you like (e.g. using `sort_by`) and convert back to a map using `from_entries`.
|
||||||
See [here](https://mikefarah.gitbook.io/yq/operators/entries#custom-sort-map-keys) for an example.
|
See [here](https://mikefarah.gitbook.io/yq/operators/entries#custom-sort-map-keys) for an example.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# String Operators
|
# String Operators
|
||||||
|
|
||||||
## RegEx
|
## RegEx
|
||||||
This uses golangs native regex functions under the hood - See their [docs](https://github.com/google/re2/wiki/Syntax) for the supported syntax.
|
This uses Golang's native regex functions under the hood - See their [docs](https://github.com/google/re2/wiki/Syntax) for the supported syntax.
|
||||||
|
|
||||||
Case insensitive tip: prefix the regex with `(?i)` - e.g. `test("(?i)cats)"`.
|
Case insensitive tip: prefix the regex with `(?i)` - e.g. `test("(?i)cats)"`.
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ Capture returns named RegEx capture groups in a map. Can be more convenient than
|
|||||||
Returns true if the string matches the RegEx, false otherwise.
|
Returns true if the string matches the RegEx, false otherwise.
|
||||||
|
|
||||||
## sub(regEx, replacement)
|
## sub(regEx, replacement)
|
||||||
Substitutes matched substrings. The first parameter is the regEx to match substrings within the original string. The second is a what to replace those matches with. This can refer to capture groups from the first RegEx.
|
Substitutes matched substrings. The first parameter is the regEx to match substrings within the original string. The second parameter specifies what to replace those matches with. This can refer to capture groups from the first RegEx.
|
||||||
|
|
||||||
## String blocks, bash and newlines
|
## String blocks, bash and newlines
|
||||||
Bash is notorious for chomping on precious trailing newline characters, making it tricky to set strings with newlines properly. In particular, the `$( exp )` _will trim trailing newlines_.
|
Bash is notorious for chomping on precious trailing newline characters, making it tricky to set strings with newlines properly. In particular, the `$( exp )` _will trim trailing newlines_.
|
||||||
@ -27,7 +27,7 @@ a: |
|
|||||||
cat
|
cat
|
||||||
```
|
```
|
||||||
|
|
||||||
Using `$( exp )` wont work, as it will trim the trailing new line.
|
Using `$( exp )` wont work, as it will trim the trailing newline.
|
||||||
|
|
||||||
```
|
```
|
||||||
m=$(echo "cat\n") yq -n '.a = strenv(m)'
|
m=$(echo "cat\n") yq -n '.a = strenv(m)'
|
||||||
@ -49,7 +49,7 @@ a: |
|
|||||||
cat
|
cat
|
||||||
```
|
```
|
||||||
|
|
||||||
Similarly, if you're trying to set the content from a file, and want a trailing new line:
|
Similarly, if you're trying to set the content from a file, and want a trailing newline:
|
||||||
|
|
||||||
```
|
```
|
||||||
IFS= read -rd '' output < <(cat my_file)
|
IFS= read -rd '' output < <(cat my_file)
|
||||||
@ -298,7 +298,7 @@ false
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Substitute / Replace string
|
## Substitute / Replace string
|
||||||
This uses golang regex, described [here](https://github.com/google/re2/wiki/Syntax)
|
This uses Golang's regex, described [here](https://github.com/google/re2/wiki/Syntax)
|
||||||
Note the use of `|=` to run in context of the current string value.
|
Note the use of `|=` to run in context of the current string value.
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
@ -315,7 +315,7 @@ a: cats are great
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Substitute / Replace string with regex
|
## Substitute / Replace string with regex
|
||||||
This uses golang regex, described [here](https://github.com/google/re2/wiki/Syntax)
|
This uses Golang's regex, described [here](https://github.com/google/re2/wiki/Syntax)
|
||||||
Note the use of `|=` to run in context of the current string value.
|
Note the use of `|=` to run in context of the current string value.
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Subtract
|
# Subtract
|
||||||
|
|
||||||
You can use subtract to subtract numbers, as well as removing elements from an array.
|
You can use subtract to subtract numbers as well as remove elements from an array.
|
||||||
|
|
||||||
## Array subtraction
|
## Array subtraction
|
||||||
Running
|
Running
|
||||||
@ -59,24 +59,6 @@ a: -1.5
|
|||||||
b: 4.5
|
b: 4.5
|
||||||
```
|
```
|
||||||
|
|
||||||
## Number subtraction - float
|
|
||||||
If the lhs or rhs are floats then the expression will be calculated with floats.
|
|
||||||
|
|
||||||
Given a sample.yml file of:
|
|
||||||
```yaml
|
|
||||||
a: 3
|
|
||||||
b: 4.5
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```bash
|
|
||||||
yq '.a = .a - .b' sample.yml
|
|
||||||
```
|
|
||||||
will output
|
|
||||||
```yaml
|
|
||||||
a: -1.5
|
|
||||||
b: 4.5
|
|
||||||
```
|
|
||||||
|
|
||||||
## Number subtraction - int
|
## Number subtraction - int
|
||||||
If both the lhs and rhs are ints then the expression will be calculated with ints.
|
If both the lhs and rhs are ints then the expression will be calculated with ints.
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Traverse (Read)
|
# Traverse (Read)
|
||||||
|
|
||||||
This is the simplest (and perhaps most used) operator, it is used to navigate deeply into yaml structures.
|
This is the simplest (and perhaps most used) operator. It is used to navigate deeply into yaml structures.
|
||||||
|
|
||||||
## Simple map navigation
|
## Simple map navigation
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
@ -51,7 +51,7 @@ will output
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Special characters
|
## Special characters
|
||||||
Use quotes with brackets around path elements with special characters
|
Use quotes with square brackets around path elements with special characters
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
@ -83,7 +83,7 @@ apple
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Keys with spaces
|
## Keys with spaces
|
||||||
Use quotes with brackets around path elements with special characters
|
Use quotes with square brackets around path elements with special characters
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -51,7 +51,7 @@ func (pe *propertiesEncoder) PrintLeadingContent(writer io.Writer, content strin
|
|||||||
|
|
||||||
if errors.Is(errReading, io.EOF) {
|
if errors.Is(errReading, io.EOF) {
|
||||||
if readline != "" {
|
if readline != "" {
|
||||||
// the last comment we read didn't have a new line, put one in
|
// the last comment we read didn't have a newline, put one in
|
||||||
if err := writeString(writer, "\n"); err != nil {
|
if err := writeString(writer, "\n"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func (ye *yamlEncoder) PrintLeadingContent(writer io.Writer, content string) err
|
|||||||
|
|
||||||
if errors.Is(errReading, io.EOF) {
|
if errors.Is(errReading, io.EOF) {
|
||||||
if readline != "" {
|
if readline != "" {
|
||||||
// the last comment we read didn't have a new line, put one in
|
// the last comment we read didn't have a newline, put one in
|
||||||
if err := writeString(writer, "\n"); err != nil {
|
if err := writeString(writer, "\n"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ foobar:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Dereference and update a field",
|
description: "Dereference and update a field",
|
||||||
subdescription: "`Use explode with multiply to dereference an object",
|
subdescription: "Use explode with multiply to dereference an object",
|
||||||
document: simpleArrayRef,
|
document: simpleArrayRef,
|
||||||
expression: `.thingOne |= explode(.) * {"value": false}`,
|
expression: `.thingOne |= explode(.) * {"value": false}`,
|
||||||
expected: []string{expectedUpdatedArrayRef},
|
expected: []string{expectedUpdatedArrayRef},
|
||||||
|
@ -196,7 +196,7 @@ var assignOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Update node value that has an anchor",
|
description: "Update node value that has an anchor",
|
||||||
subdescription: "Anchor will remaple",
|
subdescription: "Anchor will remain",
|
||||||
dontFormatInputForDoc: true,
|
dontFormatInputForDoc: true,
|
||||||
document: `a: &cool cat`,
|
document: `a: &cool cat`,
|
||||||
expression: `.a = "dog"`,
|
expression: `.a = "dog"`,
|
||||||
@ -230,7 +230,7 @@ var assignOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Custom types: clovver",
|
description: "Custom types: clobber",
|
||||||
subdescription: "Use the `c` option to clobber custom tags",
|
subdescription: "Use the `c` option to clobber custom tags",
|
||||||
document: "a: !cat meow\nb: !dog woof",
|
document: "a: !cat meow\nb: !dog woof",
|
||||||
expression: `.a =c .b`,
|
expression: `.a =c .b`,
|
||||||
|
@ -79,13 +79,13 @@ func encodeOperator(d *dataTreeNavigator, context Context, expressionNode *Expre
|
|||||||
|
|
||||||
original := originalList.Front().Value.(*CandidateNode)
|
original := originalList.Front().Value.(*CandidateNode)
|
||||||
originalNode := unwrapDoc(original.Node)
|
originalNode := unwrapDoc(original.Node)
|
||||||
// original block did not have a new line at the end, get rid of this one too
|
// original block did not have a newline at the end, get rid of this one too
|
||||||
if !endWithNewLine.MatchString(originalNode.Value) {
|
if !endWithNewLine.MatchString(originalNode.Value) {
|
||||||
stringValue = chomper.ReplaceAllString(stringValue, "")
|
stringValue = chomper.ReplaceAllString(stringValue, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// dont print a new line when printing json on a single line.
|
// dont print a newline when printing json on a single line.
|
||||||
if (preferences.format == JSONOutputFormat && preferences.indent == 0) ||
|
if (preferences.format == JSONOutputFormat && preferences.indent == 0) ||
|
||||||
preferences.format == CSVOutputFormat ||
|
preferences.format == CSVOutputFormat ||
|
||||||
preferences.format == TSVOutputFormat {
|
preferences.format == TSVOutputFormat {
|
||||||
|
@ -179,7 +179,7 @@ var encoderDecoderOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Encode array of array scalars as tsv string",
|
description: "Encode array of arrays as tsv string",
|
||||||
subdescription: "Scalars are strings, numbers and booleans.",
|
subdescription: "Scalars are strings, numbers and booleans.",
|
||||||
document: `[[cat, "thing1,thing2", true, 3.40], [dog, thing3, false, 12]]`,
|
document: `[[cat, "thing1,thing2", true, 3.40], [dog, thing3, false, 12]]`,
|
||||||
expression: `@tsv`,
|
expression: `@tsv`,
|
||||||
|
@ -36,7 +36,7 @@ var entriesOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "from_entries with numeric key indexes",
|
description: "from_entries with numeric key indices",
|
||||||
subdescription: "from_entries always creates a map, even for numeric keys",
|
subdescription: "from_entries always creates a map, even for numeric keys",
|
||||||
document: `[a,b]`,
|
document: `[a,b]`,
|
||||||
expression: `to_entries | from_entries`,
|
expression: `to_entries | from_entries`,
|
||||||
|
@ -17,7 +17,7 @@ var lineOperatorScenarios = []expressionScenario{
|
|||||||
description: "Returns line of _key_ node",
|
description: "Returns line of _key_ node",
|
||||||
subdescription: "Pipe through the key operator to get the line of the key",
|
subdescription: "Pipe through the key operator to get the line of the key",
|
||||||
document: "a: cat\nb:\n c: cat",
|
document: "a: cat\nb:\n c: cat",
|
||||||
expression: `.b | key| line`,
|
expression: `.b | key | line`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[b], (!!int)::2\n",
|
"D0, P[b], (!!int)::2\n",
|
||||||
},
|
},
|
||||||
|
@ -420,7 +420,7 @@ var multiplyOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Merge, deeply merging arrays",
|
description: "Merge, deeply merging arrays",
|
||||||
subdescription: "Merging arrays deeply means arrays are merge like objects, with indexes as their key. In this case, we merge the first item in the array, and do nothing with the second.",
|
subdescription: "Merging arrays deeply means arrays are merged like objects, with indices as their key. In this case, we merge the first item in the array and do nothing with the second.",
|
||||||
document: `{a: [{name: fred, age: 12}, {name: bob, age: 32}], b: [{name: fred, age: 34}]}`,
|
document: `{a: [{name: fred, age: 12}, {name: bob, age: 32}], b: [{name: fred, age: 34}]}`,
|
||||||
expression: `.a *d .b`,
|
expression: `.a *d .b`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
@ -525,7 +525,7 @@ var multiplyOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Custom types: clobber tags",
|
description: "Custom types: clobber tags",
|
||||||
subdescription: "Use the `c` option to clobber custom tags. Note that the second tag is now used",
|
subdescription: "Use the `c` option to clobber custom tags. Note that the second tag is now used.",
|
||||||
document: "a: !horse {cat: meow}\nb: !goat {dog: woof}",
|
document: "a: !horse {cat: meow}\nb: !goat {dog: woof}",
|
||||||
expression: ".a *=c .b",
|
expression: ".a *=c .b",
|
||||||
expected: []string{
|
expected: []string{
|
||||||
@ -535,7 +535,7 @@ var multiplyOperatorScenarios = []expressionScenario{
|
|||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
description: "Custom types: clobber tags - *=",
|
description: "Custom types: clobber tags - *=",
|
||||||
subdescription: "Use the `c` option to clobber custom tags - on both the `=` and `*` operator. Note that the second tag is now used",
|
subdescription: "Use the `c` option to clobber custom tags - on both the `=` and `*` operator. Note that the second tag is now used.",
|
||||||
document: "a: !horse {cat: meow}\nb: !goat {dog: woof}",
|
document: "a: !horse {cat: meow}\nb: !goat {dog: woof}",
|
||||||
expression: ".a =c .a *c .b",
|
expression: ".a =c .a *c .b",
|
||||||
expected: []string{
|
expected: []string{
|
||||||
@ -545,7 +545,7 @@ var multiplyOperatorScenarios = []expressionScenario{
|
|||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
description: "Custom types: dont clobber tags - *=",
|
description: "Custom types: dont clobber tags - *=",
|
||||||
subdescription: "Use the `c` option to clobber custom tags - on both the `=` and `*` operator. Note that the second tag is now used",
|
subdescription: "Use the `c` option to clobber custom tags - on both the `=` and `*` operator. Note that the second tag is now used.",
|
||||||
document: "a: !horse {cat: meow}\nb: !goat {dog: woof}",
|
document: "a: !horse {cat: meow}\nb: !goat {dog: woof}",
|
||||||
expression: ".a *= .b",
|
expression: ".a *= .b",
|
||||||
expected: []string{
|
expected: []string{
|
||||||
|
@ -90,7 +90,7 @@ var pathOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Set path to prune deep paths",
|
description: "Set path to prune deep paths",
|
||||||
subdescription: "Like pick but recursive. This uses `ireduce` to deeply set the selected paths into an empty object,",
|
subdescription: "Like pick but recursive. This uses `ireduce` to deeply set the selected paths into an empty object.",
|
||||||
document: documentToPrune,
|
document: documentToPrune,
|
||||||
expression: "(.parentB.child2, .parentC.child1) as $i\n ireduce({}; setpath($i | path; $i))",
|
expression: "(.parentB.child2, .parentC.child1) as $i\n ireduce({}; setpath($i | path; $i))",
|
||||||
expected: []string{
|
expected: []string{
|
||||||
|
@ -34,7 +34,7 @@ var pickOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Pick indices from array",
|
description: "Pick indices from array",
|
||||||
subdescription: "Note that the order of the indexes matches the pick order and non existent indexes are skipped.",
|
subdescription: "Note that the order of the indices matches the pick order and non existent indices are skipped.",
|
||||||
document: `[cat, leopard, lion]`,
|
document: `[cat, leopard, lion]`,
|
||||||
expression: `pick([2, 0, 734, -5])`,
|
expression: `pick([2, 0, 734, -5])`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
|
@ -57,7 +57,7 @@ var selectOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Select elements from array with regular expression",
|
description: "Select elements from array with regular expression",
|
||||||
subdescription: "See more regular expression examples under the `string` operator docs.",
|
subdescription: "See more regular expression examples under the [`string` operator docs](https://mikefarah.gitbook.io/yq/operators/string-operators).",
|
||||||
document: `[this_0, not_this, nor_0_this, thisTo_4]`,
|
document: `[this_0, not_this, nor_0_this, thisTo_4]`,
|
||||||
expression: `.[] | select(test("[a-zA-Z]+_[0-9]$"))`,
|
expression: `.[] | select(test("[a-zA-Z]+_[0-9]$"))`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
|
@ -205,7 +205,7 @@ var stringsOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Substitute / Replace string",
|
description: "Substitute / Replace string",
|
||||||
subdescription: "This uses golang regex, described [here](https://github.com/google/re2/wiki/Syntax)\nNote the use of `|=` to run in context of the current string value.",
|
subdescription: "This uses Golang's regex, described [here](https://github.com/google/re2/wiki/Syntax).\nNote the use of `|=` to run in context of the current string value.",
|
||||||
document: `a: dogs are great`,
|
document: `a: dogs are great`,
|
||||||
expression: `.a |= sub("dogs", "cats")`,
|
expression: `.a |= sub("dogs", "cats")`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
@ -214,7 +214,7 @@ var stringsOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Substitute / Replace string with regex",
|
description: "Substitute / Replace string with regex",
|
||||||
subdescription: "This uses golang regex, described [here](https://github.com/google/re2/wiki/Syntax)\nNote the use of `|=` to run in context of the current string value.",
|
subdescription: "This uses Golang's regex, described [here](https://github.com/google/re2/wiki/Syntax).\nNote the use of `|=` to run in context of the current string value.",
|
||||||
document: "a: cat\nb: heat",
|
document: "a: cat\nb: heat",
|
||||||
expression: `.[] |= sub("(a)", "${1}r")`,
|
expression: `.[] |= sub("(a)", "${1}r")`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
|
@ -67,15 +67,6 @@ var subtractOperatorScenarios = []expressionScenario{
|
|||||||
"D0, P[], (doc)::{a: -1.5, b: 4.5}\n",
|
"D0, P[], (doc)::{a: -1.5, b: 4.5}\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
description: "Number subtraction - float",
|
|
||||||
subdescription: "If the lhs or rhs are floats then the expression will be calculated with floats.",
|
|
||||||
document: `{a: 3, b: 4.5}`,
|
|
||||||
expression: `.a = .a - .b`,
|
|
||||||
expected: []string{
|
|
||||||
"D0, P[], (doc)::{a: -1.5, b: 4.5}\n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
description: "Number subtraction - int",
|
description: "Number subtraction - int",
|
||||||
subdescription: "If both the lhs and rhs are ints then the expression will be calculated with ints.",
|
subdescription: "If both the lhs and rhs are ints then the expression will be calculated with ints.",
|
||||||
|
@ -89,7 +89,7 @@ func traverseArrayOperator(d *dataTreeNavigator, context Context, expressionNode
|
|||||||
return Context{}, err
|
return Context{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// rhs is a collect expression that will yield indexes to retrieve of the arrays
|
// rhs is a collect expression that will yield indices to retrieve of the arrays
|
||||||
|
|
||||||
rhs, err := d.GetMatchingNodes(context.ReadOnlyClone(), expressionNode.RHS)
|
rhs, err := d.GetMatchingNodes(context.ReadOnlyClone(), expressionNode.RHS)
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ func traverseMap(context Context, matchingNode *CandidateNode, keyNode *yaml.Nod
|
|||||||
|
|
||||||
func doTraverseMap(newMatches *orderedmap.OrderedMap, candidate *CandidateNode, wantedKey string, prefs traversePreferences, splat bool) error {
|
func doTraverseMap(newMatches *orderedmap.OrderedMap, candidate *CandidateNode, wantedKey string, prefs traversePreferences, splat bool) error {
|
||||||
// value.Content is a concatenated array of key, value,
|
// value.Content is a concatenated array of key, value,
|
||||||
// so keys are in the even indexes, values in odd.
|
// so keys are in the even indices, values in odd.
|
||||||
// merge aliases are defined first, but we only want to traverse them
|
// merge aliases are defined first, but we only want to traverse them
|
||||||
// if we don't find a match directly on this node first.
|
// if we don't find a match directly on this node first.
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ var traversePathOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Special characters",
|
description: "Special characters",
|
||||||
subdescription: "Use quotes with brackets around path elements with special characters",
|
subdescription: "Use quotes with square brackets around path elements with special characters",
|
||||||
document: `{"{}": frog}`,
|
document: `{"{}": frog}`,
|
||||||
expression: `.["{}"]`,
|
expression: `.["{}"]`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
@ -133,7 +133,7 @@ var traversePathOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Keys with spaces",
|
description: "Keys with spaces",
|
||||||
subdescription: "Use quotes with brackets around path elements with special characters",
|
subdescription: "Use quotes with square brackets around path elements with special characters",
|
||||||
document: `{"red rabbit": frog}`,
|
document: `{"red rabbit": frog}`,
|
||||||
expression: `.["red rabbit"]`,
|
expression: `.["red rabbit"]`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
4.30.6:
|
4.30.6:
|
||||||
- Fixed xml comment in array of scalars #1465
|
- Fixed xml comment in array of scalars #1465
|
||||||
- Include blank new lines in leading header preprocessing #1462
|
- Include blank newlines in leading header preprocessing #1462
|
||||||
- Added aarch64 build (#1261)
|
- Added aarch64 build (#1261)
|
||||||
- Bumped dependency versions (#1453)
|
- Bumped dependency versions (#1453)
|
||||||
|
|
||||||
@ -171,7 +171,7 @@
|
|||||||
|
|
||||||
4.24.1:
|
4.24.1:
|
||||||
- Added comparison operators! (#94)
|
- Added comparison operators! (#94)
|
||||||
- Bumped golang to 1.18 (#1153)
|
- Bumped Golang to 1.18 (#1153)
|
||||||
- XML parser no longer runs in strict mode (added new flag to run in strict mode) (#1155)
|
- XML parser no longer runs in strict mode (added new flag to run in strict mode) (#1155)
|
||||||
|
|
||||||
4.23.1:
|
4.23.1:
|
||||||
|
@ -28,7 +28,7 @@ show_help() {
|
|||||||
echo " -h, --help Shows this help"
|
echo " -h, --help Shows this help"
|
||||||
echo " -d, --distribution DISTRO The distribution to use for the changelog generation. If not provided, last changelog entry"
|
echo " -d, --distribution DISTRO The distribution to use for the changelog generation. If not provided, last changelog entry"
|
||||||
echo " distribution is considered"
|
echo " distribution is considered"
|
||||||
echo " --goversion VERSION The version of golang to use. Default to $GOVERSION"
|
echo " --goversion VERSION The version of Golang to use. Default to $GOVERSION"
|
||||||
echo " -k, --sign-key KEYID Sign the package sources with the provided gpg key id (long format). When not provided this"
|
echo " -k, --sign-key KEYID Sign the package sources with the provided gpg key id (long format). When not provided this"
|
||||||
echo " paramater, the generated sources are not signed"
|
echo " paramater, the generated sources are not signed"
|
||||||
echo " -s, --sign Sign the package sources with a gpg key of the maintainer"
|
echo " -s, --sign Sign the package sources with a gpg key of the maintainer"
|
||||||
@ -156,7 +156,7 @@ fi
|
|||||||
# generate changelog
|
# generate changelog
|
||||||
gbp dch --ignore-branch --no-multimaint -N "$VERSION" -s "\$SINCE" -D "\$DISTRIBUTION"
|
gbp dch --ignore-branch --no-multimaint -N "$VERSION" -s "\$SINCE" -D "\$DISTRIBUTION"
|
||||||
|
|
||||||
# using -d to prevent failing when searching for golang dep on control file
|
# using -d to prevent failing when searching for Golang dep on control file
|
||||||
params=("-d" "-S")
|
params=("-d" "-S")
|
||||||
|
|
||||||
# add the -sa option for signing along with the key to use when provided key id
|
# add the -sa option for signing along with the key to use when provided key id
|
||||||
@ -208,7 +208,7 @@ RUN set -e \
|
|||||||
&& sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list \
|
&& sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list \
|
||||||
&& apt-get -qq update
|
&& apt-get -qq update
|
||||||
|
|
||||||
# install golang on its $GOVERSION
|
# install Golang on its $GOVERSION
|
||||||
FROM base as golang
|
FROM base as golang
|
||||||
RUN apt-get -qq -y --no-install-recommends install \
|
RUN apt-get -qq -y --no-install-recommends install \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
|
Loading…
Reference in New Issue
Block a user