This snippet shows how to find Argo workflow references in the current directory.
Usage:
refs workflow-name template-name
Links:
# Find template references in the given file | |
function find-refs-in-file() { | |
local file="$1" | |
local workflow="$2" | |
local template="$3" | |
local query=".. | select(type==\"object\") | .templateRef | select(.name==\"$workflow\") | select(.template==\"$template\")" | |
if ! cat "$file" | yq "$query"; then | |
echo "ERROR: $1" 1>&2; | |
fi | |
} | |
# Select workflow templates files, potentially | |
# containing references to the given workflow template | |
function sel() { | |
grep -lP "name:\s+([\"']?)$1" -R . | grep -v node_modules | grep yaml | |
} | |
# Find references to the given template in the current directory | |
function refs() { | |
local workflow="$1" | |
local template="$2" | |
local pattern="template:\s+['\"]?$template" | |
for file in $(sel "$workflow"); do | |
if [ ! -z "$(find-refs-in-file "$file" "$workflow" "$template")" ]; then | |
echo $file:$(grep -nP "$pattern" $file) | grep -P "$pattern"; | |
fi; | |
done | |
} |
This snippet shows how to find Argo workflow references in the current directory.
Usage:
refs workflow-name template-name
Links: