common

package
v0.8.0-beta.8 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: AGPL-3.0 Imports: 19 Imported by: 1

Documentation

Overview

Package common provides types and utils shared by all KubeBlocks components: KubeBlocks Core, KBCLI, Lorry etc. will promote to pkg/common when stable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoverStringToInterfaceBySchemaType added in v0.8.0

func CoverStringToInterfaceBySchemaType(openAPIV3Schema *apiextensionsv1.JSONSchemaProps, input map[string]string) (map[string]interface{}, error)

func Expand

func Expand(input string, mapping func(string) string) string

Expand replaces variable references in the input string according to the expansion spec using the given mapping function to resolve the values of variables.

func GetPodListByStatefulSet

func GetPodListByStatefulSet(ctx context.Context, cli client.Client, stsObj *appsv1.StatefulSet) ([]corev1.Pod, error)

GetPodListByStatefulSet gets statefulSet pod list.

func GetPodListByStatefulSetWithSelector

func GetPodListByStatefulSetWithSelector(ctx context.Context, cli client.Client, stsObj *appsv1.StatefulSet, selector client.MatchingLabels) ([]corev1.Pod, error)

GetPodListByStatefulSetWithSelector gets statefulSet pod list.

func IsMemberOf

func IsMemberOf(set *appsv1.StatefulSet, pod *corev1.Pod) bool

IsMemberOf tests if pod is a member of set.

func MappingFuncFor

func MappingFuncFor(context ...map[string]string) func(string) string

MappingFuncFor returns a mapping function for use with Expand that implements the expansion semantics defined in the expansion spec; it returns the input string wrapped in the expansion syntax if no mapping for the input is found.

func ParseParentNameAndOrdinal

func ParseParentNameAndOrdinal(s string) (string, int32)

ParseParentNameAndOrdinal gets the name of cluster-component and StatefulSet's ordinal as extracted from its Name. If the StatefulSet's Name was not match a statefulSetRegex, its parent is considered to be empty string, and its ordinal is considered to be -1.

func ToCamelCase added in v0.8.0

func ToCamelCase(input string) string

ToCamelCase transforms k8s resource Name with camel case, for examples: - make-food to MakeFood - make.food to MakeFood

func ValidateDataWithSchema added in v0.8.0

func ValidateDataWithSchema(openAPIV3Schema *apiextensionsv1.JSONSchemaProps, data interface{}) error

ValidateDataWithSchema validates if the data is valid with the jsonSchema.

Types

type BuiltinHandler

type BuiltinHandler string

BuiltinHandler defines builtin role probe handler name.

const (
	MySQLHandler    BuiltinHandler = "mysql"
	PostgresHandler BuiltinHandler = "postgres"
	MongoDBHandler  BuiltinHandler = "mongodb"
	RedisHandler    BuiltinHandler = "redis"
	ETCDHandler     BuiltinHandler = "etcd"
	KafkaHandler    BuiltinHandler = "kafka"
	WeSQLHandler    BuiltinHandler = "wesql"
)

type DescendingOrdinalSts

type DescendingOrdinalSts []*appsv1.StatefulSet

DescendingOrdinalSts is a sort.Interface that Sorts a list of StatefulSet based on the ordinals extracted from the statefulSet.

type GlobalRoleSnapshot

type GlobalRoleSnapshot struct {
	Version          string            `json:"term,omitempty"`
	PodRoleNamePairs []PodRoleNamePair `json:"PodRoleNamePairs,omitempty"`
}

GlobalRoleSnapshot defines a global(leader) perspective of all pods role. KB provides two role probe methods: per-pod level role probe and retrieving all node roles from the leader node. The latter is referred to as the global role snapshot. This data structure is used to represent a snapshot of global role information. The snapshot contains two types of information: the mapping relationship between all node names and role names, and the version of the snapshot. The purpose of the snapshot version is to ensure that only role information that is more up-to-date than the current role information on the Pod Label will be updated. This resolves the issue of role information disorder in scenarios such as KB upgrades or exceptions causing restarts, network partitioning leading to split-brain situations, node crashes, and similar occurrences.

type PodRoleNamePair

type PodRoleNamePair struct {
	PodName  string `json:"podName,omitempty"`
	RoleName string `json:"roleName,omitempty"`
}

PodRoleNamePair defines a pod name and role name pair.

Jump to

Keyboard shortcuts

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