Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
feat(plugin): Update resource monitor plug-in to latest devfile 2 API
Browse files Browse the repository at this point in the history
Change-Id: Ia532b973e081ae9801cd28008521bd07db9411fa
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
  • Loading branch information
benoitf committed Mar 5, 2021
1 parent 25acc46 commit b3dd619
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
* Copyright (c) 2020-2021 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -16,6 +16,6 @@
* @author Valerii Svydenko
*/
const che: any = {};
che.workspace = {};
che.devfile = {};
che.k8s = {};
module.exports = che;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (c) 2018-2020 Red Hat, Inc.
* Copyright (c) 2018-2021 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -193,6 +193,6 @@ export class ResMon {
}

export async function getNamespace(): Promise<string> {
const workspace = await che.workspace.getCurrentWorkspace();
return workspace.attributes ? workspace.attributes.infrastructureNamespace : '';
const devfile = await che.devfile.get();
return devfile.attributes ? devfile.attributes.infrastructureNamespace : '';
}
11 changes: 5 additions & 6 deletions plugins/resource-monitor-plugin/tests/resource-monitor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (c) 2020 Red Hat, Inc.
* Copyright (c) 2020-2021 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -20,10 +20,9 @@ import * as theia from '@theia/plugin';
import { Container } from '../src/objects';
import { ResMon } from '../src/resource-monitor-plugin';
import { SHOW_WARNING_MESSAGE_COMMAND } from '../src/constants';
import { che as cheApi } from '@eclipse-che/api';

describe('Test Resource Monitor Plugin', () => {
const getCurrentWorkspace = jest.fn();
const devfileMock = jest.fn();
const sendRawQuery = jest.fn();
const createStatusBar = jest.fn();
process.env.HOSTNAME = 'workspace';
Expand Down Expand Up @@ -75,12 +74,12 @@ describe('Test Resource Monitor Plugin', () => {
che.k8s.sendRawQuery = sendRawQuery;

// Prepare Namespace
che.workspace.getCurrentWorkspace = getCurrentWorkspace;
che.devfile.get = devfileMock;
const attributes = { infrastructureNamespace: 'che-namespace' };
const workspace: cheApi.workspace.Workspace = {
const devfile = {
attributes,
};
getCurrentWorkspace.mockReturnValue(workspace);
devfileMock.mockReturnValue(devfile);

// Prepare StatusBarItem
theia.window.createStatusBarItem = createStatusBar;
Expand Down

0 comments on commit b3dd619

Please sign in to comment.