@sap/cds-dk 6.7.0 → 6.7.2

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.
package/CHANGELOG.md CHANGED
@@ -7,19 +7,33 @@ This project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
8
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
9
9
 
10
- ## Version 6.7.0 - 2023-03-29
10
+ ## Version 6.7.2 - 2023-04-27
11
11
 
12
12
  ### Added
13
13
 
14
- - `cds upgrade` enables upgrading a tenant subscribed to a multitenant SaaS app to the latest base model.
14
+ - Added option `--skip-verification` to command `cds migrate`. It skips the extension verification to save memory. Requires `@sap/cds-mtxs@1.7.3`.
15
15
 
16
16
  ### Fixed
17
17
 
18
- - `cds watch`'s livereload feature may now use a local IPv6 address (`::1`) instead of always `localhost`. This is usually the case on Node.js 17 or higher.
19
- - In all but `cds compile` errors where not handled correctly, especially compiler errors not displayed in human readable format.
20
- - `cds init` creates project sample files correctly.
21
- - CLI commands w/ unknown arguments (`cds --foo`) clearly fail again with a proper error message
22
- - Reduce console output in case of multitenancy-related command failures.
18
+ - Swagger UI no longer fails with an error `Value of 'namespaceAndName' parameter must be in the following format: <namespace>.<name>`
19
+
20
+ ## Version 6.7.1 - 2023-04-19
21
+
22
+ ### Changed
23
+
24
+ - `cds init` uses latest Maven Java archetype version 1.33.1 for creating Java projects.
25
+ - Bump `@sap/cds` to 6.7.1
26
+ - Bump `@sap/cds-mtxs` to 1.7.2
27
+
28
+ ### Fixed
29
+
30
+ - Compatibility with @sap/cds versions >= 4.5 and < 6.2: avoid runtime errors with debugging disabled.
31
+
32
+ ## Version 6.7.0 - 2023-03-28
33
+
34
+ ### Added
35
+
36
+ - `cds upgrade` enables upgrading a tenant subscribed to a multitenant SaaS app to the latest base model.
23
37
 
24
38
  ### Changed
25
39
 
@@ -30,6 +44,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
30
44
  - `cds subscribe` and `cds unsubscribe` no longer require a username in case @sap/cds-mtxs is configured with dummy auth.
31
45
  - `cds subscribe` and `cds unsubscribe` now rely on @sap/cds-mtxs (version 1.7.0 or higher).
32
46
 
47
+ ### Fixed
48
+
49
+ - `cds watch`'s livereload feature may now use a local IPv6 address (`::1`) instead of always `localhost`. This is usually the case on Node.js 17 or higher.
50
+ - In all but `cds compile` errors where not handled correctly, especially compiler errors not displayed in human readable format.
51
+ - `cds init` creates project sample files correctly.
52
+ - CLI commands w/ unknown arguments (`cds --foo`) clearly fail again with a proper error message
53
+ - Reduce console output in case of multitenancy-related command failures.
54
+
33
55
  ## Version 6.6.2 - 2023-03-22
34
56
 
35
57
  ### Fixed
