Skip to content

feat: mark coder_parameter as "required" #6433

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 21 commits into from
Mar 7, 2023
Merged
Prev Previous commit
Next Next commit
Pass through providerd
  • Loading branch information
mtojek committed Mar 3, 2023
commit 110b10b998f67a56e7bb4df23c396c16bcb79f66
3 changes: 3 additions & 0 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions coderd/database/dbfake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,7 @@ func (q *fakeQuerier) InsertTemplateVersionParameter(_ context.Context, arg data
ValidationMin: arg.ValidationMin,
ValidationMax: arg.ValidationMax,
ValidationMonotonic: arg.ValidationMonotonic,
Required: arg.Required,
}
q.templateVersionParameters = append(q.templateVersionParameters, param)
return param, nil
Expand Down
8 changes: 6 additions & 2 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions coderd/database/queries/templateversionparameters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ INSERT INTO
validation_min,
validation_max,
validation_error,
validation_monotonic
validation_monotonic,
required
)
VALUES
(
Expand All @@ -29,7 +30,8 @@ VALUES
$10,
$11,
$12,
$13
$13,
$14
) RETURNING *;

-- name: GetTemplateVersionParameters :many
Expand Down
1 change: 1 addition & 0 deletions coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,7 @@ func convertTemplateVersionParameter(param database.TemplateVersionParameter) (c
ValidationMax: param.ValidationMax,
ValidationError: param.ValidationError,
ValidationMonotonic: codersdk.ValidationMonotonicOrder(param.ValidationMonotonic),
Required: param.Required,
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions codersdk/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type TemplateVersionParameter struct {
ValidationMin int32 `json:"validation_min,omitempty"`
ValidationMax int32 `json:"validation_max,omitempty"`
ValidationMonotonic ValidationMonotonicOrder `json:"validation_monotonic,omitempty" enums:"increasing,decreasing"`
Required bool `json:"required"`
}

// TemplateVersionParameterOption represents a selectable option for a template parameter.
Expand Down
2 changes: 2 additions & 0 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -4838,6 +4838,7 @@ Parameter represents a set value for the scope.
"value": "string"
}
],
"required": true,
"type": "string",
"validation_error": "string",
"validation_max": 0,
Expand All @@ -4858,6 +4859,7 @@ Parameter represents a set value for the scope.
| `mutable` | boolean | false | | |
| `name` | string | false | | |
| `options` | array of [codersdk.TemplateVersionParameterOption](#codersdktemplateversionparameteroption) | false | | |
| `required` | boolean | false | | |
| `type` | string | false | | |
| `validation_error` | string | false | | |
| `validation_max` | integer | false | | |
Expand Down
2 changes: 2 additions & 0 deletions docs/api/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -2182,6 +2182,7 @@ curl -X GET http://coder-server:8080/api/v2/templateversions/{templateversion}/r
"value": "string"
}
],
"required": true,
"type": "string",
"validation_error": "string",
"validation_max": 0,
Expand Down Expand Up @@ -2216,6 +2217,7 @@ Status Code **200**
| `»» icon` | string | false | | |
| `»» name` | string | false | | |
| `»» value` | string | false | | |
| `» required` | boolean | false | | |
| `» type` | string | false | | |
| `» validation_error` | string | false | | |
| `» validation_max` | integer | false | | |
Expand Down
1 change: 1 addition & 0 deletions provisioner/terraform/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string) (*State, error
Mutable: param.Mutable,
DefaultValue: param.Default,
Icon: param.Icon,
Required: param.Default == "", // FIXME pull from terraform-provider-coder
}
if len(param.Validation) == 1 {
protoParam.ValidationRegex = param.Validation[0].Regex
Expand Down
Loading