generators

package
v1.8.9 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPluginRequeueAfter = 30 * time.Minute
)
View Source
const (
	DefaultPullRequestRequeueAfter = 30 * time.Minute
)
View Source
const (
	DefaultRequeueAfter = 3 * time.Minute
)
View Source
const (
	DefaultSCMProviderRequeueAfter = 30 * time.Minute
)

Variables

View Source
var (
	ErrEmptyAppSetGenerator = errors.New("ApplicationSet is empty")
	NoRequeueAfter          time.Duration
)
View Source
var (
	ErrMoreThanTwoGenerators      = errors.New("found more than two generators, Matrix support only two")
	ErrLessThanTwoGenerators      = errors.New("found less than two generators, Matrix support only two")
	ErrMoreThenOneInnerGenerators = errors.New("found more than one generator in matrix.Generators")
)
View Source
var (
	ErrLessThanTwoGeneratorsInMerge = errors.New("found less than two generators, Merge requires two or more")
	ErrNoMergeKeys                  = errors.New("no merge keys were specified, Merge requires at least one")
	ErrNonUniqueParamSets           = errors.New("the parameters from a generator were not unique by the given mergeKeys, Merge requires all param sets to be unique")
)
View Source
var ErrSCMProvidersDisabled = errors.New("scm providers are disabled")

Functions

func GetGenerators

func GetGenerators(ctx context.Context, c client.Client, k8sClient kubernetes.Interface, controllerNamespace string, repoService services.Repos, dynamicClient dynamic.Interface, scmConfig SCMConfig, clusterInformer *settings.ClusterInformer) map[string]Generator

func InterpolateGenerator

func InterpolateGenerator(requestedGenerator *v1alpha1.ApplicationSetGenerator, params map[string]any, useGoTemplate bool, goTemplateOptions []string) (v1alpha1.ApplicationSetGenerator, error)

InterpolateGenerator allows interpolating the matrix's 2nd child generator with values from the 1st child generator "params" parameter is an array, where each index corresponds to a generator. Each index contains a map w/ that generator's parameters.

func ScmProviderAllowed

func ScmProviderAllowed(applicationSetInfo *v1alpha1.ApplicationSet, generator SCMGeneratorWithCustomApiUrl, allowedScmProviders []string) error

Types

type ClusterGenerator

type ClusterGenerator struct {
	client.Client
	// contains filtered or unexported fields
}

ClusterGenerator generates Applications for some or all clusters registered with Hanzo CD.

func (*ClusterGenerator) GenerateParams

func (g *ClusterGenerator) GenerateParams(appSetGenerator *v1alpha1.ApplicationSetGenerator, appSet *v1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error)

func (*ClusterGenerator) GetRequeueAfter

GetRequeueAfter never requeue the cluster generator because the `clusterSecretEventHandler` will requeue the appsets when the cluster secrets change

func (*ClusterGenerator) GetTemplate

type DuckTypeGenerator

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

DuckTypeGenerator generates Applications for some or all clusters registered with Hanzo CD.

func (*DuckTypeGenerator) GenerateParams

func (g *DuckTypeGenerator) GenerateParams(appSetGenerator *v1alpha1.ApplicationSetGenerator, appSet *v1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error)

func (*DuckTypeGenerator) GetRequeueAfter

func (g *DuckTypeGenerator) GetRequeueAfter(appSetGenerator *v1alpha1.ApplicationSetGenerator) time.Duration

func (*DuckTypeGenerator) GetTemplate

type ErrDisallowedSCMProvider

type ErrDisallowedSCMProvider struct {
	Provider string
	Allowed  []string
}

func NewErrDisallowedSCMProvider

func NewErrDisallowedSCMProvider(provider string, allowed []string) ErrDisallowedSCMProvider

func (ErrDisallowedSCMProvider) Error

func (e ErrDisallowedSCMProvider) Error() string

type Generator

