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

Commit

Permalink
filecheck: replace space with underscore in dim (#1158)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyam8 authored Apr 17, 2023
1 parent c3a083b commit a9fcebb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
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)
}

0 comments on commit a9fcebb

Please sign in to comment.