Skip to content

Commit 86d32e2

Browse files
authored
Assume trunk project is extension name if not set in Tembo.toml (#462)
1 parent 045779e commit 86d32e2

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

tembo-cli/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tembo-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
workspace = { members = ["temboclient", "tembodataclient"] }
22
[package]
33
name = "tembo-cli"
4-
version = "0.13.3"
4+
version = "0.13.4"
55
edition = "2021"
66
authors = ["Tembo.io"]
77
description = "The CLI for Tembo"

tembo-cli/src/cli/tembo_config.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use serde::{Deserialize, Serialize};
1+
use serde::{Deserialize, Deserializer, Serialize};
22
use std::collections::HashMap;
33
use toml::Value;
44

@@ -24,11 +24,35 @@ pub struct InstanceSettings {
2424
#[serde(default = "default_stack_type")]
2525
pub stack_type: String,
2626
pub postgres_configurations: Option<HashMap<String, Value>>,
27-
#[serde(default = "default_extensions")]
27+
#[serde(
28+
deserialize_with = "deserialize_extensions",
29+
default = "default_extensions"
30+
)]
2831
pub extensions: Option<HashMap<String, Extension>>,
2932
pub extra_domains_rw: Option<Vec<String>>,
3033
}
3134

35+
// If a trunk project name is not specified, then assume
36+
// it's the same name as the extension.
37+
fn deserialize_extensions<'de, D>(
38+
deserializer: D,
39+
) -> Result<Option<HashMap<String, Extension>>, D::Error>
40+
where
41+
D: Deserializer<'de>,
42+
{
43+
let map = Option::<HashMap<String, Extension>>::deserialize(deserializer)?;
44+
45+
map.map(|mut m| {
46+
m.iter_mut().for_each(|(key, ext)| {
47+
if ext.trunk_project.is_none() {
48+
ext.trunk_project = Some(key.clone());
49+
}
50+
});
51+
m
52+
})
53+
.map_or(Ok(None), |m| Ok(Some(m)))
54+
}
55+
3256
fn default_cpu() -> String {
3357
"0.25".to_string()
3458
}

tembo-cli/tests/integration_tests.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,9 @@ async fn data_warehouse() -> Result<(), Box<dyn Error>> {
9797

9898
// check extensions includes postgres_fdw in the output
9999
// connecting to postgres and running the command
100-
let result = get_output_from_sql(
101-
"SELECT * FROM pg_extension WHERE extname = 'postgres_fdw'".to_string(),
102-
);
103-
assert!(result.await?.contains("postgres_fdw"));
100+
let result =
101+
get_output_from_sql("SELECT * FROM pg_extension WHERE extname = 'clerk_fdw'".to_string());
102+
assert!(result.await?.contains("clerk_fdw"));
104103

105104
// tembo delete
106105
let mut cmd = Command::cargo_bin(CARGO_BIN)?;

tembo-cli/tests/tomls/data-warehouse/tembo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ cpu = "2"
55
memory = "8Gi"
66
storage = "50Gi"
77
stack_type = "DataWarehouse"
8+
9+
[data-warehouse.extensions.clerk_fdw]
10+
enabled = true
11+
version = "0.2.4"

0 commit comments

Comments
 (0)