@sap/cds-dk 6.4.0 → 6.5.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 (93) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/bin/bind.js +30 -34
  3. package/bin/cds.js +14 -3
  4. package/bin/deploy/index.js +3 -1
  5. package/bin/deploy/to-sqlite.js +2 -1
  6. package/bin/env.js +4 -4
  7. package/bin/migrate.js +25 -4
  8. package/bin/push.js +4 -0
  9. package/bin/watch.js +3 -3
  10. package/lib/bind/KubernetesApiAccessor.js +79 -0
  11. package/lib/bind/{BindingManager.js → bindingManager.js} +16 -15
  12. package/lib/bind/bindingResolver.js +41 -68
  13. package/lib/bind/bindingUtil.js +93 -104
  14. package/lib/bind/cfKeyProvider.js +85 -74
  15. package/lib/bind/kubernetesCredentialsProvider.js +34 -132
  16. package/lib/bind/userCdsrcJsonStorageProvider.js +12 -18
  17. package/lib/client/params.js +2 -2
  18. package/lib/client/push.js +11 -6
  19. package/lib/client/settings_manager.js +2 -1
  20. package/lib/client/subscription.js +4 -1
  21. package/lib/import/odata/v2parser.js +32 -8
  22. package/lib/import/odata/v4parser.js +11 -3
  23. package/lib/init/constants.js +1 -1
  24. package/lib/init/index.js +3 -11
  25. package/lib/init/template/approuter/files/approuter-configmap.yaml +4 -1
  26. package/lib/init/template/approuter/files/approuter-mtxs-configmap.yaml +5 -1
  27. package/lib/init/template/approuter/files/package.json +1 -1
  28. package/lib/init/template/approuter/files/values.yaml.hbs +1 -1
  29. package/lib/init/template/approuter/files/xs-app.json.hbs +2 -2
  30. package/lib/init/template/approuter/index.js +4 -5
  31. package/lib/init/template/auditlog/index.js +1 -1
  32. package/lib/init/template/data/index.js +1 -1
  33. package/lib/init/template/destinations/index.js +1 -1
  34. package/lib/init/template/enterprise-messaging/index.js +1 -1
  35. package/lib/init/template/extensibility/index.js +6 -1
  36. package/lib/init/template/hana/files/chart.yaml +4 -0
  37. package/lib/init/template/hana/files/hana.yaml +1 -0
  38. package/lib/init/template/hana/files/java/db/package.json +1 -1
  39. package/lib/init/template/hana/files/values.yaml.hbs +6 -3
  40. package/lib/init/template/hana/index.js +73 -21
  41. package/lib/init/template/helm/chart/templates/_deployment_helpers.tpl +14 -6
  42. package/lib/init/template/helm/chart/values.root.schema.json +10 -0
  43. package/lib/init/template/helm/chart/values.schema.json +11 -110
  44. package/lib/init/template/helm/index.js +2 -2
  45. package/lib/init/template/helm/subcharts/content-deployment/Chart.yaml +5 -0
  46. package/lib/init/template/helm/subcharts/content-deployment/templates/_helpers.tpl +207 -0
  47. package/lib/init/template/helm/subcharts/content-deployment/templates/job.yaml +66 -0
  48. package/lib/init/template/helm/subcharts/content-deployment/templates/secret.yaml +10 -0
  49. package/lib/init/template/helm/subcharts/content-deployment/templates/service-account.yaml +4 -0
  50. package/lib/init/template/helm/subcharts/content-deployment/templates/service-binding.yaml +28 -0
  51. package/lib/init/template/helm/subcharts/content-deployment/values-lint.yaml +5 -0
  52. package/lib/init/template/helm/subcharts/content-deployment/values.md +1014 -0
  53. package/lib/init/template/helm/subcharts/content-deployment/values.schema.json +589 -0
  54. package/lib/init/template/helm/subcharts/content-deployment/values.yaml +54 -0
  55. package/lib/init/template/helm/{subchart → subcharts/web-application}/Chart.yaml +0 -0
  56. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/_helpers.tpl +56 -50
  57. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/api-rule.yaml +1 -1
  58. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/deployment.yaml +15 -9
  59. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/network-policy.yaml +0 -0
  60. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/pod-disruption-budget.yaml +2 -2
  61. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/secret.yaml +0 -0
  62. package/lib/init/template/helm/subcharts/web-application/templates/service-account.yaml +6 -0
  63. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/service-binding.yaml +4 -3
  64. package/lib/init/template/helm/{subchart → subcharts/web-application}/templates/service.yaml +0 -0
  65. package/lib/init/template/helm/subcharts/web-application/templating.md +44 -0
  66. package/lib/init/template/helm/{subchart → subcharts/web-application}/values-lint.yaml +0 -0
  67. package/lib/init/template/helm/{subchart → subcharts/web-application}/values.md +254 -200
  68. package/lib/init/template/helm/{subchart → subcharts/web-application}/values.schema.json +82 -28
  69. package/lib/init/template/helm/{subchart → subcharts/web-application}/values.yaml +15 -5
  70. package/lib/init/template/html5-repo/files/chart.yaml +4 -0
  71. package/lib/init/template/html5-repo/files/html5-apps-deployer-configmap.yaml +14 -0
  72. package/lib/init/template/html5-repo/index.js +39 -7
  73. package/lib/init/template/kibana-logging/index.js +1 -1
  74. package/lib/init/template/lint/index.js +1 -1
  75. package/lib/init/template/multitenancy/files/saas-registry.yaml +2 -2
  76. package/lib/init/template/multitenancy/files/service-manager.yaml +1 -0
  77. package/lib/init/template/multitenancy/files/values.yaml.hbs +10 -6
  78. package/lib/init/template/multitenancy/index.js +21 -3
  79. package/lib/init/util/commandUtil.js +5 -5
  80. package/lib/init/util/merge.js +27 -1
  81. package/lib/init/util/mvnArchetypeUtil.js +1 -1
  82. package/lib/init/util/projectReader.js +2 -2
  83. package/lib/util/exec.js +3 -3
  84. package/lib/util/term.js +7 -7
  85. package/lib/watch/livereload-connect.js +187 -0
  86. package/lib/watch/livereload-server.js +12 -12
  87. package/lib/watch/node-watch.js +1 -1
  88. package/npm-shrinkwrap.json +191 -404
  89. package/package.json +2 -5
  90. package/lib/init/template/hana/files/hana-deployer-job.yaml +0 -49
  91. package/lib/init/template/html5-repo/files/_html5_deployment_helpers.tpl +0 -16
  92. package/lib/init/template/html5-repo/files/html5-apps-deployer-job.yaml +0 -61
  93. package/lib/init/util/spinner.js +0 -80
@@ -112,7 +112,7 @@ Service Binding secret volumes
112
112
  {{- end }}
113
113
  - name: {{ $name }}
114
114
  secret:
115
- secretName: {{ $secretName }}
115
+ secretName: {{ tpl $secretName $ }}
116
116
  {{- end }}
117
117
  {{- end }}
118
118
 
@@ -146,66 +146,73 @@ Calculate the final image name
146
146
  {{/*
147
147
  Create the name of a service instance.
148
148
  We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
149
- If release name contains chart name it will be used as service insatnce name.
149
+ If release name contains chart name it will be used as service instance name.
150
150
  */}}
151
151
  {{- define "web-application.serviceInstanceName" -}}
152
+ {{- $name := "" }}
152
153
  {{- if .binding.serviceInstanceFullname }}
153
154
  {{- if gt (len .binding.serviceInstanceFullname) 63 }}
154
155
  {{- fail (printf "name exceeds 63 characters: '%s'" .binding.serviceInstanceFullname) }}
155
156
  {{- end }}
156
- {{- .binding.serviceInstanceFullname }}
157
+ {{- $name = .binding.serviceInstanceFullname }}
157
158
  {{- else }}
158
- {{- $name := .binding.serviceInstanceName }}
159
- {{- if not (hasPrefix .release $name)}}
160
- {{- $name = printf "%s-%s" .release $name }}
159
+ {{- $name = .binding.serviceInstanceName }}
160
+ {{- if not (hasPrefix .root.Release.Name $name)}}
161
+ {{- $name = printf "%s-%s" .root.Release.Name $name }}
161
162
  {{- end }}
162
163
  {{- if gt (len $name) 63 }}
163
164
  {{- fail (printf "name exceeds 63 characters: '%s'" $name) }}
164
165
  {{- end }}
165
- {{- $name }}
166
166
  {{- end }}
167
+ {{- tpl $name .root }}
167
168
  {{- end }}
168
169
 
169
170
  {{- define "web-application.processEnv" -}}
170
171
  {{- $result := dict }}
171
172
  {{- $variables := list }}
172
- {{- range $k, $v := . }}
173
+ {{- range $k, $v := .Values.env }}
173
174
  {{- $variable := dict }}
174
- {{- if (kindIs "string" $k) }}
175
- {{- if eq "APPLICATION_NAME" $k }}
176
- {{- $_ := set $result "appName" true }}
177
- {{- end }}
178
- {{- if eq "APPLICATION_URI" $k }}
179
- {{- $_ := set $result "appURI" true }}
180
- {{- end }}
181
- {{- $_ := set $variable "name" $k -}}
182
- {{- if (kindIs "map" $v)}}
183
- {{- $_ := set $variable "valueFrom" $v}}
184
- {{- else }}
185
- {{- $_ := set $variable "value" ($v | toString) }}
186
- {{- end }}
175
+ {{/*
176
+ We support two versions to provide environment varialbes: as an array and as a map
177
+
178
+ env:
179
+ - name: TEST
180
+ value: X
181
+
182
+ env:
183
+ TEST: X
184
+
185
+ Transform the map case into the array case:
186
+ */}}
187
+ {{- if (not (kindIs "map" $v)) }}
188
+ {{- $v = (dict "value" $v) }}
189
+ {{- end }}
190
+ {{- if (kindIs "string" $k) }} {{/* $k will be the array index (therefore int) in the array case */}}
191
+ {{- $_ := (set $v "name" $k) }}
192
+ {{- end }}
193
+
194
+ {{/* we have defaults for APPLICATION_NAME and APPLICATION_URI, but only want to provide them, if the users has no explicit values. */}}
195
+ {{- if eq "APPLICATION_NAME" $v.name }}
196
+ {{- $_ := set $result "appName" true }}
197
+ {{- end }}
198
+ {{- if eq "APPLICATION_URI" $v.name }}
199
+ {{- $_ := set $result "appURI" true }}
200
+ {{- end }}
201
+
202
+ {{/* Translate into K8s struct */}}
203
+ {{- $_ := set $variable "name" $v.name }}
204
+ {{- if $v.value }}
205
+ {{- $_ := set $variable "value" ($v.value | toString) }}
187
206
  {{- else }}
188
- {{- if eq "APPLICATION_NAME" $v.name }}
189
- {{- $_ := set $result "appName" true }}
190
- {{- end }}
191
- {{- if eq "APPLICATION_URI" $v.name }}
192
- {{- $_ := set $result "appURI" true }}
193
- {{- end }}
194
- {{- $_ := set $variable "name" $v.name }}
195
- {{- if $v.value }}
196
- {{- $_ := set $variable "value" ($v.value | toString)}}
197
- {{- else }}
198
- {{- $_ := set $variable "valueFrom" (omit $v "name")}}
199
- {{- end }}
207
+ {{- $_ := set $variable "valueFrom" (omit $v "name")}}
200
208
  {{- end }}
201
209
  {{- $variables = append $variables $variable}}
202
210
  {{- end }}
203
211
  {{- $_ := set $result "vars" $variables }}
204
- {{- $result | mustToJson }}
212
+ {{- (fromYaml (tpl (toYaml $result) $)) | mustToJson }}
205
213
  {{- end }}
206
214
 
207
215
  {{- define "web-application.processEnvFrom" -}}
208
- {{- $ := . -}}
209
216
  {{- $result := dict }}
210
217
  {{- $variables := list }}
211
218
  {{- range $secretName := .Values.envSecretNames }}
@@ -214,21 +221,20 @@ If release name contains chart name it will be used as service insatnce name.
214
221
  {{- $variables = append $variables (dict "secretRef" $variable)}}
215
222
  {{- end }}
216
223
  {{- range $envFrom := .Values.envFrom }}
217
- {{- if hasKey $envFrom "configMapRef" }}
218
- {{- if and (hasKey $envFrom.configMapRef "tpl") ($envFrom.configMapRef.tpl) }}
219
- {{- $name := (tpl $envFrom.configMapRef.name $) }}
220
- {{- $_ := set $envFrom.configMapRef "name" $name }}
221
- {{- end }}
222
- {{- $_ := unset $envFrom.configMapRef "tpl" }}
223
- {{- else }}
224
- {{- if and (hasKey $envFrom.secretRef "tpl") ($envFrom.secretRef.tpl) }}
225
- {{- $name := (tpl $envFrom.secretRef.name $) }}
226
- {{- $_ := set $envFrom.secretRef "name" $name }}
227
- {{- end }}
228
- {{- $_ := unset $envFrom.secretRef "tpl" }}
229
- {{- end }}
230
224
  {{- $variables = append $variables $envFrom }}
231
225
  {{- end }}
232
226
  {{- $_ := set $result "vars" $variables }}
