aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2019-09-13 09:45:10 -0600
committerMatthew Holt <[email protected]>2019-09-13 09:45:10 -0600
commitd0c1756fc56dd43cee73ef7ccabb2276a5b26caf (patch)
treed8e2fa2fc9349462cc40254fa4ead1676d62bf9d
parented40a5dcab80f17d63c3fba83349004eac3c7930 (diff)
downloadcaddy-d0c1756fc56dd43cee73ef7ccabb2276a5b26caf.tar.gz
caddy-d0c1756fc56dd43cee73ef7ccabb2276a5b26caf.zip
httpcaddyfile: Fix tls certificate loader module names (#2748)
-rw-r--r--caddyconfig/httpcaddyfile/httptype.go2
-rw-r--r--modules.go11
2 files changed, 12 insertions, 1 deletions
diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go
index ce719dd33..32791e90a 100644
--- a/caddyconfig/httpcaddyfile/httptype.go
+++ b/caddyconfig/httpcaddyfile/httptype.go
@@ -183,7 +183,7 @@ func (st ServerType) Setup(originalServerBlocks []caddyfile.ServerBlock,
if clVals, ok := sblock.pile["tls.certificate_loader"]; ok {
for _, clVal := range clVals {
loader := clVal.Value.(caddytls.CertificateLoader)
- loaderName := caddy.GetModuleName(loader)
+ loaderName := caddy.GetModuleID(loader)
tlsApp.Certificates[loaderName] = caddyconfig.JSON(loader, &warnings)
}
}
diff --git a/modules.go b/modules.go
index ad03adf7b..3ca53841b 100644
--- a/modules.go
+++ b/modules.go
@@ -126,6 +126,17 @@ func GetModuleName(instance interface{}) string {
return name
}
+// GetModuleID returns a module's ID (the last element of its name)
+// from an instance of its value. If the value is not a module,
+// an empty string will be returned.
+func GetModuleID(instance interface{}) string {
+ var name string
+ if mod, ok := instance.(Module); ok {
+ name = mod.CaddyModule().ID()
+ }
+ return name
+}
+
// GetModules returns all modules in the given scope/namespace.
// For example, a scope of "foo" returns modules named "foo.bar",
// "foo.loo", but not "bar", "foo.bar.loo", etc. An empty scope