Skip to content

fix: Skip empty values so Terraform can use the default value #3902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions coderd/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ func (api *API) postWorkspacesByOrganization(rw http.ResponseWriter, r *http.Req
return xerrors.Errorf("insert workspace: %w", err)
}
for _, parameterValue := range createWorkspace.ParameterValues {
// If the value is empty, we don't want to save it on database so
// Terraform can use the default value
if parameterValue.SourceValue == "" {
continue
}

_, err = db.InsertParameterValue(r.Context(), database.InsertParameterValueParams{
ID: uuid.New(),
Name: parameterValue.Name,
Expand Down
1 change: 1 addition & 0 deletions site/src/components/ParameterInput/ParameterInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const ParameterField: React.FC<React.PropsWithChildren<ParameterInputProps>> = (
id={schema.name}
size="small"
defaultValue={schema.default_source_value}
placeholder={schema.default_source_value}
disabled={disabled}
onChange={(event) => {
onChange(event.target.value)
Expand Down