( client *search.APIClient, index string, scope []string, cs *iostreams.ColorScheme, )
| 49 | } |
| 50 | |
| 51 | func GetIndexConfig( |
| 52 | client *search.APIClient, |
| 53 | index string, |
| 54 | scope []string, |
| 55 | cs *iostreams.ColorScheme, |
| 56 | ) (*ExportConfigJSON, error) { |
| 57 | var configJSON ExportConfigJSON |
| 58 | |
| 59 | if utils.Contains(scope, "synonyms") { |
| 60 | rawSynonyms, err := GetSynonyms(client, index) |
| 61 | if err != nil { |
| 62 | return nil, fmt.Errorf( |
| 63 | "%s An error occurred when retrieving synonyms: %w", |
| 64 | cs.FailureIcon(), |
| 65 | err, |
| 66 | ) |
| 67 | } |
| 68 | configJSON.Synonyms = rawSynonyms |
| 69 | } |
| 70 | |
| 71 | if utils.Contains(scope, "rules") { |
| 72 | rawRules, err := GetRules(client, index) |
| 73 | if err != nil { |
| 74 | return nil, fmt.Errorf( |
| 75 | "%s An error occurred when retrieving rules: %w", |
| 76 | cs.FailureIcon(), |
| 77 | err, |
| 78 | ) |
| 79 | } |
| 80 | configJSON.Rules = rawRules |
| 81 | } |
| 82 | |
| 83 | if utils.Contains(scope, "settings") { |
| 84 | rawSettings, err := client.GetSettings(client.NewApiGetSettingsRequest(index)) |
| 85 | if err != nil { |
| 86 | return nil, fmt.Errorf( |
| 87 | "%s An error occurred when retrieving settings: %w", |
| 88 | cs.FailureIcon(), |
| 89 | err, |
| 90 | ) |
| 91 | } |
| 92 | configJSON.Settings = rawSettings |
| 93 | } |
| 94 | |
| 95 | if len(configJSON.Rules) == 0 && len(configJSON.Synonyms) == 0 && configJSON.Settings == nil { |
| 96 | return nil, fmt.Errorf("%s No config to export", cs.FailureIcon()) |
| 97 | } |
| 98 | |
| 99 | return &configJSON, nil |
| 100 | } |
nothing calls this directly
no test coverage detected