Skip to content

Commit fba228a

Browse files
author
yuanganping
authored
Merge pull request #470 from nocalhost/dev
release: v0.6.17
2 parents bb88026 + 1c9310b commit fba228a

13 files changed

Lines changed: 106 additions & 24 deletions

File tree

images/icon/locate_light.svg

Lines changed: 1 addition & 0 deletions
Loading

package.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nocalhost",
3-
"version": "0.6.16-alpha.f0d3f86",
3+
"version": "0.6.16-alpha.da5d0ea",
44
"displayName": "Nocalhost",
55
"description": "Makes developing with Kubernetes feel like on local. IDE tool for cloud-native development",
66
"license": "Apache-2.0",
@@ -208,6 +208,11 @@
208208
"when": "viewItem =~ /^workload-(deployment|statefulSet|job|daemonSet|cronjob|pod|crd-resources)-dev-(?!(developing-duplicate|developing-replace-self|starting|vpn_healthy|vpn_unhealthy))/i",
209209
"group": "navigation"
210210
},
211+
{
212+
"command": "Nocalhost.startMeshDevMode",
213+
"when": "viewItem =~ /^workload-(deployment|statefulSet|job|daemonSet|cronjob|pod|crd-resources)-dev-(?!(developing-duplicate|developing-replace-self|starting|vpn_healthy|vpn_unhealthy))/i",
214+
"group": "navigation"
215+
},
211216
{
212217
"command": "Nocalhost.endDevMode",
213218
"when": "viewItem =~ /^workload-(deployment|statefulSet|job|daemonSet|cronjob|pod|crd-resources)-dev-(developing|develop_starting)/i",
@@ -421,7 +426,10 @@
421426
{
422427
"command": "Nocalhost.LocateWorkNode",
423428
"title": "Locate Current Service",
424-
"icon": "images/icon/locate.svg"
429+
"icon": {
430+
"dark": "images/icon/locate.svg",
431+
"light": "images/icon/locate_light.svg"
432+
}
425433
},
426434
{
427435
"command": "Nocalhost.installAppSource",
@@ -473,6 +481,11 @@
473481
"title": "%startCopyDevMode%",
474482
"icon": "images/icon/dev_copy.svg"
475483
},
484+
{
485+
"command": "Nocalhost.startMeshDevMode",
486+
"title": "%startMeshDevMode%",
487+
"icon": "images/icon/dev_copy.svg"
488+
},
476489
{
477490
"command": "Nocalhost.endDevMode",
478491
"title": "%End.Develop%",

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@
3939
"viewDevConfig": "View Dev Configs",
4040
"resetPod": "Reset Pod",
4141
"startCopyDevMode": "Start DevMode(Duplicate)",
42+
"startMeshDevMode": "Start Mesh(Duplicate)",
4243

4344
"switchAssociate": "Switch This Service as Current Service",
4445
"disassociateAssociate": "Disassociate from Current Directory",
4546
"overrideRemoteChang": "Overwrite remote files",
4647
"resumeSync": "Resume File Sync",
4748
"sync.openDashboard": "Open Sync Dashboard",
4849

49-
"startProxyMode": "Start ProxyMode(Beta)",
50+
"startProxyMode": "Start ProxyMode",
5051
"resumeProxyMode": "Resume ProxyMode",
5152
"endProxyMode": "Stop ProxyMode"
5253
}

src/main/commands/RunCommand.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ export default class RunCommand implements ICommand {
8181
this.isReload = true;
8282

8383
await this.terminal.restart();
84-
85-
this.isReload = false;
8684
});
8785

8886
this.disposable.push(liveReload);
@@ -119,7 +117,10 @@ export default class RunCommand implements ICommand {
119117
spawn: {
120118
command,
121119
close: () => {
122-
this.dispose(false);
120+
if (!this.isReload) {
121+
this.dispose();
122+
}
123+
this.isReload = false;
123124
},
124125
},
125126
});
@@ -128,11 +129,11 @@ export default class RunCommand implements ICommand {
128129
this.terminal = terminal;
129130
}
130131

