Skip to content
Closed
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
17 changes: 8 additions & 9 deletions src/k8s/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import * as vscode from 'vscode';
import { Command } from "../odo";
import { KubeConfigUtils } from "../util/kubeUtils";
import open = require("open");
import { OpenShiftItem } from '../openshift/openshiftItem';

const k8sConfig = new KubeConfigUtils();
Expand Down Expand Up @@ -39,9 +38,9 @@ export class Console extends OpenShiftItem {
}
const consoleUrl = await Console.fetchOpenshiftConsoleUrl();
if (await Console.fetchClusterVersion() === null) {
return await open(`${consoleUrl}/k8s/ns/${context.id}/buildconfigs`);
return await vscode.env.openExternal(vscode.Uri.parse(`${consoleUrl}/k8s/ns/${context.id}/buildconfigs`));
} else {
return await open(`${clusterUrl}/console/project/${project}/browse/builds/${context.id}?tab=history`);
return await vscode.env.openExternal(vscode.Uri.parse(`${clusterUrl}/console/project/${project}/browse/builds/${context.id}?tab=history`));
}
}

Expand All @@ -52,9 +51,9 @@ export class Console extends OpenShiftItem {
}
const consoleUrl = await Console.fetchOpenshiftConsoleUrl();
if (await Console.fetchClusterVersion() === null) {
return await open(`${consoleUrl}/k8s/ns/${context.id}/deploymentconfigs`);
return await vscode.env.openExternal(vscode.Uri.parse(`${consoleUrl}/k8s/ns/${context.id}/deploymentconfigs`));
} else {
return await open(`${clusterUrl}/console/project/${project}/browse/dc/${context.id}?tab=history`);
return await vscode.env.openExternal(vscode.Uri.parse(`${clusterUrl}/console/project/${project}/browse/dc/${context.id}?tab=history`));
}
}

Expand All @@ -65,9 +64,9 @@ export class Console extends OpenShiftItem {
}
const consoleUrl = await this.fetchOpenshiftConsoleUrl();
if (await Console.fetchClusterVersion() === null) {
return await open(`${consoleUrl}/k8s/ns/${context.id}/imagestreams`);
return await vscode.env.openExternal(vscode.Uri.parse(`${consoleUrl}/k8s/ns/${context.id}/imagestreams`));
} else {
return await open(`${clusterUrl}/console/project/${project}/browse/images/${context.id}?tab=history`);
return await vscode.env.openExternal(vscode.Uri.parse(`${clusterUrl}/console/project/${project}/browse/images/${context.id}?tab=history`));
}
}

Expand All @@ -78,9 +77,9 @@ export class Console extends OpenShiftItem {
}
const consoleUrl = await Console.fetchOpenshiftConsoleUrl();
if (await Console.fetchClusterVersion() === null) {
return await open(`${consoleUrl}/overview/ns/${context.id}`);
return await vscode.env.openExternal(vscode.Uri.parse(`${consoleUrl}/overview/ns/${context.id}`));
} else {
return await open(`${consoleUrl}/console/project/${context.id}/overview`);
return await vscode.env.openExternal(vscode.Uri.parse(`${consoleUrl}/console/project/${context.id}/overview`));
}
}
}
16 changes: 13 additions & 3 deletions src/odo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@
*-----------------------------------------------------------------------------------------------*/

import * as cliInstance from './cli';
import { ProviderResult, TreeItemCollapsibleState, window, Terminal, Uri, commands, QuickPickItem, workspace, WorkspaceFoldersChangeEvent, WorkspaceFolder, Disposable } from 'vscode';
import { ProviderResult,
TreeItemCollapsibleState,
window,
Terminal,
Uri,
commands,
QuickPickItem,
workspace,
WorkspaceFoldersChangeEvent,
WorkspaceFolder,
Disposable,
env } from 'vscode';
import { WindowUtil } from './util/windowUtils';
import { CliExitData } from './cli';
import * as path from 'path';
Expand All @@ -19,7 +30,6 @@ import * as odo from './odo/config';
import { ComponentSettings } from './odo/config';
import { GlyphChars } from './util/constants';
import { Subject } from 'rxjs';
import open = require('open');
import { Progress } from './util/progress';
import { V1ServicePort, V1Service } from '@kubernetes/client-node';

