underpost 2.8.87 → 2.8.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/.env.development +35 -3
  2. package/.env.production +39 -4
  3. package/.env.test +35 -3
  4. package/.github/workflows/ghpkg.ci.yml +1 -1
  5. package/.github/workflows/npmpkg.ci.yml +1 -1
  6. package/.github/workflows/pwa-microservices-template-page.cd.yml +6 -5
  7. package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
  8. package/.github/workflows/release.cd.yml +3 -3
  9. package/README.md +56 -2
  10. package/bin/build.js +4 -0
  11. package/bin/deploy.js +62 -8
  12. package/bin/file.js +3 -2
  13. package/cli.md +8 -2
  14. package/conf.js +30 -4
  15. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  16. package/manifests/deployment/dd-test-development/deployment.yaml +174 -0
  17. package/manifests/deployment/dd-test-development/proxy.yaml +51 -0
  18. package/package.json +6 -5
  19. package/src/api/core/core.router.js +2 -1
  20. package/src/api/default/default.controller.js +6 -1
  21. package/src/api/default/default.router.js +6 -2
  22. package/src/api/default/default.service.js +10 -1
  23. package/src/api/document/document.controller.js +66 -0
  24. package/src/api/document/document.model.js +51 -0
  25. package/src/api/document/document.router.js +24 -0
  26. package/src/api/document/document.service.js +125 -0
  27. package/src/api/file/file.controller.js +15 -1
  28. package/src/api/file/file.router.js +2 -1
  29. package/src/api/test/test.router.js +1 -1
  30. package/src/api/user/postman_collection.json +216 -0
  31. package/src/api/user/user.controller.js +25 -60
  32. package/src/api/user/user.model.js +29 -7
  33. package/src/api/user/user.router.js +9 -3
  34. package/src/api/user/user.service.js +84 -32
  35. package/src/cli/baremetal.js +33 -3
  36. package/src/cli/cloud-init.js +11 -0
  37. package/src/cli/cron.js +0 -1
  38. package/src/cli/deploy.js +46 -23
  39. package/src/cli/index.js +5 -0
  40. package/src/cli/lxd.js +7 -0
  41. package/src/cli/repository.js +42 -6
  42. package/src/cli/run.js +45 -13
  43. package/src/cli/ssh.js +20 -6
  44. package/src/client/Default.index.js +42 -1
  45. package/src/client/components/core/Account.js +10 -2
  46. package/src/client/components/core/AgGrid.js +30 -8
  47. package/src/client/components/core/Auth.js +99 -56
  48. package/src/client/components/core/BtnIcon.js +3 -2
  49. package/src/client/components/core/CalendarCore.js +2 -3
  50. package/src/client/components/core/CommonJs.js +1 -2
  51. package/src/client/components/core/Content.js +15 -12
  52. package/src/client/components/core/Css.js +2 -1
  53. package/src/client/components/core/CssCore.js +6 -1
  54. package/src/client/components/core/Docs.js +5 -5
  55. package/src/client/components/core/FileExplorer.js +3 -3
  56. package/src/client/components/core/Input.js +22 -17
  57. package/src/client/components/core/JoyStick.js +2 -2
  58. package/src/client/components/core/LoadingAnimation.js +2 -2
  59. package/src/client/components/core/LogIn.js +16 -23
  60. package/src/client/components/core/LogOut.js +5 -1
  61. package/src/client/components/core/Logger.js +4 -1
  62. package/src/client/components/core/Modal.js +82 -53
  63. package/src/client/components/core/ObjectLayerEngineModal.js +2 -1
  64. package/src/client/components/core/Pagination.js +207 -0
  65. package/src/client/components/core/Panel.js +10 -10
  66. package/src/client/components/core/PanelForm.js +130 -33
  67. package/src/client/components/core/Recover.js +2 -2
  68. package/src/client/components/core/Router.js +210 -34
  69. package/src/client/components/core/SignUp.js +1 -2
  70. package/src/client/components/core/Stream.js +1 -1
  71. package/src/client/components/core/VanillaJs.js +3 -84
  72. package/src/client/components/core/Worker.js +2 -2
  73. package/src/client/components/default/LogInDefault.js +0 -6
  74. package/src/client/components/default/LogOutDefault.js +0 -16
  75. package/src/client/components/default/MenuDefault.js +97 -44
  76. package/src/client/components/default/RoutesDefault.js +5 -2
  77. package/src/client/services/core/core.service.js +8 -20
  78. package/src/client/services/default/default.management.js +115 -18
  79. package/src/client/services/default/default.service.js +13 -4
  80. package/src/client/services/document/document.service.js +97 -0
  81. package/src/client/services/file/file.service.js +2 -0
  82. package/src/client/services/test/test.service.js +3 -0
  83. package/src/client/services/user/user.management.js +6 -0
  84. package/src/client/services/user/user.service.js +15 -4
  85. package/src/client/ssr/Render.js +1 -1
  86. package/src/client/ssr/head/DefaultScripts.js +3 -0
  87. package/src/client/ssr/head/Seo.js +1 -0
  88. package/src/index.js +24 -2
  89. package/src/runtime/lampp/Lampp.js +89 -2
  90. package/src/runtime/xampp/Xampp.js +48 -1
  91. package/src/server/auth.js +519 -155
  92. package/src/server/backup.js +2 -2
  93. package/src/server/conf.js +66 -8
  94. package/src/server/process.js +2 -1
  95. package/src/server/runtime.js +135 -286
  96. package/src/server/ssl.js +1 -2
  97. package/src/server/ssr.js +85 -0
  98. package/src/server/start.js +2 -2
  99. package/src/server/valkey.js +2 -1
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Baremetal module for managing the generation and deployment of cloud-init configuration files
3
+ * and associated scripts for baremetal provisioning.
4
+ * @module src/cli/baremetal.js
5
+ * @namespace UnderpostBaremetal
6
+ */
7
+
1
8
  import { getNpmRootPath, getUnderpostRootPath } from '../server/conf.js';
