@kumori/aurora-backend-handler 1.0.99 → 1.0.111
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/.gitlab-ci.yml +21 -21
- package/CHANGELOG.md +10 -0
- package/api/account-api-service.ts +31 -23
- package/api/deploy-service-helper.ts +84 -68
- package/api/environment-api-service.ts +15 -10
- package/api/marketplace-api-service.ts +31 -80
- package/api/resources-api-service.ts +20 -20
- package/api/service-api-service.ts +18 -14
- package/api/tenant-api-service.ts +130 -242
- package/api/user-api-service.ts +24 -9
- package/backend-handler.ts +374 -348
- package/developer.md +998 -0
- package/event-helper.ts +13 -3
- package/event-names.ts +3 -0
- package/helpers/account-helper.ts +12 -13
- package/helpers/environment-helper.ts +25 -29
- package/helpers/marketplace-helper.ts +109 -0
- package/helpers/resource-helper.ts +19 -1
- package/helpers/revision-helper.ts +68 -18
- package/helpers/service-helper.ts +49 -33
- package/helpers/tenant-helper.ts +0 -5
- package/helpers/token-helper.ts +74 -2
- package/helpers/user-helper.ts +72 -32
- package/jest.config.ts +1 -0
- package/package.json +3 -3
- package/test/backend-handler.test.ts +992 -730
- package/test/deploy-service-helper.test.ts +707 -273
- package/test/event-helper.test.ts +489 -104
- package/test/event-names.test.ts +186 -0
- package/websocket-manager.ts +394 -69
package/.gitlab-ci.yml
CHANGED
|
@@ -18,27 +18,27 @@ install:
|
|
|
18
18
|
paths:
|
|
19
19
|
- node_modules/
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
21
|
+
test:
|
|
22
|
+
stage: test
|
|
23
|
+
image: node:16-alpine
|
|
24
|
+
tags:
|
|
25
|
+
- docker
|
|
26
|
+
dependencies:
|
|
27
|
+
- install
|
|
28
|
+
script:
|
|
29
|
+
- npm install --no-save jest-junit
|
|
30
|
+
- npm run test
|
|
31
|
+
coverage: '/All files.*?\|\s*[\d\.]+\s*\|\s*[\d\.]+\s*\|\s*[\d\.]+\s*\|\s*([\d\.]+)/'
|
|
32
|
+
artifacts:
|
|
33
|
+
when: always
|
|
34
|
+
paths:
|
|
35
|
+
- report.xml
|
|
36
|
+
reports:
|
|
37
|
+
junit: report.xml
|
|
38
|
+
only:
|
|
39
|
+
- merge_requests
|
|
40
|
+
- master
|
|
41
|
+
- tags
|
|
42
42
|
|
|
43
43
|
release:
|
|
44
44
|
stage: release
|
package/CHANGELOG.md
ADDED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Account, Notification } from "@kumori/aurora-interfaces";
|
|
1
|
+
import { Account, errors, Notification } from "@kumori/aurora-interfaces";
|
|
2
2
|
import {
|
|
3
3
|
initializeGlobalWebSocketClient,
|
|
4
4
|
getWebSocketStatus,
|
|
@@ -8,6 +8,13 @@ import { eventHelper } from "../backend-handler";
|
|
|
8
8
|
|
|
9
9
|
type Security = string;
|
|
10
10
|
function extractErrorInfo(error: unknown): { code: string; message: string } {
|
|
11
|
+
if ((error as any)?.isTimeout) {
|
|
12
|
+
return {
|
|
13
|
+
code: "timeout",
|
|
14
|
+
message:
|
|
15
|
+
"The request is taking too long, but it does not mean it failed. If you need more help, please contact support.",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
11
18
|
const err = (error as any)?.error;
|
|
12
19
|
return {
|
|
13
20
|
code: err?.code ?? "unknown_error",
|
|
@@ -630,7 +637,7 @@ export const createAccount = async (account: Account, security: Security) => {
|
|
|
630
637
|
|
|
631
638
|
const accountErrorNotification: Notification = {
|
|
632
639
|
type: "error",
|
|
633
|
-
subtype:
|
|
640
|
+
subtype: errors.account.creationError.subtype,
|
|
634
641
|
info_content: {
|
|
635
642
|
code,
|
|
636
643
|
message,
|
|
@@ -729,7 +736,7 @@ export const deleteAccount = async (account: Account, security: Security) => {
|
|
|
729
736
|
|
|
730
737
|
const accountNotification: Notification = {
|
|
731
738
|
type: "success",
|
|
732
|
-
subtype:
|
|
739
|
+
subtype: errors.account.deleting.subtype,
|
|
733
740
|
date: Date.now().toString(),
|
|
734
741
|
status: "unread",
|
|
735
742
|
callToAction: false,
|
|
@@ -747,7 +754,7 @@ export const deleteAccount = async (account: Account, security: Security) => {
|
|
|
747
754
|
|
|
748
755
|
const accountErrorNotification: Notification = {
|
|
749
756
|
type: "error",
|
|
750
|
-
subtype:
|
|
757
|
+
subtype: errors.account.deletionError.subtype,
|
|
751
758
|
date: Date.now().toString(),
|
|
752
759
|
info_content: {
|
|
753
760
|
code,
|
|
@@ -790,7 +797,7 @@ export const clearAccount = async (account: Account, security: Security) => {
|
|
|
790
797
|
eventHelper.account.publish.cleaned(updatedAccount);
|
|
791
798
|
const accountNotification: Notification = {
|
|
792
799
|
type: "success",
|
|
793
|
-
subtype:
|
|
800
|
+
subtype: errors.account.cleaned.subtype,
|
|
794
801
|
date: Date.now().toString(),
|
|
795
802
|
status: "unread",
|
|
796
803
|
callToAction: false,
|
|
@@ -808,7 +815,7 @@ export const clearAccount = async (account: Account, security: Security) => {
|
|
|
808
815
|
|
|
809
816
|
const accountErrorNotification: Notification = {
|
|
810
817
|
type: "error",
|
|
811
|
-
subtype:
|
|
818
|
+
subtype: errors.account.cleanError.subtype,
|
|
812
819
|
date: Date.now().toString(),
|
|
813
820
|
info_content: {
|
|
814
821
|
code,
|
|
@@ -1422,24 +1429,25 @@ export const updateAccount = async (account: Account, security: Security) => {
|
|
|
1422
1429
|
provider: account.cloudProvider?.name,
|
|
1423
1430
|
});
|
|
1424
1431
|
eventHelper.account.publish.updateError(account);
|
|
1425
|
-
|
|
1432
|
+
const { code, message } = extractErrorInfo(error);
|
|
1426
1433
|
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1434
|
+
const accountErrorNotification: Notification = {
|
|
1435
|
+
type: "error",
|
|
1436
|
+
subtype: errors.account.updateError.subtype,
|
|
1437
|
+
date: Date.now().toString(),
|
|
1438
|
+
info_content: {
|
|
1439
|
+
code,
|
|
1440
|
+
message,
|
|
1441
|
+
},
|
|
1442
|
+
status: "unread",
|
|
1443
|
+
callToAction: false,
|
|
1444
|
+
data: {
|
|
1445
|
+
account: account.name,
|
|
1446
|
+
tenant: account.tenant,
|
|
1447
|
+
},
|
|
1448
|
+
userError: true,
|
|
1449
|
+
};
|
|
1450
|
+
eventHelper.notification.publish.creation(accountErrorNotification);
|
|
1443
1451
|
throw error;
|
|
1444
1452
|
}
|
|
1445
1453
|
};
|
|
@@ -84,6 +84,8 @@ export interface ServiceSpecForm {
|
|
|
84
84
|
cpuRequirements: number;
|
|
85
85
|
memoryRequirements: number;
|
|
86
86
|
registryUrl: string;
|
|
87
|
+
registryCredentialsSecret?: string;
|
|
88
|
+
registryCredentialSecret?: string;
|
|
87
89
|
imageTag: string;
|
|
88
90
|
clientChannels: Array<{ name: string }>;
|
|
89
91
|
channels: Array<{
|
|
@@ -98,6 +100,7 @@ export interface ServiceSpecForm {
|
|
|
98
100
|
certificateResource?: string;
|
|
99
101
|
withMtls?: boolean;
|
|
100
102
|
caResource?: string;
|
|
103
|
+
gatewayName?: string;
|
|
101
104
|
}>;
|
|
102
105
|
clientChannelsExtra?: Array<{ name: string }>;
|
|
103
106
|
defaultExecutable: { cmd?: string; entryPoint?: string };
|
|
@@ -136,6 +139,7 @@ export interface ServiceSpecForm {
|
|
|
136
139
|
};
|
|
137
140
|
histeresys: string;
|
|
138
141
|
};
|
|
142
|
+
hsize?: number;
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
export interface ServiceWithLocalComponentSpec {
|
|
@@ -180,7 +184,8 @@ interface ArtifactConfigParameterDto {
|
|
|
180
184
|
type ParameterTypeDto = "string" | "number" | "bool";
|
|
181
185
|
type ComponentEnvironmentDto =
|
|
182
186
|
| ComponentEnvironmentParamDto
|
|
183
|
-
| ComponentEnvironmentSecretDto
|
|
187
|
+
| ComponentEnvironmentSecretDto
|
|
188
|
+
| ComponentEnvironmentValueDto;
|
|
184
189
|
interface ComponentEnvironmentParamDto {
|
|
185
190
|
varName: string;
|
|
186
191
|
param: string;
|
|
@@ -189,6 +194,10 @@ interface ComponentEnvironmentSecretDto {
|
|
|
189
194
|
varName: string;
|
|
190
195
|
secret: string;
|
|
191
196
|
}
|
|
197
|
+
interface ComponentEnvironmentValueDto {
|
|
198
|
+
varName: string;
|
|
199
|
+
value: string;
|
|
200
|
+
}
|
|
192
201
|
type ArtifactConfigResource =
|
|
193
202
|
| CA<ArtifactConfigResourceSpec>
|
|
194
203
|
| Secret<ArtifactConfigResourceSpec>
|
|
@@ -218,13 +227,21 @@ interface Port<VARIANT> {
|
|
|
218
227
|
interface Certificate<VARIANT> {
|
|
219
228
|
certificate: VARIANT;
|
|
220
229
|
}
|
|
221
|
-
type ComponentFilesystemDto =
|
|
230
|
+
type ComponentFilesystemDto =
|
|
231
|
+
| FilesystemVolumeDto
|
|
232
|
+
| FilesystemSecretDto
|
|
233
|
+
| FilesystemFileDto;
|
|
222
234
|
|
|
223
235
|
interface FilesystemVolumeDto {
|
|
224
236
|
path: string;
|
|
225
237
|
resourceVolume: string;
|
|
226
238
|
}
|
|
227
239
|
|
|
240
|
+
interface FilesystemSecretDto {
|
|
241
|
+
path: string;
|
|
242
|
+
resourceSecret: string;
|
|
243
|
+
}
|
|
244
|
+
|
|
228
245
|
interface FilesystemFileDto {
|
|
229
246
|
path: string;
|
|
230
247
|
param?: string;
|
|
@@ -378,6 +395,13 @@ export function handleParametersToGenerateData(
|
|
|
378
395
|
});
|
|
379
396
|
break;
|
|
380
397
|
|
|
398
|
+
case "clientChannel":
|
|
399
|
+
environmentResult.push({
|
|
400
|
+
varName: parameter.name,
|
|
401
|
+
value: `0.${parameter.value}`,
|
|
402
|
+
});
|
|
403
|
+
break;
|
|
404
|
+
|
|
381
405
|
default:
|
|
382
406
|
console.warn(`Unknown parameter type: ${parameter.type}`);
|
|
383
407
|
parametersResult.push({
|
|
@@ -396,10 +420,17 @@ export function handleParametersToGenerateData(
|
|
|
396
420
|
switch (resource.type) {
|
|
397
421
|
case "secret":
|
|
398
422
|
resourcesResult.push({ secret: { name: resource.name } });
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
423
|
+
if (resource.key) {
|
|
424
|
+
fileSystemResult.push({
|
|
425
|
+
path: resource.key,
|
|
426
|
+
resourceSecret: resource.name,
|
|
427
|
+
});
|
|
428
|
+
} else {
|
|
429
|
+
environmentResult.push({
|
|
430
|
+
varName: resource.name,
|
|
431
|
+
secret: resource.name as string,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
403
434
|
break;
|
|
404
435
|
case "volume":
|
|
405
436
|
resourcesResult.push({ volume: { name: resource.name } });
|
|
@@ -436,7 +467,6 @@ export function handleParametersToGenerateData(
|
|
|
436
467
|
* @returns A ServiceSpecForm object with the data of the service.
|
|
437
468
|
*/
|
|
438
469
|
export function transformServiceToForm(service: Service): ServiceSpecForm {
|
|
439
|
-
console.log('--- TRANSFORM SERVICE TO FORM ---', service.name);
|
|
440
470
|
return {
|
|
441
471
|
tenantId: service.tenant,
|
|
442
472
|
accountId: service.account,
|
|
@@ -445,6 +475,7 @@ export function transformServiceToForm(service: Service): ServiceSpecForm {
|
|
|
445
475
|
cpuRequirements: service.usage.limit.cpu.max,
|
|
446
476
|
memoryRequirements: service.usage.limit.memory.max,
|
|
447
477
|
registryUrl: service.registry,
|
|
478
|
+
registryCredentialsSecret: service.registryCredentialSecret,
|
|
448
479
|
imageTag: service.imageName,
|
|
449
480
|
clientChannels: service.clientChannels.map((ch) => ({ name: ch.name })),
|
|
450
481
|
channels: service.serverChannels.map((ch) => ({
|
|
@@ -462,6 +493,7 @@ export function transformServiceToForm(service: Service): ServiceSpecForm {
|
|
|
462
493
|
certificateResource: ch.certificateResource,
|
|
463
494
|
withMtls: ch.withMtls,
|
|
464
495
|
caResource: ch.caResource,
|
|
496
|
+
gatewayName: ch.gatewayName,
|
|
465
497
|
})),
|
|
466
498
|
clientChannelsExtra: service.duplexChannels.map((ch) => ({
|
|
467
499
|
name: ch.name,
|
|
@@ -486,13 +518,22 @@ export function transformServiceToForm(service: Service): ServiceSpecForm {
|
|
|
486
518
|
})),
|
|
487
519
|
},
|
|
488
520
|
environment: [service.environment],
|
|
489
|
-
fileSystem:
|
|
490
|
-
.
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
521
|
+
fileSystem: [
|
|
522
|
+
...service.resources
|
|
523
|
+
.filter((resource) => resource.type === "volume")
|
|
524
|
+
.map((resource) => ({
|
|
525
|
+
path: resource.key,
|
|
526
|
+
resourceVolume: resource.name,
|
|
527
|
+
})),
|
|
528
|
+
...service.resources
|
|
529
|
+
.filter((resource) => resource.type === "secret" && resource.key)
|
|
530
|
+
.map((resource) => ({
|
|
531
|
+
path: resource.key,
|
|
532
|
+
resourceSecret: resource.name,
|
|
533
|
+
})),
|
|
534
|
+
],
|
|
495
535
|
scaling: service.role[0].scalling,
|
|
536
|
+
hsize: service.role[0].hsize
|
|
496
537
|
};
|
|
497
538
|
}
|
|
498
539
|
/**
|
|
@@ -513,15 +554,12 @@ export async function generateServiceSpec(
|
|
|
513
554
|
resources: componentResources,
|
|
514
555
|
} = handleParametersToGenerateData(formParams, formResources);
|
|
515
556
|
|
|
516
|
-
console.log('--- GENERATE SERVICE SPEC ---', form.serviceId);
|
|
517
|
-
console.log('Channels from Form:', JSON.stringify(form.channels));
|
|
518
|
-
|
|
519
557
|
const serverConfigDomainResources: ArtifactConfigResource[] = form.channels
|
|
520
558
|
.filter((channel) => channel.protocol === "HTTPS" && channel.isPublic)
|
|
521
559
|
.map((channel) => ({ domain: { name: `${channel.channelName}_domain` } }));
|
|
522
560
|
|
|
523
561
|
const hasDefaultCertChannel = form.channels.some(
|
|
524
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource
|
|
562
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource,
|
|
525
563
|
);
|
|
526
564
|
if (hasDefaultCertChannel) {
|
|
527
565
|
serverConfigDomainResources.push({
|
|
@@ -531,23 +569,17 @@ export async function generateServiceSpec(
|
|
|
531
569
|
|
|
532
570
|
const customCertResources: ArtifactConfigResource[] = form.channels
|
|
533
571
|
.filter(
|
|
534
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource
|
|
572
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource,
|
|
535
573
|
)
|
|
536
574
|
.map((ch) => ({ certificate: { name: `${ch.channelName}_cert` } }));
|
|
537
575
|
|
|
538
576
|
const customCaResources: ArtifactConfigResource[] = form.channels
|
|
539
577
|
.filter(
|
|
540
578
|
(ch) =>
|
|
541
|
-
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource
|
|
579
|
+
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource,
|
|
542
580
|
)
|
|
543
581
|
.map((ch) => ({ ca: { name: `${ch.channelName}_ca` } }));
|
|
544
582
|
|
|
545
|
-
console.log('Generated Resources Spec:', {
|
|
546
|
-
serverConfigDomainResources,
|
|
547
|
-
customCertResources,
|
|
548
|
-
customCaResources
|
|
549
|
-
});
|
|
550
|
-
|
|
551
583
|
const serviceConfigPortResources: ArtifactConfigResource[] = form.channels
|
|
552
584
|
.filter((channel) => channel.protocol === "TCP" && channel.isPublic)
|
|
553
585
|
.map((channel) => ({ port: { name: `${channel.channelName}_port` } }));
|
|
@@ -636,7 +668,7 @@ export async function generateServiceSpec(
|
|
|
636
668
|
.map((channel) => {
|
|
637
669
|
if (channel.protocol === "HTTPS") {
|
|
638
670
|
return {
|
|
639
|
-
name: `${channel.channelName}_inbound`,
|
|
671
|
+
name: channel.gatewayName || `${channel.channelName}_inbound`,
|
|
640
672
|
artifact: {
|
|
641
673
|
artifactKind: "service",
|
|
642
674
|
moduleDomain: "kumori.systems",
|
|
@@ -679,7 +711,7 @@ export async function generateServiceSpec(
|
|
|
679
711
|
};
|
|
680
712
|
}
|
|
681
713
|
return {
|
|
682
|
-
name: `${channel.channelName}_inbound`,
|
|
714
|
+
name: channel.gatewayName || `${channel.channelName}_inbound`,
|
|
683
715
|
artifact: {
|
|
684
716
|
artifactKind: "service",
|
|
685
717
|
moduleDomain: " ",
|
|
@@ -713,7 +745,7 @@ export async function generateServiceSpec(
|
|
|
713
745
|
];
|
|
714
746
|
if (channel.isPublic) {
|
|
715
747
|
result.push({
|
|
716
|
-
clientRole: `${channel.channelName}_inbound`,
|
|
748
|
+
clientRole: channel.gatewayName || `${channel.channelName}_inbound`,
|
|
717
749
|
clientChannel: "inbound",
|
|
718
750
|
serverRole: withDefaultValue(form.serviceId, ""),
|
|
719
751
|
serverChannel: channel.channelName,
|
|
@@ -891,7 +923,7 @@ export async function generateServiceSpec(
|
|
|
891
923
|
}));
|
|
892
924
|
|
|
893
925
|
const hasDefaultCertChannelDeployment = form.channels.some(
|
|
894
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource
|
|
926
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource,
|
|
895
927
|
);
|
|
896
928
|
if (hasDefaultCertChannelDeployment) {
|
|
897
929
|
deploymentConfigDomain.push({
|
|
@@ -904,7 +936,7 @@ export async function generateServiceSpec(
|
|
|
904
936
|
|
|
905
937
|
const customCertDeploymentResources: DeploymentResource[] = form.channels
|
|
906
938
|
.filter(
|
|
907
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource
|
|
939
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource,
|
|
908
940
|
)
|
|
909
941
|
.map((ch) => ({
|
|
910
942
|
certificate: {
|
|
@@ -916,7 +948,7 @@ export async function generateServiceSpec(
|
|
|
916
948
|
const customCaDeploymentResources: DeploymentResource[] = form.channels
|
|
917
949
|
.filter(
|
|
918
950
|
(ch) =>
|
|
919
|
-
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource
|
|
951
|
+
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource,
|
|
920
952
|
)
|
|
921
953
|
.map((ch) => ({
|
|
922
954
|
ca: {
|
|
@@ -1065,7 +1097,7 @@ export async function generateServiceSpec(
|
|
|
1065
1097
|
detail: (marketplaceItem.roles ?? []).reduce(
|
|
1066
1098
|
(acc, role) => ({
|
|
1067
1099
|
...acc,
|
|
1068
|
-
[withDefaultValue(role, "")]: 1,
|
|
1100
|
+
[withDefaultValue(role, "")]: (marketplaceItem.deploymentData.role ?? []).find((r) => r.name === withDefaultValue(role, ""))?.hsize || 1,
|
|
1069
1101
|
}),
|
|
1070
1102
|
{},
|
|
1071
1103
|
),
|
|
@@ -1108,7 +1140,7 @@ export async function generateServiceSpec(
|
|
|
1108
1140
|
],
|
|
1109
1141
|
scale: {
|
|
1110
1142
|
detail: {
|
|
1111
|
-
[withDefaultValue(form.serviceId, "")]: 1,
|
|
1143
|
+
[withDefaultValue(form.serviceId, "")]: form.hsize || 1,
|
|
1112
1144
|
},
|
|
1113
1145
|
},
|
|
1114
1146
|
meta: autoscalingDefined
|
|
@@ -1139,13 +1171,12 @@ async function generateServiceSpecDSL(
|
|
|
1139
1171
|
fileSystem,
|
|
1140
1172
|
resources: componentResources,
|
|
1141
1173
|
} = handleParametersToGenerateData(formParams, formResources);
|
|
1142
|
-
|
|
1143
1174
|
const serverConfigDomainResources: ArtifactConfigResource[] = form.channels
|
|
1144
1175
|
.filter((channel) => channel.protocol === "HTTPS" && channel.isPublic)
|
|
1145
1176
|
.map((channel) => ({ domain: { name: `${channel.channelName}_domain` } }));
|
|
1146
1177
|
|
|
1147
1178
|
const hasDefaultCertChannel = form.channels.some(
|
|
1148
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource
|
|
1179
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource,
|
|
1149
1180
|
);
|
|
1150
1181
|
if (hasDefaultCertChannel) {
|
|
1151
1182
|
serverConfigDomainResources.push({
|
|
@@ -1155,23 +1186,17 @@ async function generateServiceSpecDSL(
|
|
|
1155
1186
|
|
|
1156
1187
|
const customCertResources: ArtifactConfigResource[] = form.channels
|
|
1157
1188
|
.filter(
|
|
1158
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource
|
|
1189
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource,
|
|
1159
1190
|
)
|
|
1160
1191
|
.map((ch) => ({ certificate: { name: `${ch.channelName}_cert` } }));
|
|
1161
1192
|
|
|
1162
1193
|
const customCaResources: ArtifactConfigResource[] = form.channels
|
|
1163
1194
|
.filter(
|
|
1164
1195
|
(ch) =>
|
|
1165
|
-
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource
|
|
1196
|
+
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource,
|
|
1166
1197
|
)
|
|
1167
1198
|
.map((ch) => ({ ca: { name: `${ch.channelName}_ca` } }));
|
|
1168
1199
|
|
|
1169
|
-
console.log('Generated Resources Config:', {
|
|
1170
|
-
serverConfigDomainResources,
|
|
1171
|
-
customCertResources,
|
|
1172
|
-
customCaResources
|
|
1173
|
-
});
|
|
1174
|
-
|
|
1175
1200
|
const serviceConfigPortResources: ArtifactConfigResource[] = form.channels
|
|
1176
1201
|
.filter((channel) => channel.protocol === "TCP" && channel.isPublic)
|
|
1177
1202
|
.map((channel) => ({ port: { name: `${channel.channelName}_port` } }));
|
|
@@ -1256,7 +1281,7 @@ async function generateServiceSpecDSL(
|
|
|
1256
1281
|
.map((channel) => {
|
|
1257
1282
|
if (channel.protocol === "HTTPS") {
|
|
1258
1283
|
return {
|
|
1259
|
-
name: `${channel.channelName}_inbound`,
|
|
1284
|
+
name: channel.gatewayName || `${channel.channelName}_inbound`,
|
|
1260
1285
|
artifact: {
|
|
1261
1286
|
artifactKind: "service" as const,
|
|
1262
1287
|
moduleDomain: "kumori",
|
|
@@ -1299,7 +1324,7 @@ async function generateServiceSpecDSL(
|
|
|
1299
1324
|
};
|
|
1300
1325
|
}
|
|
1301
1326
|
return {
|
|
1302
|
-
name: `${channel.channelName}_inbound`,
|
|
1327
|
+
name: channel.gatewayName || `${channel.channelName}_inbound`,
|
|
1303
1328
|
artifact: {
|
|
1304
1329
|
artifactKind: "service" as const,
|
|
1305
1330
|
moduleDomain: "kumori",
|
|
@@ -1334,7 +1359,7 @@ async function generateServiceSpecDSL(
|
|
|
1334
1359
|
];
|
|
1335
1360
|
if (channel.isPublic) {
|
|
1336
1361
|
result.push({
|
|
1337
|
-
clientRole: `${channel.channelName}_inbound`,
|
|
1362
|
+
clientRole: channel.gatewayName || `${channel.channelName}_inbound`,
|
|
1338
1363
|
clientChannel: "inbound",
|
|
1339
1364
|
serverRole: withDefaultValue(form.serviceId, ""),
|
|
1340
1365
|
serverChannel: channel.channelName,
|
|
@@ -1458,7 +1483,7 @@ async function generateServiceSpecDSL(
|
|
|
1458
1483
|
}));
|
|
1459
1484
|
|
|
1460
1485
|
const hasDefaultCertChannelDeployment = form.channels.some(
|
|
1461
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource
|
|
1486
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource,
|
|
1462
1487
|
);
|
|
1463
1488
|
if (hasDefaultCertChannelDeployment) {
|
|
1464
1489
|
deploymentConfigDomain.push({
|
|
@@ -1471,7 +1496,7 @@ async function generateServiceSpecDSL(
|
|
|
1471
1496
|
|
|
1472
1497
|
const customCertDeploymentResources: DeploymentResource[] = form.channels
|
|
1473
1498
|
.filter(
|
|
1474
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource
|
|
1499
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource,
|
|
1475
1500
|
)
|
|
1476
1501
|
.map((ch) => ({
|
|
1477
1502
|
certificate: {
|
|
@@ -1483,7 +1508,7 @@ async function generateServiceSpecDSL(
|
|
|
1483
1508
|
const customCaDeploymentResources: DeploymentResource[] = form.channels
|
|
1484
1509
|
.filter(
|
|
1485
1510
|
(ch) =>
|
|
1486
|
-
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource
|
|
1511
|
+
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource,
|
|
1487
1512
|
)
|
|
1488
1513
|
.map((ch) => ({
|
|
1489
1514
|
ca: {
|
|
@@ -1492,12 +1517,6 @@ async function generateServiceSpecDSL(
|
|
|
1492
1517
|
},
|
|
1493
1518
|
}));
|
|
1494
1519
|
|
|
1495
|
-
console.log('Generated Deployment Resources:', {
|
|
1496
|
-
deploymentConfigDomain,
|
|
1497
|
-
customCertDeploymentResources,
|
|
1498
|
-
customCaDeploymentResources
|
|
1499
|
-
});
|
|
1500
|
-
|
|
1501
1520
|
const deploymentConfigPort: DeploymentResource[] = form.channels
|
|
1502
1521
|
.filter((channel) => channel.protocol === "TCP" && channel.isPublic)
|
|
1503
1522
|
.map((channel) => ({
|
|
@@ -1520,7 +1539,6 @@ async function generateServiceSpecDSL(
|
|
|
1520
1539
|
} = {
|
|
1521
1540
|
simple: {},
|
|
1522
1541
|
};
|
|
1523
|
-
|
|
1524
1542
|
scaling.simple[form.serviceId] = {
|
|
1525
1543
|
scale_up: {
|
|
1526
1544
|
cpu: parseInt(form.scaling?.cpu.up || "") || 0,
|
|
@@ -1534,7 +1552,7 @@ async function generateServiceSpecDSL(
|
|
|
1534
1552
|
min_replicas: form.scaling?.instances.min || 0,
|
|
1535
1553
|
max_replicas: form.scaling?.instances.max || 0,
|
|
1536
1554
|
};
|
|
1537
|
-
|
|
1555
|
+
const autoscalingDefined = form.scaling;
|
|
1538
1556
|
const hasMarketplacePackage = marketplaceItem?.package;
|
|
1539
1557
|
|
|
1540
1558
|
const serviceSpec: ServiceSpecDSLWithLocalComponent = {
|
|
@@ -1630,14 +1648,13 @@ async function generateServiceSpecDSL(
|
|
|
1630
1648
|
],
|
|
1631
1649
|
scale: {
|
|
1632
1650
|
detail: {
|
|
1633
|
-
[withDefaultValue(form.serviceId, "")]: 1,
|
|
1651
|
+
[withDefaultValue(form.serviceId, "")]: form.hsize || 1,
|
|
1634
1652
|
},
|
|
1635
1653
|
},
|
|
1636
1654
|
meta: {
|
|
1637
|
-
deploymentMeta: {
|
|
1638
1655
|
environment: form.environment || [],
|
|
1639
1656
|
team: "development",
|
|
1640
|
-
|
|
1657
|
+
scaling: autoscalingDefined ? scaling : {}
|
|
1641
1658
|
},
|
|
1642
1659
|
},
|
|
1643
1660
|
};
|
|
@@ -1673,13 +1690,13 @@ async function generateServiceSpecDSL(
|
|
|
1673
1690
|
memoryRequirements: withDefaultValue(form.memoryRequirements, 0) * 1000,
|
|
1674
1691
|
registryUrl: withDefaultValue(form.registryUrl, "docker.io").trim(),
|
|
1675
1692
|
imageTag: withDefaultValue(form.imageTag, "").trim(),
|
|
1676
|
-
registryCredentialsSecret: form.
|
|
1677
|
-
.
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1693
|
+
registryCredentialsSecret: form.registryCredentialsSecret
|
|
1694
|
+
? form.config.resources.find(
|
|
1695
|
+
(r) => r.type === "secret" && r.name === form.registryCredentialsSecret,
|
|
1696
|
+
)?.name
|
|
1697
|
+
: form.config.resources.find(
|
|
1698
|
+
(r) => r.type === "secret" && r.key === "registryCredentials",
|
|
1699
|
+
)?.name,
|
|
1683
1700
|
config: {
|
|
1684
1701
|
parameters,
|
|
1685
1702
|
resources: componentResources,
|
|
@@ -1718,7 +1735,6 @@ export async function deployServiceHelper(
|
|
|
1718
1735
|
serviceForm,
|
|
1719
1736
|
marketplaceItem,
|
|
1720
1737
|
);
|
|
1721
|
-
console.log('Final generated ServiceSpecDSL:', JSON.stringify(serviceSpecDSL, null, 2));
|
|
1722
1738
|
CUEBundle = buildServiceDeploymentModule(serviceSpecDSL);
|
|
1723
1739
|
|
|
1724
1740
|
// if (marketplaceItem?.package) {
|