@@ -64,7 +64,7 @@ func init() {
6464 },
6565 },
6666 "uptime" : 43.21 ,
67- "conditions " : Array {
67+ "condition_values " : Array {
6868 Obj {
6969 "name" : "a" ,
7070 "value" : 45 ,
@@ -74,6 +74,16 @@ func init() {
7474 "value" : 66 ,
7575 },
7676 },
77+ "conditions" : Array {
78+ Obj {
79+ "type" : "Ready" ,
80+ "status" : "True" ,
81+ },
82+ Obj {
83+ "type" : "Provisioned" ,
84+ "status" : "False" ,
85+ },
86+ },
7787 },
7888 "metadata" : Obj {
7989 "name" : "foo" ,
@@ -175,7 +185,7 @@ func Test_values(t *testing.T) {
175185 }},
176186 {name : "array" , each : & compiledGauge {
177187 compiledCommon : compiledCommon {
178- path : mustCompilePath (t , "status" , "conditions " ),
188+ path : mustCompilePath (t , "status" , "condition_values " ),
179189 labelFromPath : map [string ]valuePath {
180190 "name" : mustCompilePath (t , "name" ),
181191 },
@@ -233,6 +243,25 @@ func Test_values(t *testing.T) {
233243 newEachValue (t , 0 , "phase" , "bar" ),
234244 newEachValue (t , 1 , "phase" , "foo" ),
235245 }},
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+ }},
236265 }
237266 for _ , tt := range tests {
238267 t .Run (tt .name , func (t * testing.T ) {
@@ -389,7 +418,7 @@ func Test_valuePath_Get(t *testing.T) {
389418 }
390419 tests := []testCase {
391420 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" ),
393422 tt ("array index" , true , "spec" , "order" , "0" , "value" ),
394423 tt ("string" , "bar" , "metadata" , "labels" , "foo" ),
395424 tt ("match number" , false , "spec" , "order" , "[id=3]" , "value" ),
0 commit comments