@geek-fun/serverlessinsight 0.9.2 → 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 +28 -5
- 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 +34 -0
- package/README.md +29 -15
- package/README.zh-CN.md +7 -14
- package/dist/package.json +1 -1
- package/dist/src/commands/index.js +19 -3
- package/dist/src/commands/local.js +16 -3
- package/dist/src/commands/plan.js +10 -3
- package/dist/src/common/aliyunClient/apigwOperations.js +17 -1
- package/dist/src/common/aliyunClient/fc3Operations.js +7 -1
- package/dist/src/common/aliyunClient/ossOperations.js +214 -221
- package/dist/src/common/bucketPolicy.js +63 -0
- 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 +6 -1
- package/dist/src/common/nameBuilder.js +3 -1
- package/dist/src/common/planCapabilities.js +119 -0
- package/dist/src/common/planCompare.js +119 -66
- package/dist/src/common/planFormatter.js +22 -14
- package/dist/src/common/planRedaction.js +26 -0
- package/dist/src/common/refreshPlanner.js +66 -21
- package/dist/src/common/tencentClient/cosOperations.js +326 -322
- package/dist/src/common/tencentClient/scfOperations.js +9 -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/lang/en.js +28 -4
- package/dist/src/lang/zh-CN.js +28 -4
- package/dist/src/parser/eventParser.js +1 -0
- package/dist/src/parser/functionParser.js +1 -1
- 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 +124 -155
- package/dist/src/stack/aliyunStack/fc3Resource.js +48 -52
- 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 -60
- package/dist/src/stack/localStack/function.js +24 -65
- 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/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 +23 -2
- 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 +67 -16
- package/dist/src/stack/scfStack/scfResource.js +170 -321
- 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 +142 -49
- package/dist/src/stack/volcengineStack/vefaasResource.js +17 -12
- package/dist/src/stack/volcengineStack/vefaasTypes.js +6 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/release-notes.md +79 -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,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateApigwPlan = void 0;
|
|
4
|
+
const certUtils_1 = require("../../common/certUtils");
|
|
5
|
+
const domainUtils_1 = require("../../common/domainUtils");
|
|
6
|
+
const planCapabilities_1 = require("../../common/planCapabilities");
|
|
7
|
+
const planCompare_1 = require("../../common/planCompare");
|
|
4
8
|
const aliyunClient_1 = require("../../common/aliyunClient");
|
|
5
9
|
const logger_1 = require("../../common/logger");
|
|
6
10
|
const apigwTypes_1 = require("./apigwTypes");
|
|
7
11
|
const stateManager_1 = require("../../common/stateManager");
|
|
8
|
-
const hashUtils_1 = require("../../common/hashUtils");
|
|
9
12
|
const iacHelper_1 = require("../../common/iacHelper");
|
|
10
|
-
const
|
|
13
|
+
const planCompare_2 = require("../../common/planCompare");
|
|
11
14
|
const refreshCache_1 = require("../../common/refreshCache");
|
|
12
15
|
const concurrency_1 = require("../../common/concurrency");
|
|
13
16
|
const ownershipTag_1 = require("../ownershipTag");
|
|
@@ -62,6 +65,8 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
62
65
|
domain: (0, apigwTypes_1.extractEventDomainDefinition)(event.domain),
|
|
63
66
|
...(logSnapshot ? { log: logSnapshot } : {}),
|
|
64
67
|
};
|
|
68
|
+
if (currentState)
|
|
69
|
+
(0, planCapabilities_1.assertPlanIdentity)(logicalId, 'ALIYUN_APIGW', currentState.definition || {}, desiredDefinition);
|
|
65
70
|
if (!currentState || currentState.status === 'tainted') {
|
|
66
71
|
// No usable local state: probe the provider before planning create.
|
|
67
72
|
// If a same-named group already exists WITHOUT our ownership tag it
|
|
@@ -99,9 +104,23 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
99
104
|
try {
|
|
100
105
|
const groupInstance = currentState.instances.find((i) => i.type === 'ALIYUN_APIGW_GROUP');
|
|
101
106
|
const currentDefinition = currentState.definition || {};
|
|
102
|
-
const definitionChanged =
|
|
107
|
+
const definitionChanged = (0, planCompare_1.definitionsDiffer)(currentDefinition, desiredDefinition);
|
|
108
|
+
if (context.refresh === false) {
|
|
109
|
+
return definitionChanged
|
|
110
|
+
? {
|
|
111
|
+
logicalId,
|
|
112
|
+
action: 'update',
|
|
113
|
+
resourceType: 'ALIYUN_APIGW',
|
|
114
|
+
changes: {
|
|
115
|
+
before: (0, planCompare_1.managedDefinition)(currentDefinition, desiredDefinition),
|
|
116
|
+
after: (0, planCompare_1.managedDefinition)(desiredDefinition),
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
: { logicalId, action: 'noop', resourceType: 'ALIYUN_APIGW' };
|
|
120
|
+
}
|
|
103
121
|
let groupRemoteDiffers = false;
|
|
104
122
|
let triggersDiffer = false;
|
|
123
|
+
let domainDiffers = false;
|
|
105
124
|
// Issue #246: live group attributes become the diff baseline when the
|
|
106
125
|
// group was readable; trigger-level drift has no attribute mapping and
|
|
107
126
|
// is surfaced as a drift reason instead.
|
|
@@ -118,14 +137,59 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
118
137
|
drifted: true,
|
|
119
138
|
};
|
|
120
139
|
}
|
|
121
|
-
// Issue #234 Phase 1: a local config change already forces update, so
|
|
122
|
-
// the live cloud is only probed when state == config — a console edit
|
|
123
|
-
// to the group/trigger then surfaces as update + drifted, and a read
|
|
124
|
-
// failure cannot degrade a config-driven update into a create.
|
|
125
|
-
// Domain/log stay existence-only in Phase 0-2 — never compared live.
|
|
126
140
|
liveGroupAttrs = (0, apigwTypes_1.cloudApigwGroupToDefinition)(remoteGroup);
|
|
127
|
-
if (
|
|
128
|
-
|
|
141
|
+
if (event.domain &&
|
|
142
|
+
desiredDefinition.domain?.cdnEnabled !== true &&
|
|
143
|
+
remoteGroup.customDomains !== undefined) {
|
|
144
|
+
const names = [
|
|
145
|
+
String(event.domain.domain_name),
|
|
146
|
+
...(event.domain.www_bind_apex === true
|
|
147
|
+
? [(0, domainUtils_1.deriveWwwDomain)(String(event.domain.domain_name))].filter((name) => name !== null)
|
|
148
|
+
: []),
|
|
149
|
+
];
|
|
150
|
+
const expectedRedirect = (0, apigwTypes_1.inferProtocolConfig)(event.domain.protocol)
|
|
151
|
+
.isHttpRedirectToHttps ?? false;
|
|
152
|
+
const desiredCertificate = event.domain.certificate_id
|
|
153
|
+
? (await (0, refreshCache_1.cachedRefreshRead)(context, `cas.getCertificate:${event.domain.certificate_id}`, () => client.cas.getCertificate(String(event.domain.certificate_id))))?.cert
|
|
154
|
+
: event.domain.certificate_body
|
|
155
|
+
? (0, certUtils_1.readPemContent)(String(event.domain.certificate_body))
|
|
156
|
+
: undefined;
|
|
157
|
+
if (event.domain.certificate_id && !desiredCertificate)
|
|
158
|
+
throw new Error(lang_1.lang.__('CERT_REFERENCE_NOT_FOUND', {
|
|
159
|
+
reference: String(event.domain.certificate_id),
|
|
160
|
+
}));
|
|
161
|
+
const certificateValue = (value) => (value ?? '').replace(/\s/g, '');
|
|
162
|
+
for (const name of names) {
|
|
163
|
+
const summary = remoteGroup.customDomains.find((domain) => domain.domainName === name);
|
|
164
|
+
if (!summary) {
|
|
165
|
+
domainDiffers = true;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (expectedRedirect !== undefined &&
|
|
169
|
+
summary.isHttpRedirectToHttps !== undefined &&
|
|
170
|
+
expectedRedirect !== summary.isHttpRedirectToHttps)
|
|
171
|
+
domainDiffers = true;
|
|
172
|
+
if (desiredCertificate) {
|
|
173
|
+
const detail = await (0, refreshCache_1.cachedRefreshRead)(context, `apigw.getDomain:${groupInstance.id}:${name}`, () => client.apigw.getDomain(groupInstance.id, name));
|
|
174
|
+
if (!detail ||
|
|
175
|
+
certificateValue(detail.certificateBody) !== certificateValue(desiredCertificate))
|
|
176
|
+
domainDiffers = true;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const cloudDomain = remoteGroup.customDomains.find((domain) => domain.domainName === event.domain.domain_name);
|
|
180
|
+
liveGroupAttrs.domain = cloudDomain
|
|
181
|
+
? {
|
|
182
|
+
...currentDefinition.domain,
|
|
183
|
+
domainName: cloudDomain.domainName,
|
|
184
|
+
}
|
|
185
|
+
: null;
|
|
186
|
+
}
|
|
187
|
+
if (event.log) {
|
|
188
|
+
const log = await (0, refreshCache_1.cachedRefreshRead)(context, 'apigw.describeGatewayLogConfig', () => client.apigw.describeGatewayLogConfig());
|
|
189
|
+
liveGroupAttrs.log = (0, apigwTypes_1.cloudGatewayLogToLogConfig)(log) ?? { logEnabled: false };
|
|
190
|
+
}
|
|
191
|
+
{
|
|
192
|
+
groupRemoteDiffers = (0, planCompare_2.remoteDiffersFromDesired)(liveGroupAttrs, desiredDefinition);
|
|
129
193
|
if (event.triggers.length > 0) {
|
|
130
194
|
const desiredApis = new Map(event.triggers.map((trigger) => {
|
|
131
195
|
const apiName = buildDesiredTriggerApiName(event, trigger, context.stage);
|
|
@@ -169,19 +233,41 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
169
233
|
}
|
|
170
234
|
}
|
|
171
235
|
}
|
|
172
|
-
|
|
236
|
+
const effectiveChanged = (0, planCompare_1.definitionsDiffer)((0, planCompare_2.mergeLiveBefore)(currentDefinition, liveGroupAttrs ?? {}, desiredDefinition), desiredDefinition);
|
|
237
|
+
if (definitionChanged && !effectiveChanged && !triggersDiffer && !domainDiffers) {
|
|
238
|
+
return {
|
|
239
|
+
logicalId,
|
|
240
|
+
action: 'noop',
|
|
241
|
+
resourceType: 'ALIYUN_APIGW',
|
|
242
|
+
stateUpdate: desiredDefinition,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
if (effectiveChanged || groupRemoteDiffers || triggersDiffer || domainDiffers) {
|
|
173
246
|
return {
|
|
174
247
|
logicalId,
|
|
175
248
|
action: 'update',
|
|
176
249
|
resourceType: 'ALIYUN_APIGW',
|
|
177
250
|
changes: {
|
|
178
251
|
before: liveGroupAttrs
|
|
179
|
-
? (0,
|
|
180
|
-
: currentDefinition,
|
|
181
|
-
after: desiredDefinition,
|
|
252
|
+
? (0, planCompare_2.mergeLiveBefore)(currentDefinition, liveGroupAttrs, desiredDefinition)
|
|
253
|
+
: (0, planCompare_1.managedDefinition)(currentDefinition, desiredDefinition),
|
|
254
|
+
after: (0, planCompare_1.managedDefinition)(desiredDefinition),
|
|
182
255
|
},
|
|
183
|
-
|
|
184
|
-
|
|
256
|
+
...((0, planCompare_2.remoteDiffersFromDesired)(liveGroupAttrs ?? {}, currentDefinition) ||
|
|
257
|
+
(domainDiffers &&
|
|
258
|
+
!(0, planCompare_1.definitionsDiffer)({ domain: currentDefinition.domain }, { domain: desiredDefinition.domain })) ||
|
|
259
|
+
(triggersDiffer &&
|
|
260
|
+
!(0, planCompare_1.definitionsDiffer)(currentDefinition, { triggers: desiredDefinition.triggers }))
|
|
261
|
+
? { drifted: true }
|
|
262
|
+
: {}),
|
|
263
|
+
...(triggersDiffer || domainDiffers
|
|
264
|
+
? {
|
|
265
|
+
driftReasons: [
|
|
266
|
+
...(triggersDiffer ? ['PLAN_DRIFT_TRIGGERS'] : []),
|
|
267
|
+
...(domainDiffers ? ['PLAN_DRIFT_EVENT_DOMAIN'] : []),
|
|
268
|
+
],
|
|
269
|
+
}
|
|
270
|
+
: {}),
|
|
185
271
|
};
|
|
186
272
|
}
|
|
187
273
|
return { logicalId, action: 'noop', resourceType: 'ALIYUN_APIGW' };
|
|
@@ -191,13 +277,7 @@ const generateApigwPlan = async (context, state, events, serviceName) => {
|
|
|
191
277
|
logicalId,
|
|
192
278
|
error: error instanceof Error ? error.message : String(error),
|
|
193
279
|
}));
|
|
194
|
-
|
|
195
|
-
logicalId,
|
|
196
|
-
action: 'create',
|
|
197
|
-
resourceType: 'ALIYUN_APIGW',
|
|
198
|
-
changes: { before: currentState.definition, after: desiredDefinition },
|
|
199
|
-
drifted: true,
|
|
200
|
-
};
|
|
280
|
+
throw error;
|
|
201
281
|
}
|
|
202
282
|
});
|
|
203
283
|
// Find resources in state that are no longer in config
|
|
@@ -369,7 +369,7 @@ const buildDomainBindingConfig = async (domain, groupId, serviceName, eventKey,
|
|
|
369
369
|
return {
|
|
370
370
|
groupId,
|
|
371
371
|
domainName: domain.domain_name,
|
|
372
|
-
isHttpRedirectToHttps: protocolConfig.isHttpRedirectToHttps,
|
|
372
|
+
isHttpRedirectToHttps: protocolConfig.isHttpRedirectToHttps ?? false,
|
|
373
373
|
...certConfig,
|
|
374
374
|
};
|
|
375
375
|
};
|
|
@@ -596,7 +596,7 @@ const readApigwResourceByName = async (context, groupName) => {
|
|
|
596
596
|
return await client.apigw.findApiGroupByName(groupName);
|
|
597
597
|
};
|
|
598
598
|
exports.readApigwResourceByName = readApigwResourceByName;
|
|
599
|
-
const updateApigwResource = async (context, event, serviceName, resolveRoleArn, state) => {
|
|
599
|
+
const updateApigwResource = async (context, event, serviceName, resolveRoleArn, state, options) => {
|
|
600
600
|
const logicalId = `events.${event.key}`;
|
|
601
601
|
const existingState = (0, stateManager_1.getResource)(state, logicalId);
|
|
602
602
|
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
@@ -782,7 +782,8 @@ const updateApigwResource = async (context, event, serviceName, resolveRoleArn,
|
|
|
782
782
|
Object.keys(state.resources ?? {}).some((k) => k.startsWith(`${logicalId}.dns_`) &&
|
|
783
783
|
k !== `${logicalId}.dns_verification` &&
|
|
784
784
|
k !== `${logicalId}.dns_txt_verification`);
|
|
785
|
-
if (
|
|
785
|
+
if (!options?.repairDomain &&
|
|
786
|
+
previousDomainDef &&
|
|
786
787
|
desiredDomainDef &&
|
|
787
788
|
hasBoundDomains &&
|
|
788
789
|
(0, hashUtils_1.attributesEqual)(previousDomainDef, desiredDomainDef)) {
|
|
@@ -239,17 +239,13 @@ const extractEventDomainDefinition = (domain) => {
|
|
|
239
239
|
certificateId: domain.certificate_id ?? null,
|
|
240
240
|
certificateBody: domain.certificate_body ?? null,
|
|
241
241
|
certificatePrivateKey: domain.certificate_private_key ? '(managed)' : null,
|
|
242
|
-
protocol: domain.protocol ??
|
|
242
|
+
protocol: domain.protocol ?? 'HTTP',
|
|
243
243
|
};
|
|
244
244
|
const cdnConfig = getDomainCdnConfig(domain);
|
|
245
245
|
if (cdnConfig?.enabled === true) {
|
|
246
246
|
definition.cdnEnabled = true;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
if (cdnConfig.scope != null) {
|
|
251
|
-
definition.cdnScope = cdnConfig.scope;
|
|
252
|
-
}
|
|
247
|
+
definition.cdnType = cdnConfig.cdn_type ?? 'web';
|
|
248
|
+
definition.cdnScope = cdnConfig.scope ?? 'global';
|
|
253
249
|
if (cdnConfig.cache_ttl != null) {
|
|
254
250
|
definition.cdnCacheTtl = cdnConfig.cache_ttl;
|
|
255
251
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deployAliyunStack = exports.buildRoleArnResolver = void 0;
|
|
4
|
+
const refreshPlanner_1 = require("../../common/refreshPlanner");
|
|
4
5
|
const common_1 = require("../../common");
|
|
5
6
|
const lang_1 = require("../../lang");
|
|
6
7
|
const fc3Planner_1 = require("./fc3Planner");
|
|
@@ -110,6 +111,7 @@ const deployAliyunStack = async (iac, backend, approvedPlan) => {
|
|
|
110
111
|
...tablePlan.items,
|
|
111
112
|
...eventPlan.items,
|
|
112
113
|
];
|
|
114
|
+
state = (0, refreshPlanner_1.applyPlanStateUpdates)(state, allItems);
|
|
113
115
|
// Build dependency graph for validation (e.g. cycle detection) and logging
|
|
114
116
|
const dependencyInfo = (0, common_1.getDependencyInfo)(allItems);
|
|
115
117
|
if (dependencyInfo.cycleError) {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.cloudEsToDefinition = exports.extractEsDefinition = exports.databaseToEsConfig = void 0;
|
|
7
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
4
8
|
const lang_1 = require("../../lang");
|
|
5
9
|
// Map database versions to ES versions
|
|
6
10
|
const esVersionMap = new Map([
|
|
@@ -88,10 +92,10 @@ const extractEsDefinition = (config) => {
|
|
|
88
92
|
appVersion: config.appVersion,
|
|
89
93
|
authentication: config.authentication
|
|
90
94
|
? {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
fingerprint: node_crypto_1.default
|
|
96
|
+
.createHash('sha256')
|
|
97
|
+
.update(JSON.stringify(config.authentication))
|
|
98
|
+
.digest('hex'),
|
|
95
99
|
}
|
|
96
100
|
: null,
|
|
97
101
|
quotaInfo: config.quotaInfo
|
|
@@ -13,11 +13,15 @@ const executeCreateAction = async (context, fn, currentState) => {
|
|
|
13
13
|
common_1.logger.info(lang_1.lang.__('RESOURCE_CREATED', { resourceType: 'function', name: fn.name }));
|
|
14
14
|
return newState;
|
|
15
15
|
};
|
|
16
|
-
const executeUpdateAction = async (context, fn, currentState, drifted) => {
|
|
16
|
+
const executeUpdateAction = async (context, fn, currentState, drifted, driftReasons) => {
|
|
17
17
|
common_1.logger.info(lang_1.lang.__('UPDATING_RESOURCE', { resourceType: 'function', name: fn.name }));
|
|
18
18
|
// A drifted plan item means the cloud left the config: force the config
|
|
19
19
|
// re-push even when state-vs-desired sees no change.
|
|
20
|
-
const newState = await (0, fc3Resource_1.updateResource)(context, fn, currentState, {
|
|
20
|
+
const newState = await (0, fc3Resource_1.updateResource)(context, fn, currentState, {
|
|
21
|
+
force: drifted === true,
|
|
22
|
+
...(driftReasons?.includes('PLAN_DRIFT_HTTP_TRIGGER') ? { repairHttp: true } : {}),
|
|
23
|
+
...(driftReasons?.includes('PLAN_DRIFT_FUNCTION_DOMAIN') ? { repairDomain: true } : {}),
|
|
24
|
+
});
|
|
21
25
|
common_1.logger.info(lang_1.lang.__('RESOURCE_UPDATED', { resourceType: 'function', name: fn.name }));
|
|
22
26
|
return newState;
|
|
23
27
|
};
|
|
@@ -44,7 +48,7 @@ const executeSingleItem = async (context, item, functionsMap, currentState) => {
|
|
|
44
48
|
if (!fn) {
|
|
45
49
|
throw new Error(lang_1.lang.__('RESOURCE_FUNCTION_NOT_FOUND', { logicalId: item.logicalId }));
|
|
46
50
|
}
|
|
47
|
-
return executeUpdateAction(context, fn, currentState, item.drifted);
|
|
51
|
+
return executeUpdateAction(context, fn, currentState, item.drifted, item.driftReasons);
|
|
48
52
|
}
|
|
49
53
|
case 'delete': {
|
|
50
54
|
const state = (0, stateManager_1.getResource)(currentState, item.logicalId);
|