type Generator interface {
	// GenerateParams interprets the ApplicationSet and generates all relevant parameters for the application template.
	// The expected / desired list of parameters is returned, it then will be render and reconciled
	// against the current state of the Applications in the cluster.
	GenerateParams(appSetGenerator *v1alpha1.ApplicationSetGenerator, applicationSetInfo *v1alpha1.ApplicationSet, client client.Client) ([]map[string]any, error)

	// GetRequeueAfter is the generator can controller the next reconciled loop
	// In case there is more then one generator the time will be the minimum of the times.
	// In case NoRequeueAfter is empty, it will be ignored
	GetRequeueAfter(appSetGenerator *v1alpha1.ApplicationSetGenerator) time.Duration

	// GetTemplate returns the inline template from the spec if there is any, or an empty object otherwise
	GetTemplate(appSetGenerator *v1alpha1.ApplicationSetGenerator) *v1alpha1.ApplicationSetTemplate
}

Generator defines the interface implemented by all ApplicationSet generators.

func GetRelevantGenerators

func GetRelevantGenerators(requestedGenerator *v1alpha1.ApplicationSetGenerator, generators map[string]Generator) []Generator

func NewClusterGenerator

func NewClusterGenerator(c client.Client, namespace string) Generator

func NewDuckTypeGenerator

func NewDuckTypeGenerator(ctx context.Context, dynClient dynamic.Interface, clientset kubernetes.Interface, namespace string, clusterInformer *settings.ClusterInformer) Generator

func NewGitGenerator

func NewGitGenerator(repos services.Repos, controllerNamespace string) Generator

NewGitGenerator creates a new instance of Git Generator

func NewListGenerator

func NewListGenerator() Generator

func NewMatrixGenerator

func NewMatrixGenerator(supportedGenerators map[string]Generator) Generator

func NewMergeGenerator

func NewMergeGenerator(supportedGenerators map[string]Generator) Generator

NewMergeGenerator returns a MergeGenerator which allows the given supportedGenerators as child generators.

func NewPluginGenerator

func NewPluginGenerator(client client.Client, namespace string) Generator

func NewPullRequestGenerator

func NewPullRequestGenerator(client client.Client, scmConfig SCMConfig) Generator

func NewSCMProviderGenerator

func NewSCMProviderGenerator(client client.Client, scmConfig SCMConfig) Generator

func NewTestSCMProviderGenerator

func NewTestSCMProviderGenerator(overrideProvider scm_provider.SCMProviderService) Generator

Testing generator

type GitGenerator

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

func (*GitGenerator) GenerateParams

func (g *GitGenerator) GenerateParams(appSetGenerator *v1alpha1.ApplicationSetGenerator, appSet *v1alpha1.ApplicationSet, client client.Client) ([]map[string]any, error)

GenerateParams generates a list of parameter maps for the ApplicationSet by evaluating the Git generator's configuration. It supports both directory-based and file-based Git generators.

func (*GitGenerator) GetRequeueAfter

func (g *GitGenerator) GetRequeueAfter(appSetGenerator *v1alpha1.ApplicationSetGenerator) time.Duration

GetRequeueAfter returns the duration after which the Git generator should be requeued for reconciliation. If RequeueAfterSeconds is set in the generator spec, it uses that value. Otherwise, it falls back to a default requeue interval (3 minutes).

func (*GitGenerator) GetTemplate

GetTemplate returns the ApplicationSetTemplate associated with the Git generator from the provided ApplicationSetGenerator. This template defines how each generated Hanzo CD Application should be rendered.

type ListGenerator

type ListGenerator struct{}

func (*ListGenerator) GenerateParams

func (g *ListGenerator) GenerateParams(appSetGenerator *v1alpha1.ApplicationSetGenerator, appSet *v1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error)

func (*ListGenerator) GetRequeueAfter

func (*ListGenerator) GetTemplate

type MatrixGenerator

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

func (*MatrixGenerator) GenerateParams

func (m *MatrixGenerator) GenerateParams(appSetGenerator *v1alpha1.ApplicationSetGenerator, appSet *v1alpha1.ApplicationSet, client client.Client) ([]map[string]any, error)

func (*MatrixGenerator) GetRequeueAfter

