Skip to content

Commit

Permalink
refactor: add target GetTagsMap()
Browse files Browse the repository at this point in the history
  • Loading branch information
710leo committed Dec 25, 2023
1 parent 47b4464 commit decccce
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions models/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,19 @@ func (t *Target) FillTagsMap() {
t.TagsMap = m
}

func (t *Target) GetTagsMap() map[string]string {
tagsJSON := strings.Fields(t.Tags)
m := make(map[string]string)
for _, item := range tagsJSON {
arr := strings.Split(item, "=")
if len(arr) != 2 {
continue
}
m[arr[0]] = arr[1]
}
return m
}

func (t *Target) FillMeta(meta *HostMeta) {
t.MemUtil = meta.MemUtil
t.CpuUtil = meta.CpuUtil
Expand Down

0 comments on commit decccce

Please sign in to comment.