Browse Source

Fix shadowed variables as prompted by go lint/vet

pull/266/head
Víctor Cuadrado Juan 7 years ago
parent
commit
d18a122ad7
No known key found for this signature in database GPG Key ID: 223F15CA5AAF0E78
  1. 2
      src/github.com/matrix-org/go-neb/clients/clients.go
  2. 14
      src/github.com/matrix-org/go-neb/goneb.go

2
src/github.com/matrix-org/go-neb/clients/clients.go

@ -129,7 +129,7 @@ func (c *Clients) updateClientInDB(newConfig api.ClientConfig) (new clientEntry,
// set the new display name if they differ
if old.config.DisplayName != new.config.DisplayName {
if err := new.client.SetDisplayName(new.config.DisplayName); err != nil {
if err = new.client.SetDisplayName(new.config.DisplayName); err != nil {
// whine about it but don't stop: this isn't fatal.
log.WithFields(log.Fields{
log.ErrorKey: err,

14
src/github.com/matrix-org/go-neb/goneb.go

@ -172,15 +172,15 @@ func setup(e envVars, mux *http.ServeMux, matrixClient *http.Client) {
log.Info("Inserted ", len(cfg.Sessions), " sessions")
}
clients := clients.New(db, matrixClient)
if err := clients.Start(); err != nil {
matrixClients := clients.New(db, matrixClient)
if err := matrixClients.Start(); err != nil {
log.WithError(err).Panic("Failed to start up clients")
}
// Handle non-admin paths for normal NEB functioning
mux.Handle("/metrics", prometheus.Handler())
mux.Handle("/test", prometheus.InstrumentHandler("test", util.MakeJSONAPI(&handlers.Heartbeat{})))
wh := handlers.NewWebhook(db, clients)
wh := handlers.NewWebhook(db, matrixClients)
mux.HandleFunc("/services/hooks/", prometheus.InstrumentHandlerFunc("webhookHandler", util.Protect(wh.Handle)))
rh := &handlers.RealmRedirect{db}
mux.HandleFunc("/realms/redirects/", prometheus.InstrumentHandlerFunc("realmRedirectHandler", util.Protect(rh.Handle)))
@ -188,7 +188,7 @@ func setup(e envVars, mux *http.ServeMux, matrixClient *http.Client) {
// Read exclusively from the config file if one was supplied.
// Otherwise, add HTTP listeners for new Services/Sessions/Clients/etc.
if e.ConfigFile != "" {
if err := insertServicesFromConfig(clients, cfg.Services); err != nil {
if err := insertServicesFromConfig(matrixClients, cfg.Services); err != nil {
log.WithError(err).Panic("Failed to insert services")
}
@ -196,13 +196,13 @@ func setup(e envVars, mux *http.ServeMux, matrixClient *http.Client) {
} else {
mux.Handle("/admin/getService", prometheus.InstrumentHandler("getService", util.MakeJSONAPI(&handlers.GetService{db})))
mux.Handle("/admin/getSession", prometheus.InstrumentHandler("getSession", util.MakeJSONAPI(&handlers.GetSession{db})))
mux.Handle("/admin/configureClient", prometheus.InstrumentHandler("configureClient", util.MakeJSONAPI(&handlers.ConfigureClient{clients})))
mux.Handle("/admin/configureService", prometheus.InstrumentHandler("configureService", util.MakeJSONAPI(handlers.NewConfigureService(db, clients))))
mux.Handle("/admin/configureClient", prometheus.InstrumentHandler("configureClient", util.MakeJSONAPI(&handlers.ConfigureClient{matrixClients})))
mux.Handle("/admin/configureService", prometheus.InstrumentHandler("configureService", util.MakeJSONAPI(handlers.NewConfigureService(db, matrixClients))))
mux.Handle("/admin/configureAuthRealm", prometheus.InstrumentHandler("configureAuthRealm", util.MakeJSONAPI(&handlers.ConfigureAuthRealm{db})))
mux.Handle("/admin/requestAuthSession", prometheus.InstrumentHandler("requestAuthSession", util.MakeJSONAPI(&handlers.RequestAuthSession{db})))
mux.Handle("/admin/removeAuthSession", prometheus.InstrumentHandler("removeAuthSession", util.MakeJSONAPI(&handlers.RemoveAuthSession{db})))
}
polling.SetClients(clients)
polling.SetClients(matrixClients)
if err := polling.Start(); err != nil {
log.WithError(err).Panic("Failed to start polling")
}

Loading…
Cancel
Save