-
Notifications
You must be signed in to change notification settings - Fork 5
Fix nas config and logConfig #135
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
base: master
Are you sure you want to change the base?
Conversation
abbd147 to
b4c3f0d
Compare
| enableInstanceMetrics: true | ||
| enableRequestMetrics: true | ||
| logBeginRule: DefaultRegex | ||
| enableInstanceMetrics: ${customFields.enableInstanceMetrics} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个感觉有点问题啊,不应该是跟 376-380 行一样的逻辑吗
| const { project, logstore } = await sls.deploy(); | ||
| const logAutoConfig = parseAutoConfig(this.local.logConfig as string); | ||
| const logParams = logAutoConfig?.params || {}; | ||
| const existingLogConfig = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里已经是 sls Auto 的逻辑了, 为什么还有 existingLogConfig?
| handler: index.handler | ||
| memorySize: 128 | ||
| timeout: 60 | ||
| nasConfig: auto|mountDir=/custom/nas/mount/path|serverAddr=/custom/nas/mount/path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/subCommands/model/index.ts
Outdated
| const customMountDir = params.mountDir | ||
| ? validateAndNormalizePath(params.mountDir, 'mountDir') | ||
| : `/mnt/${functionName}`; | ||
| const customServerAddr = params.serverAddr ? params.serverAddr : `${functionName}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 params.serverAddr 名字叫 params.nasDir 更容易理解点, 而且和 fc 的 serverAddr 没有冲突
src/subCommands/model/index.ts
Outdated
| let serverAddr = `${mountTargetDomain}:/${functionName}`; | ||
| const nasAutoConfig = parseAutoConfig(this.local.nasConfig as string); | ||
| const params = nasAutoConfig?.params || {}; | ||
| const customMountDir = params.mountDir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
customMountDir 改成 fcDir 吧,更容易理解点
src/subCommands/model/index.ts
Outdated
| const nasAutoConfig = parseAutoConfig(this.local.nasConfig as string); | ||
| const params = nasAutoConfig?.params || {}; | ||
| const customMountDir = params.mountDir | ||
| ? validateAndNormalizePath(params.mountDir, 'mountDir') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/utils/index.ts
Outdated
| * 验证并规范化路径 | ||
| */ | ||
| export function validateAndNormalizePath(path: string, paramName = 'path'): string { | ||
| if (typeof path !== 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
265-286 行没有任何意思, 不满足直接报错就好了
src/utils/index.ts
Outdated
| if (normalizedPath === prefix || normalizedPath.startsWith(`${prefix}/`)) { | ||
| const message = `Invalid ${paramName}, ${prefix} and its subdirectories are not allowed`; | ||
| if (logger) logger.warn(message); | ||
| return '/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接报错
src/utils/index.ts
Outdated
| if (normalizedPath === '/mnt' || normalizedPath === '/mnt/') { | ||
| const message = `Invalid ${paramName}, /mnt without subdirectory is not allowed`; | ||
| if (logger) logger.warn(message); | ||
| return '/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接报错, 你传给 fc, fc 那边还是会报错, 还不如直接拦了
src/utils/index.ts
Outdated
| /** | ||
| * 验证并规范化路径 | ||
| */ | ||
| export function validateAndNormalizePath(path: string, paramName = 'path'): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
函数validateAndNormalizePath名字就叫 checkFcDir , 语义明确点
aba2c4b to
d91d422
Compare
src/utils/index.ts
Outdated
| } | ||
|
|
||
| // 检查 /mnt 是否为顶级目录且没有子目录 | ||
| if (normalizedPath === '/mnt' || normalizedPath === '/mnt/') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我只是举个例子啊! 不是固定的 /mnt 。。。。。
ad984e2 to
8c3890c
Compare
8c3890c to
35e097b
Compare


No description provided.