GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(udns): restructure to internal/udns per onboarding spec · ucloud/ucloud-cli@6693084

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • cmd
    • products.gen.go
  • products/udns
    • internal/udns
      • associate_vpc.go
      • cmd.go
      • create.go
      • disassociate_vpc.go
      • list.go
      • modify.go
      • record.go
      • record_create.go
      • record_delete.go
      • record_list.go
      • record_modify.go
      • rows.go
    • product.go
    • product.yaml
    • testdata
      • cmdtree.golden
      • completion.golden
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cmd/products.gen.go‎

Copy file name to clipboardExpand all lines: cmd/products.gen.go
+2Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎products/udns/associate_vpc.go‎ ‎…ucts/udns/internal/udns/associate_vpc.go‎products/udns/associate_vpc.go renamed to products/udns/internal/udns/associate_vpc.go products/udns/associate_vpc.go renamed to products/udns/internal/udns/associate_vpc.go

Copy file name to clipboardExpand all lines: products/udns/internal/udns/associate_vpc.go
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/ucloud/ucloud-cli/pkg/cli"
1111
)
1212

13-
// newAssociateVPCCommand builds `udns associate-vpc` (AssociateUDNSZoneVPC).
1413
func newAssociateVPCCommand(ctx *cli.Context) *cobra.Command {
1514
client := cli.NewServiceClient(ctx, udnssdk.NewClient)
1615
req := client.NewAssociateUDNSZoneVPCRequest()
Collapse file

‎products/udns/internal/udns/cmd.go‎

Copy file name to clipboard
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package udns
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
6+
"github.com/ucloud/ucloud-cli/pkg/cli"
7+
)
8+
9+
func NewCommand(ctx *cli.Context) *cobra.Command {
10+
root := &cobra.Command{
11+
Use: "udns",
12+
Short: "List and manipulate ucloud private dns(udns) instance and record",
13+
Long: "List and manipulate ucloud private dns(udns) instance and record",
14+
}
15+
root.AddCommand(newCreateCommand(ctx))
16+
root.AddCommand(newListCommand(ctx))
17+
root.AddCommand(newModifyCommand(ctx))
18+
root.AddCommand(newAssociateVPCCommand(ctx))
19+
root.AddCommand(newDisassociateVPCCommand(ctx))
20+
root.AddCommand(newRecordCommand(ctx))
21+
return root
22+
}
Collapse file

‎products/udns/create.go‎ ‎products/udns/internal/udns/create.go‎products/udns/create.go renamed to products/udns/internal/udns/create.go

Copy file name to clipboardExpand all lines: products/udns/internal/udns/create.go
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88
udnssdk "github.com/ucloud/ucloud-sdk-go/services/udns"
99

1010
"github.com/ucloud/ucloud-cli/pkg/cli"
11+
"github.com/ucloud/ucloud-cli/pkg/command"
1112
)
1213

