From 54a487f1fba3744f642772c430d18e940440a87f Mon Sep 17 00:00:00 2001 From: irbekrm Date: Thu, 28 Apr 2022 14:41:22 +0100 Subject: [PATCH] certificates.Apply returns the patched certificate Signed-off-by: irbekrm --- internal/controller/certificates/apply.go | 8 +++----- pkg/controller/certificate-shim/sync.go | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/controller/certificates/apply.go b/internal/controller/certificates/apply.go index a3f09effc..e1c14df5e 100644 --- a/internal/controller/certificates/apply.go +++ b/internal/controller/certificates/apply.go @@ -35,18 +35,16 @@ import ( // The given fieldManager is will be used as the FieldManager in the Apply // call. // Always sets Force Apply to true. -func Apply(ctx context.Context, cl cmclient.Interface, fieldManager string, crt *cmapi.Certificate) error { +func Apply(ctx context.Context, cl cmclient.Interface, fieldManager string, crt *cmapi.Certificate) (*cmapi.Certificate, error) { crtData, err := serializeApply(crt) if err != nil { - return err + return nil, err } - _, err = cl.CertmanagerV1().Certificates(crt.Namespace).Patch( + return cl.CertmanagerV1().Certificates(crt.Namespace).Patch( ctx, crt.Name, apitypes.ApplyPatchType, crtData, metav1.PatchOptions{Force: pointer.Bool(true), FieldManager: fieldManager}, ) - - return err } // ApplyStatus will make a Patch API call with the given client to the diff --git a/pkg/controller/certificate-shim/sync.go b/pkg/controller/certificate-shim/sync.go index 9d038b0f3..166d392b0 100644 --- a/pkg/controller/certificate-shim/sync.go +++ b/pkg/controller/certificate-shim/sync.go @@ -135,7 +135,7 @@ func SyncFnFor( for _, crt := range updateCrts { if utilfeature.DefaultFeatureGate.Enabled(feature.ServerSideApply) { - err = internalcertificates.Apply(ctx, cmClient, fieldManager, &cmapi.Certificate{ + _, err = internalcertificates.Apply(ctx, cmClient, fieldManager, &cmapi.Certificate{ ObjectMeta: metav1.ObjectMeta{ Name: crt.Name, Namespace: crt.Namespace,