mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
schema: Migrate from scuemata to thema (#49805)
* Remove crufty scuemata bits Buhbye to: cue/ dir with old definitions, CI steps for checking unnecessary things, and the original dashboard scuemata file. * Remove grafana-cli cue subcommand * Remove old testdata * Don't swallow errors from codegen * Small nits and tweaks to cuectx package * WIP - refactor pluggen to use Thema Also consolidate the embed.FS in the repo root. * Finish halfway rename * Convert all panel models.cue to thema * Rewrite pluggen to use Thema * Remove pkg/schema, and trim command * Remove schemaloader service and usages Will be replaced by coremodel-centric hydrate/dehydrate system Soon™. * Remove schemaloader from wire * Remove hangover field on histogram models.cue * Fix lint errors, some vestiges of trim service * Remove unused cuetsify cli command
This commit is contained in:
@@ -100,12 +100,6 @@ func runPluginCommand(command func(commandLine utils.CommandLine) error) func(co
|
||||
}
|
||||
}
|
||||
|
||||
func runCueCommand(command func(commandLine utils.CommandLine) error) func(context *cli.Context) error {
|
||||
return func(context *cli.Context) error {
|
||||
return command(&utils.ContextCommandLine{Context: context})
|
||||
}
|
||||
}
|
||||
|
||||
// Command contains command state.
|
||||
type Command struct {
|
||||
Client utils.ApiClient
|
||||
@@ -197,74 +191,6 @@ var adminCommands = []*cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
var cueCommands = []*cli.Command{
|
||||
{
|
||||
Name: "validate-schema",
|
||||
Usage: "validate known *.cue files in the Grafana project",
|
||||
Action: runCueCommand(cmd.validateScuemata),
|
||||
Description: `validate-schema checks that all CUE schema files are valid with respect
|
||||
to basic standards - valid CUE, valid scuemata, etc. Note that this
|
||||
command checks only paths that existed when grafana-cli was compiled,
|
||||
so must be recompiled to validate newly-added CUE files.`,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "grafana-root",
|
||||
Usage: "path to the root of a Grafana repository to validate",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "validate-resource",
|
||||
Usage: "validate resource files (e.g. dashboard JSON) against schema",
|
||||
Action: runCueCommand(cmd.validateResources),
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "dashboard",
|
||||
Usage: "dashboard JSON file to validate",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "base-only",
|
||||
Usage: "validate using only base schema, not dist (includes plugin schema)",
|
||||
Value: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "trim-resource",
|
||||
Usage: "trim schema-specified defaults from a resource",
|
||||
Action: runCueCommand(cmd.trimResource),
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "dashboard",
|
||||
Usage: "path to file containing (valid) dashboard JSON",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "apply",
|
||||
Usage: "invert the operation: apply defaults instead of trimming them",
|
||||
Value: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "gen-ts",
|
||||
Usage: "generate TypeScript from all known CUE file types",
|
||||
Description: `gen-ts generates TypeScript from all CUE files at
|
||||
expected positions in the filesystem tree of a Grafana repository.`,
|
||||
Action: runCueCommand(cmd.generateTypescript),
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "grafana-root",
|
||||
Usage: "path to the root of a Grafana repository in which to generate TypeScript from CUE files",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "diff",
|
||||
Usage: "diff results of codegen against files already on disk. Exits 1 if diff is non-empty",
|
||||
Value: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var Commands = []*cli.Command{
|
||||
{
|
||||
Name: "plugins",
|
||||
@@ -276,9 +202,4 @@ var Commands = []*cli.Command{
|
||||
Usage: "Grafana admin commands",
|
||||
Subcommands: adminCommands,
|
||||
},
|
||||
{
|
||||
Name: "cue",
|
||||
Usage: "Cue validation commands",
|
||||
Subcommands: cueCommands,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user