From 34e4dcdcb80cc002f671d38f0f45280a6badedd7 Mon Sep 17 00:00:00 2001 From: Luke Goodfellow <107487942+lukasmagik@users.noreply.github.com> Date: Thu, 27 Mar 2025 07:27:03 -0700 Subject: [PATCH] moved logs into its on directory --- internal/utils/fetch_and_save.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/utils/fetch_and_save.go b/internal/utils/fetch_and_save.go index f5fa7ef..af33155 100644 --- a/internal/utils/fetch_and_save.go +++ b/internal/utils/fetch_and_save.go @@ -56,6 +56,10 @@ func FetchAndSaveData(namespace string, k8sResources []string, dirPath, version } if k8sType == "pods" { + err := os.MkdirAll(filepath.Join(dirPath, "logs"), os.ModePerm) + if err != nil { + return fmt.Errorf("error creating directory: %v", err) + } for _, resource := range k8sResources.JSON["items"].([]interface{}) { resourceMap := resource.(map[string]interface{}) podName := resourceMap["metadata"].(map[string]interface{})["name"].(string) @@ -69,7 +73,7 @@ func FetchAndSaveData(namespace string, k8sResources []string, dirPath, version continue } - logFileName := filepath.Join(dirPath, k8sType, fmt.Sprintf("%s_%s.log", podName, containerMap["name"].(string))) + logFileName := filepath.Join(dirPath, "logs", fmt.Sprintf("%s_%s.log", podName, containerMap["name"].(string))) err = os.WriteFile(logFileName, []byte(log), os.ModePerm) if err != nil { return fmt.Errorf("error writing log file: %v", err)