Thanks to visit codestin.com
Credit goes to github.com

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
Prepare to trigger API
  • Loading branch information
mtojek committed Mar 1, 2023
commit e945f3367ff903989ed303bb0120c69993fc824b
71 changes: 70 additions & 1 deletion coderd/apidoc/docs.go

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

59 changes: 58 additions & 1 deletion coderd/apidoc/swagger.json

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

2 changes: 1 addition & 1 deletion coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ func (api *API) patchActiveTemplateVersion(rw http.ResponseWriter, r *http.Reque
// @Produce json
// @Tags Templates
// @Param organization path string true "Organization ID" format(uuid)
// @Param request body codersdk.CreateTemplateVersionDryRunRequest true "Create template version request"
// @Param request body codersdk.CreateTemplateVersionRequest true "Create template version request"
// @Success 201 {object} codersdk.TemplateVersion
// @Router /organizations/{organization}/templateversions [post]
func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *http.Request) {
Expand Down
69 changes: 69 additions & 0 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,61 @@ CreateParameterRequest is a structure used to create a new parameter value for a
| `user_variable_values` | array of [codersdk.VariableValue](#codersdkvariablevalue) | false | | |
| `workspace_name` | string | false | | |

## codersdk.CreateTemplateVersionRequest

```json
{
"example_id": "string",
"file_id": "8a0cfb4f-ddc9-436d-91bb-75133c583767",
"name": "string",
"parameter_values": [
{
"copy_from_parameter": "000e07d6-021d-446c-be14-48a9c20bca0b",
"destination_scheme": "none",
"name": "string",
"source_scheme": "none",
"source_value": "string"
}
],
"provisioner": "terraform",
"storage_method": "file",
"tags": {
"property1": "string",
"property2": "string"
},
"template_id": "c6d67e98-83ea-49f0-8812-e4abae2b68bc",
"user_variable_values": [
{
"name": "string",
"value": "string"
}
]
}
```

### Properties

| Name | Type | Required | Restrictions | Description |
| ---------------------- | --------------------------------------------------------------------------- | -------- | ------------ | ---------------------------------------------------------------------------------------------------- |
| `example_id` | string | false | | |
| `file_id` | string | false | | |
| `name` | string | false | | |
| `parameter_values` | array of [codersdk.CreateParameterRequest](#codersdkcreateparameterrequest) | false | | Parameter values allows for additional parameters to be provided during the dry-run provision stage. |
| `provisioner` | string | true | | |
| `storage_method` | [codersdk.ProvisionerStorageMethod](#codersdkprovisionerstoragemethod) | true | | |
| `tags` | object | false | | |
| » `[any property]` | string | false | | |
| `template_id` | string | false | | Template ID optionally associates a version with a template. |
| `user_variable_values` | array of [codersdk.VariableValue](#codersdkvariablevalue) | false | | |

#### Enumerated Values

| Property | Value |
| ---------------- | ----------- |
| `provisioner` | `terraform` |
| `provisioner` | `echo` |
| `storage_method` | `file` |

## codersdk.CreateTestAuditLogRequest

```json
Expand Down Expand Up @@ -4059,6 +4114,20 @@ Parameter represents a set value for the scope.
| `canceled` |
| `failed` |

## codersdk.ProvisionerStorageMethod

```json
"file"
```

### Properties

#### Enumerated Values

| Value |
| ------ |
| `file` |

## codersdk.PutExtendWorkspaceRequest

```json
Expand Down
27 changes: 15 additions & 12 deletions docs/api/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ curl -X POST http://coder-server:8080/api/v2/organizations/{organization}/templa

```json
{
"example_id": "string",
"file_id": "8a0cfb4f-ddc9-436d-91bb-75133c583767",
"name": "string",
"parameter_values": [
{
"copy_from_parameter": "000e07d6-021d-446c-be14-48a9c20bca0b",
Expand All @@ -554,28 +557,28 @@ curl -X POST http://coder-server:8080/api/v2/organizations/{organization}/templa
"source_value": "string"
}
],
"rich_parameter_values": [
{
"name": "string",
"value": "string"
}
],
"provisioner": "terraform",
"storage_method": "file",
"tags": {
"property1": "string",
"property2": "string"
},
"template_id": "c6d67e98-83ea-49f0-8812-e4abae2b68bc",
"user_variable_values": [
{
"name": "string",
"value": "string"
}
],
"workspace_name": "string"
]
}
```

### Parameters

| Name | In | Type | Required | Description |
| -------------- | ---- | ---------------------------------------------------------------------------------------------------- | -------- | ------------------------------- |
| `organization` | path | string(uuid) | true | Organization ID |
| `body` | body | [codersdk.CreateTemplateVersionDryRunRequest](schemas.md#codersdkcreatetemplateversiondryrunrequest) | true | Create template version request |
| Name | In | Type | Required | Description |
| -------------- | ---- | ---------------------------------------------------------------------------------------- | -------- | ------------------------------- |
| `organization` | path | string(uuid) | true | Organization ID |
| `body` | body | [codersdk.CreateTemplateVersionRequest](schemas.md#codersdkcreatetemplateversionrequest) | true | Create template version request |

### Example responses

Expand Down
11 changes: 8 additions & 3 deletions site/src/pages/TemplateVariablesPage/TemplateVariablesForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const TemplateVariablesForm: FC<TemplateVariablesForm> = ({
template_id: templateVersion.template_id,
provisioner: "terraform",
storage_method: "file",
tags: {},
// FIXME file_id: null,
tags: templateVersion.job.tags,
file_id: templateVersion.job.file_id,
user_variable_values: initialUserVariableValues,
},
validationSchema: Yup.object({
Expand Down Expand Up @@ -144,7 +144,7 @@ export const selectInitialUserVariableValues = (
return defaults
}

export const ValidationSchemaForTemplateVariables = (
const ValidationSchemaForTemplateVariables = (
ns: string,
templateVariables: TemplateVersionVariable[],
): Yup.AnySchema => {
Expand All @@ -159,6 +159,11 @@ export const ValidationSchemaForTemplateVariables = (
const templateVariable = templateVariables.find(
(variable) => variable.name === name,
)
if (templateVariable && templateVariable.sensitive) {
// It's possible that the secret is already stored in database,
// so we can't properly verify the "required" condition.
return true
}
if (templateVariable && templateVariable.required) {
if (!val || val.length === 0) {
return ctx.createError({
Expand Down
Loading