(inv *serpent.Invocation, variable codersdk.TemplateVersionVariable)
| 655 | } |
| 656 | |
| 657 | func promptForStringVariable(inv *serpent.Invocation, variable codersdk.TemplateVersionVariable) (string, error) { |
| 658 | prompt := "Enter value:" |
| 659 | if !variable.Sensitive { |
| 660 | if !variable.Required && variable.DefaultValue != "" { |
| 661 | prompt = fmt.Sprintf("Enter value (default: %q):", variable.DefaultValue) |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | return cliui.Prompt(inv, cliui.PromptOptions{ |
| 666 | Text: prompt, |
| 667 | Default: variable.DefaultValue, |
| 668 | Secret: variable.Sensitive, |
| 669 | Validate: createVariableValidator(variable), |
| 670 | }) |
| 671 | } |
| 672 | |
| 673 | func createVariableValidator(variable codersdk.TemplateVersionVariable) func(string) error { |
| 674 | return func(s string) error { |
no test coverage detected