From 45d22f2added863a35bffea1821b82c498ec0d82 Mon Sep 17 00:00:00 2001 From: Matthias Rampke Date: Fri, 10 Nov 2017 20:01:57 +0000 Subject: [PATCH] Add examples for quoting matches that start with `*`. The YAML parser chokes on strings starting with asterisks. Add a scenario to the spec that shows this, and that shows that quoting fixes the issue. --- mapper_test.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/mapper_test.go b/mapper_test.go index 44e0612..4fd323e 100644 --- a/mapper_test.go +++ b/mapper_test.go @@ -203,6 +203,31 @@ mappings: }, }, }, + // Config with an improperly escaped *. + { + config: ` +mappings: +- match: *.test.* + labels: + name: "name" + label: "${1}_foo"`, + configBad: true, + }, + // Config with a properly escaped *. + { + config: ` +mappings: +- match: "*.test.*" + labels: + name: "name" + label: "${2}_foo"`, + mappings: map[string]map[string]string{ + "foo.test.a": map[string]string{ + "name": "name", + "label": "a_foo", + }, + }, + }, // Config with good timer type. { config: `--- @@ -233,7 +258,7 @@ mappings: { config: `--- mappings: -- match: *\.foo +- match: "*\.foo" match_type: regex labels: name: "foo"