Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
suslovsergey committed Feb 9, 2022
1 parent 15dfc23 commit 8bdd04d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
19 changes: 11 additions & 8 deletions apisix/model/plugin_ext_plugin_post_req.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var PluginExtPluginPostReqSchemaAttribute = tfsdk.Attribute{
}),
}

func (s PluginExtPluginPostReqType) Name() string { return "ext-plugin-pre-req" }
func (s PluginExtPluginPostReqType) Name() string { return "ext-plugin-post-req" }

func (s PluginExtPluginPostReqType) MapToState(data map[string]interface{}, pluginsType *PluginsType) {
v := data[s.Name()]
Expand All @@ -57,12 +57,14 @@ func (s PluginExtPluginPostReqType) MapToState(data map[string]interface{}, plug
utils.MapValueToBoolTypeValue(jsonData, "disable", &item.Disable)

var subItems []PluginExtPluginPostReqConfType
for _, vv := range jsonData["conf"].([]interface{}) {
subItem := PluginExtPluginPostReqConfType{}
subV := vv.(map[string]interface{})
utils.MapValueToStringTypeValue(subV, "name", &subItem.Name)
utils.MapValueToStringTypeValue(subV, "value", &subItem.Value)
subItems = append(subItems, subItem)
if v := jsonData["conf"]; v != nil {
for _, vv := range v.([]interface{}) {
subItem := PluginExtPluginPostReqConfType{}
subV := vv.(map[string]interface{})
utils.MapValueToStringTypeValue(subV, "name", &subItem.Name)
utils.MapValueToStringTypeValue(subV, "value", &subItem.Value)
subItems = append(subItems, subItem)
}
}

item.Config = subItems
Expand All @@ -79,9 +81,10 @@ func (s PluginExtPluginPostReqType) StateToMap(m map[string]interface{}) {
subItem := make(map[string]interface{})
utils.StringTypeValueToMap(vv.Name, subItem, "name")
utils.StringTypeValueToMap(vv.Value, subItem, "value")
subItems = append(subItems, subItem)
}

pluginValue["config"] = subItems
pluginValue["conf"] = subItems

m[s.Name()] = pluginValue
}
18 changes: 10 additions & 8 deletions apisix/model/plugin_ext_plugin_pre_req.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ func (s PluginExtPluginPreReqType) MapToState(data map[string]interface{}, plugi
utils.MapValueToBoolTypeValue(jsonData, "disable", &item.Disable)

var subItems []PluginExtPluginPreReqConfType
for _, vv := range jsonData["conf"].([]interface{}) {
subItem := PluginExtPluginPreReqConfType{}
subV := vv.(map[string]interface{})
utils.MapValueToStringTypeValue(subV, "name", &subItem.Name)
utils.MapValueToStringTypeValue(subV, "value", &subItem.Value)
subItems = append(subItems, subItem)
if v := jsonData["conf"]; v != nil {
for _, vv := range v.([]interface{}) {
subItem := PluginExtPluginPreReqConfType{}
subV := vv.(map[string]interface{})
utils.MapValueToStringTypeValue(subV, "name", &subItem.Name)
utils.MapValueToStringTypeValue(subV, "value", &subItem.Value)
subItems = append(subItems, subItem)
}
}

item.Config = subItems
Expand All @@ -79,9 +81,9 @@ func (s PluginExtPluginPreReqType) StateToMap(m map[string]interface{}) {
subItem := make(map[string]interface{})
utils.StringTypeValueToMap(vv.Name, subItem, "name")
utils.StringTypeValueToMap(vv.Value, subItem, "value")
subItems = append(subItems, subItem)
}

pluginValue["config"] = subItems

pluginValue["conf"] = subItems
m[s.Name()] = pluginValue
}

0 comments on commit 8bdd04d

Please sign in to comment.