233
- {{- $result | mustToJson }}
234
- {{- end }}
227
+ {{- (fromYaml (tpl (toYaml $result) $)) | mustToJson }}
228
+ {{- end }}
229
+
230
+ {{- define "web-application.ha" -}}
231
+ {{- $ha := true }}
232
+ {{- if hasKey .Values "ha"}}
233
+ {{- if hasKey .Values.ha "enabled" }}
234
+ {{- $ha = .Values.ha.enabled }}
235
+ {{- end }}
236
+ {{- end }}
237
+ {{- if $ha }}
238
+ true
239
+ {{- end}}
240
+ {{- end }}
@@ -5,7 +5,7 @@ metadata:
5
5
  name: {{ include "web-application.fullname" . }}
6
6
  labels: {{- include "web-application.labels" . | nindent 4 }}
7
7
  spec:
8
- gateway: kyma-gateway.kyma-system.svc.cluster.local
8
+ gateway: {{ .Values.expose.gateway }}
9
9
  host: {{ include "web-application.exposeHost" . }}
10
10
  service:
11
11
  name: {{ include "web-application.fullname" . }}
@@ -10,13 +10,15 @@ spec:
10
10
  template:
11
11
  metadata:
12
12
  labels: {{- include "web-application.selectorLabels" . | nindent 8 }}
13
+ annotations:
14
+ container.apparmor.security.beta.kubernetes.io/{{ include "web-application.name" . }}: runtime/default
13
15
  spec:
14
16
  {{- if (include "web-application.imagePullSecretName" .) }}
15
17
  imagePullSecrets:
16
18
  - name: {{ include "web-application.imagePullSecretName" . }}
17
19
  {{- end }}
18
20
  automountServiceAccountToken: false
19
- serviceAccountName: {{ .Values.serviceAccountName }}
21
+ serviceAccountName: {{ tpl (.Values.serviceAccountName | default (include "web-application.fullname" .)) $ }}
20
22
  containers:
21
23
  - image: {{ include "web-application.imageName" . }}
22
24
  name: {{ include "web-application.name" . }}
@@ -38,7 +40,7 @@ spec:
38
40
  value: {{ .Values.port | quote }}
39
41
  - name: TMPDIR
40
42
  value: /tmp
41
- {{- $envVars := (include "web-application.processEnv" .Values.env | fromJson) }}
43
+ {{- $envVars := (include "web-application.processEnv" $ | fromJson) }}
42
44
  {{- if not (eq (len $envVars.vars) 0) }}
43
45
  {{- $envVars.vars | toYaml | nindent 8}}
44
46
  {{- end }}
@@ -78,7 +80,8 @@ spec:
78
80
  tcpSocket:
79
81
  port: {{ .Values.port }}
80
82
  {{- end }}
81
- failureThreshold: {{ div (add1 .Values.startupTimeout) 2 }}
83
+ {{- $startupTimeout := .Values.startupTimeout | default .Values.startupTimeoutSeconds }}
84
+ failureThreshold: {{ div (add1 $startupTimeout) 2 }}
82
85
  periodSeconds: 2
83
86
  volumeMounts:
84
87
  - name: tmp
@@ -100,15 +103,18 @@ spec:
100
103
  seccompProfile:
101
104
  type: RuntimeDefault
102
105
  restartPolicy: Always
106
+ terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
103
107
  securityContext:
104
108
  runAsNonRoot: true
105
- {{- if .Values.ha.enabled }}
109
+ {{- if (include "web-application.ha" .) }}
106
110
  topologySpreadConstraints:
111
+ {{- range $constraint := .Values.availability.topologySpreadConstraints }}
107
112
  - labelSelector:
108
- matchLabels: {{- include "web-application.selectorLabels" . | nindent 12 }}
109
- maxSkew: 1
110
- topologyKey: kubernetes.io/hostname
111
- whenUnsatisfiable: DoNotSchedule
113
+ matchLabels: {{- include "web-application.selectorLabels" $ | nindent 12 }}
114
+ maxSkew: {{ $constraint.maxSkew }}
115
+ topologyKey: {{ $constraint.topologyKey }}
116
+ whenUnsatisfiable: {{ $constraint.whenUnsatisfiable }}
117
+ {{- end }}
112
118
  {{- end }}
113
119
  volumes:
114
120
  - emptyDir: {}
@@ -116,5 +122,5 @@ spec:
116
122
  {{- include "web-application.serviceVolumes" . | nindent 6 }}
117
123
  {{- range $volume := .Values.additionalVolumes }}
118
124
  -
119
- {{- omit $volume "volumeMount" | toYaml | nindent 8 }}
125
+ {{- tpl (omit $volume "volumeMount" | toYaml) $ | nindent 8 }}
120
126
  {{- end }}
