77 "github.com/spf13/cobra"
88
99 "github.com/algolia/algoliasearch-client-go/v4/algolia/search"
10+ "github.com/algolia/algoliasearch-client-go/v4/algolia/transport"
11+ "github.com/algolia/cli/pkg/cmd/factory"
1012 "github.com/algolia/cli/pkg/cmdutil"
1113 "github.com/algolia/cli/pkg/config"
1214 "github.com/algolia/cli/pkg/iostreams"
@@ -80,7 +82,7 @@ func runListCmd(opts *ListOptions) error {
8082 if apiKey == "" || profile .ApplicationID == "" {
8183 table .AddField ("N/A" , nil , nil )
8284 } else {
83- client , err := search . NewClient (profile . ApplicationID , apiKey )
85+ client , err := newSearchClient (profile , apiKey )
8486 if err != nil {
8587 table .AddField (err .Error (), nil , nil )
8688 } else {
@@ -103,3 +105,17 @@ func runListCmd(opts *ListOptions) error {
103105 opts .IO .StopProgressIndicator ()
104106 return table .Render ()
105107}
108+
109+ func newSearchClient (profile * config.Profile , apiKey string ) (* search.APIClient , error ) {
110+ hosts := factory .GetStatefulHosts (profile .GetSearchHosts ())
111+ if len (hosts ) > 0 {
112+ return search .NewClientWithConfig (search.SearchConfiguration {
113+ Configuration : transport.Configuration {
114+ AppID : profile .ApplicationID ,
115+ ApiKey : apiKey ,
116+ Hosts : hosts ,
117+ },
118+ })
119+ }
120+ return search .NewClient (profile .ApplicationID , apiKey )
121+ }
0 commit comments