kindsys: Fix loading on windows (backport of #59519 to v9.3.x) (#59520)

kindsys: Fix loading on windows (#59519)

(cherry picked from commit ce0bdb2cd9)
This commit is contained in:
sam boyer
2022-12-01 07:36:36 -05:00
committed by GitHub
parent 95b7cabe00
commit ec552dd6b8
+2 -18
View File
@@ -8,10 +8,8 @@ import (
"cuelang.org/go/cue"
"cuelang.org/go/cue/errors"
"github.com/grafana/grafana"
"github.com/grafana/grafana/pkg/cuectx"
"github.com/grafana/thema"
tload "github.com/grafana/thema/load"
)
// CoreStructuredDeclParentPath is the path, relative to the repository root, where
@@ -48,28 +46,14 @@ func loadpFrameworkOnce() {
})
}
var prefix = filepath.Join("/pkg", "kindsys")
func doLoadFrameworkCUE(ctx *cue.Context) (cue.Value, error) {
var v cue.Value
var err error
absolutePath := prefix
if !filepath.IsAbs(absolutePath) {
absolutePath, err = filepath.Abs(absolutePath)
if err != nil {
return v, err
}
}
bi, err := tload.InstancesWithThema(grafana.CueSchemaFS, absolutePath)
v, err := cuectx.BuildGrafanaInstance(ctx, filepath.Join("pkg", "kindsys"), "kindsys", nil)
if err != nil {
return v, err
}
v = ctx.BuildInstance(bi)
if err = v.Validate(cue.Concrete(false), cue.All()); err != nil {
return cue.Value{}, fmt.Errorf("coremodel framework loaded cue.Value has err: %w", err)
return cue.Value{}, fmt.Errorf("kindsys framework loaded cue.Value has err: %w", err)
}
return v, nil