@@ -41,7 +41,7 @@ import { vsCommand } from './vscommand';
4141import { CustomResourceDefinitionStub , K8sResourceKind } from './webview/common/createServiceTypes' ;
4242import { OpenShiftTerminalManager } from './webview/openshift-terminal/openShiftTerminal' ;
4343
44- type ExplorerItem = KubernetesObject | Helm . HelmRelease | Context | TreeItem | OpenShiftObject | HelmRepo ;
44+ type ExplorerItem = KubernetesObject | Helm . HelmRelease | Context | TreeItem | OpenShiftObject | HelmRepo | PipelineTasks ;
4545
4646export type OpenShiftObject = {
4747 kind : string ,
@@ -50,9 +50,18 @@ export type OpenShiftObject = {
5050 } ,
5151}
5252
53- export interface DeploymentPodObject extends KubernetesObject {
53+ export type PipelineTasks = {
54+ name : string
55+ context : string
56+ }
57+
58+ export type task = {
59+ [ key : string ] : string
60+ }
61+
62+ export interface OtherObject extends KubernetesObject {
5463 spec ?: {
55- [ key : string ] : string
64+ tasks ?: task [ ]
5665 } ,
5766 status ?: {
5867 [ key : string ] : string
@@ -209,6 +218,16 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
209218 } ;
210219 }
211220
221+ if ( 'name' in element && 'context' in element ) {
222+ return {
223+ contextValue : 'openshift.pipeline.tasks' ,
224+ label : element . name ,
225+ tooltip : 'Task Name' ,
226+ collapsibleState : TreeItemCollapsibleState . None ,
227+ iconPath : new ThemeIcon ( 'repo' )
228+ } ;
229+ }
230+
212231 // It's a Helm installation
213232 if ( 'chart' in element ) {
214233 if ( element . chart === 'noChart' ) {
@@ -255,7 +274,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
255274 collapsibleState : TreeItemCollapsibleState . Collapsed
256275 }
257276 } else if ( element . kind === 'Pod' ) {
258- const contextElement : DeploymentPodObject = element ;
277+ const contextElement : OtherObject = element ;
259278 return {
260279 contextValue : 'openshift.k8sObject.pod' ,
261280 label : contextElement . metadata . name ,
@@ -270,7 +289,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
270289 }
271290 }
272291 }
273- const contextElement : DeploymentPodObject = element ;
292+ const contextElement : OtherObject = element ;
274293 if ( ! contextElement . spec ) {
275294 const elementValue = this . makeCaps ( element . metadata . name ) ;
276295 return {
@@ -286,15 +305,15 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
286305 }
287306 }
288307
289- private getDeploymentIconSuffix ( pods : DeploymentPodObject [ ] ) : string {
308+ private getDeploymentIconSuffix ( pods : OtherObject [ ] ) : string {
290309 // Find all not 'Running' pods
291310 const notRunning = pods . filter ( ( pod ) => pod . status && pod . status . phase !== 'Running' ) ;
292311 if ( notRunning . length === 0 ) {
293312 return '-green' ; // All running - return 'green'
294313 }
295314 // Find any 'Failed' or 'Unknown' pod - if any return error ('red')
296315 const failed = notRunning . find ( ( pod ) => pod . status &&
297- ( pod . status . phase === 'Failed' || pod . status . phase === 'Unknown' ) ) ;
316+ ( pod . status . phase === 'Failed' || pod . status . phase === 'Unknown' ) ) ;
298317 if ( failed ) {
299318 return '-red' ; // At least one failed or unknown - return 'red'
300319 }
@@ -327,7 +346,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
327346
328347 inCrashLoopBackOff = inCrashLoopBackOff || reason === 'CrashLoopBackOff' ;
329348
330- const msg = `${ reason } : ${ message ? message . trim ( ) : 'No valuable message' } ` ;
349+ const msg = `${ reason } : ${ message ? message . trim ( ) : 'No valuable message' } ` ;
331350 // Skip duplicated messages
332351 if ( messages . length < 3 && ! ( messages . find ( ( m ) => m . startsWith ( `${ reason } :` ) ) ) ) {
333352 messages . push ( msg ) ;
@@ -347,7 +366,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
347366 const messages : string [ ] = [ ] ;
348367 deployment . status . conditions ?. filter ( ( c ) => c . status === 'False' )
349368 . forEach ( ( c ) => {
350- const message = `${ c . reason } : ${ c . message ? c . message . trim ( ) : 'No valuable message' } ` ;
369+ const message = `${ c . reason } : ${ c . message ? c . message . trim ( ) : 'No valuable message' } ` ;
351370
352371 // Skip duplicated messages
353372 if ( messages . length < 3 && ! ( messages . find ( ( m ) => m . startsWith ( `${ c . reason } :` ) ) ) ) {
@@ -366,7 +385,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
366385 const availableReplicas = element . status . availableReplicas ? element . status . availableReplicas : 0 ;
367386 const unavailableReplicas = element . status . unavailableReplicas ? element . status . unavailableReplicas : 0 ;
368387
369- let pods : DeploymentPodObject [ ] = [ ] ;
388+ let pods : OtherObject [ ] = [ ] ;
370389 if ( shouldHaveReplicas ) {
371390 try {
372391 pods = await this . getPods ( element ) ;
@@ -404,24 +423,24 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
404423 ) ;
405424 }
406425 const iconSuffix = ! shouldHaveReplicas ? '' :
407- podErrors . inCrashLoopBackOff ? '-red' : this . getDeploymentIconSuffix ( pods ) ;
426+ podErrors . inCrashLoopBackOff ? '-red' : this . getDeploymentIconSuffix ( pods ) ;
408427 const iconPath = element . kind === 'Deployment' || element . kind === 'DeploymentConfig' ?
409428 imagePath ( `context/component-node${ iconSuffix } .png` ) : undefined ;
410429
411430 const routeURL = await Oc . Instance . getRouteURL ( element . metadata . name ) ;
412431 return {
413- contextValue : `openshift.k8sObject.${ element . kind } ${ routeURL ? '.route' : '' } ` ,
414- label : element . metadata . name ,
415- description,
416- tooltip,
417- collapsibleState : element . kind === 'Deployment' ? TreeItemCollapsibleState . Collapsed : TreeItemCollapsibleState . None ,
418- iconPath,
419- command : {
420- title : 'Load' ,
421- command : 'openshift.resource.load' ,
422- arguments : [ element ]
423- }
424- } ;
432+ contextValue : `openshift.k8sObject.${ element . kind } ${ routeURL ? '.route' : '' } ` ,
433+ label : element . metadata . name ,
434+ description,
435+ tooltip,
436+ collapsibleState : element . kind === 'Deployment' ? TreeItemCollapsibleState . Collapsed : TreeItemCollapsibleState . None ,
437+ iconPath,
438+ command : {
439+ title : 'Load' ,
440+ command : 'openshift.resource.load' ,
441+ arguments : [ element ]
442+ }
443+ } ;
425444 }
426445
427446 private makeCaps ( kind : string ) : string {
@@ -615,7 +634,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
615634 }
616635 } else if ( 'kind' in element ) {
617636 const collectableServices : CustomResourceDefinitionStub [ ] = await this . getServiceKinds ( ) ;
618- let collections : KubernetesObject [ ] | Helm . HelmRelease [ ] | ExplorerItem [ ] ;
637+ let collections : KubernetesObject [ ] | Helm . HelmRelease [ ] | ExplorerItem [ ] | PipelineTasks [ ] ;
619638 switch ( element . kind ) {
620639 case 'helmReleases' :
621640 collections = await Helm . getHelmReleases ( ) ;
@@ -625,10 +644,12 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
625644 } ]
626645 }
627646 break ;
647+ case 'pipelines' :
648+ collections = await this . getPipelineTasks ( element ) ;
649+ break ;
628650 default :
629651 try {
630- const namespace : string = await Oc . Instance . getActiveProject ( ) ;
631- collections = await Oc . Instance . getKubernetesObjects ( element . kind , namespace , undefined , this . executionContext ) ;
652+ collections = await Oc . Instance . getKubernetesObjects ( element . kind , undefined , undefined , this . executionContext ) ;
632653 } catch {
633654 collections = [ couldNotGetItem ( element . kind , this . kubeConfig . getCluster ( this . kubeContext . cluster ) ?. server ) ] ;
634655 }
@@ -672,6 +693,17 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
672693 return await Oc . Instance . getKubernetesObjects ( 'pods' , undefined , element . metadata . name , this . executionContext ) ;
673694 }
674695
696+ public async getPipelineTasks ( element : KubernetesObject | OpenShiftObject ) : Promise < PipelineTasks [ ] > {
697+ const namespace : string = await Oc . Instance . getActiveProject ( ) ;
698+ const collections : OtherObject [ ] = await Oc . Instance . getKubernetesObjects ( element . kind , namespace , undefined , this . executionContext ) ;
699+ const taskNames : PipelineTasks [ ] = [ ] ;
700+ const tasks = collections [ 0 ] . spec . tasks ;
701+ tasks . map ( ( task ) => {
702+ taskNames . push ( { name : task . name , context : 'pipelineTask' } ) ;
703+ } )
704+ return taskNames ;
705+ }
706+
675707 refresh ( target ?: ExplorerItem ) : void {
676708 // Create new Execution Context before refreshing
677709 if ( this . executionContext ) {
@@ -693,15 +725,15 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
693725 public static async loadResource ( component : KubernetesObject ) {
694726 if ( component ) {
695727 if ( 'chart' in component && 'name' in component && 'revision' in component
696- && 'status' in component && component . chart !== 'noChart'
697- && component . status === 'deployed' ) { // Deployed Helm Chart
728+ && 'status' in component && component . chart !== 'noChart'
729+ && component . status === 'deployed' ) { // Deployed Helm Chart
698730 const releaseName : string = typeof component . name === 'string' ? component . name : '' ;
699731 const revisionString : string | undefined = typeof component . revision === 'string' ? component . revision : undefined ;
700732 const revision = revisionString ? parseInt ( revisionString , 10 ) : undefined ;
701733 void OpenShiftExplorer . getInstance ( ) . loadKubernetesHelmChart ( releaseName , revision ) ;
702734 } else {
703735 if ( component . kind === 'Pod' ) {
704- const contextElement : DeploymentPodObject = component ;
736+ const contextElement : OtherObject = component ;
705737 const pods = await OpenShiftExplorer . getInstance ( ) . getPods ( contextElement ) ;
706738 if ( pods . length === 0 ) {
707739 contextElement . status . phase = 'Terminated'
0 commit comments