Skip to content

Commit

Permalink
revert changes to create encoded secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
nhudson committed Jan 6, 2025
1 parent 23bb5ab commit b0c7699
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 56 deletions.
2 changes: 1 addition & 1 deletion charts/tembo-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: tembo-operator
description: "Helm chart to deploy the tembo-operator"
type: application
icon: https://cloud.tembo.io/images/TemboElephant.png
version: 0.9.0
version: 0.9.1
home: https://tembo.io
sources:
- https://github.com/tembo-io/tembo
Expand Down
2 changes: 0 additions & 2 deletions charts/tembo-operator/templates/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,6 @@ spec:
enum:
- ReadOnlyConnection
- ReadWriteConnection
- EncodedReadOnlyConnection
- EncodedReadWriteConnection
nullable: true
type: string
required:
Expand Down
2 changes: 1 addition & 1 deletion conductor/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tembo-operator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tembo-operator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "controller"
description = "Tembo Operator for Postgres"
version = "0.54.2"
version = "0.54.3"
edition = "2021"
default-run = "controller"
license = "Apache-2.0"
Expand Down
4 changes: 1 addition & 3 deletions tembo-operator/src/app_service/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,6 @@ fn generate_deployment(
let secret_key = match e {
EnvVarRef::ReadOnlyConnection => "ro_uri",
EnvVarRef::ReadWriteConnection => "rw_uri",
EnvVarRef::EncodedReadOnlyConnection => "encoded_ro_uri",
EnvVarRef::EncodedReadWriteConnection => "encoded_rw_uri",
};
Some(EnvVar {
name: env.name,
Expand Down Expand Up @@ -1061,7 +1059,7 @@ pub async fn prepare_apps_connection_secret(client: Client, cdb: &CoreDB) -> Res
let mut new_secret_data = BTreeMap::new();
for (key, value) in original_secret_data {
match key.as_str() {
"r_uri" | "ro_uri" | "rw_uri" | "encoded_ro_uri" | "encoded_rw_uri" => {
"r_uri" | "ro_uri" | "rw_uri" => {
let new_value = format!("{}?application_name=tembo-apps", value);
new_secret_data.insert(key, new_value);
}
Expand Down
2 changes: 0 additions & 2 deletions tembo-operator/src/app_service/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ pub struct EnvVar {
pub enum EnvVarRef {
ReadOnlyConnection,
ReadWriteConnection,
EncodedReadOnlyConnection,
EncodedReadWriteConnection,
}

/// Routing is used if there is a routing port, then a service is created using
Expand Down
42 changes: 0 additions & 42 deletions tembo-operator/src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,6 @@ fn secret_data(cdb: &CoreDB, ns: &str, password: String) -> BTreeMap<String, Byt
data.insert("pooler_uri".to_owned(), b64_pooler_uri);
}

// URL encode the password for the encoded URIs
let encoded_password = utf8_percent_encode(&password, NON_ALPHANUMERIC).to_string();

// Add encoded read-write URI
let encoded_rwuri = format!(
"postgresql://{}:{}@{}:{}",
&user, &encoded_password, &rw_host, &port
);
let b64_encoded_rwuri = b64_encode(&encoded_rwuri);
data.insert("encoded_rw_uri".to_owned(), b64_encoded_rwuri);

// Add encoded read-only URI
let encoded_rouri = format!(
"postgresql://{}:{}@{}:{}",
&user, &encoded_password, &ro_host, &port
);
let b64_encoded_rouri = b64_encode(&encoded_rouri);
data.insert("encoded_ro_uri".to_owned(), b64_encoded_rouri);

data
}

Expand Down Expand Up @@ -305,26 +286,3 @@ fn generate_password() -> String {
};
pg.generate_one().unwrap()
}

#[cfg(test)]
mod tests {
use super::*;
use crate::apis::coredb_types::{CoreDB, CoreDBSpec};

#[test]
fn test_secret_data_url_encoding() {
let cdb = CoreDB::new("test-db", CoreDBSpec::default());

let password = "TestingPasswd12345@#".to_string();
let data = secret_data(&cdb, "default", password);

let encoded_rw = data.get("encoded_rw_uri").unwrap();
// The string is already a URL, just need to convert bytes to string
let decoded_rw = String::from_utf8(encoded_rw.0.clone()).unwrap();
assert!(decoded_rw.contains("TestingPasswd12345%40%23"));

let encoded_ro = data.get("encoded_ro_uri").unwrap();
let decoded_ro = String::from_utf8(encoded_ro.0.clone()).unwrap();
assert!(decoded_ro.contains("TestingPasswd12345%40%23"));
}
}
4 changes: 2 additions & 2 deletions tembo-stacks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tembo-stacks"
description = "Tembo Stacks for Postgres"
version = "0.23.4"
version = "0.23.5"
authors = ["tembo.io"]
edition = "2021"
license = "Apache-2.0"
Expand Down Expand Up @@ -29,7 +29,7 @@ serde_json = "1.0.114"
serde_yaml = "0.9.21"
strum = "0.26.2"
strum_macros = "0.26.2"
tembo-controller = { package = "controller", version = "0.54.0" }
tembo-controller = { package = "controller", version = "0.53.0" }
tracing = "0.1"
utoipa = { version = "3", features = ["actix_extras", "chrono"] }

Expand Down
2 changes: 1 addition & 1 deletion tembo-stacks/src/apps/sql-runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ appServices:
ingressPath: "/sql/v1"
env:
- name: CONNECTION_STRING
valueFromPlatform: EncodedReadWriteConnection
valueFromPlatform: ReadWriteConnection

0 comments on commit b0c7699

Please sign in to comment.