Skip to content

adding backend resources for serviceaccount, clusterrole, and roles#4832

Merged
openshift-merge-bot[bot] merged 3 commits intostolostron:mainfrom
kurwang:ACM-22617
Aug 4, 2025
Merged

adding backend resources for serviceaccount, clusterrole, and roles#4832
openshift-merge-bot[bot] merged 3 commits intostolostron:mainfrom
kurwang:ACM-22617

Conversation

@kurwang
Copy link
Copy Markdown
Contributor

@kurwang kurwang commented Jul 30, 2025

📝 Summary

Ticket Summary (Title):
Implement backend resources for rbac including serviceaccount and roles

Ticket Link:
(https://issues.redhat.com/browse/ACM-22617)

Type of Change:

  • 🐞 Bug Fix
  • ✨ Feature
  • 🔧 Refactor
  • 💸 Tech Debt
  • 🧪 Test-related
  • 📄 Docs

✅ Checklist

General

  • PR title follows the convention (e.g. ACM-12340 Fix bug with...)
  • Code builds and runs locally without errors
  • No console logs, commented-out code, or unnecessary files
  • All commits are meaningful and well-labeled
  • All new display strings are externalized for localization (English only)
  • (Nice to have) JSDoc comments added for new functions and interfaces

If Feature

  • UI/UX reviewed (if applicable)
  • All acceptance criteria met
  • Unit test coverage added or updated
  • Relevant documentation or comments included

If Bugfix

  • Root cause and fix summary are documented in the ticket (for future reference / errata)
  • Fix tested thoroughly and resolves the issue
  • Test(s) added to prevent regression

🗒️ Notes for Reviewers

@kurwang
Copy link
Copy Markdown
Contributor Author

kurwang commented Jul 30, 2025

/retest

@oksanabaza
Copy link
Copy Markdown
Contributor

/lgtm

Copy link
Copy Markdown
Contributor

@Ginxo Ginxo left a comment

Choose a reason for hiding this comment

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

good job!! just few typing considerations.

Comment thread frontend/src/resources/rbac.ts Outdated
kind: ServiceAccountKindType
metadata: Metadata
secrets: string[]
imagePullSecrets: string[]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See https://kubernetes.io/docs/reference/kubernetes-api/authentication-resources/service-account-v1/#ServiceAccount so it is something like

"imagePullSecrets": [
                {
                    "name": "builder-dockercfg-ggmbc"
                }
            ]

so I guess it is fair to explicitly type like

Suggested change
imagePullSecrets: string[]
imagePullSecrets: LocalObjectReference[]

and to create a new kubernetes-client.ts at frontend/src/resources containing

export interface LocalObjectReference {
  name: string
}

wdyt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

agreed with these comments, will make the appropriate changes

Comment thread frontend/src/resources/rbac.ts Outdated
apiVersion: ServiceAccountApiVersionType
kind: ServiceAccountKindType
metadata: Metadata
secrets: string[]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the same from imagePullSecrets applies to this but using ObjectReference from @openshift-console/dynamic-plugin-sdk library

Comment thread frontend/src/resources/rbac.ts Outdated
verbs: string[]
apiGroups: string[]
resources: string[]
resourceNames: string[]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
resourceNames: string[]
resourceNames?: string[]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would anyway create a new PolicyRule interface at frontend/src/resources/kubernetes-client.ts containing

import { ObjectReference } from '@openshift-console/dynamic-plugin-sdk'

export interface LocalObjectReference {
  verbs: ObjectReference[]
  apiGroups: string[]
  resources: string[]
  resourceNames?: string[]
}

and I would also replace ClusterRole.rules from the same file

Comment thread frontend/src/resources/rbac.ts Outdated
kind: 'User' | 'Group'
apiGroup: 'rbac.authorization.k8s.io'
name: string
namespace: string
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
namespace: string
namespace?: string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@openshift-ci openshift-ci Bot removed the lgtm label Jul 31, 2025
Signed-off-by: kurwang <madeof50gold@gmail.com>
Copy link
Copy Markdown
Contributor

@mshort55 mshort55 left a comment

Choose a reason for hiding this comment

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

Perhaps consider creating subjects and roleref interfaces to be used in the RoleBinding and ClusterRoleBinding interfaces because RoleBinding and ClusterRoleBinding structures are almost identical:

RoleBinding_structure.txt

ClusterRoleBinding_structure.txt

You can use "oc explain ObjectName --recursive" to get k8s object structures/fields.

Comment thread frontend/src/resources/rbac.ts Outdated
kind: RoleBindingKindType
metadata: Metadata
subjects?: {
kind: 'User' | 'Group'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
kind: 'User' | 'Group'
kind: UserKindType | GroupKindType | ServiceAccountKindType

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you should make a similar change in ClusterRoleBinding.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

agreed, created them and moved them in kubernetes-client.ts because they are generic kubernetes types that can be reused

Signed-off-by: kurwang <madeof50gold@gmail.com>
Copy link
Copy Markdown
Contributor

@Ginxo Ginxo left a comment

Choose a reason for hiding this comment

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

much better!! great job!

@Ginxo
Copy link
Copy Markdown
Contributor

Ginxo commented Aug 1, 2025

/lgtm

@Ginxo
Copy link
Copy Markdown
Contributor

Ginxo commented Aug 1, 2025

/retest

1 similar comment
@kurwang
Copy link
Copy Markdown
Contributor Author

kurwang commented Aug 1, 2025

/retest

@mshort55
Copy link
Copy Markdown
Contributor

mshort55 commented Aug 1, 2025

/lgtm

@kurwang
Copy link
Copy Markdown
Contributor Author

kurwang commented Aug 1, 2025

/retest

2 similar comments
@kurwang
Copy link
Copy Markdown
Contributor Author

kurwang commented Aug 4, 2025

/retest

@kurwang
Copy link
Copy Markdown
Contributor Author

kurwang commented Aug 4, 2025

/retest

@openshift-ci openshift-ci Bot removed the lgtm label Aug 4, 2025
Signed-off-by: kurwang <madeof50gold@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Aug 4, 2025

@Ginxo
Copy link
Copy Markdown
Contributor

Ginxo commented Aug 4, 2025

/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Aug 4, 2025
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Aug 4, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Ginxo, kurwang, mshort55, oksanabaza

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

The pull request process is described 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

@openshift-merge-bot openshift-merge-bot Bot merged commit a213db9 into stolostron:main Aug 4, 2025
11 checks passed
@mshort55
Copy link
Copy Markdown
Contributor

mshort55 commented Aug 4, 2025

/lgtm

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.

4 participants