util

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const MqTypeConfigKey = "messageQueue"

Variables

View Source
var DefaultBackOffInterval = time.Second * 1
View Source
var DefaultHTTPTimeout = 15 * time.Second
View Source
var DefaultMaxRetry = 3

Functions

func BoolPtr

func BoolPtr(val bool) *bool

func CheckSum

func CheckSum(s []byte) string

func DeepCopyValues

func DeepCopyValues(input map[string]interface{}) map[string]interface{}

func DeleteValue

func DeleteValue(values map[string]interface{}, fields ...string)

func DiffStr

func DiffStr(expected interface{}, actual interface{}) string

DiffStr returns a diff of both values as long as both are of the same type and are a struct, map, slice, array or string. Otherwise it returns an empty string. ref: github.com/stretchr/testify/assert:diff()

func DoWithBackoff

func DoWithBackoff(name string, fn func() error, maxRetry int, backOff time.Duration) error

func GetBoolValue

func GetBoolValue(values map[string]interface{}, fields ...string) (bool, bool)

func GetGitRepoRootDir

func GetGitRepoRootDir() string

func GetHostPort

func GetHostPort(endpoint string) (string, int32)

func GetHostPortWithDefault added in v1.3.8

func GetHostPortWithDefault(endpoint string, defaultPort int32) (string, int32)

func GetNumberValue

func GetNumberValue(values map[string]interface{}, fields ...string) (float64, bool)

GetNumberValue supports int64 / float64 in values return as float64 see https://datatracker.ietf.org/doc/html/rfc8259#section-6

func GetStringValue

func GetStringValue(values map[string]interface{}, fields ...string) (string, bool)

func GetTemplatedValues

func GetTemplatedValues(templateConfig string, values interface{}) ([]byte, error)

func HTTPGetBytes

func HTTPGetBytes(url string) ([]byte, error)

func JoinErrors

func JoinErrors(errs []error) string

func MergeValues

func MergeValues(origin, patch map[string]interface{})

MergeValues merges patch into origin, you have to make sure origin is not nil, otherwise it won't work

func SetLogger

func SetLogger(l logr.Logger)

func SetStringSlice

func SetStringSlice(values map[string]interface{}, v []string, fields ...string)

func SetValue

func SetValue(values map[string]interface{}, v interface{}, fields ...string)

only contains types bool, int64, float64, string, []interface{}, map[string]interface{}, json.Number and nil

Types

type K8sClient

type K8sClient interface {
	Exist(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string) (bool, error)

	// Create creates resources from manifest
	Create(ctx context.Context, manifest []byte) error

	// Delete delete resources from manifest
	Delete(ctx context.Context, manifest []byte) error

	// ListCRDs list all CRDs
	ListCRDs(ctx context.Context) (*apiextensionsv1.CustomResourceDefinitionList, error)

	// GetCRDVersionsByNames returns map[crdName]crdVersion
	GetCRDVersionsByNames(ctx context.Context, crdNames []string) (map[string]string, error)

	// WaitDeploymentReady
	WaitDeploymentsReadyByNamespace(ctx context.Context, namespace string) error
}

K8sClient wrap functions by k8s clients

type K8sClients

type K8sClients struct {
	ClientSet     kubernetes.Interface
	ExtClientSet  clientset.Interface
	DynamicClient dynamic.Interface
}

func NewK8sClientsForConfig

func NewK8sClientsForConfig(config *rest.Config) (*K8sClients, error)

func (K8sClients) Create

func (clis K8sClients) Create(ctx context.Context, manifest []byte) error

Create creates resource from manifest

func (K8sClients) Delete

func (clis K8sClients) Delete(ctx context.Context, manifest []byte) error

Delete delete resource from manifest

func (K8sClients) Exist

func (clis K8sClients) Exist(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string) (bool, error)

func (*K8sClients) GetCRDVersionsByNames

func (clis *K8sClients) GetCRDVersionsByNames(ctx context.Context, crdNames []string) (map[string]string, error)

func (*K8sClients) ListCRDs

ListCRDs list all CRDs

func (K8sClients) WaitDeploymentsReadyByNamespace

func (clis K8sClients) WaitDeploymentsReadyByNamespace(ctx context.Context, namespace string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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