Skip to content

Instantly share code, notes, and snippets.

@sdboyer
Last active June 28, 2022 22:45
Show Gist options
  • Save sdboyer/a528daf51dd0d73d32952bd5c210cdfc to your computer and use it in GitHub Desktop.
Save sdboyer/a528daf51dd0d73d32952bd5c210cdfc to your computer and use it in GitHub Desktop.
A function for getting a JSON kernel from a coremodel
package something
import (
"github.com/grafana/thema/kernel"
"github.com/grafana/grafana/pkg/framework/coremodel"
)
func JSONKernelFrom(cm coremodel.Interface) kernel.InputKernel {
k, _ := kernel.NewInputKernel(kernel.InputKernelConfig{
Typ: cm.GoType(),
Loader: kernel.NewJSONDecoder(cm.Lineage().Name() + ".json"),
Lineage: cm.Lineage(),
To: cm.CurrentSchema().Version(),
})
return k
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment