-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.go
165 lines (133 loc) · 4.58 KB
/
node.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package cmd
import (
"github.com/spf13/cobra"
"github.com/jmleefree/actiontest2/src/grpc-api/logger"
)
// ===== [ Constants and Variables ] =====
// ===== [ Types ] =====
// ===== [ Implementations ] =====
// ===== [ Private Functions ] =====
// ===== [ Public Functions ] =====
// NewNodeCmd - Cloud Node 관리 기능을 수행하는 Cobra Command 생성
func NewNodeCmd() *cobra.Command {
nodeCmd := &cobra.Command{
Use: "node",
Short: "This is a manageable command for cloud node",
Long: "This is a manageable command for cloud node",
}
// Adds the commands for application.
nodeCmd.AddCommand(NewNodeAddCmd())
nodeCmd.AddCommand(NewNodeListCmd())
nodeCmd.AddCommand(NewNodeGetCmd())
nodeCmd.AddCommand(NewNodeRemoveCmd())
return nodeCmd
}
// NewNodeAddCmd - Cloud Node 생성 기능을 수행하는 Cobra Command 생성
func NewNodeAddCmd() *cobra.Command {
addCmd := &cobra.Command{
Use: "add",
Short: "This is add command for cloud node",
Long: "This is add command for cloud node",
Run: func(cmd *cobra.Command, args []string) {
logger := logger.NewLogger()
readInDataFromFile()
if inData == "" {
logger.Error("failed to validate --indata parameter")
return
}
logger.Debug("--indata parameter value : \n", inData)
logger.Debug("--infile parameter value : ", inFile)
SetupAndRun(cmd, args)
},
}
addCmd.PersistentFlags().StringVarP(&inData, "indata", "d", "", "input string data")
addCmd.PersistentFlags().StringVarP(&inFile, "infile", "f", "", "input file path")
return addCmd
}
// NewNodeListCmd - Cloud Node 목록 기능을 수행하는 Cobra Command 생성
func NewNodeListCmd() *cobra.Command {
listCmd := &cobra.Command{
Use: "list",
Short: "This is list command for cloud node",
Long: "This is list command for cloud node",
Run: func(cmd *cobra.Command, args []string) {
logger := logger.NewLogger()
if nameSpaceID == "" {
logger.Error("failed to validate --ns parameter")
return
}
if clusterName == "" {
logger.Error("failed to validate --cluster parameter")
return
}
logger.Debug("--ns parameter value : ", nameSpaceID)
logger.Debug("--cluster parameter value : ", clusterName)
SetupAndRun(cmd, args)
},
}
listCmd.PersistentFlags().StringVarP(&nameSpaceID, "ns", "", "", "namespace id")
listCmd.PersistentFlags().StringVarP(&clusterName, "cluster", "", "", "cluster name")
return listCmd
}
// NewNodeGetCmd - Cloud Node 조회 기능을 수행하는 Cobra Command 생성
func NewNodeGetCmd() *cobra.Command {
getCmd := &cobra.Command{
Use: "get",
Short: "This is get command for cloud node",
Long: "This is get command for cloud node",
Run: func(cmd *cobra.Command, args []string) {
logger := logger.NewLogger()
if nameSpaceID == "" {
logger.Error("failed to validate --ns parameter")
return
}
if clusterName == "" {
logger.Error("failed to validate --cluster parameter")
return
}
if nodeName == "" {
logger.Error("failed to validate --node parameter")
return
}
logger.Debug("--ns parameter value : ", nameSpaceID)
logger.Debug("--cluster parameter value : ", clusterName)
logger.Debug("--node parameter value : ", nodeName)
SetupAndRun(cmd, args)
},
}
getCmd.PersistentFlags().StringVarP(&nameSpaceID, "ns", "", "", "namespace id")
getCmd.PersistentFlags().StringVarP(&clusterName, "cluster", "", "", "cluster name")
getCmd.PersistentFlags().StringVarP(&nodeName, "node", "", "", "node name")
return getCmd
}
// NewNodeRemoveCmd - Cloud Node 삭제 기능을 수행하는 Cobra Command 생성
func NewNodeRemoveCmd() *cobra.Command {
removeCmd := &cobra.Command{
Use: "remove",
Short: "This is remove command for cloud node",
Long: "This is remove command for cloud node",
Run: func(cmd *cobra.Command, args []string) {
logger := logger.NewLogger()
if nameSpaceID == "" {
logger.Error("failed to validate --ns parameter")
return
}
if clusterName == "" {
logger.Error("failed to validate --cluster parameter")
return
}
if nodeName == "" {
logger.Error("failed to validate --node parameter")
return
}
logger.Debug("--ns parameter value : ", nameSpaceID)
logger.Debug("--cluster parameter value : ", clusterName)
logger.Debug("--node parameter value : ", nodeName)
SetupAndRun(cmd, args)
},
}
removeCmd.PersistentFlags().StringVarP(&nameSpaceID, "ns", "", "", "namespace id")
removeCmd.PersistentFlags().StringVarP(&clusterName, "cluster", "", "", "cluster name")
removeCmd.PersistentFlags().StringVarP(&nodeName, "node", "", "", "node name")
return removeCmd
}