shared

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

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

This section is empty.

Jump to

Keyboard shortcuts

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