(opts *SetOptions)
| 78 | } |
| 79 | |
| 80 | func runSetCmd(opts *SetOptions) error { |
| 81 | client, err := opts.SearchClient() |
| 82 | if err != nil { |
| 83 | return err |
| 84 | } |
| 85 | |
| 86 | opts.IO.StartProgressIndicatorWithLabel( |
| 87 | fmt.Sprintf("Setting settings for index %s", opts.Index), |
| 88 | ) |
| 89 | |
| 90 | res, err := client.SetSettings( |
| 91 | client.NewApiSetSettingsRequest(opts.Index, &opts.Settings). |
| 92 | WithForwardToReplicas(opts.ForwardToReplicas), |
| 93 | ) |
| 94 | if err != nil { |
| 95 | opts.IO.StopProgressIndicator() |
| 96 | return err |
| 97 | } |
| 98 | |
| 99 | if opts.Wait { |
| 100 | opts.IO.UpdateProgressIndicatorLabel("Waiting for the task to complete") |
| 101 | _, err := client.WaitForTask(opts.Index, res.TaskID) |
| 102 | if err != nil { |
| 103 | opts.IO.StopProgressIndicator() |
| 104 | return err |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | opts.IO.StopProgressIndicator() |
| 109 | |
| 110 | cs := opts.IO.ColorScheme() |
| 111 | if opts.IO.IsStdoutTTY() { |
| 112 | fmt.Fprintf(opts.IO.Out, "%s Set settings on %v\n", cs.SuccessIcon(), opts.Index) |
| 113 | } |
| 114 | |
| 115 | return nil |
| 116 | } |
no test coverage detected