Skip to content

Commit a367e13

Browse files
committed
chore: move HiveConfigOverrides into versioned module
1 parent 94778db commit a367e13

1 file changed

Lines changed: 41 additions & 38 deletions

File tree

  • rust/operator-binary/src/crd

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

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -40,42 +40,6 @@ use crate::{crd::affinity::get_affinity, listener::metastore_default_listener_cl
4040
pub mod affinity;
4141
pub mod security;
4242

43-
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
44-
#[serde(rename_all = "camelCase")]
45-
pub struct HiveConfigOverrides {
46-
#[serde(
47-
default,
48-
rename = "hive-site.xml",
49-
skip_serializing_if = "Option::is_none"
50-
)]
51-
pub hive_site_xml: Option<KeyValueConfigOverrides>,
52-
53-
#[serde(
54-
default,
55-
rename = "security.properties",
56-
skip_serializing_if = "Option::is_none"
57-
)]
58-
pub security_properties: Option<KeyValueConfigOverrides>,
59-
}
60-
61-
impl KeyValueOverridesProvider for HiveConfigOverrides {
62-
fn get_key_value_overrides(&self, file: &str) -> BTreeMap<String, Option<String>> {
63-
match file {
64-
HIVE_SITE_XML => self
65-
.hive_site_xml
66-
.as_ref()
67-
.map(KeyValueConfigOverrides::as_product_config_overrides)
68-
.unwrap_or_default(),
69-
JVM_SECURITY_PROPERTIES_FILE => self
70-
.security_properties
71-
.as_ref()
72-
.map(KeyValueConfigOverrides::as_product_config_overrides)
73-
.unwrap_or_default(),
74-
_ => BTreeMap::new(),
75-
}
76-
}
77-
}
78-
7943
pub const FIELD_MANAGER: &str = "hive-operator";
8044
pub const APP_NAME: &str = "hive";
8145

@@ -115,13 +79,13 @@ const DEFAULT_METASTORE_GRACEFUL_SHUTDOWN_TIMEOUT: Duration = Duration::from_min
11579

11680
pub type HiveRoleType = Role<
11781
MetaStoreConfigFragment,
118-
HiveConfigOverrides,
82+
v1alpha1::HiveConfigOverrides,
11983
v1alpha1::HiveMetastoreRoleConfig,
12084
JavaCommonConfig,
12185
>;
12286

12387
pub type HiveRoleGroupType =
124-
RoleGroup<MetaStoreConfigFragment, JavaCommonConfig, HiveConfigOverrides>;
88+
RoleGroup<MetaStoreConfigFragment, JavaCommonConfig, v1alpha1::HiveConfigOverrides>;
12589

12690
#[derive(Snafu, Debug)]
12791
pub enum Error {
@@ -230,6 +194,27 @@ pub mod versioned {
230194
#[serde(skip_serializing_if = "Option::is_none")]
231195
pub vector_aggregator_config_map_name: Option<String>,
232196
}
197+
198+
/// Typed config overrides for Hive config files.
199+
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
200+
#[serde(rename_all = "camelCase")]
201+
pub struct HiveConfigOverrides {
202+
/// Overrides for the `hive-site.xml` file.
203+
#[serde(
204+
default,
205+
rename = "hive-site.xml",
206+
skip_serializing_if = "Option::is_none"
207+
)]
208+
pub hive_site_xml: Option<KeyValueConfigOverrides>,
209+
210+
/// Overrides for the `security.properties` file.
211+
#[serde(
212+
default,
213+
rename = "security.properties",
214+
skip_serializing_if = "Option::is_none"
215+
)]
216+
pub security_properties: Option<KeyValueConfigOverrides>,
217+
}
233218
}
234219

235220
impl Default for v1alpha1::HiveMetastoreRoleConfig {
@@ -380,6 +365,24 @@ impl v1alpha1::HiveCluster {
380365
}
381366
}
382367

368+
impl KeyValueOverridesProvider for v1alpha1::HiveConfigOverrides {
369+
fn get_key_value_overrides(&self, file: &str) -> BTreeMap<String, Option<String>> {
370+
match file {
371+
HIVE_SITE_XML => self
372+
.hive_site_xml
373+
.as_ref()
374+
.map(KeyValueConfigOverrides::as_product_config_overrides)
375+
.unwrap_or_default(),
376+
JVM_SECURITY_PROPERTIES_FILE => self
377+
.security_properties
378+
.as_ref()
379+
.map(KeyValueConfigOverrides::as_product_config_overrides)
380+
.unwrap_or_default(),
381+
_ => BTreeMap::new(),
382+
}
383+
}
384+
}
385+
383386
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
384387
#[serde(rename_all = "camelCase")]
385388
pub struct HdfsConnection {

0 commit comments

Comments
 (0)