update vendor

This commit is contained in:
Qiu Jian
2019-12-17 16:48:14 +08:00
parent 02229d970e
commit f3370a5824
9 changed files with 49 additions and 37 deletions

6
go.mod
View File

@@ -132,11 +132,11 @@ require (
k8s.io/client-go v9.0.0+incompatible
k8s.io/klog v0.1.0 // indirect
k8s.io/kubernetes v1.12.3
yunion.io/x/jsonutils v0.0.0-20191213072101-368b77b614fc
yunion.io/x/jsonutils v0.0.0-20191213141000-dfc176a66644
yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d
yunion.io/x/pkg v0.0.0-20191121110824-e03b47b93fe0
yunion.io/x/pkg v0.0.0-20191213141200-9b18cc7f696e
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
yunion.io/x/sqlchemy v0.0.0-20191206101534-32ae27ae30cb
yunion.io/x/sqlchemy v0.0.0-20191217082202-5f99691a51c9
yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3
)

12
go.sum
View File

@@ -659,19 +659,19 @@ sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051 h1:vtZw2iwGrsARNSwRTREGjmr2BWPdxbmXVkb3kI1qu28=
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
yunion.io/x/jsonutils v0.0.0-20191213072101-368b77b614fc h1:RvAB3yUwVMx/SlxtGN64N1yMNeUcJihUrAEgfNbLSnA=
yunion.io/x/jsonutils v0.0.0-20191213072101-368b77b614fc/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
yunion.io/x/jsonutils v0.0.0-20191213141000-dfc176a66644 h1:vOB64RELefQ9Xr0WDKVSWqCJNZLMb4Y2z5H4/bJqTdg=
yunion.io/x/jsonutils v0.0.0-20191213141000-dfc176a66644/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
yunion.io/x/log v0.0.0-20190514041436-04ce53b17c6b h1:Z9z+7iegu0HXuL+S8taVWRd1P4b9JJOgPXIeoqYrj7c=
yunion.io/x/log v0.0.0-20190514041436-04ce53b17c6b/go.mod h1:+gauLs73omeJAPlsXcevLsJLKixV+sR/E7WSYTSx1fE=
yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d h1:59zrDL7Ft+hDukguJRmLr/Gdu/9V75x+yX99ovZwfaA=
yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d/go.mod h1:LC6f/4FozL0iaAbnFt2eDX9jlsyo3WiOUPm03d7+U4U=
yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf h1:OsKC+2ghZHwp+Ztm/MwKlLKKRiE7QcPG8eTp0GmsHbg=
yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/pkg v0.0.0-20191121110824-e03b47b93fe0 h1:gMENCnVkKO5BlwtbKSKW5liEeHk8FHDxxcFXZcdhlxk=
yunion.io/x/pkg v0.0.0-20191121110824-e03b47b93fe0/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/pkg v0.0.0-20191213141200-9b18cc7f696e h1:zqci0LwvSvQtBg1d3lNhAZs13mkTM/fetang47/mRYA=
yunion.io/x/pkg v0.0.0-20191213141200-9b18cc7f696e/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e h1:v+EzIadodSwkdZ/7bremd7J8J50Cise/HCylsOJngmo=
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e/go.mod h1:0iFKpOs1y4lbCxeOmq3Xx/0AcQoewVPwj62eRluioEo=
yunion.io/x/sqlchemy v0.0.0-20191206101534-32ae27ae30cb h1:NYGUHfl8aelOGMp/LCCbnPZwLZl2tybN9ZM+XMnja8Y=
yunion.io/x/sqlchemy v0.0.0-20191206101534-32ae27ae30cb/go.mod h1:FTdwPdGhMgh4E+UFXc9klI1Ok34fMuybTT+jLhOaIjI=
yunion.io/x/sqlchemy v0.0.0-20191217082202-5f99691a51c9 h1:2yZ6YgFi5NkfqSdpclOOuYGaubk+WC6Emnb78ibgTVY=
yunion.io/x/sqlchemy v0.0.0-20191217082202-5f99691a51c9/go.mod h1:FTdwPdGhMgh4E+UFXc9klI1Ok34fMuybTT+jLhOaIjI=
yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3 h1:bfC8EhXYvyGYldRWlzxiCM39Zfj3s3+zham9mW2h2LE=
yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3/go.mod h1:EP6NSv2C0zzqBDTKumv8hPWLb3XvgMZDHQRfyuOrQng=

6
vendor/modules.txt vendored
View File

