99 "strings"
1010 "time"
1111
12+ appsv1 "k8s.io/api/apps/v1"
13+
1214 "github.com/feast-dev/feast/infra/feast-operator/api/v1alpha1"
1315)
1416
@@ -26,36 +28,17 @@ func checkIfFeatureStoreCustomResourceConditionsInReady(featureStoreName, namesp
2628 featureStoreName , namespace , err , stderr .String ())
2729 }
2830
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
3133 if err := json .Unmarshal (out .Bytes (), & resource ); err != nil {
3234 return fmt .Errorf ("failed to parse the resource JSON. Error: %v" , err )
3335 }
3436
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-
4637 // 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" {
5740 return fmt .Errorf (" FeatureStore=%s condition '%s' is not in 'Ready' state. Status: %s" ,
58- featureStoreName , conditionType , conditionStatus )
41+ featureStoreName , condition . Type , condition . Status )
5942 }
6043 }
6144
@@ -87,30 +70,15 @@ func checkIfDeploymentExistsAndAvailable(namespace string, deploymentName string
8770 continue
8871 }
8972
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
9275 if err := json .Unmarshal (output .Bytes (), & result ); err != nil {
9376 return fmt .Errorf ("failed to parse deployment JSON: %v" , err )
9477 }
9578
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-
10779 // 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" {
11482 return nil // Deployment is available
11583 }
11684 }
0 commit comments