Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new services namespacegroup, namespace #13

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

kang2453
Copy link
Contributor

Category

  • New feature
  • Bug fix
  • Improvement
  • Refactor
  • etc

Description

  • add new services namespacegroup, namespace

Known issue

@kang2453 kang2453 added the enhancement New feature or request label Dec 10, 2024
@kang2453 kang2453 self-assigned this Dec 10, 2024
Copy link

⚠️ @kang2453 the signed-off-by was not found in the following 1 commits:

  • f579c01: feat: add new services namespacegroup, namespace

✅ Why it is required

The Developer Certificate of Origin (DCO) is a lightweight way for contributors to certify that they wrote or otherwise have the right to submit the code they are contributing to the project. Here is the full text of the DCO.

Contributors sign-off that they adhere to these requirements by adding a Signed-off-by line to commit messages.

This is my commit message

Signed-off-by: Random Developer <[email protected]>

Git even has a -s command line option to append this automatically to your commit message:

$ git commit -s -m 'This is my commit message'

@kang2453 kang2453 merged commit 4ddd7b1 into cloudforet-io:master Dec 10, 2024
1 check failed
Copy link
Member

@ImMin5 ImMin5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @kang2453

Please review the additional comments I've left.


def create(self, request, context):
params, metadata = self.parse_request(request, context)
namespacegroup_svc = NamespaceGroupService(metadata)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our convention is namepsace_group_svc

@append_query_filter(
[
"namespace_group_id",
"is_managed",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case append_query_filter need worksapce_id

permission="inventory-v2:NamespaceGroup.read",
role_types=["DOMAIN_ADMIN", "WORKSPACE_OWNER", "WORKSPACE_MEMBER"],
)
@append_query_filter(["domain_id"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case append_query_filter need worksapce_id

role_types=["DOMAIN_ADMIN", "WORKSPACE_OWNER", "WORKSPACE_MEMBER"],
)
@append_query_filter(["domain_id"])
@append_keyword_filter(["namespace_group_id", "name"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stat api also need @change_value_by_rule("APPEND", "workspace_id","*") decorator

'namespace_id': 'str', # required
'name': 'str',
'icon': 'str',
'tags': 'dict',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to explain that params has workspace_id

class NamespaceGroupGetRequest(BaseModel):
namespace_group_id: str
resource_group: ResourceGroup
workspace_id: Union[str,None] = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
workspace_id: Union[str,None] = None
workspace_id: Union[list,str,None] = None

Comment on lines +102 to +120
# def get_namespaces_in_namespace_group(
# self,
# namespace_group_id: str,
# ) -> NamespaceResponse:

# namespace_vos = self.namespace_model.filter(
# namespace_group_id=namespace_group_id
# )
# namespaces = [namespace_vo.namespace_id for namespace_vo in namespace_vos]

# child_namespace_groups = self.namespace_group_model.filter(
# parent_group_id=namespace_group_id
# )
# for child_namespace_group in child_namespace_groups:
# parent_group_id = child_namespace_group.namespace_group_id
# namespaces.extend(
# self.get_namespaces_in_namespace_group(parent_group_id)
# )
# return list(set(namespaces))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# def get_namespaces_in_namespace_group(
# self,
# namespace_group_id: str,
# ) -> NamespaceResponse:
# namespace_vos = self.namespace_model.filter(
# namespace_group_id=namespace_group_id
# )
# namespaces = [namespace_vo.namespace_id for namespace_vo in namespace_vos]
# child_namespace_groups = self.namespace_group_model.filter(
# parent_group_id=namespace_group_id
# )
# for child_namespace_group in child_namespace_groups:
# parent_group_id = child_namespace_group.namespace_group_id
# namespaces.extend(
# self.get_namespaces_in_namespace_group(parent_group_id)
# )
# return list(set(namespaces))

Please check this commented code is neccesary

self.identity_mgr.check_workspace(workspace_id, domain_id)
else:
params.workspace_id = "*"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before create namespace, i think we have to check namespace_group object with namespace_group_id value at params.

name: Union[str, None] = None
icon: Union[str, None] = None
tags: Union[Dict, None] = None
workspace_id: Union[list,str,None] = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
workspace_id: Union[list,str,None] = None
workspace_id: Union[str,None] = None


class NamespaceDeleteRequest(BaseModel):
namespace_id: str
workspace_id:Union[list,str,None] = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
workspace_id:Union[list,str,None] = None
workspace_id: Union[str,None] = None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fail/signedoff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants