convertToMultiServers takes an old style single-server client configuration and maps it to new a multi-servers configuration that is returned.
(conf jsonconfig.Obj)
| 170 | |
| 171 | // convertToMultiServers takes an old style single-server client configuration and maps it to new a multi-servers configuration that is returned. |
| 172 | func convertToMultiServers(conf jsonconfig.Obj) (jsonconfig.Obj, error) { |
| 173 | server := conf.OptionalString("server", "") |
| 174 | if server == "" { |
| 175 | return nil, errors.New("could not convert config to multi-servers style: no \"server\" key found") |
| 176 | } |
| 177 | newConf := jsonconfig.Obj{ |
| 178 | "servers": map[string]interface{}{ |
| 179 | "server": map[string]interface{}{ |
| 180 | "auth": conf.OptionalString("auth", ""), |
| 181 | "default": true, |
| 182 | "server": server, |
| 183 | }, |
| 184 | }, |
| 185 | "identity": conf.OptionalString("identity", ""), |
| 186 | "identitySecretRing": conf.OptionalString("identitySecretRing", ""), |
| 187 | } |
| 188 | if ignoredFiles := conf.OptionalList("ignoredFiles"); ignoredFiles != nil { |
| 189 | var list []interface{} |
| 190 | for _, v := range ignoredFiles { |
| 191 | list = append(list, v) |
| 192 | } |
| 193 | newConf["ignoredFiles"] = list |
| 194 | } |
| 195 | return newConf, nil |
| 196 | } |
| 197 | |
| 198 | // printConfigChangeHelp checks if conf contains obsolete keys, |
| 199 | // and prints additional help in this case. |