| 103 | } |
| 104 | |
| 105 | func validateScope(key, hostname string) error { |
| 106 | for _, configKey := range config.Options { |
| 107 | if key == configKey.Key { |
| 108 | switch { |
| 109 | case configKey.Scope == config.ConfigScopeHostOnly && hostname == "": |
| 110 | return fmt.Errorf("--host required when setting %s", key) |
| 111 | case configKey.Scope == config.ConfigScopeGlobalOnly && hostname != "": |
| 112 | return fmt.Errorf("--host cannot be used when setting %s", key) |
| 113 | default: |
| 114 | return nil |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | return nil |
| 120 | } |
| 121 | |
| 122 | type InvalidValueError struct { |
| 123 | ValidValues []string |