generator

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MPL-2.0 Imports: 20 Imported by: 0

README

Argo CD Generators

This directory contains the code for Argo CD generators. Generators dynamically create Kubernetes resources from various sources of truth, such as Kustomize, Helm, Ksonnet, and others. They are a key component in Argo CD for automating resource creation and management.

Overview

Generators in Argo CD enable the dynamic generation of Kubernetes manifests based on the desired state defined in different configurations. By leveraging these generators, Argo CD can efficiently manage and deploy resources across different environments.

Why Forked?

This code is a fork of the Argo CD (v2.12) generator code. The fork was necessary due to an incompatibility between Kubechecks' use of the go-gitlab library and Argo CD's generator code. To resolve this, the generator code has been forked and adapted for compatibility with Kubechecks.

Supported Generators

  • Lists
  • Clusters

Unsupported Generators

  • Git
  • Pull Requests

Usage

You can use these generators to automate the creation and management of Kubernetes resources in your environment, ensuring consistency and repeatability.

Documentation

Index

Constants

View Source
const (
	ArgoCDSecretTypeLabel   = "argocd.argoproj.io/secret-type"
	ArgoCDSecretTypeCluster = "cluster"
)

Variables

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

Functions

func InterpolateGenerator

func InterpolateGenerator(requestedGenerator *argoprojiov1alpha1.ApplicationSetGenerator, params map[string]interface{}, useGoTemplate bool, goTemplateOptions []string) (argoprojiov1alpha1.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.

Types

type AppsGenerator

type AppsGenerator interface {
	GenerateApplicationSetApps(ctx context.Context, appset argov1alpha1.ApplicationSet, ctr *container.Container) ([]argov1alpha1.Application, error)
}

func New

func New() AppsGenerator

type ClusterGenerator

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

ClusterGenerator generates Applications for some or all clusters registered with ArgoCD.

func (*ClusterGenerator) GenerateParams

func (g *ClusterGenerator) GenerateParams(appSetGenerator *argoappsetv1alpha1.ApplicationSetGenerator, appSet *argoappsetv1alpha1.ApplicationSet) ([]map[string]interface{}, 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 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 *argoprojiov1alpha1.ApplicationSetGenerator, applicationSetInfo *argoprojiov1alpha1.ApplicationSet) ([]map[string]interface{}, 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 *argoprojiov1alpha1.ApplicationSetGenerator) time.Duration

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

Generator defines the interface implemented by all ApplicationSet generators.

func GetRelevantGenerators

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

func NewClusterGenerator

func NewClusterGenerator(c client.Client, ctx context.Context, clientset kubernetes.Interface, namespace string) 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.

type ListGenerator

type ListGenerator struct {
}

func (*ListGenerator) GenerateParams

func (g *ListGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, appSet *argoprojiov1alpha1.ApplicationSet) ([]map[string]interface{}, error)

func (*ListGenerator) GetRequeueAfter

func (g *ListGenerator) GetRequeueAfter(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator) time.Duration

type MatrixGenerator

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

func (*MatrixGenerator) GenerateParams

func (m *MatrixGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, appSet *argoprojiov1alpha1.ApplicationSet) ([]map[string]interface{}, error)

func (*MatrixGenerator) GetRequeueAfter

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

func (*MatrixGenerator) GetTemplate

type MergeGenerator

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

func (*MergeGenerator) GenerateParams

func (m *MergeGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator, appSet *argoprojiov1alpha1.ApplicationSet) ([]map[string]interface{}, error)

GenerateParams gets the params produced by the MergeGenerator.

func (*MergeGenerator) GetRequeueAfter

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

func (*MergeGenerator) GetTemplate

GetTemplate gets the Template field for the MergeGenerator.

type TransformResult

type TransformResult struct {
	Params   []map[string]interface{}
	Template argoprojiov1alpha1.ApplicationSetTemplate
}

func Transform

func Transform(requestedGenerator argoprojiov1alpha1.ApplicationSetGenerator, allGenerators map[string]Generator, baseTemplate argoprojiov1alpha1.ApplicationSetTemplate, appSet *argoprojiov1alpha1.ApplicationSet, genParams map[string]interface{}) ([]TransformResult, error)

Transform a spec generator to list of paramSets and a template

Jump to

Keyboard shortcuts

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