Make "flux trace" more generic (#3543)

mine
Alexandre Veyrenc 2025-09-17 01:49:52 +02:00 committed by GitHub
parent c08d43d508
commit a6fbf984cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 5 deletions

View File

@ -162,14 +162,20 @@ plugins:
args:
- -c
- >-
resource=$(echo $RESOURCE_NAME | sed -E 's/ies$/y/' | sed -E 's/ses$/se/' | sed -E 's/(s|es)$//g');
if [ -n "$RESOURCE_GROUP" ]; then api_endpoint="/apis/$RESOURCE_GROUP/$RESOURCE_VERSION"; else api_endpoint="/api/$RESOURCE_VERSION"; fi;
api_resource=$(kubectl get --raw "${api_endpoint}" | jq -r ".resources[] | select(.name==\"$RESOURCE_NAME\")");
kind=$(echo ${api_resource} | jq -r '.kind');
namespace_arg=$(echo ${api_resource} | jq -r "if .namespaced == true then \"--namespace $NAMESPACE\" else \"\" end");
[ -n "$RESOURCE_GROUP" ] && api_version=$RESOURCE_GROUP/;
api_version=${api_version}$RESOURCE_VERSION;
flux
trace
--context $CONTEXT
--kind $resource
--api-version $RESOURCE_GROUP/$RESOURCE_VERSION
--namespace $NAMESPACE $NAME
| less -K
--kind ${kind}
--api-version ${api_version}
${namespace_arg}
$NAME
|& less -K
# credits: https://github.com/fluxcd/flux2/discussions/2494
get-suspended-helmreleases:
shortCut: Shift-S