Skip to content

hotfix: Templates language [ch14098] #466

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 5 commits into from
Jul 6, 2021
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
18 changes: 9 additions & 9 deletions admin/templates.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
title: Templates
description: Learn how to manage your workspaces as code templates.
description: Learn how to manage your workspace templates.
---

The **Templates** tab features options that control the behavior of workspace
templates, which are the basis of [workspaces as code](../workspaces/workspaces-as-code/index.md).
The **Templates** tab features options that control the behavior of
[workspace templates](../workspaces/workspace-templates/index.md).

## Enabling workspaces as code
## Enabling workspace templates

By default, workspaces as code is an opt-in feature. The **Enable using
By default, workspace templates is an opt-in feature. The **Enable using
Workspace Templates** toggle allows you to enable or disable the creation of
[workspaces](../workspaces/index.md) using predefined templates located in Git
repositories.

To enable workspaces as code, go to **Admin > Templates** and set **Enable using
Workspace Templates** to **On**.
To enable workspace templates, go to **Admin > Templates** and set **Enable
using Workspace Templates** to **On**.

![Toggle workspaces as code](../assets/admin/wac_toggle.png)
![Toggle workspace templates](../assets/admin/wac_toggle.png)

## Template policy

Expand Down Expand Up @@ -82,7 +82,7 @@ defined by the template policy.

The **Embeddable Button** section features a form you can use for generating an
embeddable button. This button makes it easy for developers to use your
[workspace template](../workspaces/workspaces-as-code/index.md).
[workspace template](../workspaces/workspace-templates/index.md).

To create your button:

Expand Down
6 changes: 3 additions & 3 deletions changelog/1.17.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ There are no breaking changes in 1.17.2.

### Features ✨

- Workspaces as code (**WAC**): Workspaces as code (WAC) brings the
_infrastructure as code_ paradigm to Coder environments. WAC allows you to
define and create new environments using **workspace templates**.
- Workspace templates: Workspace templates brings the _infrastructure as code_
paradigm to Coder environments by allowing you to define and create new
environments using YAML templates.
- web: New page available via **Admin** > **Templates** for creating an
embeddable quickstart button.
- web: New options available when clicking **New Environment** from the
Expand Down
6 changes: 3 additions & 3 deletions changelog/1.17.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ description: "Released on 04/09/2021"

### Breaking changes ❗

- infra: Removed `tolerations` from workspaces as code templates.
- infra: Removed `tolerations` from workspace templates.

### Features ✨

- web: Added a toggle to enable/disable workspaces as code on the **Manage >
Admin > Templates** page. Disabling workspaces as code has the following
- web: Added a toggle to enable/disable workspace templates on the **Manage >
Admin > Templates** page. Disabling workspace templates has the following
impact:
- New workspaces cannot be created from a template.
- Existing workspaces built from a template will continue to operate and may
Expand Down
16 changes: 8 additions & 8 deletions changelog/1.18.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ description: "Released on 04/21/2021"

### Features ✨

- web: Added the ability to specify a workspaces as code template filepath other
than the default _coder.yaml_
- web: Added the ability to specify a workspace templates filepath other than
the default _coder.yaml_
- web: Moved _built-in_ sign-in behind a toggle so that it does not display when
OIDC is configured for authentication
- web: Updated color scheme on the sign-in page
- web: Added dev URL support in workspaces as code templates
- web: Added admin toggle for workspaces as code feature
- web: Added Bitbucket Server support for workspaces as code
- web: Added dev URL support in workspace templates
- web: Added admin toggle for workspace templates feature
- web: Added Bitbucket Server support for workspace templates
- infra: Added `CODER_WP_NAME` environment variable to workspaces
- cli: Added ability to cordon and uncordon workspace providers which will
allow/disallow new workspaces from being provisioned on a specific provider
- cli: Added ability to rename workspace providers
- web: Improved error notifications with additional details and resolutions.
Added _Tip_, _Error Type_, and enumerations for workspaces as code errors.
Added _Tip_, _Error Type_, and enumerations for workspace templates errors.
- infra: Added a background job to update templates
- web: Added a workspace status indicator in the **Switch Workspace** selector
- web: Added a tooltip with an error message for workspace status indicators
Expand All @@ -39,8 +39,8 @@ description: "Released on 04/21/2021"
**Open in Coder** buttons
- web: Fixed the inability to delete an empty organization while workspaces were
awaiting deletion in the background
- web: Improved error messages regarding attempts to import a workspaces as code
template from a repository using an SSH URI
- web: Improved error messages regarding attempts to import a workspace template
from a repository using an SSH URI
- infra: Fixed a bug that had allowed updates to be made to workspaces created
from local template

