gen

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Code adapted from: https://github.com/kubernetes-sigs/controller-tools/blob/6eef398/cmd/controller-gen/main.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCache

func GetCache() afero.Fs

GetCache gets the singleton cache instance.

Types

type Config

type Config struct {
	// OperatorName is the operator's name, ex. app-operator
	OperatorName string
	// Inputs is an arbitrary map of keys to paths that an individual generator
	// understands. Keys are exported by the generator's package if any inputs
	// are required. Inputs is meant to be flexible in the case that multiple
	// on-disk inputs are required. If not set, a default is used on a
	// per-generator basis.
	Inputs map[string]string
	// OutputDir is a dir in which to generate output files. If not set, a
	// default is used on a per-generator basis.
	OutputDir string
	// Filters is a set of functional filters for paths that a generator may
	// encounter while gathering data for generation. Filters provides
	// fine-grained control over Inputs, since often those paths are often
	// top-level directories.
	Filters FilterFuncs
}

Config configures a generator with common operator project information.

type FilterFuncs

type FilterFuncs []func(string) bool

FilterFuncs is a slice of filter funcs.

func MakeFilters

func MakeFilters(paths ...string) (filters FilterFuncs)

MakeFilters creates a set of closures around each path in paths. If the argument to a closure has a prefix of path, it returns true.

func (FilterFuncs) SatisfiesAny

func (funcs FilterFuncs) SatisfiesAny(path string) bool

SatisfiesAny returns true if path passes any filter in funcs.

type Generator

type Generator interface {
	// Generate invokes the Generator, usually writing a file to disk or memory
	// depending on what output rules are set.
	Generate() error
}

Generator can generate artifacts using data contained in the Generator.

type OutputToCachedDirectory

type OutputToCachedDirectory struct {
	Dir string
}

OutputToCachedDirectory configures a generator runtime to output files to a directory. The output option rule string is formatted as follows:

- output:<generator>:<form>:dir (per-generator output) - output:<form>:dir (default output)

where <generator> is the generator's registered string name and <form> is the output rule's registered form string. See the CRD generator for an example of how this is used.

func (OutputToCachedDirectory) Open

Open is used to generate a CRD manifest in cache at path.

type Runner

type Runner interface {
	// AddOutputRule associates an OutputRule with a definition name in the
	// Runner's generator.
	AddOutputRule(string, genall.OutputRule)
	// Run creates a generator runtime by passing in rawOpts, a raw set of option
	// strings, and invokes the runtime.
	Run([]string) error
}

Runner runs a generator.

func NewCachedRunner

func NewCachedRunner() Runner

NewCachedRunner returns a cachedRunner with a set of default generators and output rules. The returned cachedRunner is lazily initialized.

Jump to

Keyboard shortcuts

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