OLD | NEW |
1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 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 backend | 5 package backend |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 | 9 |
10 "github.com/luci/luci-go/common/errors" | 10 "github.com/luci/luci-go/common/errors" |
(...skipping 18 matching lines...) Expand all Loading... |
29 ) | 29 ) |
30 | 30 |
31 // MarshalJSON implements json.Marshaler. | 31 // MarshalJSON implements json.Marshaler. |
32 func (gat GetAllTarget) MarshalJSON() ([]byte, error) { | 32 func (gat GetAllTarget) MarshalJSON() ([]byte, error) { |
33 switch gat { | 33 switch gat { |
34 case GetAllProject: | 34 case GetAllProject: |
35 return projectJSON, nil | 35 return projectJSON, nil |
36 case GetAllRef: | 36 case GetAllRef: |
37 return refJSON, nil | 37 return refJSON, nil |
38 default: | 38 default: |
39 » » return nil, errors.Reason("unknown GetAllTarget: %(value)v").D("
value", gat).Err() | 39 » » return nil, errors.Reason("unknown GetAllTarget: %v", gat).Err() |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 // UnmarshalJSON implements json.Unmarshaler. | 43 // UnmarshalJSON implements json.Unmarshaler. |
44 func (gat *GetAllTarget) UnmarshalJSON(d []byte) error { | 44 func (gat *GetAllTarget) UnmarshalJSON(d []byte) error { |
45 switch { | 45 switch { |
46 case bytes.Equal(d, projectJSON): | 46 case bytes.Equal(d, projectJSON): |
47 *gat = GetAllProject | 47 *gat = GetAllProject |
48 case bytes.Equal(d, refJSON): | 48 case bytes.Equal(d, refJSON): |
49 *gat = GetAllRef | 49 *gat = GetAllRef |
50 default: | 50 default: |
51 » » return errors.Reason("unknown GetAllTarget: %(value)q").D("value
", d).Err() | 51 » » return errors.Reason("unknown GetAllTarget: %q", d).Err() |
52 } | 52 } |
53 return nil | 53 return nil |
54 } | 54 } |
OLD | NEW |