@@ -367,6 +367,13 @@ func (c *CollectClusterResources) Collect(progressChan chan<- interface{}) (Coll
367
367
}
368
368
output .SaveResult (c .BundlePath , path .Join (constants .CLUSTER_RESOURCES_DIR , fmt .Sprintf ("%s-errors.json" , constants .CLUSTER_RESOURCES_ENDPOINTS )), marshalErrors (endpointsErrors ))
369
369
370
+ // endpointslices
371
+ endpointslices , endpointslicesErrors := endpointslices (ctx , client , namespaceNames )
372
+ for k , v := range endpointslices {
373
+ _ = output .SaveResult (c .BundlePath , path .Join (constants .CLUSTER_RESOURCES_DIR , constants .CLUSTER_RESOURCES_ENDPOINTSICES , k ), bytes .NewBuffer (v ))
374
+ }
375
+ _ = output .SaveResult (c .BundlePath , path .Join (constants .CLUSTER_RESOURCES_DIR , fmt .Sprintf ("%s-errors.json" , constants .CLUSTER_RESOURCES_ENDPOINTSICES )), marshalErrors (endpointslicesErrors ))
376
+
370
377
// Service Accounts
371
378
servicesAccounts , servicesAccountsErrors := serviceAccounts (ctx , client , namespaceNames )
372
379
for k , v := range servicesAccounts {
@@ -1983,6 +1990,42 @@ func endpoints(ctx context.Context, client *kubernetes.Clientset, namespaces []s
1983
1990
return endpointsByNamespace , errorsByNamespace
1984
1991
}
1985
1992
1993
+ func endpointslices (ctx context.Context , client * kubernetes.Clientset , namespaces []string ) (map [string ][]byte , map [string ]string ) {
1994
+ objsByNamespace := make (map [string ][]byte )
1995
+ errorsByNamespace := make (map [string ]string )
1996
+
1997
+ for _ , namespace := range namespaces {
1998
+ objs , err := client .DiscoveryV1 ().EndpointSlices (namespace ).List (ctx , metav1.ListOptions {})
1999
+ if err != nil {
2000
+ errorsByNamespace [namespace ] = err .Error ()
2001
+ continue
2002
+ }
2003
+
2004
+ // TODO: Can we DRY this? We repeat this pattern a lot
2005
+ gvk , err := apiutil .GVKForObject (objs , scheme .Scheme )
2006
+ if err == nil {
2007
+ objs .GetObjectKind ().SetGroupVersionKind (gvk )
2008
+ }
2009
+
2010
+ for i , o := range objs .Items {
2011
+ gvk , err := apiutil .GVKForObject (& o , scheme .Scheme )
2012
+ if err == nil {
2013
+ objs .Items [i ].GetObjectKind ().SetGroupVersionKind (gvk )
2014
+ }
2015
+ }
2016
+
2017
+ b , err := json .MarshalIndent (objs , "" , " " )
2018
+ if err != nil {
2019
+ errorsByNamespace [namespace ] = err .Error ()
2020
+ continue
2021
+ }
2022
+
2023
+ objsByNamespace [namespace + ".json" ] = b
2024
+ }
2025
+
2026
+ return objsByNamespace , errorsByNamespace
2027
+ }
2028
+
1986
2029
func serviceAccounts (ctx context.Context , client kubernetes.Interface , namespaces []string ) (map [string ][]byte , map [string ]string ) {
1987
2030
serviceAccountsByNamespace := make (map [string ][]byte )
1988
2031
errorsByNamespace := make (map [string ]string )
0 commit comments