This is an automated email from the ASF dual-hosted git repository.

thelabdude pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 1a8661b  Properly resolve the name of the basic auth secret for a 
SolrCloud when calling the backup API (#370)
1a8661b is described below

commit 1a8661bab03656f55a3352835b8496d5e6757f9d
Author: Timothy Potter <[email protected]>
AuthorDate: Tue Nov 9 11:58:01 2021 -0700

    Properly resolve the name of the basic auth secret for a SolrCloud when 
calling the backup API (#370)
---
 controllers/solrbackup_controller.go   | 2 +-
 controllers/util/solr_security_util.go | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/controllers/solrbackup_controller.go 
b/controllers/solrbackup_controller.go
index c5905c1..12661cc 100644
--- a/controllers/solrbackup_controller.go
+++ b/controllers/solrbackup_controller.go
@@ -179,7 +179,7 @@ func (r *SolrBackupReconciler) reconcileSolrCloudBackup(ctx 
context.Context, bac
 
        // Add any additional values needed to Authn to Solr to the Context 
used when invoking the API
        if solrCloud.Spec.SolrSecurity != nil {
-               ctx, err = util.AddAuthToContext(ctx, &r.Client, 
solrCloud.Spec.SolrSecurity, solrCloud.Namespace)
+               ctx, err = util.AddAuthToContext(ctx, &r.Client, solrCloud)
                if err != nil {
                        return nil, actionTaken, err
                }
diff --git a/controllers/util/solr_security_util.go 
b/controllers/util/solr_security_util.go
index c483181..d4f7e71 100644
--- a/controllers/util/solr_security_util.go
+++ b/controllers/util/solr_security_util.go
@@ -221,11 +221,11 @@ func (security *SecurityConfig) AddAuthToContext(ctx 
context.Context) (context.C
 }
 
 // Similar to security.AddAuthToContext but we need to lookup the secret 
containing the authn credentials first
-func AddAuthToContext(ctx context.Context, client *client.Client, solrSecurity 
*solr.SolrSecurityOptions, ns string) (context.Context, error) {
-       reader := *client
-       if solrSecurity.AuthenticationType == solr.Basic {
+func AddAuthToContext(ctx context.Context, client *client.Client, solrCloud 
*solr.SolrCloud) (context.Context, error) {
+       if solrCloud.Spec.SolrSecurity != nil && 
solrCloud.Spec.SolrSecurity.AuthenticationType == solr.Basic {
+               reader := *client
                basicAuthSecret := &corev1.Secret{}
-               if err := reader.Get(ctx, types.NamespacedName{Name: 
solrSecurity.BasicAuthSecret, Namespace: ns}, basicAuthSecret); err != nil {
+               if err := reader.Get(ctx, types.NamespacedName{Name: 
solrCloud.BasicAuthSecretName(), Namespace: solrCloud.Namespace}, 
basicAuthSecret); err != nil {
                        return nil, err
                }
                return contextWithBasicAuthHeader(ctx, basicAuthSecret), nil

Reply via email to