thema icon indicating copy to clipboard operation
thema copied to clipboard

Plan out a path for converting a Thema lineage to a CRD

Open sdboyer opened this issue 2 years ago • 1 comments

The Thema tutorials lay out how to map a Thema lineage to a LineageFactory, which forms a bridge from the literal lineage written in CUE to what's written in Go. The tutorials then continue on to create an InputKernel, which is one way of using Thema from Go programs.

However, that's not terribly helpful for the use case of Thema-as-Operator-framework - or at least, it doesn't seem that way right now. In that case, we want to go from a Lineage to a Go expression of a CRD, and the relevant necessary components on the Go side (controllers, Go types...?). i'm reasonably sure this can be done generically, which is why this issue is here, rather than in grafana/grafana.

This is a bit of a counterpart to grafana/grafana#44242, but that's just the tracker for where we're prototyping.

Would welcome input or just a "hey i'd like to help figure this out" from anyone so inclined :)

sdboyer avatar Jan 20 '22 13:01 sdboyer

candidates for auto-generated Go side components are:

  • the runtime.Objects of the custom resource, like the following:
type CR struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   Model       `json:"spec,omitempty"`
	Status ModelStatus `json:"status,omitempty"`
}

type CRList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []CR `json:"items"`
}
  • and their DeepCopyObject() implementations

papagian avatar Feb 10 '22 17:02 papagian