Chore: Fix cue loader to use absolute path (#54257)

This commit is contained in:
Yuriy Tseretyan 2022-08-26 14:08:12 -04:00 committed by GitHub
parent 20d0aa9904
commit b9be2815d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,9 +9,10 @@ import (
"cuelang.org/go/cue"
"cuelang.org/go/cue/load"
"github.com/grafana/grafana/pkg/cuectx"
"github.com/grafana/thema/kernel"
tload "github.com/grafana/thema/load"
"github.com/grafana/grafana/pkg/cuectx"
)
// Embed for all framework-related CUE files in this directory
@ -54,13 +55,22 @@ func doLoadFrameworkCUE(ctx *cue.Context) (v cue.Value, err error) {
}
over := make(map[string]load.Source)
err = tload.ToOverlay(prefix, m, over)
absolutePath := prefix
if !filepath.IsAbs(absolutePath) {
absolutePath, err = filepath.Abs(absolutePath)
if err != nil {
return
}
}
err = tload.ToOverlay(absolutePath, m, over)
if err != nil {
return
}
bi := load.Instances(nil, &load.Config{
Dir: prefix,
Dir: absolutePath,
Package: "coremodel",
Overlay: over,
})