@@ -28,7 +28,7 @@ import (
2828 "io"
2929 corev1 "k8s.io/api/core/v1"
3030 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31- "path"
31+ "path/filepath "
3232 "strings"
3333 "time"
3434)
@@ -46,7 +46,7 @@ func NICJobList() []Job {
4646 dc .Logger .Printf ("\t Could not retrieve pod list for namespace %s: %v\n " , namespace , err )
4747 } else {
4848 jsonResult , _ := json .MarshalIndent (result , "" , " " )
49- jobResult .Files [path .Join (dc .BaseDir , "resources" , namespace , "pods.json" )] = jsonResult
49+ jobResult .Files [filepath .Join (dc .BaseDir , "resources" , namespace , "pods.json" )] = jsonResult
5050 }
5151 }
5252 ch <- jobResult
@@ -64,7 +64,7 @@ func NICJobList() []Job {
6464 }
6565 for _ , pod := range pods .Items {
6666 for _ , container := range pod .Spec .Containers {
67- logFileName := path .Join (dc .BaseDir , "logs" , namespace , fmt .Sprintf ("%s__%s.txt" , pod .Name , container .Name ))
67+ logFileName := filepath .Join (dc .BaseDir , "logs" , namespace , fmt .Sprintf ("%s__%s.txt" , pod .Name , container .Name ))
6868 bufferedLogs := dc .K8sCoreClientSet .CoreV1 ().Pods (namespace ).GetLogs (pod .Name , & corev1.PodLogOptions {Container : container .Name })
6969 podLogs , err := bufferedLogs .Stream (context .TODO ())
7070 if err != nil {
@@ -96,7 +96,7 @@ func NICJobList() []Job {
9696 dc .Logger .Printf ("\t Could not retrieve events list for namespace %s: %v\n " , namespace , err )
9797 } else {
9898 jsonResult , _ := json .MarshalIndent (result , "" , " " )
99- jobResult .Files [path .Join (dc .BaseDir , "resources" , namespace , "events.json" )] = jsonResult
99+ jobResult .Files [filepath .Join (dc .BaseDir , "resources" , namespace , "events.json" )] = jsonResult
100100 }
101101 }
102102 ch <- jobResult
@@ -113,7 +113,7 @@ func NICJobList() []Job {
113113 dc .Logger .Printf ("\t Could not retrieve configmap list for namespace %s: %v\n " , namespace , err )
114114 } else {
115115 jsonResult , _ := json .MarshalIndent (result , "" , " " )
116- jobResult .Files [path .Join (dc .BaseDir , "resources" , namespace , "configmaps.json" )] = jsonResult
116+ jobResult .Files [filepath .Join (dc .BaseDir , "resources" , namespace , "configmaps.json" )] = jsonResult
117117 }
118118 }
119119
@@ -131,7 +131,7 @@ func NICJobList() []Job {
131131 dc .Logger .Printf ("\t Could not retrieve services list for namespace %s: %v\n " , namespace , err )
132132 } else {
133133 jsonResult , _ := json .MarshalIndent (result , "" , " " )
134- jobResult .Files [path .Join (dc .BaseDir , "resources" , namespace , "services.json" )] = jsonResult
134+ jobResult .Files [filepath .Join (dc .BaseDir , "resources" , namespace , "services.json" )] = jsonResult
135135 }
136136 }
137137 ch <- jobResult
@@ -148,7 +148,7 @@ func NICJobList() []Job {
148148 dc .Logger .Printf ("\t Could not retrieve deployments list for namespace %s: %v\n " , namespace , err )
149149 } else {
150150 jsonResult , _ := json .MarshalIndent (result , "" , " " )
151- jobResult .Files [path .Join (dc .BaseDir , "resources" , namespace , "deployments.json" )] = jsonResult
151+ jobResult .Files [filepath .Join (dc .BaseDir , "resources" , namespace , "deployments.json" )] = jsonResult
152152 }
153153 }
154154 ch <- jobResult
@@ -165,7 +165,7 @@ func NICJobList() []Job {
165165 dc .Logger .Printf ("\t Could not retrieve statefulsets list for namespace %s: %v\n " , namespace , err )
166166 } else {
167167 jsonResult , _ := json .MarshalIndent (result , "" , " " )
168- jobResult .Files [path .Join (dc .BaseDir , "resources" , namespace , "statefulsets.json" )] = jsonResult
168+ jobResult .Files [filepath .Join (dc .BaseDir , "resources" , namespace , "statefulsets.json" )] = jsonResult
169169 }
170170 }
171171 ch <- jobResult
@@ -182,7 +182,7 @@ func NICJobList() []Job {
182182 dc .Logger .Printf ("\t Could not retrieve daemonsets list for namespace %s: %v\n " , namespace , err )
183183 } else {
184184 jsonResult , _ := json .MarshalIndent (result , "" , " " )
185- jobResult .Files [path .Join (dc .BaseDir , "resources" , namespace , "daemonsets.json" )] = jsonResult
185+ jobResult .Files [filepath .Join (dc .BaseDir , "resources" , namespace , "daemonsets.json" )] = jsonResult
186186 }
187187 }
188188 ch <- jobResult
@@ -199,7 +199,7 @@ func NICJobList() []Job {
199199 dc .Logger .Printf ("\t Could not retrieve replicasets list for namespace %s: %v\n " , namespace , err )
200200 } else {
201201 jsonResult , _ := json .MarshalIndent (result , "" , " " )
202- jobResult .Files [path .Join (dc .BaseDir , "resources" , namespace , "replicasets.json" )] = jsonResult
202+ jobResult .Files [filepath .Join (dc .BaseDir , "resources" , namespace , "replicasets.json" )] = jsonResult
203203 }
204204 }
205205 ch <- jobResult
@@ -216,7 +216,7 @@ func NICJobList() []Job {
216216 dc .Logger .Printf ("\t Could not retrieve leases list for namespace %s: %v\n " , namespace , err )
217217 } else {
218218 jsonResult , _ := json .MarshalIndent (result , "" , " " )
219- jobResult .Files [path .Join (dc .BaseDir , "resources" , namespace , "leases.json" )] = jsonResult
219+ jobResult .Files [filepath .Join (dc .BaseDir , "resources" , namespace , "leases.json" )] = jsonResult
220220 }
221221 }
222222 ch <- jobResult
@@ -233,7 +233,7 @@ func NICJobList() []Job {
233233 dc .Logger .Printf ("\t Could not retrieve roles list for namespace %s: %v\n " , namespace , err )
234234 } else {
235235 jsonResult , _ := json .MarshalIndent (result , "" , " " )
236- jobResult .Files [path .Join (dc .BaseDir , "k8s" , "rbac" , namespace , "roles.json" )] = jsonResult
236+ jobResult .Files [filepath .Join (dc .BaseDir , "k8s" , "rbac" , namespace , "roles.json" )] = jsonResult
237237 }
238238 }
239239 ch <- jobResult
@@ -250,7 +250,7 @@ func NICJobList() []Job {
250250 dc .Logger .Printf ("\t Could not retrieve serviceaccounts list for namespace %s: %v\n " , namespace , err )
251251 } else {
252252 jsonResult , _ := json .MarshalIndent (result , "" , " " )
253- jobResult .Files [path .Join (dc .BaseDir , "k8s" , "rbac" , namespace , "serviceaccounts.json" )] = jsonResult
253+ jobResult .Files [filepath .Join (dc .BaseDir , "k8s" , "rbac" , namespace , "serviceaccounts.json" )] = jsonResult
254254 }
255255 }
256256 ch <- jobResult
@@ -267,7 +267,7 @@ func NICJobList() []Job {
267267 dc .Logger .Printf ("\t Could not retrieve role bindings list for namespace %s: %v\n " , namespace , err )
268268 } else {
269269 jsonResult , _ := json .MarshalIndent (result , "" , " " )
270- jobResult .Files [path .Join (dc .BaseDir , "k8s" , "rbac" , namespace , "rolebindings.json" )] = jsonResult
270+ jobResult .Files [filepath .Join (dc .BaseDir , "k8s" , "rbac" , namespace , "rolebindings.json" )] = jsonResult
271271 }
272272 }
273273 ch <- jobResult
@@ -283,7 +283,7 @@ func NICJobList() []Job {
283283 dc .Logger .Printf ("\t Could not retrieve server version: %v\n " , err )
284284 } else {
285285 jsonResult , _ := json .MarshalIndent (result , "" , " " )
286- jobResult .Files [path .Join (dc .BaseDir , "k8s" , "version.json" )] = jsonResult
286+ jobResult .Files [filepath .Join (dc .BaseDir , "k8s" , "version.json" )] = jsonResult
287287 }
288288 ch <- jobResult
289289 },
@@ -298,7 +298,7 @@ func NICJobList() []Job {
298298 dc .Logger .Printf ("\t Could not retrieve crd data: %v\n " , err )
299299 } else {
300300 jsonResult , _ := json .MarshalIndent (result , "" , " " )
301- jobResult .Files [path .Join (dc .BaseDir , "k8s" , "crd.json" )] = jsonResult
301+ jobResult .Files [filepath .Join (dc .BaseDir , "k8s" , "crd.json" )] = jsonResult
302302 }
303303 ch <- jobResult
304304 },
@@ -313,7 +313,7 @@ func NICJobList() []Job {
313313 dc .Logger .Printf ("\t Could not retrieve clusterroles data: %v\n " , err )
314314 } else {
315315 jsonResult , _ := json .MarshalIndent (result , "" , " " )
316- jobResult .Files [path .Join (dc .BaseDir , "k8s" , "rbac" , "clusterroles.json" )] = jsonResult
316+ jobResult .Files [filepath .Join (dc .BaseDir , "k8s" , "rbac" , "clusterroles.json" )] = jsonResult
317317 }
318318 ch <- jobResult
319319 },
@@ -328,7 +328,7 @@ func NICJobList() []Job {
328328 dc .Logger .Printf ("\t Could not retrieve clusterroles binding data: %v\n " , err )
329329 } else {
330330 jsonResult , _ := json .MarshalIndent (result , "" , " " )
331- jobResult .Files [path .Join (dc .BaseDir , "k8s" , "rbac" , "clusterrolesbindings.json" )] = jsonResult
331+ jobResult .Files [filepath .Join (dc .BaseDir , "k8s" , "rbac" , "clusterrolesbindings.json" )] = jsonResult
332332 }
333333 ch <- jobResult
334334 },
@@ -343,7 +343,7 @@ func NICJobList() []Job {
343343 dc .Logger .Printf ("\t Could not retrieve nodes information: %v\n " , err )
344344 } else {
345345 jsonResult , _ := json .MarshalIndent (result , "" , " " )
346- jobResult .Files [path .Join (dc .BaseDir , "k8s" , "nodes.json" )] = jsonResult
346+ jobResult .Files [filepath .Join (dc .BaseDir , "k8s" , "nodes.json" )] = jsonResult
347347 }
348348 ch <- jobResult
349349 },
@@ -358,15 +358,15 @@ func NICJobList() []Job {
358358 dc .Logger .Printf ("\t Could not retrieve nodes metrics: %v\n " , err )
359359 } else {
360360 jsonNodeMetrics , _ := json .MarshalIndent (nodeMetrics , "" , " " )
361- jobResult .Files [path .Join (dc .BaseDir , "metrics" , "node-resource-list.json" )] = jsonNodeMetrics
361+ jobResult .Files [filepath .Join (dc .BaseDir , "metrics" , "node-resource-list.json" )] = jsonNodeMetrics
362362 }
363363 for _ , namespace := range dc .Namespaces {
364364 podMetrics , _ := dc .K8sMetricsClientSet .MetricsV1beta1 ().PodMetricses (namespace ).List (ctx , metav1.ListOptions {})
365365 if err != nil {
366366 dc .Logger .Printf ("\t Could not retrieve pods metrics for namespace %s: %v\n " , namespace , err )
367367 } else {
368368 jsonPodMetrics , _ := json .MarshalIndent (podMetrics , "" , " " )
369- jobResult .Files [path .Join (dc .BaseDir , "metrics" , namespace , "pod-resource-list.json" )] = jsonPodMetrics
369+ jobResult .Files [filepath .Join (dc .BaseDir , "metrics" , namespace , "pod-resource-list.json" )] = jsonPodMetrics
370370 }
371371 }
372372 ch <- jobResult
@@ -382,7 +382,7 @@ func NICJobList() []Job {
382382 if err != nil {
383383 dc .Logger .Printf ("\t Could not retrieve helm information: %v\n " , err )
384384 } else {
385- jobResult .Files [path .Join (dc .BaseDir , "helm" , "settings.json" )] = jsonSettings
385+ jobResult .Files [filepath .Join (dc .BaseDir , "helm" , "settings.json" )] = jsonSettings
386386 }
387387 ch <- jobResult
388388 },
@@ -399,8 +399,8 @@ func NICJobList() []Job {
399399 } else {
400400 for _ , release := range releases {
401401 jsonRelease , _ := json .MarshalIndent (release , "" , " " )
402- jobResult .Files [path .Join (dc .BaseDir , "helm" , namespace , release .Name + "_release.json" )] = jsonRelease
403- jobResult .Files [path .Join (dc .BaseDir , "helm" , namespace , release .Name + "_manifest.txt" )] = []byte (release .Manifest )
402+ jobResult .Files [filepath .Join (dc .BaseDir , "helm" , namespace , release .Name + "_release.json" )] = jsonRelease
403+ jobResult .Files [filepath .Join (dc .BaseDir , "helm" , namespace , release .Name + "_manifest.txt" )] = []byte (release .Manifest )
404404 }
405405 }
406406 }
@@ -425,7 +425,7 @@ func NICJobList() []Job {
425425 if err != nil {
426426 dc .Logger .Printf ("\t Command execution %s failed for pod %s in namespace %s: %v\n " , command , pod .Name , namespace , err )
427427 } else {
428- jobResult .Files [path .Join (dc .BaseDir , "exec" , namespace , pod .Name + "__nginx-t.txt" )] = res
428+ jobResult .Files [filepath .Join (dc .BaseDir , "exec" , namespace , pod .Name + "__nginx-t.txt" )] = res
429429 }
430430 }
431431 }
@@ -451,7 +451,7 @@ func NICJobList() []Job {
451451 if err != nil {
452452 dc .Logger .Printf ("\t Command execution %s failed for pod %s in namespace %s: %v\n " , command , pod .Name , namespace , err )
453453 } else {
454- jobResult .Files [path .Join (dc .BaseDir , "exec" , namespace , pod .Name + "__nginx-ingress-version.txt" )] = res
454+ jobResult .Files [filepath .Join (dc .BaseDir , "exec" , namespace , pod .Name + "__nginx-ingress-version.txt" )] = res
455455 }
456456 }
457457 }
@@ -473,7 +473,7 @@ func NICJobList() []Job {
473473 } else {
474474 var jsonResult bytes.Buffer
475475 _ = json .Indent (& jsonResult , result , "" , " " )
476- jobResult .Files [path .Join (dc .BaseDir , "crds" , namespace , crd .Resource + ".json" )] = jsonResult .Bytes ()
476+ jobResult .Files [filepath .Join (dc .BaseDir , "crds" , namespace , crd .Resource + ".json" )] = jsonResult .Bytes ()
477477 }
478478 }
479479 }
0 commit comments