MCPcopy Index your code
hub / github.com/foxcpp/maddy / createInlineModule

Function createInlineModule

framework/config/module/modconfig.go:43–65  ·  view source on GitHub ↗

createInlineModule is a helper function for config matchers that can create inline modules.

(c *container.C, preferredNamespace, modName string)

Source from the content-addressed store, hash-verified

41
42// createInlineModule is a helper function for config matchers that can create inline modules.
43func createInlineModule(c *container.C, preferredNamespace, modName string) (module.Module, error) {
44 var newMod modules.FuncNewModule
45 originalModName := modName
46
47 // First try to extend the name with preferred namespace unless the name
48 // already contains it.
49 if !strings.Contains(modName, ".") && preferredNamespace != "" {
50 modName = preferredNamespace + "." + modName
51 newMod = modules.Get(modName)
52 }
53
54 // Then try global namespace for compatibility and complex modules.
55 if newMod == nil {
56 newMod = modules.Get(originalModName)
57 }
58
59 // Bail if both failed.
60 if newMod == nil {
61 return nil, fmt.Errorf("unknown module: %s (namespace: %s)", originalModName, preferredNamespace)
62 }
63
64 return newMod(c, modName, "")
65}
66
67// configureInlineModule constructs "faked" config tree and passes it to module
68// Init function to make it look like it is defined at top-level.

Callers 1

ModuleFromNodeFunction · 0.85

Calls 1

GetFunction · 0.92

Tested by

no test coverage detected