Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
ideascf committed Oct 25, 2024
1 parent 5a0911f commit 33fe843
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/manager/member/ticdc_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,6 @@ func getNewTiCDCStatefulSet(tc *v1alpha1.TidbCluster, cm *corev1.ConfigMap) (*ap
vols = append(vols, annVolume)
}

clusterTLSSecretName := util.ClusterTLSSecretName(tc.Name, label.TiCDCLabelVal)
if tc.Spec.TiCDC.ClusterTLSSecretName != "" {
clusterTLSSecretName = tc.Spec.TiCDC.ClusterTLSSecretName
}
if tc.IsTLSClusterEnabled() {
volMounts = append(volMounts, corev1.VolumeMount{
Name: ticdcCertVolumeMount,
Expand All @@ -409,7 +405,7 @@ func getNewTiCDCStatefulSet(tc *v1alpha1.TidbCluster, cm *corev1.ConfigMap) (*ap
vols = append(vols, corev1.Volume{
Name: ticdcCertVolumeMount, VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: clusterTLSSecretName,
SecretName: getTiCDCClusterTLSCertSecretName(tc),
},
},
}, corev1.Volume{
Expand Down Expand Up @@ -570,6 +566,15 @@ func getNewTiCDCStatefulSet(tc *v1alpha1.TidbCluster, cm *corev1.ConfigMap) (*ap
return ticdcSts, nil
}

func getTiCDCClusterTLSCertSecretName(tc *v1alpha1.TidbCluster) string {
clusterTLSSecretName := util.ClusterTLSSecretName(tc.Name, label.TiCDCLabelVal)
if tc.Spec.TiCDC.ClusterTLSSecretName != "" {
clusterTLSSecretName = tc.Spec.TiCDC.ClusterTLSSecretName
}

return clusterTLSSecretName
}

func labelTiCDC(tc *v1alpha1.TidbCluster) label.Label {
instanceName := tc.GetInstanceName()
return label.New().Instance(instanceName).TiCDC()
Expand Down

0 comments on commit 33fe843

Please sign in to comment.