Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CLI create: support for optional fields
  • Loading branch information
mtojek committed Mar 6, 2023
commit e804f40ccac468f0a75dba44498347ab7dd48238
2 changes: 1 addition & 1 deletion cli/cliui/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func RichParameter(cmd *cobra.Command, templateVersionParameter codersdk.Templat
}
} else {
text := "Enter a value"
if templateVersionParameter.DefaultValue != "" {
if !templateVersionParameter.Required {
text += fmt.Sprintf(" (default: %q)", templateVersionParameter.DefaultValue)
}
text += ":"
Expand Down
6 changes: 5 additions & 1 deletion codersdk/richparameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ func ValidateWorkspaceBuildParameters(richParameters []TemplateVersionParameter,

func ValidateWorkspaceBuildParameter(richParameter TemplateVersionParameter, buildParameter WorkspaceBuildParameter, lastBuildParameter *WorkspaceBuildParameter) error {
value := buildParameter.Value
if value == "" {
if value == "" && richParameter.Required {
return xerrors.Errorf("parameter value is required")
}

if value == "" { // parameter is optional
value = richParameter.DefaultValue
}

Expand Down