structs

package
v0.31.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootStructNameGeneralConfig = "GeneralConfig"
	RootStructNameSecretsConfig = "SecretsConfig"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Name,
	Type,
	Doc string

	Embedded bool

	DefaultValue string

	// Required and EnumOptions are derived from the `validate` struct tag:
	// Required from a top-level `required` or `notblank` rule (false when
	// `omitempty` is present), EnumOptions from a top-level `oneof=a b c`
	// rule. Rules after a `dive` govern slice/map elements, not the field
	// itself, and are ignored by both.
	Required    bool
	EnumOptions []string
}

func NewFieldFromAST

func NewFieldFromAST(ctx context.Context, imports map[string]string, node *ast.Field) Field

type Struct

type Struct struct {
	Name,
	Doc string

	Fields []Field
}

func NewStructFromAST

func NewStructFromAST(ctx context.Context,
	imports map[string]string,
	declarationsNode *ast.GenDecl,
	typeDeclarationNode *ast.TypeSpec,
	structDeclarationNode *ast.StructType,
) *Struct

type Structs

type Structs struct {
	// GeneralConfig and SecretsConfig are called the root structs,
	// corresponding to the general.yaml and secrets.yaml files respectively.
	Roots []*Struct

	All map[string]*Struct
}

func NewStructsFromAST

func NewStructsFromAST(ctx context.Context, imports map[string]string, node ast.Node) *Structs

func (*Structs) ResolveEmbeddedStructFields

func (structs *Structs) ResolveEmbeddedStructFields()

For each struct, we remove the embedded struct fields, and add the corresponding promoted fields.

Iterates structs.Sorted rather than structs.All directly: a struct that both embeds another and is itself embedded elsewhere (e.g. AutoScalableNodeGroup, embedded by AzureAutoScalableNodeGroup) resolves differently depending on whether it has already been mutated by this same loop when a later struct promotes its fields — map iteration order is randomized per run, so that dependency must go through a deterministic order instead.

func (*Structs) Sorted

func (structs *Structs) Sorted() []*Struct

Sorted returns all structs sorted alphabetically by name.

Jump to

Keyboard shortcuts

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