Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rearranged the explorer view #4028

Merged
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
67 changes: 47 additions & 20 deletions src/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos

// It's a Helm installation
if ('chart' in element) {

if (element.chart === 'noChart') {
return {
label: 'No charts were installed'
};
}
return {
contextValue: 'openshift.k8sObject.helm',
label: element.name,
Expand All @@ -204,13 +210,16 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
iconPath: path.resolve(__dirname, '../../images/context/project-node.png')
}
});
} else if (element.kind === 'helm') {
} else if (element.kind === 'helmContexts') {
return {
label: 'Helm',
collapsibleState: TreeItemCollapsibleState.Collapsed
}
} else if (element.kind === 'helmRepos') {
return {
contextValue: 'openshift.helm.repos',
label: element.metadata.name,
collapsibleState: TreeItemCollapsibleState.Collapsed,
description: 'Repositories',
iconPath: path.resolve(__dirname, '../../images/context/helm.png')
collapsibleState: TreeItemCollapsibleState.Collapsed
}
} else if (element.kind === 'Pod') {
const contextElement: DeploymentPodObject = element;
Expand Down Expand Up @@ -293,12 +302,6 @@ 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 Oc.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 @@ -336,10 +339,21 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
// operator framework is not installed on cluster; do nothing
}
void commands.executeCommand('setContext', 'showCreateService', serviceKinds.length > 0);

// Add Helm Context
result.push(helmContext);
} else if ('kind' in element && element.kind === 'helm') {
} else if ('kind' in element && element.kind === 'helmContexts') {
const helmRepos = {
kind: 'helmRepos',
metadata: {
name: 'Repositories'
},
} as OpenShiftObject
const helmReleases = {
kind: 'helmReleases',
metadata: {
name: 'Releases'
},
} as OpenShiftObject
result.push(helmRepos, helmReleases);
} else if ('kind' in element && element.kind === 'helmRepos') {
const cliData = await Helm.getHelmRepos();
if (!cliData.error && !cliData.stderr) {
const helmRepos = JSON.parse(cliData.stdout) as HelmRepo[];
Expand All @@ -356,12 +370,20 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
name: 'deployments'
},
} as OpenShiftObject;
const helmReleases = {
kind: 'helmreleases',
const helmContexts = {
kind: 'helmContexts',
metadata: {
name: 'helm Releases'
name: 'helmContexts'
},
} as OpenShiftObject;
} as OpenShiftObject
const workLoads = {
kind: 'workloads',
metadata: {
name: 'workloads'
},
} as OpenShiftObject
result.push(deployments, helmContexts, workLoads);
} else if ('kind' in element && element.kind === 'workloads') {
const pods = {
kind: 'pods',
metadata: {
Expand Down Expand Up @@ -410,7 +432,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
name: 'build configs'
},
} as OpenShiftObject;
result.push(deployments, helmReleases, pods,
result.push(pods,
statefulSets, daemonSets, jobs, cronJobs);
if (isOpenshiftCluster) {
result.push(deploymentConfigs, imageStreams, buildConfigs);
Expand All @@ -419,8 +441,13 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
const collectableServices: CustomResourceDefinitionStub[] = await this.getServiceKinds();
let collections: KubernetesObject[] | Helm.HelmRelease[];
switch (element.kind) {
case 'helmreleases':
case 'helmReleases':
collections = await Helm.getHelmReleases();
if (collections.length === 0) {
collections = [{
chart: 'noChart'
}]
}
break;
default:
collections = await Oc.Instance.getKubernetesObjects(element.kind);
Expand Down
12 changes: 6 additions & 6 deletions src/helm/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { HelmRepo } from './helmChartType';
import * as HelmCommands from './helmCommands';

export type HelmRelease = {
name: string;
namespace: string;
revision: string;
updated: string;
status: string;
name?: string;
namespace?: string;
revision?: string;
updated?: string;
status?: string;
chart: string;
app_version: string;
app_version?: string;
};

/**
Expand Down
Loading