MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / listClusters

Function listClusters

cmd/client/command/list.go:109–134  ·  view source on GitHub ↗
(cli *client)

Source from the content-addressed store, hash-verified

107}
108
109func listClusters(cli *client) error {
110 rsp, err := cli.restyCli.R().
111 SetPathParam("namespace", listOptions.namespace).
112 Get("/namespaces/{namespace}/clusters")
113 if err != nil {
114 return err
115 }
116 if rsp.IsError() {
117 return unmarshalError(rsp.Body())
118 }
119
120 var result struct {
121 Clusters []string `json:"clusters"`
122 }
123 if err := unmarshalData(rsp.Body(), &result); err != nil {
124 return err
125 }
126 if len(result.Clusters) == 0 {
127 printLine("no cluster found.")
128 return nil
129 }
130 for _, cluster := range result.Clusters {
131 printLine(cluster)
132 }
133 return nil
134}
135
136func init() {
137 ListCommand.Flags().StringVarP(&listOptions.namespace, "namespace", "n", "", "The namespace")

Callers 1

list.goFile · 0.85

Calls 4

unmarshalErrorFunction · 0.85
unmarshalDataFunction · 0.85
printLineFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected