9
9
"strings"
10
10
"time"
11
11
12
+ appsv1 "k8s.io/api/apps/v1"
13
+
12
14
"github.com/feast-dev/feast/infra/feast-operator/api/v1alpha1"
13
15
)
14
16
@@ -26,36 +28,17 @@ func checkIfFeatureStoreCustomResourceConditionsInReady(featureStoreName, namesp
26
28
featureStoreName , namespace , err , stderr .String ())
27
29
}
28
30
29
- // Parse the JSON into a generic map
30
- var resource map [ string ] interface {}
31
+ // Parse the JSON into FeatureStore
32
+ var resource v1alpha1. FeatureStore
31
33
if err := json .Unmarshal (out .Bytes (), & resource ); err != nil {
32
34
return fmt .Errorf ("failed to parse the resource JSON. Error: %v" , err )
33
35
}
34
36
35
- // Traverse the JSON structure to extract conditions
36
- status , ok := resource ["status" ].(map [string ]interface {})
37
- if ! ok {
38
- return fmt .Errorf ("status field is missing or invalid in the resource JSON" )
39
- }
40
-
41
- conditions , ok := status ["conditions" ].([]interface {})
42
- if ! ok {
43
- return fmt .Errorf ("conditions field is missing or invalid in the status section" )
44
- }
45
-
46
37
// Validate all conditions
47
- for _ , condition := range conditions {
48
- conditionMap , ok := condition .(map [string ]interface {})
49
- if ! ok {
50
- return fmt .Errorf ("invalid condition format" )
51
- }
52
-
53
- conditionType := conditionMap ["type" ].(string )
54
- conditionStatus := conditionMap ["status" ].(string )
55
-
56
- if conditionStatus != "True" {
38
+ for _ , condition := range resource .Status .Conditions {
39
+ if condition .Status != "True" {
57
40
return fmt .Errorf (" FeatureStore=%s condition '%s' is not in 'Ready' state. Status: %s" ,
58
- featureStoreName , conditionType , conditionStatus )
41
+ featureStoreName , condition . Type , condition . Status )
59
42
}
60
43
}
61
44
@@ -87,30 +70,15 @@ func checkIfDeploymentExistsAndAvailable(namespace string, deploymentName string
87
70
continue
88
71
}
89
72
90
- // Parse the JSON output into a map
91
- var result map [ string ] interface {}
73
+ // Parse the JSON output into Deployment
74
+ var result appsv1. Deployment
92
75
if err := json .Unmarshal (output .Bytes (), & result ); err != nil {
93
76
return fmt .Errorf ("failed to parse deployment JSON: %v" , err )
94
77
}
95
78
96
- // Navigate to status.conditions
97
- status , ok := result ["status" ].(map [string ]interface {})
98
- if ! ok {
99
- return fmt .Errorf ("failed to get status field from deployment JSON" )
100
- }
101
-
102
- conditions , ok := status ["conditions" ].([]interface {})
103
- if ! ok {
104
- return fmt .Errorf ("failed to get conditions field from deployment JSON" )
105
- }
106
-
107
79
// Check for Available condition
108
- for _ , condition := range conditions {
109
- cond , ok := condition .(map [string ]interface {})
110
- if ! ok {
111
- continue
112
- }
113
- if cond ["type" ] == "Available" && cond ["status" ] == "True" {
80
+ for _ , condition := range result .Status .Conditions {
81
+ if condition .Type == "Available" && condition .Status == "True" {
114
82
return nil // Deployment is available
115
83
}
116
84
}
0 commit comments