From fd4cc93a30e66557dee952aabd5a4009509047b3 Mon Sep 17 00:00:00 2001 From: itaynvn-runai <165032271+itaynvn-runai@users.noreply.github.com> Date: Wed, 18 Sep 2024 11:14:36 +0300 Subject: [PATCH] feat: Change the file name convention when downloading pod logs (#19938) * changed log file name convention Signed-off-by: itaynvn-runai * fixed condition Signed-off-by: itaynvn-runai * Update forwarder_overwrite.go changed `appNamespace` to `namespace`. as `appNamespace` will always be "argocd", and `namespace` is based on the actual k8s namespace, and will be unique. so each log file name will always be unique, and descriptive. Signed-off-by: itaynvn-runai <165032271+itaynvn-runai@users.noreply.github.com> * Update forwarder_overwrite.go added `container` to the file name Signed-off-by: itaynvn-runai <165032271+itaynvn-runai@users.noreply.github.com> --------- Signed-off-by: itaynvn-runai Signed-off-by: itaynvn-runai <165032271+itaynvn-runai@users.noreply.github.com> --- pkg/apiclient/application/forwarder_overwrite.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/apiclient/application/forwarder_overwrite.go b/pkg/apiclient/application/forwarder_overwrite.go index b9f90748ef182..4769775f9671f 100644 --- a/pkg/apiclient/application/forwarder_overwrite.go +++ b/pkg/apiclient/application/forwarder_overwrite.go @@ -116,8 +116,11 @@ func init() { if req.URL.Query().Get("download") == "true" { w.Header().Set("Content-Type", "application/octet-stream") fileName := "log" - if container := req.URL.Query().Get("container"); len(container) > 0 && kube.IsValidResourceName(container) { - fileName = container + namespace := req.URL.Query().Get("namespace") + podName := req.URL.Query().Get("podName") + container := req.URL.Query().Get("container") + if kube.IsValidResourceName(namespace) && kube.IsValidResourceName(podName) && kube.IsValidResourceName(container) { + fileName = fmt.Sprintf("%s-%s-%s", namespace, podName, container) } w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment;filename="%s.log"`, fileName)) for {