Expand Down Expand Up @@ -1134,7 +1144,7 @@ export class OdoImpl implements Odo {
if (projectsToMigrate.length > 0) {
const choice = await window.showWarningMessage(`Some of the resources in cluster must be updated to work with latest release of OpenShift Connector Extension.`, 'Update', 'Don\'t check again', 'Help', 'Cancel');
if (choice === 'Help') {
open('https://github.com/redhat-developer/vscode-openshift-tools/wiki/Migration-to-v0.1.0');
env.openExternal(Uri.parse('https://github.com/redhat-developer/vscode-openshift-tools/wiki/Migration-to-v0.1.0'));
this.subject.next(new OdoEventImpl('changed', this.getClusters()[0]));
} else if (choice === 'Don\'t check again') {
workspace.getConfiguration("openshiftConnector").update("disableCheckForMigration", true, true);
Expand Down
5 changes: 2 additions & 3 deletions src/openshift/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import { Command } from "../odo";
import { OpenShiftItem } from './openshiftItem';
import { window, commands, env, QuickPickItem, ExtensionContext } from 'vscode';
import { window, commands, env, QuickPickItem, ExtensionContext, Uri } from 'vscode';
import { CliExitData, Cli } from "../cli";
import open = require("open");
import { TokenStore } from "../util/credentialManager";
import { KubeConfigUtils } from '../util/kubeUtils';
import { Filters } from "../util/filters";
Expand Down Expand Up @@ -69,7 +68,7 @@ export class Cluster extends OpenShiftItem {
const serverUrl = await Cluster.odo.execute(Command.showServerUrl());
consoleUrl = `${serverUrl.stdout}/console`;
}
open(consoleUrl);
env.openExternal(Uri.parse(consoleUrl));
}

static async switchContext() {
Expand Down
11 changes: 6 additions & 5 deletions src/openshift/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import { OpenShiftItem } from './openshiftItem';
import { OpenShiftObject, Command, ContextType, ComponentType } from '../odo';
import { window, commands, QuickPickItem, Uri, workspace, ExtensionContext } from 'vscode';
import { window, commands, QuickPickItem, Uri, workspace, ExtensionContext, env } from 'vscode';
import { Progress } from '../util/progress';
import open = require('open');
import { ChildProcess } from 'child_process';
import { CliExitData } from '../cli';
import { isURL } from 'validator';
Expand Down Expand Up @@ -294,7 +293,7 @@ export class Component extends OpenShiftItem {
await Component.undeploy(component);
return null;
case 'Help':
open('https://github.com/redhat-developer/vscode-openshift-tools/wiki/Migration-to-v0.1.0');
env.openExternal(Uri.parse('https://github.com/redhat-developer/vscode-openshift-tools/wiki/Migration-to-v0.1.0'));
break;
case 'Cancel':
return null;
Expand Down Expand Up @@ -352,9 +351,11 @@ export class Component extends OpenShiftItem {
if (hostName.length >1) {
selectRoute = await window.showQuickPick(hostName, {placeHolder: "This Component has multiple URLs. Select the desired URL to open in browser."});
if (!selectRoute) return null;
return open(`${selectRoute.label}`);
env.openExternal(Uri.parse(`${selectRoute.label}`));
return;
} else {
return open(`${hostName[0].label}`);
env.openExternal(Uri.parse(`${hostName[0].label}`));
return;
}
} else if (unpushedUrl.length > 0) {
return `${unpushedUrl.length} unpushed URL in the local config. Use \'Push\' command before opening URL in browser.`;
Expand Down
5 changes: 2 additions & 3 deletions src/openshift/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
*-----------------------------------------------------------------------------------------------*/

import { OpenShiftObject, Command } from '../odo';
import { window, QuickPickItem } from 'vscode';
import { window, QuickPickItem, env, Uri } from 'vscode';
import { V1ServicePort } from '@kubernetes/client-node';
import { OpenShiftItem } from './openshiftItem';
import { Progress } from "../util/progress";
import open = require('open');
import { ChildProcess } from 'child_process';

export class Url extends OpenShiftItem{
Expand Down Expand Up @@ -80,7 +79,7 @@ export class Url extends OpenShiftItem{
urlObject = result.filter((value) => (value.metadata.name === treeItem.getName()));
}
if (urlObject[0].status.state === 'Pushed') {
open(`${urlObject[0].spec.protocol}://${urlObject[0].spec.host}`);
env.openExternal(Uri.parse(`${urlObject[0].spec.protocol}://${urlObject[0].spec.host}`));
} else {
window.showInformationMessage('Selected URL is not created in cluster. Use \'Push\' command before opening URL in browser.');
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import { Archive } from "./util/archive";
import { which } from "shelljs";
import { DownloadUtil } from "./util/download";
import hasha = require("hasha");
import open = require("open");
import * as vscode from 'vscode';
import * as path from 'path';
import * as fsex from 'fs-extra';
import * as fs from 'fs';
import { Cli } from './cli';
import semver = require('semver');
import configData = require('./tools.json');
import { env, Uri } from "vscode";

export class ToolsConfig {

Expand Down Expand Up @@ -94,7 +94,7 @@ export class ToolsConfig {
toolLocation = toolCacheLocation;
}
} else if (response === `Help`) {
open('https://github.com/redhat-developer/vscode-openshift-tools#dependencies');
env.openExternal(Uri.parse('https://github.com/redhat-developer/vscode-openshift-tools#dependencies'));
}
}
if (toolLocation) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/openshift/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,13 @@ suite('Openshift/Cluster', () => {

test('opens URL from cluster\'s tree item label if called from cluster\'s context menu', () => {
clusterMock.openshiftConsole(cluster);
openStub.calledOnceWith('http://localhost');
openStub.calledOnceWith(vscode.Uri.parse('http://localhost'));
});

test('opens URL from first cluster label', () => {
sandbox.stub(OdoImpl.prototype, 'getClusters').resolves([cluster]);
clusterMock.openshiftConsole();
openStub.calledOnceWith('http://localhost');
openStub.calledOnceWith(vscode.Uri.parse('http://localhost'));
});

test('shows error message if node label is not URL', () => {
Expand Down
8 changes: 4 additions & 4 deletions test/unit/openshift/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ suite('OpenShift/Component', () => {
showWarningMessageStub.onSecondCall().resolves(undefined);
const result = await Component.push(componentItem);

expect(opnStub).calledOnceWith('https://github.com/redhat-developer/vscode-openshift-tools/wiki/Migration-to-v0.1.0');
expect(opnStub).calledOnceWith(vscode.Uri.parse('https://github.com/redhat-developer/vscode-openshift-tools/wiki/Migration-to-v0.1.0'));
expect(result).null;
});
});
Expand Down Expand Up @@ -1192,7 +1192,7 @@ suite('OpenShift/Component', () => {
]
}), stderr: ''});
await Component.openUrl(null);
expect(opnStub).calledOnceWith('https://url');
expect(opnStub).calledOnceWith(vscode.Uri.parse('https://url'));
});

test('gets URLs for the component and if there is more than one asks which one to open it in browser and opens selected', async () => {
Expand Down Expand Up @@ -1221,7 +1221,7 @@ suite('OpenShift/Component', () => {
]
}), stderr: ''});
await Component.openUrl(null);
expect(opnStub).calledOnceWith('https://url1');
expect(opnStub).calledOnceWith(vscode.Uri.parse('https://url1'));
});

test('gets URLs for the component, if there is more than one asks which one to open it in browser and exits if selection is canceled', async () => {
Expand Down Expand Up @@ -1271,7 +1271,7 @@ suite('OpenShift/Component', () => {
]
}), stderr: ''});
await Component.openUrl(null);
expect(opnStub).calledOnceWith('https://url');
expect(opnStub).calledOnceWith(vscode.Uri.parse('https://url'));
});

test('request to create url for component if it does not exist and exits when not confirmed' , async () => {
Expand Down