Skip to content

Commit edce2fc

Browse files
committed
Replacement for 'odo describe component'
Fixes: #5747 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com> Assisted-by: OpenAI ChatGPT
1 parent 5022055 commit edce2fc

File tree

13 files changed

+1159
-54
lines changed

13 files changed

+1159
-54
lines changed

src/componentsView.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,18 @@ class ComponentInfoRoot extends ComponentInfo {
103103
`Context: ${this.contextPath}`,
104104
].join('\n');
105105

106-
return {
106+
const item = {
107107
label: Component.renderLabel(this),
108108
workspaceFolder: this,
109109
tooltip,
110110
contextValue: Component.generateContextValue(this),
111111
iconPath: vsc.Uri.file(imagePath('component/workspace.png')),
112112
collapsibleState: vsc.TreeItemCollapsibleState.Collapsed
113113
};
114+
// eslint-disable no-console
115+
console.log(`[ComponentInfoRoot.toTreeItem]: ${this.contextPath} -> `, item);
116+
117+
return item;
114118
}
115119
}
116120

src/odo/command.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ export class Command {
3838
return new CommandText('odo', 'version');
3939
}
4040

41-
static describeComponent(): CommandText {
42-
return new CommandText('odo', 'describe component');
43-
}
44-
45-
static describeComponentJson(): CommandText {
46-
return Command.describeComponent().addOption(new CommandOption('-o', 'json', false));
47-
}
48-
4941
@verbose
5042
static createLocalComponent(
5143
devfileType = '', // will use empty string in case of undefined devfileType passed in

src/odo/componentTypeDescription.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ export interface ForwardedPort {
1212
localAddress: string,
1313
localPort: number,
1414
containerPort: number,
15+
name?: string
1516
}
1617

1718
export interface ComponentDescription {
1819
devfilePath: string;
1920
devfileData: {
2021
devfile: Data;
22+
effectiveDevfile?: Data;
23+
commands: any[],
2124
supportedOdoFeatures: {
2225
debug: boolean;
2326
deploy: boolean;
@@ -26,7 +29,27 @@ export interface ComponentDescription {
2629
}
2730
devForwardedPorts: ForwardedPort[],
2831
runningIn: string[];
32+
runningOn: string[];
33+
devControlPlane?: {
34+
platform: string
35+
localPort?: number
36+
apiServerPath?: string
37+
webInterfacePath?: string
38+
}[];
2939
managedBy: string;
40+
warnings?: string[];
41+
}
42+
43+
export type DevControlPlaneInfo = NonNullable<ComponentDescription['devControlPlane']>;
44+
45+
export interface CommandInfo {
46+
name: string
47+
type: string
48+
group: string
49+
isDefault: boolean
50+
commandLine: string
51+
component: string
52+
componentType: string
3053
}
3154

3255
export interface ComponentItem {

src/odo/odoWrapper.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { Uri, WorkspaceFolder, workspace } from 'vscode';
77
import { CommandOption, CommandText } from '../base/command';
88
import * as cliInstance from '../cli';
9+
import { getComponentDescription } from '../odo/util/describe';
910
import { ToolsConfig } from '../tools';
1011
import { ChildProcessUtil, CliExitData } from '../util/childProcessUtil';
1112
import { VsCommandError } from '../vscommand';
@@ -30,20 +31,23 @@ export class Odo {
3031
}
3132

3233
public async describeComponent(
33-
contextPath: string,
34-
experimental = false,
34+
contextPath: string
3535
): Promise<ComponentDescription | undefined> {
36-
const expEnv = experimental ? { ODO_EXPERIMENTAL_MODE: 'true' } : {};
3736
try {
38-
const describeCmdResult: CliExitData = await this.execute(
39-
Command.describeComponentJson(),
40-
contextPath,
41-
false,
42-
expEnv,
43-
);
44-
return JSON.parse(describeCmdResult.stdout) as ComponentDescription;
45-
} catch {
37+
const options = {}
38+
const devfilePath = contextPath
39+
40+
const componentInfo = await getComponentDescription(devfilePath, options)
41+
// eslint-disable no-console
42+
console.log(`[describeComponent] path: ${contextPath}:`, componentInfo);
43+
return componentInfo;
44+
} catch (err) {
45+
// eslint-disable no-console
46+
console.error(`[describeComponent] FAILED: ${contextPath}`);
47+
console.error(err?.message || err);
48+
console.error(err?.stack);
4649
// ignore and return undefined
50+
return undefined;
4751
}
4852
}
4953

0 commit comments

Comments
 (0)