@@ -1,11 +1,11 @@
1
- {{- if .Values.ha.enabled }}
1
+ {{- if (include "web-application.ha" .) }}
2
2
  apiVersion: policy/v1
3
3
  kind: PodDisruptionBudget
4
4
  metadata:
5
5
  name: {{ include "web-application.fullname" . }}
6
6
  labels: {{- include "web-application.labels" . | nindent 4 }}
7
7
  spec:
8
- maxUnavailable: 10%
8
+ maxUnavailable: {{ .Values.availability.podDisruptionBudget.maxUnavailable }}
9
9
  selector:
10
10
  matchLabels: {{- include "web-application.selectorLabels" . | nindent 6 }}
11
11
  {{- end }}
@@ -0,0 +1,6 @@
1
+ {{if not .Values.serviceAccountName}}
2
+ apiVersion: v1
3
+ kind: ServiceAccount
4
+ metadata:
5
+ name: {{ include "web-application.fullname" . }}
6
+ {{end}}
@@ -7,18 +7,19 @@ metadata:
7
7
  name: {{ include "web-application.bindingName" (dict "root" $ "name" $name) }}
8
8
  labels: {{- include "web-application.labels" $ | nindent 4 }}
9
9
  spec:
10
- serviceInstanceName: {{include "web-application.serviceInstanceName" (dict "binding" $params "release" $.Release.Name) }}
10
+ serviceInstanceName: {{include "web-application.serviceInstanceName" (dict "binding" $params "root" $) }}
11
+ secretKey: credentials
11
12
  {{- if $params.externalName }}
12
13
  externalName: {{ $params.externalName }}
13
14
  {{- end }}
14
15
  {{- if $params.secretName }}
15
- secretName: {{ $params.secretName }}
16
+ secretName: {{ tpl $params.secretName $ }}
16
17
  {{- end }}
17
18
  {{- if $params.parameters }}
18
19
  parameters: {{ $params.parameters | toYaml | nindent 4 }}
19
20
  {{- end }}
20
21
  {{- if $params.parametersFrom }}
21
- parametersFrom: {{ $params.parametersFrom | toYaml | nindent 4 }}
22
+ parametersFrom: {{ tpl ($params.parametersFrom | toYaml) $ | nindent 4 }}
22
23
  {{- end }}
23
24
  {{- if $params.credentialsRotationPolicy }}
24
25
  credentialsRotationPolicy: {{ $params.credentialsRotationPolicy | toYaml | nindent 4 }}
@@ -0,0 +1,44 @@
1
+ # Templating Values
2
+
3
+ This functionality is enabled only for some of the templates provided by this helm chart. The feature itself comes with some performance costs that you should keep in mind. More details on this feature can be found in the official [documentation](https://helm.sh/docs/howto/charts_tips_and_tricks/#using-the-tpl-function).
4
+
5
+ The following values can be used in the template:
6
+
7
+ 1. [Global values](https://helm.sh/docs/chart_template_guide/subcharts_and_globals/)
8
+ 2. Values passed to the chart directly
9
+ 3. [Built-in objects](https://helm.sh/docs/chart_template_guide/builtin_objects/)
10
+
11
+ Here's a full list of values with examples, where you can use templates:
12
+
13
+ ```yaml
14
+ serviceAccountName: my-service-account-{{ .Release.Name }}
15
+ env:
16
+ - name: key1
17
+ value: value1-{{ .Release.Name }}
18
+ - name: key2
19
+ configMapKeyRef:
20
+ name: my-configmap-{{ .Release.Name }}
21
+ key: my-key
22
+ envFrom:
23
+ - configMapRef:
24
+ name: my-configmap1-{{ .Release.Name }}
25
+ - secretRef:
26
+ name: my-secret-ref1-{{ .Release.Name }}
27
+ additionalVolumes:
28
+ - name: my-volume
29
+ secret:
30
+ secretName: my-secret-{{ .Release.Name }}
31
+ volumeMount:
32
+ mountPath: /etc/mysecret
33
+ readOnly: true
34
+ bindings:
35
+ hana:
36
+ serviceInstanceName: hana-{{ .Release.Name }}
37
+ secretName: hana-secret-{{ .Release.Name }}
38
+ parametersFrom:
39
+ - secretKeyRef:
40
+ key: my-key
41
+ name: test-RELEASE-NAME
42
+ serviceManager:
43
+ fromSecret: manual-secret-{{ .Release.Name }}
44
+ ```