use LabelNam.IsValid() instead of LabelNameRE and MatchString instead of Match

pull/2094/head
Matti Savolainen 8 years ago
parent ec6524ce74
commit aabf4a419b

@ -1015,10 +1015,10 @@ func (c *RelabelConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if (c.Action == RelabelReplace || c.Action == RelabelHashMod) && c.TargetLabel == "" { if (c.Action == RelabelReplace || c.Action == RelabelHashMod) && c.TargetLabel == "" {
return fmt.Errorf("relabel configuration for %s action requires 'target_label' value", c.Action) return fmt.Errorf("relabel configuration for %s action requires 'target_label' value", c.Action)
} }
if c.Action == RelabelReplace && !relabelTarget.Match([]byte(c.TargetLabel)) { if c.Action == RelabelReplace && !relabelTarget.MatchString(c.TargetLabel) {
return fmt.Errorf("%q is invalid 'target_label' for %s action", c.TargetLabel, c.Action) return fmt.Errorf("%q is invalid 'target_label' for %s action", c.TargetLabel, c.Action)
} }
if c.Action == RelabelHashMod && !model.LabelNameRE.Match([]byte(c.TargetLabel)) { if c.Action == RelabelHashMod && !model.LabelName(c.TargetLabel).IsValid() {
return fmt.Errorf("%q is invalid 'target_label' for %s action", c.TargetLabel, c.Action) return fmt.Errorf("%q is invalid 'target_label' for %s action", c.TargetLabel, c.Action)
} }
return nil return nil

Loading…
Cancel
Save