| 243 | } |
| 244 | |
| 245 | func (o *SetupQuestion) OnAnswerWithReset(answer string, isReset bool) (err error) { |
| 246 | if o.Type == SettingTypeBool { |
| 247 | if answer == "" { |
| 248 | o.Value = "" |
| 249 | } else { |
| 250 | _, err := ParseBool(answer) |
| 251 | if err != nil { |
| 252 | return fmt.Errorf(i18n.T("plugin_invalid_boolean_value"), answer) |
| 253 | } |
| 254 | o.Value = strings.ToLower(answer) |
| 255 | } |
| 256 | } else { |
| 257 | o.Value = answer |
| 258 | } |
| 259 | if o.EnvVariable != "" { |
| 260 | if err = os.Setenv(o.EnvVariable, o.Value); err != nil { |
| 261 | return |
| 262 | } |
| 263 | } |
| 264 | // Skip validation when explicitly resetting a value - the user intentionally |
| 265 | // wants to clear the value even if it's required |
| 266 | if isReset { |
| 267 | return nil |
| 268 | } |
| 269 | err = o.IsValidErr() |
| 270 | return |
| 271 | } |
| 272 | |
| 273 | func (o *Setting) IsValidErr() (err error) { |
| 274 | if !o.IsValid() { |