Skip to content

Commit 3a15a54

Browse files
committed
feat: add support for init containers in Pod nodes and update iNode interface
1 parent d829671 commit 3a15a54

2 files changed

Lines changed: 25 additions & 10 deletions

File tree

src/Shared/Store/IndexStore.tsx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,33 @@ export function getiNodesByRootNodeWithChildNodes(
116116
})
117117
})
118118

119-
// Add containers to Pod type nodes
119+
// Add init containers and containers to Pod type nodes
120120
children
121121
.filter((_child) => _child.kind.toLowerCase() == Nodes.Pod.toLowerCase())
122122
.map((_pn) => {
123+
const podMeta = (podMetadata || _appDetailsSubject.getValue().resourceTree?.podMetadata)?.filter(
124+
(_pmd) => _pmd.uid === _pn.uid,
125+
)[0]
126+
127+
const initNodes: iNode[] = (podMeta?.initContainers || []).map((_c: string) => {
128+
const initNode = {} as iNode
129+
initNode.kind = Nodes.Containers
130+
initNode.name = _c
131+
initNode.pNode = _pn
132+
initNode.isInitContainer = true
133+
return initNode
134+
})
135+
136+
const containerNodes: iNode[] = (podMeta?.containers || []).map((_c: string) => {
137+
const childNode = {} as iNode
138+
childNode.kind = Nodes.Containers
139+
childNode.name = _c
140+
childNode.pNode = _pn
141+
return childNode
142+
})
143+
123144
// eslint-disable-next-line no-param-reassign
124-
_pn.childNodes = (podMetadata || _appDetailsSubject.getValue().resourceTree?.podMetadata)
125-
?.filter((_pmd) => _pmd.uid === _pn.uid)[0]
126-
?.containers?.map((_c) => {
127-
const childNode = {} as iNode
128-
childNode.kind = Nodes.Containers
129-
childNode.pNode = _pn
130-
childNode.name = _c
131-
return childNode
132-
})
145+
_pn.childNodes = [...initNodes, ...containerNodes]
133146
})
134147
children = children.flatMap((_node) => _node.childNodes ?? [])
135148
}

src/Shared/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ export interface iNode extends Node {
174174
type: NodeType
175175
status: string
176176
pNode?: iNode
177+
/** Marks a node as an init container, used for display purposes in the resource tree. */
178+
isInitContainer?: boolean
177179
}
178180

179181
export interface HelmReleaseStatus {

0 commit comments

Comments
 (0)