@@ -24,6 +24,8 @@ type ClusterResourcesOutput struct {
2424 ServicesErrors []byte `json:"cluster-resources/services-errors.json,omitempty"`
2525 Deployments map [string ][]byte `json:"cluster-resources/deployments,omitempty"`
2626 DeploymentsErrors []byte `json:"cluster-resources/deployments-errors.json,omitempty"`
27+ StatefulSets map [string ][]byte `json:"cluster-resources/statefulsets,omitempty"`
28+ StatefulSetsErrors []byte `json:"cluster-resources/statefulsets-errors.json,omitempty"`
2729 Ingress map [string ][]byte `json:"cluster-resources/ingress,omitempty"`
2830 IngressErrors []byte `json:"cluster-resources/ingress-errors.json,omitempty"`
2931 StorageClasses []byte `json:"cluster-resources/storage-classes.json,omitempty"`
@@ -98,6 +100,14 @@ func ClusterResources(ctx *Context) ([]byte, error) {
98100 return nil , err
99101 }
100102
103+ // statefulsets
104+ statefulsets , statefulsetsErrors := statefulsets (client , namespaceNames )
105+ clusterResourcesOutput .StatefulSets = statefulsets
106+ clusterResourcesOutput .StatefulSetsErrors , err = marshalNonNil (statefulsetsErrors )
107+ if err != nil {
108+ return nil , err
109+ }
110+
101111 // ingress
102112 ingress , ingressErrors := ingress (client , namespaceNames )
103113 clusterResourcesOutput .Ingress = ingress
@@ -278,6 +288,29 @@ func deployments(client *kubernetes.Clientset, namespaces []string) (map[string]
278288 return deploymentsByNamespace , errorsByNamespace
279289}
280290
291+ func statefulsets (client * kubernetes.Clientset , namespaces []string ) (map [string ][]byte , map [string ]string ) {
292+ statefulsetsByNamespace := make (map [string ][]byte )
293+ errorsByNamespace := make (map [string ]string )
294+
295+ for _ , namespace := range namespaces {
296+ statefulsets , err := client .AppsV1 ().StatefulSets (namespace ).List (metav1.ListOptions {})
297+ if err != nil {
298+ errorsByNamespace [namespace ] = err .Error ()
299+ continue
300+ }
301+
302+ b , err := json .MarshalIndent (statefulsets .Items , "" , " " )
303+ if err != nil {
304+ errorsByNamespace [namespace ] = err .Error ()
305+ continue
306+ }
307+
308+ statefulsetsByNamespace [namespace + ".json" ] = b
309+ }
310+
311+ return statefulsetsByNamespace , errorsByNamespace
312+ }
313+
281314func ingress (client * kubernetes.Clientset , namespaces []string ) (map [string ][]byte , map [string ]string ) {
282315 ingressByNamespace := make (map [string ][]byte )
283316 errorsByNamespace := make (map [string ]string )
@@ -513,6 +546,10 @@ func (c *ClusterResourcesOutput) Redact() (*ClusterResourcesOutput, error) {
513546 if err != nil {
514547 return nil , err
515548 }
549+ statefulsets , err := redactMap (c .StatefulSets )
550+ if err != nil {
551+ return nil , err
552+ }
516553 ingress , err := redactMap (c .Ingress )
517554 if err != nil {
518555 return nil , err
@@ -545,6 +582,8 @@ func (c *ClusterResourcesOutput) Redact() (*ClusterResourcesOutput, error) {
545582 ServicesErrors : c .ServicesErrors ,
546583 Deployments : deployments ,
547584 DeploymentsErrors : c .DeploymentsErrors ,
585+ StatefulSets : statefulsets ,
586+ StatefulSetsErrors : c .StatefulSetsErrors ,
548587 Ingress : ingress ,
549588 IngressErrors : c .IngressErrors ,
550589 StorageClasses : storageClasses ,
0 commit comments