(cli *client)
| 107 | } |
| 108 | |
| 109 | func 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 | |
| 136 | func init() { |
| 137 | ListCommand.Flags().StringVarP(&listOptions.namespace, "namespace", "n", "", "The namespace") |
no test coverage detected