| 7 | ) |
| 8 | |
| 9 | func StringifyAnyValue(anyValue *v1common.AnyValue) string { |
| 10 | switch anyValue.Value.(type) { |
| 11 | case *v1common.AnyValue_BoolValue: |
| 12 | return strconv.FormatBool(anyValue.GetBoolValue()) |
| 13 | case *v1common.AnyValue_IntValue: |
| 14 | return strconv.FormatInt(anyValue.GetIntValue(), 10) |
| 15 | case *v1common.AnyValue_ArrayValue: |
| 16 | arrStr := "[" |
| 17 | for _, v := range anyValue.GetArrayValue().Values { |
| 18 | arrStr += StringifyAnyValue(v) |
| 19 | } |
| 20 | arrStr += "]" |
| 21 | return arrStr |
| 22 | case *v1common.AnyValue_DoubleValue: |
| 23 | return strconv.FormatFloat(anyValue.GetDoubleValue(), 'f', -1, 64) |
| 24 | case *v1common.AnyValue_KvlistValue: |
| 25 | mapStr := "{" |
| 26 | for _, kv := range anyValue.GetKvlistValue().Values { |
| 27 | mapStr += kv.Key + ":" + StringifyAnyValue(kv.Value) |
| 28 | } |
| 29 | mapStr += "}" |
| 30 | return mapStr |
| 31 | case *v1common.AnyValue_StringValue: |
| 32 | return anyValue.GetStringValue() |
| 33 | } |
| 34 | |
| 35 | return "" |
| 36 | } |