From 566d0a71487953d691b926d61db6c502e632a65a Mon Sep 17 00:00:00 2001 From: sam boyer Date: Tue, 26 Jul 2022 09:14:07 -0400 Subject: [PATCH] coremodel: Fix hardcoded text and overly broad embedding (#52802) * Replace hardcoded 'dashboard' references * Only embed cue.mod/module.cue * Add quotes --- embed.go | 2 +- go.mod | 2 +- go.sum | 2 ++ pkg/codegen/coremodel.go | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/embed.go b/embed.go index 10d6ef63a04..696b08d4a14 100644 --- a/embed.go +++ b/embed.go @@ -6,5 +6,5 @@ import ( // CueSchemaFS embeds all schema-related CUE files in the Grafana project. // -//go:embed cue.mod packages/grafana-schema/src/schema/*.cue public/app/plugins/*/*/*.cue public/app/plugins/*/*/plugin.json +//go:embed cue.mod/module.cue packages/grafana-schema/src/schema/*.cue public/app/plugins/*/*/*.cue public/app/plugins/*/*/plugin.json var CueSchemaFS embed.FS diff --git a/go.mod b/go.mod index ba0ecb9d75a..e9a9f62b039 100644 --- a/go.mod +++ b/go.mod @@ -245,7 +245,7 @@ require ( github.com/getkin/kin-openapi v0.94.0 github.com/golang-migrate/migrate/v4 v4.7.0 github.com/grafana/dskit v0.0.0-20211011144203-3a88ec0b675f - github.com/grafana/thema v0.0.0-20220523183731-72aebd14e751 + github.com/grafana/thema v0.0.0-20220726124731-b8017e278cc1 go.etcd.io/etcd/api/v3 v3.5.4 go.opentelemetry.io/contrib/propagators/jaeger v1.6.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.6.3 diff --git a/go.sum b/go.sum index c19259ad9fd..8d252720d54 100644 --- a/go.sum +++ b/go.sum @@ -1353,6 +1353,8 @@ github.com/grafana/saml v0.0.0-20211007135653-aed1b2edd86b h1:YiSGp34F4V0G08HHx1 github.com/grafana/saml v0.0.0-20211007135653-aed1b2edd86b/go.mod h1:q83kyQoMD0vhy+RzFLlbw0UgHJ6TAihQpuXvdFmm4s4= github.com/grafana/thema v0.0.0-20220523183731-72aebd14e751 h1:5PpsfN52XA0hxOjD/qQ0QNiEkp9Y9Tb+yz/Hj9fyL4M= github.com/grafana/thema v0.0.0-20220523183731-72aebd14e751/go.mod h1:KuqTKX9lfM87uu9vt9DS/q+REqSrAm2xYMnBBvlmevA= +github.com/grafana/thema v0.0.0-20220726124731-b8017e278cc1 h1:BENUTE1rqYy6gcRdIAbiuSROpAYwmg3aW4CWGqoSIk4= +github.com/grafana/thema v0.0.0-20220726124731-b8017e278cc1/go.mod h1:fCV1rqv6XRQg2GfIQ7pU9zdxd5fLRcEBCnrDVwlK+ZY= github.com/grafana/xorm v0.8.3-0.20220614223926-2fcda7565af6 h1:I9dh1MXGX0wGyxdV/Sl7+ugnki4Dfsy8lv2s5Yf887o= github.com/grafana/xorm v0.8.3-0.20220614223926-2fcda7565af6/go.mod h1:ZkJLEYLoVyg7amJK/5r779bHyzs2AU8f8VMiP6BM7uY= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= diff --git a/pkg/codegen/coremodel.go b/pkg/codegen/coremodel.go index 882d5a46ffb..34e385586f1 100644 --- a/pkg/codegen/coremodel.go +++ b/pkg/codegen/coremodel.go @@ -346,7 +346,7 @@ var currentVersion = thema.SV({{ .LatestSeqv }}, {{ .LatestSchv }}) // This is the base variant of the schema. It does not include any composed // plugin schemas.{{ end }} func Lineage(lib thema.Library, opts ...thema.BindOption) (thema.Lineage, error) { - return cuectx.LoadGrafanaInstancesWithThema(filepath.Join("pkg", "coremodel", "dashboard"), cueFS, lib, opts...) + return cuectx.LoadGrafanaInstancesWithThema(filepath.Join("pkg", "coremodel", "{{ .Name }}"), cueFS, lib, opts...) } var _ thema.LineageFactory = Lineage @@ -358,7 +358,7 @@ type Coremodel struct { lin thema.Lineage } -// Lineage returns the canonical dashboard Lineage. +// Lineage returns the canonical {{ .Name }} Lineage. func (c *Coremodel) Lineage() thema.Lineage { return c.lin }