mirror of
https://github.com/grafana/grafana.git
synced 2026-08-11 05:34:53 -05:00
Kinds: publish kinds to kind registry (#67515)
* Start local schema registry
* Try to use latest version
* Revert "Try to use latest version"
This reverts commit 682385c0e4.
* update schema registry jenny to validate new lineages
* save kind instead of lineage
* handle plugins
* get published schemas from GH + fix plugins
* handle kind not yet published
* Add script to use in workflow + handle maturity
* first pass on publish-kinds GH workflow
* fix script path
* remove unused script
* use make gen-cue instead of script
* trigger publish-kinds on every commit (for test)
* temporary update to use specific thema commit
* wrapping errors
* remove GH token & refactor for rate limit
* Update publish-kinds.yml
* Update publish-kinds.yml
* revert go.mod and go.sum updates
* use Thema specific commit
* Kind registry v2
* fix script path
* fix second script path
* update go.mod
* update schema registry source
* test checks
* add GITHUB_TOKEN
* revert test checks
* actually write next files when publishing
* Add kind set arg
* Add comments
* clean up workflows
* update Thema
* Update .betterer.results
* few fixes after lineage flattening
* Update publish-kinds-next.yml
* add codeowners for new files
* update thema
* apply review feedback
* update go version in workflows
* clean up workflows
* Add step to generate token and test
* Update publish-kinds-next.yml
* fix script
* try with the app name
* Update publish-kinds-next.yml
* clean up and update release workflow
* add comment
* publish kinds only on cue updates
This commit is contained in:
@@ -232,6 +232,49 @@ func ParsePluginFS(fsys fs.FS, rt *thema.Runtime) (ParsedPlugin, error) {
|
||||
return pp, nil
|
||||
}
|
||||
|
||||
// LoadComposableKindDef loads and validates a composable kind definition.
|
||||
// On success, it returns a [Def] which contains the entire contents of the kind definition.
|
||||
//
|
||||
// defpath is the path to the directory containing the composable kind definition,
|
||||
// relative to the root of the caller's repository.
|
||||
//
|
||||
// NOTE This function will be deprecated in favor of a more generic loader when kind
|
||||
// providers will be implemented.
|
||||
func LoadComposableKindDef(fsys fs.FS, rt *thema.Runtime, defpath string) (kindsys.Def[kindsys.ComposableProperties], error) {
|
||||
pp := ParsedPlugin{
|
||||
ComposableKinds: make(map[string]kindsys.Composable),
|
||||
Properties: plugindef.PluginDef{
|
||||
Id: defpath,
|
||||
},
|
||||
}
|
||||
|
||||
fsys, err := ensureCueMod(fsys, pp.Properties)
|
||||
if err != nil {
|
||||
return kindsys.Def[kindsys.ComposableProperties]{}, fmt.Errorf("%s has invalid cue.mod: %w", pp.Properties.Id, err)
|
||||
}
|
||||
|
||||
bi, err := cuectx.LoadInstanceWithGrafana(fsys, "", load.Package(PackageName))
|
||||
if err != nil {
|
||||
return kindsys.Def[kindsys.ComposableProperties]{}, err
|
||||
}
|
||||
|
||||
ctx := rt.Context()
|
||||
v := ctx.BuildInstance(bi)
|
||||
if v.Err() != nil {
|
||||
return kindsys.Def[kindsys.ComposableProperties]{}, fmt.Errorf("%s not a valid CUE instance: %w", defpath, v.Err())
|
||||
}
|
||||
|
||||
props, err := kindsys.ToKindProps[kindsys.ComposableProperties](v)
|
||||
if err != nil {
|
||||
return kindsys.Def[kindsys.ComposableProperties]{}, err
|
||||
}
|
||||
|
||||
return kindsys.Def[kindsys.ComposableProperties]{
|
||||
V: v,
|
||||
Properties: props,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ensureCueMod(fsys fs.FS, pdef plugindef.PluginDef) (fs.FS, error) {
|
||||
if modf, err := fs.ReadFile(fsys, "cue.mod/module.cue"); err != nil {
|
||||
if !errors.Is(err, fs.ErrNotExist) {
|
||||
|
||||
Reference in New Issue
Block a user