@@ -64,7 +64,7 @@ func init() {
64
64
},
65
65
},
66
66
"uptime" : 43.21 ,
67
- "conditions " : Array {
67
+ "condition_values " : Array {
68
68
Obj {
69
69
"name" : "a" ,
70
70
"value" : 45 ,
@@ -74,6 +74,16 @@ func init() {
74
74
"value" : 66 ,
75
75
},
76
76
},
77
+ "conditions" : Array {
78
+ Obj {
79
+ "type" : "Ready" ,
80
+ "status" : "True" ,
81
+ },
82
+ Obj {
83
+ "type" : "Provisioned" ,
84
+ "status" : "False" ,
85
+ },
86
+ },
77
87
},
78
88
"metadata" : Obj {
79
89
"name" : "foo" ,
@@ -175,7 +185,7 @@ func Test_values(t *testing.T) {
175
185
}},
176
186
{name : "array" , each : & compiledGauge {
177
187
compiledCommon : compiledCommon {
178
- path : mustCompilePath (t , "status" , "conditions " ),
188
+ path : mustCompilePath (t , "status" , "condition_values " ),
179
189
labelFromPath : map [string ]valuePath {
180
190
"name" : mustCompilePath (t , "name" ),
181
191
},
@@ -233,6 +243,25 @@ func Test_values(t *testing.T) {
233
243
newEachValue (t , 0 , "phase" , "bar" ),
234
244
newEachValue (t , 1 , "phase" , "foo" ),
235
245
}},
246
+ {name : "status_conditions" , each : & compiledGauge {
247
+ compiledCommon : compiledCommon {
248
+ path : mustCompilePath (t , "status" , "conditions" , "[type=Ready]" , "status" ),
249
+ },
250
+ }, wantResult : []eachValue {
251
+ newEachValue (t , 1 ),
252
+ }},
253
+ {name : "status_conditions_all" , each : & compiledGauge {
254
+ compiledCommon : compiledCommon {
255
+ path : mustCompilePath (t , "status" , "conditions" ),
256
+ labelFromPath : map [string ]valuePath {
257
+ "type" : mustCompilePath (t , "type" ),
258
+ },
259
+ },
260
+ ValueFrom : mustCompilePath (t , "status" ),
261
+ }, wantResult : []eachValue {
262
+ newEachValue (t , 0 , "type" , "Provisioned" ),
263
+ newEachValue (t , 1 , "type" , "Ready" ),
264
+ }},
236
265
}
237
266
for _ , tt := range tests {
238
267
t .Run (tt .name , func (t * testing.T ) {
@@ -389,7 +418,7 @@ func Test_valuePath_Get(t *testing.T) {
389
418
}
390
419
tests := []testCase {
391
420
tt ("obj" , float64 (1 ), "spec" , "replicas" ),
392
- tt ("array" , float64 (66 ), "status" , "conditions " , "[name=b]" , "value" ),
421
+ tt ("array" , float64 (66 ), "status" , "condition_values " , "[name=b]" , "value" ),
393
422
tt ("array index" , true , "spec" , "order" , "0" , "value" ),
394
423
tt ("string" , "bar" , "metadata" , "labels" , "foo" ),
395
424
tt ("match number" , false , "spec" , "order" , "[id=3]" , "value" ),
0 commit comments