@@ -68,7 +68,7 @@ func (r *ReplicaSetReconciler) validateTLSConfig(ctx context.Context, mdb mdbv1.
6868
6969 // validate whether the secret contains "tls.crt" and "tls.key", or it contains "tls.pem"
7070 // if it contains all three, then the pem entry should be equal to the concatenation of crt and key
71- _ , err = getPemOrConcatenatedCrtAndKey (ctx , r .client , mdb , mdb .TLSSecretNamespacedName ())
71+ _ , err = getPemOrConcatenatedCrtAndKey (ctx , r .client , mdb .TLSSecretNamespacedName ())
7272 if err != nil {
7373 r .log .Warnf (err .Error ())
7474 return false , nil
@@ -100,7 +100,7 @@ func getTLSConfigModification(ctx context.Context, cmGetter configmap.Getter, se
100100 return automationconfig .NOOP (), err
101101 }
102102
103- certKey , err := getPemOrConcatenatedCrtAndKey (ctx , secretGetter , mdb , mdb .TLSSecretNamespacedName ())
103+ certKey , err := getPemOrConcatenatedCrtAndKey (ctx , secretGetter , mdb .TLSSecretNamespacedName ())
104104 if err != nil {
105105 return automationconfig .NOOP (), err
106106 }
@@ -109,7 +109,7 @@ func getTLSConfigModification(ctx context.Context, cmGetter configmap.Getter, se
109109}
110110
111111// getCertAndKey will fetch the certificate and key from the user-provided Secret.
112- func getCertAndKey (ctx context.Context , getter secret.Getter , mdb mdbv1. MongoDBCommunity , secretName types.NamespacedName ) string {
112+ func getCertAndKey (ctx context.Context , getter secret.Getter , secretName types.NamespacedName ) string {
113113 cert , err := secret .ReadKey (ctx , getter , tlsSecretCertName , secretName )
114114 if err != nil {
115115 return ""
@@ -124,7 +124,7 @@ func getCertAndKey(ctx context.Context, getter secret.Getter, mdb mdbv1.MongoDBC
124124}
125125
126126// getPem will fetch the pem from the user-provided secret
127- func getPem (ctx context.Context , getter secret.Getter , mdb mdbv1. MongoDBCommunity , secretName types.NamespacedName ) string {
127+ func getPem (ctx context.Context , getter secret.Getter , secretName types.NamespacedName ) string {
128128 pem , err := secret .ReadKey (ctx , getter , tlsSecretPemName , secretName )
129129 if err != nil {
130130 return ""
@@ -142,9 +142,9 @@ func combineCertificateAndKey(cert, key string) string {
142142// This is either the tls.pem entry in the given secret, or the concatenation
143143// of tls.crt and tls.key
144144// It performs a basic validation on the entries.
145- func getPemOrConcatenatedCrtAndKey (ctx context.Context , getter secret.Getter , mdb mdbv1. MongoDBCommunity , secretName types.NamespacedName ) (string , error ) {
146- certKey := getCertAndKey (ctx , getter , mdb , secretName )
147- pem := getPem (ctx , getter , mdb , secretName )
145+ func getPemOrConcatenatedCrtAndKey (ctx context.Context , getter secret.Getter , secretName types.NamespacedName ) (string , error ) {
146+ certKey := getCertAndKey (ctx , getter , secretName )
147+ pem := getPem (ctx , getter , secretName )
148148 if certKey == "" && pem == "" {
149149 return "" , fmt .Errorf (`neither "%s" nor the pair "%s"/"%s" were present in the TLS secret` , tlsSecretPemName , tlsSecretCertName , tlsSecretKeyName )
150150 }
@@ -210,7 +210,7 @@ func ensureCASecret(ctx context.Context, cmGetter configmap.Getter, secretGetter
210210// ensureTLSSecret will create or update the operator-managed Secret containing
211211// the concatenated certificate and key from the user-provided Secret.
212212func ensureTLSSecret (ctx context.Context , getUpdateCreator secret.GetUpdateCreator , mdb mdbv1.MongoDBCommunity ) error {
213- certKey , err := getPemOrConcatenatedCrtAndKey (ctx , getUpdateCreator , mdb , mdb .TLSSecretNamespacedName ())
213+ certKey , err := getPemOrConcatenatedCrtAndKey (ctx , getUpdateCreator , mdb .TLSSecretNamespacedName ())
214214 if err != nil {
215215 return err
216216 }
@@ -232,7 +232,7 @@ func ensureAgentCertSecret(ctx context.Context, getUpdateCreator secret.GetUpdat
232232 return nil
233233 }
234234
235- certKey , err := getPemOrConcatenatedCrtAndKey (ctx , getUpdateCreator , mdb , mdb .AgentCertificateSecretNamespacedName ())
235+ certKey , err := getPemOrConcatenatedCrtAndKey (ctx , getUpdateCreator , mdb .AgentCertificateSecretNamespacedName ())
236236 if err != nil {
237237 return err
238238 }
@@ -250,7 +250,7 @@ func ensureAgentCertSecret(ctx context.Context, getUpdateCreator secret.GetUpdat
250250// ensurePrometheusTLSSecret will create or update the operator-managed Secret containing
251251// the concatenated certificate and key from the user-provided Secret.
252252func ensurePrometheusTLSSecret (ctx context.Context , getUpdateCreator secret.GetUpdateCreator , mdb mdbv1.MongoDBCommunity ) error {
253- certKey , err := getPemOrConcatenatedCrtAndKey (ctx , getUpdateCreator , mdb , mdb .DeepCopy ().PrometheusTLSSecretNamespacedName ())
253+ certKey , err := getPemOrConcatenatedCrtAndKey (ctx , getUpdateCreator , mdb .DeepCopy ().PrometheusTLSSecretNamespacedName ())
254254 if err != nil {
255255 return err
256256 }
0 commit comments