@@ -108,7 +108,7 @@ func NewCmdInspect(streams genericiooptions.IOStreams) *cobra.Command {
108
108
Run : func (c * cobra.Command , args []string ) {
109
109
kcmdutil .CheckErr (o .Complete (args ))
110
110
kcmdutil .CheckErr (o .Validate ())
111
- kcmdutil .CheckErr (o .Run ())
111
+ kcmdutil .CheckErr (o .Run (context . TODO () ))
112
112
},
113
113
}
114
114
@@ -197,7 +197,7 @@ func (o *InspectOptions) Validate() error {
197
197
return nil
198
198
}
199
199
200
- func (o * InspectOptions ) Run () error {
200
+ func (o * InspectOptions ) Run (ctx context. Context ) error {
201
201
if len (o .eventFile ) > 0 {
202
202
return createEventFilterPageFromFile (o .eventFile , o .DestDir )
203
203
}
@@ -240,7 +240,7 @@ func (o *InspectOptions) Run() error {
240
240
return err
241
241
}
242
242
243
- if err := inspectDiscovery (context . Background () , o .DestDir , discoveryClient ); err != nil {
243
+ if err := inspectDiscovery (ctx , o .DestDir , discoveryClient ); err != nil {
244
244
allErrs = append (allErrs , fmt .Errorf ("failed inspecting discovery: %w" , err ))
245
245
}
246
246
@@ -259,9 +259,9 @@ func (o *InspectOptions) Run() error {
259
259
}
260
260
261
261
// finally, gather polymorphic resources specified by the user
262
- ctx := NewResourceContext (serverResources )
262
+ rCtx := NewResourceContext (serverResources )
263
263
for _ , info := range infos {
264
- err := InspectResource (info , ctx , o )
264
+ err := InspectResource (ctx , info , rCtx , o )
265
265
if err != nil {
266
266
allErrs = append (allErrs , err )
267
267
}
@@ -281,13 +281,13 @@ func (o *InspectOptions) Run() error {
281
281
}
282
282
283
283
// 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 {
285
285
// determine if we've already collected configResourceData
286
- if ctx .visited .Has (configResourceDataKey ) {
286
+ if rCtx .visited .Has (configResourceDataKey ) {
287
287
klog .V (1 ).Infof ("Skipping previously-collected config.openshift.io resource data" )
288
288
return nil
289
289
}
290
- ctx .visited .Insert (configResourceDataKey )
290
+ rCtx .visited .Insert (configResourceDataKey )
291
291
292
292
klog .V (1 ).Infof ("Gathering config.openshift.io resource data...\n " )
293
293
@@ -303,15 +303,15 @@ func (o *InspectOptions) gatherConfigResourceData(destDir string, ctx *resourceC
303
303
304
304
errs := []error {}
305
305
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 {})
307
307
if err != nil {
308
308
errs = append (errs , err )
309
309
continue
310
310
}
311
311
312
312
objToPrint := runtime .Object (resourceList )
313
313
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 {
315
315
errs = append (errs , err )
316
316
continue
317
317
}
@@ -324,13 +324,13 @@ func (o *InspectOptions) gatherConfigResourceData(destDir string, ctx *resourceC
324
324
}
325
325
326
326
// 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 {
328
328
// determine if we've already collected operatorResourceData
329
- if ctx .visited .Has (operatorResourceDataKey ) {
329
+ if rCtx .visited .Has (operatorResourceDataKey ) {
330
330
klog .V (1 ).Infof ("Skipping previously-collected operator.openshift.io resource data" )
331
331
return nil
332
332
}
333
- ctx .visited .Insert (operatorResourceDataKey )
333
+ rCtx .visited .Insert (operatorResourceDataKey )
334
334
335
335
// ensure destination path exists
336
336
if err := os .MkdirAll (destDir , os .ModePerm ); err != nil {
@@ -344,15 +344,15 @@ func (o *InspectOptions) gatherOperatorResourceData(destDir string, ctx *resourc
344
344
345
345
errs := []error {}
346
346
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 {})
348
348
if err != nil {
349
349
errs = append (errs , err )
350
350
continue
351
351
}
352
352
353
353
objToPrint := runtime .Object (resourceList )
354
354
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 {
356
356
errs = append (errs , err )
357
357
continue
358
358
}
0 commit comments