GetPortData() returns policies
[ric-plt/xapp-frame.git] / pkg / xapp / config.go
index 8d427c5..bb76a07 100755 (executable)
@@ -127,6 +127,13 @@ func PublishConfigChange(appName, eventJson string) error {
 }
 
 func GetPortData(pname string) (d PortData) {
+       var getPolicies = func(policies []interface{}) (plist []int) {
+               for _, p := range policies {
+                       plist = append(plist, int(p.(float64)))
+               }
+               return plist
+       }
+
        for _, v := range viper.GetStringMap("messaging")["ports"].([]interface{}) {
                if n, ok := v.(map[string]interface{})["name"].(string); ok && n == pname {
                        d.Name = n
@@ -148,6 +155,9 @@ func GetPortData(pname string) (d PortData) {
                        if m, _ := v.(map[string]interface{})["maxRetryOnFailure"].(float64); ok {
                                d.MaxRetryOnFailure = int(m)
                        }
+                       if policies, ok := v.(map[string]interface{})["policies"]; ok {
+                               d.Policies = getPolicies(policies.([]interface{}))
+                       }
                }
        }
        return