From ea3688e1c057a042bbae97175f42eb4ec3029667 Mon Sep 17 00:00:00 2001
From: Matthew Holt <mholt@users.noreply.github.com>
Date: Thu, 26 Mar 2020 14:02:29 -0600
Subject: [PATCH] caddytls: Remove ManageSync

This seems unnecessary for now and we can always add it in later if
people have a good reason to need it.
---
 caddyconfig/httpcaddyfile/tlsapp.go |  3 +--
 modules/caddytls/automation.go      |  9 ---------
 modules/caddytls/tls.go             | 13 ++++---------
 3 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/caddyconfig/httpcaddyfile/tlsapp.go b/caddyconfig/httpcaddyfile/tlsapp.go
index 3b3963f58..67a129819 100644
--- a/caddyconfig/httpcaddyfile/tlsapp.go
+++ b/caddyconfig/httpcaddyfile/tlsapp.go
@@ -361,8 +361,7 @@ func consolidateAutomationPolicies(aps []*caddytls.AutomationPolicy) []*caddytls
 				aps[i].MustStaple == aps[j].MustStaple &&
 				aps[i].KeyType == aps[j].KeyType &&
 				aps[i].OnDemand == aps[j].OnDemand &&
-				aps[i].RenewalWindowRatio == aps[j].RenewalWindowRatio &&
-				aps[i].ManageSync == aps[j].ManageSync {
+				aps[i].RenewalWindowRatio == aps[j].RenewalWindowRatio {
 				if len(aps[i].Subjects) == 0 && len(aps[j].Subjects) > 0 {
 					aps = append(aps[:j], aps[j+1:]...)
 				} else if len(aps[i].Subjects) > 0 && len(aps[j].Subjects) == 0 {
diff --git a/modules/caddytls/automation.go b/modules/caddytls/automation.go
index fcf645467..24a21cbcd 100644
--- a/modules/caddytls/automation.go
+++ b/modules/caddytls/automation.go
@@ -97,15 +97,6 @@ type AutomationPolicy struct {
 	// load.
 	OnDemand bool `json:"on_demand,omitempty"`
 
-	// If true, certificate management will be conducted
-	// in the foreground; this will block config reloads
-	// and return errors if there were problems with
-	// obtaining or renewing certificates. This is often
-	// not desirable, especially when serving sites out
-	// of your control. Default: false
-	// TODO: is this really necessary per-policy? why not a global setting...
-	ManageSync bool `json:"manage_sync,omitempty"`
-
 	// Issuer stores the decoded issuer parameters. This is only
 	// used to populate an underlying certmagic.Config's Issuer
 	// field; it is not referenced thereafter.
diff --git a/modules/caddytls/tls.go b/modules/caddytls/tls.go
index b2c6324d3..54f0e2356 100644
--- a/modules/caddytls/tls.go
+++ b/modules/caddytls/tls.go
@@ -247,8 +247,8 @@ func (t *TLS) Cleanup() error {
 func (t *TLS) Manage(names []string) error {
 	// for a large number of names, we can be more memory-efficient
 	// by making only one certmagic.Config for all the names that
-	// use that config, rather than calling ManageSync/ManageAsync
-	// once for every name; so first, bin names by AutomationPolicy
+	// use that config, rather than calling ManageAsync once for
+	// every name; so first, bin names by AutomationPolicy
 	policyToNames := make(map[*AutomationPolicy][]string)
 	for _, name := range names {
 		ap := t.getAutomationPolicyForName(name)
@@ -257,14 +257,9 @@ func (t *TLS) Manage(names []string) error {
 
 	// now that names are grouped by policy, we can simply make one
 	// certmagic.Config for each (potentially large) group of names
-	// and call ManageSync/ManageAsync just once for the whole batch
+	// and call ManageAsync just once for the whole batch
 	for ap, names := range policyToNames {
-		var err error
-		if ap.ManageSync {
-			err = ap.magic.ManageSync(names)
-		} else {
-			err = ap.magic.ManageAsync(t.ctx.Context, names)
-		}
+		err := ap.magic.ManageAsync(t.ctx.Context, names)
 		if err != nil {
 			return fmt.Errorf("automate: manage %v: %v", names, err)
 		}