@@ -26,7 +26,6 @@ import (
26
26
"strings"
27
27
"time"
28
28
29
- "cloud.google.com/go/compute/metadata"
30
29
"github.com/gorilla/mux"
31
30
"github.com/pkg/errors"
32
31
"github.com/sirupsen/logrus"
@@ -116,7 +115,7 @@ func (fe *frontendServer) homeHandler(w http.ResponseWriter, r *http.Request) {
116
115
"platform_css" : plat .css ,
117
116
"platform_name" : plat .provider ,
118
117
"is_cymbal_brand" : isCymbalBrand ,
119
- "deploymentDetails" : getDeploymentDetails ( r ) ,
118
+ "deploymentDetails" : deploymentDetailsMap ,
120
119
}); err != nil {
121
120
log .Error (err )
122
121
}
@@ -201,7 +200,7 @@ func (fe *frontendServer) productHandler(w http.ResponseWriter, r *http.Request)
201
200
"platform_css" : plat .css ,
202
201
"platform_name" : plat .provider ,
203
202
"is_cymbal_brand" : isCymbalBrand ,
204
- "deploymentDetails" : getDeploymentDetails ( r ) ,
203
+ "deploymentDetails" : deploymentDetailsMap ,
205
204
}); err != nil {
206
205
log .Println (err )
207
206
}
@@ -313,7 +312,7 @@ func (fe *frontendServer) viewCartHandler(w http.ResponseWriter, r *http.Request
313
312
"platform_css" : plat .css ,
314
313
"platform_name" : plat .provider ,
315
314
"is_cymbal_brand" : isCymbalBrand ,
316
- "deploymentDetails" : getDeploymentDetails ( r ) ,
315
+ "deploymentDetails" : deploymentDetailsMap ,
317
316
}); err != nil {
318
317
log .Println (err )
319
318
}
@@ -386,7 +385,7 @@ func (fe *frontendServer) placeOrderHandler(w http.ResponseWriter, r *http.Reque
386
385
"platform_css" : plat .css ,
387
386
"platform_name" : plat .provider ,
388
387
"is_cymbal_brand" : isCymbalBrand ,
389
- "deploymentDetails" : getDeploymentDetails ( r ) ,
388
+ "deploymentDetails" : deploymentDetailsMap ,
390
389
}); err != nil {
391
390
log .Println (err )
392
391
}
@@ -448,7 +447,7 @@ func renderHTTPError(log logrus.FieldLogger, r *http.Request, w http.ResponseWri
448
447
"error" : errMsg ,
449
448
"status_code" : code ,
450
449
"status" : http .StatusText (code ),
451
- "deploymentDetails" : getDeploymentDetails ( r ) ,
450
+ "deploymentDetails" : deploymentDetailsMap ,
452
451
}); templateErr != nil {
453
452
log .Println (templateErr )
454
453
}
@@ -517,36 +516,3 @@ func stringinSlice(slice []string, val string) bool {
517
516
}
518
517
return false
519
518
}
520
-
521
- func getDeploymentDetails (httpRequest * http.Request ) map [string ]string {
522
- var deploymentDetailsMap = make (map [string ]string )
523
- var metaServerClient = metadata .NewClient (& http.Client {})
524
- var log = httpRequest .Context ().Value (ctxKeyLog {}).(logrus.FieldLogger )
525
-
526
- podHostname , err := os .Hostname ()
527
- if err != nil {
528
- log .Error ("Failed to fetch the hostname for the Pod" , err )
529
- }
530
-
531
- podCluster , err := metaServerClient .InstanceAttributeValue ("cluster-name" )
532
- if err != nil {
533
- log .Error ("Failed to fetch the name of the cluster in which the pod is running" , err )
534
- }
535
-
536
- podZone , err := metaServerClient .Zone ()
537
- if err != nil {
538
- log .Error ("Failed to fetch the Zone of the node where the pod is scheduled" , err )
539
- }
540
-
541
- deploymentDetailsMap ["HOSTNAME" ] = podHostname
542
- deploymentDetailsMap ["CLUSTERNAME" ] = podCluster
543
- deploymentDetailsMap ["ZONE" ] = podZone
544
-
545
- log .WithFields (logrus.Fields {
546
- "cluster" : podCluster ,
547
- "zone" : podZone ,
548
- "hostname" : podHostname ,
549
- }).Debug ("Fetched pod details" )
550
-
551
- return deploymentDetailsMap
552
- }
0 commit comments