Skip to content

Commit

Permalink
refactor comments & function name for confuse
Browse files Browse the repository at this point in the history
  • Loading branch information
pegasas committed Jan 31, 2024
1 parent d80a29c commit 3970d9a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public Result queryNamespaceListPaging(@Parameter(hidden = true) @RequestAttribu
}

/**
* create namespace,if not exist on k8s,will create,if exist only register in db
* register namespace in db,need to create namespace in k8s first
*
* @param loginUser
* @param namespace k8s namespace
Expand All @@ -111,7 +111,7 @@ public Result createNamespace(@Parameter(hidden = true) @RequestAttribute(value
@RequestParam(value = "namespace") String namespace,
@RequestParam(value = "clusterCode") Long clusterCode) {
Map<String, Object> result =
k8sNamespaceService.createK8sNamespace(loginUser, namespace, clusterCode);
k8sNamespaceService.registerK8sNamespace(loginUser, namespace, clusterCode);
return returnDataList(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public interface K8sNamespaceService {
Result queryListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize);

/**
* create namespace,if not exist on k8s,will create,if exist only register in db
* register namespace in db,need to create namespace in k8s first
*
* @param loginUser login user
* @param namespace namespace
* @param clusterCode k8s not null
* @return
*/
Map<String, Object> createK8sNamespace(User loginUser, String namespace, Long clusterCode);
Map<String, Object> registerK8sNamespace(User loginUser, String namespace, Long clusterCode);

/**
* verify namespace and k8s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ public Result queryListPaging(User loginUser, String searchVal, Integer pageNo,
}

/**
* create namespace,if not exist on k8s,will create,if exist only register in db
* register namespace in db,need to create namespace in k8s first
*
* @param loginUser login user
* @param namespace namespace
* @param clusterCode k8s not null
* @return
*/
@Override
public Map<String, Object> createK8sNamespace(User loginUser, String namespace, Long clusterCode) {
public Map<String, Object> registerK8sNamespace(User loginUser, String namespace, Long clusterCode) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser)) {
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ public void queryListPaging() {
public void createK8sNamespace() {
// namespace is null
Map<String, Object> result =
k8sNamespaceService.createK8sNamespace(getLoginUser(), null, clusterCode);
k8sNamespaceService.registerK8sNamespace(getLoginUser(), null, clusterCode);
logger.info(result.toString());
Assertions.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
// k8s is null
result = k8sNamespaceService.createK8sNamespace(getLoginUser(), namespace, null);
result = k8sNamespaceService.registerK8sNamespace(getLoginUser(), namespace, null);
logger.info(result.toString());
Assertions.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
// correct
Mockito.when(clusterMapper.queryByClusterCode(Mockito.anyLong())).thenReturn(getCluster());
result = k8sNamespaceService.createK8sNamespace(getLoginUser(), namespace, clusterCode);
result = k8sNamespaceService.registerK8sNamespace(getLoginUser(), namespace, clusterCode);
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
Expand Down

0 comments on commit 3970d9a

Please sign in to comment.