Skip to content

Commit

Permalink
Adding mount path as env variable in container (#7968)
Browse files Browse the repository at this point in the history
* Adding mount path as env variable in container
Signed-off-by: babugeet <abhinandhbg@gmail.com>

* Added enviornment variable based on the mountpath
Signed-off-by: "babugeet <abhinandhbg@gmail.com>"
  • Loading branch information
babugeet authored Jun 7, 2024
1 parent b8623b2 commit 844dcbf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/jobsink/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
job.Labels[sinks.JobSinkIDLabel] = id
job.Labels[sinks.JobSinkNameLabel] = ref.Name
job.OwnerReferences = append(job.OwnerReferences, or)

var mountPathName string
for i := range job.Spec.Template.Spec.Containers {
found := false
for j := range job.Spec.Template.Spec.Containers[i].VolumeMounts {
if job.Spec.Template.Spec.Containers[i].VolumeMounts[j].Name == "jobsink-event" {
found = true
mountPathName = job.Spec.Template.Spec.Containers[i].VolumeMounts[j].MountPath
break
}
}
Expand All @@ -312,7 +313,12 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ReadOnly: true,
MountPath: "/etc/jobsink-event",
})
mountPathName = "/etc/jobsink-event"
}
job.Spec.Template.Spec.Containers[i].Env = append(job.Spec.Template.Spec.Containers[i].Env, corev1.EnvVar{
Name: "K_EVENT_PATH",
Value: mountPathName,
})
}

found := false
Expand Down

0 comments on commit 844dcbf

Please sign in to comment.