Skip to content

Commit 67af475

Browse files
committed
fix go lint errors
Signed-off-by: josedev-union <[email protected]>
1 parent 468cd18 commit 67af475

File tree

1 file changed

+8
-28
lines changed
  • opensearch-operator/pkg/reconcilers

1 file changed

+8
-28
lines changed

opensearch-operator/pkg/reconcilers/tls.go

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -506,13 +506,14 @@ func (r *TLSReconciler) handleTransportExistingCerts() error {
506506
}
507507

508508
// Implement new mounting logic based on CaSecret.Name configuration
509-
if tlsConfig.CaSecret.Name == "" {
509+
switch name := tlsConfig.CaSecret.Name; name {
510+
case "":
510511
// If CaSecret.Name is empty, mount Secret.Name as a directory
511512
mountFolder("transport", "certs", tlsConfig.Secret.Name, r.reconcilerContext)
512-
} else if tlsConfig.CaSecret.Name == tlsConfig.Secret.Name {
513+
case tlsConfig.Secret.Name:
513514
// If CaSecret.Name is same as Secret.Name, mount only Secret.Name as a directory
514515
mountFolder("transport", "certs", tlsConfig.Secret.Name, r.reconcilerContext)
515-
} else {
516+
default:
516517
// If CaSecret.Name is different from Secret.Name, mount both secrets as directories
517518
// Mount Secret.Name as tls-transport/
518519
mountFolder("transport", "certs", tlsConfig.Secret.Name, r.reconcilerContext)
@@ -632,13 +633,14 @@ func (r *TLSReconciler) handleHttp() error {
632633
}
633634

634635
// Implement new mounting logic based on CaSecret.Name configuration
635-
if tlsConfig.CaSecret.Name == "" {
636+
switch name := tlsConfig.CaSecret.Name; name {
637+
case "":
636638
// If CaSecret.Name is empty, mount Secret.Name as a directory
637639
mountFolder("http", "certs", tlsConfig.Secret.Name, r.reconcilerContext)
638-
} else if tlsConfig.CaSecret.Name == tlsConfig.Secret.Name {
640+
case tlsConfig.Secret.Name:
639641
// If CaSecret.Name is same as Secret.Name, mount only Secret.Name as a directory
640642
mountFolder("http", "certs", tlsConfig.Secret.Name, r.reconcilerContext)
641-
} else {
643+
default:
642644
// If CaSecret.Name is different from Secret.Name, mount both secrets as directories
643645
// Mount Secret.Name as tls-http/
644646
mountFolder("http", "certs", tlsConfig.Secret.Name, r.reconcilerContext)
@@ -686,28 +688,6 @@ func (r *TLSReconciler) providedCaCert(secretName string, namespace string) (tls
686688
return ca, nil
687689
}
688690

689-
func mountWithHotReload(interfaceName string, name string, filename string, secretName string, reconcilerContext *ReconcilerContext, enableHotReload bool) {
690-
volume := corev1.Volume{Name: interfaceName + "-" + name, VolumeSource: corev1.VolumeSource{Secret: &corev1.SecretVolumeSource{SecretName: secretName}}}
691-
reconcilerContext.Volumes = append(reconcilerContext.Volumes, volume)
692-
693-
var mount corev1.VolumeMount
694-
if enableHotReload {
695-
// Mount the entire secret as a directory to enable hot reloading
696-
mount = corev1.VolumeMount{
697-
Name: interfaceName + "-" + name,
698-
MountPath: fmt.Sprintf("/usr/share/opensearch/config/tls-%s-%s", interfaceName, name),
699-
}
700-
} else {
701-
// Use subPath for backward compatibility (prevents hot reloading)
702-
mount = corev1.VolumeMount{
703-
Name: interfaceName + "-" + name,
704-
MountPath: fmt.Sprintf("/usr/share/opensearch/config/tls-%s/%s", interfaceName, filename),
705-
SubPath: filename,
706-
}
707-
}
708-
reconcilerContext.VolumeMounts = append(reconcilerContext.VolumeMounts, mount)
709-
}
710-
711691
func mountFolder(interfaceName string, name string, secretName string, reconcilerContext *ReconcilerContext) {
712692
volume := corev1.Volume{Name: interfaceName + "-" + name, VolumeSource: corev1.VolumeSource{Secret: &corev1.SecretVolumeSource{SecretName: secretName}}}
713693
reconcilerContext.Volumes = append(reconcilerContext.Volumes, volume)

0 commit comments

Comments
 (0)