66 "strings"
77
88 v1 "github.com/acorn-io/acorn/pkg/apis/internal.acorn.io/v1"
9+ "github.com/acorn-io/acorn/pkg/config"
910 "github.com/acorn-io/acorn/pkg/labels"
1011 "github.com/acorn-io/acorn/pkg/system"
1112 "github.com/acorn-io/baaah/pkg/router"
@@ -20,7 +21,7 @@ import (
2021
2122// ProvisionWildcardCert provisions a Let's Encrypt wildcard certificate for *.<domain>.on-acorn.io
2223func ProvisionWildcardCert (req router.Request , domain , token string ) error {
23- logrus .Infof ("Provisioning wildcard cert for %v" , domain )
24+ logrus .Debugf ("Provisioning wildcard cert for %v" , domain )
2425 // Ensure that we have a Let's Encrypt account ready
2526 leUser , err := ensureLEUser (req .Ctx , req .Client )
2627 if err != nil {
@@ -51,16 +52,14 @@ func RequireSecretTypeTLS(h router.Handler) router.Handler {
5152func RenewCert (req router.Request , resp router.Response ) error {
5253 sec := req .Object .(* corev1.Secret )
5354
54- logrus .Infof ("Renewing certificate for %v" , sec .Name )
55-
5655 leUser , err := ensureLEUser (req .Ctx , req .Client )
5756 if err != nil {
5857 return err
5958 }
6059
6160 // Early exit if existing cert is still valid
6261 if ! leUser .mustRenew (sec ) {
63- logrus .Infof ("Certificate for %v is still valid" , sec .Name )
62+ logrus .Debugf ("Certificate for %v is still valid" , sec .Name )
6463 return nil
6564 }
6665
@@ -70,7 +69,7 @@ func RenewCert(req router.Request, resp router.Response) error {
7069
7170 // Do not start a new challenge if we already have one in progress
7271 if ! lockDomain (domain ) {
73- logrus .Infof ("not starting certificate renewal: %v: %s" , ErrCertificateRequestInProgress , domain )
72+ logrus .Debugf ("not starting certificate renewal: %v: %s" , ErrCertificateRequestInProgress , domain )
7473 return
7574 }
7675 defer unlockDomain (domain )
@@ -109,6 +108,18 @@ func RenewCert(req router.Request, resp router.Response) error {
109108// Note: this does not actually provision the certificates, it just creates the empty secret
110109// which is picked up by the route handled by RenewCert above
111110func ProvisionCerts (req router.Request , resp router.Response ) error {
111+
112+ cfg , err := config .Get (req .Ctx , req .Client )
113+ if err != nil {
114+ return err
115+ }
116+
117+ // Early exit if Let's Encrypt is not enabled
118+ // Just to be on the safe side, we check for all possible allowed configuration values
119+ if strings .EqualFold (* cfg .LetsEncrypt , "disabled" ) {
120+ return nil
121+ }
122+
112123 appInstance := req .Object .(* v1.AppInstance )
113124
114125 appInstanceIDSegment := strings .SplitN (string (appInstance .GetUID ()), "-" , 2 )[0 ]
@@ -150,7 +161,7 @@ func (u *LEUser) provisionCertIfNotExists(ctx context.Context, client kclient.Cl
150161 go func () {
151162 // Do not start a new challenge if we already have one in progress
152163 if ! lockDomain (domain ) {
153- logrus .Infof ("not starting certificate renewal: %v: %s" , ErrCertificateRequestInProgress , domain )
164+ logrus .Debugf ("not starting certificate renewal: %v: %s" , ErrCertificateRequestInProgress , domain )
154165 return
155166 }
156167 defer unlockDomain (domain )
0 commit comments