diff --git a/Gopkg.lock b/Gopkg.lock index 5e1701f1f6..465f2beb19 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1053,7 +1053,7 @@ [[projects]] branch = "master" - digest = "1:47670c70d0326f624de21c8f29d0f73850062f0752f27e146308db62fbb540d3" + digest = "1:f640bec6e2c558f83117e88f16753d54685c95b8fb83d5660ed6c43e04adde72" name = "yunion.io/x/pkg" packages = [ "gotypes", @@ -1088,23 +1088,23 @@ "utils", ] pruneopts = "UT" - revision = "6c349ecbdb90d5f6ecc9b86596428176c1937b32" + revision = "3bcf68100d212545f2f16b91bb3962bc8b228da7" [[projects]] branch = "master" - digest = "1:e23019db2cda58480528738c86bc7abbff09d10488c2a51dd5d500f8686815f0" + digest = "1:a8a402e8c9d4a7bf8efbdb81ae2da8fb72ebbe07bbfc1168a124905ace456ed0" name = "yunion.io/x/sqlchemy" packages = ["."] pruneopts = "UT" - revision = "19a3c90524d3638f8e3580231396dda46088aebc" + revision = "1e2883d085d6d449d4df7d28b61073dec11c5dbb" [[projects]] branch = "master" - digest = "1:71e1b62648868a9083f9e4693145a0154a600591ca548aaf64cae32a10e956e5" + digest = "1:64b263a23f3c35521bb811b2aa9f93f8c7ce1ff06487db12d6aa3fc25705ad2e" name = "yunion.io/x/structarg" packages = ["."] pruneopts = "UT" - revision = "4a5eb8e2cdfbf7f6511561a3c710c116b171f405" + revision = "ec02b19c0bccfc991fc9e850f5a2a543ae43254b" [solve-meta] analyzer-name = "dep" diff --git a/vendor/yunion.io/x/pkg/gotypes/gotypes.go b/vendor/yunion.io/x/pkg/gotypes/gotypes.go index e589aa7c61..615499fa4a 100644 --- a/vendor/yunion.io/x/pkg/gotypes/gotypes.go +++ b/vendor/yunion.io/x/pkg/gotypes/gotypes.go @@ -120,6 +120,15 @@ func ParseValue(val string, tp reflect.Type) (reflect.Value, error) { } case reflect.String: return reflect.ValueOf(val), nil + case reflect.Ptr: + tpElem := tp.Elem() + rv, err := ParseValue(val, tpElem) + if err != nil { + return reflect.ValueOf(val), fmt.Errorf("Cannot parse %s to %s", val, tp) + } + rvv := reflect.New(tpElem) + rvv.Elem().Set(rv) + return rvv, nil default: if tp == TimeType { tm, e := timeutils.ParseTimeStr(val) @@ -173,7 +182,16 @@ func SetValue(value reflect.Value, valStr string) error { Float32SliceType, Float64SliceType, StringSliceType: reflect.Append(value, reflect.ValueOf(valStr)) default: - return fmt.Errorf("Unsupported type: %v", value.Type()) + if value.Kind() == reflect.Ptr && value.Elem().Kind() != reflect.Slice { + newVal := reflect.New(value.Type().Elem()) + newValElem := newVal.Elem() + if err := SetValue(newValElem, valStr); err != nil { + return err + } + value.Set(newVal) + } else { + return fmt.Errorf("Unsupported type: %v", value.Type()) + } } return nil } diff --git a/vendor/yunion.io/x/pkg/util/filterclause/filterclause.go b/vendor/yunion.io/x/pkg/util/filterclause/filterclause.go index 2a3a1ccd10..1bddde5c61 100644 --- a/vendor/yunion.io/x/pkg/util/filterclause/filterclause.go +++ b/vendor/yunion.io/x/pkg/util/filterclause/filterclause.go @@ -16,6 +16,22 @@ type SFilterClause struct { params []string } +// "guestnetworks.guest_id(id).ip_addr.equals(10.168.222.232)" +type SJointFilterClause struct { + SFilterClause + JointModel string + RelatedKey string + OriginKey string +} + +func (jfc *SJointFilterClause) GetJointFilter(q *sqlchemy.SQuery) sqlchemy.ICondition { + return jfc.QueryCondition(q) +} + +func (jfc *SJointFilterClause) GetJointModelName() string { + return jfc.JointModel[:len(jfc.JointModel)-1] +} + func (fc *SFilterClause) QueryCondition(q *sqlchemy.SQuery) sqlchemy.ICondition { field := q.Field(fc.field) if field == nil { @@ -63,11 +79,13 @@ func (fc *SFilterClause) String() string { } var ( - filterClausePattern *regexp.Regexp + filterClausePattern *regexp.Regexp + jointFilterClausePattern *regexp.Regexp ) func init() { filterClausePattern = regexp.MustCompile(`^(\w+)\.(\w+)\((.*)\)`) + jointFilterClausePattern = regexp.MustCompile(`^(\w+)\.(\w+)\((\w+)\).(\w+)\.(\w+)\((.*)\)`) } func ParseFilterClause(filter string) *SFilterClause { @@ -79,3 +97,22 @@ func ParseFilterClause(filter string) *SFilterClause { fc := SFilterClause{field: matches[1], funcName: matches[2], params: params} return &fc } + +func ParseJointFilterClause(jointFilter string) *SJointFilterClause { + matches := jointFilterClausePattern.FindStringSubmatch(jointFilter) + if matches == nil { + return nil + } + params := utils.FindWords([]byte(matches[6]), 0) + jfc := SJointFilterClause{ + SFilterClause: SFilterClause{ + field: matches[4], + funcName: matches[5], + params: params, + }, + JointModel: matches[1], + RelatedKey: matches[2], + OriginKey: matches[3], + } + return &jfc +} diff --git a/vendor/yunion.io/x/pkg/util/sysutils/storagetypes.go b/vendor/yunion.io/x/pkg/util/sysutils/storagetypes.go index 476aa53bff..16baa403d2 100644 --- a/vendor/yunion.io/x/pkg/util/sysutils/storagetypes.go +++ b/vendor/yunion.io/x/pkg/util/sysutils/storagetypes.go @@ -9,12 +9,18 @@ const ( STORAGE_NAS = "nas" STORAGE_VSAN = "vsan" + STORAGE_CLOUD = "cloud" STORAGE_CLOUD_SSD = "cloud_ssd" STORAGE_CLOUD_EFFICIENCY = "cloud_efficiency" + + STORAGE_STANDARD = "standard" //Azure hdd storage type + STORAGE_PREMIUM = "premium" //Azure ssd storage type ) var STORAGE_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_SHEEPDOG, - STORAGE_RBD, STORAGE_DOCKER, STORAGE_NAS, STORAGE_VSAN, STORAGE_CLOUD_SSD, STORAGE_CLOUD_EFFICIENCY} + STORAGE_RBD, STORAGE_DOCKER, STORAGE_NAS, STORAGE_VSAN, + STORAGE_CLOUD, STORAGE_CLOUD_SSD, STORAGE_CLOUD_EFFICIENCY, + STORAGE_STANDARD, STORAGE_PREMIUM} var LOCAL_STORAGE_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL} diff --git a/vendor/yunion.io/x/sqlchemy/update.go b/vendor/yunion.io/x/sqlchemy/update.go index e40e0f6eff..f88e1a6bde 100644 --- a/vendor/yunion.io/x/sqlchemy/update.go +++ b/vendor/yunion.io/x/sqlchemy/update.go @@ -28,7 +28,10 @@ func (ts *STableSpec) prepareUpdate(dt interface{}) (*SUpdateSession, error) { zeroKeyIndex := make([]string, 0) for _, c := range ts.columns { k := c.Name() - ov := fields[k] + ov, ok := fields[k] + if !ok { + continue + } if c.IsPrimary() && c.IsZero(ov) { zeroPrimary = append(zeroPrimary, k) } else if c.IsKeyIndex() && c.IsZero(ov) { @@ -80,7 +83,10 @@ func (us *SUpdateSession) saveUpdate(dt interface{}) (map[string]SUpdateDiff, er setters := make(map[string]SUpdateDiff) for _, c := range us.tableSpec.columns { k := c.Name() - of := ofields[k] + of, ok := ofields[k] + if !ok { + continue + } nf := fields[k] if c.IsPrimary() && !c.IsZero(of) { // skip update primary key primaries[k] = of diff --git a/vendor/yunion.io/x/structarg/structarg.go b/vendor/yunion.io/x/structarg/structarg.go index 7f7f6c6414..7eb514b3f0 100644 --- a/vendor/yunion.io/x/structarg/structarg.go +++ b/vendor/yunion.io/x/structarg/structarg.go @@ -423,8 +423,32 @@ func (this *ArgumentParser) Options() interface{} { return this.target } +func (this *SingleArgument) valueIsBool() bool { + rv := this.value + if rv.Kind() == reflect.Bool { + return true + } + + if rv.Kind() == reflect.Ptr && rv.Type().Elem().Kind() == reflect.Bool { + return true + } + return false +} + +func (this *SingleArgument) defaultBoolValue() bool { + rv := this.defValue + if rv.Kind() == reflect.Bool { + return rv.Bool() + } + + if rv.Kind() == reflect.Ptr && rv.Type().Elem().Kind() == reflect.Bool { + return rv.Elem().Bool() + } + panic("expecting bool or *bool type: got " + rv.Type().String()) +} + func (this *SingleArgument) NeedData() bool { - if this.value.Kind() == reflect.Bool { + if this.valueIsBool() { return false } else { return true @@ -539,12 +563,14 @@ func (this *SingleArgument) Reset() { } func (this *SingleArgument) DoAction() error { - if this.value.Type() == gotypes.BoolType { + if this.valueIsBool() { + var v bool if this.useDefault { - this.value.SetBool(!this.defValue.Bool()) + v = !this.defaultBoolValue() } else { - this.value.SetBool(true) + v = true } + gotypes.SetValue(this.value, fmt.Sprintf("%t", v)) this.isSet = true } return nil