(f *cmdutil.Factory, appVersion string)
| 88 | } |
| 89 | |
| 90 | func compositionClient(f *cmdutil.Factory, appVersion string) func() (*composition.APIClient, error) { |
| 91 | return func() (*composition.APIClient, error) { |
| 92 | appID, err := f.Config.Profile().GetApplicationID() |
| 93 | if err != nil { |
| 94 | return nil, err |
| 95 | } |
| 96 | apiKey, err := f.Config.Profile().GetAPIKey() |
| 97 | if err != nil { |
| 98 | return nil, err |
| 99 | } |
| 100 | |
| 101 | userAgent, err := getUserAgentInfo(appID, apiKey, appVersion) |
| 102 | if err != nil { |
| 103 | return nil, err |
| 104 | } |
| 105 | |
| 106 | clientConf := composition.CompositionConfiguration{ |
| 107 | Configuration: transport.Configuration{ |
| 108 | AppID: appID, |
| 109 | ApiKey: apiKey, |
| 110 | UserAgent: userAgent, |
| 111 | ExposeIntermediateNetworkErrors: true, |
| 112 | }, |
| 113 | } |
| 114 | |
| 115 | return composition.NewClientWithConfig(clientConf) |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | // getUserAgentInfo returns the standard user agent info plus Algolia CLI |
| 120 | func getUserAgentInfo(appID string, apiKey string, appVersion string) (string, error) { |
no test coverage detected