@sap/cds-dk 6.5.2 → 6.6.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/bin/activate.js +7 -0
  3. package/bin/add.js +1 -2
  4. package/bin/build/all.js +14 -9
  5. package/bin/cds.js +11 -8
  6. package/bin/compile/index.js +13 -3
  7. package/bin/env.js +16 -25
  8. package/bin/extend.js +8 -0
  9. package/bin/init.js +0 -3
  10. package/bin/login.js +3 -7
  11. package/bin/logout.js +2 -7
  12. package/bin/watch.js +4 -5
  13. package/lib/client/activate.js +1 -1
  14. package/lib/client/helper/errors.js +2 -1
  15. package/lib/client/params.js +4 -3
  16. package/lib/client/pull.js +31 -5
  17. package/lib/client/push.js +3 -3
  18. package/lib/client/settings_manager.js +6 -6
  19. package/lib/client/subscription.js +1 -1
  20. package/lib/compile/asyncapi/channels.js +22 -0
  21. package/lib/compile/asyncapi/components/messageTraits/index.js +89 -0
  22. package/lib/compile/asyncapi/components/messages/index.js +150 -0
  23. package/lib/compile/asyncapi/components/schemas/annotations.js +13 -0
  24. package/lib/compile/asyncapi/components/schemas/array.js +8 -0
  25. package/lib/compile/asyncapi/components/schemas/cache.js +14 -0
  26. package/lib/compile/asyncapi/components/schemas/definition.js +187 -0
  27. package/lib/compile/asyncapi/components/schemas/enum.js +16 -0
  28. package/lib/compile/asyncapi/components/schemas/examples.js +10 -0
  29. package/lib/compile/asyncapi/components/schemas/index.js +14 -0
  30. package/lib/compile/asyncapi/components/schemas/localized.js +29 -0
  31. package/lib/compile/asyncapi/components/schemas/primitiveElement.js +41 -0
  32. package/lib/compile/asyncapi/components/schemas/ref.js +45 -0
  33. package/lib/compile/asyncapi/components/schemas/utils.js +108 -0
  34. package/lib/compile/asyncapi/index.js +226 -0
  35. package/lib/compile/asyncapi/message.js +13 -0
  36. package/lib/compile/asyncapi/utils.js +27 -0
  37. package/lib/compile/index.js +1 -0
  38. package/lib/compile/openapi/csdl2openapi.js +40 -18
  39. package/lib/import/message.js +3 -1
  40. package/lib/import/odata/metadataconverter/MetadataConverter.js +1 -1
  41. package/lib/import/odata/v2parser.js +131 -50
  42. package/lib/import/odata/v4parser.js +160 -68
  43. package/lib/import/openapi/importOpenAPI.js +14 -14
  44. package/lib/init/constants.js +1 -1
  45. package/lib/init/index.js +11 -21
  46. package/lib/init/template/_merging/registry-mta.js +15 -26
  47. package/lib/init/template/approuter/files/package.json +2 -2
  48. package/lib/init/template/approuter/index.js +6 -12
  49. package/lib/init/template/auditlog/files/auditlog.yaml +4 -1
  50. package/lib/init/template/auditlog/index.js +23 -8
  51. package/lib/init/template/cf-manifest/index.js +4 -14
  52. package/lib/init/template/connectivity/files/connectivity-proxy-info.yaml +2 -6
  53. package/lib/init/template/connectivity/files/values.yaml.hbs +5 -8
  54. package/lib/init/template/connectivity/index.js +2 -9
  55. package/lib/init/template/data/index.js +0 -4
  56. package/lib/init/template/destinations/files/destination.yaml +4 -1
  57. package/lib/init/template/destinations/index.js +25 -10
  58. package/lib/init/template/enterprise-messaging/files/event-mesh.yaml +4 -1
  59. package/lib/init/template/enterprise-messaging/files/values.yaml +1 -2
  60. package/lib/init/template/enterprise-messaging/index.js +28 -20
  61. package/lib/init/template/extensibility/index.js +23 -31
  62. package/lib/init/template/hana/files/hana.yaml +4 -1
  63. package/lib/init/template/hana/index.js +44 -24
  64. package/lib/init/template/helm/chart/templates/_helpers.tpl +12 -0
  65. package/lib/init/template/helm/chart/values.root.schema.json +40 -0
  66. package/lib/init/template/helm/chart/values.schema.json +32 -69
  67. package/lib/init/template/helm/index.js +26 -16
  68. package/lib/init/template/helm/subcharts/content-deployment/templates/_helpers.tpl +13 -26
  69. package/lib/init/template/helm/subcharts/content-deployment/templates/job.yaml +3 -3
  70. package/lib/init/template/helm/subcharts/content-deployment/templates/service-account.yaml +2 -0
  71. package/lib/init/template/helm/subcharts/content-deployment/templates/service-binding.yaml +3 -3
  72. package/lib/init/template/helm/subcharts/content-deployment/templating.md +37 -0
  73. package/lib/init/template/helm/subcharts/content-deployment/values.md +182 -185
  74. package/lib/init/template/helm/subcharts/content-deployment/values.schema.json +18 -22
  75. package/lib/init/template/helm/subcharts/content-deployment/values.yaml +2 -0
  76. package/lib/init/template/helm/subcharts/service-instance/Chart.yaml +5 -0
  77. package/lib/init/template/helm/subcharts/service-instance/templates/_helpers.tpl +65 -0
  78. package/lib/init/template/helm/subcharts/service-instance/templates/serviceinstance.yaml +23 -0
  79. package/lib/init/template/helm/subcharts/service-instance/templating.md +18 -0
  80. package/lib/init/template/helm/subcharts/service-instance/values-lint.yaml +2 -0
  81. package/lib/init/template/helm/subcharts/service-instance/values.md +186 -0
  82. package/lib/init/template/helm/subcharts/service-instance/values.schema.json +102 -0
  83. package/lib/init/template/helm/subcharts/service-instance/values.yaml +15 -0
  84. package/lib/init/template/html5-repo/files/html5-apps-repo-host.yaml +4 -1
  85. package/lib/init/template/html5-repo/index.js +30 -21
  86. package/lib/init/template/java/index.js +2 -5
  87. package/lib/init/template/kibana-logging/index.js +7 -10
  88. package/lib/init/template/lint/index.js +2 -3
  89. package/lib/init/template/mta/files/mta.yaml.hbs +4 -2
  90. package/lib/init/template/mta/index.js +7 -11
  91. package/lib/init/template/mtx/index.js +0 -5
  92. package/lib/init/template/multitenancy/files/java/package.json +16 -7
  93. package/lib/init/template/multitenancy/files/mta.yaml.hbs +11 -3
  94. package/lib/init/template/multitenancy/files/saas-registry-secret.yaml +9 -0
  95. package/lib/init/template/multitenancy/files/saas-registry.yaml +4 -17
  96. package/lib/init/template/multitenancy/files/service-manager.yaml +4 -1
  97. package/lib/init/template/multitenancy/files/values.yaml.hbs +15 -3
  98. package/lib/init/template/multitenancy/index.js +56 -31
  99. package/lib/init/template/nodejs/index.js +4 -7
  100. package/lib/init/template/notebook/index.js +1 -3
  101. package/lib/init/template/pipeline/index.js +2 -5
  102. package/lib/init/template/samples/index.js +6 -11
  103. package/lib/init/template/templateBase.js +10 -17
  104. package/lib/init/template/toggles/index.js +2 -6
  105. package/lib/init/template/xsuaa/files/values.yaml.hbs +0 -1
  106. package/lib/init/template/xsuaa/files/xsuaa.yaml +4 -1
  107. package/lib/init/template/xsuaa/index.js +27 -23
  108. package/lib/init/types.d.ts +0 -81
  109. package/lib/init/util/merge.js +23 -25
  110. package/lib/init/util/projectReader.js +27 -24
  111. package/lib/lint/Linter.js +31 -13
  112. package/lib/watch/livereload-server.js +21 -14
  113. package/lib/watch/node-watch.js +51 -49
  114. package/npm-shrinkwrap.json +551 -458
  115. package/package.json +2 -2
  116. package/readme.md +5 -0
  117. package/lib/init/template/connectivity/files/connectivity-binding.yaml +0 -9
  118. package/lib/init/template/connectivity/files/connectivity.yaml +0 -1
  119. package/lib/init/template/multitenancy/files/xsuaa.yaml +0 -1
  120. /package/lib/init/template/hana/files/{chart.yaml → hana-deployer.yaml} +0 -0
  121. /package/lib/init/template/html5-repo/files/{chart.yaml → html5-apps-deployer.yaml} +0 -0
  122. /package/lib/init/template/multitenancy/files/{chart.yaml → sidecar.yaml} +0 -0
