Skip to content

Conversation

shaohuzhang1
Copy link
Contributor

feat: Permission constants

Copy link

f2c-ci-robot bot commented Jul 28, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

f2c-ci-robot bot commented Jul 28, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

RESOURCE_MODEL_DELETE = Permission(
group=Group.SYSTEM_RES_MODEL, operate=Operate.DELETE, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.RESOURCE]
)
OPERATION_LOG_READ = Permission(
group=Group.OPERATION_LOG, operate=Operate.READ, role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.OPERATION_LOG]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The provided code snippet seems to be configuring permissions in an enumeration class, which is common in many systems for managing access control. However, it lacks comments explaining each permission's purpose and usage context.

Here are some general observations:

  1. Permission Naming:

    • While the names are descriptive, they could benefit from more specific naming that clearly identifies their functionality.
    • Consider using singular forms where appropriate (e.g., RESOURCE_MODEL instead of RESOURCE_MODELS, unless multiple models exist).
  2. Consistency:

    • Ensure consistency across all entries regarding the structure. For example, if one has parent groups [SystemGroup.RESOURCE], all might ideally follow this pattern.
  3. Documentation:

    • Add docstrings (docstrings) to explain what each permission represents and its use case within the system.
  4. Code Formatting:

    • Keep the format consistent throughout, including indentation and spacing.

Suggested Improvements

  1. Docstrings:

    """
    Access constants defining different types of permissions in the application.
    """
  2. Clearer Permissions:

    RESOURCE_MODEL_VIEW = Permission(
        group=Group.SYSTEM_RES_MODEL, 
        operate=Operate.READ, 
        role_list=[RoleConstants.ADMIN], 
        parent_group=[SystemGroup.RESOURCES]
    )
    
    RESOURCE_MODEL_CREATE = Permission(
        group=Group.SYSTEM_RES_MODEL, 
        operate=Operate.CREATE, 
        role_list=[RoleConstants.ADMIN], 
        parent_group=[SystemGroup.RESOURCES]
    )
    
    RESOURCE_MODEL_UPDATE = Permission(
        group=Group.SYSTEM_RES_MODEL, 
        operate=Operate.UPDATE, 
        role_list=[RoleConstants.ADMIN], 
        parent_group=[SystemGroup.RESOURCES]
    )
    
    RESOURCE_MODEL_DELETE = Permission(
        group=Group.SYSTEM_RES_MODEL, 
        operate=Operate.DELETE, 
        role_list=[RoleConstants.ADMIN], 
        parent_group=[SystemGroup.RESOURCES]
    )
  3. Optimization:

    • If you anticipate needing additional permissions related to ResourceModel, consider creating a separate module to avoid cluttering this class with unrelated functionalities.
    • Ensure that there are no duplicate or overly complex configurations that could hinder performance.

In summary, while the existing code works correctly, adding clearer documentation and potentially separating logic into manageable modules can improve maintainability and readability.

@zhanweizhang7 zhanweizhang7 merged commit 7942b12 into v2 Jul 28, 2025
3 of 5 checks passed
@zhanweizhang7 zhanweizhang7 deleted the pr@v2@feat_permission_constants branch July 28, 2025 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants