55 "fmt"
66 "strings"
77
8- "github.com/aws/aws-sdk-go/aws/session "
8+ "github.com/aws/aws-sdk-go-v2/config "
99 "github.com/segmentio/kafka-go"
1010 "github.com/segmentio/topicctl/pkg/admin"
1111 "github.com/segmentio/topicctl/pkg/cli"
@@ -95,9 +95,12 @@ func balanceCmd() *cobra.Command {
9595 Args : cobra .MaximumNArgs (1 ),
9696 RunE : func (cmd * cobra.Command , args []string ) error {
9797 ctx := context .Background ()
98- sess := session .Must (session .NewSession ())
98+ cfg , err := config .LoadDefaultConfig (ctx )
99+ if err != nil {
100+ return err
101+ }
99102
100- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
103+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
101104 if err != nil {
102105 return err
103106 }
@@ -122,9 +125,12 @@ func brokersCmd() *cobra.Command {
122125 Args : cobra .NoArgs ,
123126 RunE : func (cmd * cobra.Command , args []string ) error {
124127 ctx := context .Background ()
125- sess := session .Must (session .NewSession ())
128+ cfg , err := config .LoadDefaultConfig (ctx )
129+ if err != nil {
130+ return err
131+ }
126132
127- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
133+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
128134 if err != nil {
129135 return err
130136 }
@@ -143,9 +149,12 @@ func controllerCmd() *cobra.Command {
143149 Args : cobra .NoArgs ,
144150 RunE : func (cmd * cobra.Command , args []string ) error {
145151 ctx := context .Background ()
146- sess := session .Must (session .NewSession ())
152+ cfg , err := config .LoadDefaultConfig (ctx )
153+ if err != nil {
154+ return err
155+ }
147156
148- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
157+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
149158 if err != nil {
150159 return err
151160 }
@@ -164,9 +173,12 @@ func clusterIDCmd() *cobra.Command {
164173 Args : cobra .NoArgs ,
165174 RunE : func (cmd * cobra.Command , args []string ) error {
166175 ctx := context .Background ()
167- sess := session .Must (session .NewSession ())
176+ cfg , err := config .LoadDefaultConfig (ctx )
177+ if err != nil {
178+ return err
179+ }
168180
169- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
181+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
170182 if err != nil {
171183 return err
172184 }
@@ -185,9 +197,12 @@ func configCmd() *cobra.Command {
185197 Args : cobra .ExactArgs (1 ),
186198 RunE : func (cmd * cobra.Command , args []string ) error {
187199 ctx := context .Background ()
188- sess := session .Must (session .NewSession ())
200+ cfg , err := config .LoadDefaultConfig (ctx )
201+ if err != nil {
202+ return err
203+ }
189204
190- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
205+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
191206 if err != nil {
192207 return err
193208 }
@@ -206,9 +221,12 @@ func groupsCmd() *cobra.Command {
206221 Args : cobra .NoArgs ,
207222 RunE : func (cmd * cobra.Command , args []string ) error {
208223 ctx := context .Background ()
209- sess := session .Must (session .NewSession ())
224+ cfg , err := config .LoadDefaultConfig (ctx )
225+ if err != nil {
226+ return err
227+ }
210228
211- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
229+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
212230 if err != nil {
213231 return err
214232 }
@@ -227,9 +245,12 @@ func lagsCmd() *cobra.Command {
227245 Args : cobra .ExactArgs (2 ),
228246 RunE : func (cmd * cobra.Command , args []string ) error {
229247 ctx := context .Background ()
230- sess := session .Must (session .NewSession ())
248+ cfg , err := config .LoadDefaultConfig (ctx )
249+ if err != nil {
250+ return err
251+ }
231252
232- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
253+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
233254 if err != nil {
234255 return err
235256 }
@@ -254,9 +275,12 @@ func membersCmd() *cobra.Command {
254275 Args : cobra .ExactArgs (1 ),
255276 RunE : func (cmd * cobra.Command , args []string ) error {
256277 ctx := context .Background ()
257- sess := session .Must (session .NewSession ())
278+ cfg , err := config .LoadDefaultConfig (ctx )
279+ if err != nil {
280+ return err
281+ }
258282
259- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
283+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
260284 if err != nil {
261285 return err
262286 }
@@ -275,9 +299,12 @@ func partitionsCmd() *cobra.Command {
275299 Args : cobra .MinimumNArgs (0 ),
276300 RunE : func (cmd * cobra.Command , args []string ) error {
277301 ctx := context .Background ()
278- sess := session .Must (session .NewSession ())
302+ cfg , err := config .LoadDefaultConfig (ctx )
303+ if err != nil {
304+ return err
305+ }
279306
280- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
307+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
281308 if err != nil {
282309 return err
283310 }
@@ -321,9 +348,12 @@ func offsetsCmd() *cobra.Command {
321348 Args : cobra .ExactArgs (1 ),
322349 RunE : func (cmd * cobra.Command , args []string ) error {
323350 ctx := context .Background ()
324- sess := session .Must (session .NewSession ())
351+ cfg , err := config .LoadDefaultConfig (ctx )
352+ if err != nil {
353+ return err
354+ }
325355
326- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
356+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
327357 if err != nil {
328358 return err
329359 }
@@ -342,9 +372,12 @@ func topicsCmd() *cobra.Command {
342372 Args : cobra .NoArgs ,
343373 RunE : func (cmd * cobra.Command , args []string ) error {
344374 ctx := context .Background ()
345- sess := session .Must (session .NewSession ())
375+ cfg , err := config .LoadDefaultConfig (ctx )
376+ if err != nil {
377+ return err
378+ }
346379
347- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
380+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
348381 if err != nil {
349382 return err
350383 }
@@ -397,9 +430,12 @@ $ topicctl get acls --host 198.51.100.0
397430` ,
398431 RunE : func (cmd * cobra.Command , args []string ) error {
399432 ctx := context .Background ()
400- sess := session .Must (session .NewSession ())
433+ cfg , err := config .LoadDefaultConfig (ctx )
434+ if err != nil {
435+ return err
436+ }
401437
402- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
438+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
403439 if err != nil {
404440 return err
405441 }
@@ -467,9 +503,12 @@ func usersCmd() *cobra.Command {
467503 Args : cobra .NoArgs ,
468504 RunE : func (cmd * cobra.Command , args []string ) error {
469505 ctx := context .Background ()
470- sess := session .Must (session .NewSession ())
506+ cfg , err := config .LoadDefaultConfig (ctx )
507+ if err != nil {
508+ return err
509+ }
471510
472- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
511+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
473512 if err != nil {
474513 return err
475514 }
0 commit comments