Skip to content

Commit 7662ace

Browse files
committed
fix(chart): extra scripts can be imported in sub-chart by default
Fixed #2141 When it is imported as a sub-chart in another chart, files could not load Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 80856d3 commit 7662ace

File tree

4 files changed

+49
-32
lines changed

4 files changed

+49
-32
lines changed

charts/selenium-grid/templates/node-configmap.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ data:
2424
SE_DRAIN_AFTER_SESSION_COUNT: '{{- and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") | ternary "1" "0" -}}'
2525
SE_NODE_GRID_URL: '{{ include "seleniumGrid.url" .}}'
2626
SE_NODE_GRID_GRAPHQL_URL: '{{ include "seleniumGrid.graphqlURL" . }}'
27-
{{- range $fileName, $value := .Values.nodeConfigMap.extraScripts }}
28-
{{- if not (empty $value) }}
29-
{{ $fileName | indent 2 -}}: |
30-
{{ $value | indent 4 }}
31-
{{- else }}
32-
{{- $files := $.Files.Glob (printf "configs/node/%s" $fileName) }}
33-
{{- $cfg := $files.AsConfig }}
34-
{{- if and (gt (len $files) 0) (ne $cfg "") }}
35-
{{ indent 2 $cfg }}
36-
{{- end }}
27+
{{- $fileProceeded := list -}}
28+
{{- range $path, $_ := .Files.Glob $.Values.nodeConfigMap.extraScriptsImportFrom }}
29+
{{- $fileName := base $path -}}
30+
{{- $value := index $.Values.nodeConfigMap.extraScripts $fileName -}}
31+
{{- if empty $value }}
32+
{{- $fileName | nindent 2 -}}: {{- toYaml ($.Files.Get $path) | indent 4 }}
33+
{{- else }}
34+
{{- $fileName | nindent 2 -}}: {{- toYaml $value | indent 4 }}
35+
{{- end }}
36+
{{- $fileProceeded = append $fileProceeded $fileName -}}
3737
{{- end }}
38+
{{- range $fileName, $value := .Values.nodeConfigMap.extraScripts }}
39+
{{- if not (has $fileName $fileProceeded) }}
40+
{{- $fileName | nindent 2 -}}: {{- toYaml (default "" $value) | indent 4 }}
41+
{{- end }}
3842
{{- end }}

charts/selenium-grid/templates/recorder-configmap.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,20 @@ data:
2020
{{- end }}
2121
VIDEO_CONFIG_DIRECTORY: '{{ .Values.recorderConfigMap.extraScriptsDirectory }}'
2222
SE_UPLOAD_DESTINATION_PREFIX: '{{ .Values.videoRecorder.uploader.destinationPrefix }}'
23-
{{- range $fileName, $value := .Values.recorderConfigMap.extraScripts }}
24-
{{- if not (empty $value) }}
25-
{{ $fileName | indent 2 -}}: |
26-
{{ $value | indent 4 }}
27-
{{- else }}
28-
{{- $files := $.Files.Glob (printf "configs/recorder/%s" $fileName) }}
29-
{{- $cfg := $files.AsConfig }}
30-
{{- if and (gt (len $files) 0) (ne $cfg "") }}
31-
{{ indent 2 $cfg }}
32-
{{- end }}
23+
{{- $fileProceeded := list -}}
24+
{{- range $path, $_ := .Files.Glob $.Values.recorderConfigMap.extraScriptsImportFrom }}
25+
{{- $fileName := base $path -}}
26+
{{- $value := index $.Values.recorderConfigMap.extraScripts $fileName -}}
27+
{{- if empty $value }}
28+
{{- $fileName | nindent 2 -}}: {{- toYaml ($.Files.Get $path) | indent 4 }}
29+
{{- else }}
30+
{{- $fileName | nindent 2 -}}: {{- toYaml $value | indent 4 }}
31+
{{- end }}
32+
{{- $fileProceeded = append $fileProceeded $fileName -}}
3333
{{- end }}
34+
{{- range $fileName, $value := .Values.recorderConfigMap.extraScripts }}
35+
{{- if not (has $fileName $fileProceeded) }}
36+
{{- $fileName | nindent 2 -}}: {{- toYaml (default "" $value) | indent 4 }}
37+
{{- end }}
3438
{{- end }}
3539
{{- end }}

