flux

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package flux reads Flux HelmReleases and turns them into chart + values targets, resolving their sources, valuesFrom and kustomize overlays.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(dir string, vars map[string]string) ([]byte, error)

Build runs kustomize on dir in process, the way Flux's kustomize-controller does, and applies ${var} substitution to the output.

func Get

func Get(n *yaml.Node, path ...string) *yaml.Node

Get walks a mapping node by keys and returns the value node.

func IsKustomizeDir

func IsKustomizeDir(dir string) bool

IsKustomizeDir reports whether dir holds a kustomization file.

func IsRelease

func IsRelease(o *Object) bool

IsRelease reports whether o is a full HelmRelease. Partial HelmReleases used as kustomize patches have neither chart nor chartRef.

func Roots

func Roots(dir string) ([]string, error)

Roots returns the kustomize directories under dir that no other kustomization under dir includes: the overlays to build. When dir itself is a kustomize directory it is the only root.

func Str

func Str(n *yaml.Node, path ...string) string

func Substitute

func Substitute(data []byte, vars map[string]string) []byte

Substitute applies Flux postBuild-style ${var} and ${var:=default} substitution. Unknown variables without a default are left as they are.

func Tree

func Tree(dir string) []string

Tree returns the local files that make up the build of dir, in kustomize order: resources (recursively) first, then patches.

Types

type Attributor

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

Attributor traces keys of a built HelmRelease back to the files of the build that set them: the base release and every patch, in kustomize order.

func NewAttributor

func NewAttributor(files []string, vars map[string]string) *Attributor

func (*Attributor) File

func (a *Attributor) File(rel *Object) string

File returns the file holding the base definition of the release.

func (*Attributor) Origins

func (a *Attributor) Origins(rel *Object, path []string) []values.Origin

Origins lists every file of the build whose HelmRelease sets spec.values.<path>.

type Index

type Index struct {
	Objects []*Object
}

func IndexRepo

func IndexRepo(root string, vars map[string]string) (*Index, error)

IndexRepo indexes every object of every YAML file under root, plus the ConfigMaps declared by configMapGenerator entries. Files that are not valid YAML (Helm templates, for instance) are skipped.

func (*Index) Find

func (ix *Index) Find(kind, name, namespace, near string) *Object

Find returns the object of that kind and name. An object without a namespace matches any namespace (kustomize may set it later). When several match, ConfigMaps from a generator win, then the object whose file is closest to near.

type Object

type Object struct {
	APIVersion string
	Kind       string
	Name       string
	Namespace  string
	// File is empty for objects that only exist in a build output.
	File string
	Doc  int
	Node *yaml.Node
	// Gen is set for ConfigMaps produced by a kustomize configMapGenerator:
	// data key -> source file.
	Gen map[string]string
}

Object is one Kubernetes object found in the repository or in a kustomize build output.

func ParseFile

func ParseFile(path string, vars map[string]string) ([]*Object, error)

ParseFile reads every object of a YAML file, after ${var} substitution.

func ParseYAML

func ParseYAML(data []byte) ([]*Object, error)

ParseYAML reads every object of a YAML stream, such as a build output.

func TreeGenerators

func TreeGenerators(dir string) []*Object

TreeGenerators returns the ConfigMaps declared by configMapGenerator entries anywhere in dir's build.

func (*Object) ID

func (o *Object) ID() string

type Release

type Release struct {
	Object      *Object
	ID          string
	Chart       source.Ref
	ReleaseName string
	Namespace   string
	Values      *values.Set
	Notes       []string
}

type Resolver

type Resolver struct {
	RepoRoot string
	Sources  *Index
	// Fallback is searched when Sources has no match, e.g. the whole
	// repository when Sources is a kustomize build output.
	Fallback  *Index
	Attribute func(rel *Object, path []string) []values.Origin
}

Resolver turns HelmRelease objects into releases. Sources, ConfigMaps and Secrets are looked up in Sources. In build mode the HelmRelease comes from a kustomize output and Attribute traces its values back to files.

func (*Resolver) Resolve

func (r *Resolver) Resolve(rel *Object) (*Release, error)

Jump to

Keyboard shortcuts

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