Skip to content

Commit e37f8e4

Browse files
committed
fix: context handling
1 parent 69a88d8 commit e37f8e4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

api/argoApplication/ArgoApplicationRestHandler.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package argoApplication
1818

1919
import (
20+
"context"
2021
"errors"
2122
"github.com/devtron-labs/devtron/api/restHandler/common"
2223
"github.com/devtron-labs/devtron/pkg/argoApplication"
@@ -89,6 +90,9 @@ func (handler *ArgoApplicationRestHandlerImpl) GetApplicationDetail(w http.Respo
8990
common.WriteJsonResp(w, errors.New("unauthorized"), nil, http.StatusForbidden)
9091
return
9192
}
93+
ctx := r.Context()
94+
ctx = context.WithValue(ctx, "token", token)
95+
9296
var err error
9397
v := r.URL.Query()
9498
resourceName := v.Get("name")
@@ -104,7 +108,7 @@ func (handler *ArgoApplicationRestHandlerImpl) GetApplicationDetail(w http.Respo
104108
return
105109
}
106110
}
107-
resp, err := handler.readService.GetAppDetailEA(r.Context(), resourceName, namespace, clusterId)
111+
resp, err := handler.readService.GetAppDetailEA(ctx, resourceName, namespace, clusterId)
108112
if err != nil {
109113
handler.logger.Errorw("error in getting argo application app detail", "err", err, "resourceName", resourceName, "clusterId", clusterId)
110114
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)

api/k8s/application/k8sApplicationRestHandler.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response
253253
}
254254

255255
token := r.Header.Get("token")
256+
ctx := r.Context()
257+
ctx = context.WithValue(ctx, "token", token)
256258
var k8sAppDetail AppView.AppDetailContainer
257259
var resourceTreeResponse *gRPC.ResourceTreeResponse
258260
var clusterId int
@@ -276,7 +278,7 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response
276278
return
277279
}
278280
//RBAC enforcer Ends
279-
appDetail, err := handler.helmAppService.GetApplicationDetail(r.Context(), appIdentifier)
281+
appDetail, err := handler.helmAppService.GetApplicationDetail(ctx, appIdentifier)
280282
if err != nil {
281283
apiError := clientErrors.ConvertToApiError(err)
282284
if apiError != nil {

0 commit comments

Comments
 (0)