Skip to content

Commit 1a8661b

Browse files
authored
Properly resolve the name of the basic auth secret for a SolrCloud when calling the backup API (#370)
1 parent ff3bcd1 commit 1a8661b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

controllers/solrbackup_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (r *SolrBackupReconciler) reconcileSolrCloudBackup(ctx context.Context, bac
179179

180180
// Add any additional values needed to Authn to Solr to the Context used when invoking the API
181181
if solrCloud.Spec.SolrSecurity != nil {
182-
ctx, err = util.AddAuthToContext(ctx, &r.Client, solrCloud.Spec.SolrSecurity, solrCloud.Namespace)
182+
ctx, err = util.AddAuthToContext(ctx, &r.Client, solrCloud)
183183
if err != nil {
184184
return nil, actionTaken, err
185185
}

controllers/util/solr_security_util.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,11 @@ func (security *SecurityConfig) AddAuthToContext(ctx context.Context) (context.C
221221
}
222222

223223
// Similar to security.AddAuthToContext but we need to lookup the secret containing the authn credentials first
224-
func AddAuthToContext(ctx context.Context, client *client.Client, solrSecurity *solr.SolrSecurityOptions, ns string) (context.Context, error) {
225-
reader := *client
226-
if solrSecurity.AuthenticationType == solr.Basic {
224+
func AddAuthToContext(ctx context.Context, client *client.Client, solrCloud *solr.SolrCloud) (context.Context, error) {
225+
if solrCloud.Spec.SolrSecurity != nil && solrCloud.Spec.SolrSecurity.AuthenticationType == solr.Basic {
226+
reader := *client
227227
basicAuthSecret := &corev1.Secret{}
228-
if err := reader.Get(ctx, types.NamespacedName{Name: solrSecurity.BasicAuthSecret, Namespace: ns}, basicAuthSecret); err != nil {
228+
if err := reader.Get(ctx, types.NamespacedName{Name: solrCloud.BasicAuthSecretName(), Namespace: solrCloud.Namespace}, basicAuthSecret); err != nil {
229229
return nil, err
230230
}
231231
return contextWithBasicAuthHeader(ctx, basicAuthSecret), nil

0 commit comments

Comments
 (0)