@@ -14,7 +14,6 @@ import (
14
14
// "github.com/Infisical/infisical-merge/packages/models"
15
15
"github.com/Infisical/infisical-merge/packages/util"
16
16
// "github.com/Infisical/infisical-merge/packages/visualize"
17
- "github.com/go-resty/resty/v2"
18
17
"github.com/posthog/posthog-go"
19
18
"github.com/spf13/cobra"
20
19
@@ -56,7 +55,10 @@ func getDynamicSecretList(cmd *cobra.Command, args []string) {
56
55
}
57
56
58
57
var infisicalToken string
59
- httpClient := resty .New ()
58
+ httpClient , err := util .GetRestyClientWithCustomHeaders ()
59
+ if err != nil {
60
+ util .HandleError (err , "Unable to get resty client with custom headers" )
61
+ }
60
62
61
63
if projectId == "" {
62
64
workspaceFile , err := util .GetWorkSpaceFromFile ()
@@ -85,10 +87,16 @@ func getDynamicSecretList(cmd *cobra.Command, args []string) {
85
87
86
88
httpClient .SetAuthToken (infisicalToken )
87
89
90
+ customHeaders , err := util .GetInfisicalCustomHeadersMap ()
91
+ if err != nil {
92
+ util .HandleError (err , "Unable to get custom headers" )
93
+ }
94
+
88
95
infisicalClient := infisicalSdk .NewInfisicalClient (context .Background (), infisicalSdk.Config {
89
96
SiteUrl : config .INFISICAL_URL ,
90
97
UserAgent : api .USER_AGENT ,
91
98
AutoTokenRefresh : false ,
99
+ CustomHeaders : customHeaders ,
92
100
})
93
101
infisicalClient .Auth ().SetAccessToken (infisicalToken )
94
102
@@ -164,7 +172,10 @@ func createDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
164
172
}
165
173
166
174
var infisicalToken string
167
- httpClient := resty .New ()
175
+ httpClient , err := util .GetRestyClientWithCustomHeaders ()
176
+ if err != nil {
177
+ util .HandleError (err , "Unable to get resty client with custom headers" )
178
+ }
168
179
169
180
if projectId == "" {
170
181
workspaceFile , err := util .GetWorkSpaceFromFile ()
@@ -193,10 +204,16 @@ func createDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
193
204
194
205
httpClient .SetAuthToken (infisicalToken )
195
206
207
+ customHeaders , err := util .GetInfisicalCustomHeadersMap ()
208
+ if err != nil {
209
+ util .HandleError (err , "Unable to get custom headers" )
210
+ }
211
+
196
212
infisicalClient := infisicalSdk .NewInfisicalClient (context .Background (), infisicalSdk.Config {
197
213
SiteUrl : config .INFISICAL_URL ,
198
214
UserAgent : api .USER_AGENT ,
199
215
AutoTokenRefresh : false ,
216
+ CustomHeaders : customHeaders ,
200
217
})
201
218
infisicalClient .Auth ().SetAccessToken (infisicalToken )
202
219
@@ -286,7 +303,10 @@ func renewDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
286
303
}
287
304
288
305
var infisicalToken string
289
- httpClient := resty .New ()
306
+ httpClient , err := util .GetRestyClientWithCustomHeaders ()
307
+ if err != nil {
308
+ util .HandleError (err , "Unable to get resty client with custom headers" )
309
+ }
290
310
291
311
if projectId == "" {
292
312
workspaceFile , err := util .GetWorkSpaceFromFile ()
@@ -315,10 +335,16 @@ func renewDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
315
335
316
336
httpClient .SetAuthToken (infisicalToken )
317
337
338
+ customHeaders , err := util .GetInfisicalCustomHeadersMap ()
339
+ if err != nil {
340
+ util .HandleError (err , "Unable to get custom headers" )
341
+ }
342
+
318
343
infisicalClient := infisicalSdk .NewInfisicalClient (context .Background (), infisicalSdk.Config {
319
344
SiteUrl : config .INFISICAL_URL ,
320
345
UserAgent : api .USER_AGENT ,
321
346
AutoTokenRefresh : false ,
347
+ CustomHeaders : customHeaders ,
322
348
})
323
349
infisicalClient .Auth ().SetAccessToken (infisicalToken )
324
350
@@ -384,7 +410,10 @@ func revokeDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
384
410
}
385
411
386
412
var infisicalToken string
387
- httpClient := resty .New ()
413
+ httpClient , err := util .GetRestyClientWithCustomHeaders ()
414
+ if err != nil {
415
+ util .HandleError (err , "Unable to get resty client with custom headers" )
416
+ }
388
417
389
418
if projectId == "" {
390
419
workspaceFile , err := util .GetWorkSpaceFromFile ()
@@ -413,10 +442,16 @@ func revokeDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
413
442
414
443
httpClient .SetAuthToken (infisicalToken )
415
444
445
+ customHeaders , err := util .GetInfisicalCustomHeadersMap ()
446
+ if err != nil {
447
+ util .HandleError (err , "Unable to get custom headers" )
448
+ }
449
+
416
450
infisicalClient := infisicalSdk .NewInfisicalClient (context .Background (), infisicalSdk.Config {
417
451
SiteUrl : config .INFISICAL_URL ,
418
452
UserAgent : api .USER_AGENT ,
419
453
AutoTokenRefresh : false ,
454
+ CustomHeaders : customHeaders ,
420
455
})
421
456
infisicalClient .Auth ().SetAccessToken (infisicalToken )
422
457
@@ -481,7 +516,10 @@ func listDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
481
516
}
482
517
483
518
var infisicalToken string
484
- httpClient := resty .New ()
519
+ httpClient , err := util .GetRestyClientWithCustomHeaders ()
520
+ if err != nil {
521
+ util .HandleError (err , "Unable to get resty client with custom headers" )
522
+ }
485
523
486
524
if projectId == "" {
487
525
workspaceFile , err := util .GetWorkSpaceFromFile ()
@@ -510,10 +548,16 @@ func listDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
510
548
511
549
httpClient .SetAuthToken (infisicalToken )
512
550
551
+ customHeaders , err := util .GetInfisicalCustomHeadersMap ()
552
+ if err != nil {
553
+ util .HandleError (err , "Unable to get custom headers" )
554
+ }
555
+
513
556
infisicalClient := infisicalSdk .NewInfisicalClient (context .Background (), infisicalSdk.Config {
514
557
SiteUrl : config .INFISICAL_URL ,
515
558
UserAgent : api .USER_AGENT ,
516
559
AutoTokenRefresh : false ,
560
+ CustomHeaders : customHeaders ,
517
561
})
518
562
infisicalClient .Auth ().SetAccessToken (infisicalToken )
519
563
0 commit comments