@@ -508,36 +508,24 @@ export class KubeObject<T extends KubeObjectInterface | KubeEvent = any> {
508508 } ;
509509
510510 if ( ! resourceAttrs . resource ) {
511- resourceAttrs [ 'resource' ] = this . pluralName ;
511+ resourceAttrs [ 'resource' ] = this . apiName ;
512512 }
513513
514514 // @todo : We should get the API info from the API endpoint.
515515
516- // If we already have the group, version, and resource , then we can make the request
517- // without trying the API info, which may have several versions and thus be less optimal.
516+ // If we already have the group and version , then we can make the request without
517+ // trying the API info, which may have several versions and thus be less optimal.
518518 if ( ! ! resourceAttrs . group && ! ! resourceAttrs . version && ! ! resourceAttrs . resource ) {
519519 return this . fetchAuthorization ( resourceAttrs ) ;
520520 }
521521
522- // If we don't have the group, version, and resource , then we have to try all of the
522+ // If we don't have the group or version , then we have to try all of the
523523 // API info versions until we find one that works.
524524 const apiInfo = this . apiEndpoint . apiInfo ;
525525 for ( let i = 0 ; i < apiInfo . length ; i ++ ) {
526- const { group, version, resource } = apiInfo [ i ] ;
527- // We only take from the details from the apiInfo if they're missing from the resourceAttrs.
528- // The idea is that, since this function may also be called from the instance's getAuthorization,
529- // it may already have the details from the instance's API version.
530- const attrs = { ...resourceAttrs } ;
531-
532- if ( ! ! attrs . resource ) {
533- attrs . resource = resource ;
534- }
535- if ( ! ! attrs . group ) {
536- attrs . group = group ;
537- }
538- if ( ! ! attrs . version ) {
539- attrs . version = version ;
540- }
526+ const { group, version } = apiInfo [ i ] ;
527+ // The group and version are tied, so we take both if one is missing.
528+ const attrs = { ...resourceAttrs , group : group , version : version } ;
541529
542530 let authResult ;
543531
0 commit comments