Skip to content

Commit

Permalink
some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
shigedangao committed Nov 19, 2024
1 parent 584bc40 commit e2c4527
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct Cli {
pub namespace: String,

#[arg(short, long, default_value = "3")]
pub backoff_limit: usize,
pub backoff_limit: i32,
}

impl Cli {
Expand Down
4 changes: 2 additions & 2 deletions src/kube/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ where
&mut self,
name: N,
mut job_spec: JobSpec,
backoff_limit: usize,
backoff_limit: i32,
) -> Result<&Self> {
let mut job: Job = serde_json::from_value(json!({
"apiVersion": "batch/v1",
Expand All @@ -86,7 +86,7 @@ where
"spec": {}
}))?;

job_spec.backoff_limit = Some(backoff_limit as i32);
job_spec.backoff_limit = Some(backoff_limit);
job.spec = Some(job_spec);

self.job = Some(job);
Expand Down
21 changes: 12 additions & 9 deletions src/kube/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,21 @@ impl SpecHandler for JobSpec {
.ok_or_else(|| anyhow!("Unable to found pod spec on job"))?;

for (idx, container) in pod_spec.containers.iter_mut().enumerate() {
let Some(updated_env) =
envs.get(idx)
let updated_env =
match envs
.get(idx)
.and_then(|cont| match cont.name == container.name {
true => Some(cont),
false => None,
})
else {
return Err(anyhow!(
"Unable to get the environment variable for the container {:?}",
container.name
));
};
}) {
Some(updated_env) => updated_env,
None => {
return Err(anyhow!(
"Unable to get the environment variable for the container {:?}",
container.name
));
}
};

if let Some(container_envs) = container.env.as_mut() {
for container_env in container_envs {
Expand Down

0 comments on commit e2c4527

Please sign in to comment.