Skip to content

Commit 21082f3

Browse files
committed
adjust version references, remove redundant code
1 parent b3b5ec1 commit 21082f3

File tree

6 files changed

+32
-35
lines changed

6 files changed

+32
-35
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ mod tests {
3232
};
3333

3434
use super::*;
35-
use crate::crd::v1alpha1::SupersetCluster;
35+
use crate::crd::v1alpha1;
3636

3737
#[test]
3838
fn test_affinity_defaults() {
@@ -51,7 +51,8 @@ mod tests {
5151
default:
5252
replicas: 1
5353
"#;
54-
let superset: SupersetCluster = serde_yaml::from_str(input).expect("illegal test input");
54+
let superset: v1alpha1::SupersetCluster =
55+
serde_yaml::from_str(input).expect("illegal test input");
5556
let merged_config = superset
5657
.merged_config(&SupersetRole::Node, &superset.node_rolegroup_ref("default"))
5758
.unwrap();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub mod versioned {
110110
/// If we should replace ALL the user's roles each login, or only on registration.
111111
/// Gets mapped to `AUTH_ROLES_SYNC_AT_LOGIN`
112112
#[serde(default)]
113-
pub sync_roles_at: FlaskRolesSyncMoment,
113+
pub sync_roles_at: v1alpha1::FlaskRolesSyncMoment,
114114
}
115115

116116
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub mod versioned {
2222
#[derive(Clone, CustomResource, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
2323
#[versioned(k8s(
2424
group = "superset.stackable.tech",
25-
kind = "DruidConnection",
2625
plural = "druidconnections",
2726
status = "DruidConnectionStatus",
2827
namespaced,
@@ -35,9 +34,9 @@ pub mod versioned {
3534
#[serde(rename_all = "camelCase")]
3635
pub struct DruidConnectionSpec {
3736
/// The Superset to connect.
38-
pub superset: ClusterRef,
37+
pub superset: v1alpha1::ClusterRef,
3938
/// The Druid to connect.
40-
pub druid: ClusterRef,
39+
pub druid: v1alpha1::ClusterRef,
4140
}
4241

4342
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
@@ -54,7 +53,7 @@ pub mod versioned {
5453
pub struct DruidConnectionStatus {
5554
#[serde(skip_serializing_if = "Option::is_none")]
5655
pub started_at: Option<Time>,
57-
pub condition: DruidConnectionStatusCondition,
56+
pub condition: v1alpha1::DruidConnectionStatusCondition,
5857
}
5958

6059
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, PartialEq, Serialize)]

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ pub mod versioned {
9797
#[derive(Clone, CustomResource, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
9898
#[versioned(k8s(
9999
group = "superset.stackable.tech",
100-
kind = "SupersetCluster",
101100
plural = "supersetclusters",
102101
shortname = "superset",
103102
status = "SupersetClusterStatus",
@@ -115,11 +114,11 @@ pub mod versioned {
115114

116115
/// Settings that affect all roles and role groups.
117116
/// The settings in the `clusterConfig` are cluster wide settings that do not need to be configurable at role or role group level.
118-
pub cluster_config: SupersetClusterConfig,
117+
pub cluster_config: v1alpha1::SupersetClusterConfig,
119118

120119
// no doc - docs in the struct.
121120
#[serde(default, skip_serializing_if = "Option::is_none")]
122-
pub nodes: Option<Role<SupersetConfigFragment>>,
121+
pub nodes: Option<Role<v1alpha1::SupersetConfigFragment>>,
123122
}
124123

125124
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
@@ -151,7 +150,7 @@ pub mod versioned {
151150
/// In the future, this setting will control which [ListenerClass](DOCS_BASE_URL_PLACEHOLDER/listener-operator/listenerclass.html)
152151
/// will be used to expose the service, and ListenerClass names will stay the same, allowing for a non-breaking change.
153152
#[serde(default)]
154-
pub listener_class: CurrentlySupportedListenerClasses,
153+
pub listener_class: v1alpha1::CurrentlySupportedListenerClasses,
155154

156155
/// The name of a Secret object.
157156
/// The Secret should contain a key `connections.mapboxApiKey`.
@@ -195,10 +194,10 @@ pub mod versioned {
195194

196195
/// CPU and memory limits for Superset pods
197196
#[fragment_attrs(serde(default))]
198-
pub resources: Resources<SupersetStorageConfig, NoRuntimeLimits>,
197+
pub resources: Resources<v1alpha1::SupersetStorageConfig, NoRuntimeLimits>,
199198

200199
#[fragment_attrs(serde(default))]
201-
pub logging: Logging<Container>,
200+
pub logging: Logging<v1alpha1::Container>,
202201

203202
#[fragment_attrs(serde(default))]
204203
pub affinity: StackableAffinity,

rust/operator-binary/src/druid_connection_controller.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@ use stackable_operator::{
2525
use strum::{EnumDiscriminants, IntoStaticStr};
2626

2727
use crate::{
28-
crd::{
29-
druidconnection::v1alpha1::{
30-
DruidConnection, DruidConnectionStatus, DruidConnectionStatusCondition,
31-
},
32-
v1alpha1::SupersetCluster,
33-
PYTHONPATH, SUPERSET_CONFIG_FILENAME,
34-
},
28+
crd::{druidconnection, v1alpha1, PYTHONPATH, SUPERSET_CONFIG_FILENAME},
3529
rbac,
3630
superset_controller::DOCKER_IMAGE_BASE_NAME,
3731
util::{get_job_state, JobState},
@@ -81,7 +75,7 @@ pub enum Error {
8175
#[snafu(display("namespace missing on DruidConnection {druid_connection}"))]
8276
DruidConnectionNoNamespace {
8377
source: crate::crd::druidconnection::Error,
84-
druid_connection: ObjectRef<DruidConnection>,
78+
druid_connection: ObjectRef<druidconnection::v1alpha1::DruidConnection>,
8579
},
8680
#[snafu(display("failed to patch service account"))]
8781
ApplyServiceAccount {
@@ -132,7 +126,7 @@ impl ReconcilerError for Error {
132126
}
133127

134128
pub async fn reconcile_druid_connection(
135-
druid_connection: Arc<DeserializeGuard<DruidConnection>>,
129+
druid_connection: Arc<DeserializeGuard<druidconnection::v1alpha1::DruidConnection>>,
136130
ctx: Arc<Ctx>,
137131
) -> Result<Action> {
138132
tracing::info!("Starting reconciling DruidConnections");
@@ -160,7 +154,7 @@ pub async fn reconcile_druid_connection(
160154

161155
if let Some(ref s) = druid_connection.status {
162156
match s.condition {
163-
DruidConnectionStatusCondition::Pending => {
157+
druidconnection::v1alpha1::DruidConnectionStatusCondition::Pending => {
164158
// Is the referenced druid discovery configmap there?
165159
let druid_discovery_cm_exists = client
166160
.get_opt::<ConfigMap>(
@@ -176,7 +170,7 @@ pub async fn reconcile_druid_connection(
176170
.is_some();
177171

178172
let superset_cluster = client
179-
.get::<SupersetCluster>(
173+
.get::<v1alpha1::SupersetCluster>(
180174
&druid_connection.superset_name(),
181175
&druid_connection.superset_namespace().context(
182176
DruidConnectionNoNamespaceSnafu {
@@ -237,7 +231,7 @@ pub async fn reconcile_druid_connection(
237231
.context(ApplyStatusSnafu)?;
238232
}
239233
}
240-
DruidConnectionStatusCondition::Importing => {
234+
druidconnection::v1alpha1::DruidConnectionStatusCondition::Importing => {
241235
let ns = druid_connection
242236
.namespace()
243237
.unwrap_or_else(|| "default".to_string());
@@ -262,16 +256,16 @@ pub async fn reconcile_druid_connection(
262256
.context(ApplyStatusSnafu)?;
263257
}
264258
}
265-
DruidConnectionStatusCondition::Ready => (),
266-
DruidConnectionStatusCondition::Failed => (),
259+
druidconnection::v1alpha1::DruidConnectionStatusCondition::Ready => (),
260+
druidconnection::v1alpha1::DruidConnectionStatusCondition::Failed => (),
267261
}
268262
} else {
269263
// Status not set yet, initialize
270264
client
271265
.apply_patch_status(
272266
DRUID_CONNECTION_CONTROLLER_NAME,
273267
druid_connection,
274-
&DruidConnectionStatus::new(),
268+
&druidconnection::v1alpha1::DruidConnectionStatus::new(),
275269
)
276270
.await
277271
.context(ApplyStatusSnafu)?;
@@ -306,8 +300,8 @@ fn build_druid_db_yaml(druid_cluster_name: &str, sqlalchemy_str: &str) -> Result
306300

307301
/// Builds the import job. When run it will import the druid connection into the database.
308302
async fn build_import_job(
309-
superset_cluster: &SupersetCluster,
310-
druid_connection: &DruidConnection,
303+
superset_cluster: &v1alpha1::SupersetCluster,
304+
druid_connection: &druidconnection::v1alpha1::DruidConnection,
311305
resolved_product_image: &ResolvedProductImage,
312306
sqlalchemy_str: &str,
313307
sa_name: &str,
@@ -378,7 +372,7 @@ async fn build_import_job(
378372
}
379373

380374
pub fn error_policy(
381-
_obj: Arc<DeserializeGuard<DruidConnection>>,
375+
_obj: Arc<DeserializeGuard<druidconnection::v1alpha1::DruidConnection>>,
382376
error: &Error,
383377
_ctx: Arc<Ctx>,
384378
) -> Action {

rust/operator-binary/src/main.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::sync::Arc;
22

33
use clap::{crate_description, crate_version, Parser};
4+
use crd::druidconnection::DruidConnection;
45
use futures::{pin_mut, StreamExt};
56
use stackable_operator::{
67
cli::{Command, ProductOperatorRun},
@@ -20,11 +21,12 @@ use stackable_operator::{
2021
ResourceExt,
2122
},
2223
logging::controller::report_controller_reconciled,
23-
CustomResourceExt,
24+
shared::yaml::SerializeOptions,
25+
YamlSchema,
2426
};
2527

2628
use crate::{
27-
crd::{druidconnection, v1alpha1, APP_NAME},
29+
crd::{druidconnection, v1alpha1, SupersetCluster, APP_NAME},
2830
druid_connection_controller::DRUID_CONNECTION_FULL_CONTROLLER_NAME,
2931
superset_controller::SUPERSET_FULL_CONTROLLER_NAME,
3032
};
@@ -59,8 +61,10 @@ async fn main() -> anyhow::Result<()> {
5961
let opts = Opts::parse();
6062
match opts.cmd {
6163
Command::Crd => {
62-
v1alpha1::SupersetCluster::print_yaml_schema(built_info::PKG_VERSION)?;
63-
druidconnection::v1alpha1::DruidConnection::print_yaml_schema(built_info::PKG_VERSION)?;
64+
SupersetCluster::merged_crd(SupersetCluster::V1Alpha1)?
65+
.print_yaml_schema(built_info::PKG_VERSION, SerializeOptions::default())?;
66+
DruidConnection::merged_crd(DruidConnection::V1Alpha1)?
67+
.print_yaml_schema(built_info::PKG_VERSION, SerializeOptions::default())?;
6468
}
6569
Command::Run(ProductOperatorRun {
6670
product_config,

0 commit comments

Comments
 (0)