summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2023-02-27 13:58:27 -0500
committerGitHub <noreply@github.com>2023-02-27 18:58:27 +0000
commitf6bab8ba85b231ea0930282e684c0040001059e6 (patch)
tree39b9e43536a582e423625e8f04d68a98ea8e3675 /modules
parent941eae5f615aeaf038f62002e673a7bf4886f1c7 (diff)
context: Rename func to `AppIfConfigured` (#5397)
Diffstat (limited to 'modules')
-rw-r--r--modules/caddypki/adminapi.go16
1 files changed, 5 insertions, 11 deletions
diff --git a/modules/caddypki/adminapi.go b/modules/caddypki/adminapi.go
index f03c6b6..cab7c70 100644
--- a/modules/caddypki/adminapi.go
+++ b/modules/caddypki/adminapi.go
@@ -49,20 +49,14 @@ func (a *adminAPI) Provision(ctx caddy.Context) error {
a.ctx = ctx
a.log = ctx.Logger(a) // TODO: passing in 'a' is a hack until the admin API is officially extensible (see #5032)
- // First check if the PKI app was configured, because
- // a.ctx.App() has the side effect of instantiating
- // and provisioning an app even if it wasn't configured.
- pkiAppConfigured := a.ctx.AppIsConfigured("pki")
- if !pkiAppConfigured {
- return nil
- }
-
- // Load the PKI app, so we can query it for information.
- appModule, err := a.ctx.App("pki")
+ // Avoid initializing PKI if it wasn't configured
+ pkiApp, err := a.ctx.AppIfConfigured("pki")
if err != nil {
return err
}
- a.pkiApp = appModule.(*PKI)
+ if pkiApp != nil {
+ a.pkiApp = pkiApp.(*PKI)
+ }
return nil
}