Skip to content

Commit eb206db

Browse files
committed
feat: add job to collect serviceaccounts
1 parent 5145521 commit eb206db

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/jobs/job_list.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,23 @@ func JobList() []Job {
220220
ch <- jobResult
221221
},
222222
},
223+
{
224+
Name: "serviceaccounts-list",
225+
Timeout: time.Second * 10,
226+
Execute: func(dc *data_collector.DataCollector, ctx context.Context, ch chan JobResult) {
227+
jobResult := JobResult{Files: make(map[string][]byte), Error: nil}
228+
for _, namespace := range dc.Namespaces {
229+
result, err := dc.K8sCoreClientSet.CoreV1().ServiceAccounts(namespace).List(ctx, metav1.ListOptions{})
230+
if err != nil {
231+
dc.Logger.Printf("\tCould not retrieve serviceaccounts list for namespace %s: %v\n", namespace, err)
232+
} else {
233+
jsonResult, _ := json.MarshalIndent(result, "", " ")
234+
jobResult.Files[path.Join(dc.BaseDir, "k8s", "rbac", namespace, "serviceaccounts.json")] = jsonResult
235+
}
236+
}
237+
ch <- jobResult
238+
},
239+
},
223240
{
224241
Name: "rolebindings-list",
225242
Timeout: time.Second * 10,

0 commit comments

Comments
 (0)