-
Notifications
You must be signed in to change notification settings - Fork 38
/
node-list.go
41 lines (32 loc) · 812 Bytes
/
node-list.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
package main
import (
"os"
"github.com/darxkies/k8s-tew/pkg/utils"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func listNodes() error {
// Load config and check the rights
if error := bootstrap(false); error != nil {
return error
}
utils.SetProgressSteps(1)
for name, node := range _config.Config.Nodes {
log.WithFields(log.Fields{"index": node.Index, "name": name, "ip": node.IP, "labels": node.Labels}).Info("Node")
}
return nil
}
var nodeListCmd = &cobra.Command{
Use: "node-list",
Short: "List nodes",
Long: "List nodes",
Run: func(cmd *cobra.Command, args []string) {
if error := listNodes(); error != nil {
log.WithFields(log.Fields{"error": error}).Error("Failed to list nodes")
os.Exit(-1)
}
},
}
func init() {
RootCmd.AddCommand(nodeListCmd)
}