coreutil

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package coreutil is defined to get/set some fields in complex core/v1alpha1 api structs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthTokenJWKSSecretName

func AuthTokenJWKSSecretName(db *v1alpha1.TiDB) string

func ClientCASecretName

func ClientCASecretName[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F) string

func ClientCertKeyPairSecretName

func ClientCertKeyPairSecretName[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F) string

func Cluster

func Cluster[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F) string

func ClusterCASecretName

func ClusterCASecretName[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F) string

func ClusterCertKeyPairSecretName

func ClusterCertKeyPairSecretName[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F) string

func ClusterSubdomain

func ClusterSubdomain(clusterName string) string

ClusterSubdomain returns the subdomain for all components of the cluster

func ClusterTLSVolume

func ClusterTLSVolume[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) *corev1.Volume

func ConfigMapLabels

func ConfigMapLabels[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) map[string]string

func CurrentRevision

func CurrentRevision[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) string

func EnabledFeatures

func EnabledFeatures(c *v1alpha1.Cluster) []metav1alpha1.Feature

func Features

func Features[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F) []metav1alpha1.Feature

func FindStatusCondition

func FindStatusCondition[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F, condType string) *metav1.Condition

func InstanceAnnotations

func InstanceAnnotations[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F) map[string]string

func InstanceLabels

func InstanceLabels[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F, rev string) map[string]string

func IsAvailable

func IsAvailable[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F, minReadySeconds int64, now time.Time) bool

func IsDeleting

func IsDeleting(instance runtime.Instance) bool

IsDeleting check whether an instance is deleting TODO: change to use scope

func IsGroupHealthyAndUpToDate

func IsGroupHealthyAndUpToDate[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F) bool

IsGroupHealthyAndUpToDate is defined to check whether all replicas of the group are healthy and up to date TODO: simplify it by a condition

func IsMainContainer

func IsMainContainer(name string) bool

IsMainContainer checks whether the container is a main container Main container means the main component container of an instance

func IsOffline

func IsOffline[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) bool

func IsReady

func IsReady[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) bool

func IsSeparateSlowLogEnabled

func IsSeparateSlowLogEnabled(db *v1alpha1.TiDB) bool

func IsSynced

func IsSynced[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F) bool

func IsTLSClusterEnabled

func IsTLSClusterEnabled(c *v1alpha1.Cluster) bool

IsTLSClusterEnabled returns whether the cluster has enabled mTLS.

func IsTiDBGroupMySQLTLSEnabled

func IsTiDBGroupMySQLTLSEnabled(dbg *v1alpha1.TiDBGroup) bool

func IsTiDBMySQLTLSEnabled

func IsTiDBMySQLTLSEnabled(db *v1alpha1.TiDB) bool

IsTiDBMySQLTLSEnabled returns whether the TLS between TiDB server and MySQL client is enabled.

func IsTiDBMySQLTLSNoClientCert

func IsTiDBMySQLTLSNoClientCert(db *v1alpha1.TiDB) bool

func IsTiProxyBackendInsecureSkipTLSVerify

func IsTiProxyBackendInsecureSkipTLSVerify(_ *v1alpha1.TiProxy) bool

func IsTiProxyBackendMutualTLSEnabled

func IsTiProxyBackendMutualTLSEnabled(tiproxy *v1alpha1.TiProxy) bool

func IsTiProxyBackendTLSEnabled

func IsTiProxyBackendTLSEnabled(tiproxy *v1alpha1.TiProxy) bool

func IsTiProxyGroupMySQLTLSEnabled

func IsTiProxyGroupMySQLTLSEnabled(pg *v1alpha1.TiProxyGroup) bool

func IsTiProxyHTTPServerNoClientCert

func IsTiProxyHTTPServerNoClientCert(_ *v1alpha1.TiProxy) bool

func IsTiProxyHTTPServerTLSEnabled

func IsTiProxyHTTPServerTLSEnabled(c *v1alpha1.Cluster, tiproxy *v1alpha1.TiProxy) bool

func IsTiProxyMySQLNoClientCert

func IsTiProxyMySQLNoClientCert(_ *v1alpha1.TiProxy) bool

func IsTiProxyMySQLTLSEnabled

func IsTiProxyMySQLTLSEnabled(tiproxy *v1alpha1.TiProxy) bool

IsTiProxyMySQLTLSEnabled returns whether the TLS between TiProxy server and MySQL client is enabled.

func IsTokenBasedAuthEnabled

func IsTokenBasedAuthEnabled(db *v1alpha1.TiDB) bool

func LegacyTLSClusterClientSecretName

func LegacyTLSClusterClientSecretName(clusterName string) string

