fix: use apiVersion to disambiguate CRDs with same kind (#504)

When multiple CRDs share the same kind but different API groups
(e.g. Traefik's Middleware under traefik.io and traefik.containo.us),
the dashboard failed to look up the correct resource. Thread apiVersion
through the resource fetch chain and use group-qualified kind
(e.g. Widget.new.example.com) for kubectl lookups.

Closes #504

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Andrei Pohilko
2026-03-17 15:55:48 +00:00
parent 62cf1dfc3e
commit 4fb2eb099a
6 changed files with 61 additions and 8 deletions

View File

@@ -117,13 +117,18 @@ export function useGetResourceDescription(
type: string,
ns: string,
name: string,
apiVersion?: string,
options?: UseQueryOptions<string>
) {
const params = new URLSearchParams({ name, namespace: ns });
if (apiVersion) {
params.set("apiVersion", apiVersion);
}
return useQuery<string>({
queryKey: ["describe", type, ns, name],
queryKey: ["describe", type, ns, name, apiVersion],
queryFn: () =>
apiService.fetchWithDefaults<string>(
`/api/k8s/${type}/describe?name=${name}&namespace=${ns}`,
`/api/k8s/${type}/describe?${params.toString()}`,
{
headers: { "Content-Type": "text/plain; charset=utf-8" },
}

View File

@@ -154,7 +154,8 @@ const DescribeResource = ({
const { data, isLoading } = useGetResourceDescription(
resource.kind,
namespace,
name
name,
resource.apiVersion
);
const yamlFormattedData = useMemo(