@@ -798,12 +798,12 @@ k8s.io/kubernetes/pkg/scheduler/api
k8s.io/kubernetes/pkg/scheduler/api/v1
# sigs.k8s.io/yaml v1.1.0
sigs.k8s.io/yaml
# yunion.io/x/jsonutils v0.0.0-20191213072101-368b77b614fc
# yunion.io/x/jsonutils v0.0.0-20191213141000-dfc176a66644
yunion.io/x/jsonutils
# yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d
yunion.io/x/log
yunion.io/x/log/hooks
# yunion.io/x/pkg v0.0.0-20191121110824-e03b47b93fe0
# yunion.io/x/pkg v0.0.0-20191213141200-9b18cc7f696e
yunion.io/x/pkg/errors
yunion.io/x/pkg/gotypes
yunion.io/x/pkg/prettytable
@@ -835,7 +835,7 @@ yunion.io/x/pkg/util/workqueue
yunion.io/x/pkg/utils
# yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
yunion.io/x/s3cli
# yunion.io/x/sqlchemy v0.0.0-20191206101534-32ae27ae30cb
# yunion.io/x/sqlchemy v0.0.0-20191217082202-5f99691a51c9
yunion.io/x/sqlchemy
# yunion.io/x/structarg v0.0.0-20190809075558-115bed041de3
yunion.io/x/structarg

View File

@@ -28,7 +28,6 @@ import (
"strings"
"time"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/gotypes"
"yunion.io/x/pkg/tristate"
@@ -126,8 +125,7 @@ func (this *JSONInt) unmarshalValue(val reflect.Value) error {
case reflect.Interface:
val.Set(reflect.ValueOf(this.data))
default:
log.Errorf("JSONDict type mismatch: %s", val.Type())
return ErrTypeMismatch // fmt.Errorf("JSONInt type mismatch: %s", val.Type())
return errors.Wrapf(ErrTypeMismatch, "JSONInt vs. %s", val.Type())
}
return nil
}
@@ -194,8 +192,7 @@ func (this *JSONBool) unmarshalValue(val reflect.Value) error {
case reflect.Interface:
val.Set(reflect.ValueOf(this.data))
default:
log.Errorf("JSONDict type mismatch: %s", val.Type())
return ErrTypeMismatch // fmt.Errorf("JSONBool type mismatch: %s", val.Type())
return errors.Wrapf(ErrTypeMismatch, "JSONBool vs. %s", val.Type())
}
return nil
}
@@ -271,8 +268,7 @@ func (this *JSONFloat) unmarshalValue(val reflect.Value) error {
case reflect.Interface:
val.Set(reflect.ValueOf(this.data))
default:
log.Errorf("JSONDict type mismatch: %s", val.Type())
return ErrTypeMismatch // fmt.Errorf("JSONFloat type mismatch: %s", val.Type())
return errors.Wrapf(ErrTypeMismatch, "JSONFloat vs. %s", val.Type())
}
return nil
}
@@ -371,8 +367,7 @@ func (this *JSONString) unmarshalValue(val reflect.Value) error {
}
return this.unmarshalValue(val.Index(0))
default:
log.Errorf("JSONDict type mismatch: %s", val.Type())
return ErrTypeMismatch // fmt.Errorf("JSONString type mismatch: %s", val.Type())
return errors.Wrapf(ErrTypeMismatch, "JSONString vs. %s", val.Type())
}
return nil
}
@@ -429,8 +424,7 @@ func (this *JSONArray) unmarshalValue(val reflect.Value) error {
}
}
default:
log.Errorf("JSONDict type mismatch: %s", val.Type())
return ErrTypeMismatch // fmt.Errorf("JSONArray type mismatch: %s", val.Type())
return errors.Wrapf(ErrTypeMismatch, "JSONArray vs. %s", val.Type())
}
return nil
}
@@ -481,8 +475,7 @@ func (this *JSONDict) unmarshalValue(val reflect.Value) error {
//
val.Set(reflect.ValueOf(objPtr).Convert(val.Type()))
} else {
log.Errorf("Do not known how to deserialize json into this interface type %s", val.Type())
return ErrInterfaceUnsupported
return errors.Wrapf(ErrInterfaceUnsupported, "JSONDict.unmarshalValue: %s", val.Type())
}
case reflect.Ptr:
kind := val.Type().Elem().Kind()
@@ -495,8 +488,7 @@ func (this *JSONDict) unmarshalValue(val reflect.Value) error {
}
fallthrough
default:
log.Errorf("JSONDict type mismatch: %s", val.Type())
return ErrTypeMismatch
return errors.Wrapf(ErrTypeMismatch, "JSONDict.unmarshalValue: %s", val.Type())
}
return nil
}
@@ -517,8 +509,7 @@ func (this *JSONDict) unmarshalMap(val reflect.Value) error {
err := v.unmarshalValue(valVal)
if err != nil {
log.Debugf("unmarshalMap field %s error %s", k, err)
return errors.Wrap(err, "unmarshalValue")
return errors.Wrap(err, "JSONDict.unmarshalMap")
}
val.SetMapIndex(keyVal, valVal)
}
@@ -532,8 +523,7 @@ func (this *JSONDict) unmarshalStruct(val reflect.Value) error {
if find {
err := v.unmarshalValue(fieldValue)
if err != nil {
log.Debugf("unmarshalStruct field %s error %s", k, err)
return errors.Wrap(err, "unmarshalValue")
return errors.Wrap(err, "JSONDict.unmarshalStruct")
}
}
}

