| 75 | } |
| 76 | |
| 77 | func importCluster(client *client, options *ImportOptions) error { |
| 78 | rsp, err := client.restyCli.R(). |
| 79 | SetPathParam("namespace", options.namespace). |
| 80 | SetPathParam("cluster", options.cluster). |
| 81 | SetBody(map[string]interface{}{ |
| 82 | "nodes": options.nodes, |
| 83 | "password": options.password, |
| 84 | }). |
| 85 | Post("/namespaces/{namespace}/clusters/{cluster}/import") |
| 86 | if err != nil { |
| 87 | return err |
| 88 | } |
| 89 | if rsp.IsError() { |
| 90 | return errors.New(rsp.String()) |
| 91 | } |
| 92 | printLine("import cluster: %s successfully.", options.cluster) |
| 93 | return nil |
| 94 | } |
| 95 | |
| 96 | func init() { |
| 97 | ImportCommand.Flags().StringVarP(&importOptions.namespace, "namespace", "n", "", "The namespace of the cluster") |