Skip to content

Instantly share code, notes, and snippets.

@chmouel
Last active May 31, 2019 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chmouel/00500e704784f455c869458c882f86e5 to your computer and use it in GitHub Desktop.
Save chmouel/00500e704784f455c869458c882f86e5 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
choosef() {
type="$1"
[[ -n $2 ]] && label="-ltekton.dev/${2}"
[[ -n $3 ]] && jqb=$3 || jqb='.items[].metadata.name'
kubectl get ${type} ${label} -o json|jq -r $jqb | fzf -1
}
PIPELINE=$(choosef pipeline)
echo "PIPELINE:${PIPELINE} has been chosen"
PIPELINERUN=$(choosef pipelinerun pipeline=${PIPELINE})
echo "PIPELINERUN:${PIPELINERUN} has been chosen"
POD=$(choosef pods pipelineRun=${PIPELINERUN})
echo "POD:${POD} has been chosen"
CONTAINER=$(kubectl get pod/${POD} -o json|jq -r '.spec.containers[].name'|grep -vw nop|fzf -1)
echo "CONTAINER:${CONTAINER} has been chosen"
kubectl logs pod/${POD} -c ${CONTAINER}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment