@sap/cds-dk 6.1.5 → 6.2.1

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 (152) hide show
  1. package/CHANGELOG.md +36 -2
  2. package/bin/cds.js +7 -5
  3. package/bin/deploy/index.js +3 -2
  4. package/bin/deploy/to-sqlite.js +4 -3
  5. package/bin/help.js +4 -0
  6. package/bin/init.js +2 -1
  7. package/bin/login.js +23 -9
  8. package/bin/mock.js +1 -0
  9. package/bin/pull.js +24 -19
  10. package/bin/push.js +20 -9
  11. package/bin/subscribe.js +40 -10
  12. package/bin/watch.js +15 -10
  13. package/lib/bind/kubernetesCredentialsProvider.js +1 -0
  14. package/lib/client/activate.js +42 -51
  15. package/lib/client/auth_manager.js +7 -8
  16. package/lib/client/base_command.js +5 -2
  17. package/lib/client/extend.js +33 -38
  18. package/lib/client/helper/cf_helper.js +11 -11
  19. package/lib/client/helper/dependency_helper.js +2 -2
  20. package/lib/client/helper/errors.js +4 -3
  21. package/lib/client/helper/logging.js +17 -23
  22. package/lib/client/params.js +5 -5
  23. package/lib/client/pull.js +19 -21
  24. package/lib/client/push.js +16 -15
  25. package/lib/client/settings_manager.js +54 -55
  26. package/lib/compile/openapi/csdl2openapi.js +18 -12
  27. package/lib/import/message.js +1 -1
  28. package/lib/import/odata/metadataconverter/MetadataConverter.js +23 -17
  29. package/lib/import/odata/v2parser.js +43 -17
  30. package/lib/import/odata/v4parser.js +77 -22
  31. package/lib/init/constants.js +5 -2
  32. package/lib/init/index.js +16 -4
  33. package/lib/init/template/_merging/registry-mta.js +13 -0
  34. package/lib/init/template/approuter/index.js +9 -0
  35. package/lib/{k8s/connectivity/templates/connectivity.yaml → init/template/auditlog/files/auditlog.yaml} +0 -0
  36. package/lib/init/template/auditlog/index.js +46 -27
  37. package/lib/{k8s/connectivity/templates → init/template/connectivity/files}/connectivity-binding.yaml +0 -0
  38. package/lib/{k8s/connectivity/templates → init/template/connectivity/files}/connectivity-proxy-info.yaml +1 -1
  39. package/lib/init/template/connectivity/files/connectivity.yaml +1 -0
  40. package/lib/init/template/connectivity/files/values.yaml.hbs +26 -0
  41. package/lib/init/template/connectivity/index.js +41 -0
  42. package/lib/init/template/data/index.js +8 -8
  43. package/lib/init/template/destinations/files/destination.yaml +1 -0
  44. package/lib/init/template/destinations/index.js +44 -0
  45. package/lib/init/template/enterprise-messaging/files/cds.package.json +10 -0
  46. package/lib/init/template/enterprise-messaging/files/cds.profile.package.json.hbs +12 -0
  47. package/lib/init/template/enterprise-messaging/files/cdsrc.json +8 -0
  48. package/lib/init/template/enterprise-messaging/files/cdsrc.json.hbs +10 -0
  49. package/lib/init/template/enterprise-messaging/files/event-mesh.yaml +1 -0
  50. package/lib/init/template/enterprise-messaging/files/mta.yaml.hbs +13 -0
  51. package/lib/init/template/enterprise-messaging/files/values.yaml +8 -0
  52. package/lib/init/template/enterprise-messaging/index.js +56 -0
  53. package/lib/init/template/extensibility/files/cdsrc.json +5 -0
  54. package/lib/init/template/extensibility/files/cdsrc.json.hbs +7 -0
  55. package/lib/init/template/extensibility/index.js +18 -13
  56. package/lib/{k8s/hana-deployer/templates → init/template/hana/files}/hana-deployer-job.yaml +0 -0
  57. package/lib/init/template/hana/files/java/{cdsrc.json.hbs → cds.json.hbs} +0 -0
  58. package/lib/init/template/hana/files/java/{profile.cdsrc.json.hbs → cds.profile.json.hbs} +0 -0
  59. package/lib/init/template/hana/files/java/cds.shortcut.json.hbs +5 -0
  60. package/lib/init/template/hana/files/java/cds.shortcut.profile.json.hbs +8 -0
  61. package/lib/init/template/hana/files/java/db/package.json +2 -1
  62. package/lib/init/template/hana/files/mta.yaml.hbs +6 -0
  63. package/lib/init/template/hana/files/nodejs/{cds.package.json.hbs → cds.json.hbs} +0 -0
  64. package/lib/init/template/hana/files/nodejs/{cds.profile.package.json.hbs → cds.profile.json.hbs} +0 -0
  65. package/lib/init/template/hana/files/nodejs/cds.shortcut.json.hbs +7 -0
  66. package/lib/init/template/hana/files/nodejs/cds.shortcut.profile.json.hbs +10 -0
  67. package/lib/init/template/hana/files/values.yaml.hbs +19 -0
  68. package/lib/init/template/hana/index.js +29 -29
  69. package/lib/{k8s → init/template/helm}/Model.d.ts +0 -0
  70. package/lib/{k8s/resources → init/template}/helm/chart/templates/NOTES.txt +0 -0
  71. package/lib/{k8s/resources → init/template}/helm/chart/templates/_deployment_helpers.tpl +0 -0
  72. package/lib/{k8s/resources → init/template}/helm/chart/templates/_helpers.tpl +4 -5
  73. package/lib/{k8s/resources → init/template}/helm/chart/templates/_sapcp_helpers.tpl +0 -0
  74. package/lib/{k8s/resources/helm/chart/schemas → init/template/helm/chart}/values.root.schema.json +0 -0
  75. package/lib/{k8s/resources/helm/chart/schemas → init/template/helm/chart}/values.schema.json +0 -0
  76. package/lib/init/template/helm/files/Chart.yaml.hbs +13 -0
  77. package/lib/init/template/helm/files/values.yaml.hbs +26 -0
  78. package/lib/init/template/helm/index.js +74 -14
  79. package/lib/{k8s/deployment → init/template/helm}/subchart/Chart.yaml +0 -0
  80. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/_helpers.tpl +0 -0
  81. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/api-rule.yaml +0 -0
  82. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/deployment.yaml +0 -0
  83. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/network-policy.yaml +0 -0
  84. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/pod-disruption-budget.yaml +0 -0
  85. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/secret.yaml +0 -0
  86. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/service-binding.yaml +0 -0
  87. package/lib/{k8s/deployment → init/template/helm}/subchart/templates/service.yaml +0 -0
  88. package/lib/{k8s/deployment → init/template/helm}/subchart/values-lint.yaml +0 -0
  89. package/lib/{k8s/deployment → init/template/helm}/subchart/values.md +0 -0
  90. package/lib/{k8s/deployment → init/template/helm}/subchart/values.schema.json +0 -0
  91. package/lib/{k8s/deployment → init/template/helm}/subchart/values.yaml +0 -0
  92. package/lib/{k8s/html5-apps-deployer/templates → init/template/html5-repo/files}/_html5_deployment_helpers.tpl +0 -0
  93. package/lib/{k8s/html5-apps-deployer/templates → init/template/html5-repo/files}/html5-apps-deployer-job.yaml +1 -1
  94. package/lib/{k8s/html5-apps-repo-host/templates → init/template/html5-repo/files}/html5-apps-repo-host.yaml +0 -0
  95. package/lib/init/template/html5-repo/index.js +59 -0
  96. package/lib/init/template/kibana-logging/index.js +8 -0
  97. package/lib/init/template/lint/index.js +1 -4
  98. package/lib/init/template/mta/files/mta.yaml.hbs +3 -2
  99. package/lib/init/template/mta/index.js +6 -1
  100. package/lib/init/template/multitenancy/files/java/.cdsrc.json +3 -0
  101. package/lib/init/template/multitenancy/files/java/package.json +2 -6
  102. package/lib/{k8s/multitenancy/templates → init/template/multitenancy/files}/saas-registry.yaml +3 -3
  103. package/lib/init/template/multitenancy/files/xsuaa.yaml +1 -0
  104. package/lib/init/template/multitenancy/index.js +53 -26
  105. package/lib/init/template/nodejs/files/.gitignore.hbs +1 -0
  106. package/lib/init/template/templateBase.js +1 -1
  107. package/lib/init/template/xsuaa/files/values.yaml.hbs +10 -0
  108. package/lib/init/template/xsuaa/files/xsuaa.yaml +1 -0
  109. package/lib/init/template/xsuaa/index.js +34 -22
  110. package/lib/init/util/fsUtil.js +11 -5
  111. package/lib/init/util/projectReader.js +24 -32
  112. package/lib/init/util/templateUtil.js +17 -5
  113. package/lib/lint/Linter.js +9 -17
  114. package/lib/lint/checks.js +0 -1
  115. package/lib/lint/generators.js +2 -192
  116. package/lib/lint/io.js +1 -3
  117. package/lib/watch/node-watch.js +2 -2
  118. package/npm-shrinkwrap.json +1666 -873
  119. package/package.json +5 -4
  120. package/lib/init/template/helm/update/index.js +0 -28
  121. package/lib/k8s/ChartAdder.js +0 -75
  122. package/lib/k8s/ChartBuilder.js +0 -192
  123. package/lib/k8s/Context.js +0 -71
  124. package/lib/k8s/ImageUtil.js +0 -21
  125. package/lib/k8s/auditlog/index.js +0 -29
  126. package/lib/k8s/auditlog/templates/auditlog.yaml +0 -1
  127. package/lib/k8s/buildModel.js +0 -68
  128. package/lib/k8s/connectivity/index.js +0 -80
  129. package/lib/k8s/deployment/index.js +0 -79
  130. package/lib/k8s/deployment/subchart-override/templates/_web_application_helpers.tpl +0 -81
  131. package/lib/k8s/destinations/index.js +0 -40
  132. package/lib/k8s/destinations/lib.js +0 -16
  133. package/lib/k8s/destinations/templates/destinations.yaml +0 -1
  134. package/lib/k8s/docker/push.js +0 -8
  135. package/lib/k8s/event-mesh/index.js +0 -53
  136. package/lib/k8s/event-mesh/lib.js +0 -9
  137. package/lib/k8s/event-mesh/templates/event-mesh.yaml +0 -1
  138. package/lib/k8s/hana-deployer/index.js +0 -48
  139. package/lib/k8s/helm/Release.js +0 -80
  140. package/lib/k8s/html5-apps-deployer/index.js +0 -53
  141. package/lib/k8s/html5-apps-repo-host/index.js +0 -26
  142. package/lib/k8s/html5-apps-repo-host/lib.js +0 -16
  143. package/lib/k8s/index.js +0 -153
  144. package/lib/k8s/modules.js +0 -36
  145. package/lib/k8s/multitenancy/index.js +0 -24
  146. package/lib/k8s/multitenancy/lib.js +0 -25
  147. package/lib/k8s/readProject.js +0 -14
  148. package/lib/k8s/util.js +0 -186
  149. package/lib/k8s/wrapFeature.js +0 -55
  150. package/lib/k8s/xsuaa/index.js +0 -64
  151. package/lib/k8s/xsuaa/lib.js +0 -17
  152. package/lib/k8s/xsuaa/templates/xsuaa.yaml +0 -1
