grafana / kindsys

a kind system for schematizing objects
Apache License 2.0
12 stars 0 forks source link

Convert kindsys to a basic interface #33

Open ryantxu opened 1 year ago

ryantxu commented 1 year ago

Status: WIP/POC... this is a pretty big change that is only possible to evaluate when looking at the source tree (diff is too big!)

This PR changes kindsys from a strictly cue+thema managed system to one that is defined by a golang interface, and can be implemented in with alternative approaches.

This takes a few big steps:

Before:

image

After:

image

TODO:

FAQ:

Is this necessary?

Regardless how we choose to validate objects, we should build our tools against an interface that is forced to advertise its capabilities explicitly and that can be replaced/evolved as needed. The current surface area is too large/undefined/leaky to solidify into the foundation of all future grafana services.

What about existing kindsys usage and codegen?

Current kinds and codegen will continue to work after minor changes to the import package structures (TODO)

Future codegen packages can choose if they need to depend directly on thema+cue, or if access to a more generic kind interface is sufficient.

What about the shared static cuecontext?

This can still exist and work for thema based kinds. This context currently acts as a global registry -- in the future it could only be used to get access to cue based kinds.

ryantxu commented 1 year ago

I think the Resource interface will need some revisiting as we go on

Yes absolutely! my goal here was changing it as little as possible, because that is a project in itself.

joanlopez commented 1 year ago

Hey @ryantxu, what do you thing is still strictly needed to get this PR ready to merge? I see there's a (large) TODO list in PR's description, is that accurate? I'll be happy to help with any specific action to get it merged!