131-
async dispose(closeTerminal: boolean = true) {
132+
async dispose() {
132133
this.disposable.forEach((d) => d.dispose());
133134
this.disposable.length = 0;
134135

135-
if (closeTerminal && this.terminal) {
136+
if (this.terminal) {
136137
this.terminal.dispose();
137138
}
138139
}

src/main/commands/StartDevModeCommand.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
TMP_STORAGE_CLASS,
2222
TMP_WORKLOAD,
2323
TMP_WORKLOAD_PATH,
24+
TMP_HEADER,
2425
} from "../constants";
2526
import host, { Host } from "../host";
2627
import * as path from "path";
@@ -56,6 +57,7 @@ export interface ControllerNodeApi {
5657
type StartDevModeInfoType = {
5758
image?: string;
5859
mode?: "replace" | "copy";
60+
header?: string;
5961
command?: string;
6062
};
6163
export default class StartDevModeCommand implements ICommand {
@@ -78,6 +80,7 @@ export default class StartDevModeCommand implements ICommand {
7880

7981
let image = info?.image;
8082
const mode = info?.mode || "replace";
83+
const header = info?.header;
8184
this.node = node;
8285
this.info = info;
8386

@@ -168,15 +171,24 @@ export default class StartDevModeCommand implements ICommand {
168171
destDir === true ||
169172
(destDir && destDir === host.getCurrentRootPath())
170173
) {
171-
await this.startDevMode(host, appName, node, containerName, mode, image);
174+
await this.startDevMode(
175+
host,
176+
appName,
177+
node,
178+
containerName,
179+
mode,
180+
image,
181+
header
182+
);
172183
} else if (destDir) {
173184
this.saveAndOpenFolder(
174185
appName,
175186
node,
176187
destDir,
177188
containerName,
178189
mode,
179-
image
190+
image,
191+
header
180192
);
181193
messageBus.emit("devStart", {
182194
name: appName,
@@ -237,7 +249,8 @@ export default class StartDevModeCommand implements ICommand {
237249
destDir: string,
238250
containerName: string,
239251
mode: string,
240-
image: string
252+
image: string,
253+
header: string
241254
) {
242255
const currentUri = host.getCurrentRootPath();
243256

@@ -250,7 +263,8 @@ export default class StartDevModeCommand implements ICommand {
250263
node as ControllerResourceNode,
251264
containerName,
252265
mode,
253-
image
266+
image,
267+
header
254268
);
255269
}
256270
}
@@ -469,7 +483,8 @@ export default class StartDevModeCommand implements ICommand {
469483
node: ControllerNodeApi,
470484
containerName: string,
471485
mode: "replace" | "copy",
472-
image: string
486+
image: string,
487+
header?: string
473488
) {
474489
const currentUri = host.getCurrentRootPath() || os.homedir();
475490

@@ -499,7 +514,8 @@ export default class StartDevModeCommand implements ICommand {
499514
containerName,
500515
node.getStorageClass(),
501516
node.getDevStartAppendCommand(),
502-
image
517+
image,
518+
header
503519
);
504520
host.log("dev start end", true);
505521
host.log("", true);
@@ -568,7 +584,8 @@ export default class StartDevModeCommand implements ICommand {
568584
node: ControllerResourceNode,
569585
containerName: string,
570586
mode: string,
571-
image: string
587+
image: string,
588+
header: string
572589
) {
573590
const appNode = node.getAppNode();
574591
host.setGlobalState(TMP_ID, node.getNodeStateId());
@@ -587,6 +604,7 @@ export default class StartDevModeCommand implements ICommand {
587604
}
588605

589606
host.setGlobalState(TMP_MODE, mode);
607+
host.setGlobalState(TMP_HEADER, header);
590608
host.setGlobalState(TMP_DEV_START_IMAGE, image);
591609
const storageClass = node.getStorageClass();
592610
if (storageClass) {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import * as vscode from "vscode";
2+
import ICommand from "./ICommand";
3+
import registerCommand from "./register";
4+
import { START_MESH_DEV_MODE, START_DEV_MODE } from "./constants";
5+
6+
import { ControllerNodeApi } from "./StartDevModeCommand";
7+
8+
const validateInput = (value: string): string | Thenable<string> => {
9+
const reg = /\w+=\w+/;
10+
const match = reg.exec(value);
11+
if (!match) {
12+
return "please input correct string; example: foo=bar";
13+
}
14+
return "";
15+
};
16+
17+
export default class StartMeshDevModeCommand implements ICommand {
18+
command: string = START_MESH_DEV_MODE;
19+
context: vscode.ExtensionContext;
20+
constructor(context: vscode.ExtensionContext) {
21+
this.context = context;
22+
registerCommand(context, this.command, false, this.execCommand.bind(this));
23+
}
24+
25+
async execCommand(node: ControllerNodeApi) {
26+
const header = await vscode.window.showInputBox({
27+
placeHolder: "Please input header, eg: foo=bar",
28+
validateInput,
29+
});
30+
31+
if (header) {
32+
vscode.commands.executeCommand(START_DEV_MODE, node, {
33+
mode: "copy",
34+
header,
35+
});
36+
}
37+
}
38+
}

src/main/commands/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const EDIT_SERVICE_CONFIG = "Nocalhost.editServiceConfig";
1515

1616
export const START_DEV_MODE = "Nocalhost.startDevMode";
1717
export const START_COPY_DEV_MODE = "Nocalhost.startCopyDevMode";
18+
export const START_MESH_DEV_MODE = "Nocalhost.startMeshDevMode";
1819
export const END_DEV_MODE = "Nocalhost.endDevMode";
1920
export const RESET = "Nocalhost.reset";
2021

src/main/commands/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import StartProxyModeCommand from "./proxy/StartProxyModeCommand";
4747
import ResumeProxyModeCommand from "./proxy/ResumeProxyModeCommand";
4848
import EndProxyModeCommand from "./proxy/EndProxyModeCommand";
4949
import HomeWebViewCommand from "./HomeWebViewCommand";
50+
import StartMeshDevModeCommand from "./StartMeshDevModeCommand";
5051

5152
export default function initCommands(
5253
context: vscode.ExtensionContext,
@@ -107,6 +108,7 @@ export default function initCommands(
107108

108109
new ResetPluginCommand(context);
109110
new StartCopyDevModeCommand(context);
111+
new StartMeshDevModeCommand(context);
110112

111113
new StartProxyModeCommand(context);
112114
new ResumeProxyModeCommand(context);

src/main/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const TMP_KUBECONFIG_PATH = "tmpKubeconfigPath";
6363
export const TMP_STORAGE_CLASS = "tmpStorageClass";
6464
export const TMP_CONTAINER = "tmpContainer";
6565
export const TMP_MODE = "tmpMode";
66+
export const TMP_HEADER = "tmpHeader";
6667
export const TMP_DEVSTART_APPEND_COMMAND = "tmpDevstartAppendCommand";
6768
export const TMP_DEV_START_IMAGE = "tmpDevstartImage";
6869

src/main/ctl/nhctl/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,8 @@ export async function devStart(
733733
container?: string,
734734
storageClass?: string,
735735
devStartAppendCommand?: string,
736-
image?: string
736+
image?: string,
737+
header?: string
737738
) {
738739
let options = "";
739740
if (sync.isOld && sync.dirs && sync.dirs.length > 0) {
@@ -756,7 +757,7 @@ export async function devStart(
756757
mode === "copy" ? "-m duplicate" : ""
757758
} --without-terminal ${options} ${
758759
devStartAppendCommand ? devStartAppendCommand : ""
759-
} ${image ? `-i ${image}` : ""}`
760+
} ${image ? `-i ${image}` : ""} ${header ? `--header ${header}` : ""}`
760761
);
761762

762763
return execWithProgress({

0 commit comments

Comments
 (0)