Skip to content

Commit

Permalink
feat: Change the file name convention when downloading pod logs (argo…
Browse files Browse the repository at this point in the history
…proj#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>
  • Loading branch information
itaynvn-runai committed Sep 18, 2024
1 parent fcc186b commit fd4cc93
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/apiclient/application/forwarder_overwrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit fd4cc93

Please sign in to comment.