From 4b904ea172f77cada7af6f7fb5a28b8e25fea7d0 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Thu, 29 Feb 2024 11:30:55 -0500 Subject: [PATCH] handle object or KeyValue[] labels/annnotations --- src/app/Topology/Entity/utils.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/Topology/Entity/utils.tsx b/src/app/Topology/Entity/utils.tsx index 9e25102a1e..657f459f5e 100644 --- a/src/app/Topology/Entity/utils.tsx +++ b/src/app/Topology/Entity/utils.tsx @@ -53,8 +53,15 @@ import { import { ActiveRecDetail, Nothing } from './ResourceDetails'; import { DescriptionConfig, TargetOwnedResourceType, TargetRelatedResourceType, ResourceTypes, PatchFn } from './types'; -export const keyValueEntryTransformer = (kv: { key: string; value: string }[]): string[] => - kv.map((k) => `${k.key}=${k.value}`); +export const keyValueEntryTransformer = (kv: { key: string; value: string }[]): string[] => { + if (Array.isArray(kv)) { + return kv.map((k) => `${k.key}=${k.value}`); + } else if (!!kv && typeof kv === 'object') { + return Object.entries(kv).map(([k, v]) => `${k}=${v}`); + } else { + throw new Error(`Unknown kv of type "${typeof kv}": ${JSON.stringify(kv)}`); + } +}; export const valuesEntryTransformer: (kv: string[] | object) => string[] = Object.values;