Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

filecheck: replace space with underscore in dim #1158

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/filecheck/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package filecheck

import (
"regexp"
"runtime"
"strings"
)
Expand Down Expand Up @@ -35,3 +36,5 @@ func removeDuplicates(s []string) []string {
}
return uniq
}

var reSpace = regexp.MustCompile(`\s`)
4 changes: 2 additions & 2 deletions modules/filecheck/collect_dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (fc *Filecheck) addDirToCharts(path string) {
continue
}

dim := &module.Dim{ID: id, Name: path}
dim := &module.Dim{ID: id, Name: reSpace.ReplaceAllString(path, "_")}

if err := chart.AddDim(dim); err != nil {
fc.Warning(err)
Expand Down Expand Up @@ -155,7 +155,7 @@ func (fc *Filecheck) removeDirFromCharts(path string) {
}

func dirDimID(path, metric string) string {
return fmt.Sprintf("dir_%s_%s", path, metric)
return fmt.Sprintf("dir_%s_%s", reSpace.ReplaceAllString(path, "_"), metric)
}

func calcDirNumOfFiles(dirpath string) (int, error) {
Expand Down
4 changes: 2 additions & 2 deletions modules/filecheck/collect_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (fc *Filecheck) addFileToCharts(path string) {
continue
}

dim := &module.Dim{ID: id, Name: path}
dim := &module.Dim{ID: id, Name: reSpace.ReplaceAllString(path, "_")}

if err := chart.AddDim(dim); err != nil {
fc.Warning(err)
Expand Down Expand Up @@ -144,5 +144,5 @@ func (fc *Filecheck) removeFileFromCharts(path string) {
}

func fileDimID(path, metric string) string {
return fmt.Sprintf("file_%s_%s", path, metric)
return fmt.Sprintf("file_%s_%s", reSpace.ReplaceAllString(path, "_"), metric)
}