Documentation ¶
Index ¶
- func SimpleObjectHash(object client.Object) string
- type ChainedOperation
- type FallibleProcedure
- type Values
- func (v Values) AddFromYAML(content string) error
- func (v Values) AddFromYAMLBuffer(content []byte) error
- func (v Values) AddFromYAMLFile(filePath string) error
- func (v Values) AddHelmValue(key, value string) error
- func (v Values) AsMap() map[string]interface{}
- func (v Values) Coalesce(newValues Values)
- func (v Values) GetBool(key string, defaultValue ...bool) bool
- func (v Values) GetString(key string, defaultValue ...string) string
- func (v Values) GetValue(key string) (interface{}, error)
- func (v Values) HasKey(key string) bool
- func (v Values) Merge(newValues Values) error
- func (v Values) SetValue(key string, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SimpleObjectHash ¶
SimpleObjectHash offers a default implementation for `ValueProvider.Hash`. It uses the original Custom Resource to calculate the hash value.
Limitations: This implementation uses object UID and Generation. For these values to be valid, the resource must be populated with Kubernetes API, for example the resource must be retrieved with `Client.Get`.
Note that object Generation does not change when resource metadata or status changes. So, as long as changes in resource metadata do not cause changes in resource UID, the hash does not change.
For more details see:
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#status-subresource
Types ¶
type ChainedOperation ¶
type ChainedOperation []FallibleProcedure
ChainedOperation is a series of procedures that must execute without failure in a pre-determined order for the operation to be successful.
If any procedure fails the whole operation will fail.
type FallibleProcedure ¶
FallibleProcedure is any function that, within a context, runs a procedure that may fail.
Although, parameter passing to and from the procedure is only possible through the context the procedures are intended to be self-contained and not meant to act as functions.
The returning error indicates the procedure failure.
type Values ¶
type Values map[string]interface{}
Values holds an arbitrary tree-like data structure, such as parsed JSON or YAML. It can be used to represent Helm-like values.
You can use convenient accessors to work with this data structure.
Note: Some use-cases, including Helm SDK, make assumptions about the data type of the embedded lists and objects. To avoid any error or an unexpected behavior use `[]interface{}` for lists and `map[string]interface{}` for nested objects.
func (Values) AddFromYAML ¶
AddFromYAML merges the values from the provided YAML.
It will return an error if it fails to parse the YAML content or encounters an error while merging. For more details see `Merge` function.
func (Values) AddFromYAMLBuffer ¶
AddFromYAMLBuffer merges the values from the provided YAML.
It will return an error if it fails to parse the YAML content or encounters an error while merging. For more details see `Merge` function.
func (Values) AddFromYAMLFile ¶
AddFromYAMLFile merges the values from the specified YAML file.
It will return an error if it fails to read or parse the YAML file or encounters an error while merging. For more details see `Merge` function.
func (Values) AddHelmValue ¶
AddHelmValue sets the specified value using Helm style key and value format. This is similar to `--set key=value` command argument of Helm. It does not support multiple keys and values. It returns an error if it can not parse the key or assign the value.
func (Values) AsMap ¶
AsMap converts the values data structure to a plain map. This is useful for passing values to other libaries.
func (Values) Coalesce ¶
Coalesce uses Helm-style coalesce to merge the content of another data structure.
Coalesce can traverse nested values. As opposed to merge, it only inserts the missing key-value pairs and does not override the existing keys.
It uses Helm SDK coalesce function and does not return an error when fails to merge specific entries. Therefore it may lead to an incorrect output.
func (Values) GetBool ¶
GetBool retrieves the value of type `bool` that is addressed with a dot-separated key, e.g. `x.y.z`. The key format does not support array indexing.
If the key does not exist or its type is not `bool` it will return the optional `defaultValue` or `false`.
Use `HasKey` to check if the `key` exist.
func (Values) GetString ¶
GetString retrieves the value of type `string` that is addressed with a dot-separated key, e.g. `x.y.z`. The key format does not support array indexing.
If the key does not exist it will return the optional `defaultValue` or an empty string. When the key exists but its type is not `string` it tries to format it as `string`. If it fails it will return either the `defaultValue` or an empty string.
Use `HasKey` to check if the `key` exist.
func (Values) GetValue ¶
GetValue retrieves the value that is addressed with a dot-separated key, e.g. `x.y.z`. The key format does not support array indexing.
It will return an error, if the key does not exist or can not be traversed, for example nested keys of a leaf node of the tree.
func (Values) HasKey ¶
HasKey checks if a specific key exists. The `key` is in dot-separated format and it does not support array indexing. When it returns `true` the getter methods, e.g. `GetValue`, can successfully retrieve the associated value of the key.
func (Values) Merge ¶
Merge uses deep copy to merge the content of another data structure. It overrides the existing keys with their associated new values and copies the missing keys.
Merge can traverse nested values, it does not deep copy slices and treats them as scalar values. It does not do any type checking and treats `nil` values as valid values.
It retruns an error if the underlying merge utility encounters an error.
func (Values) SetValue ¶
SetValue set the value that is addressed with a dot-separated key, e.g. `x.y.z`. The key format does not support array indexing.
It does not do any type checking and will override the targeted element with the provided value. It will create any intermediate nested object that doesn't exist. But it will return an error when the key can not be traversed, for example nested keys of a leaf node of the tree.