Skip to content
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
8 changes: 8 additions & 0 deletions coderd/dynamicparameters/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ func tagValidationError(diags hcl.Diagnostics) *DiagnosticError {
}
}

func presetValidationError(diags hcl.Diagnostics) *DiagnosticError {
return &DiagnosticError{
Message: "Unable to validate presets",
Diagnostics: diags,
KeyedDiagnostics: make(map[string]hcl.Diagnostics),
}
}

type DiagnosticError struct {
// Message is the human-readable message that will be returned to the user.
Message string
Expand Down
28 changes: 28 additions & 0 deletions coderd/dynamicparameters/presets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dynamicparameters

import (
"github.com/hashicorp/hcl/v2"

"github.com/coder/preview"
)

// CheckPresets extracts the preset related diagnostics from a template version preset
func CheckPresets(output *preview.Output, diags hcl.Diagnostics) *DiagnosticError {
de := presetValidationError(diags)
if output == nil {
return de
}

presets := output.Presets
for _, preset := range presets {
if hcl.Diagnostics(preset.Diagnostics).HasErrors() {
de.Extend(preset.Name, hcl.Diagnostics(preset.Diagnostics))
}
}

if de.HasError() {
return de
}

return nil
}
4 changes: 4 additions & 0 deletions coderd/dynamicparameters/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (

func CheckTags(output *preview.Output, diags hcl.Diagnostics) *DiagnosticError {
de := tagValidationError(diags)
if output == nil {
return de
}

failedTags := output.WorkspaceTags.UnusableTags()
if len(failedTags) == 0 && !de.HasError() {
return nil // No errors, all is good!
Expand Down
8 changes: 8 additions & 0 deletions coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1822,6 +1822,14 @@ func (api *API) dynamicTemplateVersionTags(ctx context.Context, rw http.Response
return nil, false
}

// Fails early if presets are invalid to prevent downstream workspace creation errors
presetErr := dynamicparameters.CheckPresets(output, nil)
if presetErr != nil {
code, resp := presetErr.Response()
httpapi.Write(ctx, rw, code, resp)
return nil, false
}

return output.WorkspaceTags.Tags(), true
}

Expand Down
113 changes: 113 additions & 0 deletions coderd/templateversions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,119 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
})
}
})

t.Run("Presets", func(t *testing.T) {
t.Parallel()
store, ps := dbtestutil.NewDB(t)
client := coderdtest.New(t, &coderdtest.Options{
Database: store,
Pubsub: ps,
})
owner := coderdtest.CreateFirstUser(t, client)
templateAdmin, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID, rbac.RoleTemplateAdmin())

for _, tt := range []struct {
name string
files map[string]string
expectError string
}{
{
name: "valid preset",
files: map[string]string{
`main.tf`: `
terraform {
required_providers {
coder = {
source = "coder/coder"
version = "2.8.0"
}
}
}
data "coder_parameter" "valid_parameter" {
name = "valid_parameter_name"
default = "valid_option_value"
option {
name = "valid_option_name"
value = "valid_option_value"
}
}
data "coder_workspace_preset" "valid_preset" {
name = "valid_preset"
parameters = {
"valid_parameter_name" = "valid_option_value"
}
}
`,
},
},
{
name: "invalid preset",
files: map[string]string{
`main.tf`: `
terraform {
required_providers {
coder = {
source = "coder/coder"
version = "2.8.0"
}
}
}
data "coder_parameter" "valid_parameter" {
name = "valid_parameter_name"
default = "valid_option_value"
option {
name = "valid_option_name"
value = "valid_option_value"
}
}
data "coder_workspace_preset" "invalid_parameter_name" {
name = "invalid_parameter_name"
parameters = {
"invalid_parameter_name" = "irrelevant_value"
}
}
`,
},
expectError: "Undefined Parameter",
},
} {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitShort)

// Create an archive from the files provided in the test case.
tarFile := testutil.CreateTar(t, tt.files)

// Post the archive file
fi, err := templateAdmin.Upload(ctx, "application/x-tar", bytes.NewReader(tarFile))
require.NoError(t, err)

// Create a template version from the archive
tvName := testutil.GetRandomNameHyphenated(t)
tv, err := templateAdmin.CreateTemplateVersion(ctx, owner.OrganizationID, codersdk.CreateTemplateVersionRequest{
Name: tvName,
StorageMethod: codersdk.ProvisionerStorageMethodFile,
Provisioner: codersdk.ProvisionerTypeTerraform,
FileID: fi.ID,
})

if tt.expectError == "" {
require.NoError(t, err)
// Assert the expected provisioner job is created from the template version import
pj, err := store.GetProvisionerJobByID(ctx, tv.Job.ID)
require.NoError(t, err)
require.NotNil(t, pj)
// Also assert that we get the expected information back from the API endpoint
require.Zero(t, tv.MatchedProvisioners.Count)
require.Zero(t, tv.MatchedProvisioners.Available)
require.Zero(t, tv.MatchedProvisioners.MostRecentlySeen.Time)
} else {
require.ErrorContains(t, err, tt.expectError)
require.Equal(t, tv.Job.ID, uuid.Nil)
}
})
}
})
}

