@geek-fun/serverlessinsight 0.9.1 → 0.9.3
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.
- package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +1 -1
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-insight-poc-tencent.json.backup +4 -8
- package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +3 -8
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +4 -4
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +1 -1
- package/.serverlessinsight/state-insight-poc-timer-app-insight-poc-timer.json.backup +132 -0
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +2 -2
- package/.serverlessinsight/state-insight-volc-nested-app-insight-volc-nested.json.backup +3 -3
- package/.serverlessinsight/state-nested-drift-app-nested-drift-service.json.backup +20 -5
- package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +3 -3
- package/AGENTS.md +10 -0
- package/CHANGELOG.md +51 -0
- package/README.md +103 -13
- package/README.zh-CN.md +73 -13
- package/codecov +0 -0
- package/codecov.SHA256SUM +1 -0
- package/codecov.SHA256SUM.sig +16 -0
- package/dist/package.json +1 -1
- package/dist/src/commands/index.js +92 -24
- package/dist/src/commands/local.js +16 -3
- package/dist/src/commands/plan.js +31 -4
- package/dist/src/commands/schema.js +24 -0
- package/dist/src/commands/show.js +64 -10
- package/dist/src/commands/validate.js +34 -2
- package/dist/src/common/aliyunClient/apigwOperations.js +17 -1
- package/dist/src/common/aliyunClient/fc3Operations.js +39 -2
- package/dist/src/common/aliyunClient/ossOperations.js +214 -221
- package/dist/src/common/bucketPolicy.js +63 -0
- package/dist/src/common/constants.js +7 -1
- package/dist/src/common/domainUtils.js +4 -1
- package/dist/src/common/functionDefinition.js +25 -0
- package/dist/src/common/index.js +4 -0
- package/dist/src/common/jsonOutput.js +82 -0
- package/dist/src/common/logger.js +6 -3
- package/dist/src/common/nameBuilder.js +3 -1
- package/dist/src/common/noColor.js +9 -0
- package/dist/src/common/planCapabilities.js +119 -0
- package/dist/src/common/planCompare.js +119 -66
- package/dist/src/common/planFormatter.js +34 -20
- package/dist/src/common/planRedaction.js +26 -0
- package/dist/src/common/refreshPlanner.js +66 -21
- package/dist/src/common/siCron.js +415 -0
- package/dist/src/common/stateBackend/saasStateBackend.js +5 -4
- package/dist/src/common/tencentClient/cosOperations.js +326 -322
- package/dist/src/common/tencentClient/scfOperations.js +11 -2
- package/dist/src/common/tencentClient/tdsqlcOperations.js +6 -11
- package/dist/src/common/triggerMapper.js +16 -1
- package/dist/src/common/volcengineClient/apigwOperations.js +82 -0
- package/dist/src/common/volcengineClient/iamOperations.js +27 -3
- package/dist/src/common/volcengineClient/tosOperations.js +62 -56
- package/dist/src/common/volcengineClient/vefaasOperations.js +45 -0
- package/dist/src/lang/en.js +70 -3
- package/dist/src/lang/index.js +36 -1
- package/dist/src/lang/zh-CN.js +70 -3
- package/dist/src/parser/eventParser.js +1 -0
- package/dist/src/parser/functionParser.js +48 -2
- package/dist/src/stack/aliyunStack/apigwExecutor.js +1 -1
- package/dist/src/stack/aliyunStack/apigwPlanner.js +103 -23
- package/dist/src/stack/aliyunStack/apigwResource.js +4 -3
- package/dist/src/stack/aliyunStack/apigwTypes.js +3 -7
- package/dist/src/stack/aliyunStack/deployer.js +2 -0
- package/dist/src/stack/aliyunStack/esServerlessTypes.js +8 -4
- package/dist/src/stack/aliyunStack/fc3Executor.js +7 -3
- package/dist/src/stack/aliyunStack/fc3Planner.js +148 -153
- package/dist/src/stack/aliyunStack/fc3Resource.js +206 -53
- package/dist/src/stack/aliyunStack/fc3Types.js +30 -16
- package/dist/src/stack/aliyunStack/ossPlanner.js +15 -1
- package/dist/src/stack/aliyunStack/ossResource.js +113 -102
- package/dist/src/stack/aliyunStack/ossTypes.js +20 -20
- package/dist/src/stack/localStack/aliyunFc.js +1 -6
- package/dist/src/stack/localStack/event.js +31 -71
- package/dist/src/stack/localStack/function.js +25 -77
- package/dist/src/stack/localStack/functionRunner.js +10 -2
- package/dist/src/stack/localStack/httpAdapter.js +54 -0
- package/dist/src/stack/localStack/httpError.js +5 -0
- package/dist/src/stack/localStack/index.js +8 -1
- package/dist/src/stack/localStack/legacyLambda.js +26 -0
- package/dist/src/stack/localStack/localContext.js +29 -0
- package/dist/src/stack/localStack/localRoute.js +12 -0
- package/dist/src/stack/localStack/localRuntimes.js +22 -0
- package/dist/src/stack/localStack/localServer.js +8 -3
- package/dist/src/stack/localStack/requestBody.js +24 -0
- package/dist/src/stack/localStack/requestId.js +18 -0
- package/dist/src/stack/localStack/tencent.js +147 -0
- package/dist/src/stack/localStack/timer.js +183 -0
- package/dist/src/stack/localStack/utils.js +19 -1
- package/dist/src/stack/localStack/volcengine.js +68 -0
- package/dist/src/stack/scfStack/cosPlanner.js +9 -14
- package/dist/src/stack/scfStack/cosResource.js +42 -50
- package/dist/src/stack/scfStack/cosTypes.js +19 -14
- package/dist/src/stack/scfStack/deployer.js +2 -0
- package/dist/src/stack/scfStack/scfExecutor.js +7 -3
- package/dist/src/stack/scfStack/scfHttpTrigger.js +106 -0
- package/dist/src/stack/scfStack/scfPlanner.js +114 -29
- package/dist/src/stack/scfStack/scfResource.js +329 -311
- package/dist/src/stack/scfStack/scfTypes.js +4 -3
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +10 -13
- package/dist/src/stack/volcengineStack/apigwDomains.js +64 -0
- package/dist/src/stack/volcengineStack/apigwPlanner.js +71 -15
- package/dist/src/stack/volcengineStack/apigwResource.js +60 -24
- package/dist/src/stack/volcengineStack/apigwTypes.js +5 -1
- package/dist/src/stack/volcengineStack/deployer.js +6 -0
- package/dist/src/stack/volcengineStack/tosPlanner.js +8 -13
- package/dist/src/stack/volcengineStack/tosResource.js +22 -35
- package/dist/src/stack/volcengineStack/tosTypes.js +5 -8
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +186 -44
- package/dist/src/stack/volcengineStack/vefaasResource.js +232 -14
- package/dist/src/stack/volcengineStack/vefaasTypes.js +6 -3
- package/dist/src/validator/functionSchema.js +25 -2
- package/dist/src/validator/iacSchema.js +2 -1
- package/dist/src/validator/index.js +4 -1
- package/dist/src/validator/rootSchema.js +49 -18
- package/dist/src/validator/schemaExport.js +60 -0
- package/dist/src/validator/semanticValidation.js +79 -0
- package/dist/src/validator/templateRefSchema.js +9 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/release-notes.md +79 -0
- package/samples/aliyun-poc-timer.yml +39 -0
- package/samples/tencent-local/index.js +13 -0
- package/samples/tencent-local/serverlessinsight.yml +23 -0
- package/samples/volcengine-local/index.js +13 -0
- package/samples/volcengine-local/serverlessinsight.yml +28 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildTosInstanceFromProvider = exports.cloudTosToDefinition = exports.extractTosBucketDefinition = exports.bucketToTosConfig = void 0;
|
|
3
|
+
exports.buildTosInstanceFromProvider = exports.cloudTosToDefinition = exports.extractTosBucketDefinition = exports.bucketToTosConfig = exports.TOS_BUCKET_POLICY_INSTANCE_TYPE = void 0;
|
|
4
|
+
const bucketPolicy_1 = require("../../common/bucketPolicy");
|
|
4
5
|
const aclMap = {
|
|
5
6
|
PRIVATE: 'private',
|
|
6
7
|
PUBLIC_READ: 'public-read',
|
|
7
8
|
PUBLIC_READ_WRITE: 'public-read-write',
|
|
8
9
|
};
|
|
10
|
+
exports.TOS_BUCKET_POLICY_INSTANCE_TYPE = 'VOLCENGINE_TOS_BUCKET_POLICY';
|
|
9
11
|
const bucketToTosConfig = (bucket) => {
|
|
10
12
|
const config = {
|
|
11
13
|
bucketName: bucket.name,
|
|
@@ -28,11 +30,6 @@ const bucketToTosConfig = (bucket) => {
|
|
|
28
30
|
return config;
|
|
29
31
|
};
|
|
30
32
|
exports.bucketToTosConfig = bucketToTosConfig;
|
|
31
|
-
const serializeBucketPolicy = (iam) => {
|
|
32
|
-
if (!iam?.resource?.statements || iam.resource.statements.length === 0)
|
|
33
|
-
return null;
|
|
34
|
-
return JSON.stringify(iam);
|
|
35
|
-
};
|
|
36
33
|
const extractTosBucketDefinition = (config, websiteCodeHash) => {
|
|
37
34
|
return {
|
|
38
35
|
bucketName: config.bucketName,
|
|
@@ -45,7 +42,7 @@ const extractTosBucketDefinition = (config, websiteCodeHash) => {
|
|
|
45
42
|
}
|
|
46
43
|
: null,
|
|
47
44
|
websiteCodeHash: websiteCodeHash ?? null,
|
|
48
|
-
policy: serializeBucketPolicy(config.iam),
|
|
45
|
+
policy: (0, bucketPolicy_1.serializeBucketPolicy)(config.iam, 'volcengine'),
|
|
49
46
|
};
|
|
50
47
|
};
|
|
51
48
|
exports.extractTosBucketDefinition = extractTosBucketDefinition;
|
|
@@ -63,7 +60,7 @@ const cloudTosToDefinition = (info) => ({
|
|
|
63
60
|
indexDocument: info.websiteConfig.indexDocument ?? null,
|
|
64
61
|
errorDocument: info.websiteConfig.errorDocument ?? null,
|
|
65
62
|
}
|
|
66
|
-
:
|
|
63
|
+
: info.websiteConfig,
|
|
67
64
|
});
|
|
68
65
|
exports.cloudTosToDefinition = cloudTosToDefinition;
|
|
69
66
|
const buildTosInstanceFromProvider = (info, sid) => {
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateFunctionPlan = void 0;
|
|
4
|
+
const iamOperations_1 = require("../../common/volcengineClient/iamOperations");
|
|
5
|
+
const planCapabilities_1 = require("../../common/planCapabilities");
|
|
6
|
+
const planCompare_1 = require("../../common/planCompare");
|
|
4
7
|
const common_1 = require("../../common");
|
|
5
8
|
const stateManager_1 = require("../../common/stateManager");
|
|
6
9
|
const volcengineClient_1 = require("../../common/volcengineClient");
|
|
7
10
|
const refreshCache_1 = require("../../common/refreshCache");
|
|
8
|
-
const
|
|
11
|
+
const planCompare_2 = require("../../common/planCompare");
|
|
9
12
|
const concurrency_1 = require("../../common/concurrency");
|
|
13
|
+
const siCron_1 = require("../../common/siCron");
|
|
10
14
|
const vefaasTypes_1 = require("./vefaasTypes");
|
|
11
15
|
const vefaasResource_1 = require("./vefaasResource");
|
|
12
16
|
const tlsOperations_1 = require("../../common/volcengineClient/tlsOperations");
|
|
@@ -20,6 +24,15 @@ const planFunctionDeletion = (logicalId, definition) => ({
|
|
|
20
24
|
resourceType: 'VOLCENGINE_VEFAAS',
|
|
21
25
|
changes: { before: definition },
|
|
22
26
|
});
|
|
27
|
+
// Timer triggers are state-owned dependents: when the timer declaration is
|
|
28
|
+
// omitted the recorded instances are removed, and the plan folds the removal
|
|
29
|
+
// into the "before" side so it is visible before execution.
|
|
30
|
+
const removedVefaasTimerItems = (fn, currentState) => !fn.triggers?.timer &&
|
|
31
|
+
(currentState.instances ?? []).some((instance) => instance.type === 'VOLCENGINE_VEFAAS_TIMER_TRIGGER')
|
|
32
|
+
? {
|
|
33
|
+
timers: currentState.definition.timers ?? [],
|
|
34
|
+
}
|
|
35
|
+
: {};
|
|
23
36
|
const generateFunctionPlan = async (context, state, functions) => {
|
|
24
37
|
if (!functions || functions.length === 0) {
|
|
25
38
|
const allStates = (0, stateManager_1.getAllResources)(state);
|
|
@@ -32,7 +45,25 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
32
45
|
const functionItems = await (0, concurrency_1.mapWithConcurrency)(functions, concurrency_1.PLAN_READ_CONCURRENCY, async (fn) => {
|
|
33
46
|
const logicalId = `functions.${fn.key}`;
|
|
34
47
|
const currentState = (0, common_1.getResource)(state, logicalId);
|
|
35
|
-
const
|
|
48
|
+
const recordedRole = currentState?.instances?.find((instance) => instance.type === 'VOLCENGINE_IAM_ROLE');
|
|
49
|
+
const config = (0, vefaasTypes_1.functionToVefaasConfig)(fn, {
|
|
50
|
+
role: typeof fn.iam?.role === 'string' ? fn.iam.role : recordedRole?.trn,
|
|
51
|
+
vpcConfig: fn.network
|
|
52
|
+
? {
|
|
53
|
+
vpcId: fn.network.vpc_id,
|
|
54
|
+
subnetIds: fn.network.subnet_ids,
|
|
55
|
+
securityGroupIds: fn.network.security_group?.name
|
|
56
|
+
? [fn.network.security_group.name]
|
|
57
|
+
: [],
|
|
58
|
+
}
|
|
59
|
+
: undefined,
|
|
60
|
+
tosMountConfig: fn.storage?.nas?.[0]
|
|
61
|
+
? {
|
|
62
|
+
bucketName: fn.storage.nas[0].bucket_name ?? '',
|
|
63
|
+
mountPath: fn.storage.nas[0].mount_path,
|
|
64
|
+
}
|
|
65
|
+
: undefined,
|
|
66
|
+
});
|
|
36
67
|
const codePath = fn.code.path;
|
|
37
68
|
const desiredCodeHash = await (0, common_1.computeZipContentHash)(codePath);
|
|
38
69
|
// Mirror the executor's auto-role behavior: when the YAML omits
|
|
@@ -80,8 +111,10 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
80
111
|
};
|
|
81
112
|
}
|
|
82
113
|
}
|
|
83
|
-
const baseDefinition = (0, vefaasTypes_1.extractVefaasDefinition)(config, desiredCodeHash);
|
|
114
|
+
const baseDefinition = (0, vefaasTypes_1.extractVefaasDefinition)(config, desiredCodeHash, fn);
|
|
84
115
|
const desiredDefinition = fn.iam ? { ...baseDefinition, iam: fn.iam } : baseDefinition;
|
|
116
|
+
if (currentState)
|
|
117
|
+
(0, planCapabilities_1.assertPlanIdentity)(logicalId, 'VOLCENGINE_VEFAAS', currentState.definition || {}, desiredDefinition);
|
|
85
118
|
if (!currentState || currentState.status === 'tainted') {
|
|
86
119
|
// No usable local state: probe the provider before planning create.
|
|
87
120
|
// If a same-named function already exists WITHOUT our ownership tag it
|
|
@@ -106,17 +139,25 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
106
139
|
try {
|
|
107
140
|
const client = (0, volcengineClient_1.createVolcengineClient)(context);
|
|
108
141
|
const currentDefinition = currentState.definition || {};
|
|
109
|
-
const definitionChanged =
|
|
142
|
+
const definitionChanged = (0, planCompare_1.definitionsDiffer)(currentDefinition, desiredDefinition);
|
|
143
|
+
const removedTimerItems = removedVefaasTimerItems(fn, currentState);
|
|
110
144
|
// --no-refresh: no live read, no drift claims — intent-diff only.
|
|
111
145
|
if (context.refresh === false) {
|
|
112
|
-
if (!definitionChanged) {
|
|
146
|
+
if (!definitionChanged && Object.keys(removedTimerItems).length === 0) {
|
|
113
147
|
return { logicalId, action: 'noop', resourceType: 'VOLCENGINE_VEFAAS' };
|
|
114
148
|
}
|
|
149
|
+
(0, planCapabilities_1.assertSupportedPlanUpdate)(logicalId, 'VOLCENGINE_VEFAAS', (0, planCompare_1.managedDefinition)(currentDefinition, desiredDefinition), desiredDefinition);
|
|
115
150
|
return {
|
|
116
151
|
logicalId,
|
|
117
152
|
action: 'update',
|
|
118
153
|
resourceType: 'VOLCENGINE_VEFAAS',
|
|
119
|
-
changes: {
|
|
154
|
+
changes: {
|
|
155
|
+
before: {
|
|
156
|
+
...(0, planCompare_1.managedDefinition)(currentDefinition, desiredDefinition),
|
|
157
|
+
...removedTimerItems,
|
|
158
|
+
},
|
|
159
|
+
after: (0, planCompare_1.managedDefinition)(desiredDefinition),
|
|
160
|
+
},
|
|
120
161
|
};
|
|
121
162
|
}
|
|
122
163
|
const remoteFunction = await (0, refreshCache_1.cachedRefreshRead)(context, `vefaas.getFunction:${fn.name}`, () => client.vefaas.getFunction(fn.name));
|
|
@@ -141,10 +182,6 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
141
182
|
// cloud-only values within mapped keys phantom-drifted every plan).
|
|
142
183
|
// Mapper-emitted shapes are subset-normalized to the definition the
|
|
143
184
|
// config writes, so nested comparisons stay apples-to-apples.
|
|
144
|
-
// Not refreshable (issue #234 phase 2): the IAM custom policy document
|
|
145
|
-
// (volcengine IAM has no GetPolicy read) and dependent TLS topics
|
|
146
|
-
// (existence-only by design decision 5) stay covered by the executor's
|
|
147
|
-
// reconcile path instead of live plan comparison.
|
|
148
185
|
const remoteAttributes = {
|
|
149
186
|
runtime: remoteFunction.runtime,
|
|
150
187
|
handler: remoteFunction.handler,
|
|
@@ -163,26 +200,19 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
163
200
|
securityGroupIds: remoteFunction.vpcConfig.securityGroupIds ?? [],
|
|
164
201
|
}
|
|
165
202
|
: undefined,
|
|
203
|
+
tosMountConfig: remoteFunction.tosMountConfig?.mountPoints?.[0]
|
|
204
|
+
? {
|
|
205
|
+
bucketName: remoteFunction.tosMountConfig.mountPoints[0].bucketName,
|
|
206
|
+
mountPath: remoteFunction.tosMountConfig.mountPoints[0].localMountPath,
|
|
207
|
+
}
|
|
208
|
+
: null,
|
|
166
209
|
logConfig: remoteFunction.logConfig
|
|
167
210
|
? { project: remoteFunction.logConfig.project, topic: remoteFunction.logConfig.topic }
|
|
168
211
|
: undefined,
|
|
169
212
|
};
|
|
170
|
-
const remoteDiffers = (0,
|
|
171
|
-
const liveBefore = (0,
|
|
172
|
-
const revertKeys = (0,
|
|
173
|
-
if (definitionChanged || remoteDiffers) {
|
|
174
|
-
return {
|
|
175
|
-
logicalId,
|
|
176
|
-
action: 'update',
|
|
177
|
-
resourceType: 'VOLCENGINE_VEFAAS',
|
|
178
|
-
changes: { before: liveBefore, after: desiredDefinition },
|
|
179
|
-
drifted: true,
|
|
180
|
-
...(revertKeys.length ? { revertKeys } : {}),
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
// Issue #234 phase 3: live role drift — trust policy and attached
|
|
184
|
-
// managed policies. The custom <role>-policy DOCUMENT has no read API
|
|
185
|
-
// (volcengine IAM has no GetPolicy), so it stays executor-reconciled.
|
|
213
|
+
const remoteDiffers = (0, planCompare_2.remoteDiffersFromDesired)(remoteAttributes, desiredDefinition);
|
|
214
|
+
const liveBefore = (0, planCompare_2.mergeLiveBefore)(currentDefinition, remoteAttributes, desiredDefinition);
|
|
215
|
+
const revertKeys = (0, planCompare_2.computeRevertKeys)(currentDefinition, remoteAttributes, desiredDefinition);
|
|
186
216
|
const iamRoleInstance = currentState.instances.find((i) => i.type === 'VOLCENGINE_IAM_ROLE');
|
|
187
217
|
if (iamRoleInstance?.id) {
|
|
188
218
|
try {
|
|
@@ -194,7 +224,8 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
194
224
|
logicalId,
|
|
195
225
|
action: 'update',
|
|
196
226
|
resourceType: 'VOLCENGINE_VEFAAS',
|
|
197
|
-
changes: { before: liveBefore, after: desiredDefinition },
|
|
227
|
+
changes: { before: liveBefore, after: (0, planCompare_1.managedDefinition)(desiredDefinition) },
|
|
228
|
+
...(revertKeys.length ? { revertKeys } : {}),
|
|
198
229
|
drifted: true,
|
|
199
230
|
driftReasons: ['PLAN_DRIFT_ROLE_MISSING'],
|
|
200
231
|
};
|
|
@@ -207,13 +238,34 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
207
238
|
cloudTrust = undefined;
|
|
208
239
|
}
|
|
209
240
|
if (cloudTrust &&
|
|
210
|
-
|
|
241
|
+
(0, planCompare_2.remoteDiffersFromDesired)({ policy: JSON.stringify(cloudTrust) }, { policy: JSON.stringify((0, vefaasTypes_1.buildDefaultTrustPolicy)(roleGrant.trustedServices)) })) {
|
|
211
242
|
return {
|
|
212
243
|
logicalId,
|
|
213
244
|
action: 'update',
|
|
214
245
|
resourceType: 'VOLCENGINE_VEFAAS',
|
|
215
|
-
changes: { before: liveBefore, after: desiredDefinition },
|
|
216
|
-
|
|
246
|
+
changes: { before: liveBefore, after: (0, planCompare_1.managedDefinition)(desiredDefinition) },
|
|
247
|
+
...(revertKeys.length ? { revertKeys } : {}),
|
|
248
|
+
...(!(0, planCompare_1.definitionsDiffer)(currentDefinition, {
|
|
249
|
+
iam: desiredDefinition.iam,
|
|
250
|
+
vpcConfig: desiredDefinition.vpcConfig,
|
|
251
|
+
tosMountConfig: desiredDefinition.tosMountConfig,
|
|
252
|
+
logConfig: desiredDefinition.logConfig,
|
|
253
|
+
})
|
|
254
|
+
? { drifted: true }
|
|
255
|
+
: {}),
|
|
256
|
+
driftReasons: ['PLAN_DRIFT_ROLE_POLICY'],
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
const policyName = (0, nameBuilder_1.buildRolePolicyName)(roleId);
|
|
260
|
+
const livePolicy = await (0, refreshCache_1.cachedRefreshRead)(context, `iam.getPolicy:${policyName}`, () => client.iam.getPolicy(policyName));
|
|
261
|
+
const desiredPolicy = (0, iamOperations_1.buildVefaasExecutionPolicy)(roleGrant.executionStatements, typeof fn.iam?.role === 'object' ? fn.iam.role.statements : undefined);
|
|
262
|
+
if ((0, planCompare_2.remoteDiffersFromDesired)({ policy: livePolicy }, { policy: desiredPolicy })) {
|
|
263
|
+
return {
|
|
264
|
+
logicalId,
|
|
265
|
+
action: 'update',
|
|
266
|
+
resourceType: 'VOLCENGINE_VEFAAS',
|
|
267
|
+
changes: { before: liveBefore, after: (0, planCompare_1.managedDefinition)(desiredDefinition) },
|
|
268
|
+
drifted: !(0, planCompare_1.definitionsDiffer)(currentDefinition, { iam: desiredDefinition.iam }),
|
|
217
269
|
driftReasons: ['PLAN_DRIFT_ROLE_POLICY'],
|
|
218
270
|
};
|
|
219
271
|
}
|
|
@@ -221,13 +273,25 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
221
273
|
const asSetKey = (names) => [...names].sort().join(',');
|
|
222
274
|
const cloudManaged = await (0, refreshCache_1.cachedRefreshRead)(context, `iam.listAttachedRolePolicies:${roleId}`, () => client.iam.listAttachedRolePolicies(roleId));
|
|
223
275
|
const desiredNames = asSetKey([...desiredManaged, (0, nameBuilder_1.buildRolePolicyName)(roleId)]);
|
|
224
|
-
if (
|
|
276
|
+
if (fn.iam?.role &&
|
|
277
|
+
typeof fn.iam.role !== 'string' &&
|
|
278
|
+
fn.iam.role.managed_policies !== undefined
|
|
279
|
+
? desiredNames !== asSetKey(cloudManaged ?? [])
|
|
280
|
+
: !(cloudManaged ?? []).includes((0, nameBuilder_1.buildRolePolicyName)(roleId))) {
|
|
225
281
|
return {
|
|
226
282
|
logicalId,
|
|
227
283
|
action: 'update',
|
|
228
284
|
resourceType: 'VOLCENGINE_VEFAAS',
|
|
229
|
-
changes: { before: liveBefore, after: desiredDefinition },
|
|
230
|
-
|
|
285
|
+
changes: { before: liveBefore, after: (0, planCompare_1.managedDefinition)(desiredDefinition) },
|
|
286
|
+
...(revertKeys.length ? { revertKeys } : {}),
|
|
287
|
+
...(!(0, planCompare_1.definitionsDiffer)(currentDefinition, {
|
|
288
|
+
iam: desiredDefinition.iam,
|
|
289
|
+
vpcConfig: desiredDefinition.vpcConfig,
|
|
290
|
+
tosMountConfig: desiredDefinition.tosMountConfig,
|
|
291
|
+
logConfig: desiredDefinition.logConfig,
|
|
292
|
+
})
|
|
293
|
+
? { drifted: true }
|
|
294
|
+
: {}),
|
|
231
295
|
driftReasons: ['PLAN_DRIFT_ROLE_POLICY'],
|
|
232
296
|
};
|
|
233
297
|
}
|
|
@@ -238,6 +302,7 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
238
302
|
functionName: fn.name,
|
|
239
303
|
error: String(error),
|
|
240
304
|
}));
|
|
305
|
+
throw error;
|
|
241
306
|
}
|
|
242
307
|
}
|
|
243
308
|
// Issue #234 M5: nested topic drift — ttl is the only ModifyTopic
|
|
@@ -255,7 +320,8 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
255
320
|
logicalId,
|
|
256
321
|
action: 'update',
|
|
257
322
|
resourceType: 'VOLCENGINE_VEFAAS',
|
|
258
|
-
changes: { before: liveBefore, after: desiredDefinition },
|
|
323
|
+
changes: { before: liveBefore, after: (0, planCompare_1.managedDefinition)(desiredDefinition) },
|
|
324
|
+
...(revertKeys.length ? { revertKeys } : {}),
|
|
259
325
|
drifted: true,
|
|
260
326
|
driftReasons: ['PLAN_DRIFT_TLS_TOPIC'],
|
|
261
327
|
};
|
|
@@ -267,9 +333,94 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
267
333
|
functionName: fn.name,
|
|
268
334
|
error: String(error),
|
|
269
335
|
}));
|
|
336
|
+
throw error;
|
|
270
337
|
}
|
|
271
338
|
}
|
|
272
339
|
}
|
|
340
|
+
// Issue #258: timer trigger drift — the live trigger list is compared
|
|
341
|
+
// against the desired timers (name-keyed). A trigger missing from the
|
|
342
|
+
// cloud (manual delete), an edited source config, or an extra
|
|
343
|
+
// undeclared timer all count as drift.
|
|
344
|
+
const desiredTimers = fn.triggers?.timer ?? [];
|
|
345
|
+
if (fn.triggers?.timer !== undefined && remoteFunction.functionId) {
|
|
346
|
+
try {
|
|
347
|
+
const liveTriggers = await (0, refreshCache_1.cachedRefreshRead)(context, `vefaas.listTriggers:${remoteFunction.functionId}`, () => client.vefaas.listTriggers(remoteFunction.functionId));
|
|
348
|
+
const liveTimers = liveTriggers.filter((trigger) => trigger.sourceType?.toLowerCase() === 'timer');
|
|
349
|
+
const desiredNames = new Set(desiredTimers.map((timer) => timer.name));
|
|
350
|
+
const extraTimer = liveTimers.some((trigger) => !trigger.name || !desiredNames.has(trigger.name));
|
|
351
|
+
const desiredChanged = desiredTimers.some((timer) => {
|
|
352
|
+
const live = liveTimers.find((trigger) => trigger.name === timer.name);
|
|
353
|
+
if (!live) {
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
let source;
|
|
357
|
+
try {
|
|
358
|
+
source = JSON.parse(live.source ?? '{}');
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
return (source.cron !== (0, siCron_1.translateSiCron)(timer.cron, 'volcengine') ||
|
|
364
|
+
source.enable !== timer.enable ||
|
|
365
|
+
(source.payload ?? undefined) !== timer.payload ||
|
|
366
|
+
(source.description ?? undefined) !== timer.description);
|
|
367
|
+
});
|
|
368
|
+
if (extraTimer || desiredChanged) {
|
|
369
|
+
return {
|
|
370
|
+
logicalId,
|
|
371
|
+
action: 'update',
|
|
372
|
+
resourceType: 'VOLCENGINE_VEFAAS',
|
|
373
|
+
changes: { before: liveBefore, after: (0, planCompare_1.managedDefinition)(desiredDefinition) },
|
|
374
|
+
...(revertKeys.length ? { revertKeys } : {}),
|
|
375
|
+
...(!(0, planCompare_1.definitionsDiffer)(currentDefinition, { timers: desiredDefinition.timers })
|
|
376
|
+
? { drifted: true }
|
|
377
|
+
: {}),
|
|
378
|
+
driftReasons: ['PLAN_DRIFT_TIMER_TRIGGER'],
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
catch (error) {
|
|
383
|
+
common_1.logger.warn(lang_1.lang.__('PLAN_TIMER_TRIGGER_PROBE_FAILED', {
|
|
384
|
+
functionName: fn.name,
|
|
385
|
+
error: String(error),
|
|
386
|
+
}));
|
|
387
|
+
throw error;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
(0, planCapabilities_1.assertSupportedPlanUpdate)(logicalId, 'VOLCENGINE_VEFAAS', liveBefore, desiredDefinition);
|
|
391
|
+
if ((0, planCompare_1.definitionsDiffer)(liveBefore, desiredDefinition)) {
|
|
392
|
+
return {
|
|
393
|
+
logicalId,
|
|
394
|
+
action: 'update',
|
|
395
|
+
resourceType: 'VOLCENGINE_VEFAAS',
|
|
396
|
+
changes: { before: liveBefore, after: (0, planCompare_1.managedDefinition)(desiredDefinition) },
|
|
397
|
+
...(revertKeys.length ? { revertKeys } : {}),
|
|
398
|
+
...((0, planCompare_2.remoteDiffersFromDesired)(remoteAttributes, (0, planCompare_1.managedDefinition)(currentDefinition, desiredDefinition))
|
|
399
|
+
? { drifted: true }
|
|
400
|
+
: {}),
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
if (Object.keys(removedTimerItems).length > 0) {
|
|
404
|
+
return {
|
|
405
|
+
logicalId,
|
|
406
|
+
action: 'update',
|
|
407
|
+
resourceType: 'VOLCENGINE_VEFAAS',
|
|
408
|
+
changes: {
|
|
409
|
+
before: {
|
|
410
|
+
...(0, planCompare_1.managedDefinition)(currentDefinition, desiredDefinition),
|
|
411
|
+
...removedTimerItems,
|
|
412
|
+
},
|
|
413
|
+
after: (0, planCompare_1.managedDefinition)(desiredDefinition),
|
|
414
|
+
},
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
if (definitionChanged && !remoteDiffers)
|
|
418
|
+
return {
|
|
419
|
+
logicalId,
|
|
420
|
+
action: 'noop',
|
|
421
|
+
resourceType: 'VOLCENGINE_VEFAAS',
|
|
422
|
+
stateUpdate: desiredDefinition,
|
|
423
|
+
};
|
|
273
424
|
return { logicalId, action: 'noop', resourceType: 'VOLCENGINE_VEFAAS' };
|
|
274
425
|
}
|
|
275
426
|
catch (error) {
|
|
@@ -277,16 +428,7 @@ const generateFunctionPlan = async (context, state, functions) => {
|
|
|
277
428
|
logicalId,
|
|
278
429
|
error: error instanceof Error ? error.message : String(error),
|
|
279
430
|
}));
|
|
280
|
-
|
|
281
|
-
logicalId,
|
|
282
|
-
action: 'create',
|
|
283
|
-
resourceType: 'VOLCENGINE_VEFAAS',
|
|
284
|
-
changes: {
|
|
285
|
-
before: currentState.definition,
|
|
286
|
-
after: desiredDefinition,
|
|
287
|
-
},
|
|
288
|
-
drifted: true,
|
|
289
|
-
};
|
|
431
|
+
throw error;
|
|
290
432
|
}
|
|
291
433
|
});
|
|
292
434
|
const allStates = (0, stateManager_1.getAllResources)(state);
|