deployer

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package deployer defines the shared interface and types for bundle deployers.

Each deployer (helm, argocd, argocdhelm) produces deployment artifacts from a configured recipe. Deployers are configured as structs with all required data, then Generate is called to produce the output.

The Deployer interface enables mockability in bundler tests and provides a consistent contract across deployer implementations. All three deployers (helm, argocd, argocdhelm) implement this interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateFromTemplate

func GenerateFromTemplate(tmplContent string, data any, baseDir, filename string) (string, int64, error)

GenerateFromTemplate renders a template and writes it to baseDir/filename. It uses SafeJoin to verify the output path stays within baseDir.

func IsSafePathComponent

func IsSafePathComponent(name string) bool

IsSafePathComponent returns true if name is a single path component without any separators or parent directory references.

func NormalizeVersion

func NormalizeVersion(v string) string

NormalizeVersion removes the 'v' prefix from a version string. It returns the input unchanged if no prefix is present.

func NormalizeVersionWithDefault

func NormalizeVersionWithDefault(v string) string

NormalizeVersionWithDefault removes the 'v' prefix and defaults empty strings to "0.1.0". Use this for Helm chart metadata where a version is always required.

func SafeJoin

func SafeJoin(baseDir, name string) (string, error)

SafeJoin joins baseDir and name, then verifies the result is contained within baseDir. This prevents path traversal when name comes from untrusted input (e.g., component names from recipe data).

func SortByDeploymentOrder

func SortByDeploymentOrder[T any](items []T, order []string, getName func(T) string) []T

SortByDeploymentOrder sorts items by deployment order using getName to extract the component name from each item. Items in the order list are sorted by their position; items not in the order list are placed after ordered items and sorted alphabetically by name.

func SortComponentNamesByDeploymentOrder

func SortComponentNamesByDeploymentOrder(components []string, deploymentOrder []string) []string

SortComponentNamesByDeploymentOrder sorts component name strings by deployment order.

func SortComponentRefsByDeploymentOrder

func SortComponentRefsByDeploymentOrder(refs []recipe.ComponentRef, order []string) []recipe.ComponentRef

SortComponentRefsByDeploymentOrder sorts component refs by deployment order.

func WriteValuesFile

func WriteValuesFile(values map[string]any, baseDir, filename string) (string, int64, error)

WriteValuesFile writes a values.yaml file with header comment to baseDir/filename. It uses SafeJoin to verify the output path stays within baseDir.

Types

type Deployer

type Deployer interface {
	Generate(ctx context.Context, outputDir string) (*Output, error)
}

Deployer generates deployment bundles from configured inputs. Implementations are configured as structs, then Generate is called.

type Output

type Output struct {
	// Files contains the paths of generated files.
	Files []string

	// TotalSize is the total size of all generated files.
	TotalSize int64

	// Duration is the time taken to generate the output.
	Duration time.Duration

	// DeploymentSteps contains ordered deployment instructions for the user.
	DeploymentSteps []string

	// DeploymentNotes contains optional deployment notes or warnings.
	DeploymentNotes []string
}

Output contains the result of deployer generation.

func (*Output) AddDataFiles

func (o *Output) AddDataFiles(outputDir string, dataFiles []string) error

AddDataFiles resolves each relative data file path against outputDir (via SafeJoin, rejecting traversal), stats the file, and appends the absolute path to Files while adding the file size to TotalSize. Used by generators to include external --data files in their output so they are covered by checksum generation.

Directories

Path Synopsis
Package argocd provides Argo CD Application generation for recipes.
Package argocd provides Argo CD Application generation for recipes.
Package argocdhelm generates a Helm chart app-of-apps for Argo CD with dynamic install-time values.
Package argocdhelm generates a Helm chart app-of-apps for Argo CD with dynamic install-time values.
Package helm generates per-component Helm bundles from recipe results.
Package helm generates per-component Helm bundles from recipe results.
Package localformat writes the uniform numbered local-chart bundle layout.
Package localformat writes the uniform numbered local-chart bundle layout.

Jump to

Keyboard shortcuts

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