(opts *ImportOptions)
| 72 | } |
| 73 | |
| 74 | func runImportCmd(opts *ImportOptions) error { |
| 75 | client, err := opts.SearchClient() |
| 76 | if err != nil { |
| 77 | return err |
| 78 | } |
| 79 | |
| 80 | opts.IO.StartProgressIndicatorWithLabel(fmt.Sprint("Importing settings to index ", opts.Index)) |
| 81 | res, err := client.SetSettings( |
| 82 | client.NewApiSetSettingsRequest(opts.Index, &opts.Settings). |
| 83 | WithForwardToReplicas(opts.ForwardToReplicas), |
| 84 | ) |
| 85 | if err != nil { |
| 86 | opts.IO.StopProgressIndicator() |
| 87 | return err |
| 88 | } |
| 89 | |
| 90 | if opts.Wait { |
| 91 | opts.IO.UpdateProgressIndicatorLabel("Waiting for the task to complete") |
| 92 | _, err := client.WaitForTask(opts.Index, res.TaskID) |
| 93 | if err != nil { |
| 94 | opts.IO.StopProgressIndicator() |
| 95 | return err |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | opts.IO.StopProgressIndicator() |
| 100 | |
| 101 | cs := opts.IO.ColorScheme() |
| 102 | if opts.IO.IsStdoutTTY() { |
| 103 | fmt.Fprintf(opts.IO.Out, "%s Imported settings on %v\n", cs.SuccessIcon(), opts.Index) |
| 104 | } |
| 105 | |
| 106 | return nil |
| 107 | } |
no test coverage detected