Skip to content

Commit

Permalink
cmd: Add warning for type convert instead (#670)
Browse files Browse the repository at this point in the history
* cmd: Add warning for type convert instead

Signed-off-by: Xuanwo <[email protected]>

* cmd: Add docs for parseType

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Jul 15, 2021
1 parent 385b5ea commit ba29fad
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 33 additions & 0 deletions cmd/definitions/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,36 @@ func parseFunc(name string) map[string]*templateutils.Method {
}
return data
}

var typeMap = map[string]string{
"context": "context.Context",
"http_client_options": "*httpclient.Options",

"any": "interface{}",
"byte_array": "[]byte",
"string_array": "[]string",
"string_string_map": "map[string]string",
"time": "time.Time",
"BlockIterator": "*BlockIterator",
"IoCallback": "func([]byte)",
"Object": "*Object",
"ObjectIterator": "*ObjectIterator",
"Pairs": "...Pair",
"Part": "*Part",
"Parts": "[]*Part",
"PartIterator": "*PartIterator",
"Reader": "io.Reader",
"StoragerIterator": "*StoragerIterator",
"StorageMeta": "*StorageMeta",
"Writer": "io.Writer",
}

// TODO: We can remove this convert after all service migrated.
func parseType(v string) string {
s, ok := typeMap[v]
if !ok {
return v
}
log.Warnf("type %s is not supported anymore, please updated to %s.", v, s)
return s
}
4 changes: 2 additions & 2 deletions cmd/definitions/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ type Pair struct {
}

func (p *Pair) Type() string {
return p.ptype
return parseType(p.ptype)
}

// Format will formatGlobal current pair
Expand Down Expand Up @@ -159,7 +159,7 @@ func (i *Info) Format(s specs.Info, global bool) {
}

func (i *Info) Type() string {
return i.itype
return parseType(i.itype)
}

func (i *Info) TypeName() string {
Expand Down

0 comments on commit ba29fad

Please sign in to comment.