MCPcopy
hub / github.com/perkeep/perkeep / printConfigChangeHelp

Function printConfigChangeHelp

pkg/client/config.go:200–226  ·  view source on GitHub ↗

printConfigChangeHelp checks if conf contains obsolete keys, and prints additional help in this case.

(conf jsonconfig.Obj)

Source from the content-addressed store, hash-verified

198// printConfigChangeHelp checks if conf contains obsolete keys,
199// and prints additional help in this case.
200func printConfigChangeHelp(conf jsonconfig.Obj) {
201 // rename maps from old key names to the new ones.
202 // If there is no new one, the value is the empty string.
203 rename := map[string]string{
204 "keyId": "identity",
205 "publicKeyBlobref": "",
206 "selfPubKeyDir": "",
207 "secretRing": "identitySecretRing",
208 }
209 oldConfig := false
210 configChangedMsg := fmt.Sprintf("The client configuration file (%s) keys have changed.\n", osutil.UserClientConfigPath())
211 for _, unknown := range conf.UnknownKeys() {
212 v, ok := rename[unknown]
213 if ok {
214 if v != "" {
215 configChangedMsg += fmt.Sprintf("%q should be renamed %q.\n", unknown, v)
216 } else {
217 configChangedMsg += fmt.Sprintf("%q should be removed.\n", unknown)
218 }
219 oldConfig = true
220 }
221 }
222 if oldConfig {
223 configChangedMsg += "Please see https://perkeep.org/doc/client-config, or use pk-put init to recreate a default one."
224 log.Print(configChangedMsg)
225 }
226}
227
228// serverKeyId returns the public gpg key id ("identity" field)
229// from the user's server config , if any.

Callers 1

parseConfigMethod · 0.85

Calls 1

UserClientConfigPathFunction · 0.92

Tested by

no test coverage detected