11package inspect
22
33import (
4+ "context"
45 "fmt"
56 admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
67 "k8s.io/apimachinery/pkg/util/errors"
@@ -20,41 +21,41 @@ func (c *mutatingWebhookConfigList) addItem(obj interface{}) error {
2021 return nil
2122}
2223
23- func gatherMutatingAdmissionWebhook (context * resourceContext , info * resource.Info , o * InspectOptions ) error {
24+ func gatherMutatingAdmissionWebhook (ctx context. Context , rCtx * resourceContext , info * resource.Info , o * InspectOptions ) error {
2425 structuredObj , err := toStructuredObject [admissionregistrationv1.MutatingWebhookConfiguration , admissionregistrationv1.MutatingWebhookConfigurationList ](info .Object )
2526 if err != nil {
26- return gatherGenericObject (context , info , o )
27+ return gatherGenericObject (ctx , rCtx , info , o )
2728 }
2829
2930 errs := []error {}
3031 switch castObj := structuredObj .(type ) {
3132 case * admissionregistrationv1.MutatingWebhookConfiguration :
32- if err := gatherMutatingAdmissionWebhookRelated (context , o , castObj ); err != nil {
33+ if err := gatherMutatingAdmissionWebhookRelated (ctx , rCtx , o , castObj ); err != nil {
3334 errs = append (errs , err )
3435 }
3536
3637 case * admissionregistrationv1.MutatingWebhookConfigurationList :
3738 for _ , webhook := range castObj .Items {
38- if err := gatherMutatingAdmissionWebhookRelated (context , o , & webhook ); err != nil {
39+ if err := gatherMutatingAdmissionWebhookRelated (ctx , rCtx , o , & webhook ); err != nil {
3940 errs = append (errs , err )
4041 }
4142 }
4243
4344 }
4445
45- if err := gatherGenericObject (context , info , o ); err != nil {
46+ if err := gatherGenericObject (ctx , rCtx , info , o ); err != nil {
4647 errs = append (errs , err )
4748 }
4849 return errors .NewAggregate (errs )
4950}
5051
51- func gatherMutatingAdmissionWebhookRelated (context * resourceContext , o * InspectOptions , webhookConfig * admissionregistrationv1.MutatingWebhookConfiguration ) error {
52+ func gatherMutatingAdmissionWebhookRelated (ctx context. Context , rCtx * resourceContext , o * InspectOptions , webhookConfig * admissionregistrationv1.MutatingWebhookConfiguration ) error {
5253 errs := []error {}
5354 for _ , webhook := range webhookConfig .Webhooks {
5455 if webhook .ClientConfig .Service == nil {
5556 continue
5657 }
57- if err := gatherNamespaces (context , o , webhook .ClientConfig .Service .Namespace ); err != nil {
58+ if err := gatherNamespaces (ctx , rCtx , o , webhook .ClientConfig .Service .Namespace ); err != nil {
5859 errs = append (errs , err )
5960 }
6061 }
@@ -75,41 +76,41 @@ func (c *validatingWebhookConfigList) addItem(obj interface{}) error {
7576 return nil
7677}
7778
78- func gatherValidatingAdmissionWebhook (context * resourceContext , info * resource.Info , o * InspectOptions ) error {
79+ func gatherValidatingAdmissionWebhook (ctx context. Context , rCtx * resourceContext , info * resource.Info , o * InspectOptions ) error {
7980 structuredObj , err := toStructuredObject [admissionregistrationv1.ValidatingWebhookConfiguration , admissionregistrationv1.ValidatingWebhookConfigurationList ](info .Object )
8081 if err != nil {
81- return gatherGenericObject (context , info , o )
82+ return gatherGenericObject (ctx , rCtx , info , o )
8283 }
8384
8485 errs := []error {}
8586 switch castObj := structuredObj .(type ) {
8687 case * admissionregistrationv1.ValidatingWebhookConfiguration :
87- if err := gatherValidatingAdmissionWebhookRelated (context , o , castObj ); err != nil {
88+ if err := gatherValidatingAdmissionWebhookRelated (ctx , rCtx , o , castObj ); err != nil {
8889 errs = append (errs , err )
8990 }
9091
9192 case * admissionregistrationv1.ValidatingWebhookConfigurationList :
9293 for _ , webhook := range castObj .Items {
93- if err := gatherValidatingAdmissionWebhookRelated (context , o , & webhook ); err != nil {
94+ if err := gatherValidatingAdmissionWebhookRelated (ctx , rCtx , o , & webhook ); err != nil {
9495 errs = append (errs , err )
9596 }
9697 }
9798
9899 }
99100
100- if err := gatherGenericObject (context , info , o ); err != nil {
101+ if err := gatherGenericObject (ctx , rCtx , info , o ); err != nil {
101102 errs = append (errs , err )
102103 }
103104 return errors .NewAggregate (errs )
104105}
105106
106- func gatherValidatingAdmissionWebhookRelated (context * resourceContext , o * InspectOptions , webhookConfig * admissionregistrationv1.ValidatingWebhookConfiguration ) error {
107+ func gatherValidatingAdmissionWebhookRelated (ctx context. Context , rCtx * resourceContext , o * InspectOptions , webhookConfig * admissionregistrationv1.ValidatingWebhookConfiguration ) error {
107108 errs := []error {}
108109 for _ , webhook := range webhookConfig .Webhooks {
109110 if webhook .ClientConfig .Service == nil {
110111 continue
111112 }
112- if err := gatherNamespaces (context , o , webhook .ClientConfig .Service .Namespace ); err != nil {
113+ if err := gatherNamespaces (ctx , rCtx , o , webhook .ClientConfig .Service .Namespace ); err != nil {
113114 errs = append (errs , err )
114115 }
115116 }
0 commit comments