@@ -3,6 +3,7 @@ package certs
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "reflect"
6
7
"time"
7
8
8
9
cmapi "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
@@ -28,23 +29,25 @@ func CreateCertificate(ctx context.Context, l logr.Logger, c client.Client, svc
28
29
}, & cert )
29
30
if err != nil {
30
31
if errors .IsNotFound (err ) {
31
- l .Info ("Certificate resource doesn't exist, creating" )
32
+ l .V ( 1 ). Info ("Certificate resource doesn't exist, creating" )
32
33
return newCertificate (ctx , c , certName , secretName , svc )
33
34
}
34
35
35
- l .Info ("Error looking up certificate resource" , "error" , err )
36
+ l .V ( 1 ). Info ("Error looking up certificate resource" , "error" , err )
36
37
// Unexpected error, bail
37
38
return err
38
39
}
39
40
40
- l .Info ("Found existing Certificate, updating..." )
41
-
41
+ origCert := cert .DeepCopy ()
42
42
err = updateCertificate (& cert , svc )
43
43
if err != nil {
44
44
return err
45
45
}
46
-
47
- return c .Update (ctx , & cert )
46
+ if ! reflect .DeepEqual (origCert , cert ) {
47
+ l .V (1 ).Info ("Applying changes to existing certificate" )
48
+ return c .Update (ctx , & cert )
49
+ }
50
+ return nil
48
51
}
49
52
50
53
func newCertificate (ctx context.Context , c client.Client , certName , secretName string , svc corev1.Service ) error {
0 commit comments