Kinds: Reconcile verify-kinds.go with kind-registry changes (#73689)

* Kinds: Reconcile verify-kinds.go with kind-registry changes

* Remove handwritten value specific for manual test

* Update grafana/kindsys dep

* Revert "Update grafana/kindsys dep"

This reverts commit e437e1879e.

* Fix generated code
This commit is contained in:
Joan López de la Franca Beltran 2023-08-23 16:51:50 +02:00 committed by GitHub
parent 25fd8f2d59
commit fb0165ab87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 8 deletions

View File

@ -206,7 +206,7 @@ func loadComposableKind(name string, kind string) (kindsys.Kind, error) {
fs := fstest.MapFS{
fmt.Sprintf("%s.cue", name): &fstest.MapFile{
Data: []byte("package grafanaplugin\n" + kind),
Data: []byte(kind),
},
}
@ -290,7 +290,7 @@ func (j *ckrJenny) Generate(k kindsys.Composable) (*codejen.File, error) {
return nil, err
}
newKindBytes = []byte(fmt.Sprintf("package kind\n\n%s", newKindBytes))
newKindBytes = []byte(fmt.Sprintf("package grafanaplugin\n\n%s", newKindBytes))
return codejen.NewFile(filepath.Join(j.path, "next", "composable", name+".cue"), newKindBytes, j), nil
}
@ -399,10 +399,17 @@ func (registry *kindRegistry) getPublishedKind(name string, category string, lat
return "", nil
}
kindPath := filepath.Join(
registry.zipDir,
fmt.Sprintf("grafana/%s/%s/%s.cue", latestRegistryDir, category, name),
)
var cueFilePath string
switch category {
case "core":
cueFilePath = fmt.Sprintf("%s/%s.cue", name, name)
case "composable":
cueFilePath = fmt.Sprintf("%s.cue", name)
default:
return "", fmt.Errorf("kind can only be core or composable")
}
kindPath := filepath.Join(latestRegistryDir, category, cueFilePath)
file, err := registry.zipFile.Open(kindPath)
if err != nil {
return "", fmt.Errorf("failed to open file: %w", err)

View File

@ -125,7 +125,7 @@ schemas: [{
// Required Grafana version for this plugin. Validated using
// https://github.com/npm/node-semver.
grafanaDependency: =~"^(<=|>=|<|>|=|~|\\^)?([0-9]+)(\\.[0-9x\\*]+)(\\.[0-9x\\*]+)?(\\s(<=|>=|<|=>)?([0-9]+)(\\.[0-9x]+)(\\.[0-9x]+))?$"
grafanaDependency?: =~"^(<=|>=|<|>|=|~|\\^)?([0-9]+)(\\.[0-9x\\*]+)(\\.[0-9x\\*]+)?(\\s(<=|>=|<|=>)?([0-9]+)(\\.[0-9x]+)(\\.[0-9x]+))?$"
// An array of required plugins on which this plugin depends
plugins?: [...#Dependency]

View File

@ -98,7 +98,7 @@ type BuildInfo struct {
type Dependencies struct {
// Required Grafana version for this plugin. Validated using
// https://github.com/npm/node-semver.
GrafanaDependency string `json:"grafanaDependency"`
GrafanaDependency *string `json:"grafanaDependency,omitempty"`
// (Deprecated) Required Grafana version for this plugin, e.g.
// `6.x.x 7.x.x` to denote plugin requires Grafana v6.x.x or