NormalizeProtocolMode validates the configured protocol mode and applies the default auto mode when the user did not specify one.
(mode string)
| 85 | // NormalizeProtocolMode validates the configured protocol mode and applies the |
| 86 | // default auto mode when the user did not specify one. |
| 87 | func NormalizeProtocolMode(mode string) (string, error) { |
| 88 | if mode == "" { |
| 89 | return ProtocolAuto, nil |
| 90 | } |
| 91 | switch mode { |
| 92 | case ProtocolAuto, ProtocolV1, ProtocolV2: |
| 93 | return mode, nil |
| 94 | default: |
| 95 | return "", fmt.Errorf("unsupported protocol mode %q", mode) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // ParseMapping parses a CLI --map value into a ref mapping. |
| 100 | func ParseMapping(raw string) (RefMapping, error) { |
no outgoing calls