@@ -462,6 +462,20 @@ func (impl ClusterRestHandlerImpl) Update(w http.ResponseWriter, r *http.Request
462462 if util2 .IsBaseStack () {
463463 ctx = context .WithValue (ctx , "token" , token )
464464 }
465+
466+ // checkImmutable fields - cluster name
467+ modifiedCluster , err := impl .clusterService .FindByIdWithoutConfig (bean .Id )
468+ if err != nil {
469+ impl .logger .Errorw ("err finding cluster name" , "error" , err , "clusterId" , bean .Id )
470+ common .WriteJsonResp (w , err , nil , http .StatusInternalServerError )
471+ return
472+ }
473+
474+ if bean .ClusterName != modifiedCluster .ClusterName {
475+ common .WriteJsonResp (w , errors .New ("cluster name cannot be changed" ), nil , http .StatusConflict )
476+ return
477+ }
478+
465479 _ , err = impl .clusterService .Update (ctx , & bean , userId )
466480 if err != nil {
467481 impl .logger .Errorw ("service err, Update" , "error" , err , "payload" , bean )
@@ -708,7 +722,7 @@ func (impl ClusterRestHandlerImpl) GetClusterNamespaces(w http.ResponseWriter, r
708722
709723 userId , err := impl .userService .GetLoggedInUser (r )
710724 if userId == 0 || err != nil {
711- impl .logger .Errorw ("user not authorized" , "error" , err , "userId" , userId )
725+ impl .logger .Error ("user not authorized" , "error" , err , "userId" , userId )
712726 common .HandleUnauthorized (w , r )
713727 return
714728 }
@@ -719,8 +733,8 @@ func (impl ClusterRestHandlerImpl) GetClusterNamespaces(w http.ResponseWriter, r
719733 }
720734 clusterId , err := strconv .Atoi (clusterIdString )
721735 if err != nil {
722- impl .logger .Errorw ("failed to extract clusterId from param" , "error" , err , "clusterId" , clusterIdString )
723- common .WriteJsonResp (w , err , nil , http . StatusBadRequest )
736+ impl .logger .Errorw ("failed to extract clusterId from param must be integer " , "error" , err , "clusterId" , clusterIdString )
737+ common .HandleParameterError (w , r , "clusterIdString" , clusterIdString )
724738 return
725739 }
726740
0 commit comments