diff --git a/cmd/file_patch.go b/cmd/file_patch.go index 5fc770614..ada47fc25 100644 --- a/cmd/file_patch.go +++ b/cmd/file_patch.go @@ -121,21 +121,30 @@ to the output file. The patches can be specified by a '--selector' and one or mo '--value' tags, or via patch files. When using '--selector' and '--values', the items are selected by the 'selector', -which is a JSONpath query. From the array of nodes found, only the objects are updated. -The 'values' are applied on each of the JSONObjects returned by the 'selector'. +which is a JSONpath query. The 'field values' (in '' format) are applied on +each of the JSONObjects returned by the 'selector'. The 'array values' (in +'[val1, val2]' format) are appended to each of the JSONArrays returned by the 'selector'. -Objects: - -The value must be a valid JSON snippet, so use single/double quotes +The field values must be a valid JSON snippet, so use single/double quotes appropriately. If the value is empty, the field is removed from the object. Examples of valid values: + # set field "read_timeout" to a numeric value of 10000 --selector="$..services[*]" --value="read_timeout:10000" + + # set field "_comment" to a string value --selector="$..services[*]" --value='_comment:"comment injected by patching"' + + # set field "_ignore" to an array of strings --selector="$..services[*]" --value='_ignore:["ignore1","ignore2"]' + + # remove fields "_ignore" and "_comment" from the object --selector="$..services[*]" --value='_ignore:' --value='_comment:' + # append entries to the methods array of all route objects + --selector="$..routes[*].methods" --value='["OPTIONS"]' + Patch files have the following format (JSON or YAML) and can contain multiple patches that are applied in order: @@ -154,8 +163,6 @@ patches that are applied in order: ] } -Arrays: - If the 'values' object instead is an array, then any arrays returned by the selectors will get the 'values' appended to them. `,