Add proper JSON marshaling of config regexps. (#602)
This commit is contained in:
parent
5489644cbe
commit
f2ba86e9d2
|
@ -22,6 +22,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"encoding/json"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
@ -481,3 +482,11 @@ func (re *Regexp) MarshalYAML() (interface{}, error) {
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalJSON implements the json.Marshaler interface.
|
||||||
|
func (re Regexp) MarshalJSON() ([]byte, error) {
|
||||||
|
if re.Regexp != nil {
|
||||||
|
return json.Marshal(re.String())
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue