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

Function openUserDB

internal/cli/ctl/moduleinit.go:156–179  ·  view source on GitHub ↗
(ctx *cli.Context)

Source from the content-addressed store, hash-verified

154}
155
156func openUserDB(ctx *cli.Context) (module.PlainUserDB, error) {
157 _, mod, err := getCfgBlockModule(ctx)
158 if err != nil {
159 return nil, err
160 }
161
162 userDB, ok := mod.(module.PlainUserDB)
163 if !ok {
164 return nil, cli.Exit(fmt.Sprintf("Error: configuration block %s is not a local credentials store", ctx.String("cfg-block")), 2)
165 }
166
167 started := false
168 if lt, ok := userDB.(container.LifetimeModule); ok {
169 if err := lt.Start(); err != nil {
170 return nil, err
171 }
172 started = true
173 }
174
175 if started {
176 return &managedUserDB{PlainUserDB: userDB, started: started}, nil
177 }
178 return userDB, nil
179}

Callers 1

initFunction · 0.85

Calls 3

getCfgBlockModuleFunction · 0.85
StartMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected