diff --git a/api/http/handler/kubernetes/kubernetes_config.go b/api/http/handler/kubernetes/kubernetes_config.go index 19bb1648b..f2b1ac5d3 100644 --- a/api/http/handler/kubernetes/kubernetes_config.go +++ b/api/http/handler/kubernetes/kubernetes_config.go @@ -68,17 +68,19 @@ func (handler *Handler) getKubernetesConfig(w http.ResponseWriter, r *http.Reque return &httperror.HandlerError{http.StatusNotFound, "Unable to generate Kubeconfig", err} } + filenameBase := fmt.Sprintf("%s-%s", tokenData.Username, endpoint.Name) contentAcceptHeader := r.Header.Get("Accept") if contentAcceptHeader == "text/yaml" { yaml, err := kcli.GenerateYAML(config) if err != nil { return &httperror.HandlerError{http.StatusInternalServerError, "Failed to generate Kubeconfig", err} } - w.Header().Set("Content-Disposition", `attachment; filename=config.yaml`) + + w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; %s.yaml", filenameBase)) return YAML(w, yaml) } - w.Header().Set("Content-Disposition", `attachment; filename="config.json"`) + w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; %s.json", filenameBase)) return response.JSON(w, config) } diff --git a/app/kubernetes/services/kubeconfigService.js b/app/kubernetes/services/kubeconfigService.js index 752dc1ef3..8b78ca9f7 100644 --- a/app/kubernetes/services/kubeconfigService.js +++ b/app/kubernetes/services/kubeconfigService.js @@ -9,7 +9,11 @@ class KubernetesConfigService { async downloadConfig() { const response = await this.KubernetesConfig.get(); - return this.FileSaver.saveAs(response.data, 'config'); + + const headers = response.headers(); + const contentDispositionHeader = headers['content-disposition']; + const filename = contentDispositionHeader.replace('attachment;', '').trim(); + return this.FileSaver.saveAs(response.data, filename); } }