builder

package
v0.0.0-...-79e99aa Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DoltContainerName     = "dolt"
	DoltInitContainerName = "dolt-init"

	DoltMySQLPortName      = "tcp-dolt"
	DoltRemotesAPIPortName = "grpc-remotesapi"
	DoltMetricsPortName    = "http-metrics"
	DoltProfilerPortName   = "http-profiler"
	DoltMCPPortName        = "http-mcp"

	DoltDataVolume   = "dolt-data"
	DoltConfigVolume = "dolt-config"

	DoltDataMountPath   = "/db"
	DoltConfigMountPath = "/etc/doltdb"

	DefaultLivenessProbeInitialDelaySeconds  = 60
	DefaultReadinessProbeInitialDelaySeconds = 40
	DefaultProbePeriodSeconds                = 10
	DefaultProbeTimeoutSeconds               = 3
)
View Source
const (
	SnapshotClassNameConst   = "csi-hostpath-snapclass-v1"
	VolumeSnapshotAPIVersion = "snapshot.storage.k8s.io/v1"
	VolumeSnapshotKind       = "VolumeSnapshot"
)
View Source
const (
	ConfigmapKey = "dolt.yaml"
)

Variables

This section is empty.

Functions

func HashConfigMapData

func HashConfigMapData(data map[string]string) string

HashConfigMapData computes a SHA256 hash of the ConfigMap data. The keys are sorted to ensure consistent hash values regardless of map iteration order.

Types

type Builder

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

Builder is a struct that holds a Kubernetes runtime scheme.

func NewBuilder

func NewBuilder(scheme *runtime.Scheme) *Builder

NewBuilder creates a new instance of Builder with the provided runtime scheme.

func (*Builder) BuildClusterRoleBinding

func (b *Builder) BuildClusterRoleBinding(key types.NamespacedName, doltdb *doltv1alpha.DoltDB, sa *corev1.ServiceAccount,
	roleRef rbacv1.RoleRef) (*rbacv1.ClusterRoleBinding, error)

BuildClusterRoleBinding creates a ClusterRoleBinding object that binds the specified ServiceAccount to the RoleRef and sets the controller reference.

func (*Builder) BuildConfigMap

func (b *Builder) BuildConfigMap(options ConfigMapOpts, doltdb *doltv1alpha.DoltDB) (*corev1.ConfigMap, error)

BuildConfigMap creates a ConfigMap based on the provided options and sets the owner reference. It returns the created ConfigMap or an error if the operation fails.

func (*Builder) BuildCronJob

func (b *Builder) BuildCronJob(options CronJobOpts, doltdb *doltv1alpha.DoltDB, snapshot *doltv1alpha.Snapshot) (*batchv1.CronJob, error)

BuildCronJob creates a cronJob based on the provided options and sets the owner reference. It returns the created cronJob or an error if the operation fails.

func (*Builder) BuildDoltInternalService

func (b *Builder) BuildDoltInternalService(doltdb *doltv1alpha.DoltDB) (*v1.Service, error)

BuildDoltInternalService creates a headless service for the Dolt cluster.

func (*Builder) BuildDoltPrimaryService

func (b *Builder) BuildDoltPrimaryService(doltdb *doltv1alpha.DoltDB) (*v1.Service, error)

BuildDoltPrimaryService creates a primary service for the Dolt cluster.

func (*Builder) BuildDoltReaderService

func (b *Builder) BuildDoltReaderService(doltdb *doltv1alpha.DoltDB) (*v1.Service, error)

BuildDoltReaderService creates a reader service for the Dolt cluster.

func (*Builder) BuildDoltService

func (b *Builder) BuildDoltService(doltdb *doltv1alpha.DoltDB) (*v1.Service, error)

BuildDoltService creates a service for standalone mode when replication is disabled.

func (*Builder) BuildDoltStatefulSet

func (b *Builder) BuildDoltStatefulSet(
	key types.NamespacedName,
	doltdb *doltv1alpha.DoltDB,
	configMapHash string,
) (*appsv1.StatefulSet, error)

BuildDoltStatefulSet constructs a StatefulSet for a DoltDB based on the provided NamespacedName and DoltDB object. It sets up the metadata, labels, volume claim templates, and pod template for the StatefulSet. The configMapHash parameter is included in the pod template annotations to trigger pod restarts when the ConfigMap content changes (e.g., when replicas are scaled up or down). If UpdateStrategy is set to "Never", the configMapHash is not included in the pod template.

func (*Builder) BuildExternalSnapshot

func (b *Builder) BuildExternalSnapshot(pvcName string, doltdb *doltv1alpha.DoltDB) (VolumeSnapshot, error)

BuildExternalSnapshot creates a snapshot cr for taking volume backup.

func (*Builder) BuildPodDisruptionBudget

func (b *Builder) BuildPodDisruptionBudget(opts PodDisruptionBudgetOpts, owner *doltv1alpha.DoltDB) (*policyv1.PodDisruptionBudget, error)

func (*Builder) BuildRole

func (b *Builder) BuildRole(key types.NamespacedName, doltdb *doltv1alpha.DoltDB, rules []rbacv1.PolicyRule) (*rbacv1.Role, error)

BuildRole creates a Role object with the specified rules and sets the controller reference.

func (*Builder) BuildRoleBinding

func (b *Builder) BuildRoleBinding(key types.NamespacedName, doltdb *doltv1alpha.DoltDB, sa *corev1.ServiceAccount,
	roleRef rbacv1.RoleRef) (*rbacv1.RoleBinding, error)

BuildRoleBinding creates a RoleBinding object that binds the specified ServiceAccount to the RoleRef and sets the controller reference.

func (*Builder) BuildServiceAccount

