From 977de43802a72bf2e66e35a9ffb0f4d5a1d3d34c Mon Sep 17 00:00:00 2001 From: "Michi U." <4169888+michemache@users.noreply.github.com> Date: Thu, 28 Nov 2024 11:54:56 +0100 Subject: [PATCH] use vhostName from authParams when declared Signed-off-by: Michi U. <4169888+michemache@users.noreply.github.com> --- pkg/scalers/rabbitmq_scaler.go | 2 +- pkg/scalers/rabbitmq_scaler_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/scalers/rabbitmq_scaler.go b/pkg/scalers/rabbitmq_scaler.go index 43a62a404ee..e0e7a10ad7f 100644 --- a/pkg/scalers/rabbitmq_scaler.go +++ b/pkg/scalers/rabbitmq_scaler.go @@ -86,7 +86,7 @@ type rabbitMQMetadata struct { // either http or amqp protocol Protocol string `keda:"name=protocol, order=triggerMetadata;authParams, optional, default=auto"` // override the vhost from the connection info - VhostName string `keda:"name=vhostName, order=triggerMetadata, optional"` + VhostName string `keda:"name=vhostName, order=triggerMetadata;authParams, optional"` // specify if the queueName contains a rexeg UseRegex bool `keda:"name=useRegex, order=triggerMetadata, optional"` // specify if the QueueLength value should exclude Unacknowledged messages (Ready messages only) diff --git a/pkg/scalers/rabbitmq_scaler_test.go b/pkg/scalers/rabbitmq_scaler_test.go index ed1785e5be3..a75412fea62 100644 --- a/pkg/scalers/rabbitmq_scaler_test.go +++ b/pkg/scalers/rabbitmq_scaler_test.go @@ -161,6 +161,10 @@ var testRabbitMQAuthParamData = []parseRabbitMQAuthParamTestData{ {map[string]string{"queueName": "sample", "hostFromEnv": host}, v1alpha1.AuthPodIdentity{}, map[string]string{"username": "user"}, true, rmqTLSDisable, false}, // failure, password but no username {map[string]string{"queueName": "sample", "hostFromEnv": host}, v1alpha1.AuthPodIdentity{}, map[string]string{"password": "PASSWORD"}, true, rmqTLSDisable, false}, + // success, vhostName + {map[string]string{"queueName": "sample", "hostFromEnv": host}, v1alpha1.AuthPodIdentity{}, map[string]string{"vhostName": "myVhost"}, false, rmqTLSDisable, false}, + // success, vhostName but empty + {map[string]string{"queueName": "sample", "hostFromEnv": host}, v1alpha1.AuthPodIdentity{}, map[string]string{"vhostName": ""}, false, rmqTLSDisable, false}, // success, username and password from env {map[string]string{"queueName": "sample", "hostFromEnv": host, "usernameFromEnv": rabbitMQUsername, "passwordFromEnv": rabbitMQPassword}, v1alpha1.AuthPodIdentity{}, map[string]string{}, false, rmqTLSDisable, false}, // failure, username from env but not password