layout

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package layout is where a writer's files go in a GitOps repository and what one write changes there: every writer (a manager, a CLI) owns one directory under the directory a Flux Kustomization builds from, holding one file per object and its own kustomization.yaml that lists them, and the parent's kustomization.yaml, where there is one, lists the directory. Flux then builds the directory whether the parent has a kustomization.yaml (the entry is added there) or not (Flux generates one that includes every directory with a kustomization.yaml).

Build decides a write against the base branch — which files are added, updated, removed or already there — encrypts new secret files for the repository's .sops.yaml recipients and never re-encrypts one that exists. The plan's Change is what commit.Open lands as the person.

Index

Constants

View Source
const KustomizationFile = "kustomization.yaml"

KustomizationFile lists a directory's files for kustomize.

View Source
const SOPSConfigFile = ".sops.yaml"

SOPSConfigFile is the repository's encryption rules, read at its root.

Variables

This section is empty.

Functions

func Resources

func Resources(raw []byte) ([]string, error)

Resources is the resources list of a kustomization.yaml; nil content, an empty file and a file without the list have none.

func WithResources

func WithResources(raw []byte, resources []string) ([]byte, error)

WithResources is the kustomization.yaml with its resources list replaced by resources, every other key and comment kept — an entry that stays keeps its node and so its comments; a new file for nil content.

Types

type Action

type Action string

Action is what a write does to one file.

const (
	Add       Action = "add"
	Update    Action = "update"
	Remove    Action = "remove"
	Unchanged Action = "unchanged"
)

The actions of a plan's files.

type Directory

type Directory struct {
	provenance.Location
	// Name is the writer's directory name, one path segment
	// ("cluster-manager", "model-manager").
	Name string
}

Directory is a writer's directory: Name under the directory of Location, on its repository and branch.

func (Directory) ObjectFile

func (d Directory) ObjectFile(kind, name string) string

ObjectFile is the path of an object's file in the directory: named after the object, a Secret in a secret file of its own (sopsenc's naming convention), so it is encrypted and never written in plaintext.

func (Directory) Path

func (d Directory) Path() string

Path is the directory, repository-relative.

type File

type File struct {
	Path    string
	Action  Action
	Content []byte
}

File is one file of a plan. Content is the new content of an added or updated plain file, for a dry run to show; a secret file's content is never carried.

type Plan

type Plan struct {
	Directory Directory
	// Files are every file the write decided on, sorted by path — unchanged
	// ones included, so a dry run shows the whole directory the write owns.
	Files []File
	// contains filtered or unexported fields
}

Plan is the change set of one write in a directory.

func Build

func Build(ctx context.Context, r commit.Reader, dir Directory, write map[string][]byte, remove []string) (*Plan, error)

Build decides a write in dir against the base branch: write are the files to land by path, remove the paths to take away (a path the base does not carry is no change); every path lies inside the directory. A plain file is added, updated or unchanged; a new secret file is encrypted for the recipients of the repository's .sops.yaml, one that exists is left as it is. The directory's kustomization.yaml lists every file it keeps and is removed with the last one; the parent's kustomization.yaml, where there is one, lists the directory while it has files. Both are edited on their YAML nodes: comments and every other key stay. Read errors from r are returned as they are (commit.AuthError included).

func (*Plan) Change

func (p *Plan) Change() commit.Change

Change is the plan as commit.Open takes it: the written files with their content, the removed ones nil.

func (*Plan) Changed

func (p *Plan) Changed() bool

Changed reports whether the plan writes or removes anything.

type SecretError

type SecretError struct {
	Paths  []string
	Reason string
}

SecretError refuses secret files the repository cannot take encrypted: no .sops.yaml, one that does not parse, or no creation rule with recipients for their paths. They are never written in plaintext; the caller names its way out.

func (*SecretError) Error

func (e *SecretError) Error() string

Jump to

Keyboard shortcuts

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