WIP: cli: Change --await flag semantics in control set-status
Some checks failed
Tests and linters / Run gofumpt (pull_request) Successful in 1m37s
DCO action / DCO (pull_request) Failing after 1m53s
Tests and linters / Staticcheck (pull_request) Failing after 2m13s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m24s
Vulncheck / Vulncheck (pull_request) Successful in 2m17s
Build / Build Components (pull_request) Successful in 2m41s
Tests and linters / Lint (pull_request) Failing after 2m47s
Tests and linters / gopls check (pull_request) Successful in 2m57s
Tests and linters / Tests (pull_request) Successful in 4m31s
Tests and linters / Tests with -race (pull_request) Successful in 6m12s

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-11-14 10:20:34 +03:00
parent a3eb359621
commit 5cdca40598
Signed by: fyrchik
SSH key fingerprint: SHA256:m/TTwCzjnRkXgnzEx9X92ccxy1CcVeinOgDb3NPWWmg

View file

@ -68,18 +68,20 @@ func setNetmapStatus(cmd *cobra.Command, _ []string) {
} }
await, _ := cmd.Flags().GetBool(commonflags.AwaitFlag) await, _ := cmd.Flags().GetBool(commonflags.AwaitFlag)
var targetStatus control.NetmapStatus body.SetAwait(await)
// /var targetStatus control.NetmapStatus
switch st, _ := cmd.Flags().GetString(netmapStatusFlag); st { switch st, _ := cmd.Flags().GetString(netmapStatusFlag); st {
default: default:
commonCmd.ExitOnErr(cmd, "", fmt.Errorf("unsupported status %s", st)) commonCmd.ExitOnErr(cmd, "", fmt.Errorf("unsupported status %s", st))
case netmapStatusOnline: case netmapStatusOnline:
body.SetStatus(control.NetmapStatus_ONLINE) body.SetStatus(control.NetmapStatus_ONLINE)
printIgnoreForce(control.NetmapStatus_ONLINE) printIgnoreForce(control.NetmapStatus_ONLINE)
targetStatus = control.NetmapStatus_ONLINE // targetStatus = control.NetmapStatus_ONLINE
case netmapStatusOffline: case netmapStatusOffline:
body.SetStatus(control.NetmapStatus_OFFLINE) body.SetStatus(control.NetmapStatus_OFFLINE)
printIgnoreForce(control.NetmapStatus_OFFLINE) printIgnoreForce(control.NetmapStatus_OFFLINE)
targetStatus = control.NetmapStatus_OFFLINE // targetStatus = control.NetmapStatus_OFFLINE
case netmapStatusMaintenance: case netmapStatusMaintenance:
body.SetStatus(control.NetmapStatus_MAINTENANCE) body.SetStatus(control.NetmapStatus_MAINTENANCE)
@ -87,7 +89,7 @@ func setNetmapStatus(cmd *cobra.Command, _ []string) {
body.SetForceMaintenance(true) body.SetForceMaintenance(true)
common.PrintVerbose(cmd, "Local maintenance will be forced.") common.PrintVerbose(cmd, "Local maintenance will be forced.")
} }
targetStatus = control.NetmapStatus_MAINTENANCE // targetStatus = control.NetmapStatus_MAINTENANCE
} }
req := new(control.SetNetmapStatusRequest) req := new(control.SetNetmapStatusRequest)
@ -109,9 +111,9 @@ func setNetmapStatus(cmd *cobra.Command, _ []string) {
cmd.Println("Network status update request successfully sent.") cmd.Println("Network status update request successfully sent.")
if await { // if await {
awaitSetNetmapStatus(cmd, pk, cli, targetStatus) // awaitSetNetmapStatus(cmd, pk, cli, targetStatus)
} // }
} }
func awaitSetNetmapStatus(cmd *cobra.Command, pk *ecdsa.PrivateKey, cli *client.Client, targetStatus control.NetmapStatus) { func awaitSetNetmapStatus(cmd *cobra.Command, pk *ecdsa.PrivateKey, cli *client.Client, targetStatus control.NetmapStatus) {