thema

package
v0.17.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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

func ModelsGenerator() *codejen.JennyList[kindsys.Custom]

ModelsGenerator returns a Generator which will produce Go and CUE files for API contract models

func OperatorGenerator

func OperatorGenerator(projectRepo, codegenPath string) *codejen.JennyList[kindsys.Custom]

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() *codejen.JennyList[kindsys.Custom]

func TypeScriptModelsGenerator

func TypeScriptModelsGenerator() *codejen.JennyList[kindsys.Custom]

TypeScriptModelsGenerator returns a Generator which generates TypeScript model code

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

func NewCustomKindParser(rt *thema.Runtime, modFS fs.FS) (*CustomKindParser, error)

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.

func Filter

func Filter(g Generator, filterFunc func(kindsys.Custom) bool) FilteredGenerator

Filter wraps a Generator to create a FilteredGenerator, using the supplied filterFunc to create the Allowed and Filter functions of the FilteredGenerator.

type Generator

type Generator interface {
	Generate(objs ...kindsys.Custom) (codejen.Files, error)
}

Generator is an interface which describes any code generator that can be passed to a Parser, such as CustomKindParser.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(rt *thema.Runtime) (*Parser, error)

func (*Parser) Parse

func (p *Parser) Parse(modFS fs.FS, selectors ...string) ([]kindsys.Custom, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL