mcclient: options: accomodate time.Time type

This commit is contained in:
Yousong Zhou
2018-09-12 01:26:52 +00:00
parent d98e3b325f
commit af0603d6db
+6
View File
@@ -3,6 +3,7 @@ package options
import (
"fmt"
"reflect"
"time"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/gotypes"
@@ -88,6 +89,11 @@ func optionsStructRvToParams(rv reflect.Value) (*jsonutils.JSONDict, error) {
if ft.Anonymous {
continue
}
if f.Type() == gotypes.TimeType {
t := f.Interface().(time.Time)
p.Set(name, jsonutils.NewTimeString(t))
continue
}
// TODO
msg := fmt.Sprintf("do not know what to do with non-anonymous struct field: %s", ft.Name)
panic(msg)