@@ -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,51 @@ 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+ void OpenShiftExplorer . getInstance ( ) . loadKubernetesHelmChart ( component . name , component . revision ) ;
513+ } else {
514+ if ( component . kind === 'Pod' ) {
515+ const contextElement : DeploymentPodObject = component ;
516+ const pods = await OpenShiftExplorer . getInstance ( ) . getPods ( contextElement ) ;
517+ if ( pods . length === 0 ) {
518+ contextElement . status . phase = 'Terminated'
519+ void OpenShiftExplorer . getInstance ( ) . refresh ( contextElement ) ;
520+ void window . showInformationMessage ( `Pod ${ contextElement . metadata . name } ${ contextElement . status . phase . toLowerCase ( ) } ` ) ;
521+ void OpenShiftExplorer . getInstance ( ) . refresh ( ) ;
522+ return ;
523+ }
519524 }
525+ void OpenShiftExplorer . getInstance ( ) . loadKubernetesCore ( component . metadata . namespace , `${ component . kind } /${ component . metadata . name } ` ) ;
520526 }
521- void OpenShiftExplorer . getInstance ( ) . loadKubernetesCore ( component . metadata . namespace , `${ component . kind } /${ component . metadata . name } ` ) ;
522527 }
523528 }
524529
525530 /**
526- * loadind deployment config
531+ * Loading deployment config
527532 * @param namespace namespace
528533 * @param value deployment name
529534 */
530535 loadKubernetesCore ( namespace : string | null , value : string ) {
531- const outputFormat = this . getOutputFormat ( ) ;
532- const uri = this . kubefsUri ( namespace , value , outputFormat ) ;
536+ const outputFormat = getOutputFormat ( ) ;
537+ const uri = kubefsUri ( namespace , value , outputFormat ) ;
538+ this . loadKubernetesDocument ( uri ) ;
539+ }
533540
541+ /**
542+ * Loading an installed Helm Chart config
543+ * @param releaseName Installed Helm Chart release name
544+ * @param revision Installed Helm Chart revision
545+ */
546+ loadKubernetesHelmChart ( releaseName : string , revision : number | undefined ) {
547+ const uri = helmfsUri ( releaseName , revision ) ;
548+ this . loadKubernetesDocument ( uri ) ;
549+ }
550+
551+ /**
552+ * Loading a Kubernates document by its Uri
553+ * @param uri A Kubernetes document Uri
554+ */
555+ loadKubernetesDocument ( uri : Uri ) {
534556 const query = this . getComparableQuery ( uri ) ;
535557 const openUri = workspace . textDocuments . map ( ( doc ) => doc . uri )
536558 . find ( ( docUri ) => {
@@ -543,41 +565,15 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
543565
544566 // If open document is found for the URI provided, we use its URI to bring its editor to the front
545567 // instead of openning a new editor
546- workspace . openTextDocument ( openUri ? openUri : uri ) . then ( ( doc ) => {
547- if ( doc ) {
548- void window . showTextDocument ( doc ) ;
549- }
550- } ,
568+ workspace . openTextDocument ( openUri ? openUri : uri ) . then (
569+ ( doc ) => {
570+ if ( doc ) {
571+ void window . showTextDocument ( doc ) ;
572+ }
573+ } ,
551574 ( err ) => window . showErrorMessage ( `Error loading document: ${ err } ` ) ) ;
552575 }
553576
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-
581577 /*
582578 * Returns the query string of the specified Uri without "nonce" param,
583579 * so the query strings can be compared.
@@ -640,7 +636,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
640636
641637 @vsCommand ( 'openshift.resource.openInConsole' )
642638 public static openInConsole ( component : KubernetesObject ) {
643- void commands . executeCommand ( 'extension.vsKubernetesLoad ' , { namespace : component . metadata . namespace , kindName : `${ component . kind } /${ component . metadata . name } ` } ) ;
639+ void commands . executeCommand ( 'openshift.resource.load ' , { namespace : component . metadata . namespace , kindName : `${ component . kind } /${ component . metadata . name } ` } ) ;
644640 }
645641
646642 @vsCommand ( 'openshift.explorer.reportIssue' )
0 commit comments