package/bin/migrate.js CHANGED
@@ -1,11 +1,11 @@
1
1
  module.exports = Object.assign(migrate, {
2
2
  options: ['--directory', '--tag', '--tagRule'],
3
3
  shortcuts: ['-d'],
4
- flags: ['--dry', '--force', '--cleanup', '--resolve-bindings'],
4
+ flags: ['--dry', '--force', '--skip-verification', '--cleanup', '--resolve-bindings'],
5
5
  help: `
6
6
  # SYNOPSIS
7
7
 
8
- *cds migrate* <tenant1|"*">[,<tenant2>] [-d <directory>] [--tag <tag>] [--tagRule <tag rule>] [--dry] [--force]
8
+ *cds migrate* <tenant1|"*">[,<tenant2>] [-d <directory>] [--tag <tag>] [--tagRule <tag rule>] [--dry] [--force] [--skip-verification]
9
9
 
10
10
  Migrate extensions created with @sap/cds-mtx to extensions for @sap/cds-mtxs
11
11
 
@@ -33,6 +33,10 @@ module.exports = Object.assign(migrate, {
33
33
 
34
34
  Do a dry-run only. Only run a verification of the extension migration.
35
35
 
36
+ *--skip-verification
37
+
38
+ Skip verification step. Does not check for potential deployment differences.
39
+
36
40
  *--cleanup* (beta)
37
41
 
38
42
  Removes all metadata containers created by @sap/cds-mtx.
package/lib/cds.js CHANGED
@@ -7,6 +7,18 @@ const cds = module.exports = _local ('@sap/cds')
7
7
  cds._log = _local ('@sap/cds/bin/utils/log')
8
8
  cds._local = _local
9
9
 
10
+ if (/^(4\.[56]|5|6\.[01])\b/.test(cds.version)) {
11
+ // cds.debug may return false as of @sap/cds@(>=4.5 && < 6.2).
12
+ // Patch this to be able to call `cds.debug(label)?.(message)`.
13
+ // REVISIT remove once we no longer support these versions
14
+ Object.defineProperty(cds, 'debug', {
15
+ value: function cds_debug_patched (module, options) {
16
+ const L = cds.log (module, options)
17
+ if (L._debug) return L.debug
18
+ }
19
+ })
20
+ }
21
+
10
22
  function _resolve (id) {
11
23
  return require.resolve (id, {paths:[
12
24
  process.cwd(), // project-local module is preferred
@@ -59,6 +59,8 @@ module.exports.csdl2openapi = function (
59
59
  maxLevels: maxLevels = 5
60
60
  } = {}
61
61
  ) {
62
+ // as preProcess below mutates the csdl, copy it before, to avoid side-effects on the caller side
63
+ csdl = JSON.parse(JSON.stringify(csdl))
62
64
  serviceRoot = serviceRoot || (scheme + '://' + host + basePath);
63
65
  const queryOptionPrefix = csdl.$Version <= '4.0' ? '$' : '';
64
66
  const typesToInline = {}; // filled in schema() and used in inlineTypes()
@@ -1,6 +1,6 @@
1
1
  const os = require('os');
2
2
 
3
- const MAVEN_ARCHETYPE_VERSION = '1.32.1';
3
+ const MAVEN_ARCHETYPE_VERSION = '1.33.1';
4
4
 
5
5
  const constants = {
6
6
  IS_WIN: (os.platform() === 'win32'),
@@ -11,16 +11,21 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
11
11
  If release name contains chart name it will be used as a full name.
12
12
  */}}
13
13
  {{- define "web-application.fullname" -}}
14
- {{- if .Values.fullnameOverride }}
15
- {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16
- {{- else }}
17
- {{- $name := default .Chart.Name .Values.nameOverride }}
18
- {{- if contains $name .Release.Name }}
19
- {{- .Release.Name | trunc 63 | trimSuffix "-" }}
20
- {{- else }}
21
- {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22
- {{- end }}
23
- {{- end }}
14
+ {{- if .Values.fullnameOverride }}
15
+ {{- if gt (len .Values.fullnameOverride) 63 }}
16
+ {{- fail (printf "name exceeds 63 characters: '%s'" .Values.fullnameOverride) }}
17
+ {{- end }}
18
+ {{- .Values.fullnameOverride }}
19
+ {{- else }}
20
+ {{- $name := default .Chart.Name .Values.nameOverride }}
21
+ {{- if not (eq .Release.Name $name)}}
22
+ {{- $name = printf "%s-%s" .Release.Name $name }}
23
+ {{- end }}
24
+ {{- if gt (len $name) 63 }}
25
+ {{- fail (printf "name exceeds 63 characters: '%s'" $name) }}
26
+ {{- end }}
27
+ {{- $name }}
28
+ {{- end }}
24
29
  {{- end }}
25
30
 
26
31
  {{/*
@@ -70,7 +75,7 @@ Define Host for the APIRule
70
75
  */}}
71
76
  {{- define "web-application.exposeHost" -}}
72
77
  {{- if .Values.expose.host }}
73
- {{- .Values.expose.host }}
78
+ {{- tpl .Values.expose.host . }}
74
79
  {{- else }}
75
80
  {{- $name := (include "web-application.fullname" .) }}
76
81
  {{- if hasPrefix $name .Release.Namespace }}
@@ -92,7 +97,8 @@ Define the application uri which will be used for the VCAP_APPLICATION env varia
92
97
  Service Binding secret mounts
93
98
  */}}
94
99
  {{- define "web-application.serviceMounts" -}}
95
- {{- range $name, $params := .Values.bindings }}
100
+ {{- $bindings := omit .Values.bindings "defaultProperties" -}}
101
+ {{- range $name, $params := $bindings }}
96
102
  - mountPath: /bindings/{{ $name }}/
97
103
  name: "{{ $name }}"
98
104
  readOnly: true
@@ -103,7 +109,8 @@ Service Binding secret mounts
103
109
  Service Binding secret volumes
104
110
  */}}
105
111
  {{- define "web-application.serviceVolumes" -}}
106
- {{- range $name, $params := .Values.bindings }}
112
+ {{- $bindings := omit .Values.bindings "defaultProperties" -}}
113
+ {{- range $name, $params := $bindings }}
107
114
  {{- $secretName := (include "web-application.bindingName" (dict "root" $ "name" $name)) }}
108
115
  {{- if $params.fromSecret }}
109
116
  {{- $secretName = $params.fromSecret}}
@@ -173,7 +180,7 @@ If release name contains chart name it will be used as service instance name.
173
180
  {{- range $k, $v := .Values.env }}
174
181
  {{- $variable := dict }}
175
182
  {{/*
176
- We support two versions to provide environment varialbes: as an array and as a map
183
+ We support two versions to provide environment variables: as an array and as a map
177
184
 
178
185
  env:
179
186
  - name: TEST
@@ -215,26 +222,9 @@ If release name contains chart name it will be used as service instance name.
215
222
  {{- define "web-application.processEnvFrom" -}}
216
223
  {{- $result := dict }}
217
224
  {{- $variables := list }}
218
- {{- range $secretName := .Values.envSecretNames }}
219
- {{- $variable := dict }}
220
- {{- $_ := set $variable "name" $secretName -}}
221
- {{- $variables = append $variables (dict "secretRef" $variable)}}
222
- {{- end }}
223
225
  {{- range $envFrom := .Values.envFrom }}
224
226
  {{- $variables = append $variables $envFrom }}
225
227
  {{- end }}
226
228
  {{- $_ := set $result "vars" $variables }}
227
229
  {{- (fromYaml (tpl (toYaml $result) $)) | mustToJson }}
228
230
  {{- 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 }}
@@ -1,4 +1,4 @@
1
- {{ if .Values.expose.enabled}}
1
+ {{- if .Values.expose.enabled -}}
2
2
  apiVersion: gateway.kyma-project.io/v1beta1
3
3
  kind: APIRule
4
4
  metadata:
@@ -11,14 +11,5 @@ spec:
11
11
  name: {{ include "web-application.fullname" . }}
12
12
  port: {{ .Values.port }}
13
13
  rules:
14
- - accessStrategies:
15
- - handler: allow
16
- methods:
17
- - GET
18
- - POST
19
- - PUT
20
- - PATCH
21
- - DELETE
22
- - HEAD
23
- path: /.*
24
- {{ end }}
14
+ {{- toYaml .Values.expose.rules | nindent 6 }}
15
+ {{- end }}
@@ -32,10 +32,8 @@ spec:
32
32
  {{- $envFromVars.vars | toYaml | nindent 8}}
33
33
  {{- end }}
34
34
  env:
35
- {{- if .Values.bindings }}
36
35
  - name: SERVICE_BINDING_ROOT
37
36
  value: /bindings
38
- {{- end }}
39
37
  - name: PORT
40
38
  value: {{ .Values.port | quote }}
41
39
  - name: TMPDIR
@@ -52,40 +50,40 @@ spec:
52
50
  - name: APPLICATION_URI
53
51
  value: {{ include "web-application.applicationUri" . }}
54
52
  {{- end }}
55
- {{- $health := .Values.health_check | default .Values.health }}
56
53
  livenessProbe:
57
- {{- if $health.liveness.path }}
54
+ {{- if .Values.health.liveness.path }}
58
55
  httpGet:
59
- path: {{ $health.liveness.path }}
56
+ path: {{ .Values.health.liveness.path }}
60
57
  port: http
61
58
  {{- else }}
62
59
  tcpSocket:
63
60
  port: {{ .Values.port }}
64
61
  {{- end }}
65
62
  readinessProbe:
66
- {{- if $health.readiness.path }}
63
+ {{- if .Values.health.readiness.path }}
67
64
  httpGet:
68
- path: {{ $health.readiness.path }}
65
+ path: {{ .Values.health.readiness.path }}
69
66
  port: http
70
67
  {{- else }}
71
68
  tcpSocket:
72
69
  port: {{ .Values.port }}
73
70
  {{- end }}
74
71
  startupProbe:
75
- {{- if $health.liveness.path }}
72
+ {{- if .Values.health.liveness.path }}
76
73
  httpGet:
77
- path: {{ $health.liveness.path }}
74
+ path: {{ .Values.health.liveness.path }}
78
75
  port: http
79
76
  {{- else }}
80
77
  tcpSocket:
81
78
  port: {{ .Values.port }}
82
79
  {{- end }}
83
- {{- $startupTimeout := .Values.startupTimeout | default .Values.startupTimeoutSeconds }}
84
- failureThreshold: {{ div (add1 $startupTimeout) 2 }}
80
+ failureThreshold: {{ div (add1 .Values.startupTimeoutSeconds) 2 }}
85
81
  periodSeconds: 2
86
82
  volumeMounts:
87
83
  - name: tmp
88
84
  mountPath: /tmp
85
+ - name: bindings-root
86
+ mountPath: /bindings
89
87
  {{- range $volume := .Values.additionalVolumes }}
90
88
  - name: {{ $volume.name | quote }}
91
89
  {{- toYaml $volume.volumeMount | nindent 10 }}
@@ -99,14 +97,13 @@ spec:
99
97
  drop:
100
98
  - ALL
101
99
  privileged: false
102
- readOnlyRootFilesystem: false
100
+ readOnlyRootFilesystem: {{ .Values.readOnlyRootFilesystem | default false }}
103
101
  seccompProfile:
104
102
  type: RuntimeDefault
105
103
  restartPolicy: Always
106
104
  terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
107
105
  securityContext:
108
106
  runAsNonRoot: true
109
- {{- if (include "web-application.ha" .) }}
110
107
  topologySpreadConstraints:
111
108
  {{- range $constraint := .Values.availability.topologySpreadConstraints }}
112
109
  - labelSelector:
@@ -115,10 +112,11 @@ spec:
115
112
  topologyKey: {{ $constraint.topologyKey }}
116
113
  whenUnsatisfiable: {{ $constraint.whenUnsatisfiable }}
117
114
  {{- end }}
118
- {{- end }}
119
115
  volumes:
120
116
  - emptyDir: {}
121
117
  name: tmp
118
+ - emptyDir: {}
119
+ name: bindings-root
122
120
  {{- include "web-application.serviceVolumes" . | nindent 6 }}
123
121
  {{- range $volume := .Values.additionalVolumes }}
124
122
  -
@@ -1,18 +1,41 @@
1
- apiVersion: networking.k8s.io/v1
1
+ {{- if .Values.networkSecurity.enabled -}}
2
2
  kind: NetworkPolicy
3
+ apiVersion: networking.k8s.io/v1
3
4
  metadata:
4
5
  name: {{ include "web-application.fullname" . }}
5
6
  labels: {{- include "web-application.labels" . | nindent 4 }}
6
7
  spec:
7
8
  ingress:
9
+ {{- if .Values.expose.enabled }}
8
10
  - from:
9
11
  - podSelector:
10
12
  matchLabels:
11
13
  app: istio-ingressgateway
12
14
  namespaceSelector:
13
15
  matchLabels:
14
- name: istio-system
15
- podSelector:
16
- matchLabels: {{- include "web-application.selectorLabels" . | nindent 6 }}
16
+ kubernetes.io/metadata.name: istio-system
17
+ {{- end }}
18
+ {{- if .Values.networkSecurity.allowNamespaceInternal }}
19
+ - from:
20
+ - podSelector: {}
21
+ {{- end }}
22
+ {{- range $netRule := .Values.networkSecurity.ingress }}
23
+ - from:
24
+ -
25
+ {{- if $netRule.namespace }}
26
+ namespaceSelector:
27
+ matchLabels:
28
+ kubernetes.io/metadata.name: {{ tpl $netRule.namespace $ }}
29
+ {{- end }}
30
+ {{- if $netRule.podLabelsSelector }}
31
+ podSelector:
32
+ matchLabels: {{ tpl ($netRule.podLabelsSelector | toYaml) $ | nindent 10 }}
33
+ {{- else }}
34
+ podSelector: {}
35
+ {{- end }}
36
+ {{- end }}
17
37
  policyTypes:
18
38
  - Ingress
39
+ podSelector:
40
+ matchLabels: {{- include "web-application.selectorLabels" . | nindent 6 }}
41
+ {{- end }}
@@ -1,4 +1,3 @@
1
- {{- if (include "web-application.ha" .) }}
2
1
  apiVersion: policy/v1
3
2
  kind: PodDisruptionBudget
4
3
  metadata:
@@ -8,4 +7,3 @@ spec:
8
7
  maxUnavailable: {{ .Values.availability.podDisruptionBudget.maxUnavailable }}
9
8
  selector:
10
9
  matchLabels: {{- include "web-application.selectorLabels" . | nindent 6 }}
11
- {{- end }}
@@ -1,4 +1,4 @@
1
- {{ if or .Values.imagePullSecret.dockerconfigjson .Values.global.imagePullSecret.dockerconfigjson }}
1
+ {{- if or .Values.imagePullSecret.dockerconfigjson .Values.global.imagePullSecret.dockerconfigjson -}}
2
2
  apiVersion: v1
3
3
  kind: Secret
4
4
  type: kubernetes.io/dockerconfigjson
@@ -7,4 +7,4 @@ metadata:
7
7
  labels: {{- include "web-application.labels" . | nindent 4 }}
8
8
  data:
9
9
  .dockerconfigjson: {{ default .Values.global.imagePullSecret.dockerconfigjson .Values.imagePullSecret.dockerconfigjson }}
10
- {{- end -}}
10
+ {{- end }}
@@ -1,6 +1,6 @@
1
- {{if not .Values.serviceAccountName}}
1
+ {{- if not .Values.serviceAccountName -}}
2
2
  apiVersion: v1
3
3
  kind: ServiceAccount
4
4
  metadata:
5
5
  name: {{ include "web-application.fullname" . }}
6
- {{end}}
6
+ {{- end }}
@@ -1,5 +1,8 @@
1
- {{- range $name, $params := .Values.bindings }}
2
- {{- if not $params.fromSecret }}
1
+ {{- $bindings := omit .Values.bindings "defaultProperties" -}}
2
+ {{- range $name, $params := $bindings }}
3
+ {{- $defaultProperties := deepCopy $.Values.bindings.defaultProperties -}}
4
+ {{- $mergedParams := (deepCopy $params | mergeOverwrite $defaultProperties ) -}}
5
+ {{- if not $mergedParams.fromSecret }}
3
6
  ---
4
7
  apiVersion: services.cloud.sap.com/v1
5
8
  kind: ServiceBinding
@@ -7,22 +10,22 @@ metadata:
7
10
  name: {{ include "web-application.bindingName" (dict "root" $ "name" $name) }}
8
11
  labels: {{- include "web-application.labels" $ | nindent 4 }}
9
12
  spec:
10
- serviceInstanceName: {{include "web-application.serviceInstanceName" (dict "binding" $params "root" $) }}
13
+ serviceInstanceName: {{include "web-application.serviceInstanceName" (dict "binding" $mergedParams "root" $) }}
11
14
  secretKey: credentials
12
- {{- if $params.externalName }}
13
- externalName: {{ $params.externalName }}
15
+ {{- if $mergedParams.externalName }}
16
+ externalName: {{ $mergedParams.externalName }}
14
17
  {{- end }}
15
- {{- if $params.secretName }}
16
- secretName: {{ tpl $params.secretName $ }}
18
+ {{- if $mergedParams.secretName }}
19
+ secretName: {{ tpl $mergedParams.secretName $ }}
17
20
  {{- end }}
18
- {{- if $params.parameters }}
19
- parameters: {{ $params.parameters | toYaml | nindent 4 }}
21
+ {{- if $mergedParams.parameters }}
22
+ parameters: {{ $mergedParams.parameters | toYaml | nindent 4 }}
20
23
  {{- end }}
21
- {{- if $params.parametersFrom }}
22
- parametersFrom: {{ tpl ($params.parametersFrom | toYaml) $ | nindent 4 }}
24
+ {{- if $mergedParams.parametersFrom }}
25
+ parametersFrom: {{ tpl ($mergedParams.parametersFrom | toYaml) $ | nindent 4 }}
23
26
  {{- end }}
24
- {{- if $params.credentialsRotationPolicy }}
25
- credentialsRotationPolicy: {{ $params.credentialsRotationPolicy | toYaml | nindent 4 }}
27
+ {{- if $mergedParams.credentialsRotationPolicy }}
28
+ credentialsRotationPolicy: {{ $mergedParams.credentialsRotationPolicy | toYaml | nindent 4 }}
26
29
  {{- end }}
27
30
  {{- end }}
28
31
  {{- end }}
@@ -20,17 +20,24 @@ env:
20
20
  name: my-configmap-{{ .Release.Name }}
21
21
  key: my-key
22
22
  envFrom:
23
- - configMapRef:
24
- name: my-configmap1-{{ .Release.Name }}
25
- - secretRef:
23
+ - configMapRef:
24
+ name: my-configmap1-{{ .Release.Name }}
25
+ - secretRef:
26
26
  name: my-secret-ref1-{{ .Release.Name }}
27
27
  additionalVolumes:
28
- - name: my-volume
29
- secret:
30
- secretName: my-secret-{{ .Release.Name }}
31
- volumeMount:
32
- mountPath: /etc/mysecret
33
- readOnly: true
28
+ - name: my-volume
29
+ secret:
30
+ secretName: my-secret-{{ .Release.Name }}
31
+ volumeMount:
32
+ mountPath: /etc/mysecret
33
+ readOnly: true
34
+ expose:
35
+ host: "{{ .Release.Name }}-app"
36
+ networkSecurity:
37
+ ingress:
38
+ - namespace: "{{ .Release.Namespace }}"
39
+ podLabelsSelector:
40
+ app: "{{ .Release.Name }}-my-app"
34
41
  bindings:
35
42
  hana:
36
43
  serviceInstanceName: hana-{{ .Release.Name }}