Skip to content

Conversation

@wallrj
Copy link
Member

@wallrj wallrj commented Mar 25, 2021

  • Update controller-runtime to v0.8.3 (also updates various Kubernetes dependencies)
  • controller-runtime introduced a new client.Object interface which is a superset of runtime.Object. Use that where appropriate.
  • controller-runtime changed the Reconcile interface to include a context.Context
  • Update RBAC to allow use of the new coordination.k8s.io API in Kubernetes

Fixes #7

@jetstack-bot jetstack-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 25, 2021
@wallrj wallrj force-pushed the 7-controller-runtime-0.8.3 branch from c9ac06a to 15ff4c1 Compare March 25, 2021 20:47
@wallrj wallrj force-pushed the 7-controller-runtime-0.8.3 branch from ebbe964 to a3b2d62 Compare March 25, 2021 22:36
@wallrj wallrj changed the title WIP: Upgrade to controller-runtime 0.8.3 Upgrade to controller-runtime 0.8.3 Mar 25, 2021
@wallrj wallrj marked this pull request as ready for review March 25, 2021 22:41
@jetstack-bot jetstack-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 25, 2021
Copy link
Member Author

@wallrj wallrj left a comment

Choose a reason for hiding this comment

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

Some explanatory comments.

return ctrl.Result{}, nil
}

issuer := issuerRO.(client.Object)
Copy link
Member Author

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
Copy link
Member Author

Choose a reason for hiding this comment

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


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) {
Copy link
Member Author

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()
Copy link
Member Author

Choose a reason for hiding this comment

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

@wallrj wallrj force-pushed the 7-controller-runtime-0.8.3 branch from f2e0514 to 5260912 Compare March 26, 2021 07:00
// CertificateRequestReconciler reconciles a CertificateRequest object
type CertificateRequestReconciler struct {
client.Client
Log logr.Logger
Copy link
Member Author

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)
Copy link
Member Author

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

@JoshVanL
Copy link
Contributor

/lgtm
/approve

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 26, 2021
@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JoshVanL, wallrj
To complete the pull request process, please assign
You can assign the PR to them by writing /assign in a comment when ready.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wallrj wallrj merged commit 2da3f72 into cert-manager:main Mar 26, 2021
@wallrj wallrj deleted the 7-controller-runtime-0.8.3 branch March 26, 2021 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update controller-runtime

3 participants