Skip to content

Commit

Permalink
doc: add code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eshankvaish committed Jan 16, 2025
1 parent 34e6c57 commit daebf12
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/ClusterNodes/NodeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const NodeDetails = ({ addTab, lowercaseKindToResourceGroupMap, updateTabUrl }:
}, [location.search])

const selectedResource = useMemo((): { gvk: GVKType; namespaced: boolean } => {
// Using - as a prefix since the group is empty for pods
const resourceGroupData = lowercaseKindToResourceGroupMap[`-${Nodes.Pod.toLowerCase()}`]
if (!resourceGroupData) {
return { gvk: { Kind: Nodes.Pod, Group: '', Version: 'v1' }, namespaced: true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ const BaseResourceListContent = ({
const renderResourceRow = (resourceData: K8sResourceDetailDataType): JSX.Element => {
const lowercaseKind = (resourceData.kind as string)?.toLowerCase()
// This should be used only if shouldOverrideSelectedResourceKind is true
// Group and version are not available for Events / shouldOverrideSelectedResourceKind is true
const gvkFromRawData =
getFirstResourceFromKindResourceMap(lowercaseKindToResourceGroupMap, lowercaseKind)?.gvk ?? ({} as GVKType)
// Redirection and actions are not possible for Events since the required data for the same is not available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const ResourceList = () => {
() =>
(k8SObjectMapRaw?.result.apiResources ?? []).reduce<K8SResourceListType['lowercaseKindToResourceGroupMap']>(
(acc, resourceGroup) => {
// Using Group-Kind as key, but we need to move to using map instead
acc[`${resourceGroup.gvk.Group.toLowerCase()}-${resourceGroup.gvk.Kind.toLowerCase()}`] =
resourceGroup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ const NodeDetailComponent = ({
clusterName,
kind: _selectedResource?.gvk.Kind as string,
version: _selectedResource?.gvk.Version,
// Note: Using the group from the url if available
// since kind is mapped to only one group while it doesn't hold true always
group: _selectedResource?.gvk.Group,
namespace: params.namespace,
name: resourceName,
Expand Down Expand Up @@ -650,6 +648,7 @@ const NodeDetailComponent = ({
setContainers={setContainers}
switchSelectedContainer={switchSelectedContainer}
selectedNamespaceByClickingPod={selectedResource?.namespace}
// getContainersFromManifest can only be used from resource browser
handleSuccess={isResourceBrowserView ? getContainersFromManifest : noop}
/>
)}
Expand Down

0 comments on commit daebf12

Please sign in to comment.