@uofx/cli 1.0.0
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/LICENSE +40 -0
- package/README.md +444 -0
- package/THIRD-PARTY-NOTICES.txt +894 -0
- package/dist/application/dtos/index.js +24 -0
- package/dist/application/dtos/request/delete-instance.request.dto.js +3 -0
- package/dist/application/dtos/request/get-config.request.dto.js +3 -0
- package/dist/application/dtos/request/get-credentials.request.dto.js +3 -0
- package/dist/application/dtos/request/index.js +27 -0
- package/dist/application/dtos/request/install-instance.request.dto.js +3 -0
- package/dist/application/dtos/request/list-charts.request.dto.js +3 -0
- package/dist/application/dtos/request/set-config.request.dto.js +16 -0
- package/dist/application/dtos/request/setup-environment.request.dto.js +16 -0
- package/dist/application/dtos/request/show-logs.request.dto.js +19 -0
- package/dist/application/dtos/request/start-instance.request.dto.js +3 -0
- package/dist/application/dtos/request/stop-instance.request.dto.js +3 -0
- package/dist/application/dtos/response/credentials.response.dto.js +3 -0
- package/dist/application/dtos/response/delete-instance.response.dto.js +3 -0
- package/dist/application/dtos/response/index.js +26 -0
- package/dist/application/dtos/response/install-instance.response.dto.js +3 -0
- package/dist/application/dtos/response/instance-list.response.dto.js +3 -0
- package/dist/application/dtos/response/instance-status.response.dto.js +3 -0
- package/dist/application/dtos/response/setup-result.response.dto.js +3 -0
- package/dist/application/dtos/response/show-logs.response.dto.js +3 -0
- package/dist/application/dtos/response/start-instance.response.dto.js +3 -0
- package/dist/application/dtos/response/stop-instance.response.dto.js +3 -0
- package/dist/application/index.js +25 -0
- package/dist/application/interfaces/index.js +24 -0
- package/dist/application/interfaces/use-case.interface.js +3 -0
- package/dist/application/use-cases/config/get-config.use-case.js +66 -0
- package/dist/application/use-cases/config/set-config.use-case.js +49 -0
- package/dist/application/use-cases/credentials/get-credentials.use-case.js +57 -0
- package/dist/application/use-cases/index.js +28 -0
- package/dist/application/use-cases/instance/delete-instance.use-case.js +81 -0
- package/dist/application/use-cases/instance/index.js +23 -0
- package/dist/application/use-cases/instance/install-instance.use-case.js +424 -0
- package/dist/application/use-cases/instance/list-charts.use-case.js +43 -0
- package/dist/application/use-cases/instance/list-instances.use-case.js +62 -0
- package/dist/application/use-cases/instance/start-instance.use-case.js +154 -0
- package/dist/application/use-cases/instance/stop-instance.use-case.js +55 -0
- package/dist/application/use-cases/logs/show-logs.use-case.js +66 -0
- package/dist/application/use-cases/setup/setup-environment.use-case.js +53 -0
- package/dist/cli.js +286 -0
- package/dist/constants/config-defaults.js +23 -0
- package/dist/constants/defaults.js +89 -0
- package/dist/constants/deployment.js +39 -0
- package/dist/constants/environments.js +93 -0
- package/dist/constants/index.js +53 -0
- package/dist/constants/oci-artifacts.js +25 -0
- package/dist/constants/paths.js +92 -0
- package/dist/constants/timeouts.js +60 -0
- package/dist/di/container.js +34 -0
- package/dist/di/index.js +22 -0
- package/dist/di/modules/application.module.js +54 -0
- package/dist/di/modules/infrastructure.module.js +206 -0
- package/dist/di/modules/interceptor.module.js +68 -0
- package/dist/di/modules/presentation.module.js +31 -0
- package/dist/di/tokens.js +149 -0
- package/dist/domain/decorators/sensitive.decorator.js +39 -0
- package/dist/domain/entities/credentials-resolver.entity.js +127 -0
- package/dist/domain/entities/credentials.entity.js +65 -0
- package/dist/domain/entities/delete-instance-validation.entity.js +100 -0
- package/dist/domain/entities/deployment-parameters.entity.js +120 -0
- package/dist/domain/entities/environment-validation.entity.js +125 -0
- package/dist/domain/entities/index.js +29 -0
- package/dist/domain/entities/instance-lifecycle-state.entity.js +100 -0
- package/dist/domain/entities/instance-list-aggregator.entity.js +104 -0
- package/dist/domain/entities/instance-metadata.entity.js +86 -0
- package/dist/domain/entities/instance-status.entity.js +79 -0
- package/dist/domain/entities/instance.entity.js +128 -0
- package/dist/domain/entities/log-filter.entity.js +141 -0
- package/dist/domain/index.js +29 -0
- package/dist/domain/interfaces/safe-loggable.interface.js +3 -0
- package/dist/domain/ports/app-config.port.js +3 -0
- package/dist/domain/ports/base-image.port.js +3 -0
- package/dist/domain/ports/chart-version.port.js +3 -0
- package/dist/domain/ports/correlation-id.port.js +3 -0
- package/dist/domain/ports/credentials.port.js +3 -0
- package/dist/domain/ports/deployment.port.js +3 -0
- package/dist/domain/ports/error-handler.port.js +3 -0
- package/dist/domain/ports/index.js +46 -0
- package/dist/domain/ports/instance-manager.port.js +3 -0
- package/dist/domain/ports/instance-metadata.port.js +8 -0
- package/dist/domain/ports/instance-storage.port.js +3 -0
- package/dist/domain/ports/k8s-deployer.port.js +3 -0
- package/dist/domain/ports/logger.port.js +14 -0
- package/dist/domain/ports/output.port.js +3 -0
- package/dist/domain/ports/runtime-environment.port.js +6 -0
- package/dist/domain/ports/user-interaction.port.js +9 -0
- package/dist/domain/ports/user-settings.port.js +3 -0
- package/dist/domain/types/index.js +22 -0
- package/dist/domain/types/logger.types.js +29 -0
- package/dist/domain/types/validation.types.js +9 -0
- package/dist/domain/value-objects/acr-credentials.value-object.js +92 -0
- package/dist/domain/value-objects/chart-version.value-object.js +124 -0
- package/dist/domain/value-objects/config-log-level.value-object.js +84 -0
- package/dist/domain/value-objects/connection-info.value-object.js +65 -0
- package/dist/domain/value-objects/index.js +25 -0
- package/dist/domain/value-objects/instance-name.value-object.js +91 -0
- package/dist/domain/value-objects/jwt-key.value-object.js +97 -0
- package/dist/domain/value-objects/mssql-password.value-object.js +140 -0
- package/dist/domain/value-objects/rsa-key-pair.value-object.js +181 -0
- package/dist/index.js +6 -0
- package/dist/infrastructure/config/app-config.interface.js +3 -0
- package/dist/infrastructure/config/app-config.service.js +280 -0
- package/dist/infrastructure/config/config-validator.js +31 -0
- package/dist/infrastructure/config/crypto.service.js +125 -0
- package/dist/infrastructure/deployment/deployment.adapter.js +118 -0
- package/dist/infrastructure/deployment/interfaces/acr-credential-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/app-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/helm-registry.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/infra-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/k8s-job-runner.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/mssql-database-init.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/mssql-helm-deployment.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/mssql-storage.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/mssql-user-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/oci-artifact.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/secret-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/service-manager.interface.js +3 -0
- package/dist/infrastructure/deployment/interfaces/version-compatibility.interface.js +3 -0
- package/dist/infrastructure/deployment/services/acr-credential-manager.service.js +144 -0
- package/dist/infrastructure/deployment/services/app-manager.service.js +193 -0
- package/dist/infrastructure/deployment/services/base-helm-deployment.service.js +163 -0
- package/dist/infrastructure/deployment/services/helm-registry.service.js +126 -0
- package/dist/infrastructure/deployment/services/infra-manager.service.js +130 -0
- package/dist/infrastructure/deployment/services/k8s-job-runner.service.js +194 -0
- package/dist/infrastructure/deployment/services/mssql-database-init.service.js +139 -0
- package/dist/infrastructure/deployment/services/mssql-helm-deployment.service.js +100 -0
- package/dist/infrastructure/deployment/services/mssql-storage.service.js +54 -0
- package/dist/infrastructure/deployment/services/mssql-user-manager.service.js +66 -0
- package/dist/infrastructure/deployment/services/oci-artifact.service.js +289 -0
- package/dist/infrastructure/deployment/services/secret-manager.service.js +179 -0
- package/dist/infrastructure/deployment/services/service-manager.service.js +82 -0
- package/dist/infrastructure/deployment/services/version-compatibility.service.js +291 -0
- package/dist/infrastructure/environment/interfaces/hardware-info.interface.js +3 -0
- package/dist/infrastructure/environment/interfaces/network-checker.interface.js +3 -0
- package/dist/infrastructure/environment/services/hardware-info.service.js +135 -0
- package/dist/infrastructure/environment/services/network-checker.service.js +142 -0
- package/dist/infrastructure/environment/windows-environment.adapter.js +162 -0
- package/dist/infrastructure/errors/app-error.js +73 -0
- package/dist/infrastructure/errors/error-handler.interface.js +3 -0
- package/dist/infrastructure/errors/error-handler.js +218 -0
- package/dist/infrastructure/errors/exit-codes.js +27 -0
- package/dist/infrastructure/errors/index.js +25 -0
- package/dist/infrastructure/execution/builders/base-command.builder.js +122 -0
- package/dist/infrastructure/execution/builders/host-command.builder.js +58 -0
- package/dist/infrastructure/execution/builders/windows-host-command.builder.js +50 -0
- package/dist/infrastructure/execution/builders/wsl-command.builder.js +29 -0
- package/dist/infrastructure/execution/command-builder.js +252 -0
- package/dist/infrastructure/execution/command-executor.service.js +230 -0
- package/dist/infrastructure/execution/environments/wsl-execution.environment.js +70 -0
- package/dist/infrastructure/execution/execution-environment.factory.js +53 -0
- package/dist/infrastructure/execution/index.js +25 -0
- package/dist/infrastructure/execution/interfaces/command-builder.interface.js +3 -0
- package/dist/infrastructure/execution/interfaces/command-executor.interface.js +3 -0
- package/dist/infrastructure/execution/interfaces/execution-environment-factory.interface.js +3 -0
- package/dist/infrastructure/execution/interfaces/execution-environment.interface.js +7 -0
- package/dist/infrastructure/execution/interfaces/host-command-builder.interface.js +3 -0
- package/dist/infrastructure/execution/interfaces/index.js +23 -0
- package/dist/infrastructure/execution/interfaces/script-executor.interface.js +3 -0
- package/dist/infrastructure/execution/script-executor.service.js +171 -0
- package/dist/infrastructure/http/http-client.service.js +176 -0
- package/dist/infrastructure/http/index.js +18 -0
- package/dist/infrastructure/http/interfaces/http-client.interface.js +3 -0
- package/dist/infrastructure/interceptors/index.js +8 -0
- package/dist/infrastructure/interceptors/interceptor.factory.js +44 -0
- package/dist/infrastructure/interceptors/interceptor.interface.js +3 -0
- package/dist/infrastructure/interceptors/logging.interceptor.js +171 -0
- package/dist/infrastructure/logger/correlation-id.adapter.js +68 -0
- package/dist/infrastructure/logger/index.js +23 -0
- package/dist/infrastructure/logger/interfaces/index.js +22 -0
- package/dist/infrastructure/logger/interfaces/log-reader.repository.interface.js +7 -0
- package/dist/infrastructure/logger/interfaces/log-writer.repository.interface.js +7 -0
- package/dist/infrastructure/logger/logger.adapter.js +274 -0
- package/dist/infrastructure/logger/services/file-log-reader.repository.js +148 -0
- package/dist/infrastructure/logger/services/file-log-writer.repository.js +307 -0
- package/dist/infrastructure/logger/services/index.js +22 -0
- package/dist/infrastructure/persistence/index.js +25 -0
- package/dist/infrastructure/persistence/instance-metadata.adapter.js +100 -0
- package/dist/infrastructure/persistence/instance-storage.adapter.js +64 -0
- package/dist/infrastructure/persistence/interfaces/config.repository.interface.js +3 -0
- package/dist/infrastructure/persistence/interfaces/index.js +22 -0
- package/dist/infrastructure/persistence/interfaces/instance.repository.interface.js +3 -0
- package/dist/infrastructure/persistence/services/file-system-config.repository.js +168 -0
- package/dist/infrastructure/persistence/services/file-system-instance.repository.js +170 -0
- package/dist/infrastructure/persistence/services/index.js +22 -0
- package/dist/infrastructure/persistence/user-settings.adapter.js +55 -0
- package/dist/infrastructure/platform-detector.js +71 -0
- package/dist/infrastructure/platforms/windows/interfaces/microk8s.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/rootfs-manager.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/windows-features.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/windows-info.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-config.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-info.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-instance-inspection.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-instance-lifecycle.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-instance-naming.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-manager.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-resources.interface.js +8 -0
- package/dist/infrastructure/platforms/windows/interfaces/wsl-updater.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/interfaces/wslconfig-parser.interface.js +3 -0
- package/dist/infrastructure/platforms/windows/parsers/wsl-version.parser.js +133 -0
- package/dist/infrastructure/platforms/windows/services/microk8s.service.js +168 -0
- package/dist/infrastructure/platforms/windows/services/rootfs-manager.service.js +336 -0
- package/dist/infrastructure/platforms/windows/services/windows-features.service.js +191 -0
- package/dist/infrastructure/platforms/windows/services/windows-info.service.js +138 -0
- package/dist/infrastructure/platforms/windows/services/wsl-config.service.js +171 -0
- package/dist/infrastructure/platforms/windows/services/wsl-info.service.js +226 -0
- package/dist/infrastructure/platforms/windows/services/wsl-instance-inspection.service.js +325 -0
- package/dist/infrastructure/platforms/windows/services/wsl-instance-lifecycle.service.js +442 -0
- package/dist/infrastructure/platforms/windows/services/wsl-instance-naming.service.js +93 -0
- package/dist/infrastructure/platforms/windows/services/wsl-updater.service.js +273 -0
- package/dist/infrastructure/platforms/windows/services/wslconfig-parser.service.js +222 -0
- package/dist/infrastructure/platforms/windows/wsl-base-image.adapter.js +41 -0
- package/dist/infrastructure/platforms/windows/wsl-instance-manager.adapter.js +150 -0
- package/dist/infrastructure/utils/error-formatter.util.js +29 -0
- package/dist/infrastructure/utils/file-operations.util.js +201 -0
- package/dist/infrastructure/utils/input-validator.util.js +152 -0
- package/dist/infrastructure/utils/retry.util.js +98 -0
- package/dist/presentation/controllers/config.controller.js +146 -0
- package/dist/presentation/controllers/credentials.controller.js +105 -0
- package/dist/presentation/controllers/index.js +25 -0
- package/dist/presentation/controllers/instance.controller.js +363 -0
- package/dist/presentation/controllers/logs.controller.js +103 -0
- package/dist/presentation/controllers/setup.controller.js +175 -0
- package/dist/presentation/interfaces/cli-options.interface.js +8 -0
- package/dist/presentation/prompts/acr-credentials.prompt.js +76 -0
- package/dist/presentation/prompts/index.js +21 -0
- package/dist/presentation/ui/cli-progress.service.js +193 -0
- package/dist/presentation/ui/constants/output-symbols.js +42 -0
- package/dist/presentation/ui/index.js +27 -0
- package/dist/presentation/ui/interaction.service.js +276 -0
- package/dist/presentation/ui/interfaces/cli-progress.interface.js +9 -0
- package/dist/presentation/ui/interfaces/output-formatter.interface.js +23 -0
- package/dist/presentation/ui/log-level.enum.js +66 -0
- package/dist/presentation/ui/output-builder.service.js +378 -0
- package/dist/presentation/ui/output-formatter.service.js +393 -0
- package/package.json +65 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.CryptoService = void 0;
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
38
|
+
/**
|
|
39
|
+
* 混淆用字典字串
|
|
40
|
+
*/
|
|
41
|
+
const DICT = 'Kp9Xw4LmNrT2vQcYbU7sE0oA5gHdI3lJfZ6WxjMyS8nVuROe1tCaBkFhGqDiP=/+z';
|
|
42
|
+
const OFFSET = 23;
|
|
43
|
+
/**
|
|
44
|
+
* AES 密鑰 (hex 編碼後混淆)
|
|
45
|
+
* 原始密鑰: 32 bytes = 64 hex chars
|
|
46
|
+
*/
|
|
47
|
+
const ENCODED_AES_KEY = [25, 57, 50, 34, 37, 25, 37, 25, 39, 39, 25, 50, 57, 71, 41, 57, 37, 34, 57, 70, 70, 41, 41, 39, 25, 47, 25, 52, 47, 64, 64, 57, 70, 41, 25, 28, 70, 70, 64, 44, 37, 34, 41, 28, 28, 70, 41, 70, 41, 52, 28, 47, 50, 64, 50, 64, 57, 57, 34, 57, 64, 25, 64, 74];
|
|
48
|
+
/**
|
|
49
|
+
* 解碼混淆字串
|
|
50
|
+
*/
|
|
51
|
+
function decodeObfuscated(indices) {
|
|
52
|
+
return indices.map(i => DICT[i - OFFSET]).join('');
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 加密前綴,用於識別加密後的字串
|
|
56
|
+
*/
|
|
57
|
+
const ENCRYPTED_PREFIX = 'ENC:';
|
|
58
|
+
/**
|
|
59
|
+
* 加密服務
|
|
60
|
+
* 使用 AES-256-GCM 對稱加密
|
|
61
|
+
*/
|
|
62
|
+
class CryptoService {
|
|
63
|
+
/**
|
|
64
|
+
* 取得解碼後的密鑰
|
|
65
|
+
*/
|
|
66
|
+
static getKey() {
|
|
67
|
+
const keyHex = decodeObfuscated(ENCODED_AES_KEY);
|
|
68
|
+
return Buffer.from(keyHex, 'hex');
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 加密字串
|
|
72
|
+
* @param plaintext 明文
|
|
73
|
+
* @returns 加密後的字串,格式: ENC:base64(iv + authTag + ciphertext)
|
|
74
|
+
*/
|
|
75
|
+
static encrypt(plaintext) {
|
|
76
|
+
const key = this.getKey();
|
|
77
|
+
const iv = crypto.randomBytes(this.IV_LENGTH);
|
|
78
|
+
const cipher = crypto.createCipheriv(this.ALGORITHM, key, iv);
|
|
79
|
+
const encrypted = Buffer.concat([
|
|
80
|
+
cipher.update(plaintext, 'utf8'),
|
|
81
|
+
cipher.final(),
|
|
82
|
+
]);
|
|
83
|
+
const authTag = cipher.getAuthTag();
|
|
84
|
+
// 組合: iv (16) + authTag (16) + ciphertext
|
|
85
|
+
const combined = Buffer.concat([iv, authTag, encrypted]);
|
|
86
|
+
return ENCRYPTED_PREFIX + combined.toString('base64');
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 解密字串
|
|
90
|
+
* @param encrypted 加密後的字串
|
|
91
|
+
* @returns 解密後的明文
|
|
92
|
+
* @throws 如果解密失敗
|
|
93
|
+
*/
|
|
94
|
+
static decrypt(encrypted) {
|
|
95
|
+
if (!this.isEncrypted(encrypted)) {
|
|
96
|
+
throw new Error('Invalid encrypted format');
|
|
97
|
+
}
|
|
98
|
+
const key = this.getKey();
|
|
99
|
+
const data = Buffer.from(encrypted.slice(ENCRYPTED_PREFIX.length), 'base64');
|
|
100
|
+
// 解析: iv (16) + authTag (16) + ciphertext
|
|
101
|
+
const iv = data.subarray(0, this.IV_LENGTH);
|
|
102
|
+
const authTag = data.subarray(this.IV_LENGTH, this.IV_LENGTH + this.AUTH_TAG_LENGTH);
|
|
103
|
+
const ciphertext = data.subarray(this.IV_LENGTH + this.AUTH_TAG_LENGTH);
|
|
104
|
+
const decipher = crypto.createDecipheriv(this.ALGORITHM, key, iv);
|
|
105
|
+
decipher.setAuthTag(authTag);
|
|
106
|
+
const decrypted = Buffer.concat([
|
|
107
|
+
decipher.update(ciphertext),
|
|
108
|
+
decipher.final(),
|
|
109
|
+
]);
|
|
110
|
+
return decrypted.toString('utf8');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 檢查字串是否為加密格式
|
|
114
|
+
* @param value 要檢查的字串
|
|
115
|
+
* @returns 是否為加密格式
|
|
116
|
+
*/
|
|
117
|
+
static isEncrypted(value) {
|
|
118
|
+
return value.startsWith(ENCRYPTED_PREFIX);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.CryptoService = CryptoService;
|
|
122
|
+
CryptoService.ALGORITHM = 'aes-256-gcm';
|
|
123
|
+
CryptoService.IV_LENGTH = 16;
|
|
124
|
+
CryptoService.AUTH_TAG_LENGTH = 16;
|
|
125
|
+
//# sourceMappingURL=crypto.service.js.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DeploymentAdapter = void 0;
|
|
16
|
+
const tsyringe_1 = require("tsyringe");
|
|
17
|
+
const tokens_1 = require("../../di/tokens");
|
|
18
|
+
const chart_version_value_object_1 = require("../../domain/value-objects/chart-version.value-object");
|
|
19
|
+
const credentials_entity_1 = require("../../domain/entities/credentials.entity");
|
|
20
|
+
/**
|
|
21
|
+
* Deployment Adapter
|
|
22
|
+
*
|
|
23
|
+
* implements IDeploymentPort
|
|
24
|
+
* 整合 K8s、Helm、Secret 管理等部署能力
|
|
25
|
+
*/
|
|
26
|
+
let DeploymentAdapter = class DeploymentAdapter {
|
|
27
|
+
constructor(mssqlDeployment, jobRunner, infraManager, serviceManager, appManager, secretManager, helmRegistry, versionCompatibility) {
|
|
28
|
+
this.mssqlDeployment = mssqlDeployment;
|
|
29
|
+
this.jobRunner = jobRunner;
|
|
30
|
+
this.infraManager = infraManager;
|
|
31
|
+
this.serviceManager = serviceManager;
|
|
32
|
+
this.appManager = appManager;
|
|
33
|
+
this.secretManager = secretManager;
|
|
34
|
+
this.helmRegistry = helmRegistry;
|
|
35
|
+
this.versionCompatibility = versionCompatibility;
|
|
36
|
+
}
|
|
37
|
+
async deployMssql(instanceName, params, version, output) {
|
|
38
|
+
await this.mssqlDeployment.deployMssql(instanceName, params, version, output);
|
|
39
|
+
await this.jobRunner.runInitJobs(instanceName, params, version, output);
|
|
40
|
+
}
|
|
41
|
+
async deployInfra(instanceName, params, version, output) {
|
|
42
|
+
await this.infraManager.deployInfra(instanceName, params, version, output);
|
|
43
|
+
}
|
|
44
|
+
async deployService(instanceName, params, version, output) {
|
|
45
|
+
await this.serviceManager.deployService(instanceName, params, version, output);
|
|
46
|
+
}
|
|
47
|
+
async deployApp(instanceName, params, version, output) {
|
|
48
|
+
await this.appManager.deployApp(instanceName, params, version, output);
|
|
49
|
+
}
|
|
50
|
+
async createGlobalConfigSecret(instanceName, params, output) {
|
|
51
|
+
const rsaKeys = {
|
|
52
|
+
signInRsa: {
|
|
53
|
+
privateKey: params.signInRsaKeys.privateKey,
|
|
54
|
+
publicKey: params.signInRsaKeys.publicKey,
|
|
55
|
+
},
|
|
56
|
+
uofxRsa: {
|
|
57
|
+
privateKey: params.uofxRsaKeys.privateKey,
|
|
58
|
+
publicKey: params.uofxRsaKeys.publicKey,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
await this.secretManager.createGlobalConfigSecret(instanceName, params.saPassword.toString(), params.adminPassword.toString(), rsaKeys, params.jwtKey.toString(), output);
|
|
62
|
+
}
|
|
63
|
+
async getLatestCompatibleVersion(_chartName) {
|
|
64
|
+
const versionStr = await this.versionCompatibility.getLatestCompatibleVersion();
|
|
65
|
+
return chart_version_value_object_1.ChartVersion.create(versionStr);
|
|
66
|
+
}
|
|
67
|
+
async validateChartVersion(_chartName, version) {
|
|
68
|
+
// 透過 versionCompatibility 驗證
|
|
69
|
+
try {
|
|
70
|
+
await this.versionCompatibility.validateChartVersion(version.toString());
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async getCredentials(instanceName) {
|
|
78
|
+
const globalConfig = await this.secretManager.getGlobalConfigSecret(instanceName);
|
|
79
|
+
if (!globalConfig) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
// 從 GlobalConfigData 轉換為 Credentials
|
|
83
|
+
return credentials_entity_1.Credentials.fromObject({
|
|
84
|
+
instanceName: globalConfig.instanceName,
|
|
85
|
+
saPassword: globalConfig.saPassword || '',
|
|
86
|
+
adminPassword: globalConfig.adminPassword || '',
|
|
87
|
+
signInRsaPrivateKey: globalConfig.signInRsaPrivateKey || '',
|
|
88
|
+
signInRsaPublicKey: globalConfig.signInRsaPublicKey || '',
|
|
89
|
+
uofxRsaPrivateKey: globalConfig.uofxRsaPrivateKey || '',
|
|
90
|
+
uofxRsaPublicKey: globalConfig.uofxRsaPublicKey || '',
|
|
91
|
+
jwtSigningKey: globalConfig.jwtSigningKey || '',
|
|
92
|
+
connectionStringUofxDb: globalConfig.connectionStringUofxDb || '',
|
|
93
|
+
connectionStringUofxSearchDb: globalConfig.connectionStringUofxSearchDb || '',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async listChartVersions(_chartName) {
|
|
97
|
+
// 從 versionCompatibility 取得相容版本清單
|
|
98
|
+
const compatibility = await this.versionCompatibility.getCompatibility();
|
|
99
|
+
return compatibility.compatibleCharts.map((v) => chart_version_value_object_1.ChartVersion.create(v));
|
|
100
|
+
}
|
|
101
|
+
async getEnvironmentVersion(chartVersion) {
|
|
102
|
+
return await this.versionCompatibility.getEnvironmentVersion(chartVersion);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
exports.DeploymentAdapter = DeploymentAdapter;
|
|
106
|
+
exports.DeploymentAdapter = DeploymentAdapter = __decorate([
|
|
107
|
+
(0, tsyringe_1.injectable)(),
|
|
108
|
+
__param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.IMssqlHelmDeployment)),
|
|
109
|
+
__param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.IK8sJobRunner)),
|
|
110
|
+
__param(2, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.InfraManagerService)),
|
|
111
|
+
__param(3, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.ServiceManagerService)),
|
|
112
|
+
__param(4, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.AppManagerService)),
|
|
113
|
+
__param(5, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.SecretManagerService)),
|
|
114
|
+
__param(6, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.HelmRegistryService)),
|
|
115
|
+
__param(7, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.VersionCompatibilityService)),
|
|
116
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object, Object, Object, Object, Object])
|
|
117
|
+
], DeploymentAdapter);
|
|
118
|
+
//# sourceMappingURL=deployment.adapter.js.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.AcrCredentialManagerService = void 0;
|
|
49
|
+
const tsyringe_1 = require("tsyringe");
|
|
50
|
+
const fs = __importStar(require("fs"));
|
|
51
|
+
const tokens_1 = require("../../../di/tokens");
|
|
52
|
+
const sensitive_decorator_1 = require("../../../domain/decorators/sensitive.decorator");
|
|
53
|
+
let AcrCredentialManagerService = class AcrCredentialManagerService {
|
|
54
|
+
constructor(appConfig) {
|
|
55
|
+
this.appConfig = appConfig;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 從檔案載入 ACR 憑證
|
|
59
|
+
* 支援新格式 (name, account, password) 與舊格式 (acrName, acrAccount, acrPassword)
|
|
60
|
+
* @param filePath 憑證檔案路徑
|
|
61
|
+
*/
|
|
62
|
+
loadCredentialsFromFile(filePath) {
|
|
63
|
+
// 檢查檔案存在
|
|
64
|
+
if (!fs.existsSync(filePath)) {
|
|
65
|
+
throw new Error(`Pull secret file not found: ${filePath}`);
|
|
66
|
+
}
|
|
67
|
+
// 讀取檔案
|
|
68
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
69
|
+
// 解析 JSON
|
|
70
|
+
let raw;
|
|
71
|
+
try {
|
|
72
|
+
raw = JSON.parse(content);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
throw new Error('Invalid JSON format in pull secret file');
|
|
76
|
+
}
|
|
77
|
+
// 正規化欄位名稱(支援舊格式相容)
|
|
78
|
+
const credentials = this.normalizeCredentials(raw);
|
|
79
|
+
// 驗證必要欄位
|
|
80
|
+
this.validateCredentials(credentials);
|
|
81
|
+
return credentials;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 取得預設 ACR 憑證(從設定檔)
|
|
85
|
+
* @returns 預設憑證,若未設定或不完整則返回 null
|
|
86
|
+
*/
|
|
87
|
+
getDefaultCredentials() {
|
|
88
|
+
const config = this.appConfig.getConfig();
|
|
89
|
+
const acr = config.acr;
|
|
90
|
+
// 檢查是否有完整的預設憑證
|
|
91
|
+
if (acr.name && acr.account && acr.password) {
|
|
92
|
+
return {
|
|
93
|
+
name: acr.name,
|
|
94
|
+
account: acr.account,
|
|
95
|
+
password: acr.password,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 正規化憑證欄位名稱
|
|
102
|
+
* 支援舊格式 (acrName, acrAccount, acrPassword) 轉換為新格式
|
|
103
|
+
*/
|
|
104
|
+
normalizeCredentials(raw) {
|
|
105
|
+
return {
|
|
106
|
+
name: raw.name || raw.acrName || '',
|
|
107
|
+
account: raw.account || raw.acrAccount || '',
|
|
108
|
+
password: raw.password || raw.acrPassword || '',
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 驗證憑證格式 (僅檢查欄位是否存在,不進行登入驗證)
|
|
113
|
+
*/
|
|
114
|
+
validateCredentials(credentials) {
|
|
115
|
+
if (!credentials.name) {
|
|
116
|
+
throw new Error('Missing required field in pull secret: name (or acrName)');
|
|
117
|
+
}
|
|
118
|
+
if (!credentials.account) {
|
|
119
|
+
throw new Error('Missing required field in pull secret: account (or acrAccount)');
|
|
120
|
+
}
|
|
121
|
+
if (!credentials.password) {
|
|
122
|
+
throw new Error('Missing required field in pull secret: password (or acrPassword)');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
exports.AcrCredentialManagerService = AcrCredentialManagerService;
|
|
127
|
+
__decorate([
|
|
128
|
+
(0, sensitive_decorator_1.SensitiveReturn)(),
|
|
129
|
+
__metadata("design:type", Function),
|
|
130
|
+
__metadata("design:paramtypes", [String]),
|
|
131
|
+
__metadata("design:returntype", Object)
|
|
132
|
+
], AcrCredentialManagerService.prototype, "loadCredentialsFromFile", null);
|
|
133
|
+
__decorate([
|
|
134
|
+
(0, sensitive_decorator_1.SensitiveReturn)(),
|
|
135
|
+
__metadata("design:type", Function),
|
|
136
|
+
__metadata("design:paramtypes", []),
|
|
137
|
+
__metadata("design:returntype", Object)
|
|
138
|
+
], AcrCredentialManagerService.prototype, "getDefaultCredentials", null);
|
|
139
|
+
exports.AcrCredentialManagerService = AcrCredentialManagerService = __decorate([
|
|
140
|
+
(0, tsyringe_1.injectable)(),
|
|
141
|
+
__param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.IAppConfig)),
|
|
142
|
+
__metadata("design:paramtypes", [Object])
|
|
143
|
+
], AcrCredentialManagerService);
|
|
144
|
+
//# sourceMappingURL=acr-credential-manager.service.js.map
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AppManagerService = void 0;
|
|
16
|
+
const tsyringe_1 = require("tsyringe");
|
|
17
|
+
const tokens_1 = require("../../../di/tokens");
|
|
18
|
+
const deployment_parameters_entity_1 = require("../../../domain/entities/deployment-parameters.entity");
|
|
19
|
+
const sensitive_decorator_1 = require("../../../domain/decorators/sensitive.decorator");
|
|
20
|
+
const base_helm_deployment_service_1 = require("./base-helm-deployment.service");
|
|
21
|
+
const index_1 = require("../../../constants/index");
|
|
22
|
+
/**
|
|
23
|
+
* 應用程式管理服務
|
|
24
|
+
*
|
|
25
|
+
* 負責 uofx 應用程式 Helm chart 的部署管理,包含:
|
|
26
|
+
* - Blue/Green 部署策略
|
|
27
|
+
* - Registry 登入與 Chart 拉取
|
|
28
|
+
* - Helm Release 安裝與配置
|
|
29
|
+
* - K8s 就緒檢查
|
|
30
|
+
*
|
|
31
|
+
* 繼承 BaseHelmDeploymentService 使用模板方法模式
|
|
32
|
+
*/
|
|
33
|
+
let AppManagerService = class AppManagerService extends base_helm_deployment_service_1.BaseHelmDeploymentService {
|
|
34
|
+
constructor(envFactory, helmRegistry, logger) {
|
|
35
|
+
super(helmRegistry, logger, envFactory);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 部署 uofx 應用程式
|
|
39
|
+
* @param instanceName - 目標 WSL 實例名稱
|
|
40
|
+
* @param params - 部署參數(含敏感資料)
|
|
41
|
+
* @param chartVersion - Chart 版本
|
|
42
|
+
* @param progress - 進度通知回調
|
|
43
|
+
*/
|
|
44
|
+
async deployApp(instanceName, params, chartVersion, output) {
|
|
45
|
+
output?.item('arrow', 'Deploying uofx application chart...').flush();
|
|
46
|
+
await this.deployWithHelm(instanceName, params, chartVersion, output);
|
|
47
|
+
}
|
|
48
|
+
// =========================================================================
|
|
49
|
+
// BaseHelmDeploymentService 抽象方法實作
|
|
50
|
+
// =========================================================================
|
|
51
|
+
getServiceName() {
|
|
52
|
+
return 'App';
|
|
53
|
+
}
|
|
54
|
+
getDeploymentConfig(chartVersion) {
|
|
55
|
+
return {
|
|
56
|
+
chartName: 'uofx',
|
|
57
|
+
chartVersion,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 安裝前處理:修補 Secret 以轉移管理權限
|
|
62
|
+
* 將 web-appsettings-secret 的 meta.helm.sh/release-name 標註為 uofx-blue
|
|
63
|
+
*/
|
|
64
|
+
async preInstall(instanceName, _params, _output) {
|
|
65
|
+
await this.patchSecret(instanceName);
|
|
66
|
+
}
|
|
67
|
+
async installChart(instanceName, chartPath, params, output) {
|
|
68
|
+
// 透過 stdin 傳遞 values 以避免將敏感資料寫入磁碟
|
|
69
|
+
const valuesContent = this.createValuesContent(params);
|
|
70
|
+
const builder = this.createHelmUpgradeBuilder(instanceName, {
|
|
71
|
+
releaseName: 'uofx-blue',
|
|
72
|
+
chartPath,
|
|
73
|
+
wait: true,
|
|
74
|
+
timeout: '1800s',
|
|
75
|
+
sensitiveStdin: valuesContent,
|
|
76
|
+
});
|
|
77
|
+
this.logger.debug('[App] Deploying application chart', {
|
|
78
|
+
chart: 'uofx-blue',
|
|
79
|
+
chartPath: chartPath,
|
|
80
|
+
namespace: 'uofx',
|
|
81
|
+
instance: instanceName
|
|
82
|
+
});
|
|
83
|
+
output?.indent().item('arrow', 'Installing uofx chart (this may take more than 15 minutes, depending on your network speed)...').outdent().flush();
|
|
84
|
+
await this.executeWithRetry(builder, 'uofx', output);
|
|
85
|
+
}
|
|
86
|
+
// =========================================================================
|
|
87
|
+
// 私有方法
|
|
88
|
+
// =========================================================================
|
|
89
|
+
/**
|
|
90
|
+
* 修補 Secret 以轉移管理權限
|
|
91
|
+
*/
|
|
92
|
+
async patchSecret(instanceName) {
|
|
93
|
+
const patchData = JSON.stringify({
|
|
94
|
+
metadata: {
|
|
95
|
+
annotations: {
|
|
96
|
+
"meta.helm.sh/release-name": "uofx-blue"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const env = this.envFactory.getForInstance(instanceName);
|
|
101
|
+
const builder = env.kubectl('patch')
|
|
102
|
+
.arg('secret')
|
|
103
|
+
.arg('web-appsettings-secret')
|
|
104
|
+
.arg('-n', 'uofx')
|
|
105
|
+
.arg('-p', `'${patchData}'`);
|
|
106
|
+
try {
|
|
107
|
+
await builder.exec();
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// 忽略修補錯誤,secret 可能尚不存在
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 產生 Helm Values 內容
|
|
115
|
+
* @param params - 部署參數
|
|
116
|
+
* @returns JSON 格式的 Values 字串
|
|
117
|
+
*/
|
|
118
|
+
createValuesContent(params) {
|
|
119
|
+
const helmParams = params.toHelmParameters();
|
|
120
|
+
const values = {
|
|
121
|
+
appsetting: {
|
|
122
|
+
LogLevel: index_1.APP_LOG_DEFAULTS.LOG_LEVEL,
|
|
123
|
+
LogRetentionPeriod: index_1.APP_LOG_DEFAULTS.LOG_RETENTION_PERIOD,
|
|
124
|
+
LogLevelMicrosoft: index_1.APP_LOG_DEFAULTS.LOG_LEVEL_MICROSOFT,
|
|
125
|
+
LogLevelHostingLifetime: index_1.APP_LOG_DEFAULTS.LOG_LEVEL_HOSTING_LIFETIME,
|
|
126
|
+
LogLevelHttpClient: index_1.APP_LOG_DEFAULTS.LOG_LEVEL_HTTP_CLIENT,
|
|
127
|
+
ConnectionStrings: {
|
|
128
|
+
UofxDb: {
|
|
129
|
+
Host: index_1.DEPLOYMENT_DEFAULTS.DB_HOST,
|
|
130
|
+
Database: index_1.DEPLOYMENT_DEFAULTS.DB_NAME,
|
|
131
|
+
User: index_1.DEPLOYMENT_DEFAULTS.DB_USER,
|
|
132
|
+
PasswordB64: helmParams.saPasswordB64
|
|
133
|
+
},
|
|
134
|
+
UofxSearchDb: {
|
|
135
|
+
Database: index_1.DEPLOYMENT_DEFAULTS.SEARCH_DB_NAME
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
SignInRSASettings: {
|
|
139
|
+
PrivateKeyB64: helmParams.rsaSignInPrivateB64,
|
|
140
|
+
PublicKeyB64: helmParams.rsaSignInPublicB64
|
|
141
|
+
},
|
|
142
|
+
UofxRsaKey: {
|
|
143
|
+
PrivateKeyB64: helmParams.rsaUofxPrivateB64,
|
|
144
|
+
PublicKeyB64: helmParams.rsaUofxPublicB64
|
|
145
|
+
},
|
|
146
|
+
TokenSettings: {
|
|
147
|
+
IssuerSigningKeyB64: helmParams.jwtKeyB64
|
|
148
|
+
},
|
|
149
|
+
UofxServiceSettings: {
|
|
150
|
+
NotificationCenterUrl: index_1.DEPLOYMENT_DEFAULTS.CONNECT_URL,
|
|
151
|
+
LicenseCenterUrl: index_1.DEPLOYMENT_DEFAULTS.CONNECT_URL,
|
|
152
|
+
VersionCenterUrl: index_1.DEPLOYMENT_DEFAULTS.CONNECT_URL
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
job: {
|
|
156
|
+
dbHelper: {
|
|
157
|
+
enabled: false,
|
|
158
|
+
Host: index_1.DEPLOYMENT_DEFAULTS.DB_HOST,
|
|
159
|
+
Database: index_1.DEPLOYMENT_DEFAULTS.DB_NAME,
|
|
160
|
+
User: index_1.DEPLOYMENT_DEFAULTS.DB_USER,
|
|
161
|
+
PasswordB64: helmParams.saPasswordB64
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
enabledSearch: true,
|
|
165
|
+
frontend: {
|
|
166
|
+
mobiledev: {
|
|
167
|
+
enabled: false
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
imageCredentials: {
|
|
171
|
+
registry: `${params.acrCredentials.name}.azurecr.io`,
|
|
172
|
+
username: params.acrCredentials.account,
|
|
173
|
+
password: params.acrCredentials.password
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
return JSON.stringify(values, null, 2);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
exports.AppManagerService = AppManagerService;
|
|
180
|
+
__decorate([
|
|
181
|
+
__param(1, (0, sensitive_decorator_1.Sensitive)()),
|
|
182
|
+
__metadata("design:type", Function),
|
|
183
|
+
__metadata("design:paramtypes", [String, deployment_parameters_entity_1.DeploymentParameters, String, Object]),
|
|
184
|
+
__metadata("design:returntype", Promise)
|
|
185
|
+
], AppManagerService.prototype, "deployApp", null);
|
|
186
|
+
exports.AppManagerService = AppManagerService = __decorate([
|
|
187
|
+
(0, tsyringe_1.injectable)(),
|
|
188
|
+
__param(0, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.IExecutionEnvironmentFactory)),
|
|
189
|
+
__param(1, (0, tsyringe_1.inject)(tokens_1.TOKENS.Internal.IHelmRegistry)),
|
|
190
|
+
__param(2, (0, tsyringe_1.inject)(tokens_1.TOKENS.ILoggerPort)),
|
|
191
|
+
__metadata("design:paramtypes", [Object, Object, Object])
|
|
192
|
+
], AppManagerService);
|
|
193
|
+
//# sourceMappingURL=app-manager.service.js.map
|