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

Skip to content

feat: Add form to modify managed Template variables #6257

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 26 commits into from
Mar 2, 2023
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
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
4 changes: 4 additions & 0 deletions site/src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ const StarterTemplatePage = lazy(
const CreateTemplatePage = lazy(
() => import("./pages/CreateTemplatePage/CreateTemplatePage"),
)
const TemplateVariablesPage = lazy(
() => import("./pages/TemplateVariablesPage/TemplateVariablesPage"),
)

export const AppRouter: FC = () => {
return (
Expand Down Expand Up @@ -160,6 +163,7 @@ export const AppRouter: FC = () => {

<Route path="workspace" element={<CreateWorkspacePage />} />
<Route path="settings" element={<TemplateSettingsPage />} />
<Route path="variables" element={<TemplateVariablesPage />} />
<Route path="versions">
<Route path=":version">
<Route index element={<TemplateVersionPage />} />
Expand Down
9 changes: 9 additions & 0 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ export const getTemplateVersionResources = async (
return response.data
}

export const getTemplateVersionVariables = async (
versionId: string,
): Promise<TypesGen.TemplateVersionVariable[]> => {
const response = await axios.get<TypesGen.TemplateVersionVariable[]>(
`/api/v2/templateversions/${versionId}/variables`,
)
return response.data
}

export const getTemplateVersions = async (
templateId: string,
): Promise<TypesGen.TemplateVersion[]> => {
Expand Down
16 changes: 16 additions & 0 deletions site/src/components/TemplateLayout/TemplatePageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Button from "@material-ui/core/Button"
import DeleteOutlined from "@material-ui/icons/DeleteOutlined"
import AddCircleOutline from "@material-ui/icons/AddCircleOutline"
import SettingsOutlined from "@material-ui/icons/SettingsOutlined"
import CodeOutlined from "@material-ui/icons/CodeOutlined"
import { AuthorizationResponse, Template } from "api/typesGenerated"
import { Avatar } from "components/Avatar/Avatar"
import { Maybe } from "components/Conditionals/Maybe"
Expand All @@ -19,6 +20,7 @@ import { Margins } from "components/Margins/Margins"

const Language = {
editButton: "Edit",
variablesButton: "Variables",
settingsButton: "Settings",
createButton: "Create workspace",
deleteButton: "Delete",
Expand All @@ -37,6 +39,19 @@ const TemplateSettingsButton: FC<{ templateName: string }> = ({
</Button>
)

const TemplateVariablesButton: FC<{ templateName: string }> = ({
templateName,
}) => (
<Button
variant="outlined"
component={RouterLink}
to={`/templates/${templateName}/variables`}
startIcon={<CodeOutlined />}
>
{Language.variablesButton}
</Button>
)

const CreateWorkspaceButton: FC<{
templateName: string
className?: string
Expand Down Expand Up @@ -80,6 +95,7 @@ export const TemplatePageHeader: FC<TemplatePageHeaderProps> = ({
onClick={deleteTemplate.openDeleteConfirmation}
/>
<TemplateSettingsButton templateName={template.name} />
<TemplateVariablesButton templateName={template.name} />
</Maybe>
<CreateWorkspaceButton templateName={template.name} />
</>
Expand Down
Loading