-
Notifications
You must be signed in to change notification settings - Fork 2
/
region.go
133 lines (103 loc) · 3.58 KB
/
region.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
// gRPC Runtime of CB-Spider.
// The CB-Spider is a sub-Framework of the Cloud-Barista Multi-Cloud Project.
// The CB-Spider Mission is to connect all the clouds with a single interface.
//
// * Cloud-Barista: https://github.com/cloud-barista
//
// by CB-Spider Team, 2020.09.
package cmd
import (
"github.com/spf13/cobra"
"github.com/cloud-barista/poc-cicd-spider/api-runtime/grpc-runtime/logger"
)
// ===== [ Constants and Variables ] =====
// ===== [ Types ] =====
// ===== [ Implementations ] =====
// ===== [ Private Functions ] =====
// ===== [ Public Functions ] =====
// NewRegionCmd - Region 관리 기능을 수행하는 Cobra Command 생성
func NewRegionCmd() *cobra.Command {
regionCmd := &cobra.Command{
Use: "region",
Short: "This is a manageable command for region",
Long: "This is a manageable command for region",
}
// Adds the commands for application.
regionCmd.AddCommand(NewRegionCreateCmd())
regionCmd.AddCommand(NewRegionListCmd())
regionCmd.AddCommand(NewRegionGetCmd())
regionCmd.AddCommand(NewRegionDeleteCmd())
return regionCmd
}
// NewRegionCreateCmd - Region 생성 기능을 수행하는 Cobra Command 생성
func NewRegionCreateCmd() *cobra.Command {
createCmd := &cobra.Command{
Use: "create",
Short: "This is create command for region",
Long: "This is create command for region",
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)
},
}
createCmd.PersistentFlags().StringVarP(&inData, "indata", "d", "", "input string data")
createCmd.PersistentFlags().StringVarP(&inFile, "infile", "f", "", "input file path")
return createCmd
}
// NewRegionListCmd - Region 목록 기능을 수행하는 Cobra Command 생성
func NewRegionListCmd() *cobra.Command {
listCmd := &cobra.Command{
Use: "list",
Short: "This is list command for region",
Long: "This is list command for region",
Run: func(cmd *cobra.Command, args []string) {
SetupAndRun(cmd, args)
},
}
return listCmd
}
// NewRegionGetCmd - Region 조회 기능을 수행하는 Cobra Command 생성
func NewRegionGetCmd() *cobra.Command {
getCmd := &cobra.Command{
Use: "get",
Short: "This is get command for region",
Long: "This is get command for region",
Run: func(cmd *cobra.Command, args []string) {
logger := logger.NewLogger()
if regionName == "" {
logger.Error("failed to validate --name parameter")
return
}
logger.Debug("--name parameter value : ", regionName)
SetupAndRun(cmd, args)
},
}
getCmd.PersistentFlags().StringVarP(®ionName, "name", "n", "", "region name")
return getCmd
}
// NewRegionDeleteCmd - Region 삭제 기능을 수행하는 Cobra Command 생성
func NewRegionDeleteCmd() *cobra.Command {
deleteCmd := &cobra.Command{
Use: "delete",
Short: "This is delete command for region",
Long: "This is delete command for region",
Run: func(cmd *cobra.Command, args []string) {
logger := logger.NewLogger()
if regionName == "" {
logger.Error("failed to validate --name parameter")
return
}
logger.Debug("--name parameter value : ", regionName)
SetupAndRun(cmd, args)
},
}
deleteCmd.PersistentFlags().StringVarP(®ionName, "name", "n", "", "region name")
return deleteCmd
}