From a6fbf984cb8b174803698172a8fba43f2345af35 Mon Sep 17 00:00:00 2001 From: Alexandre Veyrenc Date: Wed, 17 Sep 2025 01:49:52 +0200 Subject: [PATCH] Make "flux trace" more generic (#3543) --- plugins/flux.yaml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/flux.yaml b/plugins/flux.yaml index 87e9c904..78ad5ab8 100644 --- a/plugins/flux.yaml +++ b/plugins/flux.yaml @@ -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