charts/selenium-grid/templates/uploader-configmap.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ data:
1919
{{- with .Values.videoRecorder.uploader.configFileName }}
2020
UPLOAD_CONFIG_FILE_NAME: '{{ . }}'
2121
{{- end }}
22-
{{- range $fileName, $value := .Values.uploaderConfigMap.extraScripts }}
23-
{{- if not (empty $value) }}
24-
{{ $fileName | indent 2 -}}: |
25-
{{ $value | indent 4 }}
26-
{{- else }}
27-
{{- $files := $.Files.Glob (printf "configs/uploader/%s/%s" $.Values.videoRecorder.uploader.name $fileName) }}
28-
{{- $cfg := $files.AsConfig }}
29-
{{- if and (gt (len $files) 0) (ne $cfg "") }}
30-
{{ indent 2 $cfg }}
31-
{{- end }}
22+
{{- $fileProceeded := list -}}
23+
{{- range $path, $_ := .Files.Glob $.Values.uploaderConfigMap.extraScriptsImportFrom }}
24+
{{- $fileName := base $path -}}
25+
{{- $value := index $.Values.uploaderConfigMap.extraScripts $fileName -}}
26+
{{- if empty $value }}
27+
{{- $fileName | nindent 2 -}}: {{- toYaml ($.Files.Get $path) | indent 4 }}
28+
{{- else }}
29+
{{- $fileName | nindent 2 -}}: {{- toYaml $value | indent 4 }}
30+
{{- end }}
31+
{{- $fileProceeded = append $fileProceeded $fileName -}}
3232
{{- end }}
33+
{{- range $fileName, $value := .Values.uploaderConfigMap.extraScripts }}
34+
{{- if not (has $fileName $fileProceeded) }}
35+
{{- $fileName | nindent 2 -}}: {{- toYaml (default "" $value) | indent 4 }}
36+
{{- end }}
3337
{{- end }}
3438
{{- end }}

charts/selenium-grid/values.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ nodeConfigMap:
104104
# nameOverride:
105105
# Default mode for ConfigMap is mounted as file
106106
defaultMode: 0755
107-
# File name of preStop script in ConfigMap
107+
# Directory where the extra scripts are imported to ConfigMap by default (if given a relative path, it should be in chart's directory)
108+
extraScriptsImportFrom: "configs/node/**"
109+
# Directory where the extra scripts are mounted to
108110
extraScriptsDirectory: "/opt/selenium"
109111
extraScripts:
110112
nodePreStop.sh:
@@ -118,6 +120,8 @@ recorderConfigMap:
118120
# nameOverride:
119121
# Default mode for ConfigMap is mounted as file
120122
defaultMode: 0755
123+
# Directory where the extra scripts are imported to ConfigMap by default (if given a relative path, it should be in chart's directory)
124+
extraScriptsImportFrom: "configs/recorder/**"
121125
# Directory where the extra scripts are mounted to
122126
extraScriptsDirectory: "/opt/bin"
123127
# List of extra scripts to be mounted to the container. Format as `filename: content`
@@ -134,6 +138,8 @@ uploaderConfigMap:
134138
# nameOverride:
135139
# Default mode for ConfigMap is mounted as file
136140
defaultMode: 0755
141+
# Directory where the extra scripts are imported to ConfigMap by default (if given a relative path, it should be in chart's directory)
142+
extraScriptsImportFrom: "configs/uploader/**"
137143
# Directory where the extra scripts are mounted to
138144
extraScriptsDirectory: "/opt/bin"
139145
# List of extra scripts to be mounted to the container. Format as `filename: content`
@@ -149,7 +155,6 @@ uploaderConfigMap:
149155
# Custom annotations for configmap
150156
annotations: {}
151157

152-
153158
# ConfigMap that contains common environment variables for Logging (https://www.selenium.dev/documentation/grid/configuration/cli_options/#logging)
154159
loggingConfigMap:
155160
# nameOverride:

0 commit comments

Comments
 (0)