Help us shape the future of Go! Take the 2026 Go Developer Survey

flux

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 21 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, components ...string) ([]byte, error)

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

func Components added in v0.1.7

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

Components returns the kustomize Components under dir, built only by what includes them.

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 includes: the overlays to build. Components are left out; dir itself is always a 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, components ...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.

func (*Index) KustomizationFor added in v0.1.6

func (ix *Index) KustomizationFor(root, dir string) *Object

KustomizationFor returns the Flux Kustomization whose spec.path is closest above dir.

func (*Index) Vars added in v0.1.6

func (ix *Index) Vars(ks *Object) (map[string]string, []string)

Vars returns the postBuild variables of a Flux Kustomization, with notes on sources it could not read.

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, components ...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
	// Placeholders are the targetPaths of valuesFrom sources not in the repository.
	Placeholders [][]string
	// Skip is why the release cannot be analyzed yet; it is reported, not rendered.
	Skip 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
	// Namespace replaces the releases' own, like a Kustomization's targetNamespace.
	Namespace string
	// Origin is the origin remote of the checkout; a GitRepository with another URL is not here.
	Origin string
}

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