Expand Down
12 changes: 6 additions & 6 deletions changelog/1.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ description: "Released on 05/19/2021"
- infra: Workspace assets created by Coder that were previously located at
`/opt/coder`, such as code-server and coder-cli, have been moved to
`/var/tmp/coder`
- infra: Workspaces as code templates have been updated from version _0.1_ to
_0.2_. Existing workspaces using version _0.1_ templates can be rebuilt,
but no new workspaces can be created using the old format.
- web: The workspace as code _Open in Coder_ embeddable button flow no longer
- infra: Workspace templates have been updated from version _0.1_ to _0.2_.
Existing workspaces using version _0.1_ templates can be rebuilt, but no new
workspaces can be created using the old format.
- web: The workspace templates _Open in Coder_ embeddable button flow no longer
includes a _clone_ step; buttons created from prior versions will still work,
but Coder will not clone the project. To automate project cloning, use
[`workspace.configure.start`](../workspaces/workspaces-as-code/templates.md#workspaceconfigurestart)
- web: The embedded form for workspaces as code located at **Manage** >
[`workspace.configure.start`](../workspaces/workspace-templates/templates.md#workspaceconfigurestart)
- web: The embedded form for workspace templates located at **Manage** >
**Admin** > **Templates** no longer uses the following fields: **Project
Repository URL** and **Project Git Service**

Expand Down
4 changes: 2 additions & 2 deletions changelog/1.20.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ There are no breaking changes in 1.20.0.
the provided default.
- web: Added the `node-selector`, `tolerations`, and `annotations` fields to
workspace templates.
- other: Added a new JSON schema for writing Coder workspace as code templates
with code completion and syntax checking.
- other: Added a new JSON schema for writing Coder workspace templates with code
completion and syntax checking.
- web: Added a service banner that's displayed to all users of the system. The
message can be used with existing messages. It can be dismissed by each user
at any point and will not be shown again until there is a new message.
Expand Down
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
"path": "./workspaces/ssh.md"
},
{
"path": "./workspaces/workspaces-as-code/index.md",
"path": "./workspaces/workspace-templates/index.md",
"children": [
{
"path": "./workspaces/workspaces-as-code/templates.md"
"path": "./workspaces/workspace-templates/templates.md"
},
{
"path": "./workspaces/workspaces-as-code/code-completion.md"
"path": "./workspaces/workspace-templates/code-completion.md"
}
]
}
Expand Down
10 changes: 5 additions & 5 deletions workspaces/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ workspaces. Click the **New Environment** button and choose **Custom
Workspace**.

> To learn more about creating an environment from templates, see
> [Workspaces as code](workspaces-as-code/index.md).
> [Workspace templates](workspace-templates/index.md).

![Create a workspace](../assets/workspaces/create-workspace.png)

Expand All @@ -39,10 +39,10 @@ image, and runs custom configuration on startup. Learn about the

Coder provides advanced settings that allow you to customize your workspace.

If your Coder deployment has [container-based virtual machines
enabled](../admin/workspace-management/cvms.md), Coder creates your workspace as
a [CVMs](cvms.md) by default (you can opt-out of this setting by unchecking the
**Run as Container-based Virtual Machine** box).
If your Coder deployment has
[container-based virtual machines enabled](../admin/workspace-management/cvms.md),
Coder creates your workspace as a [CVM](cvms.md) by default (you can opt-out of
this setting by unchecking the **Run as Container-based Virtual Machine** box).

You can also specify the resources Coder should allocate.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: "Workspace template code completion"
description: "Learn how to use code completion when creating workspace templates."
description:
"Learn how to use code completion when creating workspace templates."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having this on two lines breaks the build

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier did this, not me. Hmm I'll check it out - currently running build based off of the suggestions before this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Prettier will do that so I just manually format all but the metadata (I'm sure there's a better way, but that's how I've been doing it :))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khorne3 - everything on the preview seems fine 😕

preview-1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stand corrected! Good to see this won't be a problem anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea me too. If it ended up causing a problem, I'd argue that it's something we'd have to consider filing upstream to prettier or addressing in our prettier config. Otherwise it implies that a code formatter (strictly formatting) is having an unintended output consequence. That kind of defeats the purpose of what prettier is supposed to be doing, though I imagine there are few edge cases where this has happened (ex: <pre> tags).

Great stuff though - hopefully this means everyone can just enable the prettier VS Code extension and trust ctrl + save :p - afterall, that's all I did!

state: alpha
---

Expand All @@ -9,8 +10,8 @@ that enables code completion and syntax checking.

## Requirements

You must have the [YAML extension by Red
Hat](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)
You must have the
[YAML extension by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)
installed to use this feature.

## How to use
Expand All @@ -33,8 +34,8 @@ Some keyboard shortcuts you may find helpful include:
- Document outlining (<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>O</kbd>)
- Auto completion (<kbd>Ctrl</kbd> + <kbd>Space</kbd>)

See the [YAML extension by Red Hat
docs](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)
See the
[YAML extension by Red Hat docs](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)
for additional shortcuts.

![Code Completion Demo](../../assets/wac-intellisense-demo.gif)
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
title: "Workspaces as code"
title: "Workspace templates"
description: "Learn how to describe workspace configuration as code."
state: alpha
---

Workspaces as code (WAC) brings the _infrastructure as code_ paradigm to Coder
workspaces. WAC allows you to define and create new workspaces using **workspace
templates**.
Workspace templates brings the _infrastructure as code_ paradigm to Coder
workspaces. Templates allow you to define and create new workspaces using YAML.

[Workspace templates](./templates.md) are declarative YAML files that describe
how to configure workspaces and their supporting infrastructure. Coder supports
Expand All @@ -21,7 +20,7 @@ files with either the `.yaml` or `.yml` extension.

We strongly recommend allowing the Git provider to run a webhook capable of
reaching the Coder server for immediate template updates. Otherwise, Coder will
update your WAC templates daily.
update your workspace templates daily.

## Creating a workspace template

Expand All @@ -33,7 +32,7 @@ in our [syntax guide](templates.md).
To create a new workspace using a template, go to **New Workspace** > **Create
from Template**.

![Create from template button](../../assets/workspaces/workspaces-as-code/create-from-template.png)
![Create from template button](../../assets/workspaces/workspace-templates/create-from-template.png)

When prompted, provide:

Expand All @@ -46,7 +45,7 @@ When prompted, provide:
will be `.coder/coder.yaml`, but if you choose a different path, provide it
here

![Create workspace from template](../../assets/workspaces/workspaces-as-code/wac-user-form.png)
![Create workspace from template](../../assets/workspaces/workspace-templates/wac-user-form.png)

## Adding an embeddable button

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ state: alpha
> supported. To update your workspace, you **must** update your templates to
> version _0.2_.

Workspaces as code (WAC) allows you to define and create new workspaces using
Workspace templates allows you to define and create new workspaces using
**workspace templates**.

Workspace templates are written in YAML and have a `.yaml` or `.yml` extension.
For assistance with creating your Coder YAML file, you can use the [template
intellisense](code-completion.md) feature.
For assistance with creating your Coder YAML file, you can use the
[template intellisense](code-completion.md) feature.

Coder looks for your workspace template at the following path:

```text
<repository-root>/.coder/<template-name>.yaml
```

![Template Location](../../assets/workspaces/workspaces-as-code/wac-location.png)
![Template Location](../../assets/workspaces/workspace-templates/wac-location.png)

## Workspace template sample

Expand Down Expand Up @@ -195,47 +195,47 @@ Determines whether the workspace should be created as a

#### workspace.specs.kubernetes.tolerations.value

Adds [Kubernetes
tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
Adds
[Kubernetes tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
to the workspace pod.

```yaml
tolerations:
value:
- key: example1
operator: Exists
value: value-1
effect: NoSchedule
tolerationSeconds: 200
- key: example-3
operator: Equal
value: value-2
effect: PreferNoSchedule
tolerationSeconds: 400
- key: example-3
value: value-3
effect: NoExecute
```
tolerations:
value:
- key: example1
operator: Exists
value: value-1
effect: NoSchedule
tolerationSeconds: 200
- key: example-3
operator: Equal
value: value-2
effect: PreferNoSchedule
tolerationSeconds: 400
- key: example-3
value: value-3
effect: NoExecute
```

`tolerations` is disabled by default and must be enabled by a site admin.

#### workspace.specs.kubernetes.node-selector.value

Adds [Kubernetes
NodeSelectors](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector)
Adds
[Kubernetes NodeSelectors](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector)
to the workspace pod. The value is a sequence of key/value pairs.

For example, the following snippet would add two `nodeSelectors` for Kubernetes:
`accelerator:nvidia` and `disktype:ssd`.

```yaml
node-selector:
value:
- key: accelerator
value: nvidia
- key: disktype
value: ssd
```
node-selector:
value:
- key: accelerator
value: nvidia
- key: disktype
value: ssd
```

`node-selector` is disabled by default and must be enabled by a site admin.

Expand Down