@@ -1,81 +0,0 @@
1
- {{/*
2
- Old Service Bindings: volumes
3
- */}}
4
- {{- define "cap.web-application.serviceVolumes" -}}
5
- {{- $ := . -}}
6
- {{ range $bindingName, $binding := $.Values.bindings -}}
7
- {{- $secret := default (print $.Release.Name "-" $.Chart.Name "-" $bindingName) $binding.fromSecret }}
8
- - name: {{ $bindingName }}-secret
9
- secret:
10
- secretName: {{ $secret | quote }}
11
- {{- if $.Values.global.oldServiceBindings }}
12
- - name: {{ $bindingName }}-metadata
13
- secret:
14
- secretName: {{ $secret | quote }}
15
- optional: true
16
- items:
17
- - key: label
18
- path: label
19
- - key: plan
20
- path: plan
21
- - key: tags
22
- path: tags
23
- {{- end }}
24
- {{- end -}}
25
- {{- end -}}
26
-
27
- {{/*
28
- Service Bindings: env vars
29
- */}}
30
- {{- define "cap.web-application.env" }}
31
- {{- $ := . }}
32
- {{- range $key, $binding := $.Values.bindings }}
33
- {{- $cleanKey := $key | upper | replace "-" "" | replace "_" "" | replace "." "" }}
34
- {{- $prefix := print "CDS_ENVIRONMENT_K8S_SERVICEBINDINGS_" $cleanKey }}
35
- {{- $secret := default (print $.Release.Name "-" $.Chart.Name "-" $key) $binding.fromSecret }}
36
- - name: {{ $prefix }}_SERVICE
37
- valueFrom:
38
- secretKeyRef:
39
- name: {{ $secret | quote }}
40
- key: label
41
- - name: {{ $prefix }}_PLAN
42
- valueFrom:
43
- secretKeyRef:
44
- name: {{ $secret | quote }}
45
- key: plan
46
- optional: true
47
- {{- if $.Values.global.oldServiceBindings }}
48
- - name: CDS_CONFIG
49
- value: /etc/secrets/cds
50
- - name: {{ $prefix }}_SECRETSPATH
51
- value: /etc/secrets/cds/requires/{{ $key }}/credentials
52
- {{- else }}
53
- - name: {{ $prefix }}_SECRETSPATH
54
- value: /bindings/{{ $key }}
55
- {{- end }}
56
- {{- end }}
57
- {{- end }}
58
-
59
-
60
- {{/*
61
- Old Service Bindings: volume mounts
62
- */}}
63
- {{- define "cap.web-application.serviceMounts" }}
64
- {{- $ := . -}}
65
- {{- range $key, $binding := $.Values.bindings }}
66
- {{- if not $.Values.global.oldServiceBindings }}
67
- - name: {{ $key }}-secret
68
- mountPath: /bindings/{{ $key }}
69
- readOnly: true
70
- {{- else }}
71
- - name: {{ $key }}-secret
72
- mountPath: /etc/secrets/cds/requires/{{ $key }}/credentials
73
- readOnly: true
74
- - name: {{ $key }}-metadata
75
- mountPath: /etc/secrets/cds/requires/{{ $key }}/vcap
76
- readOnly: true
77
- {{- end }}
78
- {{- end }}
79
- {{- end }}
80
-
81
-
@@ -1,40 +0,0 @@
1
- const wrapFeature = require('../wrapFeature');
2
- const { checkNeedDestinations } = require('./lib');
3
-
4
- module.exports = wrapFeature('destinations', {
5
-
6
- async checkNeedDestinations(context) {
7
- const env = await context.get('env');
8
- return checkNeedDestinations(env);
9
- },
10
-
11
- async isRequired(context) {
12
- return await this.checkNeedDestinations(context) || await context.collect('getDestinationsParameters');
13
- },
14
-
15
- async getServiceBindings(context) {
16
- return await this.checkNeedDestinations(context) && {destinations: { serviceInstanceName: 'destinations' } };
17
- },
18
-
19
- async getChartCapabilities(context) {
20
- return {
21
- destinations: {
22
- serviceOfferingName: 'destination',
23
- servicePlanName: 'lite',
24
- parameters: {
25
- version: "1.0.0",
26
- ...await context.collect('getDestinationsParameters')
27
- }
28
- }
29
- }
30
- },
31
-
32
- async addToChart(builder, { destinations }) {
33
- await builder.addAllTemplates(__dirname);
34
-
35
- const { config } = destinations;
36
- if (config) {
37
- await builder.addChartFile(config);
38
- }
39
- }
40
- });
@@ -1,16 +0,0 @@
1
- function checkNeedDestinations(env) {
2
- const kinds = [ 'odata', 'odata-v2', 'odata-v4', 'rest' ].reduce( (map, key) => {
3
- map[key] = true;
4
- return map;
5
- }, {});
6
- for (const service in env.requires) {
7
- const require = env.requires[service];
8
- if (!kinds[service] && kinds[require.kind]) return true;
9
- }
10
-
11
- return false;
12
- }
13
-
14
- module.exports = {
15
- checkNeedDestinations
16
- };
@@ -1 +0,0 @@
1
- {{- include "cap.service-instance" . }}
@@ -1,8 +0,0 @@
1
- const { exec } = require('../../util/exec');
2
-
3
- async function push(imageName, fullImageName) {
4
- await exec `docker tag ${imageName} ${fullImageName}`;
5
- await exec `docker push ${fullImageName}`;
6
- }
7
-
8
- module.exports = push;
@@ -1,53 +0,0 @@
1
- const wrapFeature = require('../wrapFeature');
2
- const { cds } = require('../modules');
3
- const LOG = cds.log();
4
-
5
- module.exports = wrapFeature('event_mesh', {
6
- async isRequired(context) {
7
- const env = await context.get('env');
8
- return eventMeshServices(env).length > 0;
9
- },
10
-
11
- async getServiceBindings() {
12
- return {
13
- messaging: {
14
- serviceInstanceName: 'event-mesh'
15
- }
16
- };
17
- },
18
-
19
- async getChartCapabilities() {
20
- return {
21
- "event_mesh": {
22
- serviceOfferingName: 'enterprise-messaging',
23
- servicePlanName: 'default',
24
- config: 'event-mesh.json'
25
- }
26
- }
27
- },
28
-
29
- async addToChart(builder, { 'event_mesh': eventMesh }) {
30
- await builder.addAllTemplates(__dirname);
31
-
32
- const { config } = eventMesh;
33
- if (config) {
34
- if (!await builder.addChartFile(config, { optional: true })) {
35
- LOG.warn(`Please add the "${config}" file to the chart folder.`);
36
- }
37
- }
38
- }
39
- });
40
-
41
- function eventMeshServices(env) {
42
- const kinds = [ '$', '$-http', '$-amqp', '$-shared', 'default-messaging' ].reduce( (map, key) => {
43
- map[key.replace(/\$/, 'enterprise-messaging')] = true;
44
- return map;
45
- }, {});
46
- const names = [];
47
- for (const name in env.requires) {
48
- const service = env.requires[name];
49
- if (!kinds[name] && kinds[service.kind]) names.push(name);
50
- }
51
-
52
- return names;
53
- }
@@ -1,9 +0,0 @@
1
- const Path = require("path");
2
-
3
- async function addTemplates(builder) {
4
- await builder.addTemplate(Path.join(__dirname, "resources/templates"), 'event-mesh.yaml');
5
- }
6
-
7
- module.exports = {
8
- addTemplates
9
- };
@@ -1 +0,0 @@
1
- {{- include "cap.service-instance" . }}
@@ -1,48 +0,0 @@
1
- const wrapFeature = require('../wrapFeature');
2
-
3
- module.exports = wrapFeature('hana_deployer', {
4
- async isRequired(context) {
5
- const env = await context.get('env');
6
- return env.requires.db && (env.requires.db.kind === 'sql' || env.requires.db.kind === 'hana');
7
- },
8
-
9
- async getChartCapabilities(context) {
10
- const model = await context.get('model');
11
-
12
- return {
13
- hana_deployer: {
14
- image: {
15
- repository: '<your-container-registry>/'+model.app.name+'-hana-deployer',
16
- tag: 'latest'
17
- },
18
- bindings: {
19
- hana: {
20
- fromSecret: null
21
- }
22
- },
23
- resources: {
24
- limits: {
25
- cpu: "2000m",
26
- memory: "1G"
27
- },
28
- requests: {
29
- cpu: "1000m",
30
- memory: "1G"
31
- }
32
- }
33
- }
34
- };
35
- },
36
-
37
- getServiceBindings() {
38
- return {
39
- db: {
40
- fromSecret: null
41
- }
42
- }
43
- },
44
-
45
- async addToChart(builder) {
46
- await builder.addAllTemplates(__dirname);
47
- }
48
- });
@@ -1,80 +0,0 @@
1
- const { throwError } = require('../util');
2
- const { exec } = require('../../util/exec');
3
- const { yaml } = require('../modules');
4
- const fs = require('fs').promises;
5
- const Path = require('path');
6
-
7
- async function status({ releaseName, namespace }) {
8
- const result = await exec({stdio: [ 'inherit', 'pipe', 'inherit'], acceptStatuses: '*'}) `helm status ${releaseName} --namespace ${namespace}`;
9
- if (result.status === 0) {
10
- const output = Buffer.from(result.output[1]).toString();
11
- const lines = output.split(/[\n\r]+/sg);
12
- const status = {};
13
- for (const line of lines) {
14
- const m = line.match(/\s*([^:]+)\s*:\s*(.*)/);
15
- if (m) {
16
- status[m[1].toLowerCase()] = m[2];
17
- }
18
- }
19
-
20
- if (!status.status) throwError(`Internal error: helm status didn't return STATUS value.`);
21
- return status;
22
- } else {
23
- return { name: releaseName, status: 'not found' }
24
- }
25
- }
26
-
27
- async function deploy({ options, releaseName, namespace, chartPath, values }) {
28
- const valuesArg = formatValues(values);
29
- await exec `helm upgrade ${releaseName} ./${chartPath} --install --namespace ${namespace} ${valuesArg && ['--set', valuesArg]} ${formatOptions(options)}`;
30
- }
31
-
32
- async function template({ options, releaseName, namespace, chartPath, values }) {
33
- const valuesArg = formatValues(values);
34
- await exec `helm template ${releaseName} ./${chartPath} --namespace ${namespace} ${valuesArg && ['--set', valuesArg]} ${formatOptions(options)}`;
35
- }
36
-
37
- function formatOptions(options = {}) {
38
- const args = [];
39
- if (options.debug) args.push('--debug');
40
- return args;
41
- }
42
-
43
- async function undeploy({ releaseName, namespace }) {
44
- await exec `helm uninstall ${releaseName} --namespace ${namespace}`;
45
- }
46
-
47
- function formatValues(values) {
48
- const valuesArray = collectValues(values);
49
- return valuesArray.join(',');
50
- }
51
-
52
- function collectValues(values, prefix = '') {
53
- const valuesArray = [];
54
-
55
- for (const name of Reflect.ownKeys(values)) {
56
- const value = values[name];
57
- if (typeof value === 'object') {
58
- valuesArray.push(...collectValues(value, `${prefix}${name}.`));
59
- } else if (typeof value !== 'undefined') {
60
- // @TODO: Escaping?
61
- valuesArray.push(`${prefix}${name}=${values[name]}`);
62
- }
63
- }
64
-
65
- return valuesArray;
66
- }
67
-
68
- async function values(chartPath) {
69
- return yaml.parse(await fs.readFile(Path.join(chartPath, 'values.yaml'), 'utf-8'));
70
-
71
- }
72
-
73
-
74
- module.exports = {
75
- status,
76
- deploy,
77
- undeploy,
78
- template,
79
- values
80
- }
@@ -1,53 +0,0 @@
1
- const wrapFeature = require('../wrapFeature');
2
-
3
- module.exports = wrapFeature('html5_apps_deployer', {
4
- async getChartCapabilities(context) {
5
- const model = await context.get('model');
6
- const projectName = model.app.name;
7
- return {
8
- 'html5_apps_deployer': {
9
- cloudService: null,
10
- backendDestinations: {},
11
- image: {
12
- repository: "<your-container-registry>/" + projectName + "-html5-deployer" ,
13
- tag: "latest"
14
- },
15
- bindings: {
16
- xsuaa: {
17
- serviceInstanceName: 'xsuaa'
18
- },
19
- destination: {
20
- serviceInstanceName: 'destinations'
21
- },
22
- html5_apps_repo: {
23
- serviceInstanceName: 'html5-apps-repo-host'
24
- }
25
- },
26
- resources: {
27
- limits: {
28
- cpu: "2000m",
29
- memory: "1G"
30
- },
31
- requests: {
32
- cpu: "1000m",
33
- memory: "1G"
34
- }
35
- }
36
- }
37
- }
38
- },
39
-
40
- getDestinationsParameters() {
41
- return {
42
- HTML5Runtime_enabled: true
43
- }
44
- },
45
-
46
- isHtml5AppsRepoHostRequired() {
47
- return true;
48
- },
49
-
50
- async addToChart(builder) {
51
- await builder.addAllTemplates(__dirname);
52
- }
53
- });
@@ -1,26 +0,0 @@
1
- const wrapFeature = require('../wrapFeature');
2
-
3
- module.exports = wrapFeature('html5_apps_repo_host', {
4
-
5
- async isRequired(context) {
6
- return await context.collectBool('isHtml5AppsRepoHostRequired');
7
- },
8
-
9
- async getChartCapabilities() {
10
- return {
11
- 'html5_apps_repo_host': {
12
- serviceOfferingName: 'html5-apps-repo',
13
- servicePlanName: 'app-host'
14
- }
15
- }
16
- },
17
-
18
- async addToChart(builder, { html5_apps_repo_host }) {
19
- await builder.addAllTemplates(__dirname);
20
-
21
- const { config } = html5_apps_repo_host;
22
- if (config) {
23
- await builder.addChartFile(config);
24
- }
25
- }
26
- });
@@ -1,16 +0,0 @@
1
- function checkNeedDestinations(env) {
2
- const kinds = [ 'odata', 'odata-v2', 'odata-v4', 'rest' ].reduce( (map, key) => {
3
- map[key] = true;
4
- return map;
5
- }, {});
6
- for (const service in env.requires) {
7
- const require = env.requires[service];
8
- if (!kinds[service] && kinds[require.kind]) return true;
9
- }
10
-
11
- return false;
12
- }
13
-
14
- module.exports = {
15
- checkNeedDestinations
16
- };
package/lib/k8s/index.js DELETED
@@ -1,153 +0,0 @@
1
- const Context = require('./Context');
2
- const buildModel = require('./buildModel');
3
- const ChartAdder = require('./ChartAdder');
4
- const ChartBuilder = require('./ChartBuilder');
5
- const { resource, mergeDeep, readFileIfExists } = require('./util');
6
- const fs = require('fs');
7
- const Path = require('path');
8
- const { cds, yaml } = require('./modules');
9
-
10
- async function context(projectPath, features = []) {
11
- if (!Path.isAbsolute(projectPath)) projectPath = Path.join(process.cwd(), projectPath);
12
-
13
- const projectEnv = cds.env.for('cds', projectPath);
14
- process.env.NODE_ENV='production';
15
- process.env.CDS_ENV='production';
16
- const productiveEnv = cds.env.for('cds', projectPath);
17
-
18
- const config = JSON.parse(JSON.stringify(projectEnv.k8s || {}));
19
-
20
- const context = new Context({
21
- projectPath,
22
- config,
23
- 'effective-config': context => effectiveConfig(context),
24
- features: featuresFactory(features),
25
- env: productiveEnv,
26
- model: buildModel,
27
- auth: require('./xsuaa'),
28
- multitenancy: require('./multitenancy'),
29
- 'hana-deployer': require('./hana-deployer'),
30
- connectivity: require('./connectivity'),
31
- destinations: require('./destinations'),
32
- 'event-mesh': require('./event-mesh'),
33
- 'auditlog': require('./auditlog'),
34
- 'html5-apps-deployer': require('./html5-apps-deployer'),
35
- 'html5-apps-repo-host': require('./html5-apps-repo-host'),
36
- 'srv': require('./deployment'),
37
- });
38
-
39
- return context;
40
- }
41
-
42
- // eslint-disable-next-line no-unused-vars
43
- async function addChart(context, path = 'chart', _features) {
44
- const model = await context.get('model');
45
-
46
- const mergeSemantics = {
47
- additions: []
48
- };
49
-
50
- context.add('chartPath', path);
51
-
52
- await context.forEach('prepareChart',
53
- async plugin => plugin.prepareChart()
54
- );
55
-
56
- // Collect chart values
57
- let chartValues = {};
58
- await context.forEach('getChartValues',
59
- async plugin => chartValues = {...chartValues, ...await plugin.getChartValues()}
60
- );
61
-
62
- // Collect deployments
63
- let deployments = {};
64
- await context.forEach('getChartDeployments',
65
- async plugin => deployments = {...deployments, ...await plugin.getChartDeployments(context)}
66
- );
67
-
68
- // Extend deployments
69
- for (const name in deployments) {
70
- await context.forEach('extendChartDeployment',
71
- async plugin => await plugin.extendChartDeployment(context, name, deployments[name], mergeSemantics)
72
- );
73
- }
74
-
75
- Object.assign(chartValues, deployments);
76
-
77
- // Collect capabilities
78
- let capabilities = {};
79
- await context.forEach('getChartCapabilities',
80
- async plugin => capabilities = {...capabilities, ...await plugin.getChartCapabilities(context)}
81
- );
82
-
83
- Object.assign(chartValues, capabilities);
84
-
85
- // Collect chart dependencies (subcharts)
86
- let chartDependencies = [];
87
- await context.forEach('getChartDependencies',
88
- async plugin => chartDependencies.push(...await plugin.getChartDependencies(context))
89
- );
90
-
91
- // Create chart
92
- const projectPath = await context.get('projectPath');
93
- const builder = new ChartBuilder({ path, rootPath: projectPath });
94
- await builder.begin();
95
-
96
- const chartAdder = new ChartAdder({ builder, chartValues, chartDependencies, resources: resource('helm/chart'), app: model.app, mergeSemantics });
97
- await chartAdder.execute();
98
-
99
- let values;
100
- try {
101
- values = await chartAdder.getSavedValues();
102
- } catch (error) {
103
- console.log('Skip adding features because of broken chart/values.yaml file.')
104
- }
105
-
106
- if (values) await context.forEach('addToChart', async plugin => plugin.addToChart(builder, values));
107
-
108
- await builder.end();
109
- }
110
-
111
-
112
- async function hasChart(context, path = 'chart') {
113
- return fs.existsSync(path);
114
- }
115
-
116
- function featuresFactory(_features) {
117
- return async function(context) {
118
- const features = new Set(_features);
119
-
120
- // Collect enabled features
121
- const effectiveConfig = await context.get('effective-config');
122
- for (const name in effectiveConfig) {
123
- const entry = effectiveConfig[name];
124
- if (entry && entry.enabled !== false) features.add(name);
125
- }
126
-
127
- return features;
128
- }
129
- }
130
-
131
- async function effectiveConfig(context) {
132
- const skeleton = { images: {} };
133
- let result;
134
-
135
- const chartPath = context.has('chartPath') ? await context.get('chartPath') : 'chart';
136
- const valuesFile = await readFileIfExists(Path.join(chartPath, 'values.yaml'), 'utf-8');
137
- if (valuesFile) {
138
- const values = yaml.parse(valuesFile);
139
- const config = await context.get('config');
140
- result = mergeDeep(values, config);
141
- } else {
142
- result = await context.get('config');
143
- }
144
-
145
- return Object.assign(skeleton, result);
146
- }
147
-
148
- module.exports = {
149
- context,
150
- addChart,
151
- hasChart,
152
- effectiveConfig
153
- }
@@ -1,36 +0,0 @@
1
- /* @sap/cds */
2
- const cds = require('@sap/cds/lib');
3
- const cds_cli = require('@sap/cds/bin/cds');
4
-
5
- /* @sap/cds-dk */
6
- const term = require('../util/term');
7
- const ProjectReader = require('../init/util/projectReader');
8
- const TemplateBase = require('../init/template/templateBase');
9
- const CDSGenerator = require('../init/index');
10
-
11
- /* @sap/cds-foss */
12
- const yaml = require("@sap/cds-foss")("yaml");
13
-
14
- /* other FOSS */
15
- const glob = require('glob');
16
- const xmlJs = require('xml-js');
17
-
18
- module.exports = {
19
- /* @sap/cds */
20
- cds,
21
- cds_cli,
22
- env: cds.env,
23
-
24
- /* @sap/cds-dk */
25
- term,
26
- ProjectReader,
27
- TemplateBase,
28
- CDSGenerator,
29
-
30
- /* @sap/cds-foss */
31
- yaml,
32
-
33
- /* other FOSS */
34
- glob,
35
- xmlJs
36
- };
@@ -1,24 +0,0 @@
1
- const wrapFeature = require('../wrapFeature');
2
-
3
- module.exports = wrapFeature('multitenancy', {
4
- /**
5
- * @param {import('../ChartBuilder')} builder
6
- */
7
- async addToChart(builder, { multitenancy }) {
8
- await builder.addAllTemplates(__dirname);
9
-
10
- if (multitenancy.config) {
11
- await builder.addChartFile(multitenancy.config);
12
- }
13
- },
14
-
15
- // eslint-disable-next-line no-unused-vars
16
- async getChartCapabilities(context) {
17
- return {
18
- xsuaa: {
19
- serviceOfferingName: 'saas-registry',
20
- servicePlanName: 'application'
21
- }
22
- }
23
- },
24
- });
@@ -1,25 +0,0 @@
1
- const { exec } = require("../../util/exec");
2
- const Path = require("path");
3
-
4
- async function renderXsSecurityJson(projectPath) {
5
- const result = await exec({
6
- cwd: projectPath,
7
- stdio: ["inherit", "pipe", "inherit"],
8
- })`cds compile srv -2 xsuaa`;
9
- const xsSecurityJson = result.stdout;
10
- return xsSecurityJson;
11
- }
12
-
13
- /**
14
- * @param {import('../ChartBuilder')} builder
15
- */
16
- async function addTemplates(builder) {
17
- const templates = Path.join(__dirname, 'templates');
18
- await builder.addTemplate(templates, 'xsuaa.yaml');
19
- await builder.addTemplate(templates, 'registry.yaml');
20
- }
21
-
22
- module.exports = {
23
- renderXsSecurityJson,
24
- addTemplates
25
- };