grafana / grok

Grafana Object Development Kit
Apache License 2.0
50 stars 1 forks source link

Add index for JSON Schema #6

Closed malcolmholmes closed 1 year ago

malcolmholmes commented 1 year ago

For Grafonnet, we need to expose a list of all schemas. Not only all schemas, but all schemas for all versions. This PR adds a new Jenny that will render two JSON files, one for core kinds and another for composable kinds. These files can then be consumed by Grafonnet to render its required schema import files.

malcolmholmes commented 1 year ago

@sdboyer I believe this code is correct, but go generate fails with:

panic: *jsonschema.JsonSchemaIndexJenny is not a valid Jenny, must implement (OneToOne | OneToMany | ManyToOne | ManyToMany)

My new JsonSchemaIndexJenny is valid in every way I can see. What am I missing? (Not used generics before).

malcolmholmes commented 1 year ago

@sdboyer So this code works, but it has a hack in it. For some reason, the iterator returns the same version as previously, causing a perpetual loop. The loop is basically the same as that in LatestMajorsOrXJenny, which appears to work, so I'm not sure how to fix (other than the break hack).

malcolmholmes commented 1 year ago

Note the JSON files in the jsonschema/ directory. The code basically works.

malcolmholmes commented 1 year ago

This PR was intended for Jsonnet support, but we've moved the boundaries between grafonnet/grok, making this PR redundant.