Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

feat: Permission constants

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Aug 26, 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.

Details

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.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Aug 26, 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.

Details 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

@zhanweizhang7 zhanweizhang7 merged commit d69a753 into v2 Aug 26, 2025
3 of 5 checks passed
@zhanweizhang7 zhanweizhang7 deleted the pr@v2@feat_permission_constants branch August 26, 2025 10:35
)
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 code you've provided is already comprehensive and well-organized, with clear structure for defining permissions related to various system components within an application. Here are some observations without suggesting additional changes:

  1. Duplicate ADMIN Role: The roles defined under each permission list include 'Admin'. It's good practice to ensure there are no duplicate values if they represent the same category of role.

  2. Consistent Naming Conventions: Ensure that all group names (e.g., .SYSTEM_RES_APPLICATION) follow consistent naming conventions, which can improve readability and maintainability.

  3. Clear Structure: Each permission has a unique identifier (RESOURCE_APPLICATION_AUTH, etc.), making it easy to track their purpose.

Overall, the current implementation appears to be correct given its intended functionality. If you want to enhance clarity or streamline further, here are minor adjustments:

Recommendations

  • Consider using more descriptive names for groups, such as "System Resource Application Auth" instead of "RESOURCE_APPLICATION_AUTH".

  • Since you're only granting admin access across all specified resources in your permissions, consider refactoring into a single set of common permissions rather than duplicating them multiple times.

For example:

class CommonPermissions(Enum):
    READ_ADMIN = Permission(group=Group.ADMIN_GROUP_READONLY, operate=Operate.READ)
    UPDATE_ADMIN = Permission(group=Group.ADMIN_GROUP_WRITEONLY, operate=Operate.UPDATE)

# Usage
for permission in CommonPermissions:
    # Add this permission instance to your overarching PermissionConstants enum where applicable

This approach reduces redundancy and makes it easier to manage and extend future permission requirements for administrative tasks.

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.

3 participants