Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the implementation of the key rewriting feature, along with a couple of other enhancements that were required for the functionality. The first change is that the key() statement now works very differently: instead of being a wrapper around pair(), it is now a glob-accepting include statement instead (with keeping the name). As such, it no longer guarantees that a given key will appear in the final set, as excludes still have a chance to override it. key() and exclude() patterns are now matched in order, and the last one wins. The only way to guarantee a key into a set, in spite of any exclude() rules, is via pair(). The key-value pairs specified by pair() are still inserted into the set afterwards. The key rewriting itself is done via the new rekey() statement, to be used under the key() statement, along these lines: value-pairs( key(".cee.*" rekey(shift(4) add-prefix("Events") replace("Events.some_field" "a_new_name") ) ) ) Similarly, the same thing can be done with format-json (without the line breaks): $(format-json --key .cee.* --rekey --shift 4 --add-prefix Events --replace Events.some_field=a_new_name) The transformations listed under rekey() are applied to each key matched by the glob specified for the outer key() statement, and the transformations are applied in the order they're listed in the configuration. This patch implements the following translations: shift($AMOUNT), which simply shifts the key $AMOUNT characters right; add-prefix($PREFIX) which does as the name suggests; and replace($PREFIX, $NEW_PREFIX), which replaces a substring at the start of the key, with another. The replace() transformation does not support replacing anything other than a prefix. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
- Loading branch information