func (b *Builder) BuildServiceAccount(key types.NamespacedName, doltdb *doltv1alpha.DoltDB) (*corev1.ServiceAccount, error)

BuildServiceAccount creates a ServiceAccount object and sets the controller reference.

type ConfigMapOpts

type ConfigMapOpts struct {
	Metadata *metav1.ObjectMeta
	Key      types.NamespacedName
	Data     map[string]string
}

ConfigMapOpts holds the options for building a ConfigMap.

type CronJobOpts

type CronJobOpts struct {
	Metadata      *metav1.ObjectMeta
	Key           types.NamespacedName
	ConfigMapName string
	Schedule      string
}

CronJobOpts holds the options for building a CronJob.

type LabelsBuilder

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

func NewLabelsBuilder

func NewLabelsBuilder() *LabelsBuilder

NewLabelsBuilder creates a new instance of LabelsBuilder.

func (*LabelsBuilder) Build

func (b *LabelsBuilder) Build() map[string]string

Build returns the constructed labels map.

func (*LabelsBuilder) WithApp

func (b *LabelsBuilder) WithApp(app string) *LabelsBuilder

WithApp sets the app label.

func (*LabelsBuilder) WithDoltSelectorLabels

func (b *LabelsBuilder) WithDoltSelectorLabels(doltdb *doltv1alpha.DoltDB) *LabelsBuilder

WithDoltSelectorLabels sets the app and instance labels for a DoltDB.

func (*LabelsBuilder) WithInstance

func (b *LabelsBuilder) WithInstance(instance string) *LabelsBuilder

WithInstance sets the instance label.

func (*LabelsBuilder) WithLabels

func (b *LabelsBuilder) WithLabels(labels map[string]string) *LabelsBuilder

WithLabels adds multiple labels to the builder.

func (*LabelsBuilder) WithManagedBy

func (b *LabelsBuilder) WithManagedBy(owner string) *LabelsBuilder

WithManagedBy sets the owner label.

func (*LabelsBuilder) WithPVCRole

func (b *LabelsBuilder) WithPVCRole(role string) *LabelsBuilder

WithPVCRole sets the PVC role label.

func (*LabelsBuilder) WithPartOf

func (b *LabelsBuilder) WithPartOf(system string) *LabelsBuilder

WithPartOf sets the part of label.

func (*LabelsBuilder) WithPodPrimaryRole

func (b *LabelsBuilder) WithPodPrimaryRole() *LabelsBuilder

WithPodRole sets the pod role label to primary.

func (*LabelsBuilder) WithPodStandbyRole

func (b *LabelsBuilder) WithPodStandbyRole() *LabelsBuilder

WithPodStandbyRole sets the pod role label to standby.

func (*LabelsBuilder) WithStatefulSetPod

func (b *LabelsBuilder) WithStatefulSetPod(doltdb *doltv1alpha.DoltDB, podIndex int) *LabelsBuilder

WithStatefulSetPod sets the stateful set pod name label.

func (*LabelsBuilder) WithVersion

func (b *LabelsBuilder) WithVersion(version string) *LabelsBuilder

WithApp sets the engine version label

type MetadataBuilder

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

func NewMetadataBuilder

func NewMetadataBuilder(key types.NamespacedName) *MetadataBuilder

NewMetadataBuilder creates a new MetadataBuilder with the given NamespacedName.

func (*MetadataBuilder) Build

func (b *MetadataBuilder) Build() metav1.ObjectMeta

Build returns the constructed ObjectMeta.

func (*MetadataBuilder) WithAnnotations

func (b *MetadataBuilder) WithAnnotations(annotations map[string]string) *MetadataBuilder

WithAnnotations adds the given annotations to the metadata.

func (*MetadataBuilder) WithLabels

func (b *MetadataBuilder) WithLabels(labels map[string]string) *MetadataBuilder

WithLabels adds the given labels to the metadata.

func (*MetadataBuilder) WithMetadata

func (b *MetadataBuilder) WithMetadata(meta *metav1.ObjectMeta) *MetadataBuilder

WithMetadata adds labels and annotations from the given DoltDB metadata.

func (*MetadataBuilder) WithReleaseLabel

func (b *MetadataBuilder) WithReleaseLabel(release string) *MetadataBuilder

WithReleaseLabel adds a release label to the metadata if the release string is not empty.

type PodDisruptionBudgetOpts

type PodDisruptionBudgetOpts struct {
	Metadata       *metav1.ObjectMeta
	Key            types.NamespacedName
	MinAvailable   *intstr.IntOrString
	MaxUnavailable *intstr.IntOrString
	SelectorLabels map[string]string
}

type Source

type Source struct {
	PersistentVolumeClaimName string `json:"persistentVolumeClaimName" yaml:"persistentVolumeClaimName"`
}

Source represents the source of the VolumeSnapshot.

type VolumeSnapshot

type VolumeSnapshot struct {
	APIVersion         string             `json:"apiVersion" yaml:"apiVersion"`
	Kind               string             `json:"kind"       yaml:"kind"`
	Metadata           metav1.ObjectMeta  `json:"metadata"   yaml:"metadata"`
	VolumeSnapshotSpec VolumeSnapshotSpec `json:"spec"       yaml:"spec"`
}

VolumeSnapshot represents a VolumeSnapshot CR.

type VolumeSnapshotSpec

type VolumeSnapshotSpec struct {
	VolumeSnapshotClassName string `json:"volumeSnapshotClassName" yaml:"volumeSnapshotClassName"`
	Source                  Source `json:"source"                  yaml:"source"`
}

VolumeSnapshotSpec represents the spec of the VolumeSnapshot.

Jump to

Keyboard shortcuts

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