resourceset

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package resourceset renders flux-operator ResourceSet CRs offline.

A ResourceSet is a templating CRD that emits a fixed set of Kubernetes resources across a matrix of input values. flate evaluates each spec.resources / spec.resourcesTemplate entry once per input set using slim-sprig with the `<< >>` delimiter pair (so ResourceSet templates can sit inside Helm charts without delimiter conflicts).

Supported:

  • spec.inputs (in-YAML inline inputs)
  • spec.inputsFrom (ResourceSetInputProvider, Static type) — resolved via the ProviderResolver passed to Render. Dynamic providers (GitHubBranch, OCIArtifactTag, ExternalService, …) need network access flate doesn't have and contribute zero input sets.
  • spec.inputStrategy: Flatten (default) AND Permute. Permute Cartesian-products inputs across providers and scopes each under its normalized name; templates access values via `inputs.<provider>.foo`. ID generation matches upstream's adler32 scheme so renders are byte-equivalent to flux-operator output. Capped at 10000 permutations.
  • spec.resources (typed JSON template list)
  • spec.resourcesTemplate (multi-document YAML string)
  • spec.commonMetadata (labels + annotations applied to every emitted object)
  • Deduplication by (apiVersion, kind, namespace, name)
  • Default-namespace fallback to the ResourceSet's own namespace

Deferred:

  • fluxcd.controlplane.io/copyFrom / convertKubeConfigFrom / checksumFrom annotations — those need live cluster data flate does not have.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DedupKey

func DedupKey(doc map[string]any) string

DedupKey identifies a rendered doc by (apiVersion, kind, namespace, name) for cross-render deduplication. Returns "" when kind or name are missing — signal to the caller to drop the doc rather than merge with an "empty key" collision pile.

Exported so the orchestrator's post-Run RS-extension pass can share the same identity rule as the in-package RS render — without that, a name-grouped RS that emits the same child from two namespace variants could land both copies in the parent KS's extension list.

func MatchSelector

func MatchSelector(sel *metav1.LabelSelector, lbls map[string]string) (bool, error)

MatchSelector returns true when sel matches lbls. Helper for ProviderResolver implementations that filter by InputProviderReference.Selector.

func Render

func Render(rs *manifest.ResourceSet, resolve ProviderResolver) ([]map[string]any, error)

Render evaluates rs.Spec across rs.Spec.Inputs (flatten strategy) and returns the resulting Kubernetes manifests as decoded YAML documents, already deduplicated and stamped with rs.Spec.CommonMetadata. The caller is responsible for parsing each doc into a typed manifest.

When rs.Spec.Inputs is empty (e.g. d2-fleet's policies.yaml — static resources with no matrix), templates render once with a nil input set.

resolve is optional: when non-nil, spec.inputsFrom references are resolved and their providers' exported inputs are flattened into the matrix alongside any inline rs.Spec.Inputs.

Types

type ProviderResolver

type ProviderResolver func(ref fluxopv1.InputProviderReference, namespace string) ([]*manifest.ResourceSetInputProvider, error)

ProviderResolver returns the ResourceSetInputProviders matching a single spec.inputsFrom reference within the given namespace. Callers implement this against their object store (orchestrator) or pass nil to disable inputsFrom resolution (tests, simple cases).

func StoreResolver

func StoreResolver(s *store.Store) ProviderResolver

StoreResolver returns a ProviderResolver backed by s. Name-only refs perform a direct id lookup; selector refs walk the store's ResourceSetInputProviders in the requested namespace and filter by metadata.labels. This is the canonical implementation shared by discovery and the orchestrator — both call sites previously carried identical local copies.

Jump to

Keyboard shortcuts

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