-
Notifications
You must be signed in to change notification settings - Fork 24
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
Refactor: move common functions out of csr controller, into constants
or helpers
.
#428
Refactor: move common functions out of csr controller, into constants
or helpers
.
#428
Conversation
…s` or `helpers`. Signed-off-by: xuezhaojun <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 7 changed files in this pull request and generated no suggestions.
Files not reviewed (2)
- pkg/controller/csr/csr_controller.go: Evaluated as low risk
- pkg/controller/csr/csr_controller_test.go: Evaluated as low risk
Comments skipped due to low confidence (1)
pkg/controller/controller.go:49
- Ensure that the new behavior introduced by
extraApprovalConditions
incsr.Add
is covered by tests.
[]func(ctx context.Context, csr *certificatesv1.CertificateSigningRequest) (bool, error){})
/assign @zhujian7 |
) | ||
|
||
var log = logf.Log.WithName("controller_csr") | ||
|
||
func getClusterName(csr *certificatesv1.CertificateSigningRequest) (clusterName string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the first change, move to helpers pkg
) | ||
|
||
// Add creates a new CSR Controller and adds it to the Manager. The Manager will set fields on the Controller | ||
// and Start it when the Manager is Started. | ||
func Add(ctx context.Context, | ||
mgr manager.Manager, | ||
clientHolder *helpers.ClientHolder) error { | ||
clientHolder *helpers.ClientHolder, | ||
extraApprovalConditions []func(ctx context.Context, csr *certificatesv1.CertificateSigningRequest) (bool, error)) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the second change, now the Add function accept extraApprovalConditions.
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: xuezhaojun, zhujian7 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: xuezhaojun, zhujian7 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Quality Gate passedIssues Measures |
There are mainly 2 changes in this PR:
First, the
GetClusterName
is moved fromcsr-controller
tohelpers
pkg, along with some const values move toconstant
pkg.Second, the
Add
function added aextraApprovalConditions
array, to allow thecsr controller
to accept and use customized approval conditions.What I want to achieve, is in the future, we can have more approvalConditions defined and implementated in their our pkg(for example, flightctl approve stays in the
flightctl
pkg with other flight logic code), when we add new approval condition, thecsr controller
don't need to change much.