Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom-container local start #1066

Merged
merged 1 commit into from
Feb 4, 2021

Conversation

SquatsTonight
Copy link
Collaborator

@SquatsTonight SquatsTonight commented Jan 25, 2021

增加 custom-container 的 local invoke/start;
custom-container 本地调试启的容器,不更改 PATH 环境变量,该环境变量由用户自定义。

@SquatsTonight SquatsTonight force-pushed the add-local-invoke-to-custom-container branch 2 times, most recently from 91b03aa to a00f08c Compare January 27, 2021 12:40
return opts;
}

async function generateLocalStartOpts(runtime, name, mounts, cmd, debugPort, envs, dockerUser, imageName, debugIde, caPort=9000) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个重载的函数逻辑大部分相同, 不能合成一个函数?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generateCustomContainerLocalStartOpts 和 generateLocalStartOpts 这两个函数逻辑还是有所不一样的,如果合成一个函数,需要一些 if...else 去进行判断,代码可读性会下降,同时函数参数上会出现一些冗余,这些冗余会让这个函数在调用时的可理解性下降,因此这里是分为两个函数去写的。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Mounts: mounts
}
};
if (runtime === 'custom-container') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

custom-container 能不能定义成一个全局的 const 的变量, fun这个工程应该有 const 全局变量文件吧

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -19,22 +20,16 @@ class ApiInvoke extends Invoke {
await super.init();

this.envs = await docker.generateDockerEnvs(this.baseDir, this.serviceName, this.serviceRes.Properties, this.functionName, this.functionProps, this.debugPort, null, this.nasConfig, true, this.debugIde, this.debugArgs);
this.cmd = docker.generateDockerCmd(this.functionProps, true);
if (this.runtime === 'custom-container') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还是一个风格问题, 为什么搞两个函数, generateDockerCmd 和 generateDockerCmdOfCustomContainer

我觉得 generateDockerCmd 一个函数就好, 多加一个 runtime 的参数, custom-container 有不同的处理让 generateDockerCmd这个函数搞定就好

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@SquatsTonight SquatsTonight force-pushed the add-local-invoke-to-custom-container branch 3 times, most recently from 43aa79d to e7d03aa Compare February 1, 2021 07:42
@SquatsTonight SquatsTonight force-pushed the add-local-invoke-to-custom-container branch 3 times, most recently from cb9fda8 to 8b652b7 Compare February 4, 2021 06:19
@SquatsTonight SquatsTonight force-pushed the add-local-invoke-to-custom-container branch from 8b652b7 to 49be133 Compare February 4, 2021 06:28
@rsonghuster rsonghuster merged commit 8f04ba1 into master Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants