|
1 | 1 | package bindings |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "errors" |
4 | 5 | "net/url" |
5 | 6 | "strings" |
6 | 7 |
|
@@ -36,7 +37,10 @@ func (d *DrainParamParser) FetchBindings() ([]syslog.Binding, error) { |
36 | 37 | b.OmitMetadata = getOmitMetadata(urlParsed, d.defaultDrainMetadata) |
37 | 38 | b.InternalTls = getInternalTLS(urlParsed) |
38 | 39 | b.DrainData = getBindingType(urlParsed) |
39 | | - b.LogFilter = getLogFilter(urlParsed) |
| 40 | + b.LogFilter, err = getLogFilter(urlParsed) |
| 41 | + if err != nil { |
| 42 | + return nil, err |
| 43 | + } |
40 | 44 |
|
41 | 45 | processed = append(processed, b) |
42 | 46 | } |
@@ -138,18 +142,18 @@ func NewLogTypeSet(logTypeList string, isExclude bool) *syslog.LogTypeSet { |
138 | 142 | return &set |
139 | 143 | } |
140 | 144 |
|
141 | | -func getLogFilter(u *url.URL) *syslog.LogTypeSet { |
| 145 | +func getLogFilter(u *url.URL) (*syslog.LogTypeSet, error) { |
142 | 146 | includeLogTypes := u.Query().Get("include-log-types") |
143 | 147 | excludeLogTypes := u.Query().Get("exclude-log-types") |
144 | 148 |
|
145 | 149 | if excludeLogTypes != "" && includeLogTypes != "" { |
146 | | - // TODO return errors.New("include-log-types and exclude-log-types can not be used at the same time") |
| 150 | + return nil, errors.New("include-log-types and exclude-log-types can not be used at the same time") |
147 | 151 | } else if excludeLogTypes != "" { |
148 | | - return NewLogTypeSet(excludeLogTypes, true) |
| 152 | + return NewLogTypeSet(excludeLogTypes, true), nil |
149 | 153 | } else if includeLogTypes != "" { |
150 | | - return NewLogTypeSet(includeLogTypes, false) |
| 154 | + return NewLogTypeSet(includeLogTypes, false), nil |
151 | 155 | } |
152 | | - return NewLogTypeSet("", false) |
| 156 | + return NewLogTypeSet("", false), nil |
153 | 157 | } |
154 | 158 |
|
155 | 159 | func getRemoveMetadataQuery(u *url.URL) string { |
|
0 commit comments