(f *cmdutil.Factory, appVersion string)
| 35 | } |
| 36 | |
| 37 | func searchClient(f *cmdutil.Factory, appVersion string) func() (*search.APIClient, error) { |
| 38 | return func() (*search.APIClient, error) { |
| 39 | appID, err := f.Config.Profile().GetApplicationID() |
| 40 | if err != nil { |
| 41 | return nil, err |
| 42 | } |
| 43 | apiKey, err := f.Config.Profile().GetAPIKey() |
| 44 | if err != nil { |
| 45 | return nil, err |
| 46 | } |
| 47 | |
| 48 | userAgent, err := getUserAgentInfo(appID, apiKey, appVersion) |
| 49 | if err != nil { |
| 50 | return nil, err |
| 51 | } |
| 52 | if userAgent == "" { |
| 53 | return nil, fmt.Errorf("user agent must not be empty") |
| 54 | } |
| 55 | |
| 56 | clientConf := search.SearchConfiguration{ |
| 57 | Configuration: transport.Configuration{ |
| 58 | AppID: appID, |
| 59 | ApiKey: apiKey, |
| 60 | UserAgent: userAgent, |
| 61 | ExposeIntermediateNetworkErrors: true, |
| 62 | }, |
| 63 | } |
| 64 | |
| 65 | // Read custom hosts from flags, environment, or profile, or use default ones |
| 66 | hosts := GetStatefulHosts(f.Config.Profile().GetSearchHosts()) |
| 67 | if len(hosts) > 0 { |
| 68 | clientConf.Configuration.Hosts = hosts |
| 69 | } |
| 70 | |
| 71 | return search.NewClientWithConfig(clientConf) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | func crawlerClient(f *cmdutil.Factory) func() (*crawler.Client, error) { |
| 76 | return func() (*crawler.Client, error) { |
no test coverage detected