Skip to content

Commit 897e7d0

Browse files
committed
Migrate command and tests to runWithProgress
1 parent e4a5fd7 commit 897e7d0

File tree

7 files changed

+14
-59
lines changed

7 files changed

+14
-59
lines changed

src/commands/deploy.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ClabLabTreeNode } from "../treeView/common";
22
import { ClabCommand } from "./clabCommand";
3-
import { SpinnerMsg } from "./command";
43
import * as vscode from "vscode";
54
import { deployPopularLab } from "./deployPopular";
65
import { getSelectedLabNode } from "./utils";
@@ -11,11 +10,7 @@ export async function deploy(node?: ClabLabTreeNode) {
1110
return;
1211
}
1312

14-
const spinnerMessages: SpinnerMsg = {
15-
progressMsg: "Deploying Lab... ",
16-
successMsg: "Lab deployed successfully!"
17-
};
18-
const deployCmd = new ClabCommand("deploy", node, spinnerMessages);
13+
const deployCmd = new ClabCommand("deploy", node);
1914
deployCmd.run();
2015
}
2116

@@ -40,11 +35,8 @@ export async function deployCleanup(node?: ClabLabTreeNode) {
4035
await config.update("skipCleanupWarning", true, vscode.ConfigurationTarget.Global);
4136
}
4237
}
43-
const spinnerMessages: SpinnerMsg = {
44-
progressMsg: "Deploying Lab (cleanup)... ",
45-
successMsg: "Lab deployed (cleanup) successfully!"
46-
};
47-
const deployCmd = new ClabCommand("deploy", node, spinnerMessages);
38+
39+
const deployCmd = new ClabCommand("deploy", node);
4840
deployCmd.run(["-c"]);
4941
}
5042

src/commands/destroy.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as vscode from "vscode";
22
import { ClabLabTreeNode } from "../treeView/common";
33
import { ClabCommand } from "./clabCommand";
4-
import { SpinnerMsg } from "./command";
54
import { getSelectedLabNode } from "./utils";
65

76
export async function destroy(node?: ClabLabTreeNode) {
@@ -10,11 +9,7 @@ export async function destroy(node?: ClabLabTreeNode) {
109
return;
1110
}
1211

13-
const spinnerMessages: SpinnerMsg = {
14-
progressMsg: "Destroying Lab... ",
15-
successMsg: "Lab destroyed successfully!"
16-
};
17-
const destroyCmd = new ClabCommand("destroy", node, spinnerMessages);
12+
const destroyCmd = new ClabCommand("destroy", node);
1813
destroyCmd.run();
1914
}
2015

@@ -39,10 +34,7 @@ export async function destroyCleanup(node?: ClabLabTreeNode) {
3934
await config.update("skipCleanupWarning", true, vscode.ConfigurationTarget.Global);
4035
}
4136
}
42-
const spinnerMessages: SpinnerMsg = {
43-
progressMsg: "Destroying Lab (cleanup)... ",
44-
successMsg: "Lab destroyed (cleanup) successfully!"
45-
};
46-
const destroyCmd = new ClabCommand("destroy", node, spinnerMessages);
37+
38+
const destroyCmd = new ClabCommand("destroy", node);
4739
destroyCmd.run(["-c"]);
4840
}

src/commands/edgeshark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { execCommandInTerminal } from "./command";
1+
import { execCommandInTerminal } from './command';
22

33
export const EDGESHARK_INSTALL_CMD = "curl -sL \
44
https://github.com/siemens/edgeshark/raw/main/deployments/wget/docker-compose.yaml \

src/commands/graph.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as vscode from "vscode";
22
import * as fs from "fs";
33
import { ClabCommand } from "./clabCommand";
4-
import { SpinnerMsg } from "./command";
54
import { ClabLabTreeNode } from "../treeView/common";
65

76
import { TopoViewer } from "../topoViewer/backend/topoViewerWebUiFacade";
@@ -18,13 +17,7 @@ async function runGraphDrawIO(node: ClabLabTreeNode | undefined, layout: "horizo
1817
return;
1918
}
2019

21-
const spinnerMessages: SpinnerMsg = {
22-
progressMsg: "Generating DrawIO graph...",
23-
successMsg: "DrawIO Graph Completed!",
24-
failMsg: "Graph (draw.io) Failed",
25-
};
26-
27-
const graphCmd = new ClabCommand("graph", node, spinnerMessages);
20+
const graphCmd = new ClabCommand("graph", node);
2821

