util

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultUnstructuredConverter performs unstructured to Go typed object conversions.
	DefaultUnstructuredConverter = &unstructuredConverter{
		mismatchDetection: parseBool(os.Getenv("KUBE_PATCH_CONVERSION_DETECTOR")),
		comparison: conversion.EqualitiesOrDie(
			func(a, b time.Time) bool {
				return a.UTC() == b.UTC()
			},
		),
	}
)

Functions

func DeepCopyJSON

func DeepCopyJSON(x map[string]interface{}) map[string]interface{}

DeepCopyJSON deep copies the passed value, assuming it is a valid JSON representation i.e. only contains types produced by json.Unmarshal() and also int64. bool, int64, float64, string, []interface{}, map[string]interface{}, json.Number and nil

func DeepCopyJSONValue

func DeepCopyJSONValue(x interface{}) interface{}

DeepCopyJSONValue deep copies the passed value, assuming it is a valid JSON representation i.e. only contains types produced by json.Unmarshal() and also int64. bool, int64, float64, string, []interface{}, map[string]interface{}, json.Number and nil

func In added in v0.0.7

func In(strings []string, s string) bool

In checks if a string is in a slice.

func IsStrictDecodingError

func IsStrictDecodingError(err error) bool

IsStrictDecodingError returns true if the error indicates that the provided object strictness violations.

func MergeKVs

func MergeKVs(toMerge map[string]string, toBeMerged map[string]string) map[string]string

MergeKVs will merge kvs in toBeMerged to toMerge. If kvs exist in toMerge, they will be replaced.

func MergeResources

func MergeResources(toMerge corev1.ResourceList, toBeMerged corev1.ResourceList) corev1.ResourceList

MergeResources will merge resources in toBeMerged to toMerge. If resources exist in toMerge, do nothing. If not exist, will set the value in toBeMerged to toMerge.

func NewStrictDecodingError

func NewStrictDecodingError(errors []error) error

NewStrictDecodingError creates a new strictDecodingError object.

func ParseOSS

func ParseOSS(address string) (endpoint, bucket, modelPath string, err error)

ParseOSS address looks like: <bucket>.<endpoint>/<modelPath>

func ParseURI

func ParseURI(uri string) (protocol string, address string, err error)

func Patch

func Patch(ctx context.Context, k8sClient client.Client, pointerObj interface{}) error

Types

type UnstructuredConverter

type UnstructuredConverter interface {
	ToUnstructured(obj interface{}) (map[string]interface{}, error)
	FromUnstructured(u map[string]interface{}, obj interface{}) error
}

UnstructuredConverter is an interface for converting between interface{} and map[string]interface representation.

Jump to

Keyboard shortcuts

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