-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathgoogle_sheet.rs
More file actions
65 lines (57 loc) · 2.18 KB
/
Copy pathgoogle_sheet.rs
File metadata and controls
65 lines (57 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use async_trait::async_trait;
use stackable_operator::{
builder::pod::volume::{VolumeBuilder, VolumeMountBuilder},
client::Client,
v2::types::kubernetes::NamespaceName,
};
use super::{FromTrinoCatalogError, ToCatalogConfig, config::CatalogConfig};
use crate::{
controller::dereference::TrinoCatalogName,
crd::{CONFIG_DIR_NAME, catalog::google_sheet::GoogleSheetConnector},
};
pub const CONNECTOR_NAME: &str = "gsheets";
#[async_trait]
impl ToCatalogConfig for GoogleSheetConnector {
async fn to_catalog_config(
&self,
catalog_name: &TrinoCatalogName,
_catalog_namespace: &NamespaceName,
_client: &Client,
_trino_version: u16,
) -> Result<CatalogConfig, FromTrinoCatalogError> {
let mut config = CatalogConfig::new(catalog_name, CONNECTOR_NAME);
let volume_name = format!("{catalog_name}-google-sheets-credentials");
let google_sheets_credentials_dir =
format!("{CONFIG_DIR_NAME}/catalog/{catalog_name}/google-sheets-credentials/");
config.volumes.push(
VolumeBuilder::new(&volume_name)
.with_secret(&self.credentials_secret, false)
.build(),
);
config
.volume_mounts
.push(VolumeMountBuilder::new(&volume_name, &google_sheets_credentials_dir).build());
config.add_property(
"credentials-path",
format!("{google_sheets_credentials_dir}/credentials"),
);
config.add_property("metadata-sheet-id", &self.metadata_sheet_id);
if let Some(cache) = &self.cache {
if let Some(cache_sheets_data_max_cache_size) = &cache.sheets_data_max_cache_size {
config.add_property(
"sheets-data-max-cache-size",
cache_sheets_data_max_cache_size,
);
}
if let Some(cache_sheets_data_expire_after_write) =
&cache.sheets_data_expire_after_write
{
config.add_property(
"sheets-data-expire-after-write",
cache_sheets_data_expire_after_write,
);
}
}
Ok(config)
}
}