2922
// Figure out the .drawio filename
3023
if (!node.labPath.absolute) {
@@ -71,7 +64,7 @@ export async function graphDrawIOInteractive(node?: ClabLabTreeNode) {
7164
return;
7265
}
7366

74-
const graphCmd = new ClabCommand("graph", node, undefined, true, "Graph - drawio Interactive");
67+
const graphCmd = new ClabCommand("graph", node);
7568

7669
graphCmd.run(["--drawio", "--drawio-args", `"-I"`]);
7770
}

src/commands/redeploy.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as vscode from "vscode";
22
import { ClabLabTreeNode } from "../treeView/common";
33
import { ClabCommand } from "./clabCommand";
4-
import { SpinnerMsg } from "./command";
54
import { getSelectedLabNode } from "./utils";
65

76
export async function redeploy(node?: ClabLabTreeNode) {
@@ -10,11 +9,7 @@ export async function redeploy(node?: ClabLabTreeNode) {
109
return;
1110
}
1211

13-
const spinnerMessages: SpinnerMsg = {
14-
progressMsg: "Redeploying Lab... ",
15-
successMsg: "Lab redeployed successfully!"
16-
};
17-
const redeployCmd = new ClabCommand("redeploy", node, spinnerMessages);
12+
const redeployCmd = new ClabCommand("redeploy", node);
1813
redeployCmd.run();
1914
}
2015

@@ -40,10 +35,6 @@ export async function redeployCleanup(node?: ClabLabTreeNode) {
4035
}
4136
}
4237

43-
const spinnerMessages: SpinnerMsg = {
44-
progressMsg: "Redeploying Lab (cleanup)... ",
45-
successMsg: "Lab redeployed (cleanup) successfully!"
46-
};
47-
const redeployCmd = new ClabCommand("redeploy", node, spinnerMessages);
38+
const redeployCmd = new ClabCommand("redeploy", node);
4839
redeployCmd.run(["-c"]);
4940
}

src/commands/save.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// src/commands/save.ts
22
import * as vscode from "vscode";
3-
import { SpinnerMsg } from "./command";
43
import { ClabCommand } from "./clabCommand";
54
import { ClabLabTreeNode, ClabContainerTreeNode } from "../treeView/common";
65
import * as path from "path";
@@ -20,14 +19,8 @@ export async function saveLab(node: ClabLabTreeNode) {
2019
return;
2120
}
2221

23-
const spinnerMessages: SpinnerMsg = {
24-
progressMsg: `Saving lab configuration for ${node.label}...`,
25-
successMsg: `Lab configuration for ${node.label} saved successfully!`,
26-
failMsg: `Could not save lab configuration for ${node.label}`
27-
};
28-
2922
// Create a ClabCommand for "save" using the lab node.
30-
const saveCmd = new ClabCommand("save", node, spinnerMessages);
23+
const saveCmd = new ClabCommand("save", node);
3124
// ClabCommand automatically appends "-t <labPath>".
3225
saveCmd.run();
3326
}
@@ -50,12 +43,6 @@ export async function saveNode(node: ClabContainerTreeNode) {
5043
// Extract the short node name by removing the "clab-{labname}-" prefix
5144
const shortNodeName = node.name.replace(/^clab-[^-]+-/, '');
5245

53-
const spinnerMessages: SpinnerMsg = {
54-
progressMsg: `Saving configuration for node ${shortNodeName}...`,
55-
successMsg: `Configuration for node ${shortNodeName} saved successfully!`,
56-
failMsg: `Could not save configuration for node ${shortNodeName}`
57-
};
58-
5946
const tempLabNode = new ClabLabTreeNode(
6047
path.basename(node.labPath.absolute),
6148
vscode.TreeItemCollapsibleState.None,
@@ -66,7 +53,7 @@ export async function saveNode(node: ClabContainerTreeNode) {
6653
"containerlabLabDeployed"
6754
);
6855

69-
const saveCmd = new ClabCommand("save", tempLabNode, spinnerMessages);
56+
const saveCmd = new ClabCommand("save", tempLabNode);
7057
// Use --node-filter instead of -n and use the short name
7158
saveCmd.run(["--node-filter", shortNodeName]);
7259
}

test/unit/commands/clabCommand.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('ClabCommand', () => {
6161
vscodeStub.TreeItemCollapsibleState.None,
6262
{ absolute: '/tmp/lab.yml', relative: 'lab.yml' }
6363
);
64-
const clab = new ClabCommand('deploy', node, undefined, true, 'term');
64+
const clab = new ClabCommand('deploy', node);
6565
await clab.run(['--foo']);
6666

6767
expect(cmdStub.instances).to.have.lengthOf(1);

0 commit comments

Comments
 (0)