func (m *MatrixGenerator) GetRequeueAfter(appSetGenerator *v1alpha1.ApplicationSetGenerator) time.Duration

func (*MatrixGenerator) GetTemplate

type MergeGenerator

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

func (*MergeGenerator) GenerateParams

func (m *MergeGenerator) GenerateParams(appSetGenerator *v1alpha1.ApplicationSetGenerator, appSet *v1alpha1.ApplicationSet, client client.Client) ([]map[string]any, error)

GenerateParams gets the params produced by the MergeGenerator.

func (*MergeGenerator) GetRequeueAfter

func (m *MergeGenerator) GetRequeueAfter(appSetGenerator *v1alpha1.ApplicationSetGenerator) time.Duration

func (*MergeGenerator) GetTemplate

GetTemplate gets the Template field for the MergeGenerator.

type PluginGenerator

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

func (*PluginGenerator) GenerateParams

func (g *PluginGenerator) GenerateParams(appSetGenerator *v1alpha1.ApplicationSetGenerator, applicationSetInfo *v1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error)

func (*PluginGenerator) GetRequeueAfter

func (g *PluginGenerator) GetRequeueAfter(appSetGenerator *v1alpha1.ApplicationSetGenerator) time.Duration

func (*PluginGenerator) GetTemplate

type PullRequestGenerator

type PullRequestGenerator struct {
	SCMConfig
	// contains filtered or unexported fields
}

func (*PullRequestGenerator) GenerateParams

func (g *PullRequestGenerator) GenerateParams(appSetGenerator *v1alpha1.ApplicationSetGenerator, applicationSetInfo *v1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error)

func (*PullRequestGenerator) GetContinueOnRepoNotFoundError

func (g *PullRequestGenerator) GetContinueOnRepoNotFoundError(appSetGenerator *v1alpha1.ApplicationSetGenerator) bool

func (*PullRequestGenerator) GetRequeueAfter

func (g *PullRequestGenerator) GetRequeueAfter(appSetGenerator *v1alpha1.ApplicationSetGenerator) time.Duration

func (*PullRequestGenerator) GetTemplate

type SCMConfig

type SCMConfig struct {
	GitHubApps github_app_auth.Credentials
	// contains filtered or unexported fields
}

func NewSCMConfig

func NewSCMConfig(scmRootCAPath string, allowedSCMProviders []string, enableSCMProviders bool, enableGitHubAPIMetrics bool, gitHubApps github_app_auth.Credentials, tokenRefStrictMode bool, opts ...SCMConfigOpts) SCMConfig

type SCMConfigOpts

type SCMConfigOpts func(c *SCMConfig)

func WithNoProxyList

func WithNoProxyList(noProxyList string) SCMConfigOpts

func WithProxyURL

func WithProxyURL(scmProxyURL string) SCMConfigOpts

type SCMGeneratorWithCustomApiUrl

type SCMGeneratorWithCustomApiUrl interface {
	CustomApiUrl() string
}

type SCMProviderGenerator

type SCMProviderGenerator struct {
	SCMConfig
	// contains filtered or unexported fields
}

func (*SCMProviderGenerator) GenerateParams

func (g *SCMProviderGenerator) GenerateParams(appSetGenerator *v1alpha1.ApplicationSetGenerator, applicationSetInfo *v1alpha1.ApplicationSet, _ client.Client) ([]map[string]any, error)

func (*SCMProviderGenerator) GetRequeueAfter

func (g *SCMProviderGenerator) GetRequeueAfter(appSetGenerator *v1alpha1.ApplicationSetGenerator) time.Duration

func (*SCMProviderGenerator) GetTemplate

type TransformResult

type TransformResult struct {
	Params   []map[string]any
	Template v1alpha1.ApplicationSetTemplate
}

func Transform

func Transform(requestedGenerator v1alpha1.ApplicationSetGenerator, allGenerators map[string]Generator, baseTemplate v1alpha1.ApplicationSetTemplate, appSet *v1alpha1.ApplicationSet, genParams map[string]any, client client.Client) ([]TransformResult, error)

Transform a spec generator to list of paramSets and a template

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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