Skip to content

Commit c34f8a1

Browse files
committed
refactor: use v2 Port type
1 parent ea753f3 commit c34f8a1

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

rust/operator-binary/src/controller/build/security.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use stackable_operator::{
2626
apimachinery::pkg::util::intstr::IntOrString,
2727
},
2828
shared::time::Duration,
29+
v2::types::common::Port,
2930
};
3031

3132
use crate::crd::{
@@ -132,7 +133,7 @@ pub fn listener_ports(
132133
.collect()
133134
}
134135

135-
fn exposed_ports(tls: &DruidTlsSecurity, role: &DruidRole) -> Vec<(String, u16)> {
136+
fn exposed_ports(tls: &DruidTlsSecurity, role: &DruidRole) -> Vec<(String, Port)> {
136137
if tls.tls_enabled() {
137138
vec![(TLS_PORT_NAME.to_string(), role.get_https_port())]
138139
} else {

rust/operator-binary/src/crd/mod.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use stackable_operator::{
4545
},
4646
role_utils::{JavaCommonConfig, RoleGroupConfig, with_validated_config},
4747
types::{
48+
common::Port,
4849
kubernetes::{ConfigMapName, ListenerClassName},
4950
operator::{RoleGroupName, RoleName},
5051
},
@@ -91,7 +92,7 @@ pub const PROP_SEGMENT_CACHE_LOCATIONS: &str = "druid.segmentCache.locations";
9192
// CONFIG PROPERTIES //
9293
/////////////////////////////
9394
pub const METRICS_PORT_NAME: &str = "metrics";
94-
pub const METRICS_PORT: u16 = 9090;
95+
pub const METRICS_PORT: Port = Port(9090);
9596

9697
pub const COOKIE_PASSPHRASE_ENV: &str = "OIDC_COOKIE_PASSPHRASE";
9798

@@ -724,24 +725,24 @@ impl DruidRole {
724725
}
725726

726727
/// Returns the http port for every role
727-
pub fn get_http_port(&self) -> u16 {
728+
pub fn get_http_port(&self) -> Port {
728729
match &self {
729-
DruidRole::Coordinator => 8081,
730-
DruidRole::Broker => 8082,
731-
DruidRole::Historical => 8083,
732-
DruidRole::MiddleManager => 8091,
733-
DruidRole::Router => 8888,
730+
DruidRole::Coordinator => Port(8081),
731+
DruidRole::Broker => Port(8082),
732+
DruidRole::Historical => Port(8083),
733+
DruidRole::MiddleManager => Port(8091),
734+
DruidRole::Router => Port(8888),
734735
}
735736
}
736737

737738
/// Returns the https port for every role
738-
pub fn get_https_port(&self) -> u16 {
739+
pub fn get_https_port(&self) -> Port {
739740
match &self {
740-
DruidRole::Coordinator => 8281,
741-
DruidRole::Broker => 8282,
742-
DruidRole::Historical => 8283,
743-
DruidRole::MiddleManager => 8291,
744-
DruidRole::Router => 9088,
741+
DruidRole::Coordinator => Port(8281),
742+
DruidRole::Broker => Port(8282),
743+
DruidRole::Historical => Port(8283),
744+
DruidRole::MiddleManager => Port(8291),
745+
DruidRole::Router => Port(9088),
745746
}
746747
}
747748

0 commit comments

Comments
 (0)