diff --git a/go/vt/vtctl/cell_info.go b/go/vt/vtctl/cell_info.go index dca4cc469bc..7af97cb10b3 100644 --- a/go/vt/vtctl/cell_info.go +++ b/go/vt/vtctl/cell_info.go @@ -23,10 +23,10 @@ import ( "context" - "vitess.io/vitess/go/vt/topo" "vitess.io/vitess/go/vt/wrangler" topodatapb "vitess.io/vitess/go/vt/proto/topodata" + vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata" ) // This file contains the Cells command group for vtctl. @@ -73,18 +73,19 @@ func commandAddCellInfo(ctx context.Context, wr *wrangler.Wrangler, subFlags *fl if err := subFlags.Parse(args); err != nil { return err } - if *root == "" { - return fmt.Errorf("root must be non-empty") - } if subFlags.NArg() != 1 { return fmt.Errorf("the argument is required for the AddCellInfo command") } cell := subFlags.Arg(0) - return wr.TopoServer().CreateCellInfo(ctx, cell, &topodatapb.CellInfo{ - ServerAddress: *serverAddress, - Root: *root, + _, err := wr.VtctldServer().AddCellInfo(ctx, &vtctldatapb.AddCellInfoRequest{ + Name: cell, + CellInfo: &topodatapb.CellInfo{ + ServerAddress: *serverAddress, + Root: *root, + }, }) + return err } func commandUpdateCellInfo(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error { @@ -98,19 +99,14 @@ func commandUpdateCellInfo(ctx context.Context, wr *wrangler.Wrangler, subFlags } cell := subFlags.Arg(0) - return wr.TopoServer().UpdateCellInfoFields(ctx, cell, func(ci *topodatapb.CellInfo) error { - if (*serverAddress == "" || ci.ServerAddress == *serverAddress) && - (*root == "" || ci.Root == *root) { - return topo.NewError(topo.NoUpdateNeeded, cell) - } - if *serverAddress != "" { - ci.ServerAddress = *serverAddress - } - if *root != "" { - ci.Root = *root - } - return nil + _, err := wr.VtctldServer().UpdateCellInfo(ctx, &vtctldatapb.UpdateCellInfoRequest{ + Name: cell, + CellInfo: &topodatapb.CellInfo{ + ServerAddress: *serverAddress, + Root: *root, + }, }) + return err } func commandDeleteCellInfo(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error { @@ -123,7 +119,11 @@ func commandDeleteCellInfo(ctx context.Context, wr *wrangler.Wrangler, subFlags } cell := subFlags.Arg(0) - return wr.TopoServer().DeleteCellInfo(ctx, cell, *force) + _, err := wr.VtctldServer().DeleteCellInfo(ctx, &vtctldatapb.DeleteCellInfoRequest{ + Name: cell, + Force: *force, + }) + return err } func commandGetCellInfoNames(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error { diff --git a/go/vt/vtctl/cells_aliases.go b/go/vt/vtctl/cells_aliases.go index 195b36921ad..ecdc10eb9e9 100644 --- a/go/vt/vtctl/cells_aliases.go +++ b/go/vt/vtctl/cells_aliases.go @@ -26,6 +26,7 @@ import ( "vitess.io/vitess/go/vt/wrangler" topodatapb "vitess.io/vitess/go/vt/proto/topodata" + vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata" ) // This file contains the CellsAliases command group for vtctl. @@ -75,10 +76,11 @@ func commandAddCellsAlias(ctx context.Context, wr *wrangler.Wrangler, subFlags * } alias := subFlags.Arg(0) - - return wr.TopoServer().CreateCellsAlias(ctx, alias, &topodatapb.CellsAlias{ + _, err := wr.VtctldServer().AddCellsAlias(ctx, &vtctldatapb.AddCellsAliasRequest{ + Name: alias, Cells: cells, }) + return err } func commandUpdateCellsAlias(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error { @@ -96,11 +98,13 @@ func commandUpdateCellsAlias(ctx context.Context, wr *wrangler.Wrangler, subFlag } alias := subFlags.Arg(0) - - return wr.TopoServer().UpdateCellsAlias(ctx, alias, func(ca *topodatapb.CellsAlias) error { - ca.Cells = cells - return nil + _, err := wr.VtctldServer().UpdateCellsAlias(ctx, &vtctldatapb.UpdateCellsAliasRequest{ + Name: alias, + CellsAlias: &topodatapb.CellsAlias{ + Cells: cells, + }, }) + return err } func commandDeleteCellsAlias(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error { @@ -112,7 +116,10 @@ func commandDeleteCellsAlias(ctx context.Context, wr *wrangler.Wrangler, subFlag } alias := subFlags.Arg(0) - return wr.TopoServer().DeleteCellsAlias(ctx, alias) + _, err := wr.VtctldServer().DeleteCellsAlias(ctx, &vtctldatapb.DeleteCellsAliasRequest{ + Name: alias, + }) + return err } func commandGetCellsAliases(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error {