@@ -37,6 +37,7 @@ import { CustomResourceDefinitionStub } from './webview/common/createServiceType
3737import { OpenShiftTerminalManager } from './webview/openshift-terminal/openShiftTerminal' ;
3838import { LoginUtil } from './util/loginUtil' ;
3939import { PortForward } from './port-forward' ;
40+ import { getOutputFormat , helmfsUri , kubefsUri } from './k8s/vfs/kuberesources.virtualfs' ;
4041
4142type ExplorerItem = KubernetesObject | Helm . HelmRelease | Context | TreeItem | OpenShiftObject | HelmRepo ;
4243
@@ -507,30 +508,53 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
507508 @vsCommand ( 'openshift.resource.load' )
508509 public static async loadResource ( component : KubernetesObject ) {
509510 if ( component ) {
510- if ( component . kind === 'Pod' ) {
511- const contextElement : DeploymentPodObject = component ;
512- const pods = await OpenShiftExplorer . getInstance ( ) . getPods ( contextElement ) ;
513- if ( pods . length === 0 ) {
514- contextElement . status . phase = 'Terminated'
515- void OpenShiftExplorer . getInstance ( ) . refresh ( contextElement ) ;
516- void window . showInformationMessage ( `Pod ${ contextElement . metadata . name } ${ contextElement . status . phase . toLowerCase ( ) } ` ) ;
517- void OpenShiftExplorer . getInstance ( ) . refresh ( ) ;
518- return ;
511+ if ( 'chart' in component && component . chart !== 'noChart' ) { // Deployed Helm Chart
512+ const contextElement : Helm . HelmRelease = component ;
513+ const revision : number = contextElement . revision ? parseInt ( contextElement . revision ) : undefined ;
514+ void OpenShiftExplorer . getInstance ( ) . loadKubernetesHelmChart ( contextElement . name , revision ) ;
515+ } else {
516+ if ( component . kind === 'Pod' ) {
517+ const contextElement : DeploymentPodObject = component ;
518+ const pods = await OpenShiftExplorer . getInstance ( ) . getPods ( contextElement ) ;
519+ if ( pods . length === 0 ) {
520+ contextElement . status . phase = 'Terminated'
521+ void OpenShiftExplorer . getInstance ( ) . refresh ( contextElement ) ;
522+ void window . showInformationMessage ( `Pod ${ contextElement . metadata . name } ${ contextElement . status . phase . toLowerCase ( ) } ` ) ;
523+ void OpenShiftExplorer . getInstance ( ) . refresh ( ) ;
524+ return ;
525+ }
519526 }
527+ void OpenShiftExplorer . getInstance ( ) . loadKubernetesCore ( component . metadata . namespace , `${ component . kind } /${ component . metadata . name } ` ) ;
520528 }
521- void OpenShiftExplorer . getInstance ( ) . loadKubernetesCore ( component . metadata . namespace , `${ component . kind } /${ component . metadata . name } ` ) ;
522529 }
523530 }
524531
525532 /**
526- * loadind deployment config
533+ * Loading deployment config
527534 * @param namespace namespace
528535 * @param value deployment name
529536 */
530537 loadKubernetesCore ( namespace : string | null , value : string ) {
531- const outputFormat = this . getOutputFormat ( ) ;
532- const uri = this . kubefsUri ( namespace , value , outputFormat ) ;
538+ const outputFormat = getOutputFormat ( ) ;
539+ const uri = kubefsUri ( namespace , value , outputFormat ) ;
540+ this . loadKubernetesDocument ( uri ) ;
541+ }
533542
543+ /**
544+ * Loading an installed Helm Chart config
545+ * @param releaseName Installed Helm Chart release name
546+ * @param revision Installed Helm Chart revision
547+ */
548+ loadKubernetesHelmChart ( releaseName : string , revision : number | undefined ) {
549+ const uri = helmfsUri ( releaseName , revision ) ;
550+ this . loadKubernetesDocument ( uri ) ;
551+ }
552+
553+ /**
554+ * Loading a Kubernates document by its Uri
555+ * @param uri A Kubernetes document Uri
556+ */
557+ loadKubernetesDocument ( uri : Uri ) {
534558 const query = this . getComparableQuery ( uri ) ;
535559 const openUri = workspace . textDocuments . map ( ( doc ) => doc . uri )
536560 . find ( ( docUri ) => {
@@ -543,41 +567,15 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
543567
544568 // If open document is found for the URI provided, we use its URI to bring its editor to the front
545569 // instead of openning a new editor
546- workspace . openTextDocument ( openUri ? openUri : uri ) . then ( ( doc ) => {
547- if ( doc ) {
548- void window . showTextDocument ( doc ) ;
549- }
550- } ,
570+ workspace . openTextDocument ( openUri ? openUri : uri ) . then (
571+ ( doc ) => {
572+ if ( doc ) {
573+ void window . showTextDocument ( doc ) ;
574+ }
575+ } ,
551576 ( err ) => window . showErrorMessage ( `Error loading document: ${ err } ` ) ) ;
552577 }
553578
554- /**
555- * get output format from vs-kubernetes.outputFormat
556- * default yaml
557- *
558- * @returns output format
559- */
560- getOutputFormat ( ) : string {
561- if ( workspace . getConfiguration ( 'vs-kubernetes' ) . has ( 'vs-kubernetes.outputFormat' ) ) {
562- return workspace . getConfiguration ( 'vs-kubernetes' ) . get [ 'vs-kubernetes.outputFormat' ] as string ;
563- }
564- return 'yaml'
565- }
566-
567- kubefsUri ( namespace : string | null | undefined , value : string , outputFormat : string , action ?: string ) : Uri {
568- const K8S_RESOURCE_SCHEME = 'k8smsx' ;
569- const K8S_RESOURCE_SCHEME_READONLY = 'k8smsxro' ;
570- const KUBECTL_RESOURCE_AUTHORITY = 'loadkubernetescore' ;
571- const KUBECTL_DESCRIBE_AUTHORITY = 'kubernetesdescribe' ;
572- const docname = `${ value . replace ( '/' , '-' ) } ${ outputFormat && outputFormat !== '' ? `.${ outputFormat } ` : '' } ` ;
573- const nonce = new Date ( ) . getTime ( ) ;
574- const nsquery = namespace ? `ns=${ namespace } &` : '' ;
575- const scheme = action === 'describe' ? K8S_RESOURCE_SCHEME_READONLY : K8S_RESOURCE_SCHEME ;
576- const authority = action === 'describe' ? KUBECTL_DESCRIBE_AUTHORITY : KUBECTL_RESOURCE_AUTHORITY ;
577- const uri = `${ scheme } ://${ authority } /${ docname } ?${ nsquery } value=${ value } &_=${ nonce } ` ;
578- return Uri . parse ( uri ) ;
579- }
580-
581579 /*
582580 * Returns the query string of the specified Uri without "nonce" param,
583581 * so the query strings can be compared.
@@ -640,7 +638,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
640638
641639 @vsCommand ( 'openshift.resource.openInConsole' )
642640 public static openInConsole ( component : KubernetesObject ) {
643- void commands . executeCommand ( 'extension.vsKubernetesLoad ' , { namespace : component . metadata . namespace , kindName : `${ component . kind } /${ component . metadata . name } ` } ) ;
641+ void commands . executeCommand ( 'openshift.resource.load ' , { namespace : component . metadata . namespace , kindName : `${ component . kind } /${ component . metadata . name } ` } ) ;
644642 }
645643
646644 @vsCommand ( 'openshift.explorer.reportIssue' )
0 commit comments