Check if label value is valid when unmarhsaling external labels from

YAML, add a test to config_tests for valid/invalid external label
value.

Signed-off-by: Callum Styan <callumstyan@gmail.com>
pull/5388/head
Callum Styan 7 years ago committed by Tom Wilkie
parent 807fd33ecc
commit 5603b857a9
  1. 3
      config/config.go
  2. 3
      config/config_test.go
  3. 3
      config/testdata/labelvalue.bad.yml

@ -304,6 +304,9 @@ func (c *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if !model.LabelName(l.Name).IsValid() {
return fmt.Errorf("%q is not a valid label name", l.Name)
}
if !model.LabelValue(l.Value).IsValid() {
return fmt.Errorf("%q is not a valid label value", l.Value)
}
}
// First set the correct scrape interval, then check that the timeout

@ -714,6 +714,9 @@ var expectedErrors = []struct {
}, {
filename: "labelname2.bad.yml",
errMsg: `"not:allowed" is not a valid label name`,
}, {
filename: "labelvalue.bad.yml",
errMsg: `"\xff" is not a valid label value`,
}, {
filename: "regex.bad.yml",
errMsg: "error parsing regexp",

@ -0,0 +1,3 @@
global:
external_labels:
name: !!binary "/w=="
Loading…
Cancel
Save