Documentation ¶
Index ¶
- func ExecuteTemplate(templateFile string, data interface{}) (string, error)
- func ExecuteTemplateData(templateData string, data interface{}) (string, error)
- func ExecuteTemplateFile(filename string, data interface{}) (string, error)
- func GetAllTemplates(path string, kind string, templateType string, version string) []string
- func GetOr(m map[string]interface{}, key, fallback string) interface{}
- func GetTemplateData(t Template) (map[string]string, error)
- func GetTemplatesPath() (string, error)
- func InitMap(m *map[string]string)
- func IsJSON(s string) error
- func IsSet(m map[string]interface{}, key string) interface{}
- func LogErrorForObject(h *helper.Helper, err error, msg string, object metav1.Object, ...)
- func LogForObject(h *helper.Helper, msg string, object metav1.Object, params ...interface{})
- func MergeStringMaps(baseMap map[string]string, extraMaps ...map[string]string) map[string]string
- func ObjectHash(i interface{}) (string, error)
- func RemoveIndex(s []string, index int) []string
- func SetHash(hashMap map[string]string, hashType string, hashStr string) (map[string]string, bool)
- func StringInSlice(a string, list []string) bool
- func WrapErrorForObject(msg string, object client.Object, err error) error
- type Hash
- type List
- type Pair
- type TType
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteTemplate ¶
ExecuteTemplate creates a template from the file and execute it with the specified data
func ExecuteTemplateData ¶
ExecuteTemplateData creates a template from string and execute it with the specified data
func ExecuteTemplateFile ¶
ExecuteTemplateFile - creates a template from the file and execute it with the specified data
func GetAllTemplates ¶
GetAllTemplates - get all template files
The structur of the folder is, base path, the kind (CRD in lower case),
- path - base path of the templates folder
- kind - sub folder for the CRDs templates
- templateType - TType of the templates. When the templates got rendered and added to a CM this information is e.g. used for the permissions they get mounted into the pod
- version - if there need to be templates for different versions, they can be stored in a version subdir
Sub directories inside the specified directory with the above parameters get ignored.
func GetOr ¶
GetOr returns the value of m[key] if it exists, fallback otherwise. As a special case, it also returns fallback if the value of m[key] is the empty string
func GetTemplateData ¶
GetTemplateData - Renders templates specified via Template struct
Check the TType const and Template type for more details on defining the template.
func GetTemplatesPath ¶
GetTemplatesPath get path to templates, either running local or deployed as container
func IsSet ¶
IsSet returns the value of m[key] if key exists, otherwise false Different from getOr because it will return zero values.
func LogErrorForObject ¶
func LogErrorForObject( h *helper.Helper, err error, msg string, object metav1.Object, params ...interface{}, )
LogErrorForObject - Error logging
func LogForObject ¶
LogForObject - generic info level logging
func MergeStringMaps ¶
MergeStringMaps - merge two or more string->map maps NOTE: In case a key exists, the value in the first map is preserved.
func ObjectHash ¶
ObjectHash creates a deep object hash and return it as a safe encoded string
func RemoveIndex ¶
RemoveIndex - remove int from slice
func SetHash ¶
func SetHash( hashMap map[string]string, hashType string, hashStr string, ) (map[string]string, bool)
SetHash - set hashStr of type hashType on hashMap if it does not exist or hashStr is different from current stored value. Returns hashMap and bool which indicates if hashMap changed.
func StringInSlice ¶
StringInSlice - is string in slice
Types ¶
type Hash ¶
type Hash struct { // Name of hash referencing the parameter Name string `json:"name,omitempty"` // Hash Hash string `json:"hash,omitempty"` }
Hash - struct to add hashes to status
type List ¶
type List []Pair
List -
func SortStringMapByValue ¶
SortStringMapByValue - Creates a sorted List contain key/value of a map[string]string sorted by key
type TType ¶
type TType string
TType - TemplateType
const ( // TemplateTypeScripts - scripts type TemplateTypeScripts TType = "bin" // TemplateTypeConfig - config type TemplateTypeConfig TType = "config" // TemplateTypeCustom - custom config type, the secret/cm will not get upated as it is exected that the content is owned by a user // if the configmap/secret does not exist on first check, it gets created TemplateTypeCustom TType = "custom" // TemplateTypeNone - none type, don't add configs from a directory, only files from AdditionalData TemplateTypeNone TType = "none" )
type Template ¶
type Template struct { Name string // name of the cm/secret to create based of the Template. Check secret/configmap pkg on details how it is used. Namespace string // name of the nanmespace to create the cm/secret. Check secret/configmap pkg on details how it is used. Type TType // type of the templates, see TTtypes InstanceType string // the CRD name in lower case, to separate the templates for each CRD in /templates SecretType corev1.SecretType // Secrets only, defaults to "Opaque" AdditionalTemplate map[string]string // templates which are common to multiple CRDs can be located in a shared folder and added via this type into the resulting CM/secret CustomData map[string]string // custom data which won't get rendered as a template and just added to the resulting cm/secret Labels map[string]string // labels to be set on the cm/secret Annotations map[string]string // Annotations set on cm/secret ConfigOptions map[string]interface{} // map of parameters as input data to render the templates SkipSetOwner bool // skip setting ownership on the associated configmap Version string // optional version string to separate templates inside the InstanceType/Type directory. E.g. placementapi/config/18.0 }
Template - config map and secret details