Documentation ¶
Overview ¶
package helmette implements golang analogs for the constructs present within the helm template rendering environment. See also: - https://helm.sh/docs/chart_template_guide/function_list/ - http://masterminds.github.io/sprig/ - https://pkg.go.dev/text/template
Index ¶
- func AsIntegral[T HelmNumber](value any) (T, bool)
- func AsNumeric(value any) (float64, bool)
- func Atoi(in string) (int, error)
- func Coalesce[T any](values ...T) T
- func Concat[T any](lists ...[]T) []T
- func Contains(substr, s string) bool
- func Default[T any](default_, value T) T
- func DictTest[K comparable, V any](m map[K]V, key K) (V, bool)
- func Dig(m map[string]any, fallback any, path ...string) any
- func Empty(value any) bool
- func Fail(msg string)
- func First[T any](x []T) any
- func Float64(in string) (float64, error)
- func FromJSON(data string) any
- func HasKey[K comparable, V any](m map[K]V, key K) bool
- func Indent(spaces int, v string) string
- func Join[T any](sep string, s []T) string
- func Keys[K comparable, V any](m map[K]V) []K
- func KindIs(kind string, v any) bool
- func KindOf(v any) string
- func Len(in any) int
- func Lookup[T any, PT kube.AddrofObject[T]](dot *Dot, namespace, name string) (obj *T, found bool)
- func Lower(in string) string
- func Merge[K comparable, V any](sources ...map[K]V) map[K]V
- func MergeTo[T any](sources ...any) T
- func Min(in ...int64) int64
- func MustDuration(duration string) *metav1.Duration
- func MustFromJSON(data string) any
- func MustRegexMatch(pattern, s string) bool
- func MustToJSON(value any) string
- func NIndent(spaces int, v string) string
- func Printf(format string, a ...any) string
- func Quote(vs ...any) string
- func RandAlphaNum(length int) string
- func RegexMatch(pattern, s string) bool
- func RegexReplaceAll(regex, s, repl string) string
- func Replace(old, new, s string) string
- func Required(msg string, value any)
- func SQuote(vs ...any) string
- func SafeLookup[T any, PT kube.AddrofObject[T]](dot *Dot, namespace, name string) (*T, bool, error)
- func SemverCompare(constraint, version string) (bool, error)
- func Sha256Sum(input string) string
- func SortAlpha(x []string) []string
- func SortedKeys[T any](m map[string]T) []string
- func ToJSON(value any) string
- func ToString(input any) string
- func ToYaml(value any) string
- func Tpl(tpl string, context any) string
- func TrimPrefix(prefix, s string) string
- func TrimSuffix(suffix, s string) string
- func Trunc(length int, in string) string
- func TypeAssertion[T any](val any) T
- func TypeIs(typ string, v any) bool
- func TypeOf(v any) string
- func TypeTest[T any](val any) (T, bool)
- func UnmarshalInto[T any](value any) T
- func UnmarshalYamlArray[T any](repr string) []T
- func Unset[K comparable, V any](d map[K]V, key K)
- func Until(n int) []int
- func Unwrap[T any](from Values) T
- func Upper(in string) string
- type Chart
- type Dot
- type HelmNumber
- type Release
- type Tuple2
- type Tuple3
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsIntegral ¶
func AsIntegral[T HelmNumber](value any) (T, bool)
AsIntegral is a helm-specific replacement for type assertions/tests of numeric types. The combination of helm, text/template, and sprig prevent us from being able to reasonably distinguish between the various types of numeric types. Instead we must rely on loose heuristic to determine if a value could reasonably be interpreted as anything other than a float64.
func AsNumeric ¶
AsNumeric attempts to interpret the provided value as a helm friendly "numeric" (float64). It should be used in place of type assertions to numeric types. Due to helm's, sprig's, and gotohelm's use of untyped JSON marshalling all numeric values are cast to float64s. To ensure that gocode and helm code function the same way, AsNumeric must be used.
func Coalesce ¶
func Coalesce[T any](values ...T) T
Coalesce is the go equivalent of sprig's `coalesce`. +gotohelm:builtin=coalesce
func Concat ¶
func Concat[T any](lists ...[]T) []T
Concat is the go equivalent of sprig's `concat`. +gotohelm:builtin=concat
func Default ¶
func Default[T any](default_, value T) T
Default is a go equivalent of sprig's `default`. +gotohelm:builtin=default
func DictTest ¶
func DictTest[K comparable, V any](m map[K]V, key K) (V, bool)
DictTest is an equivalent of `val, ok := map[key]` that is exercised as a function call rather than a special form of syntax. See also: "_shims.dicttest". func DictTest[K comparable, V any](m map[K]V, key K) TestResult[V] {
func Fail ¶
func Fail(msg string)
Fail is the go equivalent of sprig's `fail`. +gotohelm:builtin=fail
func First ¶
First function can not return `T` as sprig implementation will return nil if array is of the size 0.
# Reference https://github.com/Masterminds/sprig/blob/581758eb7d96ae4d113649668fa96acc74d46e7f/list.go#L161-L163 +gotohelm:builtin=first
func HasKey ¶
func HasKey[K comparable, V any](m map[K]V, key K) bool
HasKey is the go equivalent of sprig's `hasKey`. +gotohelm:builtin=hasKey
func Keys ¶
func Keys[K comparable, V any](m map[K]V) []K
Keys is the go equivalent of sprig's `keys`. +gotohelm:builtin=keys
func Lookup ¶
Lookup is a wrapper around helm's builtin lookup function that instead returns `nil, false` if the lookup fails instead of an empty dictionary. See: https://github.com/helm/helm/blob/e24e31f6cc122405ae25069f5b3960036c202c46/pkg/engine/lookup_func.go#L60-L97
func Merge ¶
func Merge[K comparable, V any](sources ...map[K]V) map[K]V
Merge is a go equivalent of sprig's `merge`.
func MergeTo ¶
MergeTo transpiles to `merge`, but in the golang domain it'll return the type requested
func MustDuration ¶
func MustFromJSON ¶
MustFromJSON is the go equivalent of sprig's `mustFromJson`. +gotohelm:builtin=mustFromJson
func MustRegexMatch ¶
MustRegexMatch is the go equivalent of sprig's `mustRegexMatch`. +gotohelm:builtin=mustRegexMatch
func MustToJSON ¶
MustToJSON is the go equivalent of sprig's `mustToJson`. +gotohelm:builtin=mustToJson
func Quote ¶
Quote is the equivalent of sprig's `quote` - it takes an arbitrary list of arguments +gotohelm:builtin=quote
func RegexMatch ¶
RegexMatch is the go equivalent of sprig's `regexMatch`. +gotohelm:builtin=regexMatch
func RegexReplaceAll ¶
+gotohelm:builtin=regexReplaceAll
func SafeLookup ¶
SafeLookup is a wrapper around helm's builtin lookup function. It acts exactly like Lookup except it returns any errors that may have occurred in the underlying lookup operations.
func SemverCompare ¶
+gotohelm:builtin=semverCompare
func SortAlpha ¶
SortAlpha is the go equivalent of sprig's `sortAlpha`. It mutates the provided slice in place and returns the mutated slice. +gotohelm:builtin=sortAlpha
func SortedKeys ¶
SortedKeys is a convenience function to aid in iterating over maps in a deterministic order.
func ToYaml ¶
ToYAML is the go equivalent of helm's `toYaml`.
Reference https://github.com/helm/helm/blob/e90b456d655e78d7c72a32a52a9b70bc1984c33f/pkg/engine/funcs.go#L51 https://github.com/helm/helm/blob/e90b456d655e78d7c72a32a52a9b70bc1984c33f/pkg/engine/funcs.go#L78-L89 +gotohelm:builtin=toYaml
func Tpl ¶
https://helm.sh/docs/howto/charts_tips_and_tricks/#using-the-tpl-function +gotohelm:builtin=tpl
func TrimPrefix ¶
TrimPrefix is the go equivalent of sprig's `trimPrefix` +gotohelm:builtin=trimPrefix
func TrimSuffix ¶
TrimSuffix is the go equivalent of sprig's `trimSuffix` +gotohelm:builtin=trimSuffix
func TypeAssertion ¶
TypeAssertion is an equivalent of `x.(type)` that is exercised as a function call rather than a special form of syntax. See also: "_shims.typeassertion".
func TypeTest ¶
TypeTest is an equivalent of `val, ok := x.(type)` that is exercised as a function call rather than a special form of syntax. See also: "_shims.typetest".
func UnmarshalInto ¶
UnmarshalInto valuesutil.UnmarshalInto without an error return for use to the gotohelm world.
It may be used to "convert" untyped values into values of type T provided that their JSON representations are the same. For example, an any type holding a known struct value that can't be asserted via a type assertion.
DANGER: In helm, no validation or default is done. This function effectively transpiles to `return value`. Use with care.
func UnmarshalYamlArray ¶
UnmarshalYaml fills in the type requested +gotohelm:builtin=fromYamlArray
func Unset ¶
func Unset[K comparable, V any](d map[K]V, key K)
Unset is the go equivalent of sprig's `unset`. +gotohelm:builtin=unset
func Until ¶
Until is the go equivalent of spring's `until`. There might be better ways to do things with gotohelm, but this represents a high-fidelity way to translate templates. +gotohelm:builtin=until
Types ¶
type Dot ¶
type Dot struct { Values Values Release Release Chart Chart Subcharts map[string]*Dot // KubeConfig is a hacked in value to allow `Lookup` to not rely on global // values. It's a kube.Config to support JSON marshalling and allow easy // transport into the `go run` test runner. // WARNING: DO NOT USE OR REFERENCE IN HELM CHARTS. IT WILL NOT WORK. KubeConfig kube.Config }
Dot is a representation of the "global" context or `.` in the execution of a helm template. See also: https://github.com/helm/helm/blob/3764b483b385a12e7d3765bff38eced840362049/pkg/chartutil/values.go#L137-L166
type HelmNumber ¶
HelmNumber is a union type of valid numeric primitives within the context of helm templates.