sample

package
v1.42.3 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: Apache-2.0 Imports: 3 Imported by: ? 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator is a utility that can be used to generate multiple samples at a time. A Generator can be configured to run only specific subcommands for the samples via GeneratorOptions functions

func NewGenerator

func NewGenerator(opts ...GeneratorOptions) *Generator

NewGenerator creates a new Generator. The returned Generator can be configured with GeneratorOptions functions. By default the Generator that is returned will be set to run all Generate functions of a Sample (GenerateInit, GenerateApi, GenerateWebhook)

func (*Generator) GenerateSamples

func (g *Generator) GenerateSamples(samples ...Sample) error

GenerateSamples will perform the generation logic for a list of Samples based on the Generator configuration

type GeneratorHook

type GeneratorHook func(Sample)

GeneratorHook is a function that takes in a sample and represents a function that gets called in a Pre/Post hook for different stages of sample generation

type GeneratorOptions

type GeneratorOptions func(g *Generator)

GeneratorOptions is a type of function that is used to configure a Generator

func WithNoApi

func WithNoApi() GeneratorOptions

WithNoApi will configure a Generator to not run the GenerateApi function of a Sample

func WithNoInit

func WithNoInit() GeneratorOptions

WithNoInit will configure a Generator to not run the GenerateInit function of a Sample

func WithNoWebhook

func WithNoWebhook() GeneratorOptions

WithNoWebhook will configure a Generator to not run the GenerateWebhook function of a Sample

func WithPostApiHook

func WithPostApiHook(hook GeneratorHook) GeneratorOptions

WithPostApiHook will configure a Generator to run the given GeneratorHook after executing the GenerateApi function of a Sample

func WithPostInitHook

func WithPostInitHook(hook GeneratorHook) GeneratorOptions

WithPostInitHook will configure a Generator to run the given GeneratorHook after executing the GenerateInit function of a Sample

func WithPostWebhookHook

func WithPostWebhookHook(hook GeneratorHook) GeneratorOptions

WithPostWebhookHook will configure a Generator to run the given GeneratorHook after executing the GenerateWebhook function of a Sample

func WithPreApiHook

func WithPreApiHook(hook GeneratorHook) GeneratorOptions

WithPreApiHook will configure a Generator to run the given GeneratorHook before executing the GenerateApi function of a Sample

func WithPreInitHook

func WithPreInitHook(hook GeneratorHook) GeneratorOptions

WithPreInitHook will configure a Generator to run the given GeneratorHook before executing the GenerateInit function of a Sample

func WithPreWebhookHook

func WithPreWebhookHook(hook GeneratorHook) GeneratorOptions

WithPreWebhookHook will configure a Generator to run the given GeneratorHook before executing the GenerateWebhook function of a Sample

type Sample

type Sample interface {
	// CommandContext returns the CommandContext that the Sample is using
	CommandContext() command.CommandContext
	// Name returns the name of the Sample
	Name() string
	// GVKs return an array of GVKs that are used when generating the apis and webhooks for the Sample
	GVKs() []schema.GroupVersionKind
	// Domain returs the domain of the sample
	Domain() string
	// Dir returns the directory the sample is created in
	Dir() string
	// Binary returns the binary that is used when creating a sample
	Binary() string
	// GenerateInit scaffolds using the `init` subcommand
	GenerateInit() error
	// GenerateApi scaffolds using the `create api` subcommand
	GenerateApi() error
	// GenerateWebhook scaffolds using the `create webhook` subcommand
	GenerateWebhook() error
}

Sample represents a sample project that can be created and used for testing

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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