Skip to content

Commit 1e33cdc

Browse files
authored
Merge pull request #57 from ucloud/feature/uhost
update cmd uhost create about bind eip
2 parents 8bc8e51 + dd7e821 commit 1e33cdc

243 files changed

Lines changed: 16702 additions & 11260 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export VERSION=0.1.35
2+
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
23

34
.PHONY : install
45
install:
@@ -11,6 +12,11 @@ build_mac:
1112
tar zcvf out/ucloud-cli-macosx-${VERSION}-amd64.tgz -C out ucloud
1213
shasum -a 256 out/ucloud-cli-macosx-${VERSION}-amd64.tgz
1314

15+
build_mac_arm:
16+
GOOS=darwin GOARCH=arm64 go build -mod=vendor -o out/ucloud main.go
17+
tar zcvf out/ucloud-cli-macosx-${VERSION}-arm64.tgz -C out ucloud
18+
shasum -a 256 out/ucloud-cli-macosx-${VERSION}-arm64.tgz
19+
1420
.PHONY : build_linux
1521
build_linux:
1622
GOOS=linux GOARCH=amd64 go build -mod=vendor -o out/ucloud main.go
@@ -26,3 +32,6 @@ build_windows:
2632
.PHONY : build_all
2733
build_all: build_mac build_linux build_windows
2834

35+
.PHONY: fmt
36+
fmt:
37+
gofmt -w -s $(GOFMT_FILES)

