target

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package target answers where a commit about a live object goes: the repository, branch and directory its file lives in (an edit), or where a new object in a namespace goes. A Resolver reads the GitOps objects on the cluster with the client the caller passes in; it holds no credentials of its own, and the caller cannot name a repository.

Flux is the only implementation. Another GitOps tool can be added as another Resolver without a change in the callers.

Index

Constants

View Source
const (
	LabelKustomizeName      = "kustomize.toolkit.fluxcd.io/name"
	LabelKustomizeNamespace = "kustomize.toolkit.fluxcd.io/namespace"
)

The labels kustomize-controller sets on every object a Kustomization applies.

Variables

View Source
var (
	KustomizationGVR = schema.GroupVersionResource{Group: "kustomize.toolkit.fluxcd.io", Version: "v1", Resource: "kustomizations"}
	GitRepositoryGVR = schema.GroupVersionResource{Group: "source.toolkit.fluxcd.io", Version: "v1", Resource: "gitrepositories"}
)

The Flux and core resources the Flux resolver reads.

View Source
var ErrNotApplied = errors.New("not GitOps-applied")

ErrNotApplied is returned for an object, or a namespace, that no GitOps tool applies from a file: it has no target. The message says why.

View Source
var ErrTargetNamespace = errors.New("kustomization moves objects to another namespace")

ErrTargetNamespace is returned for a namespace whose applying Kustomization sets spec.targetNamespace to another namespace: a new object in its directory would land in that other namespace.

View Source
var ErrUnconfirmed = fmt.Errorf("%w: labels unconfirmed", ErrNotApplied)

ErrUnconfirmed is returned when an object's labels name a GitOps object that cannot confirm them: it is gone, it has recorded no inventory yet, or the object's inventory id is ambiguous. It is an ErrNotApplied: there is no target. A caller that refuses a live write on an object GitOps may still apply can tell it apart with errors.Is.

Functions

This section is empty.

Types

type Flux

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

Flux is the Resolver for objects a Flux Kustomization applies from a GitRepository.

Labels can be set by whoever may write an object, so they alone are no proof. An object counts as applied, and its labels as its target, only when the Kustomization the labels name lists the object in its inventory (status.inventory): forged labels yield ErrNotApplied, never another target. A Kustomization that is gone or has recorded no inventory yet cannot confirm the labels: ErrUnconfirmed, which is an ErrNotApplied. An object a HelmRelease renders has no file of its own and is not applied from a file either.

The object must live on the cluster the client reads: an inventory names no cluster, so a Kustomization that applies to another cluster (spec.kubeConfig) does not apply the object, whatever its inventory lists.

func NewFlux

func NewFlux(client dynamic.Interface) *Flux

NewFlux returns the Flux resolver that reads the Namespace, the Kustomization and its GitRepository with client: the caller's own, on the cluster Flux runs on.

func (*Flux) ForNamespace

func (f *Flux) ForNamespace(ctx context.Context, namespace string) (Target, error)

ForNamespace implements Resolver: the target of the Namespace object itself, refused when its Kustomization moves objects to another namespace.

func (*Flux) ForObject

func (f *Flux) ForObject(ctx context.Context, obj *unstructured.Unstructured) (Target, error)

ForObject implements Resolver.

type Resolver

type Resolver interface {
	// ForObject returns the target of obj, an object read from the cluster
	// the resolver reads:
	// where its file lives. ErrNotApplied when no GitOps tool applies obj
	// from a file.
	ForObject(ctx context.Context, obj *unstructured.Unstructured) (Target, error)
	// ForNamespace returns the target of a new object in namespace: the
	// directory that applies the namespace. ErrNotApplied when no GitOps
	// tool applies the namespace from a file.
	ForNamespace(ctx context.Context, namespace string) (Target, error)
}

Resolver returns the commit target of a live object or of a new object.

type Target

type Target struct {
	// Location is the repository, branch and directory the files live in.
	provenance.Location
	// Kustomization is the Flux Kustomization that applies the directory.
	Kustomization provenance.Kustomization
}

Target is where a commit goes and what lands it after the merge.

Jump to

Keyboard shortcuts

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