@sap/cds-dk 6.4.1 → 6.5.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 (93) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/bin/bind.js +30 -34
  3. package/bin/cds.js +14 -3
  4. package/bin/deploy/index.js +6 -5
  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 +5 -2
  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 +56 -308
  89. package/package.json +1 -4
  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
@@ -0,0 +1,207 @@
1
+ {{/*
2
+ Expand the name of the chart.
3
+ */}}
4
+ {{- define "content-deployment.name" -}}
5
+ {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6
+ {{- end }}
7
+
8
+ {{/*
9
+ Create a default fully qualified app name.
10
+ We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11
+ If release name contains chart name it will be used as a full name.
12
+ */}}
13
+ {{- define "content-deployment.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 }}
24
+ {{- end }}
25
+
26
+ {{/*
27
+ Define a name for the Job object
28
+ */}}
29
+ {{- define "content-deployment.jobName" -}}
30
+ {{- printf "%s-%04d" ((include "content-deployment.fullname" . ) | trunc 59) (mod .Release.Revision 1000) }}
31
+ {{- end }}
32
+
33
+ {{/*
34
+ Define a name for a ServiceBinding object
35
+ */}}
36
+ {{- define "content-deployment.bindingName" -}}
37
+ {{- printf "%s-%s" (include "content-deployment.fullname" .root ) .name }}
38
+ {{- end }}
39
+
40
+ {{/*
41
+ Create chart name and version as used by the chart label.
42
+ */}}
43
+ {{- define "content-deployment.chart" -}}
44
+ {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
45
+ {{- end }}
46
+
47
+ {{/*
48
+ Common labels
49
+ */}}
50
+ {{- define "content-deployment.labels" -}}
51
+ helm.sh/revision: {{ .Release.Revision | quote }}
52
+ helm.sh/chart: {{ include "content-deployment.chart" . }}
53
+ {{ include "content-deployment.selectorLabels" . }}
54
+ {{- if .Chart.AppVersion }}
55
+ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
56
+ {{- end }}
57
+ {{- end }}
58
+
59
+ {{/*
60
+ Selector labels
61
+ */}}
62
+ {{- define "content-deployment.selectorLabels" -}}
63
+ app.kubernetes.io/managed-by: {{ .Release.Service }}
64
+ app.kubernetes.io/name: {{ include "content-deployment.name" . }}
65
+ app.kubernetes.io/instance: {{ .Release.Name }}
66
+ {{- if .Values.global}}
67
+ {{- if .Values.global.component }}
68
+ app.kubernetes.io/component:{{ .Values.global.component }}
69
+ {{- end }}
70
+ {{- if .Values.global.partOf }}
71
+ app.kubernetes.io/partOf: {{ .Values.global.partOf }}
72
+ {{- end }}
73
+ {{- end }}
74
+ {{- end }}
75
+
76
+ {{/*
77
+ Service Binding secret mounts
78
+ */}}
79
+ {{- define "content-deployment.serviceMounts" -}}
80
+ {{- range $name, $params := .Values.bindings }}
81
+ - mountPath: /bindings/{{ $name }}/
82
+ name: {{ $name }}-binding
83
+ readOnly: true
84
+ {{- end }}
85
+ {{- end }}
86
+
87
+ {{/*
88
+ Service Binding secret volumes
89
+ */}}
90
+ {{- define "content-deployment.serviceVolumes" -}}
91
+ {{- range $name, $params := .Values.bindings }}
92
+ {{- $secretName := (include "content-deployment.bindingName" (dict "root" $ "name" $name)) }}
93
+ {{- if $params.fromSecret }}
94
+ {{- $secretName = $params.fromSecret}}
95
+ {{- else if $params.secretName }}
96
+ {{- $secretName = $params.secretName }}
97
+ {{- end }}
98
+ - name: {{ $name }}-binding
99
+ secret:
100
+ secretName: {{ $secretName }}
101
+ {{- end }}
102
+ {{- end }}
103
+
104
+ {{/*
105
+ Name of the imagePullSecret
106
+ */}}
107
+ {{- define "content-deployment.imagePullSecretName" -}}
108
+ {{ $ips := (dict "local" .Values.imagePullSecret "global" .Values.global.imagePullSecret) }}
109
+ {{- if $ips.local.name }}
110
+ {{- $ips.local.name }}
111
+ {{- else if $ips.global.name }}
112
+ {{- $ips.global.name }}
113
+ {{- else if or $ips.local.dockerconfigjson $ips.global.dockerconfigjson }}
114
+ {{- include "content-deployment.fullname" . }}
115
+ {{- end }}
116
+ {{- end }}
117
+
118
+ {{/*
119
+ Calculate the final image name
120
+ */}}
121
+ {{- define "content-deployment.imageName" -}}
122
+ {{- $tag := .Values.image.tag | default .Values.global.image.tag | default "latest" }}
123
+ {{- $registry := .Values.image.registry | default .Values.global.image.registry }}
124
+ {{- if $registry }}
125
+ {{- $registry | trimSuffix "/" }}/{{ .Values.image.repository }}:{{ $tag }}
126
+ {{- else }}
127
+ {{- .Values.image.repository }}:{{ $tag }}
128
+ {{- end }}
129
+ {{- end }}
130
+
131
+ {{/*
132
+ Create the name of a service instance.
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.
135
+ */}}
136
+ {{- define "content-deployment.serviceInstanceName" -}}
137
+ {{- if .binding.serviceInstanceFullname }}
138
+ {{- if gt (len .binding.serviceInstanceFullname) 63 }}
139
+ {{- fail (printf "name exceeds 63 characters: '%s'" .binding.serviceInstanceFullname) }}
140
+ {{- end }}
141
+ {{- .binding.serviceInstanceFullname }}
142
+ {{- else }}
143
+ {{- $name := .binding.serviceInstanceName }}
144
+ {{- if not (hasPrefix .release $name)}}
145
+ {{- $name = printf "%s-%s" .release $name }}
146
+ {{- end }}
147
+ {{- if gt (len $name) 63 }}
148
+ {{- fail (printf "name exceeds 63 characters: '%s'" $name) }}
149
+ {{- end }}
150
+ {{- $name }}
151
+ {{- end }}
152
+ {{- end }}
153
+
154
+ {{- define "content-deployment.processEnv" -}}
155
+ {{- $result := dict }}
156
+ {{- $variables := list }}
157
+ {{- range $k, $v := . }}
158
+ {{- $variable := dict }}
159
+ {{- if (kindIs "string" $k) }}
160
+ {{- $_ := set $variable "name" $k -}}
161
+ {{- if (kindIs "map" $v)}}
162
+ {{- $_ := set $variable "valueFrom" $v}}
163
+ {{- else }}
164
+ {{- $_ := set $variable "value" ($v | toString) }}
165
+ {{- end }}
166
+ {{- else }}
167
+ {{- $_ := set $variable "name" $v.name }}
168
+ {{- if $v.value }}
169
+ {{- $_ := set $variable "value" ($v.value | toString)}}
170
+ {{- else }}
171
+ {{- $_ := set $variable "valueFrom" (omit $v "name")}}
172
+ {{- end }}
173
+ {{- end }}
174
+ {{- $variables = append $variables $variable}}
175
+ {{- end }}
176
+ {{- $_ := set $result "vars" $variables }}
177
+ {{- $result | mustToJson }}
178
+ {{- end }}
179
+
180
+ {{- define "web-application.processEnvFrom" -}}
181
+ {{- $ := . -}}
182
+ {{- $result := dict }}
183
+ {{- $variables := list }}
184
+ {{- range $secretName := .Values.envSecretNames }}
185
+ {{- $variable := dict }}
186
+ {{- $_ := set $variable "name" $secretName -}}
187
+ {{- $variables = append $variables (dict "secretRef" $variable)}}
188
+ {{- end }}
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
+ {{- $variables = append $variables $envFrom }}
204
+ {{- end }}
205
+ {{- $_ := set $result "vars" $variables }}
206
+ {{- $result | mustToJson }}
207
+ {{- end }}
@@ -0,0 +1,66 @@
1
+ ---
2
+ apiVersion: batch/v1
3
+ kind: Job
4
+ metadata:
5
+ labels: {{- include "content-deployment.labels" . | nindent 4 }}
6
+ name: {{ include "content-deployment.jobName" . }}
7
+ spec:
8
+ completions: 1
9
+ manualSelector: false
10
+ parallelism: 1
11
+ ttlSecondsAfterFinished: {{ mul .Values.ttlDaysAfterFinished 24 60 60 }}
12
+ template:
13
+ metadata:
14
+ labels: {{- include "content-deployment.labels" . | nindent 8 }}
15
+ annotations:
16
+ sidecar.istio.io/inject: "false"
17
+ container.apparmor.security.beta.kubernetes.io/{{ include "content-deployment.name" . }}: runtime/default
18
+ spec:
19
+ {{- if (include "content-deployment.imagePullSecretName" .) }}
20
+ imagePullSecrets:
21
+ - name: {{ include "content-deployment.imagePullSecretName" . }}
22
+ {{- end }}
23
+ automountServiceAccountToken: false
24
+ serviceAccountName: {{ include "content-deployment.fullname" . }}
25
+ containers:
26
+ - image: {{ include "content-deployment.imageName" . }}
27
+ name: {{ include "content-deployment.name" . }}
28
+ env:
29
+ - name: EXIT
30
+ value: "1"
31
+ - name: EXIT_PROCESS_AFTER_UPLOAD
32
+ value: "true"
33
+ - name: TMPDIR
34
+ value: /tmp
35
+ - name: SERVICE_BINDING_ROOT
36
+ value: /bindings
37
+ {{- $envVars := (include "content-deployment.processEnv" .Values.env | fromJson) }}
38
+ {{- if not (eq (len $envVars.vars) 0) }}
39
+ {{- $envVars.vars | toYaml | nindent 8}}
40
+ {{- end }}
41
+ envFrom:
42
+ {{- $envFromVars := (include "web-application.processEnvFrom" . | fromJson) }}
43
+ {{- if not (eq (len $envFromVars.vars) 0) }}
44
+ {{- $envFromVars.vars | toYaml | nindent 8}}
45
+ {{- end }}
46
+ resources:
47
+ {{- toYaml .Values.resources | nindent 10 }}
48
+ securityContext:
49
+ allowPrivilegeEscalation: false
50
+ capabilities:
51
+ drop:
52
+ - ALL
53
+ privileged: false
54
+ readOnlyRootFilesystem: false
55
+ volumeMounts:
56
+ - mountPath: /tmp
57
+ name: tmp
58
+ {{- include "content-deployment.serviceMounts" . | nindent 8 }}
59
+ restartPolicy: OnFailure
60
+ securityContext:
61
+ runAsNonRoot: true
62
+ runAsUser: 1000
63
+ volumes:
64
+ - name: tmp
65
+ emptyDir: {}
66
+ {{- include "content-deployment.serviceVolumes" . | nindent 6 }}
@@ -0,0 +1,10 @@
1
+ {{ if or .Values.imagePullSecret.dockerconfigjson .Values.global.imagePullSecret.dockerconfigjson }}
2
+ apiVersion: v1
3
+ kind: Secret
4
+ type: kubernetes.io/dockerconfigjson
5
+ metadata:
6
+ name: {{ include "content-deployment.imagePullSecretName" . }}
7
+ labels: {{- include "content-deployment.labels" . | nindent 4 }}
8
+ data:
9
+ .dockerconfigjson: {{ default .Values.global.imagePullSecret.dockerconfigjson .Values.imagePullSecret.dockerconfigjson }}
10
+ {{- end -}}
@@ -0,0 +1,4 @@
1
+ apiVersion: v1
2
+ kind: ServiceAccount
3
+ metadata:
4
+ name: {{ include "content-deployment.fullname" . }}
@@ -0,0 +1,28 @@
1
+ {{- range $name, $params := .Values.bindings }}
2
+ {{- if not $params.fromSecret }}
3
+ ---
4
+ apiVersion: services.cloud.sap.com/v1
5
+ kind: ServiceBinding
6
+ metadata:
7
+ name: {{ include "content-deployment.bindingName" (dict "root" $ "name" $name) }}
8
+ labels: {{- include "content-deployment.labels" $ | nindent 4 }}
9
+ spec:
10
+ serviceInstanceName: {{include "content-deployment.serviceInstanceName" (dict "binding" $params "release" $.Release.Name) }}
11
+ secretKey: credentials
12
+ {{- if $params.externalName }}
13
+ externalName: {{ $params.externalName }}
14
+ {{- end }}
15
+ {{- if $params.secretName }}
16
+ secretName: {{ $params.secretName }}
17
+ {{- end }}
18
+ {{- if $params.parameters }}
19
+ parameters: {{ $params.parameters | toYaml | nindent 4 }}
20
+ {{- end }}
21
+ {{- if $params.parametersFrom }}
22
+ parametersFrom: {{ $params.parametersFrom | toYaml | nindent 4 }}
23
+ {{- end }}
24
+ {{- if $params.credentialsRotationPolicy }}
25
+ credentialsRotationPolicy: {{ $params.credentialsRotationPolicy | toYaml | nindent 4 }}
26
+ {{- end }}
27
+ {{- end }}
28
+ {{- end }}
@@ -0,0 +1,5 @@
1
+ image:
2
+ repository: default
3
+ bindings:
4
+ hana:
5
+ serviceInstanceName: my-hana