LegacyTLSClusterClientSecretName returns the mTLS secret name for the cluster client. NOTE: now BR still use this secret to visit the cluster Deprecated: use coreutil.ClientCASecretName and coreutil.CLientCertKeyPairSecretName

func LongestReadyPeer

func LongestReadyPeer[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](in F, peers []F) F

LongestReadyPeer returns a ready peer who is ready for the longest time.

func MinReadySeconds

func MinReadySeconds[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F) int64

func NamePrefixAndSuffix

func NamePrefixAndSuffix[
	F client.Object,
](f F) (prefix, suffix string)

func NotOfflined

func NotOfflined(reason string) *metav1.Condition

func NotRunning

func NotRunning(reason, detail string) *metav1.Condition

func Offlined

func Offlined() *metav1.Condition

func OwnerGroup

func OwnerGroup[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) *metav1.OwnerReference

func PDClientPort

func PDClientPort(pd *v1alpha1.PD) int32

func PDGroupClientPort

func PDGroupClientPort(pdg *v1alpha1.PDGroup) int32

func PDGroupPeerPort

func PDGroupPeerPort(pdg *v1alpha1.PDGroup) int32

func PDPeerPort

func PDPeerPort(pd *v1alpha1.PD) int32

func PDServiceHost

func PDServiceHost(pdg *v1alpha1.PDGroup) string

func PDServiceURL

func PDServiceURL(pdg *v1alpha1.PDGroup, isTLS bool) string

func PVCs

func PVCs[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](cluster *v1alpha1.Cluster, obj F, ps ...PVCPatch) []*corev1.PersistentVolumeClaim

func PersistentVolumeClaimLabels

func PersistentVolumeClaimLabels[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F, volName string) map[string]string

func PodLabels

func PodLabels[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) map[string]string

func PodName

func PodName[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) string

PodName returns the default managed pod name of an instance TODO(liubo02): rename to more reasonable one TODO(liubo02): move to namer

func Ready

func Ready() *metav1.Condition

func RemoveStatusCondition

func RemoveStatusCondition[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F, condTypes ...string) bool

func Replicas

func Replicas[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F) int32

func RetryIfInstancesReadyButNotAvailable

func RetryIfInstancesReadyButNotAvailable[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](ins []F, minReadySeconds int64) time.Duration

RetryIfInstancesReadyButNotAvailable returns a retry duration If any instances are ready but not available, updater may do nothing and cannot watch more changes of instances. So always retry if any instances are ready but not available.

func Running

func Running() *metav1.Condition

func SchedulePolicies

func SchedulePolicies[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F) []v1alpha1.SchedulePolicy

func SchedulerClientPort

func SchedulerClientPort(s *v1alpha1.Scheduler) int32

func SchedulerGroupClientPort

func SchedulerGroupClientPort(sg *v1alpha1.SchedulerGroup) int32

func SchedulingClientPort

func SchedulingClientPort(s *v1alpha1.Scheduling) int32

func SchedulingGroupClientPort

func SchedulingGroupClientPort(sg *v1alpha1.SchedulingGroup) int32

func SessionTokenSigningCertSecretName

func SessionTokenSigningCertSecretName(cluster *v1alpha1.Cluster, db *v1alpha1.TiDB) string

SessionTokenSigningCertSecretName returns the secret name used in TiDB server for the session token signing cert. If the session token signing cert is not specified, it will return the TLS cluster secret name if TLS is enabled. If TLS is not enabled, it will return an empty string.

func SetCluster

func SetCluster[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F, cluster string)

func SetImage

func SetImage[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F, image string)

func SetReplicas

func SetReplicas[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F, replicas int32)

func SetStatusCondition

func SetStatusCondition[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F, conds ...metav1.Condition) bool

func SetStatusObservedGeneration

func SetStatusObservedGeneration[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F) bool

func SetStatusReplicas

func SetStatusReplicas[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F, newReplicas, newReady, newUpdate, newCurrent int32) bool

func SetStatusRevision

func SetStatusRevision[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F, newUpdate, newCurrent string, newCollisionCount int32) bool

func SetStatusSelector

func SetStatusSelector[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F) bool

func SetStatusVersion

func SetStatusVersion[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F) bool

func SetTemplateAnnotations

func SetTemplateAnnotations[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F, anno map[string]string)

func SetVersion

func SetVersion[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F, version string)

func ShouldPauseReconcile

func ShouldPauseReconcile(c *v1alpha1.Cluster) bool

func ShouldSuspendCompute

func ShouldSuspendCompute(c *v1alpha1.Cluster) bool

ShouldSuspendCompute returns whether the cluster should suspend compute.

func SprintCondition

func SprintCondition(cond *metav1.Condition) string

func StatusConditions

func StatusConditions[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](f F) []metav1.Condition

func StatusVersion

func StatusVersion[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F) string

