@sap/cds-dk 7.9.6 → 8.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/CHANGELOG.md +2136 -0
  2. package/bin/add.js +18 -52
  3. package/bin/bind.js +2 -2
  4. package/bin/build.js +29 -4
  5. package/bin/cds.js +31 -14
  6. package/bin/compile/index.js +7 -6
  7. package/bin/completion/index.js +70 -46
  8. package/bin/completion/scripts/cds-bash.sh +4 -1
  9. package/bin/completion/scripts/cds-fish.fish +13 -0
  10. package/bin/completion/scripts/cds-ps.ps1 +2 -1
  11. package/bin/completion/scripts/cds-zsh.sh +2 -1
  12. package/bin/deploy/index.js +6 -5
  13. package/bin/deploy/to-sqlite.js +2 -2
  14. package/bin/extend.js +19 -50
  15. package/bin/help.js +2 -2
  16. package/bin/init.js +10 -77
  17. package/bin/login.js +13 -5
  18. package/bin/migrate.js +1 -1
  19. package/bin/pull.js +11 -0
  20. package/bin/repl.js +3 -0
  21. package/bin/test.js +5 -0
  22. package/bin/version.js +7 -7
  23. package/bin/watch.js +13 -14
  24. package/lib/bind/KubernetesApiAccessor.js +10 -9
  25. package/lib/build/buildTaskEngine.js +11 -7
  26. package/lib/build/buildTaskFactory.js +15 -43
  27. package/lib/build/buildTaskProviderFactory.js +16 -44
  28. package/lib/build/constants.js +4 -3
  29. package/lib/build/index.js +2 -2
  30. package/lib/build/{buildPlugin.js → plugin.js} +65 -46
  31. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/Chart.yaml +1 -1
  32. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/values.yaml +1 -1
  33. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/Chart.yaml +1 -1
  34. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/templates/_helpers.tpl +7 -0
  35. package/lib/build/plugins/helm/files/subcharts/service-instance/templates/servicebinding.yaml +32 -0
  36. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/templates/serviceinstance.yaml +3 -0
  37. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/values.schema.json +63 -0
  38. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/values.yaml +23 -1
  39. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/Chart.yaml +1 -1
  40. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/deployment.yaml +2 -0
  41. package/lib/build/plugins/helm/files/subcharts/web-application/templates/hpa.yaml +22 -0
  42. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/pod-disruption-budget.yaml +1 -0
  43. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/values.schema.json +49 -0
  44. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/values.yaml +8 -2
  45. package/lib/{init/template/helm/files/chart → build/plugins/helm/files}/templates/_deployment_helpers.tpl +5 -0
  46. package/lib/build/plugins/helm/files/templates/_helpers.tpl +13 -0
  47. package/lib/build/plugins/helm/index.js +81 -0
  48. package/lib/build/plugins.js +12 -15
  49. package/lib/build/provider/featureToggleBuildPlugin.js +7 -39
  50. package/lib/build/provider/hana/2migration.js +168 -124
  51. package/lib/build/provider/hana/index.js +69 -56
  52. package/lib/build/provider/hana/template/package.json +4 -3
  53. package/lib/build/provider/internalBuildPlugin.js +32 -97
  54. package/lib/build/provider/internalBuildTaskProvider.js +12 -48
  55. package/lib/build/provider/java/index.js +2 -3
  56. package/lib/build/provider/mtx/index.js +5 -4
  57. package/lib/build/provider/mtx-extension/index.js +5 -2
  58. package/lib/build/provider/mtx-sidecar/index.js +2 -2
  59. package/lib/build/provider/nodejs/index.js +4 -3
  60. package/lib/build/util.js +83 -12
  61. package/lib/compile/to-mermaid.js +108 -0
  62. package/lib/compile/to_asyncapi.js +7 -0
  63. package/lib/compile/to_openapi.js +7 -0
  64. package/lib/deploy/to-hana/hana.js +37 -34
  65. package/lib/deploy/to-hana/hdiDeployUtil.js +8 -6
  66. package/lib/env/schemas/cds-rc.js +1 -1
  67. package/lib/import/common.js +2 -2
  68. package/lib/import/odata/metadataconverter/MetadataConverter.js +4 -4
  69. package/lib/import/odata/v2parser.js +83 -197
  70. package/lib/import/odata/v4parser.js +1 -38
  71. package/lib/import/openapi/importOpenAPI.js +164 -42
  72. package/lib/index.js +10 -12
  73. package/lib/init/bas.js +91 -0
  74. package/lib/init/constants.js +21 -11
  75. package/lib/init/index.js +72 -150
  76. package/lib/init/merge.js +12 -20
  77. package/lib/init/mvn.js +103 -150
  78. package/lib/init/plugin.js +11 -7
  79. package/lib/init/projectReader.js +53 -20
  80. package/lib/init/registries/mta.js +51 -6
  81. package/lib/init/template/application-logging/files/package.json.hbs +7 -0
  82. package/lib/init/template/application-logging/index.js +13 -1
  83. package/lib/init/template/approuter/files/containerize.yaml.hbs +10 -0
  84. package/lib/init/template/approuter/files/mta.yaml.hbs +1 -2
  85. package/lib/init/template/approuter/files/values.yaml.hbs +19 -4
  86. package/lib/init/template/approuter/files/xs-app.json.hbs +12 -3
  87. package/lib/init/template/approuter/index.js +29 -25
  88. package/lib/init/template/attachments/files/mta.yaml.hbs +14 -0
  89. package/lib/init/template/attachments/files/package.json.hbs +5 -0
  90. package/lib/init/template/attachments/files/values.yaml +7 -0
  91. package/lib/init/template/attachments/index.js +53 -0
  92. package/lib/init/template/{redis-messaging → audit-logging}/files/mta.yaml.hbs +4 -4
  93. package/lib/init/template/audit-logging/files/package.json.hbs +7 -0
  94. package/lib/init/template/audit-logging/index.js +66 -0
  95. package/lib/init/template/cf-manifest/index.js +4 -0
  96. package/lib/init/template/completion/completionSetup.js +54 -33
  97. package/lib/init/template/completion/index.js +7 -1
  98. package/lib/init/template/connectivity/index.js +4 -4
  99. package/lib/init/template/containerize/files/containerize.yaml.hbs +26 -0
  100. package/lib/init/template/containerize/index.js +24 -0
  101. package/lib/init/template/data/index.js +4 -0
  102. package/lib/init/template/destination/files/mta.yaml.hbs +31 -1
  103. package/lib/init/template/destination/files/package.sidecar.json +7 -0
  104. package/lib/init/template/destination/index.js +22 -2
  105. package/lib/init/template/enterprise-messaging/index.js +6 -3
  106. package/lib/init/template/enterprise-messaging-shared/index.js +5 -1
  107. package/lib/init/template/extensibility/files/package.json.hbs +1 -1
  108. package/lib/init/template/extensibility/files/xs-security.json.hbs +2 -8
  109. package/lib/init/template/extensibility/index.js +3 -1
  110. package/lib/init/template/file-based-messaging/index.js +4 -0
  111. package/lib/init/template/h2/index.js +4 -0
  112. package/lib/init/template/hana/files/containerize.yaml.hbs +10 -0
  113. package/lib/init/template/hana/files/db/package.json +3 -2
  114. package/lib/init/template/hana/files/package.json.hbs +4 -7
  115. package/lib/init/template/hana/files/values.yaml.hbs +1 -2
  116. package/lib/init/template/hana/index.js +15 -7
  117. package/lib/init/template/helm/files/Chart.yaml.hbs +2 -3
  118. package/lib/init/template/helm/files/values.schema.json +2173 -0
  119. package/lib/init/template/helm/files/values.yaml.hbs +11 -6
  120. package/lib/init/template/helm/index.js +77 -18
  121. package/lib/init/template/helm-unified-runtime/index.js +19 -56
  122. package/lib/init/template/html5-repo/files/app-package.json.hbs +11 -7
  123. package/lib/init/template/html5-repo/files/manifest.json +13 -0
  124. package/lib/init/template/html5-repo/files/mta.yaml.hbs +14 -33
  125. package/lib/init/template/html5-repo/files/package.sidecar.json +7 -0
  126. package/lib/init/template/html5-repo/files/ui5-deploy.yaml.hbs +21 -0
  127. package/lib/init/template/html5-repo/files/ui5.yaml.hbs +2 -29
  128. package/lib/init/template/html5-repo/files/values.yaml.hbs +6 -2
  129. package/lib/init/template/html5-repo/files/xs-app.json.hbs +6 -7
  130. package/lib/init/template/html5-repo/index.js +41 -35
  131. package/lib/init/template/http/index.js +36 -12
  132. package/lib/init/template/java/index.js +18 -12
  133. package/lib/init/template/kafka/index.js +4 -0
  134. package/lib/init/template/lint/index.js +7 -2
  135. package/lib/init/template/liquibase/index.js +4 -0
  136. package/lib/init/template/local-messaging/index.js +4 -0
  137. package/lib/init/template/malware-scanner/files/mta.yaml.hbs +14 -0
  138. package/lib/init/template/malware-scanner/files/package.json.hbs +17 -0
  139. package/lib/init/template/malware-scanner/files/values.yaml +7 -0
  140. package/lib/init/template/malware-scanner/index.js +47 -0
  141. package/lib/init/template/mta/files/mta.yaml.hbs +3 -3
  142. package/lib/init/template/mta/files/package.json +1 -1
  143. package/lib/init/template/mta/index.js +4 -0
  144. package/lib/init/template/mtx/index.js +4 -0
  145. package/lib/init/template/multitenancy/files/containerize.yaml.hbs +10 -0
  146. package/lib/init/template/multitenancy/files/mta.yaml.hbs +0 -1
  147. package/lib/init/template/multitenancy/files/package.json.hbs +1 -1
  148. package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +6 -5
  149. package/lib/init/template/multitenancy/files/values.yaml.hbs +14 -24
  150. package/lib/init/template/multitenancy/index.js +50 -28
  151. package/lib/init/template/nodejs/files/eslint.config.mjs +2 -0
  152. package/lib/init/template/nodejs/files/package.json.hbs +2 -3
  153. package/lib/init/template/nodejs/index.js +4 -0
  154. package/lib/init/template/notifications/files/mta.yaml.hbs +2 -2
  155. package/lib/init/template/notifications/index.js +4 -0
  156. package/lib/init/template/pipeline/files/.pipeline/config.yml +1 -1
  157. package/lib/init/template/pipeline/files/Jenkinsfile +1 -1
  158. package/lib/init/template/pipeline/index.js +4 -0
  159. package/lib/init/template/portal/files/mta.yaml.hbs +52 -0
  160. package/lib/init/template/portal/files/package.json.hbs +11 -0
  161. package/lib/init/template/portal/files/package.sidecar.json +7 -0
  162. package/lib/init/template/portal/files/portal-site/CommonDataModel.json.hbs +97 -0
  163. package/lib/init/template/portal/files/portal-site/i18n/catalog.properties +1 -0
  164. package/lib/init/template/portal/files/portal-site/i18n/catalog_de.properties +1 -0
  165. package/lib/init/template/portal/files/portal-site/i18n/group.properties +1 -0
  166. package/lib/init/template/portal/files/portal-site/i18n/group_de.properties +1 -0
  167. package/lib/init/template/portal/index.js +84 -0
  168. package/lib/init/template/postgres/index.js +5 -1
  169. package/lib/init/template/redis/files/mta.yaml.hbs +25 -0
  170. package/lib/init/template/redis/files/package.json.hbs +5 -0
  171. package/lib/init/template/redis/index.js +44 -0
  172. package/lib/init/template/redis-messaging/files/package.json.hbs +0 -3
  173. package/lib/init/template/redis-messaging/index.js +8 -18
  174. package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n_de.properties +3 -0
  175. package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n_en.properties +3 -0
  176. package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +13 -1
  177. package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n.properties +2 -2
  178. package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n_de.properties +3 -0
  179. package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n_en.properties +4 -0
  180. package/lib/init/template/sample/files/app/browse/webapp/manifest.json +3 -3
  181. package/lib/init/template/sample/files/app/index.html +1 -1
  182. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Authors.csv +5 -5
  183. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books.csv +6 -6
  184. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books_texts.csv +5 -5
  185. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Genres.csv +16 -16
  186. package/lib/init/template/sample/files/nodejs/cat-service.js +2 -2
  187. package/lib/init/template/sample/files/package.json.hbs +3 -0
  188. package/lib/init/template/sample/index.js +16 -9
  189. package/lib/init/template/sqlite/index.js +4 -0
  190. package/lib/init/template/tiny-sample/files/nodejs/db/data/my.bookshop-Books.csv +3 -3
  191. package/lib/init/template/tiny-sample/files/nodejs/srv/cat-service.cds.hbs +1 -1
  192. package/lib/init/template/tiny-sample/index.js +4 -0
  193. package/lib/init/template/toggles/files/package.json.hbs +1 -1
  194. package/lib/init/template/toggles/index.js +4 -0
  195. package/lib/init/template/typer/index.js +4 -0
  196. package/lib/init/template/typescript/files/package.json +12 -0
  197. package/lib/init/template/typescript/files/tsconfig.json +13 -0
  198. package/lib/init/template/typescript/index.js +39 -0
  199. package/lib/init/template/workzone/index.js +9 -0
  200. package/lib/init/template/workzone-standard/files/manifest.json.hbs +6 -0
  201. package/lib/init/template/workzone-standard/files/mta.yaml.hbs +59 -0
  202. package/lib/init/template/workzone-standard/index.js +46 -0
  203. package/lib/init/template/xsuaa/files/package.json.hbs +1 -1
  204. package/lib/init/template/xsuaa/files/values.yaml.hbs +3 -2
  205. package/lib/init/template/xsuaa/index.js +11 -7
  206. package/lib/init/validate.js +27 -0
  207. package/lib/lint/generators.js +1 -1
  208. package/lib/lint/io.js +25 -7
  209. package/lib/mtx/auth_manager.js +64 -30
  210. package/lib/mtx/download_legacy.js +2 -2
  211. package/lib/mtx/index.js +0 -4
  212. package/lib/mtx/params.js +32 -38
  213. package/lib/mtx/pull.js +151 -43
  214. package/lib/mtx/push.js +3 -3
  215. package/lib/mtx/settings_manager.js +75 -35
  216. package/lib/mtx/tenant_action.js +1 -1
  217. package/lib/mtx/util/cf.js +1 -1
  218. package/lib/mtx/util/fs.js +26 -1
  219. package/lib/mtx/util/logging.js +7 -3
  220. package/lib/util/command.js +0 -2
  221. package/lib/util/fs.js +2 -3
  222. package/lib/util/question.js +28 -0
  223. package/lib/util/term.js +5 -3
  224. package/npm-shrinkwrap.json +225 -1083
  225. package/package.json +13 -8
  226. package/bin/activate.js +0 -77
  227. package/lib/compile/asyncapi/channels.js +0 -22
  228. package/lib/compile/asyncapi/components/messageTraits/index.js +0 -89
  229. package/lib/compile/asyncapi/components/messages/index.js +0 -173
  230. package/lib/compile/asyncapi/components/schemas/annotations.js +0 -33
  231. package/lib/compile/asyncapi/components/schemas/array.js +0 -8
  232. package/lib/compile/asyncapi/components/schemas/cache.js +0 -14
  233. package/lib/compile/asyncapi/components/schemas/definition.js +0 -187
  234. package/lib/compile/asyncapi/components/schemas/enum.js +0 -16
  235. package/lib/compile/asyncapi/components/schemas/examples.js +0 -10
  236. package/lib/compile/asyncapi/components/schemas/index.js +0 -14
  237. package/lib/compile/asyncapi/components/schemas/localized.js +0 -29
  238. package/lib/compile/asyncapi/components/schemas/primitiveElement.js +0 -41
  239. package/lib/compile/asyncapi/components/schemas/ref.js +0 -45
  240. package/lib/compile/asyncapi/components/schemas/utils.js +0 -108
  241. package/lib/compile/asyncapi/index.js +0 -247
  242. package/lib/compile/asyncapi/message.js +0 -13
  243. package/lib/compile/asyncapi/utils.js +0 -27
  244. package/lib/compile/openapi/csdl2openapi.js +0 -2448
  245. package/lib/compile/openapi/index.js +0 -68
  246. package/lib/init/template/helm/files/chart/templates/NOTES.txt +0 -14
  247. package/lib/init/template/helm/files/chart/templates/_helpers.tpl +0 -28
  248. package/lib/init/template/helm/files/chart/values.root.schema.json +0 -61
  249. package/lib/init/template/helm/files/chart/values.schema.json +0 -366
  250. package/lib/init/template/helm-unified-runtime/files/Chart.yaml.hbs +0 -10
  251. package/lib/init/template/helm-unified-runtime/files/templates/_deployment_helpers.tpl +0 -90
  252. package/lib/init/template/helm-unified-runtime/files/templates/_helpers.tpl +0 -28
  253. package/lib/init/template/helm-unified-runtime/files/values.root.schema.json +0 -61
  254. package/lib/init/template/helm-unified-runtime/files/values.schema.json +0 -366
  255. package/lib/init/template/helm-unified-runtime/files/values.yaml.hbs +0 -26
  256. package/lib/init/template/helm-unified-runtime/package.json +0 -4
  257. package/lib/init/template/multitenancy/files/mtxs-configmap-java-approuter.yaml +0 -20
  258. package/lib/init/template/multitenancy/files/mtxs-configmap-java.yaml +0 -18
  259. package/lib/init/template/multitenancy/files/mtxs-configmap-nodejs-approuter.yaml +0 -12
  260. package/lib/init/template/multitenancy/files/mtxs-configmap-nodejs.yaml +0 -12
  261. package/lib/init/template/multitenancy/files/saas-registry-secret.yaml +0 -9
  262. package/lib/init/template/nodejs/files/eslint.config.js +0 -13
  263. package/lib/init/template/notebook/index.js +0 -11
  264. package/lib/init/template/samples/index.js +0 -9
  265. package/lib/mtx/activate.js +0 -238
  266. package/lib/mtx/extend.js +0 -173
  267. package/lib/util/exec.d.ts +0 -54
  268. package/lib/util/exec.js +0 -211
  269. /package/lib/{init/template/approuter/files → build/plugins/helm/files/plugins/approuter}/approuter-configmap.yaml +0 -0
  270. /package/lib/{init/template/connectivity/files → build/plugins/helm/files/plugins/connectivity}/connectivity-proxy-info.yaml +0 -0
  271. /package/lib/{init/template/html5-repo/files → build/plugins/helm/files/plugins/html5-repo}/html5-apps-deployer-configmap.yaml +0 -0
  272. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/_helpers.tpl +0 -0
  273. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/job.yaml +0 -0
  274. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/secret.yaml +0 -0
  275. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/service-account.yaml +0 -0
  276. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/service-binding.yaml +0 -0
  277. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/values.schema.json +0 -0
  278. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/NOTES.txt +0 -0
  279. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/_api.tpl +0 -0
  280. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/_helpers.tpl +0 -0
  281. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/api-rule.yaml +0 -0
  282. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/network-policy.yaml +0 -0
  283. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/rbac.yaml +0 -0
  284. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/secret.yaml +0 -0
  285. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service-account.yaml +0 -0
  286. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service-binding.yaml +0 -0
  287. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service.yaml +0 -0
  288. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/virtual-service.yaml +0 -0
  289. /package/lib/{init/template/helm-unified-runtime → build/plugins/helm}/files/templates/NOTES.txt +0 -0
  290. /package/lib/init/template/{nodejs/files → java}/.cdsrc.json +0 -0
  291. /package/lib/init/template/tiny-sample/files/nodejs/db/{data-model.cds → schema.cds} +0 -0
