@cloudbase/manager-node 5.8.2 → 5.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/lib/database/index.js +11 -6
  3. package/lib/deploy/DeployOrchestrator.js +170 -278
  4. package/lib/deploy/FunctionDeployer.js +310 -52
  5. package/lib/deploy/StaticDeployer.js +7 -1
  6. package/lib/deploy/function/artifact.js +55 -41
  7. package/lib/deploy/function/builders/cloud.js +58 -359
  8. package/lib/deploy/function/cam-preflight.js +2 -1
  9. package/lib/deploy/function/cloud-build-service.js +2 -16
  10. package/lib/deploy/function/config-guard.js +210 -55
  11. package/lib/deploy/function/enterprise-tcr.js +195 -0
  12. package/lib/deploy/function/image-tag.js +31 -0
  13. package/lib/deploy/function/local-builder.js +178 -32
  14. package/lib/deploy/function/personal-tcr.js +153 -0
  15. package/lib/deploy/function/preflight.js +3 -2
  16. package/lib/deploy/types.js +11 -0
  17. package/lib/hosting/index.js +27 -0
  18. package/lib/projectValidator/index.js +22 -23
  19. package/package.json +2 -2
  20. package/types/database/index.d.ts +1 -0
  21. package/types/deploy/DeployOrchestrator.d.ts +19 -25
  22. package/types/deploy/FunctionDeployer.d.ts +35 -3
  23. package/types/deploy/StaticDeployer.d.ts +11 -0
  24. package/types/deploy/function/artifact.d.ts +0 -5
  25. package/types/deploy/function/builders/cloud.d.ts +6 -39
  26. package/types/deploy/function/config-guard.d.ts +18 -0
  27. package/types/deploy/function/enterprise-tcr.d.ts +32 -0
  28. package/types/deploy/function/image-tag.d.ts +10 -0
  29. package/types/deploy/function/local-builder.d.ts +35 -6
  30. package/types/deploy/function/personal-tcr.d.ts +35 -0
  31. package/types/deploy/types.d.ts +110 -28
  32. package/types/hosting/index.d.ts +13 -0
  33. package/types/projectValidator/index.d.ts +3 -2
  34. package/types/projectValidator/types.d.ts +0 -1
  35. package/lib/deploy/StateStore.js +0 -328
  36. package/types/deploy/StateStore.d.ts +0 -174
@@ -5,12 +5,30 @@ exports.createImageArtifactFromConfig = createImageArtifactFromConfig;
5
5
  exports.createImageArtifactFromBuild = createImageArtifactFromBuild;
6
6
  exports.createImageArtifactFromCloudBuild = createImageArtifactFromCloudBuild;
7
7
  exports.toCloudFunction = toCloudFunction;
8
+ const error_1 = require("../../error");
8
9
  const types_1 = require("../types");
9
10
  /**
10
- * 部署物构造与 SCF 参数映射
11
+ * 解析构建类镜像部署物的 SCF RegistryId
11
12
  *
12
- * 四种构建策略最终都产出统一的部署物,之后走同一条 SCF 创建或更新流程
13
+ * 个人版镜像(personal,如个人版 CCR)不携带 registryId;企业版优先取
14
+ * imageConfig.registryId,回退到构建配置 imageConfig.build.registryId。
15
+ * 正常流程下企业版 registryId 已由 prepareEnterpriseTcrTarget 在构建前解析补齐,
16
+ * 此处对缺失场景 fail-fast 并给出明确错误:避免产出缺少 RegistryId 的部署物,
17
+ * 导致后续 SCF 拉取企业版镜像时失败且难以排查。
13
18
  */
19
+ function resolveBuildRegistryId(imageConfig) {
20
+ var _a, _b;
21
+ if (imageConfig.imageType !== 'enterprise') {
22
+ return undefined;
23
+ }
24
+ const registryId = (_a = imageConfig.registryId) !== null && _a !== void 0 ? _a : (_b = imageConfig.build) === null || _b === void 0 ? void 0 : _b.registryId;
25
+ if (!registryId) {
26
+ throw new error_1.CloudBaseError('企业版镜像缺少 TCR 实例 ID(registryId),无法生成镜像部署物。', {
27
+ code: types_1.FUNCTION_DEPLOY_ERROR.IMAGE_REGISTRY_ID_MISSING
28
+ });
29
+ }
30
+ return registryId;
31
+ }
14
32
  /** 由本地代码来源构造代码类部署物 */
