func hostInfoRespToGroups(resp safcm.MsgInfoResp) []string {
groups := []string{
- config.GroupDetectedPrefix + "_" + resp.Goos,
- config.GroupDetectedPrefix + "_" + resp.Goarch,
+ hostInfoDetectedGroupName(resp.Goos),
+ hostInfoDetectedGroupName(resp.Goarch),
}
for _, x := range resp.Output {
- x = strings.TrimSpace(x)
- x = strings.ToLower(x)
- x = infoGroupDetectedRegexp.ReplaceAllString(x, "_")
- groups = append(groups, config.GroupDetectedPrefix+"_"+x)
+ groups = append(groups, hostInfoDetectedGroupName(x))
}
return groups
}
+
+func hostInfoDetectedGroupName(x string) string {
+ x = strings.TrimSpace(x)
+ x = strings.ToLower(x)
+ x = infoGroupDetectedRegexp.ReplaceAllString(x, "_")
+ x = config.GroupDetectedPrefix + "_" + x
+ return x
+}