Documentation ¶
Index ¶
- Constants
- func BackendPluginGenerator(projectRepo, generatedAPIPath string) *codejen.JennyList[kindsys.Custom]
- func CRDGenerator(outputEncoder jennies.CRDOutputEncoder, outputExtension string) *codejen.JennyList[kindsys.Custom]
- func ModelsGenerator() *codejen.JennyList[kindsys.Custom]
- func OperatorGenerator(projectRepo, codegenPath string) *codejen.JennyList[kindsys.Custom]
- func ResourceGenerator() *codejen.JennyList[kindsys.Custom]
- func TypeScriptModelsGenerator() *codejen.JennyList[kindsys.Custom]
- type CustomKindParser
- func (g *CustomKindParser) FilteredGenerate(generator FilteredGenerator, selectors ...string) (codejen.Files, error)
- func (g *CustomKindParser) Generate(generator Generator, selectors ...string) (codejen.Files, error)
- func (g *CustomKindParser) ListAllMainSelectors() ([]string, error)
- func (g *CustomKindParser) Validate(selectors ...string) (map[string]multierror.Error, error)
- type FilteredGenerator
- type Generator
- type Parser
Constants ¶
const ( CustomTargetResource = "resource" CustomTargetModel = "model" )
Variables ¶
This section is empty.
Functions ¶
func BackendPluginGenerator ¶
func BackendPluginGenerator(projectRepo, generatedAPIPath string) *codejen.JennyList[kindsys.Custom]
BackendPluginGenerator returns a Generator which will produce boilerplate backend plugin code
func CRDGenerator ¶
func CRDGenerator(outputEncoder jennies.CRDOutputEncoder, outputExtension string) *codejen.JennyList[kindsys.Custom]
CRDGenerator returns a Generator which will create a CRD file
func ModelsGenerator ¶
ModelsGenerator returns a Generator which will produce Go and CUE files for API contract models
func OperatorGenerator ¶
OperatorGenerator returns a Generator which will build out watcher boilerplate for each resource, and a main func to run an operator for the watchers.
Types ¶
type CustomKindParser ¶
type CustomKindParser struct {
// contains filtered or unexported fields
}
CustomKindParser allows for parsing of github.com/grafana/thema cue Lineages, encapsulated as grafana CustomStructured kinds. The parser can validate inputs for correctness, and can generate codegen metadata objects from the provided CUE and pass them off to a Generator.
The CustomKindParser currently understands only grafana CustomStructured CUE types, with plans to support Thema #CRD types in the future.
func NewCustomKindParser ¶
NewCustomKindParser creates a new CustomKindParser from the provided thema.Runtime and fs.FS. The fs should contain the cue.mod directory as well as any cue files expected to be parsed by the CustomKindParser. If thema cannot parse the provided fs.FS, an error will be returned.
func (*CustomKindParser) FilteredGenerate ¶
func (g *CustomKindParser) FilteredGenerate(generator FilteredGenerator, selectors ...string) (codejen.Files, error)
FilteredGenerate parses the provided selectors, checks the parsed object against generator.Allowed(), and passes the resulting list of filtered objects to the FilteredGenerator, returning the files created from each step. If no selectors are passed, all supported selectors will be used.
func (*CustomKindParser) Generate ¶
func (g *CustomKindParser) Generate(generator Generator, selectors ...string) (codejen.Files, error)
Generate parses the provided selectors and passes the parsed values to the Generator, returning the files created from each step. If no selectors are passed, all top-level declarations will be used.
func (*CustomKindParser) ListAllMainSelectors ¶
func (g *CustomKindParser) ListAllMainSelectors() ([]string, error)
ListAllMainSelectors returns a list of string selectors that are top-level declarations in the CUE runtime. These selectors are the ones which will be considered by default in calls to Validate, Generate, and FilteredGenerate if no selectors are supplied.
func (*CustomKindParser) Validate ¶
func (g *CustomKindParser) Validate(selectors ...string) (map[string]multierror.Error, error)
Validate validates the provided selectors, returning a map of <selector> -> <validation error list>. If no validation errors are found, len(map) will be 0. If no selectors are provided, all top-level declarations will be validated.
type FilteredGenerator ¶
type FilteredGenerator interface { Generator // Allowed returns true if the Generator can be used for this particular object Allowed(kindsys.Custom) bool }
FilteredGenerator allows a Generator to express an opinion on whether it should be used for a particular Custom-implementing type. When Allowed returns false, the Generator may return an error on Generate.