| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Package erroring implements config.Backend that simply returns an error. | 5 // Package erroring implements config.Backend that simply returns an error. |
| 6 // | 6 // |
| 7 // May be handy as a placeholder in case some more useful implementation is not | 7 // May be handy as a placeholder in case some more useful implementation is not |
| 8 // available. | 8 // available. |
| 9 package erroring | 9 package erroring |
| 10 | 10 |
| 11 import ( | 11 import ( |
| 12 "errors" |
| 12 "net/url" | 13 "net/url" |
| 13 | 14 |
| 15 "github.com/luci/luci-go/common/config" |
| 16 "github.com/luci/luci-go/common/config/impl/memory" |
| 14 "github.com/luci/luci-go/luci_config/server/cfgclient/backend" | 17 "github.com/luci/luci-go/luci_config/server/cfgclient/backend" |
| 15 | 18 |
| 16 "golang.org/x/net/context" | 19 "golang.org/x/net/context" |
| 17 ) | 20 ) |
| 18 | 21 |
| 19 // New produces backend.B instance that returns the given error for all calls. | 22 // New produces backend.B instance that returns the given error for all calls. |
| 20 // | 23 // |
| 21 // Panics if given err is nil. | 24 // Panics if given err is nil. |
| 22 func New(err error) backend.B { | 25 func New(err error) backend.B { |
| 23 if err == nil { | 26 if err == nil { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 42 | 45 |
| 43 func (e erroringImpl) GetAll(c context.Context, t backend.GetAllTarget, path str
ing, p backend.Params) ( | 46 func (e erroringImpl) GetAll(c context.Context, t backend.GetAllTarget, path str
ing, p backend.Params) ( |
| 44 []*backend.Item, error) { | 47 []*backend.Item, error) { |
| 45 | 48 |
| 46 return nil, e.err | 49 return nil, e.err |
| 47 } | 50 } |
| 48 | 51 |
| 49 func (e erroringImpl) ConfigSetURL(c context.Context, configSet string, p backen
d.Params) (url.URL, error) { | 52 func (e erroringImpl) ConfigSetURL(c context.Context, configSet string, p backen
d.Params) (url.URL, error) { |
| 50 return url.URL{}, e.err | 53 return url.URL{}, e.err |
| 51 } | 54 } |
| 55 |
| 56 func (e erroringImpl) GetConfigInterface(c context.Context, a backend.Authority)
config.Interface { |
| 57 emptySet := map[string]memory.ConfigSet{} |
| 58 i := memory.New(emptySet) |
| 59 memory.SetError(i, errors.New("error")) |
| 60 return i |
| 61 } |
| OLD | NEW |