-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhealth_clear_error.go
More file actions
54 lines (47 loc) · 1.58 KB
/
health_clear_error.go
File metadata and controls
54 lines (47 loc) · 1.58 KB
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
package health
import (
"fmt"
"github.com/spf13/cobra"
"github.com/stackvista/stackstate-cli/generated/stackstate_api"
"github.com/stackvista/stackstate-cli/internal/common"
"github.com/stackvista/stackstate-cli/internal/di"
)
type ClearErrorArgs struct {
Urn string
}
func HealthClearErrorCommand(cli *di.Deps) *cobra.Command {
args := &ClearErrorArgs{}
cmd := &cobra.Command{
Use: "clear-error",
Short: "Clear errors from a health synchronization stream",
Long: `Clear errors from a health synchronization stream, allowing it to resume normal operation. Use this after resolving the underlying cause of synchronization errors.
More info: https://l.stackstate.com/cli-health-synchronization.`,
Example: `# clear errors from a health stream
sts health clear-error --urn urn:health:my-stream`,
RunE: cli.CmdRunEWithApi(RunHealthClearErrorCommand(args)),
}
common.AddRequiredUrnFlagVar(cmd, &args.Urn, "URN of the health synchronization stream")
return cmd
}
func RunHealthClearErrorCommand(args *ClearErrorArgs) di.CmdWithApiFn {
return func(
cmd *cobra.Command,
cli *di.Deps,
api *stackstate_api.APIClient,
serverInfo *stackstate_api.ServerInfo,
) common.CLIError {
resp, err := api.HealthSynchronizationApi.PostHealthSynchronizationStreamClearErrors(cli.Context, args.Urn).Execute()
if err != nil {
return common.NewResponseError(err, resp)
}
if cli.IsJson() {
cli.Printer.PrintJson(map[string]interface{}{
"stream-error-clear": args.Urn,
})
} else {
msg := fmt.Sprintf("Stream error clear: %s", args.Urn)
cli.Printer.Success(msg)
}
return nil
}
}