Skip to content

Commit 81bd43a

Browse files
committed
chore: separate impls from crd data structures
1 parent 486df06 commit 81bd43a

File tree

3 files changed

+101
-101
lines changed

3 files changed

+101
-101
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,6 @@ pub struct SupersetClientAuthenticationDetails {
110110
pub sync_roles_at: FlaskRolesSyncMoment,
111111
}
112112

113-
pub fn default_user_registration() -> bool {
114-
true
115-
}
116-
117-
pub fn default_user_registration_role() -> String {
118-
"Public".to_string()
119-
}
120-
121113
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
122114
pub enum FlaskRolesSyncMoment {
123115
#[default]
@@ -145,6 +137,14 @@ pub enum SupersetAuthenticationClassResolved {
145137
},
146138
}
147139

140+
pub fn default_user_registration() -> bool {
141+
true
142+
}
143+
144+
pub fn default_user_registration_role() -> String {
145+
"Public".to_string()
146+
}
147+
148148
impl SupersetClientAuthenticationDetailsResolved {
149149
pub async fn from(
150150
auth_details: &[SupersetClientAuthenticationDetails],

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ pub enum Error {
1414
}
1515
type Result<T, E = Error> = std::result::Result<T, E>;
1616

17-
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
18-
#[serde(rename_all = "camelCase")]
19-
pub struct ClusterRef {
20-
/// The name of the stacklet.
21-
pub name: String,
22-
/// The namespace. Defaults to the namespace of the `DruidConnection` if it is not specified.
23-
pub namespace: Option<String>,
24-
}
25-
2617
/// The DruidConnection resource can be used to automatically deploy a Druid datasource in Superset.
2718
/// Learn more about it in the [Superset operator usage guide](DOCS_BASE_URL_PLACEHOLDER/superset/usage-guide/connecting-druid).
2819
#[derive(Clone, CustomResource, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
@@ -47,6 +38,23 @@ pub struct DruidConnectionSpec {
4738
pub druid: ClusterRef,
4839
}
4940

41+
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
42+
#[serde(rename_all = "camelCase")]
43+
pub struct ClusterRef {
44+
/// The name of the stacklet.
45+
pub name: String,
46+
/// The namespace. Defaults to the namespace of the `DruidConnection` if it is not specified.
47+
pub namespace: Option<String>,
48+
}
49+
50+
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, JsonSchema)]
51+
#[serde(rename_all = "camelCase")]
52+
pub struct DruidConnectionStatus {
53+
#[serde(skip_serializing_if = "Option::is_none")]
54+
pub started_at: Option<Time>,
55+
pub condition: DruidConnectionStatusCondition,
56+
}
57+
5058
impl DruidConnection {
5159
pub fn job_name(&self) -> String {
5260
format!("{}-import", self.name_unchecked())
@@ -87,14 +95,6 @@ impl DruidConnection {
8795
}
8896
}
8997

90-
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, JsonSchema)]
91-
#[serde(rename_all = "camelCase")]
92-
pub struct DruidConnectionStatus {
93-
#[serde(skip_serializing_if = "Option::is_none")]
94-
pub started_at: Option<Time>,
95-
pub condition: DruidConnectionStatusCondition,
96-
}
97-
9898
impl DruidConnectionStatus {
9999
pub fn new() -> Self {
100100
Self {

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

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -91,55 +91,6 @@ pub enum SupersetConfigOptions {
9191
AuthLdapTlsCacertfile,
9292
}
9393

94-
impl SupersetConfigOptions {
95-
/// Mapping from `SupersetConfigOptions` to the values set in `SupersetConfigFragment`.
96-
/// `None` is returned if either the according option is not set or is not exposed in the
97-
/// `SupersetConfig`.
98-
fn config_type_to_string(&self, superset_config: &SupersetConfigFragment) -> Option<String> {
99-
match self {
100-
SupersetConfigOptions::RowLimit => superset_config.row_limit.map(|v| v.to_string()),
101-
SupersetConfigOptions::SupersetWebserverTimeout => {
102-
superset_config.webserver_timeout.map(|v| v.to_string())
103-
}
104-
_ => None,
105-
}
106-
}
107-
}
108-
109-
impl FlaskAppConfigOptions for SupersetConfigOptions {
110-
fn python_type(&self) -> PythonType {
111-
match self {
112-
SupersetConfigOptions::SecretKey => PythonType::Expression,
113-
SupersetConfigOptions::SqlalchemyDatabaseUri => PythonType::Expression,
114-
SupersetConfigOptions::StatsLogger => PythonType::Expression,
115-
SupersetConfigOptions::RowLimit => PythonType::IntLiteral,
116-
SupersetConfigOptions::MapboxApiKey => PythonType::Expression,
117-
SupersetConfigOptions::OauthProviders => PythonType::Expression,
118-
SupersetConfigOptions::SupersetWebserverTimeout => PythonType::IntLiteral,
119-
SupersetConfigOptions::LoggingConfigurator => PythonType::Expression,
120-
SupersetConfigOptions::AuthType => PythonType::Expression,
121-
SupersetConfigOptions::AuthUserRegistration => PythonType::BoolLiteral,
122-
SupersetConfigOptions::AuthUserRegistrationRole => PythonType::StringLiteral,
123-
SupersetConfigOptions::AuthRolesSyncAtLogin => PythonType::BoolLiteral,
124-
SupersetConfigOptions::AuthLdapServer => PythonType::StringLiteral,
125-
SupersetConfigOptions::AuthLdapBindUser => PythonType::Expression,
126-
SupersetConfigOptions::AuthLdapBindPassword => PythonType::Expression,
127-
SupersetConfigOptions::AuthLdapSearch => PythonType::StringLiteral,
128-
SupersetConfigOptions::AuthLdapSearchFilter => PythonType::StringLiteral,
129-
SupersetConfigOptions::AuthLdapUidField => PythonType::StringLiteral,
130-
SupersetConfigOptions::AuthLdapGroupField => PythonType::StringLiteral,
131-
SupersetConfigOptions::AuthLdapFirstnameField => PythonType::StringLiteral,
132-
SupersetConfigOptions::AuthLdapLastnameField => PythonType::StringLiteral,
133-
SupersetConfigOptions::AuthLdapEmailField => PythonType::StringLiteral,
134-
SupersetConfigOptions::AuthLdapAllowSelfSigned => PythonType::BoolLiteral,
135-
SupersetConfigOptions::AuthLdapTlsDemand => PythonType::BoolLiteral,
136-
SupersetConfigOptions::AuthLdapTlsCertfile => PythonType::StringLiteral,
137-
SupersetConfigOptions::AuthLdapTlsKeyfile => PythonType::StringLiteral,
138-
SupersetConfigOptions::AuthLdapTlsCacertfile => PythonType::StringLiteral,
139-
}
140-
}
141-
}
142-
14394
/// A Superset cluster stacklet. This resource is managed by the Stackable operator for Apache Superset.
14495
/// Find more information on how to use it and the resources that the operator generates in the
14596
/// [operator documentation](DOCS_BASE_URL_PLACEHOLDER/superset/).
@@ -233,16 +184,6 @@ pub enum CurrentlySupportedListenerClasses {
233184
ExternalStable,
234185
}
235186

236-
impl CurrentlySupportedListenerClasses {
237-
pub fn k8s_service_type(&self) -> String {
238-
match self {
239-
CurrentlySupportedListenerClasses::ClusterInternal => "ClusterIP".to_string(),
240-
CurrentlySupportedListenerClasses::ExternalUnstable => "NodePort".to_string(),
241-
CurrentlySupportedListenerClasses::ExternalStable => "LoadBalancer".to_string(),
242-
}
243-
}
244-
}
245-
246187
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
247188
#[serde(rename_all = "camelCase")]
248189
pub struct SupersetCredentials {
@@ -353,6 +294,82 @@ pub struct SupersetConfig {
353294
pub graceful_shutdown_timeout: Option<Duration>,
354295
}
355296

297+
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
298+
#[serde(rename_all = "camelCase")]
299+
pub struct SupersetClusterStatus {
300+
#[serde(default)]
301+
pub conditions: Vec<ClusterCondition>,
302+
}
303+
304+
/// A reference to a [`SupersetCluster`]
305+
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
306+
#[serde(rename_all = "camelCase")]
307+
pub struct SupersetClusterRef {
308+
#[serde(default, skip_serializing_if = "Option::is_none")]
309+
pub name: Option<String>,
310+
#[serde(default, skip_serializing_if = "Option::is_none")]
311+
pub namespace: Option<String>,
312+
}
313+
314+
impl SupersetConfigOptions {
315+
/// Mapping from `SupersetConfigOptions` to the values set in `SupersetConfigFragment`.
316+
/// `None` is returned if either the according option is not set or is not exposed in the
317+
/// `SupersetConfig`.
318+
fn config_type_to_string(&self, superset_config: &SupersetConfigFragment) -> Option<String> {
319+
match self {
320+
SupersetConfigOptions::RowLimit => superset_config.row_limit.map(|v| v.to_string()),
321+
SupersetConfigOptions::SupersetWebserverTimeout => {
322+
superset_config.webserver_timeout.map(|v| v.to_string())
323+
}
324+
_ => None,
325+
}
326+
}
327+
}
328+
329+
impl FlaskAppConfigOptions for SupersetConfigOptions {
330+
fn python_type(&self) -> PythonType {
331+
match self {
332+
SupersetConfigOptions::SecretKey => PythonType::Expression,
333+
SupersetConfigOptions::SqlalchemyDatabaseUri => PythonType::Expression,
334+
SupersetConfigOptions::StatsLogger => PythonType::Expression,
335+
SupersetConfigOptions::RowLimit => PythonType::IntLiteral,
336+
SupersetConfigOptions::MapboxApiKey => PythonType::Expression,
337+
SupersetConfigOptions::OauthProviders => PythonType::Expression,
338+
SupersetConfigOptions::SupersetWebserverTimeout => PythonType::IntLiteral,
339+
SupersetConfigOptions::LoggingConfigurator => PythonType::Expression,
340+
SupersetConfigOptions::AuthType => PythonType::Expression,
341+
SupersetConfigOptions::AuthUserRegistration => PythonType::BoolLiteral,
342+
SupersetConfigOptions::AuthUserRegistrationRole => PythonType::StringLiteral,
343+
SupersetConfigOptions::AuthRolesSyncAtLogin => PythonType::BoolLiteral,
344+
SupersetConfigOptions::AuthLdapServer => PythonType::StringLiteral,
345+
SupersetConfigOptions::AuthLdapBindUser => PythonType::Expression,
346+
SupersetConfigOptions::AuthLdapBindPassword => PythonType::Expression,
347+
SupersetConfigOptions::AuthLdapSearch => PythonType::StringLiteral,
348+
SupersetConfigOptions::AuthLdapSearchFilter => PythonType::StringLiteral,
349+
SupersetConfigOptions::AuthLdapUidField => PythonType::StringLiteral,
350+
SupersetConfigOptions::AuthLdapGroupField => PythonType::StringLiteral,
351+
SupersetConfigOptions::AuthLdapFirstnameField => PythonType::StringLiteral,
352+
SupersetConfigOptions::AuthLdapLastnameField => PythonType::StringLiteral,
353+
SupersetConfigOptions::AuthLdapEmailField => PythonType::StringLiteral,
354+
SupersetConfigOptions::AuthLdapAllowSelfSigned => PythonType::BoolLiteral,
355+
SupersetConfigOptions::AuthLdapTlsDemand => PythonType::BoolLiteral,
356+
SupersetConfigOptions::AuthLdapTlsCertfile => PythonType::StringLiteral,
357+
SupersetConfigOptions::AuthLdapTlsKeyfile => PythonType::StringLiteral,
358+
SupersetConfigOptions::AuthLdapTlsCacertfile => PythonType::StringLiteral,
359+
}
360+
}
361+
}
362+
363+
impl CurrentlySupportedListenerClasses {
364+
pub fn k8s_service_type(&self) -> String {
365+
match self {
366+
CurrentlySupportedListenerClasses::ClusterInternal => "ClusterIP".to_string(),
367+
CurrentlySupportedListenerClasses::ExternalUnstable => "NodePort".to_string(),
368+
CurrentlySupportedListenerClasses::ExternalStable => "LoadBalancer".to_string(),
369+
}
370+
}
371+
}
372+
356373
impl SupersetConfig {
357374
pub const CREDENTIALS_SECRET_PROPERTY: &'static str = "credentialsSecret";
358375
pub const MAPBOX_SECRET_PROPERTY: &'static str = "mapboxSecret";
@@ -430,13 +447,6 @@ impl Configuration for SupersetConfigFragment {
430447
}
431448
}
432449

433-
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
434-
#[serde(rename_all = "camelCase")]
435-
pub struct SupersetClusterStatus {
436-
#[serde(default)]
437-
pub conditions: Vec<ClusterCondition>,
438-
}
439-
440450
impl HasStatusCondition for SupersetCluster {
441451
fn conditions(&self) -> Vec<ClusterCondition> {
442452
match &self.status {
@@ -514,13 +524,3 @@ impl SupersetCluster {
514524
fragment::validate(conf_rolegroup).context(FragmentValidationFailureSnafu)
515525
}
516526
}
517-
518-
/// A reference to a [`SupersetCluster`]
519-
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
520-
#[serde(rename_all = "camelCase")]
521-
pub struct SupersetClusterRef {
522-
#[serde(default, skip_serializing_if = "Option::is_none")]
523-
pub name: Option<String>,
524-
#[serde(default, skip_serializing_if = "Option::is_none")]
525-
pub namespace: Option<String>,
526-
}

0 commit comments

Comments
 (0)