Skip to content

Commit

Permalink
Use template annotations from pod template
Browse files Browse the repository at this point in the history
  • Loading branch information
film42 committed Mar 28, 2022
1 parent 6d43002 commit c941967
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docbot-controller/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub fn generate_from_template(
) -> Result<Job, Box<dyn std::error::Error>> {
let mut job = Job::default();
job.metadata = ObjectMeta::default();
job.metadata.annotations = template.metadata.annotations.clone();
if let Some(ref mut annotations) = job.metadata.annotations {
annotations.remove("kubectl.kubernetes.io/last-applied-configuration");
}
Expand All @@ -21,6 +20,10 @@ pub fn generate_from_template(
));
let mut job_spec = JobSpec::default();
if let Some(pod_template_spec) = template.template {
if let Some(ref metadata) = pod_template_spec.metadata {
job.metadata.annotations = metadata.annotations.clone();
}

job_spec.template = pod_template_spec.clone();
if let Some(ref mut spec) = job_spec.template.spec {
// Reset this value of Always was specified. This is the default value for
Expand Down
2 changes: 2 additions & 0 deletions podtemplate.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ metadata:
app: nginx
template:
metadata:
annotations:
yolo: brolo
labels:
app: nginx
spec:
Expand Down

0 comments on commit c941967

Please sign in to comment.