@@ -2,8 +2,8 @@ const fs = require('fs')
2
2
  const path = require('path')
3
3
  const cds = require('../cds')
4
4
  const BuildTaskProviderFactory = require('./buildTaskProviderFactory')
5
- const { hasJavaNature, getProperty, flatten, getDefaultModelOptions, hasOptionValue } = require('./util')
6
- const { FILE_EXT_CDS, BUILD_TASK_JAVA_CF, BUILD_TASK_JAVA, CONTENT_WS } = require("./constants")
5
+ const { hasJavaNature, getProperty, getDefaultModelOptions, hasOptionValue, BuildError } = require('./util')
6
+ const { FILE_EXT_CDS, OPTION_WS } = require("./constants")
7
7
  const term = require('../util/term')
8
8
  const DEBUG = cds.debug('cli|build')
9
9
 
@@ -48,17 +48,13 @@ class BuildTaskFactory {
48
48
  async _createTasks() {
49
49
  DEBUG?.(`determining build tasks for project [${cds.root}].`)
50
50
 
51
- // clearing model cache (details https://github.tools.sap/cap/cds/pull/181) is no longer required
52
- // because of changes https://github.tools.sap/cap/cds/pull/1121
53
- // cds.resolve.cache = {}
54
-
55
51
  let tasks = BuildTaskFactory._getExistingTasks()
56
52
  if (tasks.length === 0) {
57
53
  tasks = await this.providerFactory.lookupTasks()
58
54
  this._applyCliOptions(tasks)
59
55
  } else {
60
56
  this._applyCliOptions(tasks)
61
- // 1. apply default values including task.for and task.use and ensure that for all tasks a provider exists - throwing error otherwise
57
+ // 1. apply default values including task.for and ensure that for all tasks a provider exists - throwing error otherwise
62
58
  await this.providerFactory.applyTaskDefaults(tasks)
63
59
  // ensure that dependencies get wired up before filtering
64
60
  await this.providerFactory.lookupTasks(tasks, true)
@@ -84,7 +80,7 @@ class BuildTaskFactory {
84
80
  // obligatory task defaults shared by all tasks
85
81
  await BuildTaskFactory._applyCommonTaskDefaults(tasks)
86
82
 
87
- this._setDefaultBuildTargetFolder(tasks)
83
+ BuildTaskFactory._setDefaultBuildTargetFolder(tasks)
88
84
  return tasks
89
85
  }
90
86
 
@@ -106,24 +102,21 @@ class BuildTaskFactory {
106
102
  const modelPaths = await getDefaultModelOptions()
107
103
  let wsModelPaths
108
104
  // calculate only once
109
- if (cds.cli.options?.ws || tasks.some(task => hasOptionValue(task.options?.[CONTENT_WS], true))) {
105
+ if (cds.cli.options?.[OPTION_WS] || tasks.some(task => hasOptionValue(task.options?.[OPTION_WS], true))) {
110
106
  wsModelPaths = await getDefaultModelOptions(true)
111
107
  }
112
108
  // set default model options
113
109
  tasks.forEach(task => {
114
- this._setTaskModelOptions(task, cds.cli.options?.ws || hasOptionValue(task.options?.[CONTENT_WS], true) ? wsModelPaths : modelPaths)
110
+ this._setTaskModelOptions(task, cds.cli.options?.[OPTION_WS] || hasOptionValue(task.options?.[OPTION_WS], true) ? wsModelPaths : modelPaths)
115
111
  if (!task.src) {
116
- throw new Error(`Invalid build task definition - value of property 'src' is missing in [${task.for || task.use}].`)
112
+ throw new BuildError(`Mandatory property 'src' not defined for build task '${task.for}'.`)
117
113
  }
118
114
  })
119
115
  }
120
116
 
121
- _setDefaultBuildTargetFolder(tasks) {
122
- const task = tasks.find(task => task.for === BUILD_TASK_JAVA_CF || task.for === BUILD_TASK_JAVA)
123
- const srv = task ? task.src : BuildTaskFactory._getModuleFolder(flatten([cds.env.folders.srv])) || "srv"
124
-
117
+ static _setDefaultBuildTargetFolder() {
125
118
  // Java projects use "." as the default build target folder
126
- if (hasJavaNature([path.join(cds.root, srv), cds.root]) && BuildTaskFactory._adaptBuildTargetSettingForJava()) {
119
+ if (hasJavaNature() && this._adaptBuildTargetSettingForJava()) {
127
120
  DEBUG?.("using inplace build for java project instead of default staging build")
128
121
  }
129
122
  }
@@ -150,13 +143,12 @@ class BuildTaskFactory {
150
143
  const options = this.options
151
144
  // filter tasks using either option for, use, src
152
145
  let resultTasks = tasks.filter(task => {
153
- return (!options.use || options.use === task.use)
154
- && (!options.for || options.for === task.for)
146
+ return (!options.for || options.for === task.for)
155
147
  && (!options.src || options.src === task.src)
156
148
  })
157
149
  if (resultTasks.length === 0) {
158
- if (options.for || options.use) {
159
- const task = this.providerFactory.getTask(options.for ? { for: options.for } : { use: options.use })
150
+ if (options.for) {
151
+ const task = this.providerFactory.getTask({ for: options.for })
160
152
  if (options.src) {
161
153
  task.src = options.src
162
154
  }
@@ -180,9 +172,9 @@ class BuildTaskFactory {
180
172
  if (options.dest) {
181
173
  task.dest = options.dest
182
174
  }
183
- if (options.opts) {
184
- const opts = BuildTaskFactory._scanTaskOptionParams(options.opts)
185
- task.options = task.options ? Object.assign(task.options, opts) : opts
175
+ if (options.taskOptions) {
176
+ const taskOptions = JSON.parse(JSON.stringify(options.taskOptions))
177
+ task.options = task.options ? Object.assign(task.options, taskOptions) : taskOptions
186
178
  }
187
179
  })
188
180
  }
@@ -233,26 +225,6 @@ class BuildTaskFactory {
233
225
  }, '{') + '}'
234
226
  }
235
227
 
236
- static _scanTaskOptionParams(optsParams) {
237
- // need to create new regex every call since a constant would keep the match state
238
- const quoteRegex = /([\w-]+)=([\w/.-]+|\[([\w/,.-]+)\])/g
239
-
240
- // captures a=1 => a:1
241
- // a=[x,y,z] => a:[x,y,z]
242
- // a=1,b=[x,y,z] => a:1 b=[x,y,z]
243
- let match = quoteRegex.exec(optsParams)
244
- const taskOptions = {}
245
-
246
- while (match != null) {
247
- const key = match[1]
248
- const value = match[3] || match[2]
249
- const valueArray = value.split(",")
250
- taskOptions[key] = valueArray.length > 1 ? valueArray.map((entry) => entry.trim()) : value
251
- match = quoteRegex.exec(optsParams)
252
- }
253
- return taskOptions
254
- }
255
-
256
228
  /**
257
229
  * Determines the module folder from the past list that may represent files or folders w or w/o .cds file extension.
258
230
  * @param {Array} filesOrFolders
@@ -18,7 +18,6 @@ class BuildTaskProviderFactory {
18
18
  throw new BuildError(`Invalid build options - property '${key}' must be a string`)
19
19
  }
20
20
  })
21
- this._buildOptions = options
22
21
  this._context = { options, tasks: [] } // resolved tasks
23
22
  }
24
23
  get options() {
@@ -40,14 +39,10 @@ class BuildTaskProviderFactory {
40
39
 
41
40
  async applyTaskDefaults(tasks) {
42
41
  return Promise.all(tasks.map(async (task) => {
43
- if (!task.for && !task.use) {
44
- throw new Error(`Invalid build task definition - property 'for' and property 'use' missing`)
42
+ if (!task.for) {
43
+ throw new BuildError(`Mandatory property 'for' not defined for build task.`)
45
44
  }
46
- const provider = this._getProvider(task)
47
- if (provider instanceof DefaultBuildTaskProvider) {
48
- DEBUG?.(`No provider found for build task '${task.use}', using default provider`)
49
- }
50
- return this._applyTaskDefaults(provider, [task])
45
+ return this._applyTaskDefaults(this._getProvider(task), [task])
51
46
  }))
52
47
  }
53
48
 
@@ -67,23 +62,23 @@ class BuildTaskProviderFactory {
67
62
  }
68
63
 
69
64
  /**
70
- * Create a BuildPlugin instance for the given build task.
65
+ * Create a Plugin instance for the given build task.
71
66
  * The implementation is loaded based on the build task's 'for' or 'use' option.
72
67
  * @param {*} task
73
68
  */
74
69
  createPlugin(task) {
75
- const BuildPlugin = this.getPlugin(task)
70
+ const Plugin = this.getPlugin(task)
76
71
  const resolvedTask = this._resolveTask(task)
77
- DEBUG?.(`loaded build plugin [${resolvedTask.use}]`)
72
+ DEBUG?.(`loaded build plugin [${resolvedTask.for}]`)
78
73
 
79
- const plugin = new BuildPlugin()
80
- if (!(plugin instanceof BuildPlugin)) {
74
+ const plugin = new Plugin()
75
+ if (!(plugin instanceof Plugin)) {
81
76
  throw new Error(`Invalid Build plugin type ${task.for}`)
82
77
  }
83
78
  plugin._task = resolvedTask
84
79
  plugin._context = this.context
85
80
  this.context.tasks.push(resolvedTask)
86
- DEBUG?.(`created build plugin [${resolvedTask.use}]`)
81
+ DEBUG?.(`created build plugin [${resolvedTask.for}]`)
87
82
  return plugin
88
83
  }
89
84
 
@@ -98,7 +93,7 @@ class BuildTaskProviderFactory {
98
93
  try {
99
94
  return provider.getPlugin(task)
100
95
  } catch (e) {
101
- console.error(`Provider failed to load build plugin class - provider: ${provider.constructor.name}, task: ${task.for || task.use} :\n` + e)
96
+ console.error(`Provider failed to load build plugin class ${task.for} - provider: ${provider.constructor.name}`)
102
97
  throw e
103
98
  }
104
99
  }
@@ -124,7 +119,7 @@ class BuildTaskProviderFactory {
124
119
  //validate source path
125
120
  fs.realpathSync(resolvedTask.src)
126
121
  } catch (e) {
127
- throw new Error(`Build task [${resolvedTask.for || resolvedTask.use}] could not be resolved - folder src [${path.resolve(cds.root, task.src)}] does not exist`)
122
+ throw new BuildError(`The 'src' folder '${path.resolve(cds.root, task.src)}' for build task '${resolvedTask.for}' does not exist`)
128
123
  }
129
124
  resolvedTask.dest = path.resolve(cds.root, cds.env.build.target, task.dest || task.src)
130
125
  resolvedTask.options = task.options || {}
@@ -136,12 +131,12 @@ class BuildTaskProviderFactory {
136
131
  try {
137
132
  return provider.providesTask(key)
138
133
  } catch (e) {
139
- console.error(`Build task provider ${provider.constructor.name} returned an error:\n` + e)
134
+ console.error(`Build task provider ${provider.constructor.name} returned an error`)
140
135
  throw e
141
136
  }
142
137
  })
143
138
  if (!provider) {
144
- throw new BuildError(`No provider found for build task '${key.for || key.use}'. Ensure that all required dependencies have been added and 'npm install' has been executed.`)
139
+ throw new BuildError(`No provider found for build task '${key.for}'. Ensure that all required dependencies have been added and 'npm install' has been executed.`)
145
140
  }
146
141
  return provider
147
142
  }
@@ -155,37 +150,13 @@ class BuildTaskProviderFactory {
155
150
  }
156
151
 
157
152
  _loadProviders() {
158
- // DefaultBuildTaskProvider must be last entry
159
153
  return [
160
154
  new InternalBuildTaskProvider(),
161
- new PluginBuildTaskProvider(),
162
- new DefaultBuildTaskProvider()
155
+ new PluginBuildTaskProvider()
163
156
  ]
164
157
  }
165
158
  }
166
159
 
167
- /**
168
- * Default provider implementation handling fully qualified custom build task declarations.
169
- * Has to be the last entry in the providers list.
170
- */
171
- class DefaultBuildTaskProvider extends BuildTaskProvider {
172
- constructor() {
173
- super()
174
- }
175
-
176
- providesTask(key) {
177
- return !!key.use
178
- }
179
-
180
- getPlugin(task) {
181
- try {
182
- return require(require.resolve(task.use, { paths: [cds.root] }))
183
- } catch (e) {
184
- throw new Error(`Build task could not be resolved - module [${task.use}] cannot be loaded:\n` + e)
185
- }
186
- }
187
- }
188
-
189
160
  /**
190
161
  * Default provider implementation handling fully qualified custom build task declarations.
191
162
  */
@@ -226,7 +197,8 @@ class PluginBuildTaskProvider extends BuildTaskProvider {
226
197
  }
227
198
 
228
199
  getTask(key) {
229
- const task = this.plugins.get(key.for).taskDefaults ?? {}
200
+ // plugin entry is already validated, a taskDefaults default member exists
201
+ const task = JSON.parse(JSON.stringify(this.plugins.get(key.for).taskDefaults ?? {}))
230
202
  task.for = key.for
231
203
  task.src ??= DEFAULT_SRC_FOLDER
232
204
  task.src = task.src.replace(/\/$/, '')
@@ -4,8 +4,6 @@ exports.OUTPUT_MODE_FILESYSTEM = 0x1
4
4
  exports.OUTPUT_MODE_RESULT = 0x2
5
5
 
6
6
  exports.DEFAULT_SRC_FOLDER = '.'
7
- exports.BUILD_TASK_NPM_SCOPE = "@sap"
8
- exports.BUILD_TASK_PREFIX = exports.BUILD_TASK_NPM_SCOPE + "/cds/build"
9
7
  exports.BUILD_TASK_JAVA = "java"
10
8
  exports.BUILD_TASK_JAVA_CF = "java-cf"
11
9
  exports.BUILD_TASK_NODEJS = "nodejs"
@@ -16,6 +14,8 @@ exports.BUILD_TASK_MTX = "mtx"
16
14
  exports.BUILD_TASK_MTX_SIDECAR = "mtx-sidecar"
17
15
  exports.BUILD_TASK_MTX_EXTENSION = "mtx-extension"
18
16
  exports.BUILD_TASKS = [this.BUILD_TASK_JAVA, this.BUILD_TASK_JAVA_CF, this.BUILD_TASK_NODEJS, this.BUILD_TASK_NODE_CF, this.BUILD_TASK_HANA, this.BUILD_TASK_FIORI, this.BUILD_TASK_MTX, this.BUILD_TASK_MTX_SIDECAR, this.BUILD_TASK_MTX_EXTENSION]
17
+ exports.DEFAULT_BUILTIN_PRIORITY_MIN = 0
18
+ exports.DEFAULT_BUILTIN_PRIORITY_MAX = 524
19
19
 
20
20
  exports.ODATA_VERSION_V2 = "v2"
21
21
  exports.ODATA_VERSION_V4 = "v4"
@@ -33,8 +33,9 @@ exports.CONTENT_CDSRC_JSON = "contentCdsrcJson" // copy .cdsrc.j
33
33
  exports.CONTENT_NODE_MODULES = "contentNodeModules" // copy node_modules folder into deployment folder - DISABLED by default
34
34
  exports.CONTENT_ENV = "contentEnv" // copy .env file into deployment folder - DISABLED by default
35
35
  exports.CONTENT_DEFAULT_ENV_JSON = "contentDefaultEnvJson" // copy default-env.json file into deployment folder - DISABLED by default
36
- exports.CONTENT_WS = "ws" // determine model paths including submodules + CONTENT_SUBMODULES_HANA - DISABLED by default
37
36
 
37
+ exports.OPTION_WS = "ws" // run a workspace build, e.g. including model folders of configured npm workspaces
38
+ exports.OPTION_WS_PACK = "ws-pack" // enable tarball based packaging of workspace dependencies
38
39
  exports.CSV_FILE_TARGET = "csvFileTarget" // target folder when copying CSV files to the deployment target folder ./db/src/gen/*, default is 'data'
39
40
  exports.CSV_FILE_DETECTION = "csvFileDetection" // detect CSV files based on CDS model location - ENABLED by default
40
41
  exports.EXTENSION_POINT_VALIDATION = "extensionPointValidation" // validate extension point restrictions defined by the extended SaaS app - ENABLED by default
@@ -1,10 +1,10 @@
1
1
  const fs = require('fs')
2
2
  const cds = require('../cds')
3
3
  const BuildTaskEngine = require('./buildTaskEngine')
4
- const BuildPlugin = require('./buildPlugin')
4
+ const Plugin = require('./plugin')
5
5
  const { BuildError } = require('./util')
6
6
 
7
- module.exports = { build, register, Plugin: BuildPlugin, BuildError, BuildPlugin }
7
+ module.exports = { build, register, Plugin, BuildError }
8
8
 
9
9
  /**
10
10
  * Executes cds build in the directory defined by cds.root.
@@ -1,8 +1,8 @@
1
1
  const path = require('path')
2
- const fs = require('fs').promises
2
+ const fs = require('fs')
3
3
  const cds = require('../cds')
4
4
  const { OUTPUT_MODE, OUTPUT_MODE_FILESYSTEM, SEVERITY_INFO, SEVERITY_WARNING, SEVERITY_ERROR } = require('./constants')
5
- const { hasOptionValue, getProperty, relativePaths, BuildMessage, pathExists } = require('./util')
5
+ const { hasOptionValue, getProperty, relativePaths, BuildMessage, pathExists, filterFeaturePaths, getFiles } = require('./util')
6
6
  const DEBUG = cds.debug('cli|build')
7
7
 
8
8
  /**
@@ -19,27 +19,27 @@ const DEBUG = cds.debug('cli|build')
19
19
  * </ul>
20
20
  * The reflected CSN can be accessed using the async method <code>model()</code>.
21
21
  */
22
- class BuildPlugin {
22
+ class Plugin {
23
23
  /**
24
24
  * @constructor
25
25
  */
26
26
  constructor() {
27
- this._written = new Set()
27
+ this._files = new Set()
28
28
  this._messages = []
29
29
  }
30
- static hasTask() {
31
- return true
32
- }
30
+
33
31
  static INFO = SEVERITY_INFO
34
32
  static WARNING = SEVERITY_WARNING
35
33
  static ERROR = SEVERITY_ERROR
34
+
36
35
  /**
37
- * Returns the build context
38
- * @returns {object}
36
+ * Determines whether a task of this type will be created when cds build is executed,
37
+ * returns true by default.
39
38
  */
40
- get context() {
41
- return this._context
39
+ static hasTask() {
40
+ return true
42
41
  }
42
+
43
43
  /**
44
44
  * Returns the build task executed by this build plugin.
45
45
  * @return {object}
@@ -59,26 +59,33 @@ class BuildPlugin {
59
59
  }
60
60
 
61
61
  /**
62
- * Returns the list of files written by this build plugin.
62
+ * Returns the list of files and folders written by this build plugin.
63
63
  * @return {Array}
64
64
  */
65
65
  get files() {
66
- return [...this._written]
66
+ return [...this._files]
67
67
  }
68
68
 
69
69
  /**
70
- * Returns the priority of this plugin as number, where 0 represents the minimum value and
71
- * Number.MAX_SAFE_INTEGER the maximum value.
72
- * Positive numbers mean higher and negative numbers lower priority. Build plugins
73
- * with higher priority value are executed before plugins with lower priority.
74
- * <br>
75
- * Note: Currently not supported for custom build plugins as they are always executed
76
- * before the built-in plugins.
70
+ * Returns the build context
71
+ * @returns {object}
72
+ */
73
+ get context() {
74
+ return this._context
75
+ }
76
+
77
+ /**
78
+ * Returns the priority of this plugin as number, where 1024 represents the default value
79
+ * to ensure that custom plugins are by default executed before the built-in plugins.
80
+ * The higher the priority value, the sooner the build plugin will be run.
81
+ * The range of valid priority values is from -1024 to +1024.
82
+ * Built-in plugins have a priority value range from 0 - 524.
77
83
  * @return {number} the priority for this plugin as integer.
78
84
  */
79
85
  get priority() {
80
- return 1
86
+ return 1024
81
87
  }
88
+
82
89
  /**
83
90
  * Called by the framework immediately after this instance has been created.
84
91
  * The instance has already been fully initialized.
@@ -93,8 +100,7 @@ class BuildPlugin {
93
100
  * @abstract
94
101
  * Called by the framework to create the artifacts of this build plugin.
95
102
  */
96
- async build() {
97
- }
103
+ async build() { }
98
104
 
99
105
  /**
100
106
  * Called by the framework immediately before 'build' to delete any output created by this build plugin.
@@ -110,7 +116,7 @@ class BuildPlugin {
110
116
  && this.task.src !== this.task.dest
111
117
  && !isSubDirectory(this.task.dest, this.task.src)
112
118
  && await pathExists(this.task.dest)) {
113
- return fs.rm(this.task.dest, { force: true, recursive: true })
119
+ return fs.promises.rm(this.task.dest, { force: true, recursive: true })
114
120
  }
115
121
  }
116
122
 
@@ -130,19 +136,17 @@ class BuildPlugin {
130
136
  dest = path.resolve(this.task.dest, dest)
131
137
  }
132
138
  this.pushFile(dest)
133
- await fs.mkdir(path.dirname(dest), { recursive: true })
134
- await fs.writeFile(dest, typeof data === "object" && !Buffer.isBuffer(data) ? JSON.stringify(data, null, 2) : data)
139
+ await fs.promises.mkdir(path.dirname(dest), { recursive: true })
140
+ await fs.promises.writeFile(dest, typeof data === "object" && !Buffer.isBuffer(data) ? JSON.stringify(data, null, 2) : data)
135
141
  }
136
142
  }
137
143
  }
138
144
  }
139
145
 
140
- // TODO only works with files due to fs.copyFile, check usages
141
146
  /**
142
- * Copy a file or directory if the build task option 'outputMode' does not have the value 'resultOnly'.
143
- * The directory can have contents.
147
+ * Asynchronously copies a single file or the entire directory structure from 'src' to 'dest', including subdirectories and files.
144
148
  * <p>
145
- * Note: The file name is stored in the list of files written by this build plugin.
149
+ * Note: The file names are stored in the list of files written by this build plugin.
146
150
  * </p>
147
151
  * @param {string} src The absolute or relative source path of the file or directory to copy.
148
152
  * Relative paths will be resolved to this task's source path.
@@ -161,10 +165,16 @@ class BuildPlugin {
161
165
  // relative to build task's destination path
162
166
  dest = path.resolve(this.task.dest, dest)
163
167
  }
164
- this.pushFile(dest)
165
- return fs.cp(src, dest, { recursive: true })
168
+ // list all copied files recursively
169
+ if (fs.lstatSync(src).isDirectory()) {
170
+ await fs.promises.cp(src, dest, { recursive: true })
171
+ const files = getFiles(dest)
172
+ files.forEach(file => this.pushFile(file))
173
+ } else {
174
+ this.pushFile(dest)
175
+ return fs.promises.cp(src, dest, { recursive: true })
176
+ }
166
177
  }
167
- return dest
168
178
  }
169
179
  }
170
180
  }
@@ -182,11 +192,13 @@ class BuildPlugin {
182
192
  }
183
193
 
184
194
  /**
185
- * Returns the reflected CSN model using this build task's model settings.
186
- * @return {object} the reflected CSN
195
+ * Returns a compiled CSN model according to the model paths defined by this build task.
196
+ * The model includes model enhancements defined by feature toggles, if any.
197
+ * @return {object} the compiled CSN model
187
198
  */
188
199
  async model() {
189
- const files = this._resolveModel()
200
+ const files = cds.resolve(this.task.options.model || this.task.src)
201
+
190
202
  if (!files || files.length === 0) {
191
203
  console.log(`no CDS model found for [${this.task.for}] build task [${this.task.src}] - nothing to be done`)
192
204
  return null
@@ -202,6 +214,20 @@ class BuildPlugin {
202
214
  return model
203
215
  }
204
216
 
217
+ /**
218
+ * Returns a compiled base model CSN according to the model paths defined by this build task.
219
+ * The base model does not include any model enhancements defined by feature toggles.
220
+ * @return {object} the compiled base model CSN
221
+ */
222
+ async baseModel() {
223
+ const model = await this.model()
224
+ if (!model) {
225
+ return model
226
+ }
227
+ const sources = filterFeaturePaths(model, this.task.options.model || this.task.src)
228
+ return sources.features ? cds.load(sources.base, this.options()) : model
229
+ }
230
+
205
231
  options() {
206
232
  return { messages: this._messages }
207
233
  }
@@ -211,16 +237,9 @@ class BuildPlugin {
211
237
  * @param {string} filePath
212
238
  */
213
239
  pushFile(filePath) {
214
- this._written.add(filePath)
215
- }
216
- /**
217
- * Returns a list of CDS model files defining the transitive closure of the CDS model based on the model options
218
- * defined for this build task.
219
- */
220
- _resolveModel() {
221
- const modelPaths = Array.isArray(this.task.options.model) && this.task.options.model.length > 0 ? this.task.options.model : !Array.isArray(this.task.options.model) && this.task.options.model || this.task.src
222
- return cds.resolve(modelPaths)
240
+ this._files.add(filePath)
223
241
  }
242
+
224
243
  /** Determines whether the given build option value has been set for this build task.
225
244
  * If the value is omitted, the existence of the given property name is checked.
226
245
  */
@@ -238,4 +257,4 @@ class BuildPlugin {
238
257
  return value
239
258
  }
240
259
  }
241
- module.exports = BuildPlugin
260
+ module.exports = Plugin
@@ -2,4 +2,4 @@ apiVersion: v2
2
2
  description: A Helm Chart for creating a Content Deployment job
3
3
  name: content-deployment
4
4
  type: application
5
- version: 1.6.0
5
+ version: 1.6.1
@@ -15,7 +15,7 @@ global:
15
15
  _internal:
16
16
  content-deployment:
17
17
  versions:
18
- 1.6.0: true
18
+ 1.6.1: true
19
19
  # Will be used instead of the `.Chart.Name`, e.g. when generating the Deployment name.
20
20
  # nameOverride: name
21
21
 
@@ -2,4 +2,4 @@ apiVersion: v2
2
2
  description: A Helm chart for creating service instances on btp-service-operator
3
3
  name: service-instance
4
4
  type: application
5
- version: 1.3.0
5
+ version: 1.5.1
@@ -64,3 +64,10 @@ app.kubernetes.io/partOf: {{ .Values.global.partOf }}
64
64
  {{- end }}
65
65
  {{- end }}
66
66
  {{- end }}
67
+
68
+ {{/*
69
+ Binding name
70
+ */}}
71
+ {{- define "service-instance.internal.bindingName" -}}
72
+ {{- printf "%s-%s" (include "service-instance.internal.fullname" .root ) .name }}
73
+ {{- end }}
@@ -0,0 +1,32 @@
1
+ {{- $bindings := omit .Values.bindings "defaultProperties" -}}
2
+ {{- range $name, $params := $bindings }}
3
+ {{- $defaultProperties := deepCopy $.Values.bindings.defaultProperties -}}
4
+ {{- $mergedParams := (deepCopy $params | mergeOverwrite $defaultProperties ) }}
5
+ ---
6
+ apiVersion: services.cloud.sap.com/v1
7
+ kind: ServiceBinding
8
+ metadata:
9
+ name: {{ include "service-instance.internal.bindingName" (dict "root" $ "name" $name) }}
10
+ labels: {{- include "service-instance.internal.labels" $ | nindent 4 }}
11
+ {{- if or $.Values.annotations.serviceBinding }}
12
+ annotations:
13
+ {{- tpl (toYaml $.Values.annotations.serviceBinding) $ | nindent 4 }}
14
+ {{- end }}
15
+ spec:
16
+ serviceInstanceName: {{ include "service-instance.internal.fullname" $ }}
17
+ {{- if $mergedParams.externalName }}
18
+ externalName: {{ $mergedParams.externalName }}
19
+ {{- end }}
20
+ {{- if $mergedParams.secretName }}
21
+ secretName: {{ tpl $mergedParams.secretName $ }}
22
+ {{- end }}
23
+ {{- if $mergedParams.parameters }}
24
+ parameters: {{ $mergedParams.parameters | toYaml | nindent 4 }}
25
+ {{- end }}
26
+ {{- if $mergedParams.parametersFrom }}
27
+ parametersFrom: {{ tpl ($mergedParams.parametersFrom | toYaml) $ | nindent 4 }}
28
+ {{- end }}
29
+ {{- if $mergedParams.credentialsRotationPolicy }}
30
+ credentialsRotationPolicy: {{ $mergedParams.credentialsRotationPolicy | toYaml | nindent 4 }}
31
+ {{- end }}
32
+ {{- end }}
@@ -11,6 +11,9 @@ metadata:
11
11
  spec:
12
12
  serviceOfferingName: {{ .Values.serviceOfferingName }}
13
13
  servicePlanName: {{ .Values.servicePlanName }}
14
+ {{- if .Values.btpAccessCredentialsSecret }}
15
+ btpAccessCredentialsSecret: {{ .Values.btpAccessCredentialsSecret }}
16
+ {{- end }}
14
17
  {{- if .Values.externalName }}
15
18
  externalName: {{ .Values.externalName }}
16
19
  {{- end }}