Skip to content

Commit ab277d2

Browse files
authored
moved logs into its on directory (#29)
1 parent a20e046 commit ab277d2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/utils/fetch_and_save.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ func FetchAndSaveData(namespace string, k8sResources []string, dirPath, version
5656
}
5757

5858
if k8sType == "pods" {
59+
err := os.MkdirAll(filepath.Join(dirPath, "logs"), os.ModePerm)
60+
if err != nil {
61+
return fmt.Errorf("error creating directory: %v", err)
62+
}
5963
for _, resource := range k8sResources.JSON["items"].([]interface{}) {
6064
resourceMap := resource.(map[string]interface{})
6165
podName := resourceMap["metadata"].(map[string]interface{})["name"].(string)
@@ -69,7 +73,7 @@ func FetchAndSaveData(namespace string, k8sResources []string, dirPath, version
6973
continue
7074
}
7175

72-
logFileName := filepath.Join(dirPath, k8sType, fmt.Sprintf("%s_%s.log", podName, containerMap["name"].(string)))
76+
logFileName := filepath.Join(dirPath, "logs", fmt.Sprintf("%s_%s.log", podName, containerMap["name"].(string)))
7377
err = os.WriteFile(logFileName, []byte(log), os.ModePerm)
7478
if err != nil {
7579
return fmt.Errorf("error writing log file: %v", err)

0 commit comments

Comments
 (0)