-
Notifications
You must be signed in to change notification settings - Fork 20
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
Upgrade to controller-runtime 0.8.3 #9
Conversation
Signed-off-by: Richard Wall <richard.wall@jetstack.io>
Signed-off-by: Richard Wall <richard.wall@jetstack.io>
c9ac06a
to
15ff4c1
Compare
Signed-off-by: Richard Wall <richard.wall@jetstack.io>
Signed-off-by: Richard Wall <richard.wall@jetstack.io>
ebbe964
to
a3b2d62
Compare
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.
Some explanatory comments.
if err != nil { | ||
err = fmt.Errorf("%w: %v", errIssuerRef, err) | ||
log.Error(err, "Unrecognised kind. Ignoring.") | ||
setReadyCondition(cmmeta.ConditionFalse, cmapi.CertificateRequestReasonFailed, err.Error()) | ||
return ctrl.Result{}, nil | ||
} | ||
|
||
issuer := issuerRO.(client.Object) |
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.
Case a runtime.Object
to client.Object
.
This should always work for issuer types because they will always also satisfy the metav1.Object
interface.
See https://github.com/kubernetes-sigs/controller-runtime/blob/fa42462a01b0f33cfb42dd7396d198435a013122/pkg/client/object.go#L24-L48
- create | ||
- get | ||
- list | ||
- update |
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.
@@ -58,8 +58,7 @@ type CertificateRequestReconciler struct { | |||
// +kubebuilder:rbac:groups=cert-manager.io,resources=certificaterequests/status,verbs=get;update;patch | |||
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch | |||
|
|||
func (r *CertificateRequestReconciler) Reconcile(req ctrl.Request) (result ctrl.Result, err error) { | |||
ctx := context.Background() | |||
func (r *CertificateRequestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err 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.
fakeClient := fake.NewClientBuilder(). | ||
WithScheme(scheme). | ||
WithObjects(tc.objects...). | ||
Build() |
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.
Signed-off-by: Richard Wall <richard.wall@jetstack.io>
f2e0514
to
5260912
Compare
@@ -48,7 +48,6 @@ var ( | |||
// CertificateRequestReconciler reconciles a CertificateRequest object | |||
type CertificateRequestReconciler struct { | |||
client.Client | |||
Log logr.Logger |
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.
controller-runtime now sets up a logger for each controller and gives it a name based on the Kind
of resource that it being reconciled. See kubernetes-sigs/controller-runtime#1203
ctx := context.Background() | ||
log := r.Log.WithValues("certificaterequest", req.NamespacedName) | ||
func (r *CertificateRequestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error) { | ||
log := ctrl.LoggerFrom(ctx) |
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.
controller-runtime now sets up a logger for each controller and gives it a name based on the Kind of resource that it being reconciled. See kubernetes-sigs/controller-runtime#1203
/lgtm |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: JoshVanL, wallrj 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 |
client.Object
interface which is a superset ofruntime.Object
. Use that where appropriate.Reconcile
interface to include acontext.Context
coordination.k8s.io
API in KubernetesFixes #7