cmd/eip.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ func NewCmdEIPList(out io.Writer) *cobra.Command {
104104
row.Group = eip.Tag
105105
row.ChargeMode = eip.PayMode
106106
row.Bandwidth = strconv.Itoa(eip.Bandwidth) + "Mb"
107-
if eip.Resource.ResourceId != "" {
108-
row.BindResource = fmt.Sprintf("%s|%s(%s)", eip.Resource.ResourceName, eip.Resource.ResourceId, eip.Resource.ResourceType)
107+
if eip.Resource.ResourceID != "" {
108+
row.BindResource = fmt.Sprintf("%s|%s(%s)", eip.Resource.ResourceName, eip.Resource.ResourceID, eip.Resource.ResourceType)
109109
}
110110
row.Status = eip.Status
111111
row.ExpirationTime = time.Unix(int64(eip.ExpireTime), 0).Format("2006-01-02")
@@ -373,7 +373,7 @@ func NewCmdEIPUnbind() *cobra.Command {
373373
return
374374
}
375375
req.EIPId = sdk.String(base.PickResourceID(eip))
376-
req.ResourceId = sdk.String(eipIns.Resource.ResourceId)
376+
req.ResourceId = sdk.String(eipIns.Resource.ResourceID)
377377
req.ResourceType = sdk.String(eipIns.Resource.ResourceType)
378378
_, err = base.BizClient.UnBindEIP(req)
379379
if err != nil {

cmd/firewall.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ func NewCmdFirewallResource(out io.Writer) *cobra.Command {
497497
flags.StringVar(&fwID, "fw-id", "", "Required. Resource ID of firewall")
498498
req.Region = flags.String("region", base.ConfigIns.Region, "Optional. Region, see 'ucloud region'")
499499
req.ProjectId = flags.String("project-id", base.ConfigIns.ProjectID, "Optional. Project-id, see 'ucloud project list'")
500-
req.Offset = flags.String("offset", "0", "Optional. Offset")
501-
req.Limit = flags.String("limit", "50", "Optional. Limit")
500+
req.Offset = flags.Int("offset", 0, "Optional. Offset")
501+
req.Limit = flags.Int("limit", 50, "Optional. Limit")
502502

503503
flags.SetFlagValuesFunc("fw-id", func() []string {
504504
return getFirewallIDNames(*req.ProjectId, *req.Region)

cmd/pathx.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ type upathRow struct {
6262

6363
//NewCmdUpathList ucloud pathx upath list
6464
func NewCmdUpathList(out io.Writer) *cobra.Command {
65-
req := base.BizClient.NewDescribeUPathRequest()
65+
req := base.BizClient.PrivatePathxClient.NewDescribeUPathRequest()
6666
cmd := &cobra.Command{
6767
Use: "list",
6868
Short: "list upath instances",
6969
Long: "list upath instances",
7070
Run: func(c *cobra.Command, args []string) {
71-
resp, err := base.BizClient.DescribeUPath(req)
71+
resp, err := base.BizClient.PrivatePathxClient.DescribeUPath(req)
7272
if err != nil {
7373
base.HandleError(err)
7474
return
@@ -132,14 +132,14 @@ var protocols = []string{"tcp", "udp"}
132132

133133
//NewCmdUGAList ucloud uga list
134134
func NewCmdUGAList(out io.Writer) *cobra.Command {
135-
req := base.BizClient.NewDescribeUGAInstanceRequest()
135+
req := base.BizClient.PrivatePathxClient.NewDescribeUGAInstanceRequest()
136136
cmd := &cobra.Command{
137137
Use: "list",
138138
Short: "list uga instances",
139139
Long: "list uga instances",
140140
Run: func(c *cobra.Command, args []string) {
141141
*req.UGAId = base.PickResourceID(*req.UGAId)
142-
resp, err := base.BizClient.DescribeUGAInstance(req)
142+
resp, err := base.BizClient.PrivatePathxClient.DescribeUGAInstance(req)
143143
if err != nil {
144144
base.HandleError(err)
145145
return
@@ -195,14 +195,14 @@ func getPortStr(list []ppathx.UGAATask) string {
195195

196196
//NewCmdUGADescribe ucloud uga describe
197197
func NewCmdUGADescribe(out io.Writer) *cobra.Command {
198-
req := base.BizClient.NewDescribeUGAInstanceRequest()
198+
req := base.BizClient.PrivatePathxClient.NewDescribeUGAInstanceRequest()
199199
cmd := &cobra.Command{
200200
Use: "describe",
201201
Short: "Display detail informations about uga instances",
202202
Long: "Display detail informations about uga instances",
203203
Run: func(c *cobra.Command, args []string) {
204204
*req.UGAId = base.PickResourceID(*req.UGAId)
205-
resp, err := base.BizClient.DescribeUGAInstance(req)
205+
resp, err := base.BizClient.PrivatePathxClient.DescribeUGAInstance(req)
206206
if err != nil {
207207
base.HandleError(err)
208208
return
@@ -214,13 +214,13 @@ func NewCmdUGADescribe(out io.Writer) *cobra.Command {
214214

215215
ins := resp.UGAList[0]
216216
list := []base.DescribeTableRow{
217-
base.DescribeTableRow{"ResourceID", ins.UGAId},
218-
base.DescribeTableRow{"UGAName", ins.UGAName},
219-
base.DescribeTableRow{"Origin", fmt.Sprintf("%s%s", ins.Domain, strings.Join(ins.IPList, ","))},
220-
base.DescribeTableRow{"CName", ins.CName},
221-
base.DescribeTableRow{"AcceleratedPath", getUpathStr(ins.UPathSet)},
222-
base.DescribeTableRow{"OutIP", getOutIPStr(ins.OutPublicIpList)},
223-
base.DescribeTableRow{"Port", getPortStr(ins.TaskSet)},
217+
{"ResourceID", ins.UGAId},
218+
{"UGAName", ins.UGAName},
219+
{"Origin", fmt.Sprintf("%s%s", ins.Domain, strings.Join(ins.IPList, ","))},
220+
{"CName", ins.CName},
221+
{"AcceleratedPath", getUpathStr(ins.UPathSet)},
222+
{"OutIP", getOutIPStr(ins.OutPublicIpList)},
223+
{"Port", getPortStr(ins.TaskSet)},
224224
}
225225
base.PrintList(list, out)
226226
},
@@ -271,7 +271,7 @@ func formatPortList(userPorts []string) ([]string, error) {
271271
func NewCmdUGACreate(out io.Writer) *cobra.Command {
272272
var protocol string
273273
var ports, lines []string
274-
req := base.BizClient.NewCreateUGAInstanceRequest()
274+
req := base.BizClient.PrivatePathxClient.NewCreateUGAInstanceRequest()
275275
cmd := &cobra.Command{
276276
Use: "create",
277277
Short: "Create uga instance",
@@ -302,7 +302,7 @@ func NewCmdUGACreate(out io.Writer) *cobra.Command {
302302
fmt.Fprintf(out, "protocol should be one of %s, received:%s\n", strings.Join(protocols, ","), protocol)
303303
}
304304

305-
resp, err := base.BizClient.CreateUGAInstance(req)
305+
resp, err := base.BizClient.PrivatePathxClient.CreateUGAInstance(req)
306306
if err != nil {
307307
if uErr, ok := err.(uerr.Error); ok && uErr.Code() == 33756 {
308308
fmt.Fprintf(out, "The number of ports added exceeds the limit(50). We recommend that you could reduce the number of ports, then create an uga instance, \nand then add the remaining ports by executing 'ucloud pathx uga add-port --protocol %s --uga-id <uga-id> --port <PortList>'\n", protocol)
@@ -314,11 +314,11 @@ func NewCmdUGACreate(out io.Writer) *cobra.Command {
314314

315315
for _, path := range lines {
316316
p := base.PickResourceID(path)
317-
bindReq := base.BizClient.NewUGABindUPathRequest()
317+
bindReq := base.BizClient.PrivatePathxClient.NewUGABindUPathRequest()
318318
bindReq.ProjectId = req.ProjectId
319319
bindReq.UGAId = sdk.String(resp.UGAId)
320320
bindReq.UPathId = &p
321-
_, err := base.BizClient.UGABindUPath(bindReq)
321+
_, err := base.BizClient.PrivatePathxClient.UGABindUPath(bindReq)
322322
if err != nil {
323323
fmt.Fprintf(out, "bind uga[%s] and upath[%s] failed: %v\n", resp.UGAId, p, err)
324324
} else {
@@ -358,7 +358,7 @@ func NewCmdUGACreate(out io.Writer) *cobra.Command {
358358
//NewCmdUGADelete ucloud uga delete
359359
func NewCmdUGADelete(out io.Writer) *cobra.Command {
360360
idNames := []string{}
361-
req := base.BizClient.NewDeleteUGAInstanceRequest()
361+
req := base.BizClient.PrivatePathxClient.NewDeleteUGAInstanceRequest()
362362
cmd := &cobra.Command{
363363
Use: "delete",
364364
Short: "Delete uga instances",
@@ -367,7 +367,7 @@ func NewCmdUGADelete(out io.Writer) *cobra.Command {
367367
for _, idname := range idNames {
368368
id := base.PickResourceID(idname)
369369
req.UGAId = &id
370-
_, err := base.BizClient.DeleteUGAInstance(req)
370+
_, err := base.BizClient.PrivatePathxClient.DeleteUGAInstance(req)
371371
if err != nil {
372372
base.HandleError(err)
373373
} else {
@@ -510,9 +510,9 @@ func NewCmdUGARemovePort(out io.Writer) *cobra.Command {
510510
}
511511

512512
func getUGAList(project string) ([]ppathx.UGAAInfo, error) {
513-
req := base.BizClient.NewDescribeUGAInstanceRequest()
513+
req := base.BizClient.PrivatePathxClient.NewDescribeUGAInstanceRequest()
514514
req.ProjectId = &project
515-
resp, err := base.BizClient.DescribeUGAInstance(req)
515+
resp, err := base.BizClient.PrivatePathxClient.DescribeUGAInstance(req)
516516
if err != nil {
517517
return nil, err
518518
}
@@ -533,9 +533,9 @@ func getUGAIDList(project string) []string {
533533
}
534534

535535
func getUpathList(project string) ([]ppathx.UPathInfo, error) {
536-
req := base.BizClient.NewDescribeUPathRequest()
536+
req := base.BizClient.PrivatePathxClient.NewDescribeUPathRequest()
537537
req.ProjectId = &project
538-
resp, err := base.BizClient.DescribeUPath(req)
538+
resp, err := base.BizClient.PrivatePathxClient.DescribeUPath(req)
539539
if err != nil {
540540
return nil, err
541541
}

cmd/udb.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ func NewCmdUDBConfDescribe(out io.Writer) *cobra.Command {
153153
}
154154
conf := resp.DataSet[0]
155155
attrs := []base.DescribeTableRow{
156-
base.DescribeTableRow{Attribute: "ConfID", Content: strconv.Itoa(conf.GroupId)},
157-
base.DescribeTableRow{Attribute: "DBVersion", Content: conf.DBTypeId},
158-
base.DescribeTableRow{Attribute: "Name", Content: conf.GroupName},
159-
base.DescribeTableRow{Attribute: "Description", Content: conf.Description},
160-
base.DescribeTableRow{Attribute: "Modifiable", Content: strconv.FormatBool(conf.Modifiable)},
161-
base.DescribeTableRow{Attribute: "Zone", Content: conf.Zone},
156+
{Attribute: "ConfID", Content: strconv.Itoa(conf.GroupId)},
157+
{Attribute: "DBVersion", Content: conf.DBTypeId},
158+
{Attribute: "Name", Content: conf.GroupName},
159+
{Attribute: "Description", Content: conf.Description},
160+
{Attribute: "Modifiable", Content: strconv.FormatBool(conf.Modifiable)},
161+
{Attribute: "Zone", Content: conf.Zone},
162162
}
163163
fmt.Fprintln(out, "Attributes:")
164164
base.PrintList(attrs, out)
@@ -428,7 +428,7 @@ func NewCmdUDBConfApply(out io.Writer) *cobra.Command {
428428
var udbIDs []string
429429
var restart, yes, async bool
430430

431-
req := base.BizClient.NewChangeUDBParamGroupRequest()
431+
req := base.BizClient.UDBClient.NewChangeUDBParamGroupRequest()
432432
cmd := &cobra.Command{
433433
Use: "apply",
434434
Short: "Apply configuration for UDB instances",
@@ -437,7 +437,7 @@ func NewCmdUDBConfApply(out io.Writer) *cobra.Command {
437437
req.GroupId = sdk.String(base.PickResourceID(confID))
438438
for _, idname := range udbIDs {
439439
req.DBId = sdk.String(base.PickResourceID(idname))
440-
_, err := base.BizClient.ChangeUDBParamGroup(req)
440+
_, err := base.BizClient.UDBClient.ChangeUDBParamGroup(req)
441441
if err != nil {
442442
base.HandleError(err)
443443
continue
@@ -498,7 +498,7 @@ func NewCmdUDBConfApply(out io.Writer) *cobra.Command {
498498
//NewCmdUDBConfDownload ucloud udb conf download
499499
func NewCmdUDBConfDownload(out io.Writer) *cobra.Command {
500500
var confID string
501-
req := base.BizClient.NewExtractUDBParamGroupRequest()
501+
req := base.BizClient.UDBClient.NewExtractUDBParamGroupRequest()
502502
cmd := &cobra.Command{
503503
Use: "download",
504504
Short: "Download UDB configuration",
@@ -511,7 +511,7 @@ func NewCmdUDBConfDownload(out io.Writer) *cobra.Command {
511511
}
512512

513513
req.GroupId = &id
514-
resp, err := base.BizClient.ExtractUDBParamGroup(req)
514+
resp, err := base.BizClient.UDBClient.ExtractUDBParamGroup(req)
515515
if err != nil {
516516
base.HandleError(err)
517517
return

0 commit comments

Comments
 (0)