15
33
  function createCodeArtifact(config) {
16
34
  const functionRootPath = 'functionRootPath' in config ? config.functionRootPath : undefined;
@@ -28,28 +46,26 @@ function createCodeArtifact(config) {
28
46
  }
29
47
  /** 由已有镜像配置构造镜像类部署物 */
30
48
  function createImageArtifactFromConfig(config) {
31
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
49
+ var _a;
32
50
  const { imageConfig } = config;
33
- // imageType/registryId 的契约位置在配置顶层(IHttpImageRuntimeCommon),
34
- // 与 local/cloud 策略一致;imageConfig 内的同名字段仅作向后兼容兜底。
51
+ // 直接读取 cloudbaserc 嵌套形状:镜像字段全部位于 imageConfig。
35
52
  // 个人版镜像(personal,如个人版 CCR)不应携带 registryId。
36
- const configuredRegistryId = (_a = config.registryId) !== null && _a !== void 0 ? _a : imageConfig.registryId;
37
- const imageType = (_c = (_b = config.imageType) !== null && _b !== void 0 ? _b : imageConfig.imageType) !== null && _c !== void 0 ? _c : (configuredRegistryId ? 'enterprise' : 'personal');
38
- const registryId = imageType === 'enterprise' ? configuredRegistryId : undefined;
53
+ const imageType = imageConfig.imageType;
54
+ const registryId = imageType === 'enterprise' ? imageConfig.registryId : undefined;
39
55
  return {
40
56
  kind: 'image',
41
57
  deployMode: 'image',
42
58
  imageUri: imageConfig.imageUri,
43
59
  imageType,
44
60
  registryId,
45
- imagePort: types_1.IMAGE_FUNCTION_PORT,
61
+ imagePort: (_a = imageConfig.imagePort) !== null && _a !== void 0 ? _a : types_1.IMAGE_FUNCTION_PORT,
46
62
  effectiveStrategy: 'image',
47
- entryPoint: (_d = imageConfig.entryPoint) !== null && _d !== void 0 ? _d : config.entryPoint,
48
- command: (_e = imageConfig.command) !== null && _e !== void 0 ? _e : config.command,
49
- args: (_f = imageConfig.args) !== null && _f !== void 0 ? _f : config.args,
50
- commandList: (_g = imageConfig.commandList) !== null && _g !== void 0 ? _g : config.commandList,
51
- argsList: (_h = imageConfig.argsList) !== null && _h !== void 0 ? _h : config.argsList,
52
- containerImageAccelerate: (_j = imageConfig.containerImageAccelerate) !== null && _j !== void 0 ? _j : config.containerImageAccelerate
63
+ entryPoint: imageConfig.entryPoint,
64
+ command: imageConfig.command,
65
+ args: imageConfig.args,
66
+ commandList: imageConfig.commandList,
67
+ argsList: imageConfig.argsList,
68
+ containerImageAccelerate: imageConfig.containerImageAccelerate
53
69
  };
54
70
  }
55
71
  /**
@@ -59,11 +75,10 @@ function createImageArtifactFromConfig(config) {
59
75
  * 此处仅承载最终 imageUri/digest 与容器启动配置,之后复用镜像部署链。
60
76
  */
61
77
  function createImageArtifactFromBuild(config, build) {
62
- var _a, _b, _c;
63
- const imageType = (_a = config.imageType) !== null && _a !== void 0 ? _a : (((_b = config.registryId) !== null && _b !== void 0 ? _b : config.build.registryId) ? 'enterprise' : 'personal');
64
- const registryId = imageType === 'enterprise'
65
- ? (_c = config.registryId) !== null && _c !== void 0 ? _c : config.build.registryId
66
- : undefined;
78
+ var _a;
79
+ const { imageConfig } = config;
80
+ const imageType = imageConfig.imageType;
81
+ const registryId = resolveBuildRegistryId(imageConfig);
67
82
  return {
68
83
  kind: 'image',
69
84
  deployMode: 'image',
@@ -71,14 +86,14 @@ function createImageArtifactFromBuild(config, build) {
71
86
  imageDigest: build.imageDigest,
72
87
  imageType,
73
88
  registryId,
74
- imagePort: types_1.IMAGE_FUNCTION_PORT,
89
+ imagePort: (_a = imageConfig.imagePort) !== null && _a !== void 0 ? _a : types_1.IMAGE_FUNCTION_PORT,
75
90
  effectiveStrategy: 'local',
76
- entryPoint: config.entryPoint,
77
- command: config.command,
78
- args: config.args,
79
- commandList: config.commandList,
80
- argsList: config.argsList,
81
- containerImageAccelerate: config.containerImageAccelerate
91
+ entryPoint: imageConfig.entryPoint,
92
+ command: imageConfig.command,
93
+ args: imageConfig.args,
94
+ commandList: imageConfig.commandList,
95
+ argsList: imageConfig.argsList,
96
+ containerImageAccelerate: imageConfig.containerImageAccelerate
82
97
  };
83
98
  }
84
99
  /**
@@ -89,30 +104,29 @@ function createImageArtifactFromBuild(config, build) {
89
104
  * effectiveStrategy 标记为 cloud,便于结果层如实回传实际生效的策略。
90
105
  */
91
106
  function createImageArtifactFromCloudBuild(config, build) {
92
- var _a, _b;
93
- const imageType = (_a = config.imageType) !== null && _a !== void 0 ? _a : (config.build.registryId ? 'enterprise' : 'personal');
94
- const registryId = imageType === 'enterprise'
95
- ? (_b = config.registryId) !== null && _b !== void 0 ? _b : config.build.registryId
96
- : undefined;
107
+ var _a;
108
+ const { imageConfig } = config;
109
+ const imageType = imageConfig.imageType;
110
+ // 云端构建默认推送到个人版 TCR(CCR);企业版实例 ID 位于 imageConfig.build.registryId,
111
+ // 需继续透传到 Stage B 的 SCF ImageConfig,避免构建成功后拉取镜像时丢失 RegistryId。
112
+ const registryId = resolveBuildRegistryId(imageConfig);
97
113
  return {
98
114
  kind: 'image',
99
115
  deployMode: 'image',
100
116
  imageUri: build.imageUri,
101
117
  imageDigest: build.imageDigest,
102
- // 云端构建默认推送到个人版 TCR(CCR);企业版实例 ID 位于 build.registryId,
103
- // 需继续透传到 Stage B 的 SCF ImageConfig,避免构建成功后拉取镜像时丢失 RegistryId。
104
118
  imageType,
105
119
  registryId,
106
- imagePort: types_1.IMAGE_FUNCTION_PORT,
120
+ imagePort: (_a = imageConfig.imagePort) !== null && _a !== void 0 ? _a : types_1.IMAGE_FUNCTION_PORT,
107
121
  effectiveStrategy: 'cloud',
108
122
  buildId: build.buildId,
109
123
  logsUrl: build.logsUrl,
110
- entryPoint: config.entryPoint,
111
- command: config.command,
112
- args: config.args,
113
- commandList: config.commandList,
114
- argsList: config.argsList,
115
- containerImageAccelerate: config.containerImageAccelerate
124
+ entryPoint: imageConfig.entryPoint,
125
+ command: imageConfig.command,
126
+ args: imageConfig.args,
127
+ commandList: imageConfig.commandList,
128
+ argsList: imageConfig.argsList,
129
+ containerImageAccelerate: imageConfig.containerImageAccelerate
116
130
  };
117
131
  }
118
132
  /** 将构建产出的 tag 地址与 digest 合成为 SCF 支持的不可变镜像引用 */