@@ -246,7 +246,7 @@ export default class MyPlugin implements octant.Plugin {
246246 return handler . call ( this , Object . assign ( { } , params , request ) ) ;
247247 } catch ( e ) {
248248 // TODO handle errors other than not found
249- console . error ( `Error rendering Knative plugin content path "${ contentPath } ": ${ JSON . stringify ( e ) } ` ) ;
249+ console . error ( `Error rendering Knative plugin content path "${ contentPath } ": ` , e ) ;
250250 return notFoundContentResponse ( { contentPath } ) ;
251251 }
252252 }
@@ -347,13 +347,21 @@ export default class MyPlugin implements octant.Plugin {
347347
348348 serviceDetailHandler ( params : any ) : octant . ContentResponse {
349349 const name : string = params . serviceName ;
350+ const service : Service = this . dashboardClient . Get ( {
351+ apiVersion : ServingV1 ,
352+ kind : ServingV1Service ,
353+ namespace : this . namespace ,
354+ name : name ,
355+ } ) ;
350356 const title = [
351357 new LinkFactory ( { value : "Knative" , ref : "/knative" } ) ,
352358 new LinkFactory ( { value : "Serving" , ref : this . linker ( { apiVersion : ServingV1 } ) } ) ,
353359 new LinkFactory ( { value : "Services" , ref : this . linker ( { apiVersion : ServingV1 , kind : ServingV1Service } ) } ) ,
354360 new TextFactory ( { value : name } ) ,
355361 ] ;
356- const body = this . serviceDetail ( name ) ;
362+ const body = this . serviceDetail ( service ) ;
363+ const controlledBy = service . metadata . ownerReferences ?. find ( r => r . controller ) ;
364+ const controlledByMessage = controlledBy ? `This resource is controlled by *${ controlledBy . kind } * **${ controlledBy . name } **, deleting it may not have the intended effect.\n\n` : '' ;
357365 const buttonGroup = new ButtonGroupFactory ( {
358366 buttons : [
359367 {
@@ -367,7 +375,7 @@ export default class MyPlugin implements octant.Plugin {
367375 } ,
368376 confirmation : {
369377 title : "Delete Service" ,
370- body : `Are you sure you want to delete *Service* **${ name } **? This action is permanent and cannot be recovered.` ,
378+ body : `${ controlledByMessage } Are you sure you want to delete *Service* **${ name } **? This action is permanent and cannot be recovered.` ,
371379 } ,
372380 } ,
373381 ] ,
@@ -396,13 +404,21 @@ export default class MyPlugin implements octant.Plugin {
396404
397405 configurationDetailHandler ( params : any ) : octant . ContentResponse {
398406 const name : string = params . configurationName ;
407+ const configuration : Configuration = this . dashboardClient . Get ( {
408+ apiVersion : ServingV1 ,
409+ kind : ServingV1Configuration ,
410+ namespace : this . namespace ,
411+ name : name ,
412+ } ) ;
399413 const title = [
400414 new LinkFactory ( { value : "Knative" , ref : "/knative" } ) ,
401415 new LinkFactory ( { value : "Serving" , ref : this . linker ( { apiVersion : ServingV1 } ) } ) ,
402416 new LinkFactory ( { value : "Configurations" , ref : this . linker ( { apiVersion : ServingV1 , kind : ServingV1Configuration } ) } ) ,
403417 new TextFactory ( { value : name } ) ,
404418 ] ;
405- const body = this . configurationDetail ( name ) ;
419+ const body = this . configurationDetail ( configuration ) ;
420+ const controlledBy = configuration . metadata . ownerReferences ?. find ( r => r . controller ) ;
421+ const controlledByMessage = controlledBy ? `This resource is controlled by *${ controlledBy . kind } * **${ controlledBy . name } **, deleting it may not have the intended effect.\n\n` : '' ;
406422 const buttonGroup = new ButtonGroupFactory ( {
407423 buttons : [
408424 {
@@ -416,7 +432,7 @@ export default class MyPlugin implements octant.Plugin {
416432 } ,
417433 confirmation : {
418434 title : "Delete Configuration" ,
419- body : `Are you sure you want to delete *Configuration* **${ name } **? This action is permanent and cannot be recovered.` ,
435+ body : `${ controlledByMessage } Are you sure you want to delete *Configuration* **${ name } **? This action is permanent and cannot be recovered.` ,
420436 } ,
421437 } ,
422438 ] ,
@@ -441,6 +457,12 @@ export default class MyPlugin implements octant.Plugin {
441457
442458 revisionDetailHandler ( params : any ) : octant . ContentResponse {
443459 const name : string = params . revisionName ;
460+ const revision : Revision = this . dashboardClient . Get ( {
461+ apiVersion : ServingV1 ,
462+ kind : ServingV1Revision ,
463+ namespace : this . namespace ,
464+ name : name ,
465+ } ) ;
444466 const title = [ ] ;
445467 if ( params . serviceName ) {
446468 title . push (
@@ -462,7 +484,9 @@ export default class MyPlugin implements octant.Plugin {
462484 ) ;
463485 }
464486
465- const body = this . revisionDetail ( name ) ;
487+ const body = this . revisionDetail ( revision ) ;
488+ const controlledBy = revision . metadata . ownerReferences ?. find ( r => r . controller ) ;
489+ const controlledByMessage = controlledBy ? `This resource is controlled by *${ controlledBy . kind } * **${ controlledBy . name } **, deleting it may not have the intended effect.\n\n` : '' ;
466490 const buttonGroup = new ButtonGroupFactory ( {
467491 buttons : [
468492 {
@@ -476,7 +500,7 @@ export default class MyPlugin implements octant.Plugin {
476500 } ,
477501 confirmation : {
478502 title : "Delete Revision" ,
479- body : `Are you sure you want to delete *Revision* **${ name } **? This action is permanent and cannot be recovered.` ,
503+ body : `${ controlledByMessage } Are you sure you want to delete *Revision* **${ name } **? This action is permanent and cannot be recovered.` ,
480504 } ,
481505 } ,
482506 ] ,
@@ -505,13 +529,21 @@ export default class MyPlugin implements octant.Plugin {
505529
506530 routeDetailHandler ( params : any ) : octant . ContentResponse {
507531 const name : string = params . routeName ;
532+ const route : Route = this . dashboardClient . Get ( {
533+ apiVersion : ServingV1 ,
534+ kind : ServingV1Route ,
535+ namespace : this . namespace ,
536+ name : name ,
537+ } ) ;
508538 const title = [
509539 new LinkFactory ( { value : "Knative" , ref : "/knative" } ) ,
510540 new LinkFactory ( { value : "Serving" , ref : this . linker ( { apiVersion : ServingV1 } ) } ) ,
511541 new LinkFactory ( { value : "Routes" , ref : this . linker ( { apiVersion : ServingV1 , kind : ServingV1Route } ) } ) ,
512542 new TextFactory ( { value : name } ) ,
513543 ] ;
514- const body = this . routeDetail ( name ) ;
544+ const body = this . routeDetail ( route ) ;
545+ const controlledBy = route . metadata . ownerReferences ?. find ( r => r . controller ) ;
546+ const controlledByMessage = controlledBy ? `This resource is controlled by *${ controlledBy . kind } * **${ controlledBy . name } **, deleting it may not have the intended effect.\n\n` : '' ;
515547 const buttonGroup = new ButtonGroupFactory ( {
516548 buttons : [
517549 {
@@ -525,7 +557,7 @@ export default class MyPlugin implements octant.Plugin {
525557 } ,
526558 confirmation : {
527559 title : "Delete Route" ,
528- body : `Are you sure you want to delete *Route* **${ name } **? This action is permanent and cannot be recovered.` ,
560+ body : `${ controlledByMessage } Are you sure you want to delete *Route* **${ name } **? This action is permanent and cannot be recovered.` ,
529561 } ,
530562 } ,
531563 ] ,
@@ -564,13 +596,7 @@ export default class MyPlugin implements octant.Plugin {
564596 return [ form ] ;
565597 }
566598
567- serviceDetail ( name : string ) : ComponentFactory < any > [ ] {
568- const service : Service = this . dashboardClient . Get ( {
569- apiVersion : ServingV1 ,
570- kind : ServingV1Service ,
571- namespace : this . namespace ,
572- name : name ,
573- } ) ;
599+ serviceDetail ( service : Service ) : ComponentFactory < any > [ ] {
574600 const routes : Route [ ] = this . dashboardClient . List ( {
575601 apiVersion : ServingV1 ,
576602 kind : ServingV1Route ,
@@ -683,13 +709,7 @@ export default class MyPlugin implements octant.Plugin {
683709 return new ConfigurationListFactory ( { configurations, linker : this . linker , factoryMetadata } ) ;
684710 }
685711
686- configurationDetail ( name : string ) : ComponentFactory < any > [ ] {
687- const configuration : Configuration = this . dashboardClient . Get ( {
688- apiVersion : ServingV1 ,
689- kind : ServingV1Configuration ,
690- namespace : this . namespace ,
691- name : name ,
692- } ) ;
712+ configurationDetail ( configuration : Configuration ) : ComponentFactory < any > [ ] {
693713 const revisions : Revision [ ] = this . dashboardClient . List ( {
694714 apiVersion : ServingV1 ,
695715 kind : ServingV1Revision ,
@@ -763,13 +783,7 @@ export default class MyPlugin implements octant.Plugin {
763783 ] ;
764784 }
765785
766- revisionDetail ( name : string ) : ComponentFactory < any > [ ] {
767- const revision : Revision = this . dashboardClient . Get ( {
768- apiVersion : ServingV1 ,
769- kind : ServingV1Revision ,
770- namespace : this . namespace ,
771- name : name ,
772- } ) ;
786+ revisionDetail ( revision : Revision ) : ComponentFactory < any > [ ] {
773787 const childDeployment : V1Deployment | undefined = this . dashboardClient . List ( {
774788 apiVersion : 'apps/v1' ,
775789 kind : 'Deployment' ,
@@ -785,7 +799,7 @@ export default class MyPlugin implements octant.Plugin {
785799 kind : 'Pod' ,
786800 namespace : this . namespace ,
787801 selector : {
788- 'serving.knative.dev/revision' : name ,
802+ 'serving.knative.dev/revision' : revision . metadata . name || '_' ,
789803 } ,
790804 } ) ;
791805 pods . sort ( ( a , b ) => ( a . metadata ?. name || '' ) . localeCompare ( b . metadata ?. name || '' ) ) ;
@@ -838,14 +852,7 @@ export default class MyPlugin implements octant.Plugin {
838852 return new RouteListFactory ( { routes, linker : this . linker , factoryMetadata } ) ;
839853 }
840854
841- routeDetail ( name : string ) : ComponentFactory < any > [ ] {
842- const route : Route = this . dashboardClient . Get ( {
843- apiVersion : ServingV1 ,
844- kind : ServingV1Route ,
845- namespace : this . namespace ,
846- name : name ,
847- } ) ;
848-
855+ routeDetail ( route : Route ) : ComponentFactory < any > [ ] {
849856 return [
850857 new RouteSummaryFactory ( {
851858 route,
0 commit comments