builder

package
v0.0.43 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompositionConfig added in v0.0.8

type CompositionConfig struct {
	// SourceBuilderName refers to the builder to use as a source for the
	// composition. Builders for "composable" objects will be composed into
	// this source builder following the mapping defined in the CompositionMap
	// field.
	// Note: The builder name must follow the [package].[builder_name] pattern.
	// Example: "dashboard.Panel"
	SourceBuilderName string

	// PluginDiscriminatorField contains the name of the field used to identify
	// the plugin implementing this object.
	// Example: "type", "kind", ...
	PluginDiscriminatorField string

	// Composition map describes how to perform the composition.
	// Each entry in this map associates a builder (referenced by its name)
	// to a path under witch the assignments should be performed.
	//
	// Example:
	// “`go
	// compositionMap := map[string]string{
	//   "Options": "options",
	//   "FieldConfig": "fieldConfig.defaults.custom",
	// }
	// “`
	CompositionMap map[string]string

	// ExcludeOptions lists option names to exclude in the resulting
	// composed builders.
	ExcludeOptions []string

	// ComposedBuilderName configures the name of the newly composed builders.
	// If left empty, the name is taken from SourceBuilderName.
	ComposedBuilderName string

	// PreserveOriginalBuilders ensures that builders used as part of the
	// composition process are preserved.
	// It is useful when the same builders need to be composed more than once
	// (ex: dashboard and dashboardv2 packages both use Options & FieldConfig
	// types from panels for their composition needs)
	PreserveOriginalBuilders bool

	// RenameOption is used to rename the options from the original schema in order
	// to avoid conflicts with composed builders.
	RenameOptions map[string]string
}

type Initialization

type Initialization struct {
	PropertyPath string
	Value        any
}

type RewriteRule

type RewriteRule func(schemas ast.Schemas, builders ast.Builders) (ast.Builders, error)

func AddFactory added in v0.0.25

func AddFactory(selector Selector, factory ast.BuilderFactory) RewriteRule

AddFactory adds a builder factory to the selected builders. These factories are meant to be used to simplify the instantiation of builders for common use-cases.

func AddOption

func AddOption(selector Selector, newOption veneers.Option) RewriteRule

AddOption adds a completely new option to the selected builders.

func ComposeBuilders added in v0.0.8

func ComposeBuilders(selector Selector, config CompositionConfig) RewriteRule

func Duplicate

func Duplicate(selector Selector, duplicateName string, excludeOptions []string) RewriteRule

func Initialize

func Initialize(selector Selector, statements []Initialization) RewriteRule

func MergeInto

func MergeInto(selector Selector, sourceBuilderName string, underPath string, excludeOptions []string, renameOptions map[string]string) RewriteRule

func Omit

func Omit(selector Selector) RewriteRule

func PromoteOptionsToConstructor

func PromoteOptionsToConstructor(selector Selector, optionNames []string) RewriteRule

PromoteOptionsToConstructor promotes the given options as constructor parameters. Both arguments and assignments described by the options will be exposed in the builder's constructor.

func Properties

func Properties(selector Selector, properties []ast.StructField) RewriteRule

func Rename

func Rename(selector Selector, newName string) RewriteRule

func VeneerTrailAsComments

func VeneerTrailAsComments(selector Selector) RewriteRule

type Selector

type Selector func(schemas ast.Schemas, builder ast.Builder) bool

func ByName

func ByName(pkg string, builderName string) Selector

ByName matches builders for the given name. Note: the comparison on builder name is case-insensitive.

func ByObjectName

func ByObjectName(pkg string, objectName string) Selector

ByObjectName matches builders for the given the object (referred to by its package and name). Note: the comparison on object name is case-insensitive.

func ByVariant added in v0.0.8

func ByVariant(variant ast.SchemaVariant) Selector

ByVariant matches builders defined within a schema marked as "composable" and implementing the given variant.

func EveryBuilder

func EveryBuilder() Selector

EveryBuilder accepts any given builder.

func StructGeneratedFromDisjunction

func StructGeneratedFromDisjunction() Selector

StructGeneratedFromDisjunction matches builders for structs that were generated from a disjunction (see the Disjunction compiler pass).

Jump to

Keyboard shortcuts

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