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

feat(KFLUXUI-175): give up SpaceBindingRequest and enjoy RoleBinding #83

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

testcara
Copy link
Contributor

@testcara testcara commented Jan 16, 2025

Fixes

KFLUXUI-175

Description

Konflux is migrating off workspace api and also the related SpaceBindingRequest.
For Konflux UI, we need to enjoy the shared Konflux cluster role and rolebinding for the namespace access and permission checks.

For the details:
We use k8swatch the rolebinding of the namespace for the list page.
And for the form actions, we use the create rolebinding, delete rolebinding, get rolebindings.
More, the status of the user access list are removed.

Type of change

  • Feature
  • Bugfix
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Screen shots / Gifs for design review

Screen.Recording.2025-01-22.at.15.30.33.mov

How to test or reproduce?

Just enjoy the use access page as previous.
You can visit access list, grant access, edit access, revoke access like before.

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@testcara testcara changed the title [WIP]feat(KFLUXUI-251): give up SpaceBindingRequest and enjoy RoleBinding [WIP]feat(KFLUXUI-175): give up SpaceBindingRequest and enjoy RoleBinding Jan 16, 2025
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 89.02439% with 27 lines in your changes missing coverage. Please review.

Project coverage is 80.24%. Comparing base (3ae7eee) to head (bedeb99).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...components/UserAccess/UserAccessForm/form-utils.ts 50.00% 20 Missing ⚠️
src/components/InlineAlert.tsx 90.00% 4 Missing ⚠️
src/components/UserAccess/UserAccessListView.tsx 77.77% 2 Missing ⚠️
src/components/UserAccess/UserAccessListPage.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #83      +/-   ##
==========================================
+ Coverage   80.09%   80.24%   +0.14%     
==========================================
  Files         570      574       +4     
  Lines       21476    21657     +181     
  Branches     5326     5352      +26     
==========================================
+ Hits        17202    17378     +176     
- Misses       4249     4253       +4     
- Partials       25       26       +1     
Flag Coverage Δ
unittests 80.24% <89.02%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@testcara testcara force-pushed the KFLUXUI-251 branch 2 times, most recently from a75a873 to 3371d76 Compare January 22, 2025 06:25
@testcara testcara closed this Jan 22, 2025
@testcara testcara deleted the KFLUXUI-251 branch January 22, 2025 06:29
@testcara testcara restored the KFLUXUI-251 branch January 22, 2025 06:31
@testcara testcara reopened this Jan 22, 2025
@testcara testcara changed the title [WIP]feat(KFLUXUI-175): give up SpaceBindingRequest and enjoy RoleBinding feat(KFLUXUI-175): give up SpaceBindingRequest and enjoy RoleBinding Jan 22, 2025
@abhinandan13jan
Copy link
Contributor

looks good first pass, I'll run this locally and label

Copy link
Collaborator

@sahil143 sahil143 left a comment

Choose a reason for hiding this comment

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

Partially reviewed. Will continue after the requested changes are addressed.

src/hooks/useRoleBindings.ts Outdated Show resolved Hide resolved
src/hooks/useRoleBindings.ts Outdated Show resolved Hide resolved
src/hooks/useRoleBindings.ts Outdated Show resolved Hide resolved
src/consts/konfluxRoleMap.ts Outdated Show resolved Hide resolved
src/components/UserAccess/UserAccessForm/form-utils.ts Outdated Show resolved Hide resolved
src/components/UserAccess/UserAccessForm/form-utils.ts Outdated Show resolved Hide resolved
src/components/UserAccess/UserAccessForm/form-utils.ts Outdated Show resolved Hide resolved
src/components/UserAccess/UserAccessForm/form-utils.ts Outdated Show resolved Hide resolved
src/components/UserAccess/UserAccessForm/form-utils.ts Outdated Show resolved Hide resolved
@testcara testcara force-pushed the KFLUXUI-251 branch 2 times, most recently from cb18cea to 3453b1f Compare January 25, 2025 04:46
@testcara
Copy link
Contributor Author

@sahil143 , hi, sahil, all comments have been addressed. Thank you for the help for continuous review.

Copy link
Collaborator

@sahil143 sahil143 left a comment

Choose a reason for hiding this comment

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

@testcara You missed some of the comments in previous review.

Comment on lines 31 to 46
apiVersion: 'rbac.authorization.k8s.io/v1',
kind: 'RoleBinding',
metadata: { name: 'konflux-maintainer-user1-actions-user', namespace: 'test-ns' },
roleRef: {
apiGroup: 'rbac.authorization.k8s.io',
kind: 'ClusterRole',
name: 'konflux-maintainer-user-actions',
},
subjects: [
{
apiGroup: 'rbac.authorization.k8s.io',
kind: 'User',
name: 'user1',
namespace: 'test-ns',
},
],
Copy link
Collaborator

Choose a reason for hiding this comment

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

use only data that's needed for this test, expect.objectContaining( supports checking partial data in an object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have improved the test to ensure it's shorter and clearer.

Comment on lines +119 to +127
const existingRBs = await getRBs(roleBinding.metadata.namespace);

const roleBindingExists = existingRBs.some(
(binding) => binding.metadata.name === roleBinding.metadata.name,
);

if (roleBindingExists && newRoleBinding) {
await deleteRB(roleBinding, dryRun);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to delete the role binding first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We delete the obsoleted rolebinding after the new rolebinding is created successfully.
The comment is inconsistent with real application. I would fix it.

src/hooks/__tests__/useRole.spec.ts Outdated Show resolved Hide resolved
src/hooks/__tests__/useRoleBindings.spec.ts Outdated Show resolved Hide resolved
src/hooks/__tests__/useRoleBindings.spec.ts Outdated Show resolved Hide resolved
src/hooks/useRole.ts Outdated Show resolved Hide resolved
src/models/role-binding.ts Outdated Show resolved Hide resolved
Comment on lines 9 to 11
role: NamespaceRole;
availableRoles?: NamespaceRole[];
bindings?: RoleBinding[];
Copy link
Collaborator

Choose a reason for hiding this comment

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

why change the type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed the useless change.

@testcara testcara force-pushed the KFLUXUI-251 branch 2 times, most recently from fa6d02d to d787802 Compare February 5, 2025 05:49
@testcara
Copy link
Contributor Author

testcara commented Feb 5, 2025

@sahil143, thank you a million for the continuous review. I have updated the patch with your suggestions. Thank you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants