Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator(apps): don't duplicate TEMBO_INSTANCE_ID, TEMBO_ORG_ID #925

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading