Skip to content

Commit b3f8faf

Browse files
committed
feat: change ready condition equality check logic
1 parent 77694f2 commit b3f8faf

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

docs/readme-generic-ui.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ In order to use the generic list view, you need to adjust the node’s `conten
2626

2727
- in the `"resourceDefinition"` the given fields need to be specified: `group, plural, singular, kind, scope, namespace` describing properties of the resource.
2828
- Also `"resourceDefinition"` have optional field `readyCondition` that describing when resource treated as ready
29-
It's an object that contain two fields. `jsonPathExpression` that contain JSONPath expression for complex data access and `property` JSON path to the resource property that contain info about resource ready state
29+
It's an object that contain two fields. `jsonPathExpression` that contain JSONPath expression for complex data access and ready status matching and `property` JSON path to the resource property that contain info about resource ready state
3030
```json
3131
"readyCondition": {
32-
"jsonPathExpression": "status.conditions[?(@.type=='Ready')].status",
32+
"jsonPathExpression": "status.conditions[?(@.type=='Ready' && @.status=='True')]",
3333
"property": ["status.conditions.status", "status.conditions.type"],
3434
},
3535
```
@@ -103,7 +103,7 @@ Below is an example content-configuration for an accounts node using the generic
103103
"scope": "Cluster",
104104
"namespace": null,
105105
"readyCondition": {
106-
"jsonPathExpression": "status.conditions[?(@.type=='Ready')].status",
106+
"jsonPathExpression": "status.conditions[?(@.type=='Ready' && @.status=='True')]",
107107
"property": ["status.conditions.status", "status.conditions.type"],
108108
},
109109
"ui": {

projects/wc/src/app/components/generic-ui/list-view/list-view.component.spec.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@ describe('ListViewComponent', () => {
349349
plural: 'clusters',
350350
kind: 'Cluster',
351351
group: 'core.k8s.io',
352+
readyCondition: {
353+
jsonPathExpression:
354+
'status.conditions[?(@.type=="Ready" && @.status=="True")]',
355+
property: ['status.conditions.status', 'status.conditions.type'],
356+
},
352357
ui: {
353358
listView: {
354359
fields: [],
@@ -393,7 +398,8 @@ describe('ListViewComponent', () => {
393398
kind: 'Cluster',
394399
group: 'core.k8s.io',
395400
readyCondition: {
396-
jsonPathExpression: 'status.conditions[?(@.type=="Ready")].status',
401+
jsonPathExpression:
402+
'status.conditions[?(@.type=="Ready" && @.status=="True")]',
397403
property: ['status.conditions.status', 'status.conditions.type'],
398404
},
399405
ui: {
@@ -484,7 +490,8 @@ describe('ListViewComponent', () => {
484490
kind: 'Cluster',
485491
group: 'core.k8s.io',
486492
readyCondition: {
487-
jsonPathExpression: 'status.conditions[?(@.type=="Ready")].status',
493+
jsonPathExpression:
494+
'status.conditions[?(@.type=="Ready" && @.status=="True")]',
488495
property: ['status.conditions.status', 'status.conditions.type'],
489496
},
490497
ui: {
@@ -533,7 +540,8 @@ describe('ListViewComponent', () => {
533540
kind: 'Cluster',
534541
group: 'core.k8s.io',
535542
readyCondition: {
536-
jsonPathExpression: 'status.conditions[?(@.type=="Ready")].status',
543+
jsonPathExpression:
544+
'status.conditions[?(@.type=="Ready" && @.status=="True")]',
537545
property: ['status.conditions.status', 'status.conditions.type'],
538546
},
539547
ui: {
@@ -595,7 +603,8 @@ describe('ListViewComponent', () => {
595603
kind: 'Cluster',
596604
group: 'core.k8s.io',
597605
readyCondition: {
598-
jsonPathExpression: 'status.conditions[?(@.type=="Ready")].status',
606+
jsonPathExpression:
607+
'status.conditions[?(@.type=="Ready" && @.status=="True")]',
599608
property: ['status.conditions.status', 'status.conditions.type'],
600609
},
601610
ui: {
@@ -801,5 +810,5 @@ describe('ListViewComponent', () => {
801810
type: 'error',
802811
});
803812
});
804-
})
813+
});
805814
});

projects/wc/src/app/components/generic-ui/list-view/list-view.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ export class ListViewComponent implements OnInit {
244244
}
245245

246246
const readyStatus = getResourceValueByJsonPath(resource, readyCondition);
247-
return readyStatus === 'True';
247+
console.log('readyStatus', readyStatus);
248+
return !!readyStatus;
248249
}
249250

250251
private getResourceDefinition() {

0 commit comments

Comments
 (0)