Created
August 12, 2025 10:22
-
-
Save chmouel/e4f0c9df8be6af8f17a27f736723617a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eufo pipefail | |
namespace=gosmee | |
savedir=/tmp/save | |
targetdir=/tmp | |
if ! kubectl get ns ${namespace} >/dev/null 2>/dev/null; then | |
namespace=pipelines-as-code | |
if ! kubectl get ns ${namespace} >/dev/null 2>/dev/null; then | |
namespace=openshift-pipelines | |
if ! kubectl get ns ${namespace} >/dev/null 2>/dev/null; then | |
echo "cannot find a namespace" | |
exit 1 | |
fi | |
fi | |
fi | |
mapfile -t pods <<<$(kubectl get pods -n ${namespace} -l 'app in (gosmee-ghe, gosmee, gosmee-client)' -o go-template='{{range .items}}{{.metadata.name}} {{end}}') | |
if [ ${#pods[@]} -eq 0 ]; then | |
echo "No pod found" | |
exit 1 | |
fi | |
initialquery="" | |
if [[ -n ${1:-} ]]; then | |
initialquery="-q $1" | |
fi | |
pod=$(printf "%s\n" ${pods[*]} | fzf -1 --prompt="Select a pod: " ${initialquery}) | |
name=$(kubectl get pod -n ${namespace} ${pod} -o jsonpath='{.metadata.labels.app}') | |
targetdir=${targetdir}/${name} | |
mkdir -p ${targetdir} | |
oc rsync -q -n ${namespace} ${pod}:${savedir}/ ${targetdir} | |
echo "saved to ${targetdir}" | |
replayview -c -d ${targetdir} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment