refactor comments & function name for confuse (#15546)

Co-authored-by: fuchanghai <changhaifu@apache.org>
This commit is contained in:
John Huang 2024-02-01 10:39:54 +08:00 committed by GitHub
parent 25810a81dc
commit 2f66a667ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 9 deletions

View File

@ -92,7 +92,7 @@ public class K8sNamespaceController extends BaseController {
}
/**
* 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
@ -111,7 +111,7 @@ public class K8sNamespaceController extends BaseController {
@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);
}

View File

@ -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

View File

@ -100,7 +100,7 @@ public class K8SNamespaceServiceImpl extends BaseServiceImpl implements K8sNames
}
/**
* 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
@ -108,7 +108,7 @@ public class K8SNamespaceServiceImpl extends BaseServiceImpl implements K8sNames
* @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);

View File

@ -107,16 +107,16 @@ public class K8SNamespaceServiceTest {
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));
}