Skip to content

Commit b6a527f

Browse files
authored
Print crc command to channel before output (#1965)
Signed-off-by: Denis Golovin [email protected]
1 parent 0b8fd9c commit b6a527f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/view/cluster/clusterViewLoader.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { CliChannel } from '../../cli';
1212

1313
let panel: vscode.WebviewPanel;
1414

15+
const channel: vscode.OutputChannel = vscode.window.createOutputChannel('CRC Logs');
16+
1517
export default class ClusterViewLoader {
1618
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
1719
static get extensionPath() {
@@ -23,7 +25,6 @@ export default class ClusterViewLoader {
2325

2426
let startProcess: ChildProcess;
2527
let stopProcess: ChildProcess;
26-
const channel: vscode.OutputChannel = vscode.window.createOutputChannel('CRC Logs');
2728
const localResourceRoot = vscode.Uri.file(path.join(ClusterViewLoader.extensionPath, 'out', 'clusterViewer'));
2829
if (panel) {
2930
// If we already have a panel, show it in the target column
@@ -42,22 +43,21 @@ export default class ClusterViewLoader {
4243
panel = undefined;
4344
});
4445
panel.webview.onDidReceiveMessage(async (event) => {
45-
const timestamp = Number(new Date());
46-
const date = new Date(timestamp);
4746
if (event.action === 'run') {
4847
const terminal: vscode.Terminal = WindowUtil.createTerminal(`OpenShift: CRC Setup`, undefined);
4948
terminal.sendText(`${event.data} setup`);
5049
terminal.show();
5150
}
5251
if (event.action === 'start') {
5352
channel.show();
54-
channel.append(`\nStarting Red Hat CodeReady Containers from webview at ${date}\n`);
5553
if (event.isSetting) {
5654
const binaryFromSetting= vscode.workspace.getConfiguration("openshiftConnector").get("crcBinaryLocation");
5755
const pullSecretFromSetting= vscode.workspace.getConfiguration("openshiftConnector").get("crcPullSecretPath");
5856
const cpuFromSetting= vscode.workspace.getConfiguration("openshiftConnector").get("crcCpuCores");
5957
const memoryFromSetting= vscode.workspace.getConfiguration("openshiftConnector").get("crcMemoryAllocated");
60-
startProcess = spawn(`${binaryFromSetting}`, ['start', '-p', `${pullSecretFromSetting}`, '-c', `${cpuFromSetting}`, '-m', `${memoryFromSetting}`, '-ojson']);
58+
const crcOptions = ['start', '-p', `${pullSecretFromSetting}`, '-c', `${cpuFromSetting}`, '-m', `${memoryFromSetting}`, '-ojson'];
59+
startProcess = spawn(`${binaryFromSetting}`, crcOptions);
60+
channel.append(`\n\n${binaryFromSetting} ${crcOptions.join(' ')}\n`);
6161
} else {
6262
const configuration = vscode.workspace.getConfiguration("openshiftConnector");
6363
configuration.update("crcBinaryLocation", event.crcLoc, vscode.ConfigurationTarget.Global);
@@ -66,6 +66,7 @@ export default class ClusterViewLoader {
6666
configuration.update("crcMemoryAllocated", Number.parseInt(event.memory), vscode.ConfigurationTarget.Global);
6767
const [tool, ...params] = event.data.split(' ');
6868
startProcess = spawn(tool, params);
69+
channel.append(`\n\n${tool} ${params.join(' ')}\n`);
6970
}
7071
startProcess.stdout.setEncoding('utf8');
7172
startProcess.stderr.setEncoding('utf8');
@@ -88,11 +89,13 @@ export default class ClusterViewLoader {
8889
if (event.action === 'stop') {
8990
let filePath: string;
9091
channel.show();
91-
channel.append(`\nStopping Red Hat CodeReady Containers from webview at ${date}\n`);
9292
if (event.data === '') {
9393
filePath = vscode.workspace.getConfiguration("openshiftConnector").get("crcBinaryLocation");
94-
} else filePath = event.data;
94+
} else {
95+
filePath = event.data;
96+
}
9597
stopProcess = spawn(`${filePath}`, ['stop']);
98+
channel.append(`\n\n$${filePath} stop\n`);
9699
stopProcess.stdout.setEncoding('utf8');
97100
stopProcess.stderr.setEncoding('utf8');
98101
stopProcess.stdout.on('data', (chunk) => {
@@ -134,7 +137,11 @@ export default class ClusterViewLoader {
134137
private static async checkCrcStatus(filePath: string, postCommand: string, panel: vscode.WebviewPanel | undefined = undefined) {
135138
let crcCredArray = [];
136139
const crcVerInfo = await CliChannel.getInstance().execute(`${filePath} version -ojson`);
140+
channel.append(`\n\n${filePath} version -ojson\n`);
141+
channel.append(crcVerInfo.stdout);
137142
const result = await CliChannel.getInstance().execute(`${filePath} status -ojson`);
143+
channel.append(`\n\n${filePath} status -ojson\n`);
144+
channel.append(result.stdout);
138145
if (result.stderr || crcVerInfo.stderr) {
139146
panel.webview.postMessage({action: postCommand, errorStatus: true});
140147
} else {

0 commit comments

Comments
 (0)