@@ -173,6 +173,7 @@ type packetManagerNodePool struct {
173
173
}
174
174
175
175
type packetManagerRest struct {
176
+ authToken string
176
177
packetManagerNodePools map [string ]* packetManagerNodePool
177
178
}
178
179
@@ -304,6 +305,13 @@ func createPacketManagerRest(configReader io.Reader, discoverOpts cloudprovider.
304
305
klog .Fatalf ("No \" default\" or [Global] nodepool definition was found" )
305
306
}
306
307
308
+ packetAuthToken := os .Getenv ("PACKET_AUTH_TOKEN" )
309
+ if len (packetAuthToken ) == 0 {
310
+ klog .Fatalf ("PACKET_AUTH_TOKEN is required and missing" )
311
+ }
312
+
313
+ manager .authToken = packetAuthToken
314
+
307
315
for nodepool := range cfg .Nodegroupdef {
308
316
if opts .ClusterName == "" && cfg .Nodegroupdef [nodepool ].ClusterName == "" {
309
317
klog .Fatalf ("The cluster-name parameter must be set" )
@@ -330,14 +338,12 @@ func createPacketManagerRest(configReader io.Reader, discoverOpts cloudprovider.
330
338
}
331
339
332
340
func (mgr * packetManagerRest ) request (ctx context.Context , method , url string , jsonData []byte ) ([]byte , error ) {
333
- packetAuthToken := os .Getenv ("PACKET_AUTH_TOKEN" )
334
-
335
341
req , err := http .NewRequestWithContext (ctx , method , url , bytes .NewBuffer (jsonData ))
336
342
if err != nil {
337
343
return nil , fmt .Errorf ("failed to create request: %w" , err )
338
344
}
339
345
340
- req .Header .Set ("X-Auth-Token" , packetAuthToken )
346
+ req .Header .Set ("X-Auth-Token" , mgr . authToken )
341
347
req .Header .Set ("Content-Type" , "application/json" )
342
348
343
349
client := & http.Client {}
0 commit comments