Documentation ¶
Index ¶
- Constants
- func PrefixDropper(prefix string) dstutil.ApplyFunc
- func PrefixReplacer(prefix, replace string) dstutil.ApplyFunc
- type CRDOutputEncoder
- 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
- func BackendPluginGenerator(projectRepo, generatedAPIPath string) Generator
- func CRDGenerator(outputEncoder CRDOutputEncoder, outputExtension string) Generator
- func ModelsGenerator() Generator
- func OperatorGenerator(projectRepo, codegenPath string) Generator
- func ResourceGenerator() Generator
- func TypeScriptModelsGenerator() Generator
- type TSTypesJenny
Constants ¶
const ( CustomTargetResource = "resource" CustomTargetModel = "model" )
Variables ¶
This section is empty.
Functions ¶
func PrefixDropper ¶
PrefixDropper returns a dstutil.ApplyFunc that removes the provided prefix string when it appears as a leading sequence in type names, var names, and comments in a generated Go file.
func PrefixReplacer ¶
PrefixReplacer returns a dstutil.ApplyFunc that removes the provided prefix string when it appears as a leading sequence in type names, var names, and comments in a generated Go file.
When an exact match for prefix is found, the provided replace string is substituted.
Types ¶
type CRDOutputEncoder ¶
CRDOutputEncoder is a function which marshals an object into a desired output format
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.
type Generator ¶
Generator is an interface which describes any code generator that can be passed to a Parser, such as CustomKindParser.
func BackendPluginGenerator ¶
BackendPluginGenerator returns a Generator which will produce boilerplate backend plugin code
func CRDGenerator ¶
func CRDGenerator(outputEncoder CRDOutputEncoder, outputExtension string) Generator
CRDGenerator returns a Generator which will create a CRD file
func ModelsGenerator ¶
func ModelsGenerator() Generator
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.
func ResourceGenerator ¶
func ResourceGenerator() Generator
ResourceGenerator returns a Generator which will produce Go and Cue files for using a schema for storage
func TypeScriptModelsGenerator ¶
func TypeScriptModelsGenerator() Generator
TypeScriptModelsGenerator returns a Generator which generates TypeScript model code
type TSTypesJenny ¶
type TSTypesJenny struct{}
TSTypesJenny is a [OneToOne] that produces TypeScript types and defaults for a Thema schema.
Thema's generic TS jenny will be able to replace this one once https://github.com/grafana/thema/issues/89 is complete.
func (TSTypesJenny) JennyName ¶
func (TSTypesJenny) JennyName() string