func Subdomain

func Subdomain[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) string

func Suspended

func Suspended() *metav1.Condition

func Suspending

func Suspending() *metav1.Condition

func Synced

func Synced() *metav1.Condition

func TSOAdvertiseClientURLs

func TSOAdvertiseClientURLs(tso *v1alpha1.TSO) string

func TSOAdvertiseClientURLsWithScheme

func TSOAdvertiseClientURLsWithScheme(tso *v1alpha1.TSO, isTLS bool) string

func TSOClientPort

func TSOClientPort(tso *v1alpha1.TSO) int32

func TSOGroupClientPort

func TSOGroupClientPort(tg *v1alpha1.TSOGroup) int32

func TSOServiceHost

func TSOServiceHost(tg *v1alpha1.TSOGroup) string

func TSOServiceURL

func TSOServiceURL(tg *v1alpha1.TSOGroup, isTLS bool) string

func TemplateAnnotations

func TemplateAnnotations[
	S scope.Group[F, T],
	F client.Object,
	T runtime.Group,
](f F) map[string]string

func TiCDCAdvertiseURL

func TiCDCAdvertiseURL(ticdc *v1alpha1.TiCDC) string

func TiCDCGroupPort

func TiCDCGroupPort(cdcg *v1alpha1.TiCDCGroup) int32

func TiCDCPort

func TiCDCPort(cdc *v1alpha1.TiCDC) int32

func TiDBClientPort

func TiDBClientPort(db *v1alpha1.TiDB) int32

func TiDBGroupClientPort

func TiDBGroupClientPort(dbg *v1alpha1.TiDBGroup) int32

func TiDBGroupMySQLCASecretName

func TiDBGroupMySQLCASecretName(dbg *v1alpha1.TiDBGroup) string

func TiDBGroupMySQLCertKeyPairSecretName

func TiDBGroupMySQLCertKeyPairSecretName(dbg *v1alpha1.TiDBGroup) string

func TiDBGroupMySQLTLS

func TiDBGroupMySQLTLS(dbg *v1alpha1.TiDBGroup) *v1alpha1.TLS

func TiDBGroupStatusPort

func TiDBGroupStatusPort(dbg *v1alpha1.TiDBGroup) int32

func TiDBMySQLCASecretName

func TiDBMySQLCASecretName(db *v1alpha1.TiDB) string

TiDBMySQLCASecretName returns the secret name for TiDB server to authenticate MySQL client.

func TiDBMySQLCertKeyPairSecretName

func TiDBMySQLCertKeyPairSecretName(db *v1alpha1.TiDB) string

TiDBMySQLCertKeyPairSecretName returns the secret name used in TiDB server for the TLS between TiDB server and MySQL client.

func TiDBMySQLTLS

func TiDBMySQLTLS(db *v1alpha1.TiDB) *v1alpha1.TLS

func TiDBMySQLTLSVolume

func TiDBMySQLTLSVolume(db *v1alpha1.TiDB) *corev1.Volume

func TiDBStatusPort

func TiDBStatusPort(db *v1alpha1.TiDB) int32

func TiFlashFlashPort

func TiFlashFlashPort(f *v1alpha1.TiFlash) int32

func TiFlashGroupFlashPort

func TiFlashGroupFlashPort(fg *v1alpha1.TiFlashGroup) int32

func TiFlashGroupMetricsPort

func TiFlashGroupMetricsPort(fg *v1alpha1.TiFlashGroup) int32

func TiFlashGroupProxyPort

func TiFlashGroupProxyPort(fg *v1alpha1.TiFlashGroup) int32

func TiFlashGroupProxyStatusPort

func TiFlashGroupProxyStatusPort(fg *v1alpha1.TiFlashGroup) int32

func TiFlashMetricsPort

func TiFlashMetricsPort(f *v1alpha1.TiFlash) int32

func TiFlashProxyPort

func TiFlashProxyPort(f *v1alpha1.TiFlash) int32

func TiFlashProxyStatusPort

func TiFlashProxyStatusPort(f *v1alpha1.TiFlash) int32

func TiFlashProxyStatusURL

func TiFlashProxyStatusURL(f *v1alpha1.TiFlash, isTLS bool) string

func TiKVAdvertiseClientURLs

func TiKVAdvertiseClientURLs(tikv *v1alpha1.TiKV) string

func TiKVAdvertiseStatusURLs

func TiKVAdvertiseStatusURLs(tikv *v1alpha1.TiKV) string

func TiKVClientPort

func TiKVClientPort(kv *v1alpha1.TiKV) int32

func TiKVGroupClientPort

func TiKVGroupClientPort(kvg *v1alpha1.TiKVGroup) int32

func TiKVGroupStatusPort

func TiKVGroupStatusPort(kvg *v1alpha1.TiKVGroup) int32

