diff --git a/ansi/code.go b/ansi/code.go index f702a87516..22956a2525 100644 --- a/ansi/code.go +++ b/ansi/code.go @@ -1,4 +1,4 @@ -//Package ansi reference https://github.com/sindresorhus/ansi-escapes +// Package ansi reference https://github.com/sindresorhus/ansi-escapes package ansi import ( @@ -9,26 +9,26 @@ const csi = "\x1b[" const sep = ";" -//CursorLeft move cursor to the left side +// CursorLeft move cursor to the left side var CursorLeft = fmt.Sprintf("%sG", csi) -//EraseDown Erase the screen from the current line down to the bottom of the +// EraseDown Erase the screen from the current line down to the bottom of the var EraseDown = fmt.Sprintf("%sJ", csi) -//EraseUp Erase the screen from the current line up to the top of the screen +// EraseUp Erase the screen from the current line up to the top of the screen var EraseUp = fmt.Sprintf("%s1J", csi) -//CursorUp Move cursor up a specific amount of rows. +// CursorUp Move cursor up a specific amount of rows. func CursorUp(count int) string { return fmt.Sprintf("%s%dA", csi, count) } -//CursorPrevLine Move cursor up a specific amount of rows. +// CursorPrevLine Move cursor up a specific amount of rows. func CursorPrevLine(count int) string { return fmt.Sprintf("%s%dF", csi, count) } -//CursorTo Set the absolute position of the cursor. `x` `y` is the top left of the screen. +// CursorTo Set the absolute position of the cursor. `x` `y` is the top left of the screen. func CursorTo(x, y int) string { return fmt.Sprintf("%s%d;%dH", csi, y+1, x+1) } diff --git a/base/client.go b/base/client.go index 404c8c922d..307e857790 100644 --- a/base/client.go +++ b/base/client.go @@ -22,19 +22,19 @@ import ( "github.com/ucloud/ucloud-sdk-go/ucloud/request" ) -//PrivateUHostClient 私有模块的uhost client 即未在官网开放的接口 +// PrivateUHostClient 私有模块的uhost client 即未在官网开放的接口 type PrivateUHostClient = puhost.UHostClient -//PrivateUDBClient 私有模块的udb client 即未在官网开放的接口 +// PrivateUDBClient 私有模块的udb client 即未在官网开放的接口 type PrivateUDBClient = pudb.UDBClient -//PrivateUMemClient 私有模块的umem client 即未在官网开放的接口 +// PrivateUMemClient 私有模块的umem client 即未在官网开放的接口 type PrivateUMemClient = pumem.UMemClient -//PrivatePathxClient 私有模块的pathx client 即未在官网开放的接口 +// PrivatePathxClient 私有模块的pathx client 即未在官网开放的接口 type PrivatePathxClient = ppathx.PathXClient -//Client aggregate client for business +// Client aggregate client for business type Client struct { uaccount.UAccountClient uhost.UHostClient diff --git a/base/log.go b/base/log.go index c6cf2576a4..da036404df 100644 --- a/base/log.go +++ b/base/log.go @@ -20,7 +20,7 @@ import ( const DefaultDasURL = "https://das-rpt.ucloud.cn/log" -//Logger 日志 +// Logger 日志 var logger *log.Logger var mu sync.Mutex var out = Cxt.GetWriter() @@ -62,22 +62,22 @@ func logCmd() { LogInfo(fmt.Sprintf("command: %s", strings.Join(args, " "))) } -//GetLogger return point of logger +// GetLogger return point of logger func GetLogger() *log.Logger { return logger } -//GetLogFileDir 获取日志文件路径 +// GetLogFileDir 获取日志文件路径 func GetLogFileDir() string { return GetHomePath() + fmt.Sprintf("/%s", ConfigPath) } -//GetLogFilePath 获取日志文件路径 +// GetLogFilePath 获取日志文件路径 func GetLogFilePath() string { return GetHomePath() + fmt.Sprintf("/%s/cli.log", ConfigPath) } -//LogInfo 记录日志 +// LogInfo 记录日志 func LogInfo(logs ...string) { _, ok := os.LookupEnv("COMP_LINE") if ok { @@ -94,7 +94,7 @@ func LogInfo(logs ...string) { } } -//LogPrint 记录日志 +// LogPrint 记录日志 func LogPrint(logs ...string) { _, ok := os.LookupEnv("COMP_LINE") if ok { @@ -112,7 +112,7 @@ func LogPrint(logs ...string) { } } -//LogWarn 记录日志 +// LogWarn 记录日志 func LogWarn(logs ...string) { _, ok := os.LookupEnv("COMP_LINE") if ok { @@ -130,7 +130,7 @@ func LogWarn(logs ...string) { } } -//LogError 记录日志 +// LogError 记录日志 func LogError(logs ...string) { _, ok := os.LookupEnv("COMP_LINE") if ok { @@ -148,7 +148,7 @@ func LogError(logs ...string) { } } -//UploadLogs send logs to das server +// UploadLogs send logs to das server func UploadLogs(logs []string, level string, goID int64) { var lines []string for _, log := range logs { @@ -158,7 +158,7 @@ func UploadLogs(logs []string, level string, goID int64) { tracer.Send(lines) } -//LogRotateHook rotate log file +// LogRotateHook rotate log file type LogRotateHook struct { MaxSize int64 Cut float32 @@ -166,12 +166,12 @@ type LogRotateHook struct { mux sync.Mutex } -//Levels fires hook +// Levels fires hook func (hook *LogRotateHook) Levels() []log.Level { return log.AllLevels } -//Fire do someting when hook is triggered +// Fire do someting when hook is triggered func (hook *LogRotateHook) Fire(entry *log.Entry) error { hook.mux.Lock() defer hook.mux.Unlock() @@ -212,7 +212,7 @@ func (hook *LogRotateHook) Fire(entry *log.Entry) error { return nil } -//NewLogRotateHook create a LogRotateHook +// NewLogRotateHook create a LogRotateHook func NewLogRotateHook(file *os.File) *LogRotateHook { return &LogRotateHook{ MaxSize: 1024 * 1024, //1MB @@ -221,7 +221,7 @@ func NewLogRotateHook(file *os.File) *LogRotateHook { } } -//ToQueryMap tranform request to map +// ToQueryMap tranform request to map func ToQueryMap(req request.Common) map[string]string { reqMap, err := request.ToQueryMap(req) if err != nil { @@ -231,7 +231,7 @@ func ToQueryMap(req request.Common) map[string]string { return reqMap } -//Tracer upload log to server if allowed +// Tracer upload log to server if allowed type Tracer struct { DasUrl string } @@ -266,7 +266,7 @@ func (t Tracer) wrapLogs(log []string) ([]byte, error) { return marshaled, nil } -//Send logs to server +// Send logs to server func (t Tracer) Send(logs []string) error { body, err := t.wrapLogs(logs) if err != nil { diff --git a/base/util.go b/base/util.go index 83cf1dcdac..d9033d8119 100644 --- a/base/util.go +++ b/base/util.go @@ -25,19 +25,19 @@ import ( "github.com/ucloud/ucloud-cli/ux" ) -//ConfigPath 配置文件路径 +// ConfigPath 配置文件路径 const ConfigPath = ".ucloud" -//GAP 表格列直接的间隔字符数 +// GAP 表格列直接的间隔字符数 const GAP = 2 -//Cxt 上下文 +// Cxt 上下文 var Cxt = model.GetContext(os.Stdout) -//SdkClient 用于上报数据 +// SdkClient 用于上报数据 var SdkClient *sdk.Client -//GetHomePath 获取家目录 +// GetHomePath 获取家目录 func GetHomePath() string { if runtime.GOOS == "windows" { home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") @@ -49,7 +49,7 @@ func GetHomePath() string { return os.Getenv("HOME") } -//MosaicString 对字符串敏感部分打马赛克 如公钥私钥 +// MosaicString 对字符串敏感部分打马赛克 如公钥私钥 func MosaicString(str string, beginChars, lastChars int) string { r := len(str) - lastChars - beginChars if r > 5 { @@ -58,7 +58,7 @@ func MosaicString(str string, beginChars, lastChars int) string { return strings.Repeat("*", len(str)) } -//AppendToFile 添加到文件中 +// AppendToFile 添加到文件中 func AppendToFile(name string, content string) error { f, err := os.OpenFile(name, os.O_RDWR|os.O_APPEND, 0) if err != nil { @@ -69,7 +69,7 @@ func AppendToFile(name string, content string) error { return err } -//LineInFile 检查某一行是否在某文件中 +// LineInFile 检查某一行是否在某文件中 func LineInFile(fileName string, lookFor string) bool { f, err := os.Open(fileName) if err != nil { @@ -98,7 +98,7 @@ func LineInFile(fileName string, lookFor string) bool { } } -//GetConfigDir 获取配置文件所在目录 +// GetConfigDir 获取配置文件所在目录 func GetConfigDir() string { path := GetHomePath() + "/" + ConfigPath if _, err := os.Stat(path); os.IsNotExist(err) { @@ -110,14 +110,14 @@ func GetConfigDir() string { return path } -//HandleBizError 处理RetCode != 0 的业务异常 +// HandleBizError 处理RetCode != 0 的业务异常 func HandleBizError(resp response.Common) error { format := "Something wrong. RetCode:%d. Message:%s\n" LogError(fmt.Sprintf(format, resp.GetRetCode(), resp.GetMessage())) return fmt.Errorf(format, resp.GetRetCode(), resp.GetMessage()) } -//HandleError 处理错误,业务错误 和 HTTP错误 +// HandleError 处理错误,业务错误 和 HTTP错误 func HandleError(err error) { if uErr, ok := err.(uerr.Error); ok && uErr.Code() != 0 { format := "Something wrong. RetCode:%d. Message:%s\n" @@ -127,7 +127,7 @@ func HandleError(err error) { } } -//ParseError 解析错误为字符串 +// ParseError 解析错误为字符串 func ParseError(err error) string { if uErr, ok := err.(uerr.Error); ok && uErr.Code() != 0 { format := "Something wrong. RetCode:%d. Message:%s" @@ -140,7 +140,7 @@ func ParseError(err error) string { return fmt.Sprintf("Error:%v", err) } -//PrintJSON 以JSON格式打印数据集合 +// PrintJSON 以JSON格式打印数据集合 func PrintJSON(dataSet interface{}, out io.Writer) error { bytes, err := json.MarshalIndent(dataSet, "", " ") if err != nil { @@ -153,7 +153,7 @@ func PrintJSON(dataSet interface{}, out io.Writer) error { return nil } -//PrintTableS 简化版表格打印,无需传表头,根据结构体反射解析 +// PrintTableS 简化版表格打印,无需传表头,根据结构体反射解析 func PrintTableS(dataSet interface{}) { dataSetVal := reflect.ValueOf(dataSet) fieldNameList := make([]string, 0) @@ -170,7 +170,7 @@ func PrintTableS(dataSet interface{}) { } } -//PrintList 打印表格或者JSON +// PrintList 打印表格或者JSON func PrintList(dataSet interface{}, out io.Writer) { if Global.JSON { PrintJSON(dataSet, out) @@ -179,7 +179,7 @@ func PrintList(dataSet interface{}, out io.Writer) { } } -//PrintDescribe 打印详情 +// PrintDescribe 打印详情 func PrintDescribe(attrs []DescribeTableRow, json bool) { if json { PrintJSON(attrs, os.Stdout) @@ -192,7 +192,7 @@ func PrintDescribe(attrs []DescribeTableRow, json bool) { } } -//PrintTable 以表格方式打印数据集合 +// PrintTable 以表格方式打印数据集合 func PrintTable(dataSet interface{}, fieldList []string) { dataSetVal := reflect.ValueOf(dataSet) switch dataSetVal.Kind() { @@ -264,7 +264,7 @@ func printTable(rowList []map[string]interface{}, fieldList []string, fieldWidth } } -//DescribeTableRow 详情表格通用表格行 +// DescribeTableRow 详情表格通用表格行 type DescribeTableRow struct { Attribute string Content string @@ -294,20 +294,20 @@ func calcWidth(text string) int { return width } -//FormatDate 格式化时间,把以秒为单位的时间戳格式化未年月日 +// FormatDate 格式化时间,把以秒为单位的时间戳格式化未年月日 func FormatDate(seconds int) string { return time.Unix(int64(seconds), 0).Format("2006-01-02") } -//DateTimeLayout 时间格式 +// DateTimeLayout 时间格式 const DateTimeLayout = "2006-01-02/15:04:05" -//FormatDateTime 格式化时间,把以秒为单位的时间戳格式化未年月日/时分秒 +// FormatDateTime 格式化时间,把以秒为单位的时间戳格式化未年月日/时分秒 func FormatDateTime(seconds int) string { return time.Unix(int64(seconds), 0).Format("2006-01-02/15:04:05") } -//RegionLabel regionlable +// RegionLabel regionlable var RegionLabel = map[string]string{ "cn-bj1": "Beijing1", "cn-bj2": "Beijing2", @@ -333,7 +333,7 @@ var RegionLabel = map[string]string{ "afr-nigeria": "Lagos", } -//Poller 轮询器 +// Poller 轮询器 type Poller struct { stateFields []string DescribeFunc func(string, string, string, string) (interface{}, error) @@ -348,7 +348,7 @@ type pollResult struct { Err error } -//Sspoll 简化版, 支持并发 +// Sspoll 简化版, 支持并发 func (p *Poller) Sspoll(resourceID, pollText string, targetStates []string, block *ux.Block) *pollResult { w := waiter.StateWaiter{ Pending: []string{"pending"}, @@ -417,7 +417,7 @@ func (p *Poller) Sspoll(resourceID, pollText string, targetStates []string, bloc return &ret } -//Spoll 简化版 +// Spoll 简化版 func (p *Poller) Spoll(resourceID, pollText string, targetStates []string) { w := waiter.StateWaiter{ Pending: []string{"pending"}, @@ -480,7 +480,7 @@ func (p *Poller) Spoll(resourceID, pollText string, targetStates []string) { } } -//Poll function +// Poll function func (p *Poller) Poll(resourceID, projectID, region, zone, pollText string, targetState []string) bool { w := waiter.StateWaiter{ Pending: []string{"pending"}, @@ -542,7 +542,7 @@ func (p *Poller) Poll(resourceID, projectID, region, zone, pollText string, targ return ret } -//NewSpoller simple +// NewSpoller simple func NewSpoller(describeFunc func(string) (interface{}, error), out io.Writer) *Poller { return &Poller{ SdescribeFunc: describeFunc, @@ -552,7 +552,7 @@ func NewSpoller(describeFunc func(string) (interface{}, error), out io.Writer) * } } -//NewPoller 轮询 +// NewPoller 轮询 func NewPoller(describeFunc func(string, string, string, string) (interface{}, error), out io.Writer) *Poller { return &Poller{ DescribeFunc: describeFunc, @@ -562,7 +562,7 @@ func NewPoller(describeFunc func(string, string, string, string) (interface{}, e } } -//PickResourceID uhost-xxx/uhost-name => uhost-xxx +// PickResourceID uhost-xxx/uhost-name => uhost-xxx func PickResourceID(str string) string { if strings.Index(str, "/") > -1 { return strings.SplitN(str, "/", 2)[0] @@ -570,7 +570,7 @@ func PickResourceID(str string) string { return str } -//WriteJSONFile 写json文件 +// WriteJSONFile 写json文件 func WriteJSONFile(list interface{}, filePath string) error { byts, err := json.Marshal(list) if err != nil { @@ -583,7 +583,7 @@ func WriteJSONFile(list interface{}, filePath string) error { return nil } -//GetFileList 补全文件名 +// GetFileList 补全文件名 func GetFileList(suffix string) []string { cmdLine := strings.TrimSpace(os.Getenv("COMP_LINE")) words := strings.Split(cmdLine, " ") @@ -621,7 +621,7 @@ func GetFileList(suffix string) []string { return names } -//Confirm 二次确认 +// Confirm 二次确认 func Confirm(yes bool, text string) bool { if yes { return true diff --git a/cmd/api.go b/cmd/api.go index 4cc4dbe0e6..523cff7522 100644 --- a/cmd/api.go +++ b/cmd/api.go @@ -13,7 +13,7 @@ import ( "github.com/ucloud/ucloud-cli/base" ) -//NewCmdAPI ucloud api --xkey xvalue +// NewCmdAPI ucloud api --xkey xvalue func NewCmdAPI(out io.Writer) *cobra.Command { return &cobra.Command{ Use: "api", diff --git a/cmd/backup.go b/cmd/backup.go index b31a400bd0..6c7d4396fc 100644 --- a/cmd/backup.go +++ b/cmd/backup.go @@ -27,7 +27,7 @@ import ( "github.com/ucloud/ucloud-cli/base" ) -//NewCmdUDBBackup ucloud udb backup +// NewCmdUDBBackup ucloud udb backup func NewCmdUDBBackup() *cobra.Command { cmd := &cobra.Command{ Use: "backup", @@ -42,7 +42,7 @@ func NewCmdUDBBackup() *cobra.Command { return cmd } -//NewCmdUDBBackupCreate ucloud udb backup create +// NewCmdUDBBackupCreate ucloud udb backup create func NewCmdUDBBackupCreate(out io.Writer) *cobra.Command { req := base.BizClient.NewBackupUDBInstanceRequest() cmd := &cobra.Command{ @@ -91,7 +91,7 @@ type udbBackupRow struct { BackupEndTime string } -//NewCmdUDBBackupList ucloud udb backup list +// NewCmdUDBBackupList ucloud udb backup list func NewCmdUDBBackupList(out io.Writer) *cobra.Command { var bpType, dbType, beginTime, endTime, backupID string bpTypeMap := map[string]int{ @@ -189,7 +189,7 @@ func NewCmdUDBBackupList(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBBackupDelete ucloud udb backup delete +// NewCmdUDBBackupDelete ucloud udb backup delete func NewCmdUDBBackupDelete(out io.Writer) *cobra.Command { ids := []int{} req := base.BizClient.NewDeleteUDBBackupRequest() @@ -222,7 +222,7 @@ func NewCmdUDBBackupDelete(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBBackupGetDownloadURL ucloud udb backup get-download-url +// NewCmdUDBBackupGetDownloadURL ucloud udb backup get-download-url func NewCmdUDBBackupGetDownloadURL(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeUDBInstanceBackupURLRequest() cmd := &cobra.Command{ @@ -255,7 +255,7 @@ func NewCmdUDBBackupGetDownloadURL(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBLog ucloud udb log +// NewCmdUDBLog ucloud udb log func NewCmdUDBLog() *cobra.Command { cmd := &cobra.Command{ Use: "logs", @@ -272,7 +272,7 @@ func NewCmdUDBLog() *cobra.Command { return cmd } -//NewCmdUDBLogArchiveCreate ucloud udb log archive create +// NewCmdUDBLogArchiveCreate ucloud udb log archive create func NewCmdUDBLogArchiveCreate(out io.Writer) *cobra.Command { var region, zone, project, udbID string var name, logType, beginTime, endTime string @@ -364,7 +364,7 @@ type udbArchiveRow struct { CreateTime string } -//NewCmdUDBLogArchiveList ucloud udb log archive list +// NewCmdUDBLogArchiveList ucloud udb log archive list func NewCmdUDBLogArchiveList(out io.Writer) *cobra.Command { var beginTime, endTime string logTypes := []string{} @@ -456,7 +456,7 @@ func NewCmdUDBLogArchiveList(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBLogArchiveGetDownloadURL ucloud udb log archive get-download-url +// NewCmdUDBLogArchiveGetDownloadURL ucloud udb log archive get-download-url func NewCmdUDBLogArchiveGetDownloadURL(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeUDBBinlogBackupURLRequest() cmd := &cobra.Command{ @@ -493,7 +493,7 @@ func NewCmdUDBLogArchiveGetDownloadURL(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBLogArchiveDelete ucloud udb log archive delete +// NewCmdUDBLogArchiveDelete ucloud udb log archive delete func NewCmdUDBLogArchiveDelete(out io.Writer) *cobra.Command { var ids []int req := base.BizClient.NewDeleteUDBLogPackageRequest() diff --git a/cmd/bandwidth.go b/cmd/bandwidth.go index 0d99e873fc..703d2c1243 100644 --- a/cmd/bandwidth.go +++ b/cmd/bandwidth.go @@ -29,7 +29,7 @@ import ( "github.com/ucloud/ucloud-cli/model/status" ) -//NewCmdBandwidth ucloud bw +// NewCmdBandwidth ucloud bw func NewCmdBandwidth() *cobra.Command { cmd := &cobra.Command{ Use: "bw", @@ -41,7 +41,7 @@ func NewCmdBandwidth() *cobra.Command { return cmd } -//NewCmdSharedBW ucloud shared-bw +// NewCmdSharedBW ucloud shared-bw func NewCmdSharedBW() *cobra.Command { cmd := &cobra.Command{ Use: "shared", @@ -56,7 +56,7 @@ func NewCmdSharedBW() *cobra.Command { return cmd } -//NewCmdSharedBWCreate ucloud shared-bw create +// NewCmdSharedBWCreate ucloud shared-bw create func NewCmdSharedBWCreate() *cobra.Command { req := base.BizClient.NewAllocateShareBandwidthRequest() cmd := &cobra.Command{ @@ -91,7 +91,7 @@ func NewCmdSharedBWCreate() *cobra.Command { return cmd } -//SharedBWRow 表格行 +// SharedBWRow 表格行 type SharedBWRow struct { Name string ResourceID string @@ -101,7 +101,7 @@ type SharedBWRow struct { ExpirationTime string } -//NewCmdSharedBWList ucloud shared-bw list +// NewCmdSharedBWList ucloud shared-bw list func NewCmdSharedBWList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeShareBandwidthRequest() cmd := &cobra.Command{ @@ -147,7 +147,7 @@ func NewCmdSharedBWList(out io.Writer) *cobra.Command { return cmd } -//NewCmdSharedBWResize ucloud shared-bw resize +// NewCmdSharedBWResize ucloud shared-bw resize func NewCmdSharedBWResize() *cobra.Command { req := base.BizClient.NewResizeShareBandwidthRequest() cmd := &cobra.Command{ @@ -188,7 +188,7 @@ func NewCmdSharedBWResize() *cobra.Command { return cmd } -//NewCmdSharedBWDelete ucloud shared-bw delete +// NewCmdSharedBWDelete ucloud shared-bw delete func NewCmdSharedBWDelete() *cobra.Command { req := base.BizClient.NewReleaseShareBandwidthRequest() ids := []string{} @@ -242,7 +242,7 @@ func getAllSharedBW(project, region string) ([]string, error) { return list, nil } -//NewCmdBandwidthPkg ucloud bw-pkg +// NewCmdBandwidthPkg ucloud bw-pkg func NewCmdBandwidthPkg() *cobra.Command { cmd := &cobra.Command{ Use: "pkg", @@ -256,7 +256,7 @@ func NewCmdBandwidthPkg() *cobra.Command { return cmd } -//NewCmdBandwidthPkgCreate ucloud bw-pkg create +// NewCmdBandwidthPkgCreate ucloud bw-pkg create func NewCmdBandwidthPkgCreate() *cobra.Command { var start, end *string timeLayout := "2006-01-02/15:04:05" @@ -323,7 +323,7 @@ func NewCmdBandwidthPkgCreate() *cobra.Command { return cmd } -//BandwidthPkgRow 表格行 +// BandwidthPkgRow 表格行 type BandwidthPkgRow struct { ResourceID string EIP string @@ -332,7 +332,7 @@ type BandwidthPkgRow struct { EndTime string } -//NewCmdBandwidthPkgList ucloud bw-pkg list +// NewCmdBandwidthPkgList ucloud bw-pkg list func NewCmdBandwidthPkgList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeBandwidthPackageRequest() cmd := &cobra.Command{ @@ -373,7 +373,7 @@ func NewCmdBandwidthPkgList(out io.Writer) *cobra.Command { return cmd } -//NewCmdBandwidthPkgDelete ucloud bw-pkg delete +// NewCmdBandwidthPkgDelete ucloud bw-pkg delete func NewCmdBandwidthPkgDelete() *cobra.Command { ids := []string{} req := base.BizClient.NewDeleteBandwidthPackageRequest() diff --git a/cmd/configure.go b/cmd/configure.go index b3de234159..fdc5682ed0 100644 --- a/cmd/configure.go +++ b/cmd/configure.go @@ -40,7 +40,7 @@ const helloUcloud = ` If you want add or modify your configurations, run 'ucloud config add/update' ` -//NewCmdInit ucloud init +// NewCmdInit ucloud init func NewCmdInit() *cobra.Command { cmd := &cobra.Command{ Use: "init", @@ -118,7 +118,7 @@ func printHello() { base.Cxt.Println(helloUcloud) } -//根据用户设置的region和zone,检查其合法性,补上缺失的部分,给出一个合理的符合用户本意设置的region和zone +// 根据用户设置的region和zone,检查其合法性,补上缺失的部分,给出一个合理的符合用户本意设置的region和zone func getReasonableRegionZone(cfg *base.AggConfig) (string, string, error) { userRegion := cfg.Region userZone := cfg.Zone @@ -159,7 +159,7 @@ func getReasonableRegionZone(cfg *base.AggConfig) (string, string, error) { return userRegion, userZone, nil } -//NewCmdConfig ucloud config +// NewCmdConfig ucloud config func NewCmdConfig() *cobra.Command { var active, upload string cfg := base.AggConfig{} @@ -328,7 +328,7 @@ func NewCmdConfig() *cobra.Command { return cmd } -//NewCmdConfigAdd ucloud config add +// NewCmdConfigAdd ucloud config add func NewCmdConfigAdd() *cobra.Command { var active, upload string cfg := &base.AggConfig{} @@ -409,7 +409,7 @@ func NewCmdConfigAdd() *cobra.Command { return cmd } -//NewCmdConfigUpdate ucloud config update +// NewCmdConfigUpdate ucloud config update func NewCmdConfigUpdate() *cobra.Command { var timeout, active, maxRetries, upload string cfg := &base.AggConfig{} @@ -543,7 +543,7 @@ func NewCmdConfigUpdate() *cobra.Command { return cmd } -//NewCmdConfigList ucloud config list +// NewCmdConfigList ucloud config list func NewCmdConfigList() *cobra.Command { cmd := &cobra.Command{ Use: "list", @@ -556,7 +556,7 @@ func NewCmdConfigList() *cobra.Command { return cmd } -//NewCmdConfigDelete ucloud config Delete +// NewCmdConfigDelete ucloud config Delete func NewCmdConfigDelete() *cobra.Command { var profileList []string cmd := &cobra.Command{ diff --git a/cmd/disk.go b/cmd/disk.go index 10e10da296..2a68a75f6c 100644 --- a/cmd/disk.go +++ b/cmd/disk.go @@ -30,7 +30,7 @@ import ( "github.com/ucloud/ucloud-cli/ux" ) -//NewCmdDisk ucloud disk +// NewCmdDisk ucloud disk func NewCmdDisk() *cobra.Command { cmd := &cobra.Command{ Use: "udisk", @@ -52,7 +52,7 @@ func NewCmdDisk() *cobra.Command { return cmd } -//NewCmdDiskCreate ucloud udisk create +// NewCmdDiskCreate ucloud udisk create func NewCmdDiskCreate(out io.Writer) *cobra.Command { var async *bool var count *int @@ -160,7 +160,7 @@ func NewCmdDiskCreate(out io.Writer) *cobra.Command { return cmd } -//DiskRow TableRow +// DiskRow TableRow type DiskRow struct { ResourceID string Name string @@ -175,7 +175,7 @@ type DiskRow struct { ExpirationTime string } -//NewCmdDiskList ucloud disk list +// NewCmdDiskList ucloud disk list func NewCmdDiskList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeUDiskRequest() typeMap := map[string]string{ @@ -238,7 +238,7 @@ func NewCmdDiskList(out io.Writer) *cobra.Command { return cmd } -//NewCmdDiskAttach ucloud disk attach +// NewCmdDiskAttach ucloud disk attach func NewCmdDiskAttach(out io.Writer) *cobra.Command { var async *bool var udiskIDs *[]string @@ -291,7 +291,7 @@ func NewCmdDiskAttach(out io.Writer) *cobra.Command { return cmd } -//NewCmdDiskDetach ucloud udisk detach +// NewCmdDiskDetach ucloud udisk detach func NewCmdDiskDetach(out io.Writer) *cobra.Command { var async, yes *bool var udiskIDs *[]string @@ -368,7 +368,7 @@ func detachUdisk(async bool, udiskID string, out io.Writer) error { return nil } -//NewCmdDiskDelete ucloud udisk delete +// NewCmdDiskDelete ucloud udisk delete func NewCmdDiskDelete() *cobra.Command { var yes *bool var udiskIDs *[]string @@ -418,7 +418,7 @@ func NewCmdDiskDelete() *cobra.Command { return cmd } -//NewCmdDiskClone ucloud disk clone +// NewCmdDiskClone ucloud disk clone func NewCmdDiskClone(out io.Writer) *cobra.Command { var async *bool req := base.BizClient.NewCloneUDiskRequest() @@ -480,7 +480,7 @@ func NewCmdDiskClone(out io.Writer) *cobra.Command { return cmd } -//NewCmdDiskExpand ucloud udisk expand +// NewCmdDiskExpand ucloud udisk expand func NewCmdDiskExpand() *cobra.Command { var udiskIDs *[]string req := base.BizClient.NewResizeUDiskRequest() @@ -519,7 +519,7 @@ func NewCmdDiskExpand() *cobra.Command { return cmd } -//NewCmdDiskSnapshot ucloud udisk snapshot +// NewCmdDiskSnapshot ucloud udisk snapshot func NewCmdDiskSnapshot(out io.Writer) *cobra.Command { var async *bool var udiskIDs *[]string @@ -568,7 +568,7 @@ func NewCmdDiskSnapshot(out io.Writer) *cobra.Command { return cmd } -//NewCmdDiskRestore ucloud udisk restore +// NewCmdDiskRestore ucloud udisk restore func NewCmdDiskRestore(out io.Writer) *cobra.Command { var snapshotIDs *[]string req := base.BizClient.NewRestoreUHostDiskRequest() @@ -627,7 +627,7 @@ func NewCmdDiskRestore(out io.Writer) *cobra.Command { return cmd } -//SnapshotRow 表格行 +// SnapshotRow 表格行 type SnapshotRow struct { Name string ResourceID string @@ -639,7 +639,7 @@ type SnapshotRow struct { CreationTime string } -//NewCmdSnapshotList ucloud udisk list-snapshot +// NewCmdSnapshotList ucloud udisk list-snapshot func NewCmdSnapshotList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeSnapshotRequest() cmd := &cobra.Command{ @@ -685,7 +685,7 @@ func NewCmdSnapshotList(out io.Writer) *cobra.Command { return cmd } -//NewCmdSnapshotDelete ucloud udisk delete-snapshot +// NewCmdSnapshotDelete ucloud udisk delete-snapshot func NewCmdSnapshotDelete(out io.Writer) *cobra.Command { var snapshotIds *[]string req := base.BizClient.NewDeleteSnapshotRequest() diff --git a/cmd/doc_md.go b/cmd/doc_md.go index b390bdab72..9c7d373c0a 100644 --- a/cmd/doc_md.go +++ b/cmd/doc_md.go @@ -27,7 +27,7 @@ import ( "github.com/ucloud/ucloud-cli/base" ) -//NewCmdDoc ucloud doc +// NewCmdDoc ucloud doc func NewCmdDoc(out io.Writer) *cobra.Command { var dir, format string cmd := &cobra.Command{ diff --git a/cmd/eip.go b/cmd/eip.go index ad4274229b..2e45dce86e 100644 --- a/cmd/eip.go +++ b/cmd/eip.go @@ -31,7 +31,7 @@ import ( "github.com/ucloud/ucloud-cli/model/status" ) -//NewCmdEIP ucloud eip +// NewCmdEIP ucloud eip func NewCmdEIP() *cobra.Command { var cmd = &cobra.Command{ Use: "eip", @@ -52,7 +52,7 @@ func NewCmdEIP() *cobra.Command { return cmd } -//EIPRow 表格行 +// EIPRow 表格行 type EIPRow struct { Name string IP string @@ -65,7 +65,7 @@ type EIPRow struct { ExpirationTime string } -//NewCmdEIPList ucloud eip list +// NewCmdEIPList ucloud eip list func NewCmdEIPList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeEIPRequest() fetchAll := false @@ -165,7 +165,7 @@ func fetchAllEip(projectID, region string) ([]unet.UnetEIPSet, error) { return list, nil } -//states,paymodes 为nil时,不作为过滤条件 +// states,paymodes 为nil时,不作为过滤条件 func getAllEip(projectID, region string, states, paymodes []string) []string { list, err := fetchAllEip(projectID, region) if err != nil { @@ -220,7 +220,7 @@ func getEIP(eipID string) (*unet.UnetEIPSet, error) { return nil, fmt.Errorf("eip[%s] may not exist", eipID) } -//NewCmdEIPAllocate ucloud eip allocate +// NewCmdEIPAllocate ucloud eip allocate func NewCmdEIPAllocate() *cobra.Command { var count *int var req = base.BizClient.NewAllocateEIPRequest() @@ -269,7 +269,7 @@ func NewCmdEIPAllocate() *cobra.Command { return cmd } -//NewCmdEIPBind ucloud eip bind +// NewCmdEIPBind ucloud eip bind func NewCmdEIPBind() *cobra.Command { var projectID, region, resourceID, resourceType *string var eipIDs []string @@ -355,7 +355,7 @@ func sbindEIP(resourceID, resourceType, eipID, projectID, region *string) ([]str return logs, nil } -//NewCmdEIPUnbind ucloud eip unbind +// NewCmdEIPUnbind ucloud eip unbind func NewCmdEIPUnbind() *cobra.Command { eipIDs := []string{} req := base.BizClient.NewUnBindEIPRequest() @@ -427,7 +427,7 @@ func unbindEIP(resourceID, resourceType, eipID, projectID, region string) ([]str return logs, nil } -//NewCmdEIPRelease ucloud eip release +// NewCmdEIPRelease ucloud eip release func NewCmdEIPRelease() *cobra.Command { var ids []string req := base.BizClient.NewReleaseEIPRequest() @@ -462,7 +462,7 @@ func NewCmdEIPRelease() *cobra.Command { return cmd } -//NewCmdEIPModifyBandwidth ucloud eip modify-bw +// NewCmdEIPModifyBandwidth ucloud eip modify-bw func NewCmdEIPModifyBandwidth() *cobra.Command { ids := []string{} req := base.BizClient.NewModifyEIPBandwidthRequest() @@ -498,7 +498,7 @@ func NewCmdEIPModifyBandwidth() *cobra.Command { return cmd } -//NewCmdEIPSetChargeMode ucloud eip modify-traffic-mode +// NewCmdEIPSetChargeMode ucloud eip modify-traffic-mode func NewCmdEIPSetChargeMode() *cobra.Command { ids := []string{} req := base.BizClient.NewSetEIPPayModeRequest() @@ -541,7 +541,7 @@ func NewCmdEIPSetChargeMode() *cobra.Command { return cmd } -//NewCmdEIPJoinSharedBW ucloud eip join-shared-bw +// NewCmdEIPJoinSharedBW ucloud eip join-shared-bw func NewCmdEIPJoinSharedBW() *cobra.Command { eipIDs := []string{} req := base.BizClient.NewAssociateEIPWithShareBandwidthRequest() @@ -582,7 +582,7 @@ func NewCmdEIPJoinSharedBW() *cobra.Command { return cmd } -//NewCmdEIPLeaveSharedBW ucloud eip leave-shared-bw +// NewCmdEIPLeaveSharedBW ucloud eip leave-shared-bw func NewCmdEIPLeaveSharedBW() *cobra.Command { eipIDs := []string{} req := base.BizClient.NewDisassociateEIPWithShareBandwidthRequest() diff --git a/cmd/ext.go b/cmd/ext.go index c81411128a..d50850ec3c 100644 --- a/cmd/ext.go +++ b/cmd/ext.go @@ -26,7 +26,7 @@ import ( sdk "github.com/ucloud/ucloud-sdk-go/ucloud" ) -//NewCmdExt ucloud ext +// NewCmdExt ucloud ext func NewCmdExt() *cobra.Command { cmd := &cobra.Command{ Use: "ext", @@ -37,7 +37,7 @@ func NewCmdExt() *cobra.Command { return cmd } -//NewCmdExtUHost ucloud ext uhost +// NewCmdExtUHost ucloud ext uhost func NewCmdExtUHost() *cobra.Command { cmd := &cobra.Command{ Use: "uhost", @@ -48,7 +48,7 @@ func NewCmdExtUHost() *cobra.Command { return cmd } -//NewCmdExtUHostSwitchEIP ucloud ext uhost switch-eip +// NewCmdExtUHostSwitchEIP ucloud ext uhost switch-eip func NewCmdExtUHostSwitchEIP() *cobra.Command { var project, region, zone, chargeType, trafficMode, shareBandwidthID string var uhostIDs, eipAddrs []string diff --git a/cmd/firewall.go b/cmd/firewall.go index 21b60025ce..a1f8deb57f 100644 --- a/cmd/firewall.go +++ b/cmd/firewall.go @@ -29,7 +29,7 @@ import ( "github.com/ucloud/ucloud-cli/base" ) -//NewCmdFirewall ucloud firewall +// NewCmdFirewall ucloud firewall func NewCmdFirewall() *cobra.Command { cmd := &cobra.Command{ Use: "firewall", @@ -51,7 +51,7 @@ func NewCmdFirewall() *cobra.Command { return cmd } -//FirewallRow 表格行 +// FirewallRow 表格行 type FirewallRow struct { ResourceID string FirewallName string @@ -62,7 +62,7 @@ type FirewallRow struct { CreationTime string } -//NewCmdFirewallList ucloud firewall list +// NewCmdFirewallList ucloud firewall list func NewCmdFirewallList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeFirewallRequest() cmd := &cobra.Command{ @@ -125,7 +125,7 @@ func parseRulesFromFile(filePath string) ([]string, error) { return lines, nil } -//NewCmdFirewallCreate ucloud firewall create +// NewCmdFirewallCreate ucloud firewall create func NewCmdFirewallCreate(out io.Writer) *cobra.Command { var rulesFilePath string var rules []string @@ -174,7 +174,7 @@ func NewCmdFirewallCreate(out io.Writer) *cobra.Command { return cmd } -//NewCmdFirewallAddRule ucloud firewall add-rule +// NewCmdFirewallAddRule ucloud firewall add-rule func NewCmdFirewallAddRule(out io.Writer) *cobra.Command { var rulesFilePath string var fwIDs []string @@ -247,7 +247,7 @@ func NewCmdFirewallAddRule(out io.Writer) *cobra.Command { return cmd } -//NewCmdFirewallDeleteRule ucloud firewall remove-rule +// NewCmdFirewallDeleteRule ucloud firewall remove-rule func NewCmdFirewallDeleteRule(out io.Writer) *cobra.Command { var rulesFilePath string var fwIDs []string @@ -321,7 +321,7 @@ func NewCmdFirewallDeleteRule(out io.Writer) *cobra.Command { return cmd } -//NewCmdFirewallApply ucloud firewall apply +// NewCmdFirewallApply ucloud firewall apply func NewCmdFirewallApply() *cobra.Command { req := base.BizClient.NewGrantFirewallRequest() resourceIDs := []string{} @@ -365,7 +365,7 @@ func NewCmdFirewallApply() *cobra.Command { return cmd } -//NewCmdFirewallCopy ucloud firewall copy +// NewCmdFirewallCopy ucloud firewall copy func NewCmdFirewallCopy() *cobra.Command { srcFirewall := "" srcRegion := "" @@ -417,7 +417,7 @@ func NewCmdFirewallCopy() *cobra.Command { return cmd } -//NewCmdFirewallDelete ucloud firewall delete +// NewCmdFirewallDelete ucloud firewall delete func NewCmdFirewallDelete() *cobra.Command { req := base.BizClient.NewDeleteFirewallRequest() ids := []string{} @@ -452,7 +452,7 @@ func NewCmdFirewallDelete() *cobra.Command { return cmd } -//FirewallResourceRow 表格行 +// FirewallResourceRow 表格行 type FirewallResourceRow struct { ResourceName string ResourceID string @@ -462,7 +462,7 @@ type FirewallResourceRow struct { Remark string } -//NewCmdFirewallResource ucloud firewall resource +// NewCmdFirewallResource ucloud firewall resource func NewCmdFirewallResource(out io.Writer) *cobra.Command { fwID := "" req := base.BizClient.NewDescribeFirewallResourceRequest() @@ -509,7 +509,7 @@ func NewCmdFirewallResource(out io.Writer) *cobra.Command { return cmd } -//NewCmdFirewallUpdate ucloud firewall update +// NewCmdFirewallUpdate ucloud firewall update func NewCmdFirewallUpdate(out io.Writer) *cobra.Command { fwIDs := []string{} req := base.BizClient.NewUpdateFirewallAttributeRequest() diff --git a/cmd/globalssh.go b/cmd/globalssh.go index 1ea598f106..6fcfbdb6f8 100644 --- a/cmd/globalssh.go +++ b/cmd/globalssh.go @@ -28,7 +28,7 @@ import ( "github.com/ucloud/ucloud-cli/base" ) -//NewCmdGssh ucloud gssh +// NewCmdGssh ucloud gssh func NewCmdGssh() *cobra.Command { cmd := &cobra.Command{ Use: "gssh", @@ -44,7 +44,7 @@ func NewCmdGssh() *cobra.Command { return cmd } -//GSSHRow gssh表格行 +// GSSHRow gssh表格行 type GSSHRow struct { ResourceID string SSHServerIP string @@ -56,7 +56,7 @@ type GSSHRow struct { InstanceType string } -//NewCmdGsshList ucloud gssh list +// NewCmdGsshList ucloud gssh list func NewCmdGsshList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeGlobalSSHInstanceRequest() cmd := &cobra.Command{ @@ -106,7 +106,7 @@ func NewCmdGsshList(out io.Writer) *cobra.Command { return cmd } -//NewCmdGsshArea ucloud gssh area +// NewCmdGsshArea ucloud gssh area func NewCmdGsshArea() *cobra.Command { req := base.BizClient.NewDescribeGlobalSSHAreaRequest() cmd := &cobra.Command{ @@ -139,7 +139,7 @@ func NewCmdGsshArea() *cobra.Command { return cmd } -//GsshLocation 服务地点和覆盖区域 +// GsshLocation 服务地点和覆盖区域 type GsshLocation struct { AirportCode string SSHServerLocation string @@ -156,7 +156,7 @@ var areaCodeMap = map[string]string{ "LOS": "Lagos", } -//NewCmdGsshCreate ucloud gssh create +// NewCmdGsshCreate ucloud gssh create func NewCmdGsshCreate() *cobra.Command { var targetIP *net.IP req := base.BizClient.NewCreateGlobalSSHInstanceRequest() @@ -215,7 +215,7 @@ func NewCmdGsshCreate() *cobra.Command { return cmd } -//NewCmdGsshDelete ucloud gssh delete +// NewCmdGsshDelete ucloud gssh delete func NewCmdGsshDelete() *cobra.Command { var req = base.BizClient.NewDeleteGlobalSSHInstanceRequest() var gsshIds *[]string @@ -248,7 +248,7 @@ func NewCmdGsshDelete() *cobra.Command { return cmd } -//NewCmdGsshModify ucloud gssh modify +// NewCmdGsshModify ucloud gssh modify func NewCmdGsshModify() *cobra.Command { gsshModifyPortReq := base.BizClient.NewModifyGlobalSSHPortRequest() gsshModifyRemarkReq := base.BizClient.NewModifyGlobalSSHRemarkRequest() diff --git a/cmd/image.go b/cmd/image.go index 20de130f94..c3ed24925b 100644 --- a/cmd/image.go +++ b/cmd/image.go @@ -28,7 +28,7 @@ import ( "github.com/ucloud/ucloud-cli/model/status" ) -//NewCmdUImage ucloud uimage +// NewCmdUImage ucloud uimage func NewCmdUImage() *cobra.Command { cmd := &cobra.Command{ Use: "image", @@ -47,7 +47,7 @@ func NewCmdUImage() *cobra.Command { return cmd } -//ImageRow 表格行 +// ImageRow 表格行 type ImageRow struct { ImageName string ImageID string @@ -58,7 +58,7 @@ type ImageRow struct { State string } -//NewCmdUImageList ucloud uimage list +// NewCmdUImageList ucloud uimage list func NewCmdUImageList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeImageRequest() cmd := &cobra.Command{ @@ -105,7 +105,7 @@ func NewCmdUImageList(out io.Writer) *cobra.Command { // req := BizClient.NewImportCustomImageRequest() // } -//NewCmdUImageDelete ucloud image delete +// NewCmdUImageDelete ucloud image delete func NewCmdUImageDelete() *cobra.Command { var imageIDs *[]string req := base.BizClient.NewTerminateCustomImageRequest() @@ -139,7 +139,7 @@ func NewCmdUImageDelete() *cobra.Command { return cmd } -//NewCmdImageCopy ucloud image copy +// NewCmdImageCopy ucloud image copy func NewCmdImageCopy(out io.Writer) *cobra.Command { var imageIDs *[]string var async *bool diff --git a/cmd/mysql.go b/cmd/mysql.go index 0d257e56e1..7dff0a8707 100644 --- a/cmd/mysql.go +++ b/cmd/mysql.go @@ -35,7 +35,7 @@ var dbDiskTypeList = []string{"normal", "sata_ssd", "pcie_ssd"} var poller = base.NewSpoller(describeUdbByID, base.Cxt.GetWriter()) -//NewCmdMysql ucloud mysql +// NewCmdMysql ucloud mysql func NewCmdMysql() *cobra.Command { cmd := &cobra.Command{ Use: "mysql", @@ -50,7 +50,7 @@ func NewCmdMysql() *cobra.Command { return cmd } -//NewCmdMysqlDB ucloud mysql db +// NewCmdMysqlDB ucloud mysql db func NewCmdMysqlDB(out io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "db", @@ -74,7 +74,7 @@ func NewCmdMysqlDB(out io.Writer) *cobra.Command { return cmd } -//NewCmdMysqlCreate ucloud mysql create +// NewCmdMysqlCreate ucloud mysql create func NewCmdMysqlCreate(out io.Writer) *cobra.Command { var confID, diskType string var backupID int @@ -178,7 +178,7 @@ func NewCmdMysqlCreate(out io.Writer) *cobra.Command { return cmd } -//UDBMysqlRow 表格行 +// UDBMysqlRow 表格行 type UDBMysqlRow struct { Name string ResourceID string @@ -195,7 +195,7 @@ type UDBMysqlRow struct { // CreateTime string } -//NewCmdUDBList ucloud udb list +// NewCmdUDBList ucloud udb list func NewCmdUDBList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeUDBInstanceRequest() cmd := &cobra.Command{ @@ -267,7 +267,7 @@ func NewCmdUDBList(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBDelete ucloud udb delete +// NewCmdUDBDelete ucloud udb delete func NewCmdUDBDelete(out io.Writer) *cobra.Command { var idNames []string var yes bool @@ -323,7 +323,7 @@ func NewCmdUDBDelete(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBStop ucloud udb stop +// NewCmdUDBStop ucloud udb stop func NewCmdUDBStop(out io.Writer) *cobra.Command { var idNames []string var async bool @@ -360,7 +360,7 @@ func NewCmdUDBStop(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBStart ucloud udb start +// NewCmdUDBStart ucloud udb start func NewCmdUDBStart(out io.Writer) *cobra.Command { var async bool var idNames []string @@ -405,7 +405,7 @@ func NewCmdUDBStart(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBRestart ucloud udb restart +// NewCmdUDBRestart ucloud udb restart func NewCmdUDBRestart(out io.Writer) *cobra.Command { var async bool var idNames []string @@ -449,7 +449,7 @@ func NewCmdUDBRestart(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBResize ucloud udb resize +// NewCmdUDBResize ucloud udb resize func NewCmdUDBResize(out io.Writer) *cobra.Command { var diskTypes = []string{"normal", "sata_ssd", "pcie_ssd", "normal_volume", "sata_ssd_volume", "pcie_ssd_volume"} var async, yes bool @@ -557,7 +557,7 @@ func NewCmdUDBResize(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBResetPassword ucloud udb reset-password +// NewCmdUDBResetPassword ucloud udb reset-password func NewCmdUDBResetPassword(out io.Writer) *cobra.Command { var idNames []string req := base.BizClient.NewModifyUDBInstancePasswordRequest() @@ -598,7 +598,7 @@ func NewCmdUDBResetPassword(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBRestore ucloud udb restore +// NewCmdUDBRestore ucloud udb restore func NewCmdUDBRestore(out io.Writer) *cobra.Command { var datetime, diskType string var async bool @@ -666,7 +666,7 @@ func NewCmdUDBRestore(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBCreateSlave ucloud udb create-slave +// NewCmdUDBCreateSlave ucloud udb create-slave func NewCmdUDBCreateSlave(out io.Writer) *cobra.Command { var diskType string var async bool @@ -724,7 +724,7 @@ func NewCmdUDBCreateSlave(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBPromoteSlave ucloud udb promote-slave +// NewCmdUDBPromoteSlave ucloud udb promote-slave func NewCmdUDBPromoteSlave(out io.Writer) *cobra.Command { var ids []string req := base.BizClient.NewPromoteUDBSlaveRequest() @@ -759,7 +759,7 @@ func NewCmdUDBPromoteSlave(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBPromoteToHA ucloud udb promote-to-ha 低频操作 暂不开放 +// NewCmdUDBPromoteToHA ucloud udb promote-to-ha 低频操作 暂不开放 func NewCmdUDBPromoteToHA(out io.Writer) *cobra.Command { var idNames []string req := base.BizClient.NewPromoteUDBInstanceToHARequest() diff --git a/cmd/pathx.go b/cmd/pathx.go index 1ae815503c..8b59437159 100644 --- a/cmd/pathx.go +++ b/cmd/pathx.go @@ -30,7 +30,7 @@ import ( "github.com/ucloud/ucloud-cli/ux" ) -//NewCmdPathx ucloud pathx +// NewCmdPathx ucloud pathx func NewCmdPathx() *cobra.Command { cmd := &cobra.Command{ Use: "pathx", @@ -949,7 +949,7 @@ type EgressIpInfoRow struct { Area string } -//NewCmdUpath ucloud pathx upath +// NewCmdUpath ucloud pathx upath func NewCmdUpath() *cobra.Command { cmd := &cobra.Command{ Use: "upath", @@ -968,7 +968,7 @@ type upathRow struct { BoundUGA string } -//NewCmdUpathList ucloud pathx upath list +// NewCmdUpathList ucloud pathx upath list func NewCmdUpathList(out io.Writer) *cobra.Command { req := base.BizClient.PrivatePathxClient.NewDescribeUPathRequest() cmd := &cobra.Command{ @@ -1008,7 +1008,7 @@ func NewCmdUpathList(out io.Writer) *cobra.Command { return cmd } -//NewCmdUGA ucloud uga +// NewCmdUGA ucloud uga func NewCmdUGA() *cobra.Command { cmd := &cobra.Command{ Use: "uga", @@ -1027,7 +1027,7 @@ func NewCmdUGA() *cobra.Command { return cmd } -//UGARow 表格行 +// UGARow 表格行 type UGARow struct { ResourceID string UGAName string @@ -1038,7 +1038,7 @@ type UGARow struct { var protocols = []string{"tcp", "udp"} -//NewCmdUGAList ucloud uga list +// NewCmdUGAList ucloud uga list func NewCmdUGAList(out io.Writer) *cobra.Command { req := base.BizClient.PrivatePathxClient.NewDescribeUGAInstanceRequest() cmd := &cobra.Command{ @@ -1101,7 +1101,7 @@ func getPortStr(list []ppathx.UGAATask) string { return strings.Join(strs, "\n") } -//NewCmdUGADescribe ucloud uga describe +// NewCmdUGADescribe ucloud uga describe func NewCmdUGADescribe(out io.Writer) *cobra.Command { req := base.BizClient.PrivatePathxClient.NewDescribeUGAInstanceRequest() cmd := &cobra.Command{ @@ -1175,7 +1175,7 @@ func formatPortList(userPorts []string) ([]string, error) { return portList, nil } -//NewCmdUGACreate ucloud uga create +// NewCmdUGACreate ucloud uga create func NewCmdUGACreate(out io.Writer) *cobra.Command { var protocol string var ports, lines []string @@ -1263,7 +1263,7 @@ func NewCmdUGACreate(out io.Writer) *cobra.Command { return cmd } -//NewCmdUGADelete ucloud uga delete +// NewCmdUGADelete ucloud uga delete func NewCmdUGADelete(out io.Writer) *cobra.Command { idNames := []string{} req := base.BizClient.PrivatePathxClient.NewDeleteUGAInstanceRequest() @@ -1299,7 +1299,7 @@ func NewCmdUGADelete(out io.Writer) *cobra.Command { return cmd } -//NewCmdUGAAddPort ucloud pathx uga add-port +// NewCmdUGAAddPort ucloud pathx uga add-port func NewCmdUGAAddPort(out io.Writer) *cobra.Command { var ports []string var protocol string @@ -1358,7 +1358,7 @@ func NewCmdUGAAddPort(out io.Writer) *cobra.Command { return cmd } -//NewCmdUGARemovePort ucloud pathx uga delete-port +// NewCmdUGARemovePort ucloud pathx uga delete-port func NewCmdUGARemovePort(out io.Writer) *cobra.Command { var ports []string var protocol string diff --git a/cmd/project.go b/cmd/project.go index dc8d65890a..1b36152a81 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -24,7 +24,7 @@ import ( "github.com/ucloud/ucloud-cli/base" ) -//NewCmdProject ucloud project +// NewCmdProject ucloud project func NewCmdProject() *cobra.Command { var cmd = &cobra.Command{ Use: "project", @@ -40,7 +40,7 @@ func NewCmdProject() *cobra.Command { return cmd } -//NewCmdProjectList ucloud project list +// NewCmdProjectList ucloud project list func NewCmdProjectList(out io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "list", @@ -54,7 +54,7 @@ func NewCmdProjectList(out io.Writer) *cobra.Command { return cmd } -//NewCmdProjectCreate ucloud project create +// NewCmdProjectCreate ucloud project create func NewCmdProjectCreate() *cobra.Command { req := base.BizClient.NewCreateProjectRequest() cmd := &cobra.Command{ @@ -81,7 +81,7 @@ func NewCmdProjectCreate() *cobra.Command { return cmd } -//NewCmdProjectUpdate ucloud project update +// NewCmdProjectUpdate ucloud project update func NewCmdProjectUpdate() *cobra.Command { req := base.BizClient.NewModifyProjectRequest() cmd := &cobra.Command{ @@ -109,7 +109,7 @@ func NewCmdProjectUpdate() *cobra.Command { return cmd } -//NewCmdProjectDelete ucloud project delete +// NewCmdProjectDelete ucloud project delete func NewCmdProjectDelete() *cobra.Command { req := base.BizClient.NewTerminateProjectRequest() cmd := &cobra.Command{ diff --git a/cmd/region.go b/cmd/region.go index c6edbea826..17275532fb 100644 --- a/cmd/region.go +++ b/cmd/region.go @@ -29,7 +29,7 @@ import ( "github.com/ucloud/ucloud-cli/base" ) -//NewCmdRegion ucloud region +// NewCmdRegion ucloud region func NewCmdRegion(out io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "region", @@ -52,7 +52,7 @@ func NewCmdRegion(out io.Writer) *cobra.Command { return cmd } -//RegionTable 为显示region表格创建的类型 +// RegionTable 为显示region表格创建的类型 type RegionTable struct { Region string Zones string @@ -75,7 +75,7 @@ func getDefaultRegion() (string, string, error) { return "", "", fmt.Errorf("No default region") } -//Region region, zone, isDefault +// Region region, zone, isDefault type Region struct { Labels map[string][]string DefaultRegion string @@ -136,7 +136,7 @@ func getAllRegions() ([]string, error) { return list, nil } -//仅在命令补全中使用,忽略错误 +// 仅在命令补全中使用,忽略错误 func getRegionList() []string { regionIns, err := fetchRegion() if err != nil { diff --git a/cmd/root.go b/cmd/root.go index 0577b68a14..283f9f4a7f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -27,7 +27,7 @@ import ( var global = &base.Global -//NewCmdRoot 创建rootCmd rootCmd represents the base command when called without any subcommands +// NewCmdRoot 创建rootCmd rootCmd represents the base command when called without any subcommands func NewCmdRoot() *cobra.Command { cmd := &cobra.Command{ Use: "ucloud", @@ -95,7 +95,7 @@ Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}} Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}} ` -//概要帮助信息模板 +// 概要帮助信息模板 const usageTmpl = `Usage:{{if .Runnable}} {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} [command] {{if $size:=len .Commands}} {{"command may be" | printf "%-20s"}} {{range $index,$cmd:= .Commands}}{{if .IsAvailableCommand}}{{$cmd.Name}}{{if gt $size (add $index 1)}} | {{end}}{{end}}{{end}}{{end}}{{end}}{{if .HasAvailableFlags}} diff --git a/cmd/signup.go b/cmd/signup.go index 6f5cb2546d..4a3ffd9391 100644 --- a/cmd/signup.go +++ b/cmd/signup.go @@ -22,7 +22,7 @@ import ( "github.com/spf13/cobra" ) -//NewCmdSignup ucloud signup +// NewCmdSignup ucloud signup func NewCmdSignup() *cobra.Command { var cmd = &cobra.Command{ Use: "signup", diff --git a/cmd/udb.go b/cmd/udb.go index 3ca9d75c4c..433386d3db 100644 --- a/cmd/udb.go +++ b/cmd/udb.go @@ -32,7 +32,7 @@ import ( "github.com/ucloud/ucloud-cli/model/status" ) -//NewCmdUDBConf ucloud udb conf +// NewCmdUDBConf ucloud udb conf func NewCmdUDBConf() *cobra.Command { cmd := &cobra.Command{ Use: "conf", @@ -51,7 +51,7 @@ func NewCmdUDBConf() *cobra.Command { return cmd } -//UDBConfRow 表格行 +// UDBConfRow 表格行 type UDBConfRow struct { ConfID int DBVersion string @@ -70,7 +70,7 @@ var dbTypeMap = map[string]string{ var dbTypeList = []string{"mysql", "mongodb", "postgresql", "sqlserver"} -//NewCmdUDBConfList ucloud mysql conf list +// NewCmdUDBConfList ucloud mysql conf list func NewCmdUDBConfList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeUDBParamGroupRequest() cmd := &cobra.Command{ @@ -120,13 +120,13 @@ func NewCmdUDBConfList(out io.Writer) *cobra.Command { return cmd } -//UDBConfParamRow 参数配置展示表格行 +// UDBConfParamRow 参数配置展示表格行 type UDBConfParamRow struct { Key string Value string } -//NewCmdUDBConfDescribe ucloud udb conf describe +// NewCmdUDBConfDescribe ucloud udb conf describe func NewCmdUDBConfDescribe(out io.Writer) *cobra.Command { var confID string req := base.BizClient.NewDescribeUDBParamGroupRequest() @@ -194,7 +194,7 @@ func NewCmdUDBConfDescribe(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBConfClone ucloud udb conf clone +// NewCmdUDBConfClone ucloud udb conf clone func NewCmdUDBConfClone(out io.Writer) *cobra.Command { var srcConfID string req := base.BizClient.NewCreateUDBParamGroupRequest() @@ -260,7 +260,7 @@ var udbSubtypeMap = map[string]int{ var subtypeList = []string{"Shardsvr-MMAPv1", "Shardsvr-WiredTiger", "Configsvr-MMAPv1", "Configsvr-WiredTiger", "Mongos", "Mysql", "Postgresql"} -//NewCmdUDBConfUpload ucloud udb conf upload +// NewCmdUDBConfUpload ucloud udb conf upload func NewCmdUDBConfUpload(out io.Writer) *cobra.Command { var file string req := base.BizClient.NewUploadUDBParamGroupRequest() @@ -313,7 +313,7 @@ func NewCmdUDBConfUpload(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBConfUpdate ucloud udb conf update +// NewCmdUDBConfUpdate ucloud udb conf update func NewCmdUDBConfUpdate(out io.Writer) *cobra.Command { var confID, key, value, file string req := base.BizClient.NewUpdateUDBParamGroupRequest() @@ -384,7 +384,7 @@ func NewCmdUDBConfUpdate(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBConfDelete ucloud udb conf delete +// NewCmdUDBConfDelete ucloud udb conf delete func NewCmdUDBConfDelete(out io.Writer) *cobra.Command { var confID string req := base.BizClient.NewDeleteUDBParamGroupRequest() @@ -495,7 +495,7 @@ func NewCmdUDBConfApply(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDBConfDownload ucloud udb conf download +// NewCmdUDBConfDownload ucloud udb conf download func NewCmdUDBConfDownload(out io.Writer) *cobra.Command { var confID string req := base.BizClient.UDBClient.NewExtractUDBParamGroupRequest() diff --git a/cmd/uhost.go b/cmd/uhost.go index db3e7f72a8..54897102cd 100644 --- a/cmd/uhost.go +++ b/cmd/uhost.go @@ -28,6 +28,7 @@ import ( "github.com/ucloud/ucloud-sdk-go/services/uhost" "github.com/ucloud/ucloud-sdk-go/services/unet" sdk "github.com/ucloud/ucloud-sdk-go/ucloud" + sdkerror "github.com/ucloud/ucloud-sdk-go/ucloud/error" "github.com/ucloud/ucloud-sdk-go/ucloud/request" "github.com/ucloud/ucloud-cli/base" @@ -36,6 +37,8 @@ import ( "github.com/ucloud/ucloud-cli/ux" ) +const _RetCodeRegionNoPermission = 230 + var uhostSpoller = base.NewSpoller(sdescribeUHostByID, base.Cxt.GetWriter()) // NewCmdUHost ucloud uhost @@ -84,7 +87,7 @@ type UHostRow struct { CreationTime string } -func listUhost(uhosts []uhost.UHostInstanceSet, out io.Writer, output string) { +func listUhost(uhosts []uhost.UHostInstanceSet, out io.Writer, output string, listAllRegion bool) { list := make([]UHostRow, 0) for _, host := range uhosts { row := UHostRow{} @@ -134,6 +137,9 @@ func listUhost(uhosts []uhost.UHostInstanceSet, out io.Writer, output string) { cols = []string{"UHostName", "Remark", "ResourceID", "Group", "PrivateIP", "PublicIP", "Config", "DiskSet", "Zone", "Image", "VPC", "Subnet", "Type", "State", "CreationTime"} } else { cols = []string{"UHostName", "ResourceID", "Group", "PrivateIP", "PublicIP", "Config", "Image", "Type", "State", "CreationTime"} + if listAllRegion { + cols = append(cols, "Zone") + } } base.PrintTable(list, cols) } @@ -185,6 +191,10 @@ func getAllUHosts(req *uhost.DescribeUHostInstanceRequest, pageOff bool, allRegi _req.Region = sdk.String(region) //如果要获取所有region的主机,则不分页 uhosts, err := fetchUHostsPageOff(&_req) + // Has no permission in current region for UHost + if e, ok := err.(sdkerror.Error); ok && e.Code() == _RetCodeRegionNoPermission { + continue + } if err != nil { return nil, err } @@ -235,7 +245,7 @@ func NewCmdUHostList(out io.Writer) *cobra.Command { if idOnly { listUhostID(uhosts, out) } else { - listUhost(uhosts, out, output) + listUhost(uhosts, out, output, allRegion) } }, } diff --git a/cmd/ulb.go b/cmd/ulb.go index 66731306dd..168628326b 100644 --- a/cmd/ulb.go +++ b/cmd/ulb.go @@ -29,7 +29,7 @@ import ( "github.com/ucloud/ucloud-cli/model/status" ) -//NewCmdULB ucloud ulb +// NewCmdULB ucloud ulb func NewCmdULB() *cobra.Command { cmd := &cobra.Command{ Use: "ulb", @@ -48,7 +48,7 @@ func NewCmdULB() *cobra.Command { return cmd } -//ULBRow 表格行 +// ULBRow 表格行 type ULBRow struct { Name string ResourceID string @@ -59,7 +59,7 @@ type ULBRow struct { CreationTime string } -//NewCmdULBList ucloud ulb list +// NewCmdULBList ucloud ulb list func NewCmdULBList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeULBRequest() cmd := &cobra.Command{ @@ -119,7 +119,7 @@ func NewCmdULBList(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBCreate ucloud ulb create +// NewCmdULBCreate ucloud ulb create func NewCmdULBCreate(out io.Writer) *cobra.Command { var bindEipID *string mode := "outer" @@ -224,7 +224,7 @@ func NewCmdULBCreate(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBDelete ucloud ulb delete +// NewCmdULBDelete ucloud ulb delete func NewCmdULBDelete(out io.Writer) *cobra.Command { idNames := []string{} req := base.BizClient.NewDeleteULBRequest() @@ -262,7 +262,7 @@ func NewCmdULBDelete(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBUpdate ucloud ulb update +// NewCmdULBUpdate ucloud ulb update func NewCmdULBUpdate(out io.Writer) *cobra.Command { var name, group, remark string idNames := []string{} @@ -353,7 +353,7 @@ func getAllULBIDNames(project, region string) []string { return list } -//NewCmdULBVserver ucloud ulb-vserver +// NewCmdULBVserver ucloud ulb-vserver func NewCmdULBVserver() *cobra.Command { cmd := &cobra.Command{ Use: "vserver", @@ -372,7 +372,7 @@ func NewCmdULBVserver() *cobra.Command { return cmd } -//ULBVServerRow 表格行 +// ULBVServerRow 表格行 type ULBVServerRow struct { VServerName string ResourceID string @@ -388,7 +388,7 @@ type ULBVServerRow struct { HealthCheckPath string } -//NewCmdULBVServerList ucloud ulb-vserver list +// NewCmdULBVServerList ucloud ulb-vserver list func NewCmdULBVServerList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeVServerRequest() cmd := &cobra.Command{ @@ -441,7 +441,7 @@ func NewCmdULBVServerList(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBVServerCreate ucloud ulb-vserver create +// NewCmdULBVServerCreate ucloud ulb-vserver create func NewCmdULBVServerCreate(out io.Writer) *cobra.Command { sslID := "" req := base.BizClient.NewCreateVServerRequest() @@ -530,7 +530,7 @@ func NewCmdULBVServerCreate(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBVServerUpdate ucloud ulb-vserver update +// NewCmdULBVServerUpdate ucloud ulb-vserver update func NewCmdULBVServerUpdate(out io.Writer) *cobra.Command { req := base.BizClient.NewUpdateVServerAttributeRequest() vserverIDs := []string{} @@ -609,7 +609,7 @@ func NewCmdULBVServerUpdate(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBVServerDelete ucloud ulb-vserver delete +// NewCmdULBVServerDelete ucloud ulb-vserver delete func NewCmdULBVServerDelete(out io.Writer) *cobra.Command { vserverIDs := []string{} req := base.BizClient.NewDeleteVServerRequest() @@ -655,7 +655,7 @@ func NewCmdULBVServerDelete(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBVServerNode ucloud ulb vserver node +// NewCmdULBVServerNode ucloud ulb vserver node func NewCmdULBVServerNode() *cobra.Command { out := base.Cxt.GetWriter() cmd := &cobra.Command{ @@ -670,7 +670,7 @@ func NewCmdULBVServerNode() *cobra.Command { return cmd } -//ULBVServerNode 表格行 +// ULBVServerNode 表格行 type ULBVServerNode struct { Name string ResourceID string @@ -682,7 +682,7 @@ type ULBVServerNode struct { Weight int } -//NewCmdULBVServerListNode ucloud ulb-vserver list-node +// NewCmdULBVServerListNode ucloud ulb-vserver list-node func NewCmdULBVServerListNode(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeVServerRequest() cmd := &cobra.Command{ @@ -749,7 +749,7 @@ func NewCmdULBVServerListNode(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBVServerAddNode ucloud ulb-vserver add-node +// NewCmdULBVServerAddNode ucloud ulb-vserver add-node func NewCmdULBVServerAddNode(out io.Writer) *cobra.Command { var enable *string var weight *int @@ -815,7 +815,7 @@ func NewCmdULBVServerAddNode(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBVServerUpdateNode ucloud ulb-vserver update-node +// NewCmdULBVServerUpdateNode ucloud ulb-vserver update-node func NewCmdULBVServerUpdateNode(out io.Writer) *cobra.Command { var mode *string var weight *int @@ -886,7 +886,7 @@ func NewCmdULBVServerUpdateNode(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBVServerDeleteNode ucloud ulb-vserver delete-node +// NewCmdULBVServerDeleteNode ucloud ulb-vserver delete-node func NewCmdULBVServerDeleteNode(out io.Writer) *cobra.Command { backendIDs := []string{} req := base.BizClient.NewReleaseBackendRequest() @@ -927,7 +927,7 @@ func NewCmdULBVServerDeleteNode(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBVServerPolicy ucloud ulb vserver policy +// NewCmdULBVServerPolicy ucloud ulb vserver policy func NewCmdULBVServerPolicy() *cobra.Command { out := base.Cxt.GetWriter() cmd := &cobra.Command{ @@ -942,7 +942,7 @@ func NewCmdULBVServerPolicy() *cobra.Command { return cmd } -//NewCmdULBVServerCreatePolicy ucloud ulb-vserver create-policy +// NewCmdULBVServerCreatePolicy ucloud ulb-vserver create-policy func NewCmdULBVServerCreatePolicy(out io.Writer) *cobra.Command { backendIDs := []string{} req := base.BizClient.NewCreatePolicyRequest() @@ -1001,7 +1001,7 @@ func NewCmdULBVServerCreatePolicy(out io.Writer) *cobra.Command { return cmd } -//ULBVServerPolicy 表格行 +// ULBVServerPolicy 表格行 type ULBVServerPolicy struct { ForwardMethod string Expression string @@ -1010,7 +1010,7 @@ type ULBVServerPolicy struct { Backends string } -//NewCmdULBVServerListPolicy ucloud ulb-vserver list-policy +// NewCmdULBVServerListPolicy ucloud ulb-vserver list-policy func NewCmdULBVServerListPolicy(out io.Writer) *cobra.Command { var ulbID, vserverID *string region := base.ConfigIns.Region @@ -1067,7 +1067,7 @@ func NewCmdULBVServerListPolicy(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBVServerUpdatePolicy ucloud ulb-vserver update-policy +// NewCmdULBVServerUpdatePolicy ucloud ulb-vserver update-policy func NewCmdULBVServerUpdatePolicy(out io.Writer) *cobra.Command { policyIDs := []string{} backendIDs := []string{} @@ -1182,7 +1182,7 @@ func NewCmdULBVServerUpdatePolicy(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBVServerDeletePolicy ucloud ulb-vserver delete-policy +// NewCmdULBVServerDeletePolicy ucloud ulb-vserver delete-policy func NewCmdULBVServerDeletePolicy(out io.Writer) *cobra.Command { policyIDs := []string{} req := base.BizClient.NewDeletePolicyRequest() @@ -1216,7 +1216,7 @@ func NewCmdULBVServerDeletePolicy(out io.Writer) *cobra.Command { return cmd } -//NewCmdULBSSL ucloud ulb-ssl-certificate +// NewCmdULBSSL ucloud ulb-ssl-certificate func NewCmdULBSSL() *cobra.Command { cmd := &cobra.Command{ Use: "ssl", @@ -1233,7 +1233,7 @@ func NewCmdULBSSL() *cobra.Command { return cmd } -//SSLCertificate 表格行 +// SSLCertificate 表格行 type SSLCertificate struct { Name string ResourceID string @@ -1242,7 +1242,7 @@ type SSLCertificate struct { UploadTime string } -//NewCmdSSLList ucloud ulb-ssl-certificate list +// NewCmdSSLList ucloud ulb-ssl-certificate list func NewCmdSSLList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeSSLRequest() cmd := &cobra.Command{ @@ -1286,7 +1286,7 @@ func NewCmdSSLList(out io.Writer) *cobra.Command { return cmd } -//NewCmdSSLDescribe ucloud ulb-ssl-certificate describe +// NewCmdSSLDescribe ucloud ulb-ssl-certificate describe func NewCmdSSLDescribe(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeSSLRequest() cmd := &cobra.Command{ @@ -1358,7 +1358,7 @@ func NewCmdSSLDescribe(out io.Writer) *cobra.Command { return cmd } -//NewCmdSSLAdd ucloud ulb-ssl-certificate add +// NewCmdSSLAdd ucloud ulb-ssl-certificate add func NewCmdSSLAdd(out io.Writer) *cobra.Command { var allPath, sitePath, keyPath, caPath *string req := base.BizClient.NewCreateSSLRequest() @@ -1440,7 +1440,7 @@ func NewCmdSSLAdd(out io.Writer) *cobra.Command { return cmd } -//NewCmdSSLDelete ucloud ulb-ssl-certificate delete +// NewCmdSSLDelete ucloud ulb-ssl-certificate delete func NewCmdSSLDelete(out io.Writer) *cobra.Command { var idNames []string req := base.BizClient.NewDeleteSSLRequest() @@ -1473,7 +1473,7 @@ func NewCmdSSLDelete(out io.Writer) *cobra.Command { return cmd } -//NewCmdSSLBind ucloud ulb-ssl-certificate bind +// NewCmdSSLBind ucloud ulb-ssl-certificate bind func NewCmdSSLBind(out io.Writer) *cobra.Command { req := base.BizClient.NewBindSSLRequest() cmd := &cobra.Command{ @@ -1516,7 +1516,7 @@ func NewCmdSSLBind(out io.Writer) *cobra.Command { return cmd } -//NewCmdSSLUnbind ucloud ulb-ssl-certificate unbind +// NewCmdSSLUnbind ucloud ulb-ssl-certificate unbind func NewCmdSSLUnbind(out io.Writer) *cobra.Command { req := base.BizClient.NewUnbindSSLRequest() cmd := &cobra.Command{ diff --git a/cmd/umem.go b/cmd/umem.go index fc676da0d0..54054cdacd 100644 --- a/cmd/umem.go +++ b/cmd/umem.go @@ -30,7 +30,7 @@ import ( "github.com/ucloud/ucloud-cli/ux" ) -//NewCmdRedis ucloud redis +// NewCmdRedis ucloud redis func NewCmdRedis() *cobra.Command { cmd := &cobra.Command{ Use: "redis", @@ -45,7 +45,7 @@ func NewCmdRedis() *cobra.Command { return cmd } -//NewCmdMemcache ucloud memcache +// NewCmdMemcache ucloud memcache func NewCmdMemcache() *cobra.Command { cmd := &cobra.Command{ Use: "memcache", @@ -60,7 +60,7 @@ func NewCmdMemcache() *cobra.Command { return cmd } -//UMemRedisRow 表格行 +// UMemRedisRow 表格行 type UMemRedisRow struct { ResourceID string Name string @@ -80,7 +80,7 @@ var redisTypeMap = map[string]string{ "distributed": "distributed", } -//NewCmdRedisList ucloud redis list +// NewCmdRedisList ucloud redis list func NewCmdRedisList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeUMemRequest() cmd := &cobra.Command{ @@ -152,7 +152,7 @@ func NewCmdRedisList(out io.Writer) *cobra.Command { return cmd } -//NewCmdRedisCreate ucloud redis create +// NewCmdRedisCreate ucloud redis create func NewCmdRedisCreate(out io.Writer) *cobra.Command { req := base.BizClient.NewCreateURedisGroupRequest() req.HighAvailability = sdk.String("enable") @@ -235,7 +235,7 @@ func NewCmdRedisCreate(out io.Writer) *cobra.Command { return cmd } -//NewCmdRedisDelete ucloud redis delete +// NewCmdRedisDelete ucloud redis delete func NewCmdRedisDelete(out io.Writer) *cobra.Command { var idNames []string req := base.BizClient.NewDeleteURedisGroupRequest() @@ -288,7 +288,7 @@ func NewCmdRedisDelete(out io.Writer) *cobra.Command { return cmd } -//NewCmdRedisRestart ucloud redis restart +// NewCmdRedisRestart ucloud redis restart func NewCmdRedisRestart(out io.Writer) *cobra.Command { idNames := make([]string, 0) req := base.BizClient.UMemClient.NewRestartURedisGroupRequest() @@ -373,7 +373,7 @@ func getRedisIDList(project, region string) []string { return list } -//UMemMemcacheRow 表格行 +// UMemMemcacheRow 表格行 type UMemMemcacheRow struct { ResourceID string Name string @@ -385,7 +385,7 @@ type UMemMemcacheRow struct { CreateTime string } -//NewCmdMemcacheList ucloud memcache list +// NewCmdMemcacheList ucloud memcache list func NewCmdMemcacheList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeUMemcacheGroupRequest() cmd := &cobra.Command{ @@ -429,7 +429,7 @@ func NewCmdMemcacheList(out io.Writer) *cobra.Command { return cmd } -//NewCmdMemcacheCreate ucloud memcache create +// NewCmdMemcacheCreate ucloud memcache create func NewCmdMemcacheCreate(out io.Writer) *cobra.Command { req := base.BizClient.NewCreateUMemcacheGroupRequest() cmd := &cobra.Command{ @@ -477,7 +477,7 @@ func NewCmdMemcacheCreate(out io.Writer) *cobra.Command { return cmd } -//NewCmdMemcacheDelete ucloud memcache delete +// NewCmdMemcacheDelete ucloud memcache delete func NewCmdMemcacheDelete(out io.Writer) *cobra.Command { var idNames []string req := base.BizClient.NewDeleteUMemcacheGroupRequest() @@ -517,7 +517,7 @@ func NewCmdMemcacheDelete(out io.Writer) *cobra.Command { return cmd } -//NewCmdMemcacheRestart ucloud memcache restart +// NewCmdMemcacheRestart ucloud memcache restart func NewCmdMemcacheRestart(out io.Writer) *cobra.Command { idNames := make([]string, 0) req := base.BizClient.NewRestartUMemcacheGroupRequest() diff --git a/cmd/unet.go b/cmd/unet.go index 628fb36080..f4dead67c2 100644 --- a/cmd/unet.go +++ b/cmd/unet.go @@ -26,7 +26,7 @@ import ( "github.com/ucloud/ucloud-cli/base" ) -//NewCmdUDPN ucloud udpn +// NewCmdUDPN ucloud udpn func NewCmdUDPN(out io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "udpn", @@ -42,7 +42,7 @@ func NewCmdUDPN(out io.Writer) *cobra.Command { return cmd } -//NewCmdUDPNCreate ucloud udpn create +// NewCmdUDPNCreate ucloud udpn create func NewCmdUDPNCreate(out io.Writer) *cobra.Command { req := base.BizClient.NewAllocateUDPNRequest() cmd := &cobra.Command{ @@ -96,7 +96,7 @@ func NewCmdUDPNCreate(out io.Writer) *cobra.Command { return cmd } -//UDPNRow 表格行 +// UDPNRow 表格行 type UDPNRow struct { ResourceID string Peers string @@ -105,7 +105,7 @@ type UDPNRow struct { CreationTime string } -//NewCmdUDPNList ucloud udpn list +// NewCmdUDPNList ucloud udpn list func NewCmdUDPNList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeUDPNRequest() cmd := &cobra.Command{ @@ -151,7 +151,7 @@ func NewCmdUDPNList(out io.Writer) *cobra.Command { return cmd } -//NewCmdUdpnDelete ucloud udpn delete +// NewCmdUdpnDelete ucloud udpn delete func NewCmdUdpnDelete(out io.Writer) *cobra.Command { idNames := []string{} req := base.BizClient.NewReleaseUDPNRequest() @@ -187,7 +187,7 @@ func NewCmdUdpnDelete(out io.Writer) *cobra.Command { return cmd } -//NewCmdUdpnModifyBW ucloud udpn modify-bw +// NewCmdUdpnModifyBW ucloud udpn modify-bw func NewCmdUdpnModifyBW(out io.Writer) *cobra.Command { idNames := []string{} req := base.BizClient.NewModifyUDPNBandwidthRequest() diff --git a/cmd/uphost.go b/cmd/uphost.go index e9b4b02a68..e902c0130b 100644 --- a/cmd/uphost.go +++ b/cmd/uphost.go @@ -22,7 +22,7 @@ import ( "github.com/ucloud/ucloud-cli/base" ) -//NewCmdUPHost ucloud uphost +// NewCmdUPHost ucloud uphost func NewCmdUPHost() *cobra.Command { cmd := &cobra.Command{ Use: "uphost", @@ -48,7 +48,7 @@ type uphostRow struct { Group string } -//NewCmdUPHostList ucloud uphost list +// NewCmdUPHostList ucloud uphost list func NewCmdUPHostList(out io.Writer) *cobra.Command { ids := []string{} req := base.BizClient.NewDescribePHostRequest() diff --git a/cmd/vpc.go b/cmd/vpc.go index 565e20a21c..f6ecd02db9 100644 --- a/cmd/vpc.go +++ b/cmd/vpc.go @@ -15,7 +15,7 @@ import ( "github.com/ucloud/ucloud-cli/base" ) -//NewCmdVpc ucloud vpc +// NewCmdVpc ucloud vpc func NewCmdVpc() *cobra.Command { cmd := &cobra.Command{ Use: "vpc", @@ -33,7 +33,7 @@ func NewCmdVpc() *cobra.Command { return cmd } -//VPCRow 表格行 +// VPCRow 表格行 type VPCRow struct { VPCName string ResourceID string @@ -43,7 +43,7 @@ type VPCRow struct { CreationTime string } -//NewCmdVPCList ucloud vpc list +// NewCmdVPCList ucloud vpc list func NewCmdVPCList(out io.Writer) *cobra.Command { vpcIDs := []string{} req := base.BizClient.NewDescribeVPCRequest() @@ -89,7 +89,7 @@ func NewCmdVPCList(out io.Writer) *cobra.Command { return cmd } -//NewCmdVpcCreate ucloud vpc create +// NewCmdVpcCreate ucloud vpc create func NewCmdVpcCreate() *cobra.Command { var segments *[]string req := base.BizClient.NewCreateVPCRequest() @@ -129,7 +129,7 @@ func NewCmdVpcCreate() *cobra.Command { return cmd } -//NewCmdVpcDelete ucloud vpc delete +// NewCmdVpcDelete ucloud vpc delete func NewCmdVpcDelete() *cobra.Command { idNames := []string{} req := base.BizClient.NewDeleteVPCRequest() @@ -166,7 +166,7 @@ func NewCmdVpcDelete() *cobra.Command { return cmd } -//NewCmdVpcCreatePeer ucloud vpc peer +// NewCmdVpcCreatePeer ucloud vpc peer func NewCmdVpcCreatePeer() *cobra.Command { req := base.BizClient.NewCreateVPCIntercomRequest() cmd := &cobra.Command{ @@ -214,7 +214,7 @@ func NewCmdVpcCreatePeer() *cobra.Command { return cmd } -//VPCIntercomRow 表格行 +// VPCIntercomRow 表格行 type VPCIntercomRow struct { VPCName string ResourceID string @@ -224,7 +224,7 @@ type VPCIntercomRow struct { Group string } -//NewCmdVpcListPeer ucloud vpc list-intercome +// NewCmdVpcListPeer ucloud vpc list-intercome func NewCmdVpcListPeer(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeVPCIntercomRequest() cmd := &cobra.Command{ @@ -268,7 +268,7 @@ func NewCmdVpcListPeer(out io.Writer) *cobra.Command { return cmd } -//NewCmdVpcDeletePeer ucloud vpc delete-intercome +// NewCmdVpcDeletePeer ucloud vpc delete-intercome func NewCmdVpcDeletePeer() *cobra.Command { req := base.BizClient.NewDeleteVPCIntercomRequest() cmd := &cobra.Command{ @@ -331,7 +331,7 @@ func getAllVPCIdNames(project, region string) []string { return list } -//NewCmdSubnet ucloud subnet +// NewCmdSubnet ucloud subnet func NewCmdSubnet() *cobra.Command { cmd := &cobra.Command{ Use: "subnet", @@ -348,7 +348,7 @@ func NewCmdSubnet() *cobra.Command { return cmd } -//SubnetRow 表格行 +// SubnetRow 表格行 type SubnetRow struct { SubnetName string ResourceID string @@ -358,7 +358,7 @@ type SubnetRow struct { CreationTime string } -//NewCmdSubnetList ucloud subnet list +// NewCmdSubnetList ucloud subnet list func NewCmdSubnetList(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeSubnetRequest() cmd := &cobra.Command{ @@ -400,7 +400,7 @@ func NewCmdSubnetList(out io.Writer) *cobra.Command { return cmd } -//NewCmdSubnetCreate ucloud subnet create +// NewCmdSubnetCreate ucloud subnet create func NewCmdSubnetCreate() *cobra.Command { var segment *net.IPNet req := base.BizClient.NewCreateSubnetRequest() @@ -448,7 +448,7 @@ func NewCmdSubnetCreate() *cobra.Command { return cmd } -//NewCmdSubnetDelete ucloud subnet delete +// NewCmdSubnetDelete ucloud subnet delete func NewCmdSubnetDelete(out io.Writer) *cobra.Command { idNames := []string{} req := base.BizClient.NewDeleteSubnetRequest() @@ -484,7 +484,7 @@ func NewCmdSubnetDelete(out io.Writer) *cobra.Command { return cmd } -//SubnetResourceRow 表格行 +// SubnetResourceRow 表格行 type SubnetResourceRow struct { ResourceName string ResourceID string @@ -492,7 +492,7 @@ type SubnetResourceRow struct { PrivateIP string } -//NewCmdSubnetListResource ucloud subnet list-resource +// NewCmdSubnetListResource ucloud subnet list-resource func NewCmdSubnetListResource(out io.Writer) *cobra.Command { req := base.BizClient.NewDescribeSubnetResourceRequest() cmd := &cobra.Command{ diff --git a/model/context.go b/model/context.go index 0177aa1c43..d41e3019fd 100644 --- a/model/context.go +++ b/model/context.go @@ -15,35 +15,35 @@ type Context struct { data map[string]interface{} } -//Print 打印一行 +// Print 打印一行 func (c *Context) Print(a ...interface{}) (n int, err error) { text := fmt.Sprint(a...) n, err = c.writer.Write([]byte(text)) return } -//Println 打印一行 +// Println 打印一行 func (c *Context) Println(a ...interface{}) (n int, err error) { text := fmt.Sprintln(a...) n, err = c.writer.Write([]byte(text)) return } -//Printf 根据格式字符串打印 +// Printf 根据格式字符串打印 func (c *Context) Printf(format string, a ...interface{}) (n int, err error) { text := fmt.Sprintf(format, a...) n, err = c.writer.Write([]byte(text)) return } -//PrintErr 打印错误 +// PrintErr 打印错误 func (c *Context) PrintErr(uerr error) (n int, err error) { text := fmt.Sprintf("Error:%v\n", uerr) n, err = c.writer.Write([]byte(text)) return } -//GetWriter 获取Writer +// GetWriter 获取Writer func (c *Context) GetWriter() io.Writer { return c.writer } diff --git a/ux/document.go b/ux/document.go index 98b3060cbe..3d1a659989 100644 --- a/ux/document.go +++ b/ux/document.go @@ -12,7 +12,7 @@ import ( var width, rows, _ = terminalSize() -//Document 当前进程在打印的内容 +// Document 当前进程在打印的内容 type document struct { blocks []*Block mux sync.RWMutex @@ -98,10 +98,10 @@ func newDocument(out io.Writer) *document { return doc } -//Doc global document +// Doc global document var Doc = newDocument(os.Stdout) -//Block in document, including a spinner and some text +// Block in document, including a spinner and some text type Block struct { spinner *Spin spinnerIndex int @@ -111,17 +111,17 @@ type Block struct { getLines chan []string } -//Update lines in Block +// Update lines in Block func (b *Block) Update(text string, index int) { b.updateLine <- updateBlockLine{text, index} } -//Append text to Block +// Append text to Block func (b *Block) Append(text string) { b.updateLine <- updateBlockLine{text, -1} } -//SetSpin set spin for block +// SetSpin set spin for block func (b *Block) SetSpin(s *Spin) error { if b.spinner != nil { return fmt.Errorf("block has spinner already") @@ -146,7 +146,7 @@ type updateBlockLine struct { index int } -//NewSpinBlock create a new Block with spinner +// NewSpinBlock create a new Block with spinner func NewSpinBlock(s *Spin) *Block { block := NewBlock() if s != nil { @@ -155,7 +155,7 @@ func NewSpinBlock(s *Spin) *Block { return block } -//NewBlock create a new Block without spinner. block.Stable closed +// NewBlock create a new Block without spinner. block.Stable closed func NewBlock() *Block { block := &Block{ lines: []string{}, diff --git a/ux/spinner.go b/ux/spinner.go index 711943b284..56ac43f45f 100644 --- a/ux/spinner.go +++ b/ux/spinner.go @@ -102,7 +102,7 @@ var spinnerFrames = []rune{'⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷ // DotSpinner dot spinner var DotSpinner = NewDotSpinner(os.Stdout) -//NewDotSpinner get new DotSpinner instance +// NewDotSpinner get new DotSpinner instance func NewDotSpinner(out io.Writer) *Spinner { return &Spinner{ out: out, @@ -114,13 +114,13 @@ func NewDotSpinner(out io.Writer) *Spinner { } } -//Refresh 刷新显示文本 +// Refresh 刷新显示文本 type Refresh struct { out io.Writer reset bool } -//Do 刷新显示 +// Do 刷新显示 func (r *Refresh) Do(text string) { if r.reset { fmt.Fprintf(r.out, ansi.CursorLeft+ansi.CursorUp(1)+ansi.EraseDown) @@ -130,7 +130,7 @@ func (r *Refresh) Do(text string) { fmt.Fprintln(r.out, text) } -//NewRefresh create a new Refresh instance +// NewRefresh create a new Refresh instance func NewRefresh() *Refresh { return &Refresh{ out: os.Stdout, diff --git a/ux/spinnerv2.go b/ux/spinnerv2.go index 1118759307..5469bf87fa 100644 --- a/ux/spinnerv2.go +++ b/ux/spinnerv2.go @@ -107,7 +107,7 @@ func (s *Spin) newFrameFactory() func() rune { var spinFrames = []rune{'⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷'} -//NewDotSpin get new DotSpinner instance +// NewDotSpin get new DotSpinner instance func NewDotSpin(out io.Writer, doingText string) *Spin { s := &Spin{ out: out, diff --git a/ux/terminal_win.go b/ux/terminal_win.go index f692151825..ba9b9d5171 100644 --- a/ux/terminal_win.go +++ b/ux/terminal_win.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package ux diff --git a/ux/terminal_x.go b/ux/terminal_x.go index 74a2a76d1e..3d71bcc4be 100644 --- a/ux/terminal_x.go +++ b/ux/terminal_x.go @@ -1,3 +1,4 @@ +//go:build linux || darwin || freebsd || netbsd || openbsd || solaris || dragonfly // +build linux darwin freebsd netbsd openbsd solaris dragonfly package ux