-
Notifications
You must be signed in to change notification settings - Fork 2
/
credential.go
133 lines (103 loc) · 3.62 KB
/
credential.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 ] =====
// NewCredentialCmd - Credential 관리 기능을 수행하는 Cobra Command 생성
func NewCredentialCmd() *cobra.Command {
credentialCmd := &cobra.Command{
Use: "credential",
Short: "This is a manageable command for credential",
Long: "This is a manageable command for credential",
}
// Adds the commands for application.
credentialCmd.AddCommand(NewCredentialCreateCmd())
credentialCmd.AddCommand(NewCredentialListCmd())
credentialCmd.AddCommand(NewCredentialGetCmd())
credentialCmd.AddCommand(NewCredentialDeleteCmd())
return credentialCmd
}
// NewCredentialCreateCmd -Credential 생성 기능을 수행하는 Cobra Command 생성
func NewCredentialCreateCmd() *cobra.Command {
createCmd := &cobra.Command{
Use: "create",
Short: "This is create command for credential",
Long: "This is create command for credential",
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
}
// NewCredentialListCmd - Credential 목록 기능을 수행하는 Cobra Command 생성
func NewCredentialListCmd() *cobra.Command {
listCmd := &cobra.Command{
Use: "list",
Short: "This is list command for credential",
Long: "This is list command for credential",
Run: func(cmd *cobra.Command, args []string) {
SetupAndRun(cmd, args)
},
}
return listCmd
}
// NewCredentialGetCmd - Credential 조회 기능을 수행하는 Cobra Command 생성
func NewCredentialGetCmd() *cobra.Command {
getCmd := &cobra.Command{
Use: "get",
Short: "This is get command for credential",
Long: "This is get command for credential",
Run: func(cmd *cobra.Command, args []string) {
logger := logger.NewLogger()
if credentialName == "" {
logger.Error("failed to validate --name parameter")
return
}
logger.Debug("--name parameter value : ", credentialName)
SetupAndRun(cmd, args)
},
}
getCmd.PersistentFlags().StringVarP(&credentialName, "name", "n", "", "crendential name")
return getCmd
}
// NewCredentialDeleteCmd - Credential 삭제 기능을 수행하는 Cobra Command 생성
func NewCredentialDeleteCmd() *cobra.Command {
deleteCmd := &cobra.Command{
Use: "delete",
Short: "This is delete command for credential",
Long: "This is delete command for credential",
Run: func(cmd *cobra.Command, args []string) {
logger := logger.NewLogger()
if credentialName == "" {
logger.Error("failed to validate --name parameter")
return
}
logger.Debug("--name parameter value : ", credentialName)
SetupAndRun(cmd, args)
},
}
deleteCmd.PersistentFlags().StringVarP(&credentialName, "name", "n", "", "crendential name")
return deleteCmd
}