module K8S::Util

Overview

Miscellaneous helpers

Extended Modules

Defined in:

k8s/util.cr

Constant Summary

PATH_REGEX = /(\/|~(?!1))/
PATH_TR_MAP = {"~" => "~0", "/" => "~1"}

Class Method Summary

Instance Method Summary

Class Method Detail

def self.compact_map(args, &) #

Yield with all non-nil args, returning matching array with corresponding return values or nils.

Args must be usable as hash keys. Duplicate args will all map to the same return value.


[View source]

Instance Method Detail

def deep_merge(input, other, overwrite_arrays = true, union_arrays = false, keep_existing = false, merge_nil_values = false, merge_non_hash = false) #

overwrite_arrays [Boolean] when encountering an array, replace the array with the new array union_arrays [Boolean] when encountering an array, use Array#union to combine with the existing array keep_existing [Boolean] prefer old value over new value merge_nil_values [Boolean] overwrite an existing value with a nil value merge_non_hash [Boolean] will merge ::K8S::Kubernetes::Resource objects


[View source]
def json_patch(patch_to : Hash, patch_from : Hash) #

Produces a set of json-patch operations so that applying the operations on a, gives you the results of b Used in correctly patching the Kube resources on stack updates

patch_to [Hash] Hash to compute patches against patch_from [Hash] New Hash to compute patches "from"


[View source]
def json_patch(patch_to : NamedTuple, patch_from : NamedTuple) #

[View source]
def recursive_compact(value : Hash | Array | YAML::Any | JSON::Any) #

Recursive compact for Hash/Array


[View source]