5
5
"fmt"
6
6
"strings"
7
7
8
- "github.com/aws/aws-sdk-go/aws/session "
8
+ "github.com/aws/aws-sdk-go-v2/config "
9
9
"github.com/segmentio/kafka-go"
10
10
"github.com/segmentio/topicctl/pkg/admin"
11
11
"github.com/segmentio/topicctl/pkg/cli"
@@ -95,9 +95,12 @@ func balanceCmd() *cobra.Command {
95
95
Args : cobra .MaximumNArgs (1 ),
96
96
RunE : func (cmd * cobra.Command , args []string ) error {
97
97
ctx := context .Background ()
98
- sess := session .Must (session .NewSession ())
98
+ cfg , err := config .LoadDefaultConfig (ctx )
99
+ if err != nil {
100
+ return err
101
+ }
99
102
100
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
103
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
101
104
if err != nil {
102
105
return err
103
106
}
@@ -122,9 +125,12 @@ func brokersCmd() *cobra.Command {
122
125
Args : cobra .NoArgs ,
123
126
RunE : func (cmd * cobra.Command , args []string ) error {
124
127
ctx := context .Background ()
125
- sess := session .Must (session .NewSession ())
128
+ cfg , err := config .LoadDefaultConfig (ctx )
129
+ if err != nil {
130
+ return err
131
+ }
126
132
127
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
133
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
128
134
if err != nil {
129
135
return err
130
136
}
@@ -143,9 +149,12 @@ func controllerCmd() *cobra.Command {
143
149
Args : cobra .NoArgs ,
144
150
RunE : func (cmd * cobra.Command , args []string ) error {
145
151
ctx := context .Background ()
146
- sess := session .Must (session .NewSession ())
152
+ cfg , err := config .LoadDefaultConfig (ctx )
153
+ if err != nil {
154
+ return err
155
+ }
147
156
148
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
157
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
149
158
if err != nil {
150
159
return err
151
160
}
@@ -164,9 +173,12 @@ func clusterIDCmd() *cobra.Command {
164
173
Args : cobra .NoArgs ,
165
174
RunE : func (cmd * cobra.Command , args []string ) error {
166
175
ctx := context .Background ()
167
- sess := session .Must (session .NewSession ())
176
+ cfg , err := config .LoadDefaultConfig (ctx )
177
+ if err != nil {
178
+ return err
179
+ }
168
180
169
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
181
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
170
182
if err != nil {
171
183
return err
172
184
}
@@ -185,9 +197,12 @@ func configCmd() *cobra.Command {
185
197
Args : cobra .ExactArgs (1 ),
186
198
RunE : func (cmd * cobra.Command , args []string ) error {
187
199
ctx := context .Background ()
188
- sess := session .Must (session .NewSession ())
200
+ cfg , err := config .LoadDefaultConfig (ctx )
201
+ if err != nil {
202
+ return err
203
+ }
189
204
190
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
205
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
191
206
if err != nil {
192
207
return err
193
208
}
@@ -206,9 +221,12 @@ func groupsCmd() *cobra.Command {
206
221
Args : cobra .NoArgs ,
207
222
RunE : func (cmd * cobra.Command , args []string ) error {
208
223
ctx := context .Background ()
209
- sess := session .Must (session .NewSession ())
224
+ cfg , err := config .LoadDefaultConfig (ctx )
225
+ if err != nil {
226
+ return err
227
+ }
210
228
211
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
229
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
212
230
if err != nil {
213
231
return err
214
232
}
@@ -227,9 +245,12 @@ func lagsCmd() *cobra.Command {
227
245
Args : cobra .ExactArgs (2 ),
228
246
RunE : func (cmd * cobra.Command , args []string ) error {
229
247
ctx := context .Background ()
230
- sess := session .Must (session .NewSession ())
248
+ cfg , err := config .LoadDefaultConfig (ctx )
249
+ if err != nil {
250
+ return err
251
+ }
231
252
232
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
253
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
233
254
if err != nil {
234
255
return err
235
256
}
@@ -254,9 +275,12 @@ func membersCmd() *cobra.Command {
254
275
Args : cobra .ExactArgs (1 ),
255
276
RunE : func (cmd * cobra.Command , args []string ) error {
256
277
ctx := context .Background ()
257
- sess := session .Must (session .NewSession ())
278
+ cfg , err := config .LoadDefaultConfig (ctx )
279
+ if err != nil {
280
+ return err
281
+ }
258
282
259
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
283
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
260
284
if err != nil {
261
285
return err
262
286
}
@@ -275,9 +299,12 @@ func partitionsCmd() *cobra.Command {
275
299
Args : cobra .MinimumNArgs (0 ),
276
300
RunE : func (cmd * cobra.Command , args []string ) error {
277
301
ctx := context .Background ()
278
- sess := session .Must (session .NewSession ())
302
+ cfg , err := config .LoadDefaultConfig (ctx )
303
+ if err != nil {
304
+ return err
305
+ }
279
306
280
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
307
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
281
308
if err != nil {
282
309
return err
283
310
}
@@ -321,9 +348,12 @@ func offsetsCmd() *cobra.Command {
321
348
Args : cobra .ExactArgs (1 ),
322
349
RunE : func (cmd * cobra.Command , args []string ) error {
323
350
ctx := context .Background ()
324
- sess := session .Must (session .NewSession ())
351
+ cfg , err := config .LoadDefaultConfig (ctx )
352
+ if err != nil {
353
+ return err
354
+ }
325
355
326
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
356
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
327
357
if err != nil {
328
358
return err
329
359
}
@@ -342,9 +372,12 @@ func topicsCmd() *cobra.Command {
342
372
Args : cobra .NoArgs ,
343
373
RunE : func (cmd * cobra.Command , args []string ) error {
344
374
ctx := context .Background ()
345
- sess := session .Must (session .NewSession ())
375
+ cfg , err := config .LoadDefaultConfig (ctx )
376
+ if err != nil {
377
+ return err
378
+ }
346
379
347
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
380
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
348
381
if err != nil {
349
382
return err
350
383
}
@@ -397,9 +430,12 @@ $ topicctl get acls --host 198.51.100.0
397
430
` ,
398
431
RunE : func (cmd * cobra.Command , args []string ) error {
399
432
ctx := context .Background ()
400
- sess := session .Must (session .NewSession ())
433
+ cfg , err := config .LoadDefaultConfig (ctx )
434
+ if err != nil {
435
+ return err
436
+ }
401
437
402
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
438
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
403
439
if err != nil {
404
440
return err
405
441
}
@@ -467,9 +503,12 @@ func usersCmd() *cobra.Command {
467
503
Args : cobra .NoArgs ,
468
504
RunE : func (cmd * cobra.Command , args []string ) error {
469
505
ctx := context .Background ()
470
- sess := session .Must (session .NewSession ())
506
+ cfg , err := config .LoadDefaultConfig (ctx )
507
+ if err != nil {
508
+ return err
509
+ }
471
510
472
- adminClient , err := getConfig .shared .getAdminClient (ctx , sess , true )
511
+ adminClient , err := getConfig .shared .getAdminClient (ctx , cfg , true )
473
512
if err != nil {
474
513
return err
475
514
}
0 commit comments