Skip to content

Commit fd4cc93

Browse files
authoredSep 18, 2024··
feat: Change the file name convention when downloading pod logs (#19938)
* changed log file name convention Signed-off-by: itaynvn-runai <itay.anavian@run.ai> * fixed condition Signed-off-by: itaynvn-runai <itay.anavian@run.ai> * 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 <itay.anavian@run.ai> Signed-off-by: itaynvn-runai <165032271+itaynvn-runai@users.noreply.github.com>
1 parent fcc186b commit fd4cc93

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎pkg/apiclient/application/forwarder_overwrite.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,11 @@ func init() {
116116
if req.URL.Query().Get("download") == "true" {
117117
w.Header().Set("Content-Type", "application/octet-stream")
118118
fileName := "log"
119-
if container := req.URL.Query().Get("container"); len(container) > 0 && kube.IsValidResourceName(container) {
120-
fileName = container
119+
namespace := req.URL.Query().Get("namespace")
120+
podName := req.URL.Query().Get("podName")
121+
container := req.URL.Query().Get("container")
122+
if kube.IsValidResourceName(namespace) && kube.IsValidResourceName(podName) && kube.IsValidResourceName(container) {
123+
fileName = fmt.Sprintf("%s-%s-%s", namespace, podName, container)
121124
}
122125
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment;filename="%s.log"`, fileName))
123126
for {

0 commit comments

Comments
 (0)
Please sign in to comment.