Skip to content

Commit

Permalink
Removed Load Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Aneesh-M-Bhat authored and savitaashture committed Sep 10, 2024
1 parent 9042ed2 commit 6895a7b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 38 deletions.
22 changes: 3 additions & 19 deletions templates/common-steps.tpl
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
{{- define "common_steps" -}}
{{- $workspace := index . 1 -}}
{{- with index . 0 -}}
- name: prepare
- name: prepare-and-run
image: {{ .Values.images.gitInit }}
{{- if eq $workspace "source" }}
workingDir: $(workspaces.source.path)
{{- end }}
{{- if eq $workspace "output" }}
workingDir: $(workspaces.output.path)
{{- end }}
command:
- /scripts/prepare.sh
volumeMounts:
- name: scripts-dir
mountPath: /scripts
- name: user-home
mountPath: "$(params.USER_HOME)"

- name: git-run
image: {{ .Values.images.gitInit }}
{{- if eq $workspace "source" }}
workingDir: $(workspaces.source.path)
{{- end }}
{{- if eq $workspace "output" }}
workingDir: $(workspaces.output.path)
{{- end }}
command:
- /scripts/git-run.sh
script: |
{{- include "load_scripts" ( list . ( list "" ) ( list "/scripts/prepare.sh" "/scripts/git-run.sh" ) ) | nindent 4 }}
volumeMounts:
- name: scripts-dir
mountPath: /scripts
Expand Down
34 changes: 16 additions & 18 deletions templates/load-scripts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@
*/ -}}

{{- define "load_scripts" -}}
{{- $global := index . 0 -}}
- name: load-scripts
image: {{ $global.Values.images.gitInit }}
workingDir: /scripts
script: |
set -e
{{- range $i, $prefix := . -}}
{{- if gt $i 0 }}
{{- range $path, $content := $global.Files.Glob "scripts/*.sh" }}
{{- $name := trimPrefix "scripts/" $path }}
{{- if or ( hasPrefix $prefix $name ) ( hasPrefix "common" $name ) }}
printf '%s' "{{ $content | toString | b64enc }}" |base64 -d >{{ $name }}
{{- end }}
{{- end }}
chmod +x {{ $prefix }}*.sh
{{- $global := index . 0 -}}
set -e
{{- range $i, $prefix := index . 1 -}}
{{- range $path, $content := $global.Files.Glob "scripts/*.sh" }}
{{- $name := trimPrefix "scripts/" $path }}
echo "/scripts/{{ $name }}"
{{- if or ( hasPrefix $prefix $name ) ( hasPrefix "common" $name ) }}
printf '%s' "{{ $content | toString | b64enc }}" |base64 -d >"/scripts/{{ $name }}"
{{- end }}
{{- end }}
volumeMounts:
- name: scripts-dir
mountPath: /scripts
ls /scripts/{{ $prefix }}*.sh;
chmod +x /scripts/{{ $prefix }}*.sh;
{{- end }}

{{- range $i, $script := index . 2 -}}
echo "Running Script {{ $script }}";
{{ $script }};
{{- end }}
{{- end -}}
1 change: 0 additions & 1 deletion templates/spec-git.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ stepTemplate:
{{- end }}

steps:
{{- include "load_scripts" ( list . "" ) | nindent 2 }}
{{- include "common_steps" ( list . $workspace ) | nindent 2 }}
{{- if ne $steps "" }}
{{- include $steps . | nindent 2}}
Expand Down

0 comments on commit 6895a7b

Please sign in to comment.