MCPcopy
hub / github.com/helm/helm / funcMap

Function funcMap

pkg/engine/funcs.go:45–81  ·  view source on GitHub ↗

funcMap returns a mapping of all of the functions that Engine has. Because some functions are late-bound (e.g. contain context-sensitive data), the functions may not all perform identically outside of an Engine as they will inside of an Engine. Known late-bound functions: - "include" - "tpl" The

()

Source from the content-addressed store, hash-verified

43// These are late-bound in Engine.Render(). The
44// version included in the FuncMap is a placeholder.
45func funcMap() template.FuncMap {
46 f := sprig.TxtFuncMap()
47 delete(f, "env")
48 delete(f, "expandenv")
49
50 // Add some extra functionality
51 extra := template.FuncMap{
52 "toToml": toTOML,
53 "mustToToml": mustToTOML,
54 "fromToml": fromTOML,
55 "toYaml": toYAML,
56 "mustToYaml": mustToYAML,
57 "toYamlPretty": toYAMLPretty,
58 "fromYaml": fromYAML,
59 "fromYamlArray": fromYAMLArray,
60 "toJson": toJSON,
61 "mustToJson": mustToJSON,
62 "fromJson": fromJSON,
63 "fromJsonArray": fromJSONArray,
64
65 // This is a placeholder for the "include" function, which is
66 // late-bound to a template. By declaring it here, we preserve the
67 // integrity of the linter.
68 "include": func(string, any) string { return "not implemented" },
69 "tpl": func(string, any) any { return "not implemented" },
70 "required": func(string, any) (any, error) { return "not implemented", nil },
71 // Provide a placeholder for the "lookup" function, which requires a kubernetes
72 // connection.
73 "lookup": func(string, string, string, string) (map[string]any, error) {
74 return map[string]any{}, nil
75 },
76 }
77
78 maps.Copy(f, extra)
79
80 return f
81}
82
83// toYAML takes an interface, marshals it to yaml, and returns a string. It will
84// always return a string, even on marshal error (empty string).

Callers 4

initFunMapMethod · 0.85
TestFuncsFunction · 0.85
TestMergeFunction · 0.85
TestFuncMapFunction · 0.85

Calls 1

CopyMethod · 0.80

Tested by 3

TestFuncsFunction · 0.68
TestMergeFunction · 0.68
TestFuncMapFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…