(ctx *gin.Context)
| 911 | } |
| 912 | |
| 913 | func (m *Modules) DownloadLogs(ctx *gin.Context) { |
| 914 | ctx.Header("Access-Control-Allow-Origin", "*") |
| 915 | |
| 916 | namespace := ctx.Param("namespace") |
| 917 | container := ctx.Param("container") |
| 918 | name := ctx.Param("name") |
| 919 | |
| 920 | logs, err := m.kubernetesClient.GetPodLogs( |
| 921 | namespace, |
| 922 | container, |
| 923 | name, |
| 924 | nil, |
| 925 | ) |
| 926 | if err != nil { |
| 927 | fmt.Println(err) |
| 928 | ctx.JSON(http.StatusInternalServerError, dto.NewError("Error fetching logs", err.Error())) |
| 929 | return |
| 930 | } |
| 931 | |
| 932 | tempFile, err := os.CreateTemp("", fmt.Sprintf("%v-%v-*.txt", name, container)) |
| 933 | if err != nil { |
| 934 | ctx.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to create file"}) |
| 935 | return |
| 936 | } |
| 937 | defer tempFile.Close() |
| 938 | |
| 939 | for _, log := range logs { |
| 940 | _, err = tempFile.WriteString(log + "\n") |
| 941 | if err != nil { |
| 942 | ctx.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to write to file"}) |
| 943 | return |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | ctx.Header("Content-Description", "File Transfer") |
| 948 | ctx.Header("Content-Disposition", "attachment; filename="+fmt.Sprintf("%v-%v.txt", name, container)) |
| 949 | ctx.Header("Content-Type", "application/octet-stream") |
| 950 | ctx.Header("Content-Transfer-Encoding", "binary") |
| 951 | ctx.File(tempFile.Name()) |
| 952 | } |
| 953 | |
| 954 | func (m *Modules) GetManifest(ctx *gin.Context) { |
| 955 | ctx.Header("Access-Control-Allow-Origin", "*") |
nothing calls this directly
no test coverage detected