13-
// NewCreateCommand builds `udns create` (CreateUDNSZone).
14-
func NewCreateCommand(ctx *cli.Context) *cobra.Command {
14+
func newCreateCommand(ctx *cli.Context) *cobra.Command {
1515
client := cli.NewServiceClient(ctx, udnssdk.NewClient)
1616
req := client.NewCreateUDNSZoneRequest()
1717
cmd := &cobra.Command{
@@ -39,9 +39,9 @@ func NewCreateCommand(ctx *cli.Context) *cobra.Command {
3939
req.Remark = flags.String("remark", "", "Optional. Remark")
4040
ctx.BindRegion(cmd, req)
4141
ctx.BindProjectID(cmd, req)
42-
ctx.SetFlagValues(cmd, "type", "private", "public")
43-
ctx.SetFlagValues(cmd, "charge-type", "Month", "Year", "Dynamic")
44-
ctx.SetFlagValues(cmd, "recursion", "enable", "disable")
42+
command.SetFlagValues(cmd, "type", "private", "public")
43+
command.SetFlagValues(cmd, "charge-type", "Month", "Year", "Dynamic")
44+
command.SetFlagValues(cmd, "recursion", "enable", "disable")
4545
cmd.MarkFlagRequired("zone-name")
4646
cmd.MarkFlagRequired("type")
4747
return cmd
Collapse file

‎products/udns/disassociate_vpc.go‎ ‎…s/udns/internal/udns/disassociate_vpc.go‎products/udns/disassociate_vpc.go renamed to products/udns/internal/udns/disassociate_vpc.go products/udns/disassociate_vpc.go renamed to products/udns/internal/udns/disassociate_vpc.go

Copy file name to clipboardExpand all lines: products/udns/internal/udns/disassociate_vpc.go
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/ucloud/ucloud-cli/pkg/cli"
1111
)
1212

13-
// newDisassociateVPCCommand builds `udns disassociate-vpc` (DisassociateUDNSZoneVPC).
1413
func newDisassociateVPCCommand(ctx *cli.Context) *cobra.Command {
1514
client := cli.NewServiceClient(ctx, udnssdk.NewClient)
1615
req := client.NewDisassociateUDNSZoneVPCRequest()
Collapse file

‎products/udns/list.go‎ ‎products/udns/internal/udns/list.go‎products/udns/list.go renamed to products/udns/internal/udns/list.go

Copy file name to clipboardExpand all lines: products/udns/internal/udns/list.go
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/ucloud/ucloud-cli/pkg/cli"
1212
)
1313

14-
// newListCommand builds `udns list` (DescribeUDNSZone).
1514
func newListCommand(ctx *cli.Context) *cobra.Command {
1615
client := cli.NewServiceClient(ctx, udnssdk.NewClient)
1716
req := client.NewDescribeUDNSZoneRequest()
@@ -27,7 +26,7 @@ func newListCommand(ctx *cli.Context) *cobra.Command {
2726
ctx.HandleError(err)
2827
return
2928
}
30-
rows := make([]ZoneRow, 0, len(resp.DNSZoneInfos))
29+
rows := make([]zoneRow, 0, len(resp.DNSZoneInfos))
3130
for _, z := range resp.DNSZoneInfos {
3231
rows = append(rows, toZoneRow(z))
3332
}
@@ -44,12 +43,12 @@ func newListCommand(ctx *cli.Context) *cobra.Command {
4443
return cmd
4544
}
4645

47-
func toZoneRow(z udnssdk.ZoneInfo) ZoneRow {
46+
func toZoneRow(z udnssdk.ZoneInfo) zoneRow {
4847
vpcIDs := make([]string, 0, len(z.VPCInfos))
4948
for _, v := range z.VPCInfos {
5049
vpcIDs = append(vpcIDs, v.VPCId)
5150
}
52-
return ZoneRow{
51+
return zoneRow{
5352
ZoneID: z.DNSZoneId,
5453
Name: z.DNSZoneName,
5554
ChargeType: z.ChargeType,
Collapse file

‎products/udns/modify.go‎ ‎products/udns/internal/udns/modify.go‎products/udns/modify.go renamed to products/udns/internal/udns/modify.go

Copy file name to clipboardExpand all lines: products/udns/internal/udns/modify.go
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
udnssdk "github.com/ucloud/ucloud-sdk-go/services/udns"
99

1010
"github.com/ucloud/ucloud-cli/pkg/cli"
11+
"github.com/ucloud/ucloud-cli/pkg/command"
1112
)
1213

13-
// newModifyCommand builds `udns modify` (ModifyUDNSZone).
1414
func newModifyCommand(ctx *cli.Context) *cobra.Command {
1515
client := cli.NewServiceClient(ctx, udnssdk.NewClient)
1616
req := client.NewModifyUDNSZoneRequest()
@@ -37,7 +37,7 @@ func newModifyCommand(ctx *cli.Context) *cobra.Command {
3737
req.Remark = flags.String("remark", "", "Optional. Remark")
3838
ctx.BindRegion(cmd, req)
3939
ctx.BindProjectID(cmd, req)
40-
ctx.SetFlagValues(cmd, "recursion", "enable", "disable")
40+
command.SetFlagValues(cmd, "recursion", "enable", "disable")
4141
cmd.MarkFlagRequired("zone-id")
4242
return cmd
4343
}
Collapse file

‎products/udns/record.go‎ ‎products/udns/internal/udns/record.go‎products/udns/record.go renamed to products/udns/internal/udns/record.go

Copy file name to clipboardExpand all lines: products/udns/internal/udns/record.go
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/ucloud/ucloud-cli/pkg/cli"
77
)
88

9-
// newRecordCommand builds the `udns record` subgroup.
109
func newRecordCommand(ctx *cli.Context) *cobra.Command {
1110
cmd := &cobra.Command{
1211
Use: "record",
Collapse file

‎products/udns/record_create.go‎ ‎…ucts/udns/internal/udns/record_create.go‎products/udns/record_create.go renamed to products/udns/internal/udns/record_create.go products/udns/record_create.go renamed to products/udns/internal/udns/record_create.go

Copy file name to clipboardExpand all lines: products/udns/internal/udns/record_create.go
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
udnssdk "github.com/ucloud/ucloud-sdk-go/services/udns"
99

1010
"github.com/ucloud/ucloud-cli/pkg/cli"
11+
"github.com/ucloud/ucloud-cli/pkg/command"
1112
)
1213

13-
// newRecordCreateCommand builds `udns record create` (CreateUDNSRecord).
1414
func newRecordCreateCommand(ctx *cli.Context) *cobra.Command {
1515
client := cli.NewServiceClient(ctx, udnssdk.NewClient)
1616
req := client.NewCreateUDNSRecordRequest()
@@ -39,8 +39,8 @@ func newRecordCreateCommand(ctx *cli.Context) *cobra.Command {
3939
req.Remark = flags.String("remark", "", "Optional. Remark")
4040
ctx.BindRegion(cmd, req)
4141
ctx.BindProjectID(cmd, req)
42-
ctx.SetFlagValues(cmd, "type", "A", "AAAA", "CNAME", "MX", "TXT", "SRV", "PTR")
43-
ctx.SetFlagValues(cmd, "value-type", "Normal", "Multivalue")
42+
command.SetFlagValues(cmd, "type", "A", "AAAA", "CNAME", "MX", "TXT", "SRV", "PTR")
43+
command.SetFlagValues(cmd, "value-type", "Normal", "Multivalue")
4444
cmd.MarkFlagRequired("zone-id")
4545
cmd.MarkFlagRequired("name")
4646
cmd.MarkFlagRequired("type")
Collapse file

‎products/udns/record_delete.go‎ ‎…ucts/udns/internal/udns/record_delete.go‎products/udns/record_delete.go renamed to products/udns/internal/udns/record_delete.go products/udns/record_delete.go renamed to products/udns/internal/udns/record_delete.go

Copy file name to clipboardExpand all lines: products/udns/internal/udns/record_delete.go
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,29 @@ import (
1010
"github.com/ucloud/ucloud-cli/pkg/cli"
1111
)
1212

13-
// newRecordDeleteCommand builds `udns record delete` (DeleteUDNSRecord).
1413
func newRecordDeleteCommand(ctx *cli.Context) *cobra.Command {
1514
client := cli.NewServiceClient(ctx, udnssdk.NewClient)
1615
req := client.NewDeleteUDNSRecordRequest()
1716
var recordIDs []string
17+
var yes bool
1818
cmd := &cobra.Command{
1919
Use: "delete",
2020
Short: "Delete DNS records from a UDNS zone",
2121
Long: "Delete DNS records from a UDNS zone",
2222
Run: func(cmd *cobra.Command, args []string) {
23+
ok, err := ctx.Confirm(yes, "Are you sure you want to delete the record(s)?")
24+
if err != nil {
25+
ctx.HandleError(err)
26+
return
27+
}
28+
if !ok {
29+
return
30+
}
2331
for i, id := range recordIDs {
2432
recordIDs[i] = ctx.PickResourceID(id)
2533
}
2634
req.RecordIds = recordIDs
27-
_, err := client.DeleteUDNSRecord(req)
35+
_, err = client.DeleteUDNSRecord(req)
2836
if err != nil {
2937
ctx.HandleError(err)
3038
return
@@ -41,6 +49,7 @@ func newRecordDeleteCommand(ctx *cli.Context) *cobra.Command {
4149
flags.SortFlags = false
4250
req.DNSZoneId = flags.String("zone-id", "", "Required. Zone resource ID")
4351
flags.StringSliceVar(&recordIDs, "record-id", nil, "Required. Record resource ID (repeatable)")
52+
flags.BoolVarP(&yes, "yes", "y", false, "Optional. Skip the confirmation prompt.")
4453
ctx.BindRegion(cmd, req)
4554
ctx.BindProjectID(cmd, req)
4655
cmd.MarkFlagRequired("zone-id")

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.