Skip to content

Commit

Permalink
operator(apps): don't duplicate TEMBO_INSTANCE_ID, TEMBO_ORG_ID (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vrmiguel authored Aug 21, 2024
1 parent ec42853 commit 2295805
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
37 changes: 24 additions & 13 deletions tembo-operator/src/app_service/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use kube::{
Client, Resource,
};
use lazy_static::lazy_static;
use std::{collections::BTreeMap, sync::Arc, time::Duration};
use std::{collections::BTreeMap, ops::Not, sync::Arc, time::Duration};

use crate::{
app_service::ingress::{generate_ingress_tcp_routes, reconcile_ingress_tcp},
Expand Down Expand Up @@ -432,21 +432,32 @@ fn generate_deployment(
}
}

let has_instance_id = env_vars.iter().any(|env| env.name == "TEMBO_INSTANCE_ID");
let has_org_id = env_vars.iter().any(|env| env.name == "TEMBO_ORG_ID");

// Check for tembo.io/instance_id and tembo.io/organization_id annotations
if let Some(instance_id) = annotations.get("tembo.io/instance_id") {
env_vars.push(EnvVar {
name: "TEMBO_INSTANCE_ID".to_string(),
value: Some(instance_id.clone()),
..EnvVar::default()
});
if has_instance_id.not() {
if let Some(instance_id) = annotations.get("tembo.io/instance_id") {
env_vars.push(EnvVar {
name: "TEMBO_INSTANCE_ID".to_string(),
value: Some(instance_id.clone()),
..EnvVar::default()
});
}
} else {
tracing::info!("Not applying TEMBO_INSTANCE_ID to env since it's already present");
}

if let Some(organization_id) = annotations.get("tembo.io/organization_id") {
env_vars.push(EnvVar {
name: "TEMBO_ORG_ID".to_string(),
value: Some(organization_id.clone()),
..EnvVar::default()
});
if has_org_id.not() {
if let Some(organization_id) = annotations.get("tembo.io/organization_id") {
env_vars.push(EnvVar {
name: "TEMBO_ORG_ID".to_string(),
value: Some(organization_id.clone()),
..EnvVar::default()
});
}
} else {
tracing::info!("Not applying TEMBO_ORG_ID to env since it's already present");
}

// Add the pre-loaded forwarded environment variables
Expand Down
2 changes: 1 addition & 1 deletion tembo-operator/src/extensions/toggle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ async fn get_trunk_project_version(
if let Some(extension_version) = &location_to_toggle.version {
let maybe_trunk_project = get_trunk_project_metadata_for_version(
trunk_project_name,
trunk::Version::Extension(&extension_version),
trunk::Version::Extension(extension_version),
)
.await;

Expand Down

0 comments on commit 2295805

Please sign in to comment.