From 10f1be3bd409eab3d1326d36a1477e85fba55793 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Fri, 15 Sep 2023 13:40:52 +0300 Subject: [PATCH] [cli] Code refactoring --- cli/command_clients.go | 5 ++++- cli/common.go | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cli/command_clients.go b/cli/command_clients.go index 1ced0af..29bf9e6 100644 --- a/cli/command_clients.go +++ b/cli/command_clients.go @@ -51,7 +51,10 @@ func ClientsCommand(args CommandArgs) int { req := &REDIS.Request{ Command: []string{"CLIENT", "LIST", "TYPE", "NORMAL"}, Port: CORE.GetInstancePort(id), - Auth: REDIS.Auth{CORE.REDIS_USER_ADMIN, meta.Preferencies.AdminPassword}, + Auth: REDIS.Auth{ + User: CORE.REDIS_USER_ADMIN, + Password: meta.Preferencies.AdminPassword, + }, Timeout: time.Second, } diff --git a/cli/common.go b/cli/common.go index 1375ec6..e996beb 100644 --- a/cli/common.go +++ b/cli/common.go @@ -472,11 +472,12 @@ func warnAboutUnsafeAction(id int, message string) bool { case 5: ops, err := getCurrentInstanceTraffic(id) - if ops > 10 { + switch { + case ops > 10: terminal.Warn("There is some traffic on the instance (%d ops/s).", ops) - } else if err != nil { + case err != nil: terminal.Warn("Can't measure the number of operations on the instance.") - } else { + default: continue } }