mutate parses the given string as URL query parameters and sets the fields according to the parsed values
(given string)
| 42 | // mutate parses the given string as URL query parameters and sets the fields |
| 43 | // according to the parsed values |
| 44 | func (o *Options) mutate(given string) error { |
| 45 | vals, err := url.ParseQuery(given) |
| 46 | if err != nil { |
| 47 | return err |
| 48 | } |
| 49 | |
| 50 | if v := vals.Get("show-successes"); v != "" { |
| 51 | if f, err := strconv.ParseBool(v); err == nil { |
| 52 | o.ShowSuccesses = f |
| 53 | } else { |
| 54 | return err |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | if v := vals.Get("show-warnings"); v != "" { |
| 59 | if f, err := strconv.ParseBool(v); err == nil { |
| 60 | o.ShowWarnings = f |
| 61 | } else { |
| 62 | return err |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | if v := vals.Get("show-policy-docs-link"); v != "" { |
| 67 | if f, err := strconv.ParseBool(v); err == nil { |
| 68 | o.ShowPolicyDocsLink = f |
| 69 | } else { |
| 70 | return err |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | return nil |
| 75 | } |
| 76 | |
| 77 | // Write proxies the write operation to the underlying writer. |
| 78 | func (t *Target) Write(data []byte) (int, error) { |