@@ -108,7 +108,7 @@ func NewCmdInspect(streams genericiooptions.IOStreams) *cobra.Command {
108108 Run : func (c * cobra.Command , args []string ) {
109109 kcmdutil .CheckErr (o .Complete (args ))
110110 kcmdutil .CheckErr (o .Validate ())
111- kcmdutil .CheckErr (o .Run ())
111+ kcmdutil .CheckErr (o .Run (context . TODO () ))
112112 },
113113 }
114114
@@ -197,7 +197,7 @@ func (o *InspectOptions) Validate() error {
197197 return nil
198198}
199199
200- func (o * InspectOptions ) Run () error {
200+ func (o * InspectOptions ) Run (ctx context. Context ) error {
201201 if len (o .eventFile ) > 0 {
202202 return createEventFilterPageFromFile (o .eventFile , o .DestDir )
203203 }
@@ -240,7 +240,7 @@ func (o *InspectOptions) Run() error {
240240 return err
241241 }
242242
243- if err := inspectDiscovery (context . Background () , o .DestDir , discoveryClient ); err != nil {
243+ if err := inspectDiscovery (ctx , o .DestDir , discoveryClient ); err != nil {
244244 allErrs = append (allErrs , fmt .Errorf ("failed inspecting discovery: %w" , err ))
245245 }
246246
@@ -259,9 +259,9 @@ func (o *InspectOptions) Run() error {
259259 }
260260
261261 // finally, gather polymorphic resources specified by the user
262- ctx := NewResourceContext (serverResources )
262+ rCtx := NewResourceContext (serverResources )
263263 for _ , info := range infos {
264- err := InspectResource (info , ctx , o )
264+ err := InspectResource (ctx , info , rCtx , o )
265265 if err != nil {
266266 allErrs = append (allErrs , err )
267267 }
@@ -281,13 +281,13 @@ func (o *InspectOptions) Run() error {
281281}
282282
283283// gatherConfigResourceData gathers all config.openshift.io resources
284- func (o * InspectOptions ) gatherConfigResourceData (destDir string , ctx * resourceContext ) error {
284+ func (o * InspectOptions ) gatherConfigResourceData (ctx context. Context , destDir string , rCtx * resourceContext ) error {
285285 // determine if we've already collected configResourceData
286- if ctx .visited .Has (configResourceDataKey ) {
286+ if rCtx .visited .Has (configResourceDataKey ) {
287287 klog .V (1 ).Infof ("Skipping previously-collected config.openshift.io resource data" )
288288 return nil
289289 }
290- ctx .visited .Insert (configResourceDataKey )
290+ rCtx .visited .Insert (configResourceDataKey )
291291
292292 klog .V (1 ).Infof ("Gathering config.openshift.io resource data...\n " )
293293
@@ -303,15 +303,15 @@ func (o *InspectOptions) gatherConfigResourceData(destDir string, ctx *resourceC
303303
304304 errs := []error {}
305305 for _ , resource := range resources {
306- resourceList , err := o .dynamicClient .Resource (resource ).List (context . TODO () , metav1.ListOptions {})
306+ resourceList , err := o .dynamicClient .Resource (resource ).List (ctx , metav1.ListOptions {})
307307 if err != nil {
308308 errs = append (errs , err )
309309 continue
310310 }
311311
312312 objToPrint := runtime .Object (resourceList )
313313 filename := fmt .Sprintf ("%s.yaml" , resource .Resource )
314- if err := o .fileWriter .WriteFromResource (path .Join (destDir , "/" + filename ), objToPrint ); err != nil {
314+ if err := o .fileWriter .WriteFromResource (ctx , path .Join (destDir , "/" + filename ), objToPrint ); err != nil {
315315 errs = append (errs , err )
316316 continue
317317 }
@@ -324,13 +324,13 @@ func (o *InspectOptions) gatherConfigResourceData(destDir string, ctx *resourceC
324324}
325325
326326// gatherOperatorResourceData gathers all kubeapiserver.operator.openshift.io resources
327- func (o * InspectOptions ) gatherOperatorResourceData (destDir string , ctx * resourceContext ) error {
327+ func (o * InspectOptions ) gatherOperatorResourceData (ctx context. Context , destDir string , rCtx * resourceContext ) error {
328328 // determine if we've already collected operatorResourceData
329- if ctx .visited .Has (operatorResourceDataKey ) {
329+ if rCtx .visited .Has (operatorResourceDataKey ) {
330330 klog .V (1 ).Infof ("Skipping previously-collected operator.openshift.io resource data" )
331331 return nil
332332 }
333- ctx .visited .Insert (operatorResourceDataKey )
333+ rCtx .visited .Insert (operatorResourceDataKey )
334334
335335 // ensure destination path exists
336336 if err := os .MkdirAll (destDir , os .ModePerm ); err != nil {
@@ -344,15 +344,15 @@ func (o *InspectOptions) gatherOperatorResourceData(destDir string, ctx *resourc
344344
345345 errs := []error {}
346346 for _ , resource := range resources {
347- resourceList , err := o .dynamicClient .Resource (resource ).List (context . TODO () , metav1.ListOptions {})
347+ resourceList , err := o .dynamicClient .Resource (resource ).List (ctx , metav1.ListOptions {})
348348 if err != nil {
349349 errs = append (errs , err )
350350 continue
351351 }
352352
353353 objToPrint := runtime .Object (resourceList )
354354 filename := fmt .Sprintf ("%s.yaml" , resource .Resource )
355- if err := o .fileWriter .WriteFromResource (path .Join (destDir , "/" + filename ), objToPrint ); err != nil {
355+ if err := o .fileWriter .WriteFromResource (ctx , path .Join (destDir , "/" + filename ), objToPrint ); err != nil {
356356 errs = append (errs , err )
357357 continue
358358 }
0 commit comments