Skip to content

Commit 25088ae

Browse files
committed
chore: separate impls from crd data structures
This makes way for the versioned module we will soon introduce
1 parent 1c6c314 commit 25088ae

File tree

2 files changed

+50
-50
lines changed

2 files changed

+50
-50
lines changed

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

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,6 @@ pub enum CurrentlySupportedListenerClasses {
122122
ExternalStable,
123123
}
124124

125-
impl CurrentlySupportedListenerClasses {
126-
pub fn k8s_service_type(&self) -> String {
127-
match self {
128-
CurrentlySupportedListenerClasses::ClusterInternal => "ClusterIP".to_string(),
129-
CurrentlySupportedListenerClasses::ExternalUnstable => "NodePort".to_string(),
130-
CurrentlySupportedListenerClasses::ExternalStable => "LoadBalancer".to_string(),
131-
}
132-
}
133-
}
134-
135125
#[allow(clippy::derive_partial_eq_without_eq)]
136126
#[derive(Clone, Debug, Default, Fragment, JsonSchema, PartialEq)]
137127
#[fragment_attrs(
@@ -201,6 +191,42 @@ pub struct OpaConfig {
201191
pub graceful_shutdown_timeout: Option<Duration>,
202192
}
203193

194+
#[derive(
195+
EnumIter,
196+
Clone,
197+
Debug,
198+
Hash,
199+
Deserialize,
200+
Eq,
201+
JsonSchema,
202+
PartialEq,
203+
Serialize,
204+
Display,
205+
EnumString,
206+
)]
207+
pub enum OpaRole {
208+
#[serde(rename = "server")]
209+
#[strum(serialize = "server")]
210+
Server,
211+
}
212+
213+
#[derive(Clone, Default, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
214+
#[serde(rename_all = "camelCase")]
215+
pub struct OpaClusterStatus {
216+
#[serde(default)]
217+
pub conditions: Vec<ClusterCondition>,
218+
}
219+
220+
impl CurrentlySupportedListenerClasses {
221+
pub fn k8s_service_type(&self) -> String {
222+
match self {
223+
CurrentlySupportedListenerClasses::ClusterInternal => "ClusterIP".to_string(),
224+
CurrentlySupportedListenerClasses::ExternalUnstable => "NodePort".to_string(),
225+
CurrentlySupportedListenerClasses::ExternalStable => "LoadBalancer".to_string(),
226+
}
227+
}
228+
}
229+
204230
impl OpaConfig {
205231
fn default_config() -> OpaConfigFragment {
206232
OpaConfigFragment {
@@ -256,25 +282,6 @@ impl Configuration for OpaConfigFragment {
256282
}
257283
}
258284

259-
#[derive(
260-
EnumIter,
261-
Clone,
262-
Debug,
263-
Hash,
264-
Deserialize,
265-
Eq,
266-
JsonSchema,
267-
PartialEq,
268-
Serialize,
269-
Display,
270-
EnumString,
271-
)]
272-
pub enum OpaRole {
273-
#[serde(rename = "server")]
274-
#[strum(serialize = "server")]
275-
Server,
276-
}
277-
278285
impl OpaCluster {
279286
/// Returns a reference to the role.
280287
pub fn role(&self, role_variant: &OpaRole) -> &Role<OpaConfigFragment, EmptyRoleConfig> {
@@ -354,13 +361,6 @@ impl OpaCluster {
354361
}
355362
}
356363

357-
#[derive(Clone, Default, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
358-
#[serde(rename_all = "camelCase")]
359-
pub struct OpaClusterStatus {
360-
#[serde(default)]
361-
pub conditions: Vec<ClusterCondition>,
362-
}
363-
364364
impl HasStatusCondition for OpaCluster {
365365
fn conditions(&self) -> Vec<ClusterCondition> {
366366
match &self.status {

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ pub enum Backend {
3838
ActiveDirectory(ActiveDirectoryBackend),
3939
}
4040

41-
impl Default for Backend {
42-
fn default() -> Self {
43-
Self::None {}
44-
}
45-
}
46-
4741
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
4842
#[serde(rename_all = "camelCase")]
4943
pub struct KeycloakBackend {
@@ -75,10 +69,6 @@ pub struct KeycloakBackend {
7569
pub user_realm: String,
7670
}
7771

78-
fn default_root_path() -> String {
79-
"/".to_string()
80-
}
81-
8272
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
8373
#[serde(rename_all = "camelCase")]
8474
pub struct AasBackend {
@@ -90,10 +80,6 @@ pub struct AasBackend {
9080
pub port: u16,
9181
}
9282

93-
fn aas_default_port() -> u16 {
94-
5000
95-
}
96-
9783
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
9884
#[serde(rename_all = "camelCase")]
9985
pub struct ActiveDirectoryBackend {
@@ -125,6 +111,20 @@ pub struct Cache {
125111
pub entry_time_to_live: Duration,
126112
}
127113

114+
impl Default for Backend {
115+
fn default() -> Self {
116+
Self::None {}
117+
}
118+
}
119+
120+
fn default_root_path() -> String {
121+
"/".to_string()
122+
}
123+
124+
fn aas_default_port() -> u16 {
125+
5000
126+
}
127+
128128
impl Cache {
129129
const fn default_entry_time_to_live() -> Duration {
130130
Duration::from_minutes_unchecked(1)

0 commit comments

Comments
 (0)