util

package
v0.0.0-...-9e299b5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AnnPingcapToolOptions describes optional command line args for a tool.
	AnnPingcapToolOptions = "tidb.pingcap.com/tool-options"
	DefaultRootUser       = "root"
	DefaultRootPassword   = "Nz_2@sMw6R"
)
View Source
const (
	// InstanceLabelKey is Kubernetes recommended label key, it represents a unique name identifying the instance of an application
	// It's set by helm when installing a release
	InstanceLabelKey string = "app.kubernetes.io/instance"

	InstanceAnnotationKey string = "bcrds.cmss.com/instance"
	BcRdsInstanceLabelKey        = InstanceAnnotationKey
	RoleInstanceLabelKey  string = "bcrds.cmss.com/role"

	// RestartAtAnnotationKey represents restart flag
	RestartAtAnnotationKey string = "bcrds.cmss.com/restartAt"

	// RestartAtAnnotationKey represents restart flag
	PingcapRestartAtAnnotationKey string = "tidb.pingcap.com/restartedAt"

	// SLDBOperator is ManagedByLabelKey label value
	SLDBOperator string = "sldb-operator"
)
View Source
const (

	// Ready
	Ready = "Ready"
	// TiDBInitialNotDone is added when ti is not done.
	TiDBInitialNotDone = "TiDBInitialNotDone"
	// TiDBRestartNotDone is added when ti is not done.
	TiDBRestartNotDone = "TiDBRestartNotDone"
)

Variables

View Source
var (
	// controllerKind contains the schema.GroupVersionKind for ServerlessDB controller type.
	ServerlessDBControllerKind = v1alpha1.SchemeGroupVersion.WithKind("ServerlessDB")
)

Functions

func FilterOutCondition

func FilterOutCondition(conditions []v1alpha1.ServerlessDBCondition, condType v1alpha1.ConditionType) []v1alpha1.ServerlessDBCondition

FilterOutCondition returns a new slice of ServerlessDB conditions without conditions with the provided type.

func GetProxyResourceName

func GetProxyResourceName(instanceName string) string

func GetServerlessDBCondition

func GetServerlessDBCondition(status v1alpha1.ServerlessDBStatus, condType v1alpha1.ConditionType) *v1alpha1.ServerlessDBCondition

GetServerlessDBCondition returns the condition with the provided type.

func IgnoreErrorf

func IgnoreErrorf(format string, a ...interface{}) error

IgnoreErrorf returns a IgnoreError

func IsIgnoreError

func IsIgnoreError(err error) bool

IsIgnoreError returns whether err is a IgnoreError

func IsRequeueError

func IsRequeueError(err error) bool

IsRequeueError returns whether err is a RequeueError

func IsServerlessDBRestart

func IsServerlessDBRestart(db *v1alpha1.ServerlessDB) bool

IsServerlessDBRestart, true means tidb is restarting.

func IsServerlessDBSilence

func IsServerlessDBSilence(db *v1alpha1.ServerlessDB) bool

IsServerlessDBSilence, true means tidb server pods replica is zero.

func LabelEq

func LabelEq(key string, val string) *labels.Requirement

func LabelsComponentForServerlessDB

func LabelsComponentForServerlessDB(name, component string) map[string]string

LabelsProxyForServerlessDB returns the labels for selecting the resources belonging to the given CR name.

func LabelsForServerlessDB

func LabelsForServerlessDB(name string) map[string]string

LabelsForServerlessDB returns the labels for selecting the resources belonging to the given CR name.

func NewServerlessDBCondition

func NewServerlessDBCondition(condType v1alpha1.ConditionType, status v1.ConditionStatus, reason, message string) *v1alpha1.ServerlessDBCondition

NewServerlessDBCondition creates a new ServerlessDB condition.

func RequeueErrorf

func RequeueErrorf(format string, a ...interface{}) error

RequeueErrorf returns a RequeueError

func SetServerlessDBCondition

func SetServerlessDBCondition(status *v1alpha1.ServerlessDBStatus, condition v1alpha1.ServerlessDBCondition)

SetServerlessDBCondition updates the ServerlessDB to include the provided condition. If the condition that we are about to add already exists and has the same status and reason then we are not going to update.

Types

type IgnoreError

type IgnoreError struct {
	// contains filtered or unexported fields
}

IgnoreError is used to ignore this item, this error type should't be considered as a real error, no need to requeue

func (*IgnoreError) Error

func (re *IgnoreError) Error() string

type Label

type Label map[string]string

Label is the label field in metadata

func New

func New() Label

New initialize a new Label for components of tidb cluster

func (Label) BcRdsInstance

func (l Label) BcRdsInstance(name string) Label

Instance adds instance kv pair to label

func (Label) Component

func (l Label) Component(name string) Label

Component adds component kv pair to label

func (Label) Copy

func (l Label) Copy() Label

Copy copy the value of label to avoid pointer copy

func (Label) Instance

func (l Label) Instance(name string) Label

Instance adds instance kv pair to label

func (Label) LabelSelector

func (l Label) LabelSelector() *metav1.LabelSelector

LabelSelector gets LabelSelector from label

func (Label) Labels

func (l Label) Labels() map[string]string

Labels converts label to map[string]string

func (Label) Selector

func (l Label) Selector() (labels.Selector, error)

Selector gets labels.Selector from label

func (Label) String

func (l Label) String() string

String converts label to a string

type RequeueError

type RequeueError struct {
	// contains filtered or unexported fields
}

RequeueError is used to requeue the item, this error type should't be considered as a real error

func (*RequeueError) Error

func (re *RequeueError) Error() string

Jump to

Keyboard shortcuts

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