Skip to content

Commit 62e1c62

Browse files
committed
fix: disable modifying cluster nae and env name in update env api
1 parent eab5419 commit 62e1c62

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

api/cluster/EnvironmentRestHandler.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,16 @@ func (impl EnvironmentRestHandlerImpl) Update(w http.ResponseWriter, r *http.Req
293293
}
294294
//RBAC enforcer Ends
295295

296+
// checkImmutable fields
297+
if modifiedEnvironment.Environment != bean.Environment {
298+
common.WriteJsonResp(w, errors.New("environment name cannot be changed"), nil, http.StatusConflict)
299+
return
300+
}
301+
if modifiedEnvironment.Namespace != bean.Namespace {
302+
common.WriteJsonResp(w, errors.New("namespace cannot be changed"), nil, http.StatusConflict)
303+
return
304+
}
305+
296306
res, err := impl.environmentClusterMappingsService.Update(&bean, userId)
297307
if err != nil {
298308
impl.logger.Errorw("service err, Update", "err", err, "payload", bean)

0 commit comments

Comments
 (0)