Skip to content

Commit

Permalink
Fix targetless Job agent namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Razz4780 committed Feb 4, 2025
1 parent c5504f7 commit 219b709
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mirrord/kube/src/api/kubernetes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ pub struct KubernetesAPI {
}

impl KubernetesAPI {
/// Creates a new instance from the given [`LayerConfig`].
///
/// If [`LayerConfig::target`] specifies a targetless run,
/// replaces [`AgentConfig::namespace`] with the target namespace.
pub async fn create(config: &LayerConfig) -> Result<Self> {
let client = create_kube_config(
config.accept_invalid_certificates,
Expand All @@ -50,7 +54,17 @@ impl KubernetesAPI {
.await?
.try_into()?;

Ok(KubernetesAPI::new(client, config.agent.clone()))
let mut agent = config.agent.clone();
if config
.target
.path
.as_ref()
.is_none_or(|path| matches!(path, Target::Targetless))
{
agent.namespace = config.target.namespace.clone();
}

Ok(KubernetesAPI::new(client, agent))
}

pub fn new(client: Client, agent: AgentConfig) -> Self {
Expand Down

0 comments on commit 219b709

Please sign in to comment.