Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const webviews = [
'create-component',
'devfile-registry',
'helm-chart',
'helm-manage-repository',
'welcome',
'feedback',
'serverless-function',
Expand Down
99 changes: 87 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
"onCommand:clusters.openshift.deployment.openConsole",
"onCommand:clusters.openshift.imagestream.openConsole",
"onCommand:openshift.componentTypesView.registry.openInView",
"onCommand:openshift.componentTypesView.registry.openHelmChartsInView",
"onCommand:openshift.helm.openView",
"onCommand:openshift.component.deleteConfigurationFiles",
"onCommand:openshift.component.deleteSourceFolder",
"onWalkthrough:openshiftWalkthrough",
Expand Down Expand Up @@ -364,20 +364,45 @@
"category": "OpenShift"
},
{
"command": "openshift.componentTypesView.registry.openHelmChartsInView",
"title": "Open Helm Charts",
"command": "openshift.helm.openView",
"title": "Open Helm View",
"category": "OpenShift"
},
{
"command": "openshift.componentTypesView.registry.helmChart.install",
"title": "Open Helm Charts",
"command": "openshift.helm.install",
"title": "Install",
"category": "OpenShift"
},
{
"command": "openshift.componentTypesView.registry.helmChart.open",
"command": "openshift.helm.manageRepository",
"title": "Manage Repositories",
"category": "OpenShift"
},
{
"command": "openshift.helm.open",
"title": "Open Helm Charts",
"category": "OpenShift"
},
{
"command": "openshift.helm.add",
"title": "Add repository",
"category": "OpenShift"
},
{
"command": "openshift.helm.edit",
"title": "Edit repository",
"category": "OpenShift"
},
{
"command": "openshift.helm.delete",
"title": "Delete repository",
"category": "OpenShift"
},
{
"command": "openshift.helm.sync",
"title": "Sync repository",
"category": "OpenShift"
},
{
"command": "openshift.project.delete",
"title": "Delete",
Expand Down Expand Up @@ -1171,15 +1196,35 @@
"when": "false"
},
{
"command": "openshift.componentTypesView.registry.openHelmChartsInView",
"command": "openshift.helm.manageRepository",
"when": "false"
},
{
"command": "openshift.helm.openView",
"when": "false"
},
{
"command": "openshift.helm.install",
"when": "false"
},
{
"command": "openshift.helm.add",
"when": "false"
},
{
"command": "openshift.helm.open",
"when": "false"
},
{
"command": "openshift.helm.edit",
"when": "false"
},
{
"command": "openshift.componentTypesView.registry.helmChart.install",
"command": "openshift.helm.delete",
"when": "false"
},
{
"command": "openshift.componentTypesView.registry.helmChart.open",
"command": "openshift.helm.sync",
"when": "false"
},
{
Expand Down Expand Up @@ -1434,7 +1479,7 @@
],
"view/item/context/createService": [
{
"command": "openshift.componentTypesView.registry.openHelmChartsInView",
"command": "openshift.helm.openView",
"when": "view == openshiftProjectExplorer && viewItem == openshift.k8sContext && isLoggedIn",
"group": "c2"
},
Expand Down Expand Up @@ -1751,6 +1796,36 @@
"command": "openshift.component.commands.command.run",
"when": "view == openshiftComponentsView && viewItem =~ /openshift\\-component-command.*\\.dev-run.*/",
"group": "inline"
},
{
"command": "openshift.helm.add",
"when": "view == openshiftProjectExplorer && viewItem == openshift.helm.repos",
"group": "c1"
},
{
"command": "openshift.helm.manageRepository",
"when": "view == openshiftProjectExplorer && viewItem == openshift.helm.repos",
"group": "c2"
},
{
"command": "openshift.helm.openView",
"when": "view == openshiftProjectExplorer && viewItem == openshift.helm.repos",
"group": "c3"
},
{
"command": "openshift.helm.edit",
"when": "view == openshiftProjectExplorer && viewItem == openshift.helm.repo",
"group": "c1"
},
{
"command": "openshift.helm.delete",
"when": "view == openshiftProjectExplorer && viewItem == openshift.helm.repo",
"group": "c2"
},
{
"command": "openshift.helm.sync",
"when": "view == openshiftProjectExplorer && viewItem == openshift.helm.repo",
"group": "c3"
}
]
},
Expand Down Expand Up @@ -1808,13 +1883,13 @@
{
"id": "helmChart",
"title": "Work with Helm Charts",
"description": "Browse the catalog to discover and install Helm Charts.\n[Browse Helm Chart](command:openshift.componentTypesView.registry.openHelmChartsInView)",
"description": "Browse the catalog to discover and install Helm Charts.\n[Browse Helm Chart](command:openshift.helm.openView)",
"media": {
"image": "images/walkthrough/helm.gif",
"altText": "helm chart"
},
"completionEvents": [
"onCommand:openshift.componentTypesView.registry.openHelmChartsInView"
"onCommand:openshift.helm.openView"
]
},
{
Expand Down
65 changes: 53 additions & 12 deletions src/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ import { Progress } from './util/progress';
import { FileContentChangeNotifier, WatchUtil } from './util/watch';
import { vsCommand } from './vscommand';
import { CustomResourceDefinitionStub } from './webview/common/createServiceTypes';
import { HelmRepo } from './helm/helmChartType';

type ExplorerItem = KubernetesObject | Helm.HelmRelease | Context | TreeItem;
type ExplorerItem = KubernetesObject | Helm.HelmRelease | Context | TreeItem | OpenShiftObject | HelmRepo;

export type OpenShiftObject = {
kind: string,
metadata: {
name: string
},
}

type PackageJSON = {
version: string;
bugs: string;
version: string;
bugs: string;
};

const CREATE_OR_SET_PROJECT_ITEM = {
Expand Down Expand Up @@ -108,8 +116,8 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
return element;
}

if('label' in element) {
return {
if ('label' in element) {
return {
contextValue: 'openshift.openConfigFile',
label: element.label,
collapsibleState: TreeItemCollapsibleState.None,
Expand All @@ -122,14 +130,24 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
// check if element is Context instance
if ('name' in element && 'cluster' in element && 'user' in element) { // Context instance could be without namespace
void commands.executeCommand('setContext', 'isLoggedIn', true);
return {
return {
contextValue: 'openshift.k8sContext',
label: this.kubeConfig.getCluster(element.cluster).server,
collapsibleState: TreeItemCollapsibleState.Collapsed,
iconPath: path.resolve(__dirname, '../../images/context/cluster-node.png')
};
}

if ('name' in element && 'url' in element) {
return {
contextValue: 'openshift.helm.repo',
label: element.name,
tooltip: element.url,
collapsibleState: TreeItemCollapsibleState.None,
iconPath: new ThemeIcon('repo')
};
}

// It's a Helm installation
if ('chart' in element) {
return {
Expand All @@ -150,6 +168,14 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
collapsibleState: TreeItemCollapsibleState.Collapsed,
iconPath: path.resolve(__dirname, '../../images/context/project-node.png')
}
} else if (element.kind === 'helm') {
return {
contextValue: 'openshift.helm.repos',
label: element.metadata.name,
collapsibleState: TreeItemCollapsibleState.Collapsed,
description: 'Repositories',
iconPath: path.resolve(__dirname, '../../images/context/helm.png')
}
}
return {
contextValue: 'openshift.k8sObject',
Expand Down Expand Up @@ -181,7 +207,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
const config = getKubeConfigFiles();
const canCreateNamespace = await Oc.Instance.canCreateNamespace();
void commands.executeCommand('setContext', 'canCreateNamespace', canCreateNamespace);
result.unshift({label: process.env.KUBECONFIG ? 'Custom KubeConfig' : 'Default KubeConfig', description: config.join(':')})
result.unshift({ label: process.env.KUBECONFIG ? 'Custom KubeConfig' : 'Default KubeConfig', description: config.join(':') })
}
} catch (err) {
// ignore because ether server is not accessible or user is logged out
Expand All @@ -198,6 +224,12 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
// (3) there is namespace set in context and namespace exists in the cluster
// (4) there is namespace set in context and namespace does not exist in the cluster
const namespaces = await Odo.Instance.getProjects();
const helmContext = {
kind: 'helm',
metadata: {
name: 'Helm'
},
} as OpenShiftObject
if (this.kubeContext.namespace) {
if (namespaces.find(item => item.name === this.kubeContext.namespace)) {
result = [{
Expand Down Expand Up @@ -226,8 +258,16 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
result = [CREATE_OR_SET_PROJECT_ITEM]
}
}
result.push(helmContext);
} else if ('kind' in element && element.kind === 'helm') {
const cliData = await Helm.getHelmRepos();
if (!cliData.error && !cliData.stderr) {
const helmRepos = JSON.parse(cliData.stdout) as HelmRepo[];
if (helmRepos?.length > 0) {
result = [...helmRepos.sort(Helm.ascRepoName)];
}
}
} else {

let serviceKinds: CustomResourceDefinitionStub[] = [];
try {
serviceKinds = await getServiceKindStubs();
Expand All @@ -249,6 +289,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
result = await Promise.all(toCollect).then(listOfLists => listOfLists.flatMap(a => a as ExplorerItem[]));

}

// don't show Open In Developer Dashboard if not openshift cluster
const isOpenshiftCluster = await Oc.Instance.isOpenShiftCluster();
void commands.executeCommand('setContext', 'isOpenshiftCluster', isOpenshiftCluster);
Expand All @@ -272,7 +313,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos

@vsCommand('openshift.resource.load')
public static loadResource(component: KubernetesObject) {
void commands.executeCommand('extension.vsKubernetesLoad', {namespace: component.metadata.namespace, kindName: `${component.kind}/${component.metadata.name}`});
void commands.executeCommand('extension.vsKubernetesLoad', { namespace: component.metadata.namespace, kindName: `${component.kind}/${component.metadata.name}` });
}

@vsCommand('openshift.resource.unInstall')
Expand All @@ -285,13 +326,13 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos

@vsCommand('openshift.resource.openInConsole')
public static openInConsole(component: KubernetesObject) {
void commands.executeCommand('extension.vsKubernetesLoad', {namespace: component.metadata.namespace, kindName: `${component.kind}/${component.metadata.name}`});
void commands.executeCommand('extension.vsKubernetesLoad', { namespace: component.metadata.namespace, kindName: `${component.kind}/${component.metadata.name}` });
}

@vsCommand('openshift.explorer.reportIssue')
static async reportIssue(): Promise<unknown> {
const extensionPath = path.resolve(__dirname, '..', '..');
const templatePath = path.join(extensionPath,'resources', 'issueReport.md');
const templatePath = path.join(extensionPath, 'resources', 'issueReport.md');
const template = fs.readFileSync(templatePath, 'utf-8');
return commands.executeCommand('workbench.action.openIssueReporter', {
extensionId: 'redhat.vscode-openshift-connector',
Expand All @@ -301,7 +342,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos

@vsCommand('openshift.open.configFile')
async openConfigFile(context: TreeItem): Promise<void> {
if(context.description && typeof context.description === 'string'){
if (context.description && typeof context.description === 'string') {
await commands.executeCommand('vscode.open', Uri.file(context.description));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export async function activate(extensionContext: ExtensionContext): Promise<unkn
'./componentsView',
'./webview/devfile-registry/registryViewLoader',
'./webview/helm-chart/helmChartLoader',
'./webview/helm-manage-repository/manageRepositoryLoader',
'./feedback'
)),
commands.registerCommand('clusters.openshift.useProject', (context) =>
Expand Down
Loading