Skip to content

Commit 510df9b

Browse files
committed
refactor: move k8s resources
1 parent 28d8ce0 commit 510df9b

10 files changed

Lines changed: 39 additions & 29 deletions

File tree

rust/operator-binary/src/controller.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ use strum::EnumDiscriminants;
4242
use crate::{
4343
OPERATOR_NAME,
4444
controller::build::{
45-
discovery,
46-
listener::build_role_listener,
4745
opa::HiveOpaConfig,
48-
pdb::add_pdbs,
49-
service::{build_rolegroup_headless_service, build_rolegroup_metrics_service},
46+
resource::{
47+
discovery,
48+
listener::build_role_listener,
49+
pdb::add_pdbs,
50+
service::{build_rolegroup_headless_service, build_rolegroup_metrics_service},
51+
},
5052
},
5153
crd::{APP_NAME, HiveClusterStatus, HiveRole, MetaStoreConfig, v1alpha1},
5254
};
@@ -71,7 +73,7 @@ pub enum Error {
7173

7274
#[snafu(display("failed to build ConfigMap for role group {role_group}"))]
7375
BuildRoleGroupConfigMap {
74-
source: build::config_map::Error,
76+
source: build::resource::config_map::Error,
7577
role_group: RoleGroupName,
7678
},
7779

@@ -125,7 +127,7 @@ pub enum Error {
125127

126128
#[snafu(display("failed to create PodDisruptionBudget"))]
127129
FailedToCreatePdb {
128-
source: crate::controller::build::pdb::Error,
130+
source: crate::controller::build::resource::pdb::Error,
129131
},
130132

131133
#[snafu(display("failed to get required Labels"))]
@@ -154,7 +156,7 @@ pub enum Error {
154156

155157
#[snafu(display("failed to build StatefulSet for role group {role_group}"))]
156158
BuildRoleGroupStatefulSet {
157-
source: build::statefulset::Error,
159+
source: build::resource::statefulset::Error,
158160
role_group: RoleGroupName,
159161
},
160162
}
@@ -478,7 +480,7 @@ pub async fn reconcile_hive(
478480
let rg_headless_service =
479481
build_rolegroup_headless_service(&validated_cluster, role_group_name);
480482

481-
let rg_configmap = build::config_map::build_metastore_rolegroup_config_map(
483+
let rg_configmap = build::resource::config_map::build_metastore_rolegroup_config_map(
482484
&validated_cluster,
483485
role_group_name,
484486
rg,
@@ -488,17 +490,18 @@ pub async fn reconcile_hive(
488490
role_group: role_group_name.clone(),
489491
})?;
490492

491-
let rg_statefulset = build::statefulset::build_metastore_rolegroup_statefulset(
492-
hive,
493-
hive_role,
494-
&validated_cluster,
495-
role_group_name,
496-
rg,
497-
&rbac_sa.name_any(),
498-
)
499-
.with_context(|_| BuildRoleGroupStatefulSetSnafu {
500-
role_group: role_group_name.clone(),
501-
})?;
493+
let rg_statefulset =
494+
build::resource::statefulset::build_metastore_rolegroup_statefulset(
495+
hive,
496+
hive_role,
497+
&validated_cluster,
498+
role_group_name,
499+
rg,
500+
&rbac_sa.name_any(),
501+
)
502+
.with_context(|_| BuildRoleGroupStatefulSetSnafu {
503+
role_group: role_group_name.clone(),
504+
})?;
502505

503506
cluster_resources
504507
.add(client, rg_metrics_service)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use stackable_operator::crd::s3;
22

3-
use super::{opa::HiveOpaConfig, properties::ConfigFileName, statefulset::HDFS_CONFIG_MOUNT_DIR};
3+
use super::{
4+
opa::HiveOpaConfig, properties::ConfigFileName, resource::statefulset::HDFS_CONFIG_MOUNT_DIR,
5+
};
46
use crate::crd::{
57
STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_MOUNT_DIR, STACKABLE_LOG_CONFIG_MOUNT_DIR,
68
STACKABLE_TRUST_STORE, STACKABLE_TRUST_STORE_PASSWORD, v1alpha1,

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@ stackable_operator::constant!(pub(crate) PLACEHOLDER_LISTENER_ROLE_GROUP: RoleGr
1717
stackable_operator::constant!(pub(crate) UNVERSIONED_PRODUCT_VERSION: ProductVersion = "none");
1818

1919
pub mod command;
20-
pub mod config_map;
21-
pub mod discovery;
2220
pub mod graceful_shutdown;
2321
pub mod jvm;
2422
pub mod kerberos;
25-
pub mod listener;
2623
pub mod opa;
27-
pub mod pdb;
2824
pub mod properties;
29-
pub mod service;
30-
pub mod statefulset;
25+
pub mod resource;

rust/operator-binary/src/controller/build/config_map.rs renamed to rust/operator-binary/src/controller/build/resource/config_map.rs

File renamed without changes.

rust/operator-binary/src/controller/build/discovery.rs renamed to rust/operator-binary/src/controller/build/resource/discovery.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use stackable_operator::{
77
use crate::{
88
controller::{
99
ValidatedCluster,
10-
build::{PLACEHOLDER_DISCOVERY_ROLE_GROUP, listener::build_listener_connection_string},
10+
build::{
11+
PLACEHOLDER_DISCOVERY_ROLE_GROUP, resource::listener::build_listener_connection_string,
12+
},
1113
},
1214
crd::{HiveRole, v1alpha1},
1315
};
@@ -22,7 +24,7 @@ pub enum Error {
2224

2325
#[snafu(display("failed to configure listener discovery configmap"))]
2426
ListenerConfiguration {
25-
source: crate::controller::build::listener::Error,
27+
source: crate::controller::build::resource::listener::Error,
2628
},
2729
}
2830

rust/operator-binary/src/controller/build/listener.rs renamed to rust/operator-binary/src/controller/build/resource/listener.rs

File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//! Builders that turn a `ValidatedCluster` into Kubernetes resources.
2+
3+
pub mod config_map;
4+
pub mod discovery;
5+
pub mod listener;
6+
pub mod pdb;
7+
pub mod service;
8+
pub mod statefulset;
File renamed without changes.

rust/operator-binary/src/controller/build/service.rs renamed to rust/operator-binary/src/controller/build/resource/service.rs

File renamed without changes.

rust/operator-binary/src/controller/build/statefulset.rs renamed to rust/operator-binary/src/controller/build/resource/statefulset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub const LISTENER_VOLUME_DIR: &str = "/stackable/listener";
135135
stackable_operator::constant!(HDFS_DISCOVERY_VOLUME_NAME: VolumeName = "hdfs-discovery");
136136

137137
/// The directory the HDFS discovery ConfigMap volume is mounted at. Also consumed by
138-
/// [`build_container_command_args`](super::command::build_container_command_args) when copying the
138+
/// [`build_container_command_args`](super::super::command::build_container_command_args) when copying the
139139
/// mounted HDFS config into the writeable config directory.
140140
pub(crate) const HDFS_CONFIG_MOUNT_DIR: &str = "/stackable/mount/hdfs-config";
141141

0 commit comments

Comments
 (0)