Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions go/cmd/vtctldclient/command/topology.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2022 The Vitess Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package command

import (
"fmt"

"github.com/spf13/cobra"

"vitess.io/vitess/go/cmd/vtctldclient/cli"

vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata"
)

var (
// GetTopologyPath makes a GetTopologyPath gRPC call to a vtctld.
GetTopologyPath = &cobra.Command{
Use: "GetTopologyPath <path>",
Short: "Gets the file located at the specified path in the topology server.",
DisableFlagsInUseLine: true,
Args: cobra.ExactArgs(1),
RunE: commandGetTopologyPath,
}
)

func commandGetTopologyPath(cmd *cobra.Command, args []string) error {
path := cmd.Flags().Arg(0)

cli.FinishedParsing(cmd)

resp, err := client.GetTopologyPath(commandCtx, &vtctldatapb.GetTopologyPathRequest{
Path: path,
})
if err != nil {
return err
}

data, err := cli.MarshalJSON(resp.Cell)
if err != nil {
return err
}

fmt.Printf("%s\n", data)

return nil
}

func init() {
Root.AddCommand(GetTopologyPath)
}
4 changes: 2 additions & 2 deletions go/cmd/zk/zkcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import (
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/topo/zk2topo"
"vitess.io/vitess/go/vt/vtctl"
)

var doc = `
Expand Down Expand Up @@ -588,7 +588,7 @@ func cmdCat(ctx context.Context, subFlags *pflag.FlagSet, args []string) error {
}
decoded := ""
if decodeProto {
decoded, err = vtctl.DecodeContent(zkPath, data, false)
decoded, err = topo.DecodeContent(zkPath, data, false)
if err != nil {
log.Warningf("cat: cannot proto decode %v: %v", zkPath, err)
decoded = string(data)
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vtctldclient.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Available Commands:
GetTablet Outputs a JSON structure that contains information about the tablet.
GetTabletVersion Print the version of a tablet from its debug vars.
GetTablets Looks up tablets according to filter criteria.
GetTopologyPath Gets the file located at the specified path in the topology server.
GetVSchema Prints a JSON representation of a keyspace's topo record.
GetWorkflows Gets all vreplication workflows (Reshard, MoveTables, etc) in the given keyspace.
InitShardPrimary Sets the initial primary for the shard.
Expand Down
Loading