func TestPatchCancelTemplateVersion(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion docs/admin/monitoring/notifications/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ troubleshoot:
1. Review the logs. Search for the term `notifications` for diagnostic information.

- If you do not see any relevant logs, set
`CODER_VERBOSE=true` or `--verbose` to output debug logs.
`CODER_LOG_FILTER=".*notifications.*"` to filter for notification-related logs.
1. If you are on version 2.15.x, notifications must be enabled using the
`notifications`
[experiment](../../../install/releases/feature-stages.md#early-access-features).
Expand Down
3 changes: 1 addition & 2 deletions docs/admin/users/idp-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Visit the Coder UI to confirm these changes:
### Group allowlist

You can limit which groups from your identity provider can log in to Coder with
[CODER_OIDC_ALLOWED_GROUPS](https://coder.com/docs/cli/server#--oidc-allowed-groups).
[CODER_OIDC_ALLOWED_GROUPS](../../reference/cli/server.md#--oidc-allowed-groups).
Users who are not in a matching group will see the following error:

<Image height="412px" src="../../images/admin/group-allowlist.png" alt="Unauthorized group error" align="center" />
Expand Down Expand Up @@ -419,7 +419,6 @@ If you are running into issues with a sync:
1. To reduce noise, you can filter for only logs related to group/role sync:

```sh
CODER_VERBOSE=true
CODER_LOG_FILTER=".*userauth.*|.*groups returned.*"
```

Expand Down
2 changes: 1 addition & 1 deletion docs/admin/users/oidc-auth/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ claims from the ID token and the claims obtained from hitting the upstream
provider's `userinfo` endpoint, and use the resulting data as a basis for
creating a new user or looking up an existing user.

To troubleshoot claims, set `CODER_VERBOSE=true` and follow the logs while
To troubleshoot claims, set `CODER_LOG_FILTER=".*got oidc claims.*"` and follow the logs while
signing in via OIDC as a new user. Coder will log the claim fields returned by
the upstream identity provider in a message containing the string
`got oidc claims`, as well as the user info returned.
Expand Down
5 changes: 5 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@
"description": "Access your workspace with IDEs in the browser",
"path": "./user-guides/workspace-access/web-ides.md"
},
{
"title": "code-server",
"description": "Access your workspace with code-server",
"path": "./user-guides/workspace-access/code-server.md"
},
{
"title": "Zed",
"description": "Access your workspace with Zed",
Expand Down
29 changes: 29 additions & 0 deletions docs/user-guides/workspace-access/code-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# code-server

[code-server](https://github.com/coder/code-server) is our supported method of running VS Code in the web browser.

![code-server in a workspace](../../images/code-server-ide.png)

## Differences between code-server and VS Code Web

Some of the key differences between code-server and VS Code Web are:

| Feature | code-server | VS Code Web |
|--------------------------|-----------------------------------------------------------------------------|-------------------------------------------------------------------|
| Authentication | Optional login form | No built-in auth |
| Built-in proxy | Includes development proxy (not needed with Coder) | No built-in development proxy |
| Clipboard integration | Supports piping text from terminal (similar to `xclip`) | More limited |
| Display languages | Supports language pack extensions | Limited language support |
| File operations | Options to disable downloads and uploads | No built-in restrictions |
| Health endpoint | Provides `/healthz` endpoint | Limited health monitoring |
| Marketplace | Open VSX by default, configurable via flags/env vars | Uses Microsoft marketplace; modify `product.json` to use your own |
| Path-based routing | Has fixes for state collisions when used path-based | May have issues with path-based routing in certain configurations |
| Proposed API | Always enabled for all extensions | Only Microsoft extensions without configuration |
| Proxy integration | Integrates with Coder's proxy for ports panel | Integration is more limited |
| Sourcemaps | Loads locally | Uses CDN |
| Telemetry | Configurable endpoint | Does not allow a configurable endpoint |
| Terminal access to files | You can use a terminal outside of the integrated one to interact with files | Limited to integrated terminal access |
| User settings | Stored on remote disk | Stored in browser |
| Web views | Self-contained | Uses Microsoft CDN |

For more information about code-server, visit the [code-server FAQ](https://coder.com/docs/code-server/FAQ).
9 changes: 5 additions & 4 deletions docs/user-guides/workspace-access/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ Your workspace is now accessible via `ssh coder.<workspace_name>`
## Visual Studio Code

You can develop in your Coder workspace remotely with
[VSCode](https://code.visualstudio.com/download). We support connecting with the
desktop client and VSCode in the browser with [code-server](#code-server).
[VS Code](https://code.visualstudio.com/download).
We support connecting with the desktop client and VS Code in the browser with [code-server](#code-server).

![Demo](https://github.com/coder/vscode-coder/raw/main/demo.gif?raw=true)

Read more details on [using VSCode in your workspace](./vscode.md).
Read more details on [using VS Code in your workspace](./vscode.md).

## Cursor

Expand Down Expand Up @@ -118,7 +118,8 @@ on connecting your JetBrains IDEs.
## code-server

[code-server](https://github.com/coder/code-server) is our supported method of
running VS Code in the web browser. You can read more in our
running VS Code in the web browser.
Learn more about [what makes code-server different from VS Code web](./code-server.md) or visit the
[documentation for code-server](https://coder.com/docs/code-server/latest).

![code-server in a workspace](../../images/code-server-ide.png)
Expand Down
12 changes: 7 additions & 5 deletions docs/user-guides/workspace-access/vscode.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Visual Studio Code

You can develop in your Coder workspace remotely with
[VSCode](https://code.visualstudio.com/download). We support connecting with the
desktop client and VSCode in the browser with
[VS Code](https://code.visualstudio.com/download).
We support connecting with the desktop client and VS Code in the browser with
[code-server](https://github.com/coder/code-server).
Learn more about how VS Code Web and code-server compare in the
[code-server doc](./code-server.md).

## VSCode Desktop
## VS Code Desktop

VSCode desktop is a default app for workspaces.
VS Code desktop is a default app for workspaces.

Click `VS Code Desktop` in the dashboard to one-click enter a workspace. This
automatically installs the [Coder Remote](https://github.com/coder/vscode-coder)
Expand All @@ -21,7 +23,7 @@ extension, authenticates with Coder, and connects to the workspace.

### Manual Installation

You can install our extension manually in VSCode using the command palette.
You can install our extension manually in VS Code using the command palette.
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press
enter.

Expand Down
Loading
Loading