Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
wikibase-local-ca.crt
*.bak
.extracted
28 changes: 28 additions & 0 deletions bin/extract-yaml-job-scripts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

if [[ -n "${CI}" ]]; then
set -x
fi

# absolute path of the wbaas-deploy repository
ROOT=$(git rev-parse --show-toplevel)
EXTRACTED_SCRIPTS_DIR="$ROOT/k8s/jobs/.extracted"

rm -Rfv "$ROOT/k8s/jobs/.extracted"/*_extracted.sh
mkdir -p "$EXTRACTED_SCRIPTS_DIR"

for file in "$ROOT"/k8s/jobs/*.yaml; do
BASENAME=$(basename "$file")
TMP_FILE="${EXTRACTED_SCRIPTS_DIR}/${BASENAME}_extracted.sh"
SCRIPT_SHELL=$(cat "$file" | yq '.spec.template.spec.containers[0].command[0]')

if [[ "$SCRIPT_SHELL" == "null" ]]; then
continue
fi

SCRIPT=$(cat "$file" | yq '.spec.template.spec.containers[0].command[2]')
echo "#!/usr/bin/env $SCRIPT_SHELL" >"$TMP_FILE"
echo "$SCRIPT" >>"$TMP_FILE"

echo "extracted $TMP_FILE"
done
Loading