generator

package
v0.0.0-...-74b6dd6 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NewLine = "\n"
	Tab     = "\t"
)

Variables

This section is empty.

Functions

func CreateOrRewrite

func CreateOrRewrite(tmpl *template.Template, config *Controller) (err error)

func CreateOrRewriteDeepCopy

func CreateOrRewriteDeepCopy(tmpl *template.Template, config *Controller) error

func CreateOrRewriteGoMod

func CreateOrRewriteGoMod(goModTmpl *template.Template, config *Controller) (err error)

func CreateOrUpdateCustom

func CreateOrUpdateCustom(customTmpl *template.Template, config *Controller) (err error)

func RunGoModTidy

func RunGoModTidy(config *Controller) error

Types

type Controller

type Controller struct {
	Base string `yaml:"base"`
	Name string `yaml:"name"`

	Go GoConfig `yaml:"go"`

	// Enqueue   string     `yaml:"enqueue"`
	Retry     int        `yaml:"retry"`
	Namespace string     `yaml:"namespace"`
	Resources []Resource `yaml:"resources"`

	HasCustomResources bool `yaml:"-"`

	// template: controller
	//  type Controller struct {
	//      xxxLister kool.Lister           // global
	//      xxxLister kool.NamespacedLister // namespaced
	//  }
	ListerFields []string `yaml:"-"`

	// template: controller
	//  type Controller struct {
	//      xxxHasSynced cache.InformerSynced // common
	//  }
	HasSyncedFields []string `yaml:"-"`

	// template: controller
	//  c.xxxLister := xxxInformer.Lister()             // common
	//  c.xxxSynced := xxxInformer.Informer().HasSynced // common
	StructFieldInits []string `yaml:"-"`

	// template: main
	//  xxxInformer := kool.NewInformer           // global
	//  xxxInformer := kool.NewNamespacedInformer // namespaced
	InformerInits []string `yaml:"-"`

	// template: main
	//  go c.xxxInformer.Informer().Run(ctx.Done())
	InformerRuns []string `yaml:"-"`

	// template: controller
	//  func NewController(
	//      xxxInformer kool.Informer,           // global
	//      xxxInformer kool.NamespacedInformer, // namespaced
	//  )
	NewControllerArgs []string `yaml:"-"`

	Imports []string `yaml:"-"`
}

func ReadConfig

func ReadConfig(filepath string) (*Controller, error)

func ReadConfigFromReader

func ReadConfigFromReader(reader io.Reader) (*Controller, error)

func (*Controller) InitAndValidate

func (c *Controller) InitAndValidate() error

type GoConfig

type GoConfig struct {
	Module        string
	Version       string
	K8sAPIVersion string `yaml:"k8sAPIVersion"`
}

type Resource

type Resource struct {
	Group       string
	SchemaGroup string `yaml:"-"`
	Version     string
	Kind        string

	Package string

	Template     Template
	IsCustom     bool `yaml:"isCustom"`
	IsNamespaced bool `yaml:"isNamespaced"`

	LowerKind string `yaml:"-"`
	GoType    string `yaml:"-"`
}

type Template

type Template int8
const (
	TemplateNone Template = iota
	TemplateDefinition
	TemplateDeepCopy
	TemplateBoth
)

Jump to

Keyboard shortcuts

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