-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmdConnectorList.go
61 lines (53 loc) · 1.14 KB
/
cmdConnectorList.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"log"
"io/ioutil"
"encoding/json"
"github.com/spf13/cobra"
)
var cmdConnectorList = &cobra.Command{
Use: "list",
Short: "List connectors",
Run: func(cmd *cobra.Command, args []string) {
url := GetKafkaConnectUrl("connectors")
resp, err := httpClient.Get(url);
if err != nil {
log.Fatal(err)
return
}
body, err := ioutil.ReadAll(resp.Body);
defer resp.Body.Close()
if err != nil {
log.Fatal(err)
return
}
var arr []string
if err = json.Unmarshal(body, &arr); err != nil {
log.Fatal("Failed to print json", err)
return
}
if len(arr) == 0 {
fmt.Println("no connectors.")
return
}
for _, connector := range arr {
fmt.Println(connector)
}
},
}
// type ConnectorResponse struct {
// State string `json:"state"`
// WorkerId string `json:"worker_id"`
// }
// type TaskResponse struct {
// Id int `json:"id"`
// State string `json:"state"`
// WorkerId string `json:"worker_id"`
// }
// type StatusResponse struct {
// Name string `json:"name"`
// Type string `json:"type"`
// Connector ConnectorResponse `json:"connector"`
// Tasks []TaskResponse `json:"tasks"`
// }