-
Notifications
You must be signed in to change notification settings - Fork 2
/
root.go
100 lines (78 loc) · 2.63 KB
/
root.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
// 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 - 어플리케이션 실행을 위한 Cobra 기반의 CLI Commands 기능 제공
package cmd
import (
"fmt"
"github.com/cloud-barista/poc-cicd-spider/api-runtime/grpc-runtime/config"
"github.com/spf13/cobra"
)
// ===== [ Constants and Variables ] =====
var (
Version string = "latest"
CommitSHA string = "development build"
Time string = ""
User string = ""
)
var (
configFile string
inData string
inFile string
inType string
outType string
driverName string
credentialName string
regionName string
configName string
connectionName string
imageName string
specName string
vpcName string
subnetName string
securityName string
keypairName string
vmName string
action string
cspID string
force string
parser config.Parser
)
// ===== [ Types ] =====
// ===== [ Implementations ] =====
// ===== [ Private Functions ] =====
// ===== [ Public Functions ] =====
// NewRootCmd - 어플리케이션 진입점으로 사용할 Root Cobra Command 생성
func NewRootCmd() *cobra.Command {
rootCmd := &cobra.Command{
Use: "spctl",
Version: fmt.Sprintf("%s, build %s", Version, CommitSHA),
Short: "spctl is an cb-spider grpc cli tool",
Long: "This is a lightweight cb-spider grpc cli tool for Cloud-Barista Spider",
}
// 옵션 플래그 설정
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "./grpc_conf.yaml", "config file")
rootCmd.PersistentFlags().StringVarP(&inType, "input", "i", "yaml", "input format (json/yaml)")
rootCmd.PersistentFlags().StringVarP(&outType, "output", "o", "yaml", "output format (json/yaml)")
// Viper 를 사용하는 설정 파서 생성
parser = config.MakeParser()
// Adds the commands for application.
rootCmd.AddCommand(NewVersionCmd())
rootCmd.AddCommand(NewOsCmd())
rootCmd.AddCommand(NewDriverCmd())
rootCmd.AddCommand(NewCredentialCmd())
rootCmd.AddCommand(NewRegionCmd())
rootCmd.AddCommand(NewConnectionCmd())
rootCmd.AddCommand(NewImageCmd())
rootCmd.AddCommand(NewVMSpecCmd())
rootCmd.AddCommand(NewVPCCmd())
rootCmd.AddCommand(NewSecurityCmd())
rootCmd.AddCommand(NewKeyPairCmd())
rootCmd.AddCommand(NewVMCmd())
rootCmd.AddCommand(NewSSHCmd())
return rootCmd
}