Merge branch 'update_status' into 'master'
Update status See merge request integration-system/isp-ctl!1
This commit is contained in:
commit
690e9d6f44
7 files changed
+37
-22
No files matched your search
@@ -1,3 +1,5 @@
|
||||
## v2.1.0
|
||||
* add output format for `status`
|
||||
## v2.0.1
|
||||
* print module version in `status` command
|
||||
## v2.0.0
|
||||
|
||||
@@ -45,7 +45,7 @@ instanceUuid: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
|
||||
## Использование
|
||||
```bash
|
||||
ispctl [flag...] status
|
||||
ispctl [flag...] status [local_flag]
|
||||
ispctl [flag...] get module_name property_path [local_flag]
|
||||
ispctl [flag...] set module_name property_path [new_object]
|
||||
ispctl [flag...] delete module_name property_path
|
||||
@@ -109,7 +109,10 @@ ispctl [flag...] common contain config_name
|
||||
|
||||
## Пример
|
||||
### ispctl status
|
||||
`ispctl [flag...] status`
|
||||
`ispctl [flag...] status [local_flag]`
|
||||
|
||||
`[local_flag]` - локальный флаг `-o` определяет формат вывода доступных конфигураций и состояний модулей. Доступные значения: `json`.
|
||||
По умолчанию вывод осуществляется в виде таблицы.
|
||||
|
||||
Запрос
|
||||
```bash
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ func Schema() cli.Command {
|
||||
Usage: "get schema configuration by module_name",
|
||||
Action: schema.action,
|
||||
Flags: []cli.Flag{
|
||||
flag.OutPrint,
|
||||
flag.OutPrintSchema,
|
||||
},
|
||||
BashComplete: bash.Get(bash.ModuleName, bash.Empty).Complete,
|
||||
}
|
||||
@@ -39,7 +39,7 @@ func (s schemaCommand) action(ctx *cli.Context) {
|
||||
schema := make(map[string]interface{})
|
||||
schema["title"] = moduleName
|
||||
schema["schema"] = schemaConfig
|
||||
switch ctx.String(flag.OutPrint.Name) {
|
||||
switch ctx.String(flag.OutPrintSchema.Name) {
|
||||
case flag.OutPrintJsonValue:
|
||||
utils.PrintAnswer(schema)
|
||||
case flag.OutPrintHtmlValue:
|
||||
|
||||
+23
-15
@@ -25,6 +25,9 @@ func Status() cli.Command {
|
||||
Name: "status",
|
||||
Usage: "get available configs",
|
||||
Action: status.action,
|
||||
Flags: []cli.Flag{
|
||||
flag.OutPrintStatus,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,22 +43,27 @@ func (statusCommand) action(ctx *cli.Context) {
|
||||
if arrayOfModules, err := service.Config.GetAvailableConfigs(); err != nil {
|
||||
utils.PrintError(err)
|
||||
} else {
|
||||
table := tablewriter.NewWriter(os.Stdout)
|
||||
table.SetBorders(tablewriter.Border{Left: false, Top: false, Right: false, Bottom: false})
|
||||
table.SetHeader([]string{tableHeaderModuleName, tableHeaderStatus, tableHeaderAddresses})
|
||||
for _, module := range arrayOfModules {
|
||||
addresses := ""
|
||||
connection := tableNotConnectedStatus
|
||||
instanceList := make([]string, 0, len(module.Status))
|
||||
for _, value := range module.Status {
|
||||
instanceList = append(instanceList, fmt.Sprintf("%s %s", value.Address.GetAddress(), value.Version))
|
||||
switch ctx.String(flag.OutPrintStatus.Name) {
|
||||
case flag.OutPrintJsonValue:
|
||||
utils.PrintAnswer(arrayOfModules)
|
||||
default:
|
||||
table := tablewriter.NewWriter(os.Stdout)
|
||||
table.SetBorders(tablewriter.Border{Left: false, Top: false, Right: false, Bottom: false})
|
||||
table.SetHeader([]string{tableHeaderModuleName, tableHeaderStatus, tableHeaderAddresses})
|
||||
for _, module := range arrayOfModules {
|
||||
addresses := ""
|
||||
connection := tableNotConnectedStatus
|
||||
instanceList := make([]string, 0, len(module.Status))
|
||||
for _, value := range module.Status {
|
||||
instanceList = append(instanceList, fmt.Sprintf("%s %s", value.Address.GetAddress(), value.Version))
|
||||
}
|
||||
addresses = strings.Join(instanceList, "\n")
|
||||
if addresses != "" {
|
||||
connection = tableConnectedStatus
|
||||
}
|
||||
table.Append([]string{module.Name, connection, addresses})
|
||||
}
|
||||
addresses = strings.Join(instanceList, "\n")
|
||||
if addresses != "" {
|
||||
connection = tableConnectedStatus
|
||||
}
|
||||
table.Append([]string{module.Name, connection, addresses})
|
||||
table.Render()
|
||||
}
|
||||
table.Render()
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -24,5 +24,6 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
outPrintUsage = fmt.Sprintf("out print for schema; %s or %s", OutPrintJsonValue, OutPrintHtmlValue)
|
||||
outPrintStatusUsage = fmt.Sprintf("out print for status; %s", OutPrintJsonValue)
|
||||
outPrintSchemaUsage = fmt.Sprintf("out print for schema; %s or %s", OutPrintJsonValue, OutPrintHtmlValue)
|
||||
)
|
||||
+2
-1
@@ -13,7 +13,8 @@ var (
|
||||
Color = cli.BoolFlag{Name: colorName, Usage: colorUsage}
|
||||
Unsafe = cli.BoolFlag{Name: unsafeName, Usage: unsafeUsage}
|
||||
//---local---
|
||||
OutPrint = cli.StringFlag{Name: outPrintName, Usage: outPrintUsage, Value: OutPrintJsonValue}
|
||||
OutPrintStatus = cli.StringFlag{Name: outPrintName, Usage: outPrintStatusUsage}
|
||||
OutPrintSchema = cli.StringFlag{Name: outPrintName, Usage: outPrintSchemaUsage, Value: OutPrintJsonValue}
|
||||
WithCommonConfig = cli.BoolFlag{Name: withCommonConfigName, Usage: withCommonConfigUsage}
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user