Skip to content

Commit deb5dd4

Browse files
committed
osrdyne: add k8s/keda authentication ref support
Signed-off-by: Élyse Viard <elysasrc@tuta.com>
1 parent 8ebfe52 commit deb5dd4

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

osrdyne/src/drivers/kubernetes.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ pub struct KedaOptions {
5959
/// Max Replicas for the HPA of the ScaledObject
6060
pub max_replicas: i32,
6161

62-
/// Amqp Host
62+
/// Amqp Host, without authentication ref
6363
pub amqp_host: String,
6464

65+
/// Amqp Host, with authentication ref
66+
pub authentication_ref: Option<String>,
67+
6568
/// Mode
6669
pub mode: String,
6770

@@ -298,9 +301,18 @@ impl KubernetesDriver {
298301
type_: "rabbitmq".to_string(),
299302
use_cached_metrics: Some(keda.use_cached_metrics),
300303
metric_type: keda.metric_type.clone(),
304+
authentication_ref: keda
305+
.authentication_ref
306+
.clone()
307+
.map(|auth_ref| keda::AuthenticationRef { name: auth_ref }),
301308
metadata: {
302309
let mut metadata = HashMap::new();
303-
metadata.insert("host".to_string(), keda.amqp_host.clone());
310+
311+
// If there is no authentication reference, we use the amqp host from the KEDA configuration.
312+
if keda.authentication_ref.is_none() {
313+
metadata.insert("host".to_string(), keda.amqp_host.clone());
314+
}
315+
304316
metadata.insert("protocol".to_string(), "auto".to_string());
305317
metadata.insert("mode".to_string(), keda.mode.clone());
306318
metadata.insert("value".to_string(), keda.value.clone());

osrdyne/src/drivers/kubernetes/keda.rs

+7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ pub enum MetricType {
4444
pub struct Trigger {
4545
pub type_: String,
4646
pub metadata: HashMap<String, String>,
47+
pub authentication_ref: Option<AuthenticationRef>,
4748
pub use_cached_metrics: Option<bool>,
4849
pub metric_type: MetricType,
4950
}
51+
52+
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
53+
#[serde(rename_all = "camelCase")]
54+
pub struct AuthenticationRef {
55+
pub name: String,
56+
}

0 commit comments

Comments
 (0)