@@ -28,7 +28,7 @@ import (
28
28
"io"
29
29
corev1 "k8s.io/api/core/v1"
30
30
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31
- "path"
31
+ "path/filepath "
32
32
"strings"
33
33
"time"
34
34
)
@@ -46,7 +46,7 @@ func NICJobList() []Job {
46
46
dc .Logger .Printf ("\t Could not retrieve pod list for namespace %s: %v\n " , namespace , err )
47
47
} else {
48
48
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
50
50
}
51
51
}
52
52
ch <- jobResult
@@ -64,7 +64,7 @@ func NICJobList() []Job {
64
64
}
65
65
for _ , pod := range pods .Items {
66
66
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 ))
68
68
bufferedLogs := dc .K8sCoreClientSet .CoreV1 ().Pods (namespace ).GetLogs (pod .Name , & corev1.PodLogOptions {Container : container .Name })
69
69
podLogs , err := bufferedLogs .Stream (context .TODO ())
70
70
if err != nil {
@@ -96,7 +96,7 @@ func NICJobList() []Job {
96
96
dc .Logger .Printf ("\t Could not retrieve events list for namespace %s: %v\n " , namespace , err )
97
97
} else {
98
98
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
100
100
}
101
101
}
102
102
ch <- jobResult
@@ -113,7 +113,7 @@ func NICJobList() []Job {
113
113
dc .Logger .Printf ("\t Could not retrieve configmap list for namespace %s: %v\n " , namespace , err )
114
114
} else {
115
115
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
117
117
}
118
118
}
119
119
@@ -131,7 +131,7 @@ func NICJobList() []Job {
131
131
dc .Logger .Printf ("\t Could not retrieve services list for namespace %s: %v\n " , namespace , err )
132
132
} else {
133
133
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
135
135
}
136
136
}
137
137
ch <- jobResult
@@ -148,7 +148,7 @@ func NICJobList() []Job {
148
148
dc .Logger .Printf ("\t Could not retrieve deployments list for namespace %s: %v\n " , namespace , err )
149
149
} else {
150
150
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
152
152
}
153
153
}
154
154
ch <- jobResult
@@ -165,7 +165,7 @@ func NICJobList() []Job {
165
165
dc .Logger .Printf ("\t Could not retrieve statefulsets list for namespace %s: %v\n " , namespace , err )
166
166
} else {
167
167
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
169
169
}
170
170
}
171
171
ch <- jobResult
@@ -182,7 +182,7 @@ func NICJobList() []Job {
182
182
dc .Logger .Printf ("\t Could not retrieve daemonsets list for namespace %s: %v\n " , namespace , err )
183
183
} else {
184
184
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
186
186
}
187
187
}
188
188
ch <- jobResult
@@ -199,7 +199,7 @@ func NICJobList() []Job {
199
199
dc .Logger .Printf ("\t Could not retrieve replicasets list for namespace %s: %v\n " , namespace , err )
200
200
} else {
201
201
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
203
203
}
204
204
}
205
205
ch <- jobResult
@@ -216,7 +216,7 @@ func NICJobList() []Job {
216
216
dc .Logger .Printf ("\t Could not retrieve leases list for namespace %s: %v\n " , namespace , err )
217
217
} else {
218
218
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
220
220
}
221
221
}
222
222
ch <- jobResult
@@ -233,7 +233,7 @@ func NICJobList() []Job {
233
233
dc .Logger .Printf ("\t Could not retrieve roles list for namespace %s: %v\n " , namespace , err )
234
234
} else {
235
235
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
237
237
}
238
238
}
239
239
ch <- jobResult
@@ -250,7 +250,7 @@ func NICJobList() []Job {
250
250
dc .Logger .Printf ("\t Could not retrieve serviceaccounts list for namespace %s: %v\n " , namespace , err )
251
251
} else {
252
252
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
254
254
}
255
255
}
256
256
ch <- jobResult
@@ -267,7 +267,7 @@ func NICJobList() []Job {
267
267
dc .Logger .Printf ("\t Could not retrieve role bindings list for namespace %s: %v\n " , namespace , err )
268
268
} else {
269
269
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
271
271
}
272
272
}
273
273
ch <- jobResult
@@ -283,7 +283,7 @@ func NICJobList() []Job {
283
283
dc .Logger .Printf ("\t Could not retrieve server version: %v\n " , err )
284
284
} else {
285
285
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
287
287
}
288
288
ch <- jobResult
289
289
},
@@ -298,7 +298,7 @@ func NICJobList() []Job {
298
298
dc .Logger .Printf ("\t Could not retrieve crd data: %v\n " , err )
299
299
} else {
300
300
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
302
302
}
303
303
ch <- jobResult
304
304
},
@@ -313,7 +313,7 @@ func NICJobList() []Job {
313
313
dc .Logger .Printf ("\t Could not retrieve clusterroles data: %v\n " , err )
314
314
} else {
315
315
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
317
317
}
318
318
ch <- jobResult
319
319
},
@@ -328,7 +328,7 @@ func NICJobList() []Job {
328
328
dc .Logger .Printf ("\t Could not retrieve clusterroles binding data: %v\n " , err )
329
329
} else {
330
330
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
332
332
}
333
333
ch <- jobResult
334
334
},
@@ -343,7 +343,7 @@ func NICJobList() []Job {
343
343
dc .Logger .Printf ("\t Could not retrieve nodes information: %v\n " , err )
344
344
} else {
345
345
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
347
347
}
348
348
ch <- jobResult
349
349
},
@@ -358,15 +358,15 @@ func NICJobList() []Job {
358
358
dc .Logger .Printf ("\t Could not retrieve nodes metrics: %v\n " , err )
359
359
} else {
360
360
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
362
362
}
363
363
for _ , namespace := range dc .Namespaces {
364
364
podMetrics , _ := dc .K8sMetricsClientSet .MetricsV1beta1 ().PodMetricses (namespace ).List (ctx , metav1.ListOptions {})
365
365
if err != nil {
366
366
dc .Logger .Printf ("\t Could not retrieve pods metrics for namespace %s: %v\n " , namespace , err )
367
367
} else {
368
368
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
370
370
}
371
371
}
372
372
ch <- jobResult
@@ -382,7 +382,7 @@ func NICJobList() []Job {
382
382
if err != nil {
383
383
dc .Logger .Printf ("\t Could not retrieve helm information: %v\n " , err )
384
384
} else {
385
- jobResult .Files [path .Join (dc .BaseDir , "helm" , "settings.json" )] = jsonSettings
385
+ jobResult .Files [filepath .Join (dc .BaseDir , "helm" , "settings.json" )] = jsonSettings
386
386
}
387
387
ch <- jobResult
388
388
},
@@ -399,8 +399,8 @@ func NICJobList() []Job {
399
399
} else {
400
400
for _ , release := range releases {
401
401
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 )
404
404
}
405
405
}
406
406
}
@@ -425,7 +425,7 @@ func NICJobList() []Job {
425
425
if err != nil {
426
426
dc .Logger .Printf ("\t Command execution %s failed for pod %s in namespace %s: %v\n " , command , pod .Name , namespace , err )
427
427
} 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
429
429
}
430
430
}
431
431
}
@@ -451,7 +451,7 @@ func NICJobList() []Job {
451
451
if err != nil {
452
452
dc .Logger .Printf ("\t Command execution %s failed for pod %s in namespace %s: %v\n " , command , pod .Name , namespace , err )
453
453
} 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
455
455
}
456
456
}
457
457
}
@@ -473,7 +473,7 @@ func NICJobList() []Job {
473
473
} else {
474
474
var jsonResult bytes.Buffer
475
475
_ = 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 ()
477
477
}
478
478
}
479
479
}
0 commit comments