@@ -1,12 +1,15 @@
1
+ const cds = require('../../../cds')
2
+ const { read, write, exists } = cds.utils
1
3
  const { join } = require('path')
2
- const ProjectReader = require('../../util/projectReader')
4
+ const { readProject } = require('../../util/projectReader')
3
5
  const { mergeJSON } = require('../../util/merge')
4
- const { copyAndTrack, parseMd5File, writeMd5File } = require('../../util/md5Tracking')
6
+ const { OPTION_MULTITENANCY } = require('../../constants')
5
7
 
6
8
  module.exports = class ExtensibilityTemplate extends require('../templateBase') {
7
- constructor(projectPath, generator) {
8
- super(projectPath, generator, __dirname)
9
- this.projectReader = new ProjectReader(projectPath)
9
+
10
+
11
+ getDependencies() {
12
+ return exists('pom.xml') ? [OPTION_MULTITENANCY] : [] // REVISIT: Remove this dependency
10
13
  }
11
14
 
12
15
  static hasFacet(env) {
@@ -14,33 +17,38 @@ module.exports = class ExtensibilityTemplate extends require('../templateBase')
14
17
  }
15
18
 
16
19
  async run() {
17
- const projectDescriptor = await this.projectReader.read(this.options)
18
- const { for: forProfile, isJava } = projectDescriptor.cap
20
+ const projectDescriptor = await readProject(this.options)
21
+ const { for: forProfile, isJava, hasSidecar } = projectDescriptor.cap
19
22
  const cdsConfigPath = join(this.projectPath, isJava ? '.cdsrc.json' : 'package.json')
20
23
  const cdsTemplateFile = forProfile ? (isJava ? 'cdsrc.json.hbs' : 'cds.package.json.hbs') : (isJava ? 'cdsrc.json' : 'cds.package.json')
21
24
  await mergeJSON(cdsConfigPath, join(__dirname, 'files', cdsTemplateFile), projectDescriptor)
25
+ if (hasSidecar) {
26
+ const out = join('mtx', 'sidecar', 'package.json')
27
+ const config = await read(out)
28
+ if (!('cds.xt.ExtensibilityService' in config.cds.requires)) {
29
+ config.cds.requires['cds.xt.ExtensibilityService'] = true
30
+ await write(out, config, { spaces: 2 })
31
+ }
32
+ }
22
33
  await this.runDependentMerging()
23
34
  }
24
35
 
25
- async runDependentMerging(context = {}) {
26
- const projectDescriptor = await this.projectReader.read()
27
- const { hasXsuaa, hasHelm, hasApprouter } = projectDescriptor.cap
36
+ async runDependentMerging() {
37
+ const projectDescriptor = await readProject()
38
+ const { hasXsuaa, hasApprouter } = projectDescriptor.cap
28
39
  if (hasXsuaa) {
29
40
  await mergeJSON(
30
- join(this.projectPath, 'xs-security.json'),
41
+ 'xs-security.json',
31
42
  join(__dirname, 'files', 'xs-security.json.hbs'),
32
43
  projectDescriptor,
33
44
  {
34
45
  additions: [{
35
- ref: 'scope-extension-developer',
36
46
  in: 'scopes',
37
47
  where: [{ property: 'name', isEqualTo: '$XSAPPNAME.cds.ExtensionDeveloper' }],
38
48
  }, {
39
- ref: 'scope-uiflex',
40
49
  in: 'scopes',
41
50
  where: [{ property: 'name', isEqualTo: '$XSAPPNAME.cds.UIFlexDeveloper' }],
42
51
  }, {
43
- ref: 'template-extension-developer',
44
52
  in: 'role-templates',
45
53
  where: [{ property: 'name', isEqualTo: 'ExtensionDeveloper' }],
46
54
  }]
@@ -49,24 +57,8 @@ module.exports = class ExtensibilityTemplate extends require('../templateBase')
49
57
  }
50
58
  if (hasApprouter) {
51
59
  const ApprouterTemplate = require(`../approuter`)
52
- const approuterTemplate = new ApprouterTemplate(this.projectPath, this.generator)
60
+ const approuterTemplate = new ApprouterTemplate(this.generator)
53
61
  await approuterTemplate.runDependentMerging()
54
- }
55
- if (hasXsuaa && hasHelm) {
56
- //in case facet is being added to the already exisiting charts folder
57
- let isIndependentCommand = false
58
- if(Object.keys(context).length == 0){
59
- isIndependentCommand = true
60
- context.projectPath = this.projectPath
61
- context.oldTrackingData = context.newTrackingData = await parseMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'))
62
- }
63
- // REVISIT: Shared xs-security.json location for Helm and MTA?
64
- await copyAndTrack(
65
- join(this.projectPath, 'xs-security.json'),
66
- join(this.projectPath, 'chart', 'xs-security.json'),
67
- context
68
- )
69
- if(isIndependentCommand) await writeMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'), context.newTrackingData)
70
62
  }
71
63
  }
72
64
  }
@@ -1 +1,4 @@
1
- {{- include "cap.service-instance" . }}
1
+ dependencies:
2
+ - name: service-instance
3
+ alias: hana
4
+ version: 0.1.0
@@ -5,9 +5,9 @@ const commandUtil = require('../../util/commandUtil');
5
5
  const mvnArchetypes = require('../../util/mvnArchetypeUtil');
6
6
  const term = require('../../../util/term');
7
7
  const { mergeJSON, mergeYAML, removeFromYAML, removeFromYAMLArray } = require('../../util/merge')
8
- const { copyAndTrack, parseMd5File, writeMd5File } = require('../../util/md5Tracking')
8
+ const { parseMd5File, writeMd5File } = require('../../util/md5Tracking')
9
9
  const { copyFiles } = require('../../util/templateUtil')
10
- const ProjectReader = require('../../util/projectReader');
10
+ const { readProject } = require('../../util/projectReader');
11
11
  const versionCompare = require('../../util/versionCompare');
12
12
 
13
13
  const { PROJECT_TYPE, OPTION_JAVA, URLS } = require('../../constants');
@@ -15,10 +15,6 @@ const { PROJECT_TYPE, OPTION_JAVA, URLS } = require('../../constants');
15
15
  const { srvNode, srvJava, hdbDeployer, serviceManager, hdiContainer, mtxSidecar } = require('../_merging/registry-mta');
16
16
 
17
17
  module.exports = class HanaTemplate extends require('../templateBase') {
18
- constructor(projectPath, generator) {
19
- super(projectPath, generator, __dirname);
20
- this.projectReader = new ProjectReader(projectPath);
21
- }
22
18
 
23
19
  static hasFacet(env) {
24
20
  return env.requires?.db?.kind === 'hana'
@@ -43,7 +39,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
43
39
  const undeployJSONTemplatePath = join(__dirname, 'files', 'common', 'undeploy.json');
44
40
  await mergeJSON(undeployJSONPath, undeployJSONTemplatePath);
45
41
 
46
- const projectType = await this.getProjectType();
42
+ const projectType = this.getProjectType();
47
43
  switch (projectType) {
48
44
  case PROJECT_TYPE.java: {
49
45
  await copyFiles(join(__dirname, 'files', 'java', 'db'), join(this.projectPath, env.folders.db), {}, this.options.force);
@@ -85,9 +81,9 @@ module.exports = class HanaTemplate extends require('../templateBase') {
85
81
  }
86
82
  }
87
83
  }
88
-
84
+
89
85
  async runDependentMerging(context = {}) {
90
- const projectDescriptor = await this.projectReader.read(this.options)
86
+ const projectDescriptor = await readProject(this.options)
91
87
  const { hasMta, hasHelm, hasHtml5Repo, isNodejs, isJava, isMultitenant } = projectDescriptor.cap
92
88
 
93
89
  if (isMultitenant) {
@@ -136,7 +132,7 @@ module.exports = class HanaTemplate extends require('../templateBase') {
136
132
 
137
133
  await mergeYAML(
138
134
  mtaYAMLPath,
139
- `${__dirname}/files/mta.yaml.hbs`,
135
+ join(__dirname, 'files', 'mta.yaml.hbs'),
140
136
  projectDescriptor,
141
137
  { additions: [...modules, db].filter(a => a), deletions, relationships }
142
138
  )
@@ -178,32 +174,39 @@ module.exports = class HanaTemplate extends require('../templateBase') {
178
174
  if(exists(hanaInstanceTemplatePath)) {
179
175
  await rm(hanaInstanceTemplatePath);
180
176
  }
177
+
178
+ await mergeYAML(
179
+ join(this.projectPath, 'chart', 'Chart.yaml'),
180
+ join(__dirname, 'files', 'hana.yaml'),
181
+ projectDescriptor,
182
+ { deletions: [{
183
+ item: {
184
+ in: `dependencies`,
185
+ where: [{
186
+ property: 'alias',
187
+ isEqualTo: 'hana'
188
+ }]
189
+ }
190
+ }]}
191
+ )
181
192
  } else {
182
193
  await mergeYAML(
183
194
  join(this.projectPath, 'chart', 'values.yaml'),
184
195
  join(__dirname, 'files', 'values.yaml.hbs'),
185
196
  projectDescriptor
186
197
  )
187
- await copyAndTrack(
188
- join(__dirname, 'files', 'hana.yaml'),
189
- join(this.projectPath, 'chart', 'templates', 'hana.yaml'),
190
- context
191
- )
192
198
 
193
199
  // copy content deployment chart if it is not present
194
- const contentDeploymentSubchartPath = join(this.projectPath, 'chart', 'charts', 'content-deployment');
195
- if(!exists(contentDeploymentSubchartPath)) {
196
- const contentDeploymentResourcePath = join(__dirname, '..', 'helm', 'subcharts', 'content-deployment');
197
- await copyAndTrack(contentDeploymentResourcePath, contentDeploymentSubchartPath, context);
198
- }
200
+ const HelmTemplate = require(`../helm`);
201
+ const helmTemplate = new HelmTemplate(this.generator, context.oldTrackingData, context.newTrackingData);
202
+ shouldUpdateTrackingFile = shouldUpdateTrackingFile | await helmTemplate.addSubChart('content-deployment');
199
203
 
200
204
  // add dependency entry in chart.yaml
201
205
  await mergeYAML(
202
206
  join(this.projectPath, 'chart', 'Chart.yaml'),
203
- join(__dirname, 'files', 'chart.yaml'),
207
+ join(__dirname, 'files', 'hana-deployer.yaml'),
204
208
  projectDescriptor,
205
209
  { additions: [{
206
- ref: `content-deployment-hana-deployer`,
207
210
  in: `dependencies`,
208
211
  where: [{
209
212
  property: 'alias',
@@ -211,6 +214,23 @@ module.exports = class HanaTemplate extends require('../templateBase') {
211
214
  }]
212
215
  }]}
213
216
  )
217
+
218
+ // add service instance chart if it is not present
219
+ shouldUpdateTrackingFile = shouldUpdateTrackingFile | await helmTemplate.addSubChart('service-instance');
220
+
221
+ // add dependency entry in chart.yaml
222
+ await mergeYAML(
223
+ join(this.projectPath, 'chart', 'Chart.yaml'),
224
+ join(__dirname, 'files', 'hana.yaml'),
225
+ projectDescriptor,
226
+ { additions: [{
227
+ in: `dependencies`,
228
+ where: [{
229
+ property: 'alias',
230
+ isEqualTo: 'hana'
231
+ }]
232
+ }]}
233
+ )
214
234
  }
215
235
  if(shouldUpdateTrackingFile) await writeMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'), context.newTrackingData);
216
236
  }
@@ -248,10 +268,10 @@ module.exports = class HanaTemplate extends require('../templateBase') {
248
268
  }
249
269
 
250
270
  async _updateCdsConfiguration(configPath) {
251
- const projectType = await this.getProjectType();
271
+ const projectType = this.getProjectType();
252
272
  const configFile = projectType === PROJECT_TYPE.nodejs ? 'package.json' : '.cdsrc.json';
253
273
  configPath = configPath ?? join(this.projectPath, configFile)
254
- const projectDescriptor = await this.projectReader.read(this.options);
274
+ const projectDescriptor = await readProject(this.options);
255
275
  const { for: forProfile } = projectDescriptor.cap;
256
276
  let json; try { json = await read(configPath, 'utf8') } catch { /* ignore */ }
257
277
  const _cds = projectType === PROJECT_TYPE.nodejs ? json?.cds : json;
@@ -130,4 +130,16 @@ spec:
130
130
  {{- end }}
131
131
  {{- $name }}
132
132
  {{- end }}
133
+ {{- end }}
134
+
135
+ {{/*
136
+ Saas Registry Parameters
137
+ */}}
138
+ {{- define "cap.service-instance.saasRegistryParameters" -}}
139
+ {{- $srvHostFull := include "cap.deploymentHostFull" (merge (dict "name" "srv" "deployment" .Values.srv) . ) }}
140
+ {{- $parameters := .Values.saasRegistryParameters }}
141
+ {{- $appUrls := $parameters.appUrls }}
142
+ {{- $_ := set $appUrls "getDependencies" (printf "https://%s%s" $srvHostFull $appUrls.getDependencies) }}
143
+ {{- $_ := set $appUrls "onSubscription" (printf "https://%s%s" $srvHostFull $appUrls.onSubscription) }}
144
+ {{- $parameters | mustToJson }}
133
145
  {{- end }}
@@ -21,6 +21,46 @@
21
21
  "$id": "#/properties/html5-apps-deployer",
22
22
  "description": "Content Deployment",
23
23
  "$ref": "./charts/content-deployment/values.schema.json"
24
+ },
25
+ "event-mesh": {
26
+ "$id": "#/properties/event-mesh",
27
+ "description": "Service Instance",
28
+ "$ref": "./charts/service-instance/values.schema.json"
29
+ },
30
+ "html5-apps-repo-host": {
31
+ "$id": "#/properties/html5-apps-repo-host",
32
+ "description": "Service Instance",
33
+ "$ref": "./charts/service-instance/values.schema.json"
34
+ },
35
+ "xsuaa": {
36
+ "$id": "#/properties/xsuaa",
37
+ "description": "Service Instance",
38
+ "$ref": "./charts/service-instance/values.schema.json"
39
+ },
40
+ "auditlog": {
41
+ "$id": "#/properties/auditlog",
42
+ "description": "Service Instance",
43
+ "$ref": "./charts/service-instance/values.schema.json"
44
+ },
45
+ "destination": {
46
+ "$id": "#/properties/destination",
47
+ "description": "Service Instance",
48
+ "$ref": "./charts/service-instance/values.schema.json"
49
+ },
50
+ "hana": {
51
+ "$id": "#/properties/hana",
52
+ "description": "Service Instance",
53
+ "$ref": "./charts/service-instance/values.schema.json"
54
+ },
55
+ "saas-registry": {
56
+ "$id": "#/properties/saas-registry",
57
+ "description": "Service Instance",
58
+ "$ref": "./charts/service-instance/values.schema.json"
59
+ },
60
+ "service-manager": {
61
+ "$id": "#/properties/service-manager",
62
+ "description": "Service Instance",
63
+ "$ref": "./charts/service-instance/values.schema.json"
24
64
  }
25
65
  }
26
66
  }
@@ -54,6 +54,38 @@
54
54
  "$id": "#/properties/approuter",
55
55
  "description": "Deployment"
56
56
  },
57
+ "event-mesh": {
58
+ "$id": "#/properties/event-mesh",
59
+ "description": "Service Instance"
60
+ },
61
+ "html5-apps-repo-host": {
62
+ "$id": "#/properties/html5-apps-repo-host",
63
+ "description": "Service Instance"
64
+ },
65
+ "xsuaa": {
66
+ "$id": "#/properties/xsuaa",
67
+ "description": "Service Instance"
68
+ },
69
+ "auditlog": {
70
+ "$id": "#/properties/auditlog",
71
+ "description": "Service Instance"
72
+ },
73
+ "destination": {
74
+ "$id": "#/properties/destination",
75
+ "description": "Service Instance"
76
+ },
77
+ "hana": {
78
+ "$id": "#/properties/hana",
79
+ "description": "Service Instance"
80
+ },
81
+ "saas-registry": {
82
+ "$id": "#/properties/saas-registry",
83
+ "description": "Service Instance"
84
+ },
85
+ "service-manager": {
86
+ "$id": "#/properties/service-manager",
87
+ "description": "Service Instance"
88
+ },
57
89
  "backendDestinations": {
58
90
  "$id": "#/properties/backendDestinations",
59
91
  "title": "Backend Destinations for Approuter or HTML5 Apps Deployer",
@@ -76,75 +108,6 @@
76
108
  }
77
109
  }
78
110
  }
79
- },
80
- "auditlog": {
81
- "$id": "#/properties/auditlog",
82
- "$ref": "#/definitions/ServiceInstance"
83
- },
84
- "destinations": {
85
- "$id": "#/properties/destinations",
86
- "$ref": "#/definitions/ServiceInstance"
87
- },
88
- "connectivity": {
89
- "type": "object",
90
- "additionalProperties": false,
91
- "required": [
92
- "serviceOfferingName",
93
- "servicePlanName",
94
- "configMapName",
95
- "secretName"
96
- ],
97
- "properties": {
98
- "fullnameOverride": {
99
- "type": "string",
100
- "pattern": "[0-9a-z][0-9a-z-.]*",
101
- "maxLength": 63,
102
- "description": "If present then this will be used instead of the generated name"
103
- },
104
- "enabled": {
105
- "type": "boolean",
106
- "default": true,
107
- "description": "Service instance will be created (default: true)"
108
- },
109
- "serviceOfferingName": {
110
- "type": "string",
111
- "default": "connectivity",
112
- "description": "Technical service offering name from service catalog"
113
- },
114
- "servicePlanName": {
115
- "type": "string",
116
- "default": "connectivity_proxy",
117
- "description": "Technical service plan name from service catalog"
118
- },
119
- "parameters": {
120
- "type": "object",
121
- "description": "Some services support the provisioning of additional configuration parameters during the instance creation. For the list of supported parameters, check the documentation of the particular service offering."
122
- },
123
- "config": {
124
- "type": "string",
125
- "description": "File name of JSON configuration file in chart folder. Values from the file will be copied and placed in the parameters for the service instance. If both parameters and config are specified, the values in parameters override those read from config."
126
- },
127
- "configMapName": {
128
- "type": "string",
129
- "description": "Required to add additional connection information, compared to what is available from the service binding."
130
- },
131
- "secretName": {
132
- "type": "string",
133
- "description": "Required to add additional connection information."
134
- }
135
- }
136
- },
137
- "event_mesh": {
138
- "$id": "#/properties/event_mesh",
139
- "$ref": "#/definitions/ServiceInstance"
140
- },
141
- "html5_apps_repo_host": {
142
- "$id": "#/properties/html5_apps_repo_host",
143
- "$ref": "#/definitions/ServiceInstance"
144
- },
145
- "xsuaa": {
146
- "$id": "#/properties/xsuaa",
147
- "$ref": "#/definitions/ServiceInstance"
148
111
  }
149
112
  },
150
113
  "definitions": {
@@ -1,22 +1,21 @@
1
1
  const { join } = require('path');
2
2
  const { exists, rimraf } = require('../../../cds').utils;
3
- const ProjectReader = require('../../util/projectReader');
3
+ const { readProject } = require('../../util/projectReader');
4
4
  const { mergeYAML } = require('../../util/merge')
5
5
  const { parseMd5File, writeMd5File, copyAndTrack } = require('../../util/md5Tracking')
6
6
  //const { yaml } = require('@sap/cds-foss')
7
7
 
8
8
  module.exports = class HelmTemplate extends require('../templateBase') {
9
- constructor(projectPath, generator) {
10
- super(projectPath, generator, __dirname);
11
- this.projectReader = new ProjectReader(projectPath);
12
- this.oldTrackingData = undefined;
13
- this.newTrackingData = {};
9
+ constructor(generator, oldTrackingData = undefined, newTrackingData = {}) {
10
+ super(generator)
11
+ this.oldTrackingData = oldTrackingData;
12
+ this.newTrackingData = newTrackingData;
14
13
  }
15
14
 
16
- static hasFacet(_, projectPath, options) {
15
+ static hasFacet(_, options) {
17
16
  // REVISIT: this works, but could be semantically nicer with a 'shouldRunDependentMerging' or the like
18
17
  if (options?.add.has('mta') && !options?.add.has('helm')) return false
19
- return exists(join(projectPath, 'chart', 'values.yaml'))
18
+ return exists(join('chart', 'values.yaml'))
20
19
  }
21
20
 
22
21
  async canRun() {
@@ -27,15 +26,26 @@ module.exports = class HelmTemplate extends require('../templateBase') {
27
26
  return true;
28
27
  }
29
28
 
29
+ async addSubChart(subchart) {
30
+ const subchartPath = join(this.projectPath, 'chart', 'charts', subchart);
31
+ if(!exists(subchartPath)) {
32
+ await copyAndTrack(
33
+ join(__dirname, 'subcharts', subchart),
34
+ subchartPath,
35
+ this
36
+ )
37
+
38
+ return true;
39
+ }
40
+
41
+ return false;
42
+ }
43
+
30
44
  async run() {
31
- const projectDescriptor = await this.projectReader.read(this.options)
45
+ const projectDescriptor = await readProject(this.options)
32
46
  this.oldTrackingData = await parseMd5File(join(this.projectPath, 'chart', '.cds-add-helm-files.md5'));
33
47
 
34
- await copyAndTrack(
35
- join(__dirname, 'subcharts', 'web-application'),
36
- join(this.projectPath, 'chart', 'charts', 'web-application'),
37
- this
38
- )
48
+ await this.addSubChart('web-application');
39
49
  await copyAndTrack(
40
50
  join(__dirname, 'chart'),
41
51
  join(this.projectPath, 'chart'),
@@ -62,8 +72,8 @@ module.exports = class HelmTemplate extends require('../templateBase') {
62
72
  const dependentFacets = ['hana', 'xsuaa', 'auditlog', 'enterprise-messaging', 'destinations' , 'multitenancy', 'extensibility', 'approuter']
63
73
  for (const facet of dependentFacets) {
64
74
  const Template = require('../'+facet)
65
- const template = new Template(this.projectPath, this.generator)
66
- if (Template.hasFacet(await this.getEnv(), this.projectPath, this.options)) await template.runDependentMerging(this)
75
+ const template = new Template(this.generator)
76
+ if (Template.hasFacet(await this.getEnv(), this.options)) await template.runDependentMerging(this)
67
77
  }
68
78
  }
69
79
  };
@@ -97,7 +97,7 @@ Service Binding secret volumes
97
97
  {{- end }}
98
98
  - name: {{ $name }}-binding
99
99
  secret:
100
- secretName: {{ $secretName }}
100
+ secretName: {{ tpl $secretName $ }}
101
101
  {{- end }}
102
102
  {{- end }}
103
103
 
@@ -131,30 +131,31 @@ Calculate the final image name
131
131
  {{/*
132
132
  Create the name of a service instance.
133
133
  We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
134
- If release name contains chart name it will be used as service insatnce name.
134
+ If release name contains chart name it will be used as service instance name.
135
135
  */}}
136
136
  {{- define "content-deployment.serviceInstanceName" -}}
137
- {{- if .binding.serviceInstanceFullname }}
137
+ {{- $name := "" }}
138
+ {{- if .binding.serviceInstanceFullname }}
138
139
  {{- if gt (len .binding.serviceInstanceFullname) 63 }}
139
140
  {{- fail (printf "name exceeds 63 characters: '%s'" .binding.serviceInstanceFullname) }}
140
141
  {{- end }}
141
- {{- .binding.serviceInstanceFullname }}
142
+ {{- $name = .binding.serviceInstanceFullname }}
142
143
  {{- else }}
143
- {{- $name := .binding.serviceInstanceName }}
144
- {{- if not (hasPrefix .release $name)}}
145
- {{- $name = printf "%s-%s" .release $name }}
144
+ {{- $name = .binding.serviceInstanceName }}
145
+ {{- if not (hasPrefix .root.Release.Name $name)}}
146
+ {{- $name = printf "%s-%s" .root.Release.Name $name }}
146
147
  {{- end }}
147
148
  {{- if gt (len $name) 63 }}
148
149
  {{- fail (printf "name exceeds 63 characters: '%s'" $name) }}
149
150
  {{- end }}
150
- {{- $name }}
151
151
  {{- end }}
152
+ {{- tpl $name .root }}
152
153
  {{- end }}
153
154
 
154
155
  {{- define "content-deployment.processEnv" -}}
155
156
  {{- $result := dict }}
156
157
  {{- $variables := list }}
157
- {{- range $k, $v := . }}
158
+ {{- range $k, $v := .Values.env }}
158
159
  {{- $variable := dict }}
159
160
  {{- if (kindIs "string" $k) }}
160
161
  {{- $_ := set $variable "name" $k -}}
@@ -174,11 +175,10 @@ If release name contains chart name it will be used as service insatnce name.
174
175
  {{- $variables = append $variables $variable}}
175
176
  {{- end }}
176
177
  {{- $_ := set $result "vars" $variables }}
177
- {{- $result | mustToJson }}
178
+ {{- (fromYaml (tpl (toYaml $result) $)) | mustToJson }}
178
179
  {{- end }}
179
180
 
180
- {{- define "web-application.processEnvFrom" -}}
181
- {{- $ := . -}}
181
+ {{- define "content-deployment.processEnvFrom" -}}
182
182
  {{- $result := dict }}
183
183
  {{- $variables := list }}
184
184
  {{- range $secretName := .Values.envSecretNames }}
@@ -187,21 +187,8 @@ If release name contains chart name it will be used as service insatnce name.
187
187
  {{- $variables = append $variables (dict "secretRef" $variable)}}
188
188
  {{- end }}
189
189
  {{- range $envFrom := .Values.envFrom }}
190
- {{- if hasKey $envFrom "configMapRef" }}
191
- {{- if and (hasKey $envFrom.configMapRef "tpl") ($envFrom.configMapRef.tpl) }}
192
- {{- $name := (tpl $envFrom.configMapRef.name $) }}
193
- {{- $_ := set $envFrom.configMapRef "name" $name }}
194
- {{- end }}
195
- {{- $_ := unset $envFrom.configMapRef "tpl" }}
196
- {{- else }}
197
- {{- if and (hasKey $envFrom.secretRef "tpl") ($envFrom.secretRef.tpl) }}
198
- {{- $name := (tpl $envFrom.secretRef.name $) }}
199
- {{- $_ := set $envFrom.secretRef "name" $name }}
200
- {{- end }}
201
- {{- $_ := unset $envFrom.secretRef "tpl" }}
202
- {{- end }}
203
190
  {{- $variables = append $variables $envFrom }}
204
191
  {{- end }}
205
192
  {{- $_ := set $result "vars" $variables }}
206
- {{- $result | mustToJson }}
193
+ {{- (fromYaml (tpl (toYaml $result) $)) | mustToJson }}
207
194
  {{- end }}
@@ -21,7 +21,7 @@ spec:
21
21
  - name: {{ include "content-deployment.imagePullSecretName" . }}
22
22
  {{- end }}
23
23
  automountServiceAccountToken: false
24
- serviceAccountName: {{ include "content-deployment.fullname" . }}
24
+ serviceAccountName: {{ tpl (.Values.serviceAccountName | default (include "content-deployment.fullname" .)) $ }}
25
25
  containers:
26
26
  - image: {{ include "content-deployment.imageName" . }}
27
27
  name: {{ include "content-deployment.name" . }}
@@ -34,12 +34,12 @@ spec:
34
34
  value: /tmp
35
35
  - name: SERVICE_BINDING_ROOT
36
36
  value: /bindings
37
- {{- $envVars := (include "content-deployment.processEnv" .Values.env | fromJson) }}
37
+ {{- $envVars := (include "content-deployment.processEnv" $ | fromJson) }}
38
38
  {{- if not (eq (len $envVars.vars) 0) }}
39
39
  {{- $envVars.vars | toYaml | nindent 8}}
40
40
  {{- end }}
41
41
  envFrom:
42
- {{- $envFromVars := (include "web-application.processEnvFrom" . | fromJson) }}
42
+ {{- $envFromVars := (include "content-deployment.processEnvFrom" . | fromJson) }}
43
43
  {{- if not (eq (len $envFromVars.vars) 0) }}
44
44
  {{- $envFromVars.vars | toYaml | nindent 8}}
45
45
  {{- end }}
@@ -1,4 +1,6 @@
1
+ {{if not .Values.serviceAccountName}}
1
2
  apiVersion: v1
2
3
  kind: ServiceAccount
3
4
  metadata:
4
5
  name: {{ include "content-deployment.fullname" . }}
6
+ {{end}}
@@ -7,19 +7,19 @@ metadata:
7
7
  name: {{ include "content-deployment.bindingName" (dict "root" $ "name" $name) }}
8
8
  labels: {{- include "content-deployment.labels" $ | nindent 4 }}
9
9
  spec:
10
- serviceInstanceName: {{include "content-deployment.serviceInstanceName" (dict "binding" $params "release" $.Release.Name) }}
10
+ serviceInstanceName: {{include "content-deployment.serviceInstanceName" (dict "binding" $params "root" $) }}
11
11
  secretKey: credentials
12
12
  {{- if $params.externalName }}
13
13
  externalName: {{ $params.externalName }}
14
14
  {{- end }}
15
15
  {{- if $params.secretName }}
16
- secretName: {{ $params.secretName }}
16
+ secretName: {{ tpl $params.secretName $ }}
17
17
  {{- end }}
18
18
  {{- if $params.parameters }}
19
19
  parameters: {{ $params.parameters | toYaml | nindent 4 }}
20
20
  {{- end }}
21
21
  {{- if $params.parametersFrom }}
22
- parametersFrom: {{ $params.parametersFrom | toYaml | nindent 4 }}
22
+ parametersFrom: {{ tpl ($params.parametersFrom | toYaml) $ | nindent 4 }}
23
23
  {{- end }}
24
24
  {{- if $params.credentialsRotationPolicy }}
25
25
  credentialsRotationPolicy: {{ $params.credentialsRotationPolicy | toYaml | nindent 4 }}