View File

@@ -24,6 +24,13 @@ type IDeepCopy interface {
type DeepCopyFlags uintptr
// DeepCopy copies the passed argument recursively
//
// There are a few constraint
//
// - It cannot handle un-exported fields
// - It cannot handle circular references. Doing so will cause runtime stack
// overflow panic
func DeepCopy(v interface{}) interface{} {
rv := reflect.ValueOf(v)
cpRv := DeepCopyRv(rv)

View File

@@ -144,10 +144,12 @@ func fetchStructFieldValueSet(dataValue reflect.Value, allocatePtr bool) SStruct
}
}
jsonInfo := ParseStructFieldJsonInfo(sf)
fields = append(fields, SStructFieldValue{
Info: jsonInfo,
Value: fv,
})
if !jsonInfo.Ignore {
fields = append(fields, SStructFieldValue{
Info: jsonInfo,
Value: fv,
})
}
}
return fields
}

View File

@@ -48,6 +48,7 @@ type IColumnSpec interface {
ConvertFromValue(val interface{}) interface{}
// ConvertToValue(str interface{}) interface{}
IsZero(val interface{}) bool
AllowZero() bool
// IsEqual(v1, v2 interface{}) bool
Tags() map[string]string
@@ -64,6 +65,7 @@ type SBaseColumn struct {
isPrimary bool
isUnique bool
isIndex bool
isAllowZero bool
tags map[string]string
}
@@ -127,6 +129,10 @@ func (c *SBaseColumn) IsNumeric() bool {
return false
}
func (c *SBaseColumn) AllowZero() bool {
return c.isAllowZero
}
func (c *SBaseColumn) ConvertFromString(str string) string {
return str
}
@@ -217,6 +223,11 @@ func NewBaseColumn(name string, sqltype string, tagmap map[string]string, isPoin
if isPrimary {
isNullable = false
}
isAllowZero := false
tagmap, val, ok = utils.TagPop(tagmap, TAG_ALLOW_ZERO)
if ok {
isAllowZero = utils.ToBool(val)
}
return SBaseColumn{
name: name,
dbName: dbName,
@@ -228,6 +239,7 @@ func NewBaseColumn(name string, sqltype string, tagmap map[string]string, isPoin
isIndex: isIndex,
tags: tagmap,
isPointer: isPointer,
isAllowZero: isAllowZero,
}
}

View File

@@ -46,4 +46,5 @@ const (
TAG_AUTOVERSION = "auto_version"
TAG_UPDATE_TIMESTAMP = "updated_at"
TAG_CREATE_TIMESTAMP = "created_at"
TAG_ALLOW_ZERO = "allow_zero"
)

View File

@@ -20,9 +20,9 @@ import (
"strings"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/gotypes"
"yunion.io/x/pkg/util/reflectutils"
"yunion.io/x/pkg/errors"
)
func (t *STableSpec) Insert(dt interface{}) error {
@@ -92,7 +92,7 @@ func (t *STableSpec) insertSqlPrep(dataFields reflectutils.SStructFieldValueSet,
}
_, isTextCol := c.(*STextColumn)
if c.IsSupportDefault() && (len(c.Default()) > 0 || isTextCol) && !gotypes.IsNil(ov) && c.IsZero(ov) { // empty text value
if c.IsSupportDefault() && (len(c.Default()) > 0 || isTextCol) && !gotypes.IsNil(ov) && c.IsZero(ov) && !c.AllowZero() { // empty text value
val := c.ConvertFromString(c.Default())
values = append(values, val)
names = append(names, fmt.Sprintf("`%s`", k))