Skip to content

Commit

Permalink
Fix rabbitmq client builder for disable auth (#138)
Browse files Browse the repository at this point in the history
Signed-off-by: raihankhan <raihan@appscode.com>
  • Loading branch information
raihankhan authored Sep 6, 2024
1 parent 2af340c commit 392630b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions rabbitmq/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,9 @@ func (o *KubeDBClientBuilder) GetRabbitMQClient() (*Client, error) {
authSecret := &core.Secret{}
var username, password string
if !o.db.Spec.DisableSecurity {
if o.db.Spec.AuthSecret == nil {
klog.Info("Auth-secret not set")
return nil, errors.New("auth-secret is not set")
}
err := o.kc.Get(o.ctx, types.NamespacedName{
Namespace: o.db.Namespace,
Name: o.db.Spec.AuthSecret.Name,
Name: o.db.GetAuthSecretName(),
}, authSecret)
if err != nil {
if kerr.IsNotFound(err) {
Expand All @@ -136,7 +132,7 @@ func (o *KubeDBClientBuilder) GetRabbitMQClient() (*Client, error) {
}

var tlsConfig *tls.Config
if o.db.Spec.EnableSSL {
if o.db.Spec.EnableSSL && !o.db.Spec.DisableSecurity {
certSecret := &core.Secret{}
err := o.kc.Get(o.ctx, types.NamespacedName{
Namespace: o.db.Namespace,
Expand Down Expand Up @@ -191,7 +187,7 @@ func (o *KubeDBClientBuilder) GetRabbitMQClient() (*Client, error) {
})
}
return rmqhttp.NewClient(o.httpURL, username, password)
}(o.db.Spec.EnableSSL)
}(o.db.Spec.EnableSSL && !o.db.Spec.DisableSecurity)
if err != nil {
klog.Error(err, "Failed to get http client for rabbitmq")
return nil, err
Expand Down Expand Up @@ -241,7 +237,7 @@ func (o *KubeDBClientBuilder) GetAMQPconnURL(username string, password string, v
func (o *KubeDBClientBuilder) GetHTTPconnURL() string {
protocolScheme := o.db.GetConnectionScheme()
connectionPort := func(scheme string) int {
if scheme == "http" {
if scheme == "http" || o.db.Spec.DisableSecurity {
return kubedb.RabbitMQManagementUIPort
} else {
return kubedb.RabbitMQManagementUIPortWithSSL
Expand Down

0 comments on commit 392630b

Please sign in to comment.