MCPcopy
hub / github.com/perkeep/perkeep / convertToMultiServers

Function convertToMultiServers

pkg/client/config.go:172–196  ·  view source on GitHub ↗

convertToMultiServers takes an old style single-server client configuration and maps it to new a multi-servers configuration that is returned.

(conf jsonconfig.Obj)

Source from the content-addressed store, hash-verified

170
171// convertToMultiServers takes an old style single-server client configuration and maps it to new a multi-servers configuration that is returned.
172func 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.

Callers 1

parseConfigMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected