| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 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 types | 5 package types |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "flag" | 8 "flag" |
| 9 "net/url" | 9 "net/url" |
| 10 "strings" | 10 "strings" |
| 11 | 11 |
| 12 "github.com/luci/luci-go/common/errors" | 12 "github.com/luci/luci-go/common/errors" |
| 13 "github.com/luci/luci-go/luci_config/common/cfgtypes" | 13 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 14 ) | 14 ) |
| 15 | 15 |
| 16 const logDogURLScheme = "logdog" | 16 const logDogURLScheme = "logdog" |
| 17 | 17 |
| 18 // StreamAddr is a fully-qualified LogDog stream address. | 18 // StreamAddr is a fully-qualified LogDog stream address. |
| 19 type StreamAddr struct { | 19 type StreamAddr struct { |
| 20 // Host is the LogDog host. | 20 // Host is the LogDog host. |
| 21 » Host string | 21 » Host string `json:"host,omitempty"` |
| 22 | 22 |
| 23 // Project is the LUCI project name that this log belongs to. | 23 // Project is the LUCI project name that this log belongs to. |
| 24 » Project cfgtypes.ProjectName | 24 » Project cfgtypes.ProjectName `json:"project,omitempty"` |
| 25 | 25 |
| 26 // Path is the LogDog stream path. | 26 // Path is the LogDog stream path. |
| 27 » Path StreamPath | 27 » Path StreamPath `json:"path,omitempty"` |
| 28 } | 28 } |
| 29 | 29 |
| 30 var _ flag.Value = (*StreamAddr)(nil) | 30 var _ flag.Value = (*StreamAddr)(nil) |
| 31 | 31 |
| 32 // Set implements flag.Value | 32 // Set implements flag.Value |
| 33 func (s *StreamAddr) Set(v string) error { | 33 func (s *StreamAddr) Set(v string) error { |
| 34 a, err := ParseURL(v) | 34 a, err := ParseURL(v) |
| 35 if err != nil { | 35 if err != nil { |
| 36 return err | 36 return err |
| 37 } | 37 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 if err := addr.Path.Validate(); err != nil { | 108 if err := addr.Path.Validate(); err != nil { |
| 109 return nil, errors.Annotate(err).Reason("invalid stream path: %(
path)q"). | 109 return nil, errors.Annotate(err).Reason("invalid stream path: %(
path)q"). |
| 110 D("path", addr.Path). | 110 D("path", addr.Path). |
| 111 Err() | 111 Err() |
| 112 } | 112 } |
| 113 | 113 |
| 114 return &addr, nil | 114 return &addr, nil |
| 115 } | 115 } |
| OLD | NEW |