Skip to content

Commit

Permalink
fix(chart): extra scripts can be imported in sub-chart by default
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
VietND96 committed Feb 24, 2024
1 parent 80856d3 commit 7662ace
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 32 deletions.
24 changes: 14 additions & 10 deletions charts/selenium-grid/templates/node-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ data:
SE_DRAIN_AFTER_SESSION_COUNT: '{{- and (eq (include "seleniumGrid.useKEDA" .) "true") (eq .Values.autoscaling.scalingType "job") | ternary "1" "0" -}}'
SE_NODE_GRID_URL: '{{ include "seleniumGrid.url" .}}'
SE_NODE_GRID_GRAPHQL_URL: '{{ include "seleniumGrid.graphqlURL" . }}'
{{- range $fileName, $value := .Values.nodeConfigMap.extraScripts }}
{{- if not (empty $value) }}
{{ $fileName | indent 2 -}}: |
{{ $value | indent 4 }}
{{- else }}
{{- $files := $.Files.Glob (printf "configs/node/%s" $fileName) }}
{{- $cfg := $files.AsConfig }}
{{- if and (gt (len $files) 0) (ne $cfg "") }}
{{ indent 2 $cfg }}
{{- end }}
{{- $fileProceeded := list -}}
{{- range $path, $_ := .Files.Glob $.Values.nodeConfigMap.extraScriptsImportFrom }}
{{- $fileName := base $path -}}
{{- $value := index $.Values.nodeConfigMap.extraScripts $fileName -}}
{{- if empty $value }}
{{- $fileName | nindent 2 -}}: {{- toYaml ($.Files.Get $path) | indent 4 }}
{{- else }}
{{- $fileName | nindent 2 -}}: {{- toYaml $value | indent 4 }}
{{- end }}
{{- $fileProceeded = append $fileProceeded $fileName -}}
{{- end }}
{{- range $fileName, $value := .Values.nodeConfigMap.extraScripts }}
{{- if not (has $fileName $fileProceeded) }}
{{- $fileName | nindent 2 -}}: {{- toYaml (default "" $value) | indent 4 }}
{{- end }}
{{- end }}
24 changes: 14 additions & 10 deletions charts/selenium-grid/templates/recorder-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ data:
{{- end }}
VIDEO_CONFIG_DIRECTORY: '{{ .Values.recorderConfigMap.extraScriptsDirectory }}'
SE_UPLOAD_DESTINATION_PREFIX: '{{ .Values.videoRecorder.uploader.destinationPrefix }}'
{{- range $fileName, $value := .Values.recorderConfigMap.extraScripts }}
{{- if not (empty $value) }}
{{ $fileName | indent 2 -}}: |
{{ $value | indent 4 }}
{{- else }}
{{- $files := $.Files.Glob (printf "configs/recorder/%s" $fileName) }}
{{- $cfg := $files.AsConfig }}
{{- if and (gt (len $files) 0) (ne $cfg "") }}
{{ indent 2 $cfg }}
{{- end }}
{{- $fileProceeded := list -}}
{{- range $path, $_ := .Files.Glob $.Values.recorderConfigMap.extraScriptsImportFrom }}
{{- $fileName := base $path -}}
{{- $value := index $.Values.recorderConfigMap.extraScripts $fileName -}}
{{- if empty $value }}
{{- $fileName | nindent 2 -}}: {{- toYaml ($.Files.Get $path) | indent 4 }}
{{- else }}
{{- $fileName | nindent 2 -}}: {{- toYaml $value | indent 4 }}
{{- end }}
{{- $fileProceeded = append $fileProceeded $fileName -}}
{{- end }}
{{- range $fileName, $value := .Values.recorderConfigMap.extraScripts }}
{{- if not (has $fileName $fileProceeded) }}
{{- $fileName | nindent 2 -}}: {{- toYaml (default "" $value) | indent 4 }}
{{- end }}
{{- end }}
{{- end }}
24 changes: 14 additions & 10 deletions charts/selenium-grid/templates/uploader-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ data:
{{- with .Values.videoRecorder.uploader.configFileName }}
UPLOAD_CONFIG_FILE_NAME: '{{ . }}'
{{- end }}
{{- range $fileName, $value := .Values.uploaderConfigMap.extraScripts }}
{{- if not (empty $value) }}
{{ $fileName | indent 2 -}}: |
{{ $value | indent 4 }}
{{- else }}
{{- $files := $.Files.Glob (printf "configs/uploader/%s/%s" $.Values.videoRecorder.uploader.name $fileName) }}
{{- $cfg := $files.AsConfig }}
{{- if and (gt (len $files) 0) (ne $cfg "") }}
{{ indent 2 $cfg }}
{{- end }}
{{- $fileProceeded := list -}}
{{- range $path, $_ := .Files.Glob $.Values.uploaderConfigMap.extraScriptsImportFrom }}
{{- $fileName := base $path -}}
{{- $value := index $.Values.uploaderConfigMap.extraScripts $fileName -}}
{{- if empty $value }}
{{- $fileName | nindent 2 -}}: {{- toYaml ($.Files.Get $path) | indent 4 }}
{{- else }}
{{- $fileName | nindent 2 -}}: {{- toYaml $value | indent 4 }}
{{- end }}
{{- $fileProceeded = append $fileProceeded $fileName -}}
{{- end }}
{{- range $fileName, $value := .Values.uploaderConfigMap.extraScripts }}
{{- if not (has $fileName $fileProceeded) }}
{{- $fileName | nindent 2 -}}: {{- toYaml (default "" $value) | indent 4 }}
{{- end }}
{{- end }}
{{- end }}
9 changes: 7 additions & 2 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ nodeConfigMap:
# nameOverride:
# Default mode for ConfigMap is mounted as file
defaultMode: 0755
# File name of preStop script in ConfigMap
# Directory where the extra scripts are imported to ConfigMap by default (if given a relative path, it should be in chart's directory)
extraScriptsImportFrom: "configs/node/**"
# Directory where the extra scripts are mounted to
extraScriptsDirectory: "/opt/selenium"
extraScripts:
nodePreStop.sh:
Expand All @@ -118,6 +120,8 @@ recorderConfigMap:
# nameOverride:
# Default mode for ConfigMap is mounted as file
defaultMode: 0755
# Directory where the extra scripts are imported to ConfigMap by default (if given a relative path, it should be in chart's directory)
extraScriptsImportFrom: "configs/recorder/**"
# Directory where the extra scripts are mounted to
extraScriptsDirectory: "/opt/bin"
# List of extra scripts to be mounted to the container. Format as `filename: content`
Expand All @@ -134,6 +138,8 @@ uploaderConfigMap:
# nameOverride:
# Default mode for ConfigMap is mounted as file
defaultMode: 0755
# Directory where the extra scripts are imported to ConfigMap by default (if given a relative path, it should be in chart's directory)
extraScriptsImportFrom: "configs/uploader/**"
# Directory where the extra scripts are mounted to
extraScriptsDirectory: "/opt/bin"
# List of extra scripts to be mounted to the container. Format as `filename: content`
Expand All @@ -149,7 +155,6 @@ uploaderConfigMap:
# Custom annotations for configmap
annotations: {}


# ConfigMap that contains common environment variables for Logging (https://www.selenium.dev/documentation/grid/configuration/cli_options/#logging)
loggingConfigMap:
# nameOverride:
Expand Down

0 comments on commit 7662ace

Please sign in to comment.