@@ -37,6 +37,7 @@ import { FileContentChangeNotifier, WatchUtil } from './util/watch';
3737import { vsCommand } from './vscommand' ;
3838import { CustomResourceDefinitionStub } from './webview/common/createServiceTypes' ;
3939import { OpenShiftTerminalManager } from './webview/openshift-terminal/openShiftTerminal' ;
40+ import { getOutputFormat , helmfsUri , kubefsUri } from './k8s/vfs/kuberesources.virtualfs' ;
4041
4142type ExplorerItem = KubernetesObject | Helm . HelmRelease | Context | TreeItem | OpenShiftObject | HelmRepo ;
4243
@@ -507,30 +508,55 @@ 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 && 'name' in component && 'revision' in component
512+ && component . chart !== 'noChart' ) { // Deployed Helm Chart
513+ const releaseName : string = typeof component . name === 'string' ? component . name : '' ;
514+ const revisionString : string | undefined = typeof component . revision === 'string' ? component . revision : undefined ;
515+ const revision = revisionString ? parseInt ( revisionString , 10 ) : undefined ;
516+ void OpenShiftExplorer . getInstance ( ) . loadKubernetesHelmChart ( releaseName , revision ) ;
517+ } else {
518+ if ( component . kind === 'Pod' ) {
519+ const contextElement : DeploymentPodObject = component ;
520+ const pods = await OpenShiftExplorer . getInstance ( ) . getPods ( contextElement ) ;
521+ if ( pods . length === 0 ) {
522+ contextElement . status . phase = 'Terminated'
523+ void OpenShiftExplorer . getInstance ( ) . refresh ( contextElement ) ;
524+ void window . showInformationMessage ( `Pod ${ contextElement . metadata . name } ${ contextElement . status . phase . toLowerCase ( ) } ` ) ;
525+ void OpenShiftExplorer . getInstance ( ) . refresh ( ) ;
526+ return ;
527+ }
519528 }
529+ void OpenShiftExplorer . getInstance ( ) . loadKubernetesCore ( component . metadata . namespace , `${ component . kind } /${ component . metadata . name } ` ) ;
520530 }
521- void OpenShiftExplorer . getInstance ( ) . loadKubernetesCore ( component . metadata . namespace , `${ component . kind } /${ component . metadata . name } ` ) ;
522531 }
523532 }
524533
525534 /**
526- * loadind deployment config
535+ * Loading deployment config
527536 * @param namespace namespace
528537 * @param value deployment name
529538 */
530539 loadKubernetesCore ( namespace : string | null , value : string ) {
531- const outputFormat = this . getOutputFormat ( ) ;
532- const uri = this . kubefsUri ( namespace , value , outputFormat ) ;
540+ const outputFormat = getOutputFormat ( ) ;
541+ const uri = kubefsUri ( namespace , value , outputFormat ) ;
542+ this . loadKubernetesDocument ( uri ) ;
543+ }
533544
545+ /**
546+ * Loading an installed Helm Chart config
547+ * @param releaseName Installed Helm Chart release name
548+ * @param revision Installed Helm Chart revision
549+ */
550+ loadKubernetesHelmChart ( releaseName : string , revision : number | undefined ) {
551+ const uri = helmfsUri ( releaseName , revision ) ;
552+ this . loadKubernetesDocument ( uri ) ;
553+ }
554+
555+ /**
556+ * Loading a Kubernates document by its Uri
557+ * @param uri A Kubernetes document Uri
558+ */
559+ loadKubernetesDocument ( uri : Uri ) {
534560 const query = this . getComparableQuery ( uri ) ;
535561 const openUri = workspace . textDocuments . map ( ( doc ) => doc . uri )
536562 . find ( ( docUri ) => {
@@ -543,41 +569,15 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
543569
544570 // If open document is found for the URI provided, we use its URI to bring its editor to the front
545571 // instead of openning a new editor
546- workspace . openTextDocument ( openUri ? openUri : uri ) . then ( ( doc ) => {
547- if ( doc ) {
548- void window . showTextDocument ( doc ) ;
549- }
550- } ,
572+ workspace . openTextDocument ( openUri ? openUri : uri ) . then (
573+ ( doc ) => {
574+ if ( doc ) {
575+ void window . showTextDocument ( doc ) ;
576+ }
577+ } ,
551578 ( err ) => window . showErrorMessage ( `Error loading document: ${ err } ` ) ) ;
552579 }
553580
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-
581581 /*
582582 * Returns the query string of the specified Uri without "nonce" param,
583583 * so the query strings can be compared.
@@ -640,7 +640,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
640640
641641 @vsCommand ( 'openshift.resource.openInConsole' )
642642 public static openInConsole ( component : KubernetesObject ) {
643- void commands . executeCommand ( 'extension.vsKubernetesLoad ' , { namespace : component . metadata . namespace , kindName : `${ component . kind } /${ component . metadata . name } ` } ) ;
643+ void commands . executeCommand ( 'openshift.resource.load ' , { namespace : component . metadata . namespace , kindName : `${ component . kind } /${ component . metadata . name } ` } ) ;
644644 }
645645
646646 @vsCommand ( 'openshift.explorer.reportIssue' )
0 commit comments