1 package static 2 3 import ( 4 "path" 5 "path/filepath" 6 "runtime" 7 ) 8 9 // GetRepoRoot returns the full path to the root of the repo. We assume this 10 // function is only called from the `Templates` var above, and that this source 11 // file lives at `pkg/charts/static`, relative to the root of the repo. 12 func GetRepoRoot() string { 13 // /foo/bar/linkerd2/pkg/charts/static/templates.go 14 _, filename, _, _ := runtime.Caller(0) 15 16 // /foo/bar/linkerd2/pkg/charts/static 17 dir := filepath.Dir(filename) 18 19 // filepath.Dir returns the parent directory, so that combined with joining 20 // ".." walks 3 levels up the tree: 21 // /foo/bar/linkerd2 22 return filepath.Dir(path.Join(dir, "../..")) 23 } 24