From 844dcbf03ed2ff19d1c837121ebce0c4bbaccc68 Mon Sep 17 00:00:00 2001 From: babugeet <97796199+babugeet@users.noreply.github.com> Date: Sat, 8 Jun 2024 00:47:01 +0530 Subject: [PATCH] Adding mount path as env variable in container (#7968) * Adding mount path as env variable in container Signed-off-by: babugeet * Added enviornment variable based on the mountpath Signed-off-by: "babugeet " --- cmd/jobsink/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/jobsink/main.go b/cmd/jobsink/main.go index 58eee06b987..bb4d8b6fcca 100644 --- a/cmd/jobsink/main.go +++ b/cmd/jobsink/main.go @@ -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 } } @@ -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