layout

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 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 layout places the documents of a rendered order into a GitOps repository by the paths the order names itself.

Under the source-path layout the order decides where it goes, not the CLI (stuttgart-things/claims#92, stuttgart-things/stuttgart-things#4296):

  • a document annotated stuttgart-things.com/target-path goes to that file
  • a document annotated stuttgart-things.com/source-path goes to that file (the annotation names the file the document lives in; the repository's check-xr-source-path holds it to that)
  • a document with neither goes to the file of the document before it

Paths are relative to the repository root. If a kustomization.yaml sits next to a written file, the file's entry is appended to its resources.

Index

Constants

View Source
const (
	// AnnotationSourcePath names the file a document lives in.
	AnnotationSourcePath = "stuttgart-things.com/source-path"
	// AnnotationTargetPath names the file a client writes a document to when
	// it is not the order's own file (e.g. a dev VM's ScrapeConfig).
	AnnotationTargetPath = "stuttgart-things.com/target-path"
	// AnnotationManagementCluster names the cluster that applies the order.
	AnnotationManagementCluster = "stuttgart-things.com/management-cluster"
)

Variables

This section is empty.

Functions

func Write

func Write(repoRoot string, files []File, changes []*KustomizationChange) error

Write writes the files and kustomization changes below repoRoot. It refuses to overwrite an existing file: an order's file is new, and an existing one means the name is taken.

Types

type Document

type Document struct {
	Kind        string
	Name        string
	Annotations map[string]string
	Content     string
}

Document is one YAML document of a rendered order.

func SplitDocuments

func SplitDocuments(content string) ([]Document, error)

SplitDocuments splits a YAML stream into its non-empty documents.

type File

type File struct {
	Path      string
	Documents []Document
}

File is one file of an order: its repository-relative path and the documents it holds, in render order.

func Plan

func Plan(content string) ([]File, error)

Plan maps the documents of a rendered order to files.

func (File) Content

func (f File) Content() string

Content is the file as written: every document starts with "---".

type KustomizationChange

type KustomizationChange struct {
	Path   string   // repository-relative path of the kustomization
	Lines  []string // the appended lines, as written
	Before string
	After  string
}

KustomizationChange is what an order appends to one kustomization.yaml.

func Kustomizations

func Kustomizations(repoRoot string, files []File) ([]*KustomizationChange, error)

Kustomizations appends each file's entry to the kustomization next to it, the way the Backstage templates do: one line " - <file>" at the end of the kustomization, which needs resources: to be its last key. A directory without a kustomization is applied as a whole and gets nothing; an entry that is there already is left alone. Several files in one directory make one change.

Jump to

Keyboard shortcuts

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