| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 // that can be found in the LICENSE file. | |
| 4 | |
| 5 // Package erroring implements config.Interface that simply returns an error. | |
| 6 // | |
| 7 // May be handy as a placeholder in case some more useful implementation is not | |
| 8 // available. | |
| 9 package erroring | |
| 10 | |
| 11 import ( | |
| 12 "net/url" | |
| 13 | |
| 14 "golang.org/x/net/context" | |
| 15 | |
| 16 "github.com/luci/luci-go/common/config" | |
| 17 ) | |
| 18 | |
| 19 // New produces config.Interface instance that returns the given error for all | |
| 20 // calls. | |
| 21 // | |
| 22 // Panics if given err is nil. | |
| 23 func New(err error) config.Interface { | |
| 24 if err == nil { | |
| 25 panic("the error must not be nil") | |
| 26 } | |
| 27 return erroringImpl{err} | |
| 28 } | |
| 29 | |
| 30 type erroringImpl struct { | |
| 31 err error | |
| 32 } | |
| 33 | |
| 34 func (e erroringImpl) ServiceURL(ctx context.Context) url.URL { | |
| 35 return url.URL{ | |
| 36 Scheme: "error", | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 func (e erroringImpl) GetConfig(ctx context.Context, configSet, path string, has
hOnly bool) (*config.Config, error) { | |
| 41 return nil, e.err | |
| 42 } | |
| 43 | |
| 44 func (e erroringImpl) GetConfigByHash(ctx context.Context, contentHash string) (
string, error) { | |
| 45 return "", e.err | |
| 46 } | |
| 47 | |
| 48 func (e erroringImpl) GetConfigSetLocation(ctx context.Context, configSet string
) (*url.URL, error) { | |
| 49 return nil, e.err | |
| 50 } | |
| 51 | |
| 52 func (e erroringImpl) GetProjectConfigs(ctx context.Context, path string, hashes
Only bool) ([]config.Config, error) { | |
| 53 return nil, e.err | |
| 54 } | |
| 55 | |
| 56 func (e erroringImpl) GetProjects(ctx context.Context) ([]config.Project, error)
{ | |
| 57 return nil, e.err | |
| 58 } | |
| 59 | |
| 60 func (e erroringImpl) GetRefConfigs(ctx context.Context, path string, hashesOnly
bool) ([]config.Config, error) { | |
| 61 return nil, e.err | |
| 62 } | |
| 63 | |
| 64 func (e erroringImpl) GetRefs(ctx context.Context, projectID string) ([]string,
error) { | |
| 65 return nil, e.err | |
| 66 } | |
| OLD | NEW |