Skip to content

Commit 6022db1

Browse files
committed
fix: access undefined spec.template when using workloadRef
1 parent 886a3a5 commit 6022db1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ui/src/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const parseInfoFromResourceNode = (
2222
const steps = spec.strategy?.canary?.steps || [];
2323
ro.steps = steps;
2424

25-
if (status.currentStepIndex && steps.length > 0) {
25+
if (steps && status.currentStepIndex && steps.length > 0) {
2626
ro.step = `${status.currentStepIndex}/${steps.length}`;
2727
}
2828

@@ -49,8 +49,10 @@ const parseInfoFromResourceNode = (
4949
}
5050

5151
ro.containers = [];
52-
for (const c of spec.template?.spec?.containers) {
53-
ro.containers.push({ name: c.name, image: c.image });
52+
if (spec.template) {
53+
for (const c of spec.template?.spec?.containers) {
54+
ro.containers.push({ name: c.name, image: c.image });
55+
}
5456
}
5557

5658
ro.current = status.replicas;
@@ -64,8 +66,8 @@ const parseCurrentCanaryStep = (
6466
): { currentStep: any; currentStepIndex: number } => {
6567
const { status, spec } = resource;
6668
const canary = spec.strategy?.canary;
67-
if (!canary || canary.steps.length === 0) {
68-
return null;
69+
if (!canary || !canary.steps || canary.steps.length === 0) {
70+
return { currentStep: null, currentStepIndex: -1 };
6971
}
7072
let currentStepIndex = 0;
7173
if (status.currentStepIndex) {

0 commit comments

Comments
 (0)