func TiKVStatusPort

func TiKVStatusPort(kv *v1alpha1.TiKV) int32

func TiProxyAPIPort

func TiProxyAPIPort(tiproxy *v1alpha1.TiProxy) int32

func TiProxyBackendCASecretName

func TiProxyBackendCASecretName(tiproxy *v1alpha1.TiProxy) string

func TiProxyBackendCertKeyPairSecretName

func TiProxyBackendCertKeyPairSecretName(tiproxy *v1alpha1.TiProxy) string

func TiProxyBackendTLS

func TiProxyBackendTLS(db *v1alpha1.TiProxy) *v1alpha1.ClientTLS

func TiProxyBackendTLSVolume

func TiProxyBackendTLSVolume(tiproxy *v1alpha1.TiProxy) *corev1.Volume

func TiProxyClientPort

func TiProxyClientPort(tiproxy *v1alpha1.TiProxy) int32

func TiProxyGroupAPIPort

func TiProxyGroupAPIPort(proxyg *v1alpha1.TiProxyGroup) int32

func TiProxyGroupClientPort

func TiProxyGroupClientPort(proxyg *v1alpha1.TiProxyGroup) int32

func TiProxyGroupMySQLCASecretName

func TiProxyGroupMySQLCASecretName(pg *v1alpha1.TiProxyGroup) string

func TiProxyGroupMySQLCertKeyPairSecretName

func TiProxyGroupMySQLCertKeyPairSecretName(pg *v1alpha1.TiProxyGroup) string

func TiProxyGroupMySQLTLS

func TiProxyGroupMySQLTLS(pg *v1alpha1.TiProxyGroup) *v1alpha1.TLS

func TiProxyGroupPeerPort

func TiProxyGroupPeerPort(proxyg *v1alpha1.TiProxyGroup) int32

func TiProxyHTTPServerCASecretName

func TiProxyHTTPServerCASecretName(tiproxy *v1alpha1.TiProxy) string

TiProxyHTTPServerCASecretName returns the secret name for TiProxy http server to authenticate clients.

func TiProxyHTTPServerCertKeyPairSecretName

func TiProxyHTTPServerCertKeyPairSecretName(tiproxy *v1alpha1.TiProxy) string

TiProxyHTTPServerCertKeyPairSecretName returns the secret name used for tiproxy http server.

func TiProxyHTTPServerTLS

func TiProxyHTTPServerTLS(_ *v1alpha1.TiProxy) *v1alpha1.TLS

func TiProxyHTTPServerTLSVolume

func TiProxyHTTPServerTLSVolume(tiproxy *v1alpha1.TiProxy) *corev1.Volume

func TiProxyMySQLCASecretName

func TiProxyMySQLCASecretName(tiproxy *v1alpha1.TiProxy) string

TiProxyMySQLCASecretName returns the secret name for TiProxy server to authenticate MySQL client.

func TiProxyMySQLCertKeyPairSecretName

func TiProxyMySQLCertKeyPairSecretName(tiproxy *v1alpha1.TiProxy) string

TiProxyMySQLCertKeyPairSecretName returns the secret name used in TiProxy server for the TLS between TiProxy server and MySQL client.

func TiProxyMySQLTLS

func TiProxyMySQLTLS(db *v1alpha1.TiProxy) *v1alpha1.TLS

func TiProxyMySQLTLSVolume

func TiProxyMySQLTLSVolume(tiproxy *v1alpha1.TiProxy) *corev1.Volume

func TiProxyPeerPort

func TiProxyPeerPort(tiproxy *v1alpha1.TiProxy) int32

func Topology

func Topology[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) v1alpha1.Topology

func Unready

func Unready(reason string) *metav1.Condition

func Unsuspended

func Unsuspended() *metav1.Condition

func Unsynced

func Unsynced(reason string) *metav1.Condition

func UpdateRevision

func UpdateRevision[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) string

func Version

func Version[
	S scope.Object[F, T],
	F client.Object,
	T runtime.Object,
](in F) string

func Volumes

func Volumes[
	S scope.Instance[F, T],
	F client.Object,
	T runtime.Instance,
](f F) []v1alpha1.Volume

Types

type PVCPatch

type PVCPatch interface {
	Patch(vol *v1alpha1.Volume, pvc *corev1.PersistentVolumeClaim)
}

func EnableVAC

func EnableVAC(enable bool) PVCPatch

func WithLegacyK8sAppLabels

func WithLegacyK8sAppLabels() PVCPatch

type PVCPatchFunc

type PVCPatchFunc func(vol *v1alpha1.Volume, pvc *corev1.PersistentVolumeClaim)

func (PVCPatchFunc) Patch

Jump to

Keyboard shortcuts

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