chartutil

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrResourceNotFound signals the referenced values resource could not be
	// found.
	ErrResourceNotFound = errors.New("resource not found")
	// ErrKeyNotFound signals the key could not be found in the referenced
	// values resource.
	ErrKeyNotFound = errors.New("key not found")
	// ErrUnsupportedRefKind signals the values reference kind is not
	// supported.
	ErrUnsupportedRefKind = errors.New("unsupported values reference kind")
	// ErrValuesDataRead signals the referenced resource's values data could
	// not be read.
	ErrValuesDataRead = errors.New("failed to read values data")
	// ErrValueMerge signals a single value could not be merged into the
	// values.
	ErrValueMerge = errors.New("failed to merge value")
	// ErrUnknown signals the reason an error occurred is unknown.
	ErrUnknown = errors.New("unknown error")
)

Functions

func ChartValuesFromReferences

func ChartValuesFromReferences(ctx context.Context, log logr.Logger, client kubeclient.Client, namespace string,
	values map[string]interface{}, refs ...meta.ValuesReference) (chartutil.Values, error)

ChartValuesFromReferences attempts to construct new chart values by resolving the provided references using the client, merging them in the order given. If provided, the values map is merged in last overwriting values from references, unless a reference has a targetPath specified, in which case it will overwrite all. It returns the merged values, or an ErrValuesReference error.

func DigestValues

func DigestValues(algo digest.Algorithm, values chartutil.Values) digest.Digest

DigestValues calculates the digest of the values using the provided algorithm. The caller is responsible for ensuring that the algorithm is supported.

func Encode

func Encode(w io.Writer, data map[string]interface{}, pe ...PreEncoder) error

Encode encodes the given data to YAML format and writes it to the provided io.Write, without going through a byte representation (unlike sigs.k8s.io/yaml#Unmarshal).

It optionally takes one or more PreEncoder functions that allow for pre-processing of the data before encoding, such as sorting the data.

It returns an error if the data cannot be encoded.

func MergeMaps

func MergeMaps(a, b map[string]interface{}) map[string]interface{}

MergeMaps merges map b into given map a and returns the result. It allows overwrites of map values with flat values, and vice versa.

Originally copied over from https://github.com/helm/helm/blob/v3.3.0/pkg/cli/values/options.go#L88.

func ReplacePathValue

func ReplacePathValue(values chartutil.Values, path string, value string) error

ReplacePathValue replaces the value at the dot notation path with the given value using Helm's string value parser using strvals.ParseInto. Single or double-quoted values are merged using strvals.ParseIntoString.

func SortMapSlice

func SortMapSlice(ms goyaml.MapSlice)

SortMapSlice recursively sorts the given goyaml.MapSlice by key. It can be used in combination with Encode to sort YAML by key before encoding it.

func VerifyValues

func VerifyValues(digest digest.Digest, values chartutil.Values) bool

VerifyValues verifies the digest of the values against the provided digest.

Types

type ErrValuesRefReason

type ErrValuesRefReason error

ErrValuesRefReason is the descriptive reason for an ErrValuesReference.

type ErrValuesReference

type ErrValuesReference struct {
	// Reason for the values reference error. Nil equals ErrUnknown.
	// Can be used with Is to reason about a returned error:
	//  err := &ErrValuesReference{Reason: ErrResourceNotFound, ...}
	//  errors.Is(err, ErrResourceNotFound)
	Reason ErrValuesRefReason
	// Kind of the values reference the error is being reported for.
	Kind string
	// Name of the values reference the error is being reported for.
	Name types.NamespacedName
	// Key of the values reference the error is being reported for.
	Key string
	// Optional indicates if the error is being reported for an optional values
	// reference.
	Optional bool
	// Err contains the further error chain leading to this error, it can be
	// nil.
	Err error
}

ErrValuesReference is returned by ChartValuesFromReferences

func NewErrValuesReference

func NewErrValuesReference(name types.NamespacedName, ref meta.ValuesReference, reason ErrValuesRefReason, err error) *ErrValuesReference

NewErrValuesReference returns a new ErrValuesReference constructed from the provided values.

func (*ErrValuesReference) Error

func (e *ErrValuesReference) Error() string

Error returns an error string constructed out of the state of ErrValuesReference.

func (*ErrValuesReference) Is

func (e *ErrValuesReference) Is(target error) bool

Is returns if target == Reason, or target == Err. Can be used to Reason about a returned error:

err := &ErrValuesReference{Reason: ErrResourceNotFound, ...}
errors.Is(err, ErrResourceNotFound)

func (*ErrValuesReference) Unwrap

func (e *ErrValuesReference) Unwrap() error

Unwrap returns the wrapped Err.

type PreEncoder

type PreEncoder func(goyaml.MapSlice)

PreEncoder allows for pre-processing of the YAML data before encoding.

Jump to

Keyboard shortcuts

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