From 6539ae512c818cacf8f4434c4c9262038ceb877d Mon Sep 17 00:00:00 2001 From: Yuriy Tseretyan Date: Fri, 16 Sep 2022 10:29:39 -0400 Subject: [PATCH] use filepath.Dir to get the parent (#55266) --- pkg/framework/coremodel/gen.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/framework/coremodel/gen.go b/pkg/framework/coremodel/gen.go index 051a9217fdf..c261edd66c9 100644 --- a/pkg/framework/coremodel/gen.go +++ b/pkg/framework/coremodel/gen.go @@ -9,13 +9,13 @@ import ( "os" "path/filepath" "sort" - "strings" "cuelang.org/go/cue/cuecontext" "cuelang.org/go/cue/load" "github.com/grafana/cuetsy" - gcgen "github.com/grafana/grafana/pkg/codegen" "github.com/grafana/thema" + + gcgen "github.com/grafana/grafana/pkg/codegen" ) var lib = thema.NewLibrary(cuecontext.New()) @@ -37,8 +37,7 @@ func main() { } // TODO this binds us to only having coremodels in a single directory. If we need more, compgen is the way - grootp := strings.Split(cwd, sep) - groot := filepath.Join(sep, filepath.Join(grootp[:len(grootp)-3]...)) + groot := filepath.Dir(filepath.Dir(filepath.Dir(cwd))) // the working dir is /pkg/framework/coremodel. Going up 3 dirs we get the grafana root cmroot := filepath.Join(groot, "pkg", "coremodel") tsroot := filepath.Join(groot, "packages", "grafana-schema", "src", "schema")