properly strip path.rootfs from mountpoint labels (#1421)

Change-type: patch
Connects-to: #1418
Signed-off-by: dt-rush <nickp@balena.io>
This commit is contained in:
dt-rush 2019-07-19 14:51:17 +00:00 committed by Ben Kochie
commit 5d3e2ce2ef
7 changed files with 44 additions and 3 deletions

View file

@ -15,6 +15,7 @@ package collector
import (
"path/filepath"
"strings"
"github.com/prometheus/procfs"
kingpin "gopkg.in/alecthomas/kingpin.v2"
@ -38,3 +39,10 @@ func sysFilePath(name string) string {
func rootfsFilePath(name string) string {
return filepath.Join(*rootfsPath, name)
}
func rootfsStripPrefix(path string) string {
if *rootfsPath == "/" {
return path
}
return strings.TrimPrefix(path, *rootfsPath)
}