agent: move parseMetaPair to config and export

This commit is contained in:
Frank Schroeder 2017-06-02 12:04:04 +02:00 committed by Frank Schröder
parent 34c981ba55
commit 02ce45e5bb
4 changed files with 11 additions and 11 deletions

View File

@ -2115,15 +2115,6 @@ func (a *Agent) loadMetadata(conf *Config) error {
return nil
}
// parseMetaPair parses a key/value pair of the form key:value
func parseMetaPair(raw string) (string, string) {
pair := strings.SplitN(raw, ":", 2)
if len(pair) == 2 {
return pair[0], pair[1]
}
return pair[0], ""
}
// unloadMetadata resets the local metadata state
func (a *Agent) unloadMetadata() {
a.state.Lock()

View File

@ -214,7 +214,7 @@ func (cmd *Command) readConfig() *Config {
if len(nodeMeta) > 0 {
cmdCfg.Meta = make(map[string]string)
for _, entry := range nodeMeta {
key, value := parseMetaPair(entry)
key, value := ParseMetaPair(entry)
cmdCfg.Meta[key] = value
}
}

View File

@ -2079,3 +2079,12 @@ func (d dirEnts) Less(i, j int) bool {
func (d dirEnts) Swap(i, j int) {
d[i], d[j] = d[j], d[i]
}
// ParseMetaPair parses a key/value pair of the form key:value
func ParseMetaPair(raw string) (string, string) {
pair := strings.SplitN(raw, ":", 2)
if len(pair) == 2 {
return pair[0], pair[1]
}
return pair[0], ""
}

View File

@ -420,7 +420,7 @@ func (s *HTTPServer) parseMetaFilter(req *http.Request) map[string]string {
if filterList, ok := req.URL.Query()["node-meta"]; ok {
filters := make(map[string]string)
for _, filter := range filterList {
key, value := parseMetaPair(filter)
key, value := ParseMetaPair(filter)
filters[key] = value
}
return filters