2
9
  import { openTerminal, pbcopy, shellExec } from '../server/process.js';
3
10
  import dotenv from 'dotenv';
@@ -40,6 +47,7 @@ class UnderpostBaremetal {
40
47
  * @param {boolean} [options.nfsUnmount=false] - Flag to unmount the NFS root filesystem.
41
48
  * @param {boolean} [options.nfsSh=false] - Flag to chroot into the NFS environment for shell access.
42
49
  * @param {string} [options.logs=''] - Specifies which logs to display ('dhcp', 'cloud', 'machine', 'cloud-config').
50
+ * @memberof UnderpostBaremetal
43
51
  * @returns {void}
44
52
  */
45
53
  async callback(
@@ -576,6 +584,7 @@ menuentry '${menuentryStr}' {
576
584
  * @param {object} params.maas - MAAS configuration details.
577
585
  * @param {string} params.networkInterfaceName - The name of the network interface.
578
586
  * @returns {Promise<void>} A promise that resolves when commissioning is initiated or after a delay.
587
+ * @memberof UnderpostBaremetal
579
588
  */
580
589
  async commissionMonitor({ macAddress, nfsHostPath, underpostRoot, hostname, maas, networkInterfaceName }) {
581
590
  {
@@ -725,6 +734,7 @@ menuentry '${menuentryStr}' {
725
734
  * This is necessary for cross-architecture execution within a chroot environment.
726
735
  * @param {object} params - The parameters for the function.
727
736
  * @param {string} params.nfsHostPath - The path to the NFS root filesystem on the host.
737
+ * @memberof UnderpostBaremetal
728
738
  * @returns {void}
729
739
  */
730
740
  mountBinfmtMisc({ nfsHostPath }) {
@@ -747,6 +757,7 @@ menuentry '${menuentryStr}' {
747
757
  * @description Deletes all specified machines from MAAS.
748
758
  * @param {object} params - The parameters for the function.
749
759
  * @param {Array<object>} params.machines - An array of machine objects, each with a `system_id`.
760
+ * @memberof UnderpostBaremetal
750
761
  * @returns {Array<object>} An empty array after machines are removed.
751
762
  */
752
763
  removeMachines({ machines }) {
@@ -761,6 +772,7 @@ menuentry '${menuentryStr}' {
761
772
  * @description Clears all observed discoveries in MAAS and optionally forces a new scan.
762
773
  * @param {object} params - The parameters for the function.
763
774
  * @param {boolean} params.force - If true, forces a new discovery scan after clearing.
775
+ * @memberof UnderpostBaremetal
764
776
  * @returns {void}
765
777
  */
766
778
  clearDiscoveries({ force }) {
@@ -776,6 +788,7 @@ menuentry '${menuentryStr}' {
776
788
  * This is used to wait for the target machine to report its MAC address.
777
789
  * @param {object} params - The parameters for the function.
778
790
  * @param {string} params.nfsHostPath - The NFS host path where the MAC file is expected.
791
+ * @memberof UnderpostBaremetal
779
792
  * @returns {Promise<void>} A promise that resolves when the MAC file is found or after a delay.
780
793
  */
781
794
  async macMonitor({ nfsHostPath }) {
@@ -794,6 +807,7 @@ menuentry '${menuentryStr}' {
794
807
  * for cross-architecture execution within a chroot environment.
795
808
  * @param {object} params - The parameters for the function.
796
809
  * @param {string} params.nfsHostPath - The path to the NFS root filesystem on the host.
810
+ * @memberof UnderpostBaremetal
797
811
  * @param {'arm64'|'amd64'} params.debootstrapArch - The target architecture of the debootstrap environment.
798
812
  * @returns {void}
799
813
  */
@@ -825,6 +839,7 @@ menuentry '${menuentryStr}' {
825
839
  * @param {string} params.nfsHostPath - The path to the NFS root filesystem on the host.
826
840
  * @param {'arm64'|'amd64'} params.debootstrapArch - The target architecture of the debootstrap environment.
827
841
  * @param {object} params.callbackMetaData - Metadata about the callback, including runner host architecture.
842
+ * @memberof UnderpostBaremetal
828
843
  * @param {string[]} params.steps - An array of shell commands to execute.
829
844
  * @returns {void}
830
845
  */
@@ -860,6 +875,7 @@ EOF`);
860
875
  * This helps in visualizing and debugging the execution flow of provisioning steps.
861
876
  * @param {string[]} [steps=[]] - An array of shell commands.
862
877
  * @param {boolean} [yaml=true] - If true, formats the output as YAML list items.
878
+ * @memberof UnderpostBaremetal
863
879
  * @returns {string} The formatted string of commands.
864
880
  */
865
881
  stepsRender(steps = [], yaml = true) {
@@ -892,6 +908,7 @@ EOF`);
892
908
  * @param {string} params.workflowId - The identifier for the workflow configuration.
893
909
  * @param {boolean} [params.mount] - If true, attempts to mount the NFS paths.
894
910
  * @param {boolean} [params.unmount] - If true, attempts to unmount the NFS paths.
911
+ * @memberof UnderpostBaremetal
895
912
  * @returns {{isMounted: boolean}} An object indicating whether any NFS path is currently mounted.
896
913
  */
897
914
  nfsMountCallback({ hostname, workflowId, mount, unmount }) {
@@ -929,7 +946,8 @@ EOF`);
929
946
  * @method getHostArch
930
947
  * @description Determines the architecture of the host machine.
931
948
  * This is crucial for cross-compilation and selecting the correct QEMU binaries.
932
- * @returns {'amd64'|'arm64'} The host architecture.
949
+ * @memberof UnderpostBaremetal
950
+ * @returns {{alias: 'amd64'|'arm64', name: 'x86_64'|'aarch64'}} The host architecture.
933
951
  * @throws {Error} If the host architecture is unsupported.
934
952
  */
935
953
  getHostArch() {
@@ -944,12 +962,16 @@ EOF`);
944
962
  * @property {object} systemProvisioningFactory
945
963
  * @description A factory object containing functions for system provisioning based on OS type.
946
964
  * Each OS type (e.g., 'ubuntu') provides methods for base system setup, user creation,
947
- * timezone configuration, and keyboard layout settings.
965
+ * timezone configuration, and keyboard layout settings. *
966
+ * @memberof UnderpostBaremetal
967
+ * @namespace UnderpostBaremetal.systemProvisioningFactory
948
968
  */
949
969
  systemProvisioningFactory: {
950
970
  /**
951
971
  * @property {object} ubuntu
952
972
  * @description Provisioning steps for Ubuntu-based systems.
973
+ * @memberof UnderpostBaremetal.systemProvisioningFactory
974
+ * @namespace UnderpostBaremetal.systemProvisioningFactory.ubuntu
953
975
  */
954
976
  ubuntu: {
955
977
  /**
@@ -959,6 +981,7 @@ EOF`);
959
981
  * kernel modules, cloud-init, SSH server, and other core utilities.
960
982
  * @param {object} params - The parameters for the function.
961
983
  * @param {string} params.kernelLibVersion - The specific kernel library version to install.
984
+ * @memberof UnderpostBaremetal.systemProvisioningFactory.ubuntu
962
985
  * @returns {string[]} An array of shell commands.
963
986
  */
964
987
  base: ({ kernelLibVersion }) => [
@@ -991,6 +1014,7 @@ SOURCES`,
991
1014
  * @method user
992
1015
  * @description Generates shell commands for creating a root user and configuring SSH access.
993
1016
  * This is a critical security step for initial access to the provisioned system.
1017
+ * @memberof UnderpostBaremetal.systemProvisioningFactory.ubuntu
994
1018
  * @returns {string[]} An array of shell commands.
995
1019
  */
996
1020
  user: () => [
@@ -1014,6 +1038,7 @@ SOURCES`,
1014
1038
  * @param {string} params.timezone - The timezone string (e.g., 'America/New_York').
1015
1039
  * @param {string} params.chronyConfPath - The path to the Chrony configuration file.
1016
1040
  * @param {string} [alias='chrony'] - The alias for the chrony service.
1041
+ * @memberof UnderpostBaremetal.systemProvisioningFactory.ubuntu
1017
1042
  * @returns {string[]} An array of shell commands.
1018
1043
  */
1019
1044
  timezone: ({ timezone, chronyConfPath }, alias = 'chrony') => [
@@ -1081,6 +1106,7 @@ logdir /var/log/chrony
1081
1106
  * @method keyboard
1082
1107
  * @description Generates shell commands for configuring the keyboard layout.
1083
1108
  * This ensures correct input behavior on the provisioned system.
1109
+ * @memberof UnderpostBaremetal.systemProvisioningFactory.ubuntu
1084
1110
  * @returns {string[]} An array of shell commands.
1085
1111
  */
1086
1112
  keyboard: () => [
@@ -1099,6 +1125,7 @@ logdir /var/log/chrony
1099
1125
  * This is crucial for allowing baremetal machines to boot via NFS.
1100
1126
  * @param {object} params - The parameters for the function.
1101
1127
  * @param {string} params.nfsHostPath - The path to be exported by the NFS server.
1128
+ * @memberof UnderpostBaremetal
1102
1129
  * @param {string} [params.subnet='192.168.1.0/24'] - The subnet allowed to access the NFS export.
1103
1130
  * @returns {void}
1104
1131
  */
@@ -1169,6 +1196,7 @@ udp-port = 32766
1169
1196
  * @param {string} params.clientIp - The static IP address for the client device.
1170
1197
  * @param {string} params.subnet - The subnet mask for the client device.
1171
1198
  * @param {string} params.gateway - The gateway IP address for the client device.
1199
+ * @memberof UnderpostBaremetal
1172
1200
  * @returns {string} The generated boot configuration content.
1173
1201
  * @throws {Error} If an invalid workflow ID is provided.
1174
1202
  */
@@ -1229,12 +1257,14 @@ GATEWAY=${gateway}`;
1229
1257
  * @property {object} workflowsConfig
1230
1258
  * @description Configuration for different baremetal provisioning workflows.
1231
1259
  * Each workflow defines specific parameters like system provisioning type,
1232
- * kernel version, Chrony settings, debootstrap image details, and NFS mounts.
1260
+ * kernel version, Chrony settings, debootstrap image details, and NFS mounts. *
1261
+ * @memberof UnderpostBaremetal
1233
1262
  */
1234
1263
  workflowsConfig: {
1235
1264
  /**
1236
1265
  * @property {object} rpi4mb
1237
1266
  * @description Configuration for the Raspberry Pi 4 Model B workflow.
1267
+ * @memberof UnderpostBaremetal.workflowsConfig
1238
1268
  */
1239
1269
  rpi4mb: {
1240
1270
  menuentryStr: 'UNDERPOST.NET UEFI/GRUB/MAAS RPi4 commissioning (ARM64)',
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Cloud-init module for managing the generation and deployment of cloud-init configuration files
3
+ * and associated scripts for baremetal provisioning.
4
+ * @module src/cli/cloud-init.js
5
+ * @namespace UnderpostCloudInit
6
+ */
7
+
1
8
  import dotenv from 'dotenv';
2
9
  import { shellExec } from '../server/process.js';
3
10
  import fs from 'fs-extra';
@@ -15,6 +22,7 @@ const logger = loggerFactory(import.meta);
15
22
  * and associated scripts for baremetal provisioning. This class provides methods
16
23
  * to build various shell scripts and a cloud-init configuration file tailored
17
24
  * for MAAS (Metal as a Service) integration.
25
+ * @memberof UnderpostCloudInit
18
26
  */
19
27
  class UnderpostCloudInit {
20
28
  static API = {
@@ -30,6 +38,7 @@ class UnderpostCloudInit {
30
38
  * @param {object} params.callbackMetaData - Metadata about the callback, used for dynamic configuration.
31
39
  * @param {boolean} params.dev - Development mode flag.
32
40
  * @returns {void}
41
+ * @memberof UnderpostCloudInit
33
42
  */
34
43
  buildTools({ workflowId, nfsHostPath, hostname, callbackMetaData, dev }) {
35
44
  // Destructure workflow configuration for easier access.
@@ -281,6 +290,7 @@ curl -X POST \\
281
290
  * @param {object} [authCredentials={}] - Optional MAAS authentication credentials.
282
291
  * @param {string} [path='/etc/cloud/cloud.cfg.d/90_maas.cfg'] - The target path for the cloud-init configuration file.
283
292
  * @returns {string} The generated cloud-init configuration content.
293
+ * @memberof UnderpostCloudInit
284
294
  */
285
295
  configFactory(
286
296
  {
@@ -494,6 +504,7 @@ EOF_MAAS_CFG`;
494
504
  * This method parses the output of `maas apikey` to extract the consumer key,
495
505
  * consumer secret, token key, and token secret.
496
506
  * @returns {object} An object containing the MAAS authentication credentials.
507
+ * @memberof UnderpostCloudInit
497
508
  * @throws {Error} If the MAAS API key format is invalid.
498
509
  */
499
510
  authCredentialsFactory() {
package/src/cli/cron.js CHANGED
@@ -64,7 +64,6 @@ class UnderpostCron {
64
64
  shellExec(Cmd.cron(deployId, job, name, confCronConfig.jobs[job].expression, options));
65
65
  }
66
66
  }
67
- if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
68
67
  return;
69
68
  }
70
69
  for (const _jobId of jobList.split(',')) {
package/src/cli/deploy.js CHANGED
@@ -12,7 +12,6 @@ import { loggerFactory } from '../server/logger.js';
12
12
  import { shellExec } from '../server/process.js';
13
13
  import fs from 'fs-extra';
14
14
  import dotenv from 'dotenv';
15
- import { DataBaseProvider } from '../db/DataBaseProvider.js';
16
15
  import UnderpostRootEnv from './env.js';
17
16
  import UnderpostCluster from './cluster.js';
18
17
  import Underpost from '../index.js';
@@ -62,7 +61,7 @@ class UnderpostDeploy {
62
61
  )
63
62
  .join('');
64
63
  },
65
- deploymentYamlPartsFactory({ deployId, env, suffix, resources, replicas }) {
64
+ deploymentYamlPartsFactory({ deployId, env, suffix, resources, replicas, image }) {
66
65
  return `apiVersion: apps/v1
67
66
  kind: Deployment
68
67
  metadata:
@@ -81,7 +80,7 @@ spec:
81
80
  spec:
82
81
  containers:
83
82
  - name: ${deployId}-${env}-${suffix}
84
- image: localhost/rockylinux9-underpost:${Underpost.version}
83
+ image: ${image ?? `localhost/rockylinux9-underpost:${Underpost.version}`}
85
84
  # resources:
86
85
  # requests:
87
86
  # memory: "${resources.requests.memory}"
@@ -118,6 +117,7 @@ spec:
118
117
  async buildManifest(deployList, env, options) {
119
118
  const resources = UnderpostDeploy.API.resourcesFactory();
120
119
  const replicas = options.replicas;
120
+ const image = options.image;
121
121
 
122
122
  for (const _deployId of deployList.split(',')) {
123
123
  const deployId = _deployId.trim();
@@ -144,6 +144,7 @@ ${UnderpostDeploy.API.deploymentYamlPartsFactory({
144
144
  suffix: deploymentVersion,
145
145
  resources,
146
146
  replicas,
147
+ image,
147
148
  }).replace('{{ports}}', buildKindPorts(fromPort, toPort))}
148
149
  `;
149
150
  }
@@ -153,21 +154,7 @@ ${UnderpostDeploy.API.deploymentYamlPartsFactory({
153
154
  let secretYaml = '';
154
155
 
155
156
  for (const host of Object.keys(confServer)) {
156
- if (env === 'production')
157
- secretYaml += `
158
- ---
159
- apiVersion: cert-manager.io/v1
160
- kind: Certificate
161
- metadata:
162
- name: ${host}
163
- spec:
164
- commonName: ${host}
165
- dnsNames:
166
- - ${host}
167
- issuerRef:
168
- name: letsencrypt-prod
169
- kind: ClusterIssuer
170
- secretName: ${host}`;
157
+ if (env === 'production') secretYaml += UnderpostDeploy.API.buildCertManagerCertificate({ host });
171
158
 
172
159
  const pathPortAssignment = pathPortAssignmentData[host];
173
160
  // logger.info('', { host, pathPortAssignment });
@@ -221,6 +208,22 @@ spec:
221
208
  }
222
209
  }
223
210
  },
211
+ buildCertManagerCertificate({ host }) {
212
+ return `
213
+ ---
214
+ apiVersion: cert-manager.io/v1
215
+ kind: Certificate
216
+ metadata:
217
+ name: ${host}
218
+ spec:
219
+ commonName: ${host}
220
+ dnsNames:
221
+ - ${host}
222
+ issuerRef:
223
+ name: letsencrypt-prod
224
+ kind: ClusterIssuer
225
+ secretName: ${host}`;
226
+ },
224
227
  getCurrentTraffic(deployId) {
225
228
  // kubectl get deploy,sts,svc,configmap,secret -n default -o yaml --export > default.yaml
226
229
  const hostTest = Object.keys(
@@ -230,7 +233,7 @@ spec:
230
233
  return info.match('blue') ? 'blue' : info.match('green') ? 'green' : null;
231
234
  },
232
235
  async callback(
233
- deployList = 'default',
236
+ deployList = '',
234
237
  env = 'development',
235
238
  options = {
236
239
  remove: false,
@@ -240,7 +243,9 @@ spec:
240
243
  infoUtil: false,
241
244
  expose: false,
242
245
  cert: false,
246
+ certHosts: '',
243
247
  versions: '',
248
+ image: '',
244
249
  traffic: '',
245
250
  replicas: '',
246
251
  node: '',
@@ -302,6 +307,14 @@ docker login nvcr.io
302
307
  Username: $oauthtoken
303
308
  Password: <Your Key>
304
309
  `);
310
+ if (!deployList && options.certHosts) {
311
+ for (const host of options.certHosts.split(',')) {
312
+ shellExec(`sudo kubectl apply -f - <<EOF
313
+ ${UnderpostDeploy.API.buildCertManagerCertificate({ host })}
314
+ EOF`);
315
+ }
316
+ return;
317
+ } else if (!deployList) deployList = 'dd-default';
305
318
  if (deployList === 'dd' && fs.existsSync(`./engine-private/deploy/dd.router`))
306
319
  deployList = fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8');
307
320
  if (options.infoTraffic === true) {
@@ -321,7 +334,7 @@ Password: <Your Key>
321
334
  if (!options.replicas) options.replicas = 1;
322
335
  if (options.sync) UnderpostDeploy.API.sync(deployList, options);
323
336
  if (options.buildManifest === true) await UnderpostDeploy.API.buildManifest(deployList, env, options);
324
- if (options.infoRouter === true) {
337
+ if (options.infoRouter === true || options.buildManifest === true) {
325
338
  logger.info('router', await UnderpostDeploy.API.routerFactory(deployList, env));
326
339
  return;
327
340
  }
@@ -358,7 +371,8 @@ Password: <Your Key>
358
371
  const confServer = JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'));
359
372
  for (const host of Object.keys(confServer)) {
360
373
  shellExec(`sudo kubectl delete HTTPProxy ${host}`);
361
- if (env === 'production' && options.cert === true) shellExec(`sudo kubectl delete Certificate ${host}`);
374
+ if (UnderpostDeploy.API.isValidTLSContext({ host, env, options }))
375
+ shellExec(`sudo kubectl delete Certificate ${host}`);
362
376
  if (!options.remove === true && env === 'development') etcHosts.push(host);
363
377
  }
364
378
 
@@ -370,7 +384,8 @@ Password: <Your Key>
370
384
  if (!options.remove === true) {
371
385
  if (!options.disableUpdateDeployment) shellExec(`sudo kubectl apply -f ./${manifestsPath}/deployment.yaml`);
372
386
  shellExec(`sudo kubectl apply -f ./${manifestsPath}/proxy.yaml`);
373
- if (env === 'production' && options.cert === true)
387
+
388
+ if (UnderpostDeploy.API.isValidTLSContext({ host: Object.keys(confServer)[0], env, options }))
374
389
  shellExec(`sudo kubectl apply -f ./${manifestsPath}/secret.yaml`);
375
390
  }
376
391
  }
@@ -455,7 +470,11 @@ Password: <Your Key>
455
470
  notReadyPods.push(pod);
456
471
  }
457
472
  }
458
- return { ready: notReadyPods.length === 0, notReadyPods, readyPods };
473
+ return {
474
+ ready: pods.length > 0 && notReadyPods.length === 0,
475
+ notReadyPods,
476
+ readyPods,
477
+ };
459
478
  },
460
479
  configMap(env) {
461
480
  shellExec(`kubectl delete configmap underpost-config`);
@@ -479,6 +498,10 @@ Password: <Your Key>
479
498
  fs.writeFileSync(`/etc/hosts`, renderHosts, 'utf8');
480
499
  return { renderHosts };
481
500
  },
501
+ isValidTLSContext: ({ host, env, options }) =>
502
+ env === 'production' &&
503
+ options.cert === true &&
504
+ (!options.certHosts || options.certHosts.split(',').includes(host)),
482
505
  };
483
506
  }
484
507
 
package/src/cli/index.js CHANGED
@@ -24,6 +24,7 @@ program
24
24
  .command('new')
25
25
  .argument('<app-name>', 'The name or deploy-id of the application to create.')
26
26
  .option('--deploy-id', 'Crete deploy ID conf env files')
27
+ .option('--cluster', 'Create deploy ID cluster files and sync to current cluster')
27
28
  .option('--dev', 'Sets the development cli context')
28
29
  .description('Initializes a new Underpost project with a predefined structure.')
29
30
  .action(Underpost.repo.new);
@@ -158,12 +159,14 @@ program
158
159
  .option('--expose', 'Exposes services matching the provided deployment ID list.')
159
160
  .option('--info-util', 'Displays useful `kubectl` utility management commands.')
160
161
  .option('--cert', 'Resets TLS/SSL certificate secrets for deployments.')
162
+ .option('--cert-hosts <hosts>', 'Resets TLS/SSL certificate secrets for specified hosts.')
161
163
  .option('--node <node>', 'Sets optional node for deployment operations.')
162
164
  .option(
163
165
  '--build-manifest',
164
166
  'Builds Kubernetes YAML manifests, including deployments, services, proxies, and secrets.',
165
167
  )
166
168
  .option('--replicas <replicas>', 'Sets a custom number of replicas for deployments.')
169
+ .option('--image <image>', 'Sets a custom image for deployments.')
167
170
  .option('--versions <deployment-versions>', 'A comma-separated list of custom deployment versions.')
168
171
  .option('--traffic <traffic-versions>', 'A comma-separated list of custom deployment traffic weights.')
169
172
  .option('--disable-update-deployment', 'Disables updates to deployments.')
@@ -348,6 +351,8 @@ program
348
351
  .option('--command <command-array>', 'Array of commands to run.')
349
352
  .option('--args <args-array>', 'Array of arguments to pass to the command.')
350
353
  .option('--dev', 'Sets the development context environment for the script.')
354
+ .option('--build', 'Set builder context runner')
355
+ .option('--replicas <replicas>', 'Sets a custom number of replicas for deployment.')
351
356
  .option('--pod-name <pod-name>', 'Optional: Specifies the pod name for test execution.')
352
357
  .option('--volume-host-path <volume-host-path>', 'Optional: Specifies the volume host path for test execution.')
353
358
  .option('--volume-mount-path <volume-mount-path>', 'Optional: Specifies the volume mount path for test execution.')
package/src/cli/lxd.js CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * LXD module for managing LXD virtual machines and networks.
3
+ * @module src/cli/lxd.js
4
+ * @namespace UnderpostLxd
5
+ */
6
+
1
7
  import { getNpmRootPath } from '../server/conf.js';
2
8
  import { getLocalIPv4Address } from '../server/dns.js';
3
9
  import { pbcopy, shellExec } from '../server/process.js';
@@ -32,6 +38,7 @@ class UnderpostLxd {
32
38
  * @param {string} [options.deleteExpose=''] - Delete exposed ports from a VM (format: 'vmName:port1,port2').
33
39
  * @param {string} [options.test=''] - Test health, status and network connectivity for a VM.
34
40
  * @param {string} [options.autoExposeK8sPorts=''] - Automatically expose common Kubernetes ports for the VM.
41
+ * @memberof UnderpostLxd
35
42
  */
36
43
  async callback(
37
44
  options = {
@@ -1,6 +1,6 @@
1
1
  import { commitData } from '../client/components/core/CommonJs.js';
2
2
  import dotenv from 'dotenv';
3
- import { pbcopy, shellExec } from '../server/process.js';
3
+ import { pbcopy, shellCd, shellExec } from '../server/process.js';
4
4
  import { actionInitLog, loggerFactory } from '../server/logger.js';
5
5
  import fs from 'fs-extra';
6
6
  import { getNpmRootPath } from '../server/conf.js';
@@ -13,7 +13,7 @@ const logger = loggerFactory(import.meta);
13
13
 
14
14
  class UnderpostRepository {
15
15
  static API = {
16
- clone(gitUri = 'underpostnet/pwa-microservices-template', options = { bare: false, g8: false }) {
16
+ clone(gitUri = `${process.env.GITHUB_USERNAME}/pwa-microservices-template`, options = { bare: false, g8: false }) {
17
17
  const gExtension = options.g8 === true ? '.g8' : '.git';
18
18
  const repoName = gitUri.split('/').pop();
19
19
  if (fs.existsSync(`./${repoName}`)) fs.removeSync(`./${repoName}`);
@@ -26,7 +26,11 @@ class UnderpostRepository {
26
26
  },
27
27
  );
28
28
  },
29
- pull(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template', options = { g8: false }) {
29
+ pull(
30
+ repoPath = './',
31
+ gitUri = `${process.env.GITHUB_USERNAME}/pwa-microservices-template`,
32
+ options = { g8: false },
33
+ ) {
30
34
  const gExtension = options.g8 === true ? '.g8' : '.git';
31
35
  shellExec(
32
36
  `cd ${repoPath} && git pull https://${
@@ -49,6 +53,7 @@ class UnderpostRepository {
49
53
  },
50
54
  ) {
51
55
  if (commitType === 'reset') {
56
+ if (options.copy) pbcopy(shellExec(`git --no-pager log -1 --pretty=%B`, { stdout: true }));
52
57
  shellExec(`cd ${repoPath} && git reset --soft HEAD~${isNaN(parseInt(subModule)) ? 1 : parseInt(subModule)}`);
53
58
  return;
54
59
  }
@@ -60,7 +65,11 @@ class UnderpostRepository {
60
65
  shellExec(`cd ${repoPath} && git commit ${options?.empty ? `--allow-empty ` : ''}-m "${_message}"`);
61
66
  },
62
67
 
63
- push(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template', options = { f: false, g8: false }) {
68
+ push(
69
+ repoPath = './',
70
+ gitUri = `${process.env.GITHUB_USERNAME}/pwa-microservices-template}`,
71
+ options = { f: false, g8: false },
72
+ ) {
64
73
  const gExtension = options.g8 === true || options.G8 === true ? '.g8' : '.git';
65
74
  shellExec(
66
75
  `cd ${repoPath} && git push https://${process.env.GITHUB_TOKEN}@github.com/${gitUri}${gExtension}${
@@ -81,7 +90,7 @@ class UnderpostRepository {
81
90
  );
82
91
  },
83
92
 
84
- new(repositoryName, options = { dev: false, deployId: false }) {
93
+ new(repositoryName, options = { dev: false, deployId: false, cluster: false }) {
85
94
  return new Promise(async (resolve, reject) => {
86
95
  try {
87
96
  await logger.setUpInfo();
@@ -90,7 +99,7 @@ class UnderpostRepository {
90
99
  return resolve(
91
100
  await UnderpostStartUp.API.listenPortController(UnderpostStartUp.API.listenServerFactory(), ':'),
92
101
  );
93
- if (options.deployId === true) return Config.deployIdFactory(repositoryName);
102
+ if (options.deployId === true) return Config.deployIdFactory(repositoryName, options);
94
103
  const npmRoot = getNpmRootPath();
95
104
  const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
96
105
  const destFolder = `./${repositoryName}`;
@@ -137,6 +146,33 @@ class UnderpostRepository {
137
146
  .concat(diffUntrackOutput.toString().split('\n').filter(Boolean))
138
147
  .filter((f) => !deleteFiles.includes(f));
139
148
  },
149
+ privateConfUpdate(deployId) {
150
+ shellCd(`/home/dd/engine`);
151
+ const privateRepoName = `engine-${deployId.split('dd-')[1]}-private`;
152
+ const privateRepoPath = `../${privateRepoName}`;
153
+ if (fs.existsSync(privateRepoPath)) fs.removeSync(privateRepoPath);
154
+ shellExec(`cd .. && underpost clone ${process.env.GITHUB_USERNAME}/${privateRepoName}`);
155
+ shellExec(`cd ${privateRepoPath} && underpost pull . ${process.env.GITHUB_USERNAME}/${privateRepoName}`);
156
+ const packageJsonDeploy = JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/package.json`, 'utf8'));
157
+ const packageJsonEngine = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));
158
+ if (packageJsonDeploy.version !== packageJsonEngine.version) {
159
+ logger.warn(
160
+ `Version mismatch: deploy-version:${packageJsonDeploy.version} !== engine-version:${packageJsonEngine.version},
161
+ Prevent build private config repo.`,
162
+ );
163
+ return {
164
+ validVersion: false,
165
+ engineVersion: packageJsonEngine.version,
166
+ deployVersion: packageJsonDeploy.version,
167
+ };
168
+ }
169
+ shellExec(`node bin/build ${deployId} conf`);
170
+ return {
171
+ validVersion: true,
172
+ engineVersion: packageJsonEngine.version,
173
+ deployVersion: packageJsonDeploy.version,
174
+ };
175
+ },
140
176
  };
141
177
  }
142
178