support

package
v0.11.7 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimpleObjectHash

func SimpleObjectHash(object client.Object) string

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.

func (ChainedOperation) Run

func (o ChainedOperation) Run(ctx goctx.Context) error

Run executes the chained operation with the given context. If any procedure fails it stops the execution and returns the error.

type FallibleProcedure

type FallibleProcedure = func(goctx.Context) error

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

func (v Values) AddFromYAML(content string) error

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

func (v Values) AddFromYAMLBuffer(content []byte) error

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

func (v Values) AddFromYAMLFile(filePath string) error

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

func (v Values) AddHelmValue(key, value string) error

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

func (v Values) AsMap() map[string]interface{}

AsMap converts the values data structure to a plain map. This is useful for passing values to other libaries.

func (Values) Coalesce

func (v Values) Coalesce(newValues Values)

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

func (v Values) GetBool(key string, defaultValue ...bool) bool

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

func (v Values) GetString(key string, defaultValue ...string) string

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

func (v Values) GetValue(key string) (interface{}, error)

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

func (v Values) HasKey(key string) bool

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

func (v Values) Merge(newValues Values) error

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

func (v Values) SetValue(key string, value interface{}) error

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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