Skip to content

Commit dd64802

Browse files
committed
fix: resolving review comments
1 parent e20bc6a commit dd64802

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

api/cluster/ClusterRestHandler.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -717,12 +717,11 @@ func (impl ClusterRestHandlerImpl) HandleRbacForClusterNamespace(userId int32, t
717717

718718
func (impl ClusterRestHandlerImpl) GetClusterNamespaces(w http.ResponseWriter, r *http.Request) {
719719
//token := r.Header.Get("token")
720-
vars := mux.Vars(r)
721-
clusterIdString := vars["clusterId"]
720+
//vars := mux.Vars(r)
722721

723722
userId, err := impl.userService.GetLoggedInUser(r)
724723
if userId == 0 || err != nil {
725-
impl.logger.Error("user not authorized", "error", err, "userId", userId)
724+
impl.logger.Error("user not authorized", "userId", userId, "error", err)
726725
common.HandleUnauthorized(w, r)
727726
return
728727
}
@@ -731,10 +730,10 @@ func (impl ClusterRestHandlerImpl) GetClusterNamespaces(w http.ResponseWriter, r
731730
if ok := impl.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*"); ok {
732731
isActionUserSuperAdmin = true
733732
}
734-
clusterId, err := strconv.Atoi(clusterIdString)
733+
// extract cluster and handle response on error
734+
clusterId, err := common.ExtractIntPathParamWithContext(w, r, "clusterId", "cluster")
735735
if err != nil {
736-
impl.logger.Errorw("failed to extract clusterId from param must be integer", "error", err, "clusterId", clusterIdString)
737-
common.HandleParameterError(w, r, "clusterIdString", clusterIdString)
736+
impl.logger.Error("error in parsing clusterId", "clusterId", clusterId, "err", err)
738737
return
739738
}
740739

0 commit comments

Comments
 (0)