Skip to content

Commit e6ea0bf

Browse files
Merge branch 'main' into 3638-show-vscode-notification-message-if-docker-is-not-started-for-fn-commands
2 parents 2e01dc8 + 0b85593 commit e6ea0bf

22 files changed

+529
-580
lines changed

package-lock.json

Lines changed: 337 additions & 307 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"make-fetch-happen": "^12.0.0",
8585
"mkdirp": "^3.0.1",
8686
"rxjs": "^7.8.1",
87-
"semver": "^7.5.2",
87+
"semver": "^7.6.0",
8888
"shelljs": "^0.8.5",
8989
"stacktrace-parser": "^0.1.10",
9090
"targz": "^1.0.1",
@@ -98,15 +98,15 @@
9898
},
9999
"devDependencies": {
100100
"@devfile/api": "^2.2.2-1704827891",
101-
"@mui/icons-material": "^5.15.7",
102-
"@mui/lab": "^5.0.0-alpha.163",
103-
"@mui/material": "^5.15.7",
104-
"@mui/styles": "^5.15.7",
101+
"@mui/icons-material": "^5.15.9",
102+
"@mui/lab": "^5.0.0-alpha.165",
103+
"@mui/material": "^5.15.9",
104+
"@mui/styles": "^5.15.9",
105105
"@rjsf/core": "^5.17.0",
106106
"@rjsf/mui": "^5.17.0",
107107
"@rjsf/utils": "^5.15.1",
108108
"@rjsf/validator-ajv8": "^5.17.0",
109-
"@segment/analytics-next": "^1.63.0",
109+
"@segment/analytics-next": "^1.64.0",
110110
"@svgr/plugin-jsx": "^8.1.0",
111111
"@types/chai": "^4.3.11",
112112
"@types/dockerode": "^3.3.23",
@@ -127,14 +127,14 @@
127127
"@types/targz": "^1.0.4",
128128
"@types/tmp": "^0.2.6",
129129
"@types/unzip-stream": "^0.3.4",
130-
"@types/validator": "^13.11.8",
130+
"@types/validator": "^13.11.9",
131131
"@types/vscode": "1.64.0",
132-
"@typescript-eslint/eslint-plugin": "^6.20.0",
133-
"@typescript-eslint/parser": "^6.20.0",
132+
"@typescript-eslint/eslint-plugin": "^6.21.0",
133+
"@typescript-eslint/parser": "^6.21.0",
134134
"@vscode/test-electron": "^2.3.9",
135135
"bootstrap": "^5.3.2",
136136
"chai": "^4.4.1",
137-
"chokidar": "^3.5.3",
137+
"chokidar": "^3.6.0",
138138
"codecov": "^3.8.2",
139139
"dockerode": "^4.0.2",
140140
"dpdm": "^3.14.0",
@@ -153,10 +153,10 @@
153153
"glob": "^10.3.10",
154154
"istanbul": "^0.4.5",
155155
"leasot": "^13.3.0",
156-
"mocha": "^10.2.0",
156+
"mocha": "^10.3.0",
157157
"mocha-jenkins-reporter": "^0.4.7",
158158
"npm-run-all": "^4.1.5",
159-
"prettier": "^3.2.4",
159+
"prettier": "^3.2.5",
160160
"pretty-bytes": "^6.1.1",
161161
"proxyquire": "^2.1.3",
162162
"react": "^17.0.2",
@@ -172,7 +172,7 @@
172172
"sinon": "^17.0.1",
173173
"sinon-chai": "^3.7.0",
174174
"source-map-support": "^0.5.21",
175-
"survey-react-ui": "^1.9.128",
175+
"survey-react-ui": "^1.9.129",
176176
"typescript": "^5.3.3",
177177
"vscode-extension-tester": "^7.0",
178178
"xterm-addon-fit": "^0.8.0",
@@ -762,6 +762,11 @@
762762
"title": "Create Deployment from Container Image URL",
763763
"category": "OpenShift"
764764
},
765+
{
766+
"command": "openshift.deployment.shell",
767+
"title": "Open Shell to Container",
768+
"category": "OpenShift"
769+
},
765770
{
766771
"command": "openshift.resource.load",
767772
"title": "Load",
@@ -1277,6 +1282,10 @@
12771282
"command": "openshift.resource.watchLogs",
12781283
"when": "false"
12791284
},
1285+
{
1286+
"command": "openshift.deployment.shell",
1287+
"when": "false"
1288+
},
12801289
{
12811290
"command": "openshift.resource.unInstall",
12821291
"when": "false"
@@ -1798,27 +1807,31 @@
17981807
},
17991808
{
18001809
"command": "openshift.resource.load",
1801-
"when": "view == openshiftProjectExplorer && viewItem == openshift.k8sObject || viewItem == openshift.k8sObject.route"
1810+
"when": "view == openshiftProjectExplorer && viewItem =~ /^openshift\\.k8sObject\\.(?!helm)/"
18021811
},
18031812
{
18041813
"command": "openshift.resource.delete",
1805-
"when": "view == openshiftProjectExplorer && viewItem == openshift.k8sObject || viewItem == openshift.k8sObject.route"
1814+
"when": "view == openshiftProjectExplorer && viewItem =~ /^openshift\\.k8sObject\\.(?!helm)/"
18061815
},
18071816
{
18081817
"command": "openshift.resource.watchLogs",
1809-
"when": "view == openshiftProjectExplorer && viewItem == openshift.k8sObject || viewItem == openshift.k8sObject.route"
1818+
"when": "view == openshiftProjectExplorer && viewItem =~ /^openshift\\.k8sObject\\.(?!helm)/"
1819+
},
1820+
{
1821+
"command": "openshift.deployment.shell",
1822+
"when": "view == openshiftProjectExplorer && viewItem =~ /^openshift\\.k8sObject\\.Deployment/"
18101823
},
18111824
{
18121825
"command": "openshift.resource.unInstall",
18131826
"when": "view == openshiftProjectExplorer && viewItem == openshift.k8sObject.helm"
18141827
},
18151828
{
18161829
"command": "openshift.resource.openInDeveloperConsole",
1817-
"when": "view == openshiftProjectExplorer && (viewItem == openshift.k8sObject || openshift.k8sObject.helm || viewItem == openshift.k8sObject.route) && isOpenshiftCluster"
1830+
"when": "view == openshiftProjectExplorer && viewItem =~ /^openshift\\.k8sObject/ && isOpenshiftCluster"
18181831
},
18191832
{
18201833
"command": "openshift.resource.openInBrowser",
1821-
"when": "view == openshiftProjectExplorer && viewItem == openshift.k8sObject.route && isOpenshiftCluster"
1834+
"when": "view == openshiftProjectExplorer && viewItem =~ /^openshift\\.k8sObject\\..*route$/ && isOpenshiftCluster"
18221835
},
18231836
{
18241837
"command": "openshift.Serverless.buildAndRun",

src/deployment.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
55

6+
import { KubernetesObject } from '@kubernetes/client-node';
67
import * as path from 'path';
78
import validator from 'validator';
89
import { Disposable, QuickInputButtons, ThemeIcon, TreeItem, window } from 'vscode';
10+
import { CommandText } from './base/command';
911
import { OpenShiftExplorer } from './explorer';
1012
import { Oc } from './oc/ocWrapper';
1113
import { validateRFC1123DNSLabel } from './openshift/nameValidator';
1214
import { quickBtn } from './util/inputValue';
1315
import { vsCommand } from './vscommand';
16+
import { OpenShiftTerminalManager } from './webview/openshift-terminal/openShiftTerminal';
1417

1518
export class Deployment {
1619

@@ -78,6 +81,12 @@ export class Deployment {
7881

7982
}
8083

84+
@vsCommand('openshift.deployment.shell')
85+
static shellIntoDeployment(component: KubernetesObject): Promise<void> {
86+
void OpenShiftTerminalManager.getInstance().createTerminal(new CommandText('oc', `exec -it ${component.kind}/${component.metadata.name} -- /bin/sh`), `Shell to '${component.metadata.name}'`);
87+
return Promise.resolve();
88+
}
89+
8190
/**
8291
* Prompt the user for the URL of a container image.
8392
*

src/explorer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
200200

201201
const routeURL = await Oc.Instance.getRouteURL(element.metadata.name);
202202
return {
203-
contextValue: !routeURL ? 'openshift.k8sObject' : 'openshift.k8sObject.route',
203+
contextValue: `openshift.k8sObject.${element.kind}${routeURL ? '.route' : ''}`,
204204
label: element.metadata.name,
205205
description: `${element.kind.substring(0, 1).toLocaleUpperCase()}${element.kind.substring(1)}`,
206206
collapsibleState: TreeItemCollapsibleState.None,

src/extension.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ export async function activate(extensionContext: ExtensionContext): Promise<unkn
204204
updateStatusBarItem(crcStatusItem, 'Stop CRC');
205205
void extendClusterExplorer();
206206

207-
await ComponentTypesView.instance.getAllComponents();
208207
await registerKubernetesCloudProvider();
209208
void startTelemetry(extensionContext);
210209
await verifyBinariesInRemoteContainer();

src/k8s/csv.ts

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
55

6-
import { TreeItem, WebviewPanel, window } from 'vscode';
6+
import { TreeItem } from 'vscode';
77
import { ClusterExplorerV1 } from 'vscode-kubernetes-tools-api';
88
import { Oc } from '../oc/ocWrapper';
9-
import { Odo } from '../odo/odoWrapper';
109
import OpenShiftItem from '../openshift/openshiftItem';
1110
import { CRDDescription, ClusterServiceVersionKind } from './olm/types';
1211

@@ -53,40 +52,4 @@ export class ClusterServiceVersion extends OpenShiftItem {
5352
};
5453
}
5554

56-
static createFormMessageListener(panel: WebviewPanel) {
57-
return async (event: any) => {
58-
if (event.command === 'cancel') {
59-
if (event.changed === true) {
60-
const choice = await window.showWarningMessage('Discard all the changes in the form?', 'Yes', 'No');
61-
if (choice === 'No') {
62-
return;
63-
}
64-
}
65-
panel.dispose();
66-
}
67-
if (event.command === 'create') {
68-
// add waiting for Deployment to be created using wait --for=condition
69-
// no need to wait until it is available
70-
if (!await Odo.Instance.getActiveCluster()) {
71-
// could be expired session
72-
return;
73-
}
74-
75-
try {
76-
// make the service part of the app
77-
event.formData.metadata.labels = {
78-
app: 'app',
79-
'app.kubernetes.io/part-of': 'app'
80-
};
81-
await Oc.Instance.createKubernetesObjectFromSpec(event.formData);
82-
void window.showInformationMessage(`Service ${event.formData.metadata.name} successfully created.`);
83-
panel.dispose();
84-
} catch (err) {
85-
void window.showErrorMessage(err);
86-
await panel.webview.postMessage({action: 'error'});
87-
}
88-
}
89-
}
90-
}
91-
9255
}

src/odo/odoWrapper.ts

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
55

6-
import { KubeConfig, KubernetesObject } from '@kubernetes/client-node';
7-
import { pathExistsSync } from 'fs-extra';
8-
import * as path from 'path';
9-
import { Uri, WorkspaceFolder, commands, workspace } from 'vscode';
6+
import { KubernetesObject } from '@kubernetes/client-node';
7+
import { Uri, WorkspaceFolder, workspace } from 'vscode';
108
import { CommandOption, CommandText } from '../base/command';
119
import * as cliInstance from '../cli';
1210
import { ToolsConfig } from '../tools';
1311
import { ChildProcessUtil, CliExitData } from '../util/childProcessUtil';
14-
import { KubeConfigUtils } from '../util/kubeUtils';
15-
import { Platform } from '../util/platform';
1612
import { VsCommandError } from '../vscommand';
1713
import { Command } from './command';
1814
import { AnalyzeResponse, ComponentTypeAdapter, ComponentTypeDescription, DevfileComponentType, Registry } from './componentType';
@@ -36,75 +32,13 @@ export class Odo {
3632
// no state
3733
}
3834

39-
/**
40-
* Returns the URL of the API of the current active cluster,
41-
* or undefined if there are no active clusters.
42-
*
43-
* @return the URL of the API of the current active cluster,
44-
* or undefined if there are no active clusters
45-
*/
46-
public async getActiveCluster(): Promise<string> {
47-
const result: CliExitData = await this.execute(
48-
Command.printOdoVersion(),
49-
process.cwd(),
50-
false,
51-
);
52-
53-
const odoCluster = result.stdout
54-
.trim()
55-
.split('\n')
56-
.filter((value) => value.includes('Server:'))
57-
.map((value) => {
58-
return value.substring(value.indexOf(':') + 1).trim();
59-
});
60-
if (odoCluster.length !== 0) {
61-
void commands.executeCommand('setContext', 'isLoggedIn', true);
62-
return odoCluster[0];
63-
}
64-
65-
// odo didn't report an active cluster, try reading it from KubeConfig
66-
try {
67-
const kubeConfigCurrentCluster = new KubeConfigUtils().getCurrentCluster().server;
68-
if (kubeConfigCurrentCluster) {
69-
void commands.executeCommand('setContext', 'isLoggedIn', true);
70-
return kubeConfigCurrentCluster;
71-
}
72-
} catch (e) {
73-
// ignored
74-
}
75-
76-
// no active cluster
77-
void commands.executeCommand('setContext', 'isLoggedIn', false);
78-
}
79-
80-
public getKubeconfigEnv(): { KUBECONFIG?: string } {
81-
const addEnv: { KUBECONFIG?: string } = {};
82-
let kc: KubeConfig;
83-
// TODO: Remove when odo works without kubeconfig present
84-
try {
85-
kc = new KubeConfigUtils();
86-
} catch (err) {
87-
// ignore error
88-
}
89-
90-
const configPath = path.join(Platform.getUserHomePath(), '.kube', 'config');
91-
92-
if (kc && !pathExistsSync(configPath)) {
93-
// config is loaded, yay! But there is still use case for missing config file
94-
// use fake config to let odo get component types from registry
95-
addEnv.KUBECONFIG = path.resolve(__dirname, '..', '..', 'config', 'kubeconfig');
96-
}
97-
return addEnv;
98-
}
99-
10035
public async getComponentTypes(): Promise<ComponentTypeAdapter[]> {
10136
// if kc is produced, KUBECONFIG env var is empty or pointing
10237

10338
const result: CliExitData = await this.execute(
10439
new CommandText('odo', 'registry -o json'),
10540
undefined,
106-
true,
107-
this.getKubeconfigEnv(),
41+
true
10842
);
10943
const componentTypes: DevfileComponentType[] = this.loadJSON(result.stdout);
11044
const devfileItems: ComponentTypeAdapter[] = [];

0 commit comments

Comments
 (0)