starsz commented on a change in pull request #1061:
URL: https://github.com/apache/apisix-dashboard/pull/1061#discussion_r545614713



##########
File path: api/internal/utils/utils.go
##########
@@ -94,3 +95,38 @@ func InterfaceToString(val interface{}) string {
        str := fmt.Sprintf("%v", val)
        return str
 }
+
+func GenLabelMap(label string) map[string]string {
+       mp := make(map[string]string)
+
+       if label == "" {
+               return mp
+       }
+
+       labels := strings.Split(label, ",")
+       for _, l := range labels {
+               kv := strings.Split(l, ":")
+               if len(kv) == 2 {
+                       mp[kv[0]] = kv[1]
+               } else if len(kv) == 1 {
+                       mp[kv[0]] = ""
+               }

Review comment:
       Fixed.

##########
File path: api/internal/utils/utils_test.go
##########
@@ -42,3 +42,33 @@ func TestSumIPs_with_nil(t *testing.T) {
        total := sumIPs(nil)
        assert.Equal(t, uint16(0), total)
 }
+
+func TestGenLabelMap(t *testing.T) {
+       mp := GenLabelMap("l1")

Review comment:
       Fixed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to