Compare commits

..

307 Commits

Author SHA1 Message Date
Stephen Kirby e6ec95757a Cherry-pick for release 2.25 (#19169)
Co-authored-by: Sas Swart <sas.swart.cdk@gmail.com>
Co-authored-by: Danielle Maywood <danielle@themaywoods.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ethan <39577870+ethanndickson@users.noreply.github.com>
Co-authored-by: Hugo Dutka <hugo@coder.com>
Co-authored-by: Thomas Kosiewski <tk@coder.com>
Co-authored-by: Cian Johnston <cian@coder.com>
2025-08-05 11:50:51 -05:00
gcp-cherry-pick-bot[bot] f1cf81c10b chore: add openai icon (cherry-pick #19118) (#19176)
Co-authored-by: ケイラ <mckayla@hey.com>
Co-authored-by: 35C4n0r <70096901+35C4n0r@users.noreply.github.com>
2025-08-05 12:17:53 +05:00
ケイラ 4bced62bf1 chore: add site/ CODEOWNERS (#19086) 2025-07-29 12:26:32 -06:00
Atif Ali 3a3972c44d chore: add catalog-info.yaml for backstage integration (#19085) 2025-07-29 22:56:53 +05:00
Asher 558e25d591 feat: support shift+enter in terminal (#19021)
It acts the same alt+enter, but is more familiar to users.

Closes #18864
2025-07-29 09:27:11 -08:00
Susana Ferreira 71738f6db9 feat(site): support icon and description in preset (#19063)
## Description

This PR updates the `CreateWorkspacePageView` to use the `Combobox`
React component instead of `SelectFilter` for the Preset selection.

## Changes

* Updated `CreateWorkspacePageView` to use the `Combobox` component in
place of `SelectFilter`.
* Modified the `Combobox` component to render preset icons using
`ExternalImage` instead of `Avatar`.

<img width="2172" height="1138" alt="Screenshot 2025-07-29 at 12 27 14"
src="https://github.com/user-attachments/assets/2ef8342f-7927-4430-bf87-bc93c47d2980"
/>

<img width="2176" height="1112" alt="Screenshot 2025-07-29 at 12 27 21"
src="https://github.com/user-attachments/assets/863089a6-dcfd-46ed-8b85-68838ee04f28"
/>

Follow-up from: https://github.com/coder/coder/pull/18977

---------

Co-authored-by: Jaayden Halko <jaayden.halko@gmail.com>
2025-07-29 17:45:32 +01:00
Danielle Maywood 219d1b4101 chore(agent/agentcontainers): skip part of test if on darwin (#19081) 2025-07-29 17:06:17 +01:00
Ethan 6147da58dd chore: add vpn-daemon run command for macos (#19080)
Continues to address https://github.com/coder/coder-desktop-macos/issues/201

Identical to the windows command, except we don't write to stdio. We're retaining the system we have for logging on macOS, where we push logs over the tunnel and use the OS logger. 

I've tested that a build with this command works end-to-end with my new version of Coder Desktop macOS.

Also brings in the soft net isolation changes from `main` of coder/tailscale.
2025-07-30 02:03:20 +10:00
Susana Ferreira 4e7331a9c4 feat(cli): support description in create and presets list CLI commands (#19079)
## Description

This PR improves the `coder templates presets` and `coder create` CLI
commands to include preset descriptions.

## Changes

* Added a `description` column to the `coder templates presets list` CLI
command.
* Fixed the `-o json` output for `coder templates presets list` to
correctly include and format data.
* Updated the `coder create` CLI command to display the preset's
description in the selection menu.

Follow-up from: 
* https://github.com/coder/coder/pull/18910 
* https://github.com/coder/coder/pull/18912
* https://github.com/coder/coder/pull/18977
2025-07-29 16:59:26 +01:00
Ethan 415273f648 ci: sign macos slim binaries on dogfood builds (#19077)
This will be necessary for future versions of Coder Desktop to connect to dogfood.
2025-07-30 01:22:16 +10:00
35C4n0r 0ef7720f8c feat: add tmux and gemini icons (#19031)
Related PRs: #246 #229

---------

Co-authored-by: DevCats <christofer@coder.com>
2025-07-29 19:49:17 +05:00
Cian Johnston 812d72c5bb fix: sanitize app status summary (#19075)
Fixes https://github.com/coder/coder/issues/18875
2025-07-29 15:24:11 +01:00
Jaayden Halko 29486f9d4e fix: fix e2e tests (#19076)
Closes https://github.com/coder/internal/issues/824
2025-07-29 10:23:57 -04:00
Hugo Dutka b666d52171 feat(codersdk/toolsdk): add MCP workspace bash background parameter (#19034)
Addresses coder/internal#820

---------

Signed-off-by: Thomas Kosiewski <tk@coder.com>
Co-authored-by: Thomas Kosiewski <tk@coder.com>
2025-07-29 16:20:02 +02:00
Dean Sheather bf78966256 chore: remove soft isolation configurability (#19069)
Undoes a lot of the changes in 5319d47dfa

Keeps the `netns.SetCoderSoftIsolation()` call, but always sets it to
`true` when using a TUN device.
2025-07-29 22:30:17 +10:00
Jaayden Halko 1320b8d5be feat: make dynamic parameters opt-in by default for new templates (#19006)
resolves #18975 

---------

Co-authored-by: Steven Masley <stevenmasley@gmail.com>
Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
2025-07-28 20:41:49 -05:00
Austen Bruhn faac75389b feat(helm): add pod-level securityContext support for certificate mounting (#19041)
**Add pod-level securityContext support to Coder Helm chart**

Adds `coder.podSecurityContext` field to enable pod-level security
settings, primarily to solve TLS certificate mounting permission issues.

**Problem**: When mounting TLS certificates from Kubernetes secrets, the
Coder process (UID 1000) cannot read the files due to restrictive
permissions.

**Solution**: Setting `podSecurityContext.fsGroup: 1000` ensures
Kubernetes sets group ownership of mounted volumes to GID 1000, allowing
the Coder process to read certificate files.

**Changes**:
- Added `podSecurityContext` field to values.yaml with documentation
- Updated `_coder.yaml` template to include pod-level security context
- Added test case and golden files
- Maintains backward compatibility (opt-in feature)

**Usage**:
```yaml
coder:
  podSecurityContext:
    fsGroup: 1000  # Enables TLS cert access
```

Fixes #19038
2025-07-28 20:41:32 -04:00
Andrew Aquino 72b8ab530e fix(docs): add missing GFM alert directives to blockquotes (#19042)
I just added support for rendering GFM alerts inside of numbered lists
in coder.com (see https://github.com/coder/coder.com/pull/328), and
noticed that these plain blockquotes should probably be alerts.

This should cover all the missing alerts. I found them by searching for
the regex `^\s*>\s` within docs/**/*.md

Is `[!NOTE]` the correct type for these? Or do we want to use
tip/important/etc?

- @mtojek CONTRIBUTING.md
- @johnstcn support-bundle.md
- @matifali gateway.md
2025-07-28 15:00:56 -07:00
Michael Suchacz 36d2e01471 chore: add managed ai usage consumption to license view (#18934)
Customers with licenses not supporting managed AI agents will receive
the following information:
<img width="597" height="261" alt="image"
src="https://github.com/user-attachments/assets/b794a9f2-bca8-494e-a8d1-cc6e6bc43bfe"
/>

Customers with active licenes for managed AI agents will see:
<img width="604" height="293" alt="image"
src="https://github.com/user-attachments/assets/7ce8931c-05c6-4e64-a5a1-2e9364e99de2"
/>

Closes https://github.com/coder/internal/issues/813

---------

Co-authored-by: McKayla Washburn <mckayla@hey.com>
2025-07-28 20:27:49 +02:00
Susana Ferreira 0672bf5084 feat: support icon and description in preset (#18977)
## Description 

This PR adds support for `description` and `icon` fields to
`template_version_presets`. These fields will allow displaying richer
information for presets in the UI, improving the user experience when
creating a workspace.
Both fields are optional, non-nullable, and default to empty strings.

## Changes

* Database migration with the addition of `description VARCHAR(128)` and
`icon VARCHAR(256)` columns to the `template_version_presets` table.
* Updated the `CreateWorkspacePageView` in the UI

Note: UI changes will be addressed in a separate PR
2025-07-28 15:02:26 +01:00
Jaayden Halko 58123e17ca fix: fix to display tooltip on hover (#19058) 2025-07-28 10:00:41 -04:00
Susana Ferreira b975d6d9b3 feat(cli): add CLI support for creating a workspace with preset (#18912)
## Description 

This PR introduces a `--preset` flag for the `create` command to allow
users to apply a predefined preset to their workspace build.

## Changes

- The `--preset` flag on the `create` command integrates with the
parameter resolution logic and takes precedence over other sources
(e.g., CLI/env vars, last build, etc.).
- Added internal logic to ensure that preset parameters override
parameters values during resolution.
- Updated tests and added new ones to cover these flows.

## Implementation logic

* If a template has presets and includes a default, the CLI will
automatically use the default when `--preset` is not specified.
* If a template has presets but no default, the CLI will prompt the user
to select one when `--preset` is not specified.
* If a template does not have presets, the CLI will not prompt the user
for a preset.
* If the user specifies a preset using the `--preset` flag, that preset
will be used.
* If the user passes `--preset None`, no preset will be applied.

This logic aligns with the behavior in the UI for consistency.

```
> coder create --help

USAGE:
  coder create [flags] [workspace]

  Create a workspace

    - Create a workspace for another user (if you have permission):

        $ coder create <username>/<workspace_name>

OPTIONS:
      (...)

      --preset string, $CODER_PRESET_NAME
          Specify the name of a template version preset. Use 'none' to explicitly indicate that no preset should be used.

      (...)

  -y, --yes bool
          Bypass prompts.
```

## Breaking change

**Note:** This is a breaking change to the create CLI command. If a
template includes presets and the user does not provide a `--preset`
flag, the CLI will now prompt the user to select one. This behavior may
break non-interactive scripts or automated workflows.


Relates to PR: https://github.com/coder/coder/pull/18910 - please
consider both PRs together as they’re part of the same workflow
Relates to issue: https://github.com/coder/coder/issues/16594
2025-07-28 14:46:04 +01:00
Danielle Maywood 66cf90c736 feat(agent/agentcontainers): allow auto start for discovered containers (#19040)
Closes https://github.com/coder/internal/issues/711

When a `devcontainer.json` has been found and it has `.customizations.coder.autoStart = true`, we will now auto start this dev container.
2025-07-28 12:30:52 +01:00
Thomas Kosiewski 398e80f003 feat: add timeout support to workspace bash tool (#19035)
# Add timeout support to workspace bash tool

This PR adds a timeout feature to the workspace bash tool, allowing
users to specify a maximum execution time for commands. Key changes
include:

- Added a `timeout_ms` parameter to control command execution time
(defaults to 60 seconds, with a maximum of 5 minutes)
- Implemented a new `executeCommandWithTimeout` function that properly
handles command timeouts
- Added proper output capturing during timeout scenarios, returning all
output collected before the timeout
- Updated documentation to explain the timeout feature and provide usage
examples
- Added comprehensive tests for the timeout functionality, including
integration tests

When a command times out, the tool now returns all captured output up to
that point along with a cancellation message, making it clear to users
what happened.

Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-07-28 11:25:43 +02:00
Thomas Kosiewski d1595781e1 fix: fix nil pointer dereference in ReportTask (#19045)
This pull request addresses a bug related to a nil pointer dereference
in the task reporting functionality.

### Bug Fixes and Error Handling:

* Updated `RegisterTools` in `mcp.go` to skip registering the
`ReportTask` tool in the remote MCP context when a task reporter is not
configured, preventing potential nil pointer dereference panics.
* Added a check in `toolsdk.go` to ensure task reporting dependencies
are available before invoking the reporter, returning an appropriate
error if not.

### Test Coverage:

* Added `TestReportTaskNilPointerDeref` in `toolsdk_test.go` to verify
that the system does not panic when task reporting dependencies are
missing and instead returns a clear error message.
* Added `TestReportTaskWithReporter` in `toolsdk_test.go` to validate
correct behavior when a task reporter is configured, ensuring the
handler processes the request as expected.

Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-07-28 11:23:29 +02:00
Cian Johnston 6bf2ec3eb1 chore: fix unbound variable in develop.sh (#19043)
Missed this in https://github.com/coder/coder/pull/18991
2025-07-28 09:20:35 +01:00
Dean Sheather 2a430ab435 fix: avoid duplicating logs on Coder Connect Windows (#19052)
The sinks are already added to the logger above, so they're just getting duplicated
2025-07-28 14:02:00 +10:00
dependabot[bot] 8d6cc51da9 chore: bump coder/code-server/coder from 1.3.0 to 1.3.1 in /dogfood/coder-envbuilder (#19050)
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)



[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/code-server/coder&package-manager=terraform&previous-version=1.3.0&new-version=1.3.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-28 00:32:41 +00:00
dependabot[bot] d0a7d84191 chore: bump coder/cursor/coder from 1.2.0 to 1.2.1 in /dogfood/coder (#19047)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/cursor/coder&package-manager=terraform&previous-version=1.2.0&new-version=1.2.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-28 00:32:32 +00:00
dependabot[bot] 10b8610045 chore: bump coder/code-server/coder from 1.3.0 to 1.3.1 in /dogfood/coder (#19049)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/code-server/coder&package-manager=terraform&previous-version=1.3.0&new-version=1.3.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-28 00:32:24 +00:00
dependabot[bot] 355dd9c119 chore: bump coder/vscode-web/coder from 1.3.0 to 1.3.1 in /dogfood/coder (#19048)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/vscode-web/coder&package-manager=terraform&previous-version=1.3.0&new-version=1.3.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-28 00:32:15 +00:00
dependabot[bot] c2a271ffda chore: bump coder/windsurf/coder from 1.1.0 to 1.1.1 in /dogfood/coder (#19046)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/windsurf/coder&package-manager=terraform&previous-version=1.1.0&new-version=1.1.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-28 00:32:08 +00:00
Steven Masley 38755e204d chore: remove actDef function, had no value (#19019) 2025-07-24 14:52:03 -05:00
Cian Johnston 9a05a8a28a feat: add preset selector in TasksPage (#19012)
* Adds a preset selector in TasksPage with the default preset pre-selected and at the top of the list.
* If no default preset exists, the user is prompted to select one.
* If a preset defines an AI Prompt, it will override the textarea.
2025-07-24 20:19:33 +01:00
ケイラ 5c31b983e5 chore: update logo in index.html (#19017) 2025-07-24 09:48:05 -06:00
Susana Ferreira 931b97caab feat(cli): add CLI support for listing presets (#18910)
## Description 

This PR introduces a new `list presets` command to display the presets
associated with a given template.
By default, it displays the presets for the template's active version,
unless a `--template-version` flag is provided.

## Changes

* Added a new `list presets` command under `coder templates presets` to
display presets associated with a template.
* By default, the command lists presets from the template’s active
version.
* Users can override the default behavior by providing the
`--template-version` flag to target a specific version.

```
> coder templates versions presets list --help

USAGE:
  coder templates presets list [flags] <template>

  List all presets of the specified template. Defaults to the active template version.

OPTIONS:
  -O, --org string, $CODER_ORGANIZATION
          Select which organization (uuid or name) to use.

  -c, --column [name|parameters|default|desired prebuild instances] (default: name,parameters,default,desired prebuild instances)
          Columns to display in table output.

  -o, --output table|json (default: table)
          Output format.

      --template-version string
          Specify a template version to list presets for. Defaults to the active version.
```

Related PR: https://github.com/coder/coder/pull/18912 - please consider
both PRs together as they’re part of the same workflow
Relates to issue: https://github.com/coder/coder/issues/16594

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added CLI commands to manage and list presets for specific template
versions, supporting tabular and JSON output.
* Introduced a new CLI subcommand group for template version presets,
including detailed help and documentation.
* Added support for displaying and managing the desired number of
prebuild instances for presets in CLI, API, and UI.

* **Documentation**
* Updated and expanded CLI and API documentation to describe new
commands, options, and the desired prebuild instances field in presets.
* Added new help output and reference files for template version presets
commands.

* **Bug Fixes**
* Ensured correct handling and display of the desired prebuild instances
property for presets across CLI, API, and UI.

* **Tests**
* Introduced end-to-end tests for listing template version presets,
covering scenarios with and without presets.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-24 16:44:36 +01:00
Susana Ferreira 070178c454 chore: bump github.com/coder/terraform-provider-coder/v2 from 2.8.0 to 2.9.0 (#19032)
Bumps
[github.com/coder/terraform-provider-coder/v2](https://github.com/coder/terraform-provider-coder)
from 2.8.0 to 2.9.0.

Release:
https://github.com/coder/terraform-provider-coder/releases/tag/v2.9.0
2025-07-24 12:17:21 +01:00
Danielle Maywood 25d70ce7bc fix(agent/agentcontainers): respect ignore files (#19016)
Closes https://github.com/coder/coder/issues/19011

We now use
[go-git](https://pkg.go.dev/github.com/go-git/go-git/v5@v5.16.2/plumbing/format/gitignore)'s
`gitignore` plumbing implementation to parse the `.gitignore` files and
match against the patterns generated. We use this to ignore any ignored
files in the git repository.

Unfortunately I've had to slightly re-implement some of the interface
exposed by `go-git` because they use `billy.Filesystem` instead of
`afero.Fs`.
2025-07-24 12:12:05 +01:00
Ethan 5c1bf1d46c test(coderd/database): use seperate context for subtests to fix flake (#19029)
Fixes flakes like https://github.com/coder/coder/actions/runs/16487670478/job/46615625141, caused by the issue described in https://coder.com/blog/go-testing-contexts-and-t-parallel

It'd be cool if we could lint for this? That a context from an outer test isn't used in a subtest if that subtest calls `t.Parallel`.
2025-07-24 20:07:54 +10:00
Dean Sheather 9a05b4679b chore: fix TestManagedAgentLimit flake (#19026)
Closes https://github.com/coder/internal/issues/812
2025-07-24 05:13:15 +00:00
Dean Sheather 5319d47dfa chore: add support for tailscale soft isolation in VPN (#19023) 2025-07-24 04:18:29 +00:00
blink-so[bot] 28789d7204 feat: add View Source button for template administrators in workspace creation (#18951) 2025-07-23 11:16:53 -06:00
Cian Johnston bb83071b5f chore: override codersdk.SessionTokenCookie in develop.sh (#18991)
Updates `develop.sh`, `coder-dev.sh` and `build_go.sh` to conditionally override `codersdk.SessionTokenCookie` for usage in nested development scenario.
2025-07-23 12:48:15 +01:00
Danielle Maywood f41275eb39 feat(agent/agentcontainers): auto detect dev containers (#18950)
Relates to https://github.com/coder/internal/issues/711

This PR implements a project discovery mechanism that searches for any
dev container projects and makes them visible in the UI so that they can
be started. To make the wording on the site more clear, "Rebuild" has
been changed to "Start" when there is no container associated with a
known dev container configuration. I've also made it so that site will
show the dev container config path when there is no other name
available.

### Design decisions

Just want to ensure my explanation for a few design decisions are noted
down:
- We only search for dev container configurations inside git
repositories
- We only search for these git repositories if they're at the top level
or a direct child of the agent directory.

This limited approach is to reduce the amount of files we ultimately
walk when trying to find these projects. It makes sense to limit it to
only the agent directory, although I'm open to expanding how deep we
search.
2025-07-22 19:02:43 +01:00
Thomas Kosiewski c6efe64a65 fix: handle nil writer in bash MCP tool (#18978)
- Refactors the bash tool to use `io.Discard` instead of nil to avoid panics.

- Enhances panic recovery in `codersdk/toolsdk/toolsdk.go` by adding stack trace information in development builds. When a panic occurs in a tool handler:
   - In development builds: The error includes the full stack trace for easier debugging
   - In production builds: A simpler error message is shown without the stack trace
2025-07-22 18:03:26 +02:00
Jaayden Halko dd2fb896eb fix: debounce slider to avoid laggy behavior (#18980)
resolves #18856 
resolves coder/internal#753
2025-07-22 11:15:43 -04:00
Steven Masley 99adb4a15b chore: update codeowners to include emyrk specific features (#18974) 2025-07-22 08:56:56 -05:00
Dean Sheather 62dc8310d1 fix: use httponly flag on coder_signed_app_token cookie (#18989) 2025-07-22 22:44:20 +10:00
Cian Johnston c4b69bbe63 fix: prioritise human-initiated builds over prebuilds (#18933)
Continues from https://github.com/coder/coder/pull/18882

- Reverts extraneous changes
- Adds explicit `ORDER BY initiator_id = $PREBUILDS_USER_ID` to
`AcquireProvisionerJob`
- Improves test added for above PR

---------

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>
2025-07-22 13:03:50 +01:00
Marcin Tojek e98dce7f99 fix: mute Claude API key warning if Bedrock in use (#18988)
Fixes: https://github.com/coder/coder/issues/17402
2025-07-22 13:56:20 +02:00
Kacper Sawicki 482463c51a feat: extend workspace build reasons to track connection types (#18827)
This PR introduces new build reason values to identify what type of
connection triggered a workspace build, helping to troubleshoot
workspace-related issues.

## Database Migration
Added migration 000349_extend_workspace_build_reason.up.sql that extends
the build_reason enum with new values:
```
dashboard, cli, ssh_connection, vscode_connection, jetbrains_connection
```

## Implementation
The build reason is specified through the API when creating new
workspace builds:

- Dashboard: Automatically sets reason to `dashboard` when users start
workspaces via the web interface
- CLI `start` command: Sets reason to `cli` when workspaces are started
via the command line
- CLI `ssh` command: Sets reason to ssh_connection when workspaces are
started due to SSH connections
- VS Code connections: Will be set to `vscode_connection` by the VS Code
extension through CLI hidden flag
(https://github.com/coder/vscode-coder/pull/550)
- JetBrains connections: Will be set to `jetbrains_connection` by the
Jetbrains Toolbox
(https://github.com/coder/coder-jetbrains-toolbox/pull/150) and
Jetbrains Gateway extension
(https://github.com/coder/jetbrains-coder/pull/561)

## UI Changes:
* Tooltip with reason in Build history
<img width="309" height="457" alt="image"
src="https://github.com/user-attachments/assets/bde8440b-bf3b-49a1-a244-ed7e8eb9763c"
/>

* Reason in Audit Logs Row tooltip
<img width="906" height="237" alt="image"
src="https://github.com/user-attachments/assets/ebbb62c7-cf07-4398-afbf-323c83fb6426"
/>

<img width="909" height="188" alt="image"
src="https://github.com/user-attachments/assets/1ddbab07-44bf-4dee-8867-b4e2cd56ae96"
/>
2025-07-22 13:11:27 +02:00
Dean Sheather 0ebd4356a0 fix: use system context for managed agent count query (#18985) 2025-07-22 06:03:35 +00:00
Dean Sheather 9a6dd73f68 feat: add managed agent license limit checks (#18937)
- Adds a query for counting managed agent workspace builds between two
timestamps
- The "Actual" field in the feature entitlement for managed agents is
now populated with the value read from the database
- The wsbuilder package now validates AI agent usage against the limit
when a license is installed

Closes coder/internal#777
2025-07-22 13:39:26 +10:00
blink-so[bot] aa1a985381 docs: update DX integration title from 'DX Data Cloud' to 'DX' (#18981)
Simplifies the title to reduce customer confusion as requested by
@kylejaggi.

The DX platform covers all products, not just Data Cloud. This change
makes the documentation clearer for customers who might get confused
about which DX product the integration refers to.

**Changes:**
- Updated page title from "DX Data Cloud" to "DX" in
`docs/admin/integrations/dx-data-cloud.md`

**Testing:**
- Verified the markdown renders correctly
- No functional changes, documentation-only update

---------

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: bpmct <22407953+bpmct@users.noreply.github.com>
2025-07-21 22:02:44 +00:00
ケイラ 19afeda98a feat: improve workspace upgrade flow when template parameters change (#18917) 2025-07-21 15:42:04 -06:00
Jaayden Halko d7b12535db chore: remove beta labels for dynamic parameters (#18976)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Style**
* Removed the "beta" badge from various workspace and template settings
pages. The "Dynamic parameters" feature no longer displays a beta label
in the interface.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-21 16:16:33 -04:00
Thomas Kosiewski 326c02459f feat: add workspace SSH execution tool for AI SDK (#18924)
# Add SSH Command Execution Tool for Coder Workspaces

This PR adds a new AI tool `coder_workspace_ssh_exec` that allows executing commands in Coder workspaces via SSH. The tool provides functionality similar to the `coder ssh <workspace> <command>` CLI command.

Key features:
- Executes commands in workspaces via SSH and returns the output and exit code
- Automatically starts workspaces if they're stopped
- Waits for the agent to be ready before executing commands
- Trims leading and trailing whitespace from command output
- Supports various workspace identifier formats:
  - `workspace` (uses current user)
  - `owner/workspace`
  - `owner--workspace`
  - `workspace.agent` (specific agent)
  - `owner/workspace.agent`

The implementation includes:
- A new tool definition with schema and handler
- Helper functions for workspace and agent discovery
- Workspace name normalization to handle different input formats
- Comprehensive test coverage including integration tests

This tool enables AI assistants to execute commands in user workspaces, making it possible to automate tasks and provide more interactive assistance.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Introduced the ability to execute bash commands inside a Coder workspace via SSH, supporting multiple workspace identification formats.
* **Tests**
  * Added comprehensive unit and integration tests for executing bash commands in workspaces, including input validation, output handling, and error scenarios.
* **Chores**
  * Registered the new bash execution tool in the global tools list.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-21 21:24:00 +02:00
blink-so[bot] 75c124013f fix: remove remaining v prefixes from all module versions in dogfood directory (#18971)
This PR completes the fix for Dependabot version prefix issues by
removing the remaining `v` prefixes that weren't caught in the previous
merge.

**Fixed modules:**

**dogfood/coder-envbuilder/main.tf:**
- slackme: `v1.0.30` → `1.0.30`
- dotfiles: `v1.2.0` → `1.2.0` 
- personalize: `v1.0.30` → `1.0.30`
- code-server: `v1.3.0` → `1.3.0`
- filebrowser: `v1.1.1` → `1.1.1`
- coder-login: `v1.0.30` → `1.0.30`

**dogfood/coder/main.tf:**
- dotfiles: `v1.2.0` → `1.2.0`
- git-clone: `v1.1.0` → `1.1.0`
- vscode-web: `v1.3.0` → `1.3.0`
- coder-login: `v1.0.30` → `1.0.30`
- cursor: `v1.2.0` → `1.2.0`

Now **all** modules in the dogfood directory use consistent version
formatting without the `v` prefix.

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
2025-07-21 13:45:04 -05:00
Thomas Kosiewski 1db096d8f9 chore: fix CodeRabbit config to disable review status (#18973)
Disable review status in CodeRabbit configuration

Change-Id: I0ee266e0b284832b65762a4f7a3f26d56af53e86
Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-07-21 20:26:01 +02:00
Steven Masley aedc019b4e feat: include template variables in dynamic parameter rendering (#18819)
Closes https://github.com/coder/coder/issues/18671

Template variables now loaded into dynamic parameters.
2025-07-21 13:02:31 -05:00
Jon Ayers 40a6367d4b chore: update CLAUDE.md to discourage time.Sleep (#18967) 2025-07-21 12:55:16 -04:00
blink-so[bot] 6d335910ea Update dogfood envbuilder template to use dev.registry.coder.com (#18968)
Updates the dogfood envbuilder template to pull modules from
`dev.registry.coder.com` instead of `registry.coder.com` to match the
regular dogfood template.

This ensures consistency between both dogfood templates and uses the
development registry for testing new module versions.

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
2025-07-21 16:51:05 +00:00
dependabot[bot] b181644930 chore: bump coder/coder-login/coder from 1.0.15 to v1.0.30 in /dogfood/coder-envbuilder (#18962)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/coder-login/coder&package-manager=terraform&previous-version=1.0.15&new-version=v1.0.30)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 16:32:01 +00:00
dependabot[bot] 1a3c1d0533 chore: bump coder/dotfiles/coder from 1.0.29 to v1.2.0 in /dogfood/coder-envbuilder (#18965)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/dotfiles/coder&package-manager=terraform&previous-version=1.0.29&new-version=v1.2.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 16:31:55 +00:00
dependabot[bot] 56c6b0f939 chore: bump coder/filebrowser/coder from 1.0.31 to v1.1.1 in /dogfood/coder-envbuilder (#18963)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/filebrowser/coder&package-manager=terraform&previous-version=1.0.31&new-version=v1.1.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 16:31:47 +00:00
dependabot[bot] 9d60acbfc3 chore: bump coder/code-server/coder from 1.2.0 to v1.3.0 in /dogfood/coder-envbuilder (#18960)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/code-server/coder&package-manager=terraform&previous-version=1.2.0&new-version=v1.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 16:27:18 +00:00
dependabot[bot] b05574ba53 chore: bump coder/windsurf/coder from 1.0.0 to 1.1.0 in /dogfood/coder (#18958)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/windsurf/coder&package-manager=terraform&previous-version=1.0.0&new-version=1.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 16:27:13 +00:00
dependabot[bot] 235bb5b279 chore: bump coder/personalize/coder from 1.0.2 to v1.0.30 in /dogfood/coder-envbuilder (#18959)
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)



[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/personalize/coder&package-manager=terraform&previous-version=1.0.2&new-version=v1.0.30)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 16:27:06 +00:00
dependabot[bot] 90eb5c3d6f chore: bump coder/slackme/coder from 1.0.2 to 1.0.30 in /dogfood/coder (#18956)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/slackme/coder&package-manager=terraform&previous-version=1.0.2&new-version=1.0.30)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 16:27:02 +00:00
dependabot[bot] 8c68961a1c chore: bump coder/slackme/coder from 1.0.2 to v1.0.30 in /dogfood/coder-envbuilder (#18961)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/slackme/coder&package-manager=terraform&previous-version=1.0.2&new-version=v1.0.30)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 16:26:56 +00:00
dependabot[bot] 847373aba1 chore: bump coder/personalize/coder from 1.0.2 to 1.0.30 in /dogfood/coder (#18957)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/personalize/coder&package-manager=terraform&previous-version=1.0.2&new-version=1.0.30)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 16:26:44 +00:00
ケイラ a9b110df68 chore: remove site/ CODEOWNERS entry (#18954) 2025-07-21 10:04:44 -06:00
dependabot[bot] e6b3b5900f chore: bump github.com/go-chi/chi/v5 from 5.1.0 to 5.2.2 (#18475) 2025-07-21 17:53:28 +02:00
Thomas Kosiewski 4ac6be6d83 chore: add CodeRabbit config with disabled auto-reviews (#18949) 2025-07-21 15:51:48 +01:00
dependabot[bot] b235f8cfeb chore: bump coder/git-clone/coder from 1.0.18 to v1.1.0 in /dogfood/coder (#18947)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/git-clone/coder&package-manager=terraform&previous-version=1.0.18&new-version=v1.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 14:40:23 +00:00
dependabot[bot] be672682f5 chore: bump coder/vscode-web/coder from 1.2.0 to v1.3.0 in /dogfood/coder (#18946)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/vscode-web/coder&package-manager=terraform&previous-version=1.2.0&new-version=v1.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 14:40:12 +00:00
dependabot[bot] d86dcdbb92 chore: bump coder/cursor/coder from 1.1.0 to v1.2.0 in /dogfood/coder (#18944)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/cursor/coder&package-manager=terraform&previous-version=1.1.0&new-version=v1.2.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 14:39:58 +00:00
dependabot[bot] dc5399d261 chore: bump coder/dotfiles/coder from 1.0.29 to v1.2.0 in /dogfood/coder (#18943)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/dotfiles/coder&package-manager=terraform&previous-version=1.0.29&new-version=v1.2.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 14:39:48 +00:00
dependabot[bot] 79f4d262a6 chore: bump coder/coder-login/coder from 1.0.15 to v1.0.30 in /dogfood/coder (#18945)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=coder/coder-login/coder&package-manager=terraform&previous-version=1.0.15&new-version=v1.0.30)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 14:39:42 +00:00
dependabot[bot] a10f25659c chore: bump google.golang.org/api from 0.241.0 to 0.242.0 (#18941)
Bumps
[google.golang.org/api](https://github.com/googleapis/google-api-go-client)
from 0.241.0 to 0.242.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/googleapis/google-api-go-client/releases">google.golang.org/api's
releases</a>.</em></p>
<blockquote>
<h2>v0.242.0</h2>
<h2><a
href="https://github.com/googleapis/google-api-go-client/compare/v0.241.0...v0.242.0">0.242.0</a>
(2025-07-16)</h2>
<h3>Features</h3>
<ul>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3226">#3226</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/9bd47c484b01476118eee059103a36373a6e560b">9bd47c4</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3228">#3228</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/2ee2e31870227ca989696c35f57be0b616a4fea2">2ee2e31</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3229">#3229</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/6fdc3ebb204a9a3275ccca159be884ec387848ac">6fdc3eb</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3230">#3230</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/d5fa61e954f9ccd53074a67b223a5af0a6446970">d5fa61e</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3231">#3231</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/96d4d98a3d73775fa606b8dbdc6f900287f335be">96d4d98</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3232">#3232</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/2ab275bbcb1a8c206099ca7b2e66bd5d0c0b9eac">2ab275b</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md">google.golang.org/api's
changelog</a>.</em></p>
<blockquote>
<h2><a
href="https://github.com/googleapis/google-api-go-client/compare/v0.241.0...v0.242.0">0.242.0</a>
(2025-07-16)</h2>
<h3>Features</h3>
<ul>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3226">#3226</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/9bd47c484b01476118eee059103a36373a6e560b">9bd47c4</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3228">#3228</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/2ee2e31870227ca989696c35f57be0b616a4fea2">2ee2e31</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3229">#3229</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/6fdc3ebb204a9a3275ccca159be884ec387848ac">6fdc3eb</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3230">#3230</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/d5fa61e954f9ccd53074a67b223a5af0a6446970">d5fa61e</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3231">#3231</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/96d4d98a3d73775fa606b8dbdc6f900287f335be">96d4d98</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3232">#3232</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/2ab275bbcb1a8c206099ca7b2e66bd5d0c0b9eac">2ab275b</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/16277b75e6b0b8146ea1f462a5f007b9f76fbe6b"><code>16277b7</code></a>
chore(main): release 0.242.0 (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3227">#3227</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/2ab275bbcb1a8c206099ca7b2e66bd5d0c0b9eac"><code>2ab275b</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3232">#3232</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/96d4d98a3d73775fa606b8dbdc6f900287f335be"><code>96d4d98</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3231">#3231</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/d5fa61e954f9ccd53074a67b223a5af0a6446970"><code>d5fa61e</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3230">#3230</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/6fdc3ebb204a9a3275ccca159be884ec387848ac"><code>6fdc3eb</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3229">#3229</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/2ee2e31870227ca989696c35f57be0b616a4fea2"><code>2ee2e31</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3228">#3228</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/9bd47c484b01476118eee059103a36373a6e560b"><code>9bd47c4</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3226">#3226</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/f1d0fc0610cf1185bb9a705b04bdd4e8a26c5963"><code>f1d0fc0</code></a>
test(transport): replaced deprecated grpc.WithInsecure code</li>
<li>See full diff in <a
href="https://github.com/googleapis/google-api-go-client/compare/v0.241.0...v0.242.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=google.golang.org/api&package-manager=go_modules&previous-version=0.241.0&new-version=0.242.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 14:33:16 +00:00
Cian Johnston 198d50dbc2 chore: replace original GetPrebuiltWorkspaces with optimized version (#18832)
Fixes https://github.com/coder/internal/issues/715

Follow-up from https://github.com/coder/coder/pull/18717

Now that we've determined the updated query is safe, remove the duplication.
2025-07-21 15:31:11 +01:00
dependabot[bot] af01562e35 chore: bump golang.org/x/tools from 0.34.0 to 0.35.0 in the x group (#18942)
Bumps the x group with 1 update:
[golang.org/x/tools](https://github.com/golang/tools).

Updates `golang.org/x/tools` from 0.34.0 to 0.35.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/tools/commit/50ec2f15fda46d8960c1d871856265127b4dcce5"><code>50ec2f1</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="https://github.com/golang/tools/commit/197c6c1b47160df25b9cd6598d88525c27a01e5a"><code>197c6c1</code></a>
gopls/internal/mcp: more tuning of tools and prompts</li>
<li><a
href="https://github.com/golang/tools/commit/9563af690255d5b5f7802773c0853f1176130da4"><code>9563af6</code></a>
gopls/internal/mcp: include module paths in workspace summaries</li>
<li><a
href="https://github.com/golang/tools/commit/88a4eb3018821e07f501b483e0f6f4eac4146198"><code>88a4eb3</code></a>
gopls/internal/cmd: wait for startup log in TestMCPCommandHTTP</li>
<li><a
href="https://github.com/golang/tools/commit/4738c7c0b1a53ae0c0fa248a8c31d2a07922dc9b"><code>4738c7c</code></a>
gopls/internal/cmd: avoid the use of channels in the sessions API</li>
<li><a
href="https://github.com/golang/tools/commit/ae1841752658d1d164b5926e72b2b0751fe5db17"><code>ae18417</code></a>
gopls/internal/filewatcher: skip test for unsupported OS</li>
<li><a
href="https://github.com/golang/tools/commit/8391b17713e95ac9bc23d8de7c0303b11c4a190b"><code>8391b17</code></a>
gopls/doc: document Zed editor</li>
<li><a
href="https://github.com/golang/tools/commit/778fe21d5d9f021763cced9defde671c6329d921"><code>778fe21</code></a>
gopls/internal/util/tokeninternal: move from internal/tokeninternal</li>
<li><a
href="https://github.com/golang/tools/commit/0343b7064dcefd5b28e53395fa70768990cc71fb"><code>0343b70</code></a>
internal/jsonrpc2/stack: move from internal/stack</li>
<li><a
href="https://github.com/golang/tools/commit/8c9f4cc0c2a00d508755a558cf73e0dab8d78863"><code>8c9f4cc</code></a>
gopls/internal/filewatcher: refactor filewatcher to pass in handler
func</li>
<li>Additional commits viewable in <a
href="https://github.com/golang/tools/compare/v0.34.0...v0.35.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/tools&package-manager=go_modules&previous-version=0.34.0&new-version=0.35.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 14:21:53 +00:00
dependabot[bot] e4c2099031 chore: bump github.com/valyala/fasthttp from 1.63.0 to 1.64.0 (#18940)
Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp)
from 1.63.0 to 1.64.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/valyala/fasthttp/releases">github.com/valyala/fasthttp's
releases</a>.</em></p>
<blockquote>
<h2>v1.64.0</h2>
<h2>⚠️ Deprecation warning! ⚠️</h2>
<p>In the next version of fasthttp headers delimited by just
<code>\n</code> (instead of <code>\r\n</code>) are no longer
supported!</p>
<h2>What's Changed</h2>
<ul>
<li>Add warning for deprecated newline separator by <a
href="https://github.com/erikdubbelboer"><code>@​erikdubbelboer</code></a>
in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2031">valyala/fasthttp#2031</a></li>
<li>refact: eliminate duplication in Request/Response via struct
embedding by <a
href="https://github.com/ksw2000"><code>@​ksw2000</code></a> in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2027">valyala/fasthttp#2027</a></li>
<li>chore(deps): bump golang.org/x/sys from 0.33.0 to 0.34.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2034">valyala/fasthttp#2034</a></li>
<li>chore(deps): bump golang.org/x/crypto from 0.39.0 to 0.40.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2036">valyala/fasthttp#2036</a></li>
<li>chore(deps): bump golang.org/x/net from 0.41.0 to 0.42.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2035">valyala/fasthttp#2035</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/valyala/fasthttp/compare/v1.63.0...v1.64.0">https://github.com/valyala/fasthttp/compare/v1.63.0...v1.64.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/valyala/fasthttp/commit/b1a54c8de5720d048bc2cc9aef47903bda171a9e"><code>b1a54c8</code></a>
chore(deps): bump golang.org/x/net from 0.41.0 to 0.42.0 (<a
href="https://redirect.github.com/valyala/fasthttp/issues/2035">#2035</a>)</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/7ac856f71f3b3f8a0df682af0d3d09c88bf0519b"><code>7ac856f</code></a>
chore(deps): bump golang.org/x/crypto from 0.39.0 to 0.40.0 (<a
href="https://redirect.github.com/valyala/fasthttp/issues/2036">#2036</a>)</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/2a917b661a90127b84796d80fc30d4e70845ecfa"><code>2a917b6</code></a>
chore(deps): bump golang.org/x/sys from 0.33.0 to 0.34.0 (<a
href="https://redirect.github.com/valyala/fasthttp/issues/2034">#2034</a>)</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/a3c9dab7573946aa0afcee62d94fbfb58e3c4c2c"><code>a3c9dab</code></a>
Add warning for deprecated newline separator (<a
href="https://redirect.github.com/valyala/fasthttp/issues/2031">#2031</a>)</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/eb1f908d9764ef1a355bab13ed83ce7cfc5e793e"><code>eb1f908</code></a>
refact: eliminate duplication in Request/Response via struct embedding
(<a
href="https://redirect.github.com/valyala/fasthttp/issues/2027">#2027</a>)</li>
<li>See full diff in <a
href="https://github.com/valyala/fasthttp/compare/v1.63.0...v1.64.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/valyala/fasthttp&package-manager=go_modules&previous-version=1.63.0&new-version=1.64.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 14:16:42 +00:00
dependabot[bot] 4c1a46150b chore: bump github.com/mark3labs/mcp-go from 0.33.0 to 0.34.0 (#18939)
Bumps [github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go)
from 0.33.0 to 0.34.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/mark3labs/mcp-go/releases">github.com/mark3labs/mcp-go's
releases</a>.</em></p>
<blockquote>
<h2>v0.34.0</h2>
<h2>What's Changed</h2>
<ul>
<li>fix(streamable_http): ensure graceful shutdown to prevent close
reque… by <a
href="https://github.com/sunerpy"><code>@​sunerpy</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/477">mark3labs/mcp-go#477</a></li>
<li>fix(streamble_http) SendNotification not work bug by <a
href="https://github.com/Robin-ZMH"><code>@​Robin-ZMH</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/473">mark3labs/mcp-go#473</a></li>
<li>refactor: replace fmt.Errorf with TransportError wrapper by <a
href="https://github.com/AdamShannag"><code>@​AdamShannag</code></a> in
<a
href="https://redirect.github.com/mark3labs/mcp-go/pull/486">mark3labs/mcp-go#486</a></li>
<li>fix <code>Content-Type: application/json; charset=utf-8</code> error
by <a href="https://github.com/oldweipro"><code>@​oldweipro</code></a>
in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/478">mark3labs/mcp-go#478</a></li>
<li>feat: Inprocess sampling support by <a
href="https://github.com/ezynda3"><code>@​ezynda3</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/487">mark3labs/mcp-go#487</a></li>
<li>feat: support in tool result handling &amp; update example by <a
href="https://github.com/CocaineCong"><code>@​CocaineCong</code></a> in
<a
href="https://redirect.github.com/mark3labs/mcp-go/pull/467">mark3labs/mcp-go#467</a></li>
<li>feat(logging): add support for send log message notifications and
implemented the <code>SessionWithLogging</code> interface on
<code>streamableHttpSession</code> by <a
href="https://github.com/sunerpy"><code>@​sunerpy</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/484">mark3labs/mcp-go#484</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/sunerpy"><code>@​sunerpy</code></a> made
their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/477">mark3labs/mcp-go#477</a></li>
<li><a href="https://github.com/Robin-ZMH"><code>@​Robin-ZMH</code></a>
made their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/473">mark3labs/mcp-go#473</a></li>
<li><a
href="https://github.com/AdamShannag"><code>@​AdamShannag</code></a>
made their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/486">mark3labs/mcp-go#486</a></li>
<li><a href="https://github.com/oldweipro"><code>@​oldweipro</code></a>
made their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/478">mark3labs/mcp-go#478</a></li>
<li><a
href="https://github.com/CocaineCong"><code>@​CocaineCong</code></a>
made their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/467">mark3labs/mcp-go#467</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/mark3labs/mcp-go/compare/v0.33.0...v0.34.0">https://github.com/mark3labs/mcp-go/compare/v0.33.0...v0.34.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/ffea75ff8133a2efec8ae549f0a5bc25cd27f8a4"><code>ffea75f</code></a>
feat(logging): add support for send log message notifications and
implemented...</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/e859847efc844f904dac49f8220cb5c911ffed91"><code>e859847</code></a>
feat: support in tool result handling &amp; update example (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/467">#467</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/9c352bd3f37f776d3390b22957da4ad114f114b1"><code>9c352bd</code></a>
feat: Inprocess sampling support (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/487">#487</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/78eb7a3c790dc7de26b9d61039a9527ef4022833"><code>78eb7a3</code></a>
fix <code>Content-Type: application/json; charset=utf-8</code> error (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/478">#478</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/c8c52a8c25536b4cdc1ad7725338a5b0d336f13f"><code>c8c52a8</code></a>
refactor: replace fmt.Errorf with TransportError wrapper (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/486">#486</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/65df1b095c8274f7cb0997fbd1a7bdbf12a2fc43"><code>65df1b0</code></a>
fix(streamble_http) SendNotification not work bug (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/473">#473</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/2d479bb4995a6279223c524f27ad94bf7e7a30cd"><code>2d479bb</code></a>
Merge pull request <a
href="https://redirect.github.com/mark3labs/mcp-go/issues/477">#477</a>
from sunerpy/main</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/bee9f90bab8622796cb7e9348acdaaebcc3cd7ed"><code>bee9f90</code></a>
fix(streamable_http): ensure graceful shutdown to prevent close request
errors</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/56f25011a0a97b4bb60e7742f017ce0ce098ae66"><code>56f2501</code></a>
fix quick-start</li>
<li>See full diff in <a
href="https://github.com/mark3labs/mcp-go/compare/v0.33.0...v0.34.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/mark3labs/mcp-go&package-manager=go_modules&previous-version=0.33.0&new-version=0.34.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 14:13:04 +00:00
dependabot[bot] 6b141d76de ci: bump the github-actions group with 6 updates (#18938)
Bumps the github-actions group with 6 updates:

| Package | From | To |
| --- | --- | --- |
|
[step-security/harden-runner](https://github.com/step-security/harden-runner)
| `2.12.2` | `2.13.0` |
|
[google-github-actions/auth](https://github.com/google-github-actions/auth)
| `2.1.10` | `2.1.11` |
|
[google-github-actions/setup-gcloud](https://github.com/google-github-actions/setup-gcloud)
| `2.1.4` | `2.1.5` |
|
[google-github-actions/get-gke-credentials](https://github.com/google-github-actions/get-gke-credentials)
| `2.3.3` | `2.3.4` |
| [github/codeql-action](https://github.com/github/codeql-action) |
`3.29.2` | `3.29.3` |
|
[umbrelladocs/action-linkspector](https://github.com/umbrelladocs/action-linkspector)
| `1.3.6` | `1.3.7` |

Updates `step-security/harden-runner` from 2.12.2 to 2.13.0
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/step-security/harden-runner/releases">step-security/harden-runner's
releases</a>.</em></p>
<blockquote>
<h2>v2.13.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Improved job markdown summary</li>
<li>Https monitoring for all domains (included with the enterprise
tier)</li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/step-security/harden-runner/compare/v2...v2.13.0">https://github.com/step-security/harden-runner/compare/v2...v2.13.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/step-security/harden-runner/commit/ec9f2d5744a09debf3a187a3f4f675c53b671911"><code>ec9f2d5</code></a>
Merge pull request <a
href="https://redirect.github.com/step-security/harden-runner/issues/565">#565</a>
from step-security/rc-24</li>
<li><a
href="https://github.com/step-security/harden-runner/commit/04bcbc31cfcefe0cf4720832008735021cec5ec4"><code>04bcbc3</code></a>
update agent</li>
<li><a
href="https://github.com/step-security/harden-runner/commit/7c7a56fcaa124ab72fff1cc3e81257f264fd7317"><code>7c7a56f</code></a>
feat: get job summary from API</li>
<li>See full diff in <a
href="https://github.com/step-security/harden-runner/compare/6c439dc8bdf85cadbbce9ed30d1c7b959517bc49...ec9f2d5744a09debf3a187a3f4f675c53b671911">compare
view</a></li>
</ul>
</details>
<br />

Updates `google-github-actions/auth` from 2.1.10 to 2.1.11
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/google-github-actions/auth/releases">google-github-actions/auth's
releases</a>.</em></p>
<blockquote>
<h2>v2.1.11</h2>
<h2>What's Changed</h2>
<ul>
<li>Update troubleshooting docs for Python by <a
href="https://github.com/sethvargo"><code>@​sethvargo</code></a> in <a
href="https://redirect.github.com/google-github-actions/auth/pull/488">google-github-actions/auth#488</a></li>
<li>Add linters by <a
href="https://github.com/sethvargo"><code>@​sethvargo</code></a> in <a
href="https://redirect.github.com/google-github-actions/auth/pull/499">google-github-actions/auth#499</a></li>
<li>Update deps by <a
href="https://github.com/sethvargo"><code>@​sethvargo</code></a> in <a
href="https://redirect.github.com/google-github-actions/auth/pull/500">google-github-actions/auth#500</a></li>
<li>Release: v2.1.11 by <a
href="https://github.com/google-github-actions-bot"><code>@​google-github-actions-bot</code></a>
in <a
href="https://redirect.github.com/google-github-actions/auth/pull/501">google-github-actions/auth#501</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/google-github-actions/auth/compare/v2.1.10...v2.1.11">https://github.com/google-github-actions/auth/compare/v2.1.10...v2.1.11</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/google-github-actions/auth/commit/140bb5113ffb6b65a7e9b937a81fa96cf5064462"><code>140bb51</code></a>
Release: v2.1.11 (<a
href="https://redirect.github.com/google-github-actions/auth/issues/501">#501</a>)</li>
<li><a
href="https://github.com/google-github-actions/auth/commit/ab3132e2ad698521ee1355566103fa838732e48c"><code>ab3132e</code></a>
Update deps (<a
href="https://redirect.github.com/google-github-actions/auth/issues/500">#500</a>)</li>
<li><a
href="https://github.com/google-github-actions/auth/commit/25b96bac992fdf64486c6fd3fd3d9c4cddb3a812"><code>25b96ba</code></a>
Add linters (<a
href="https://redirect.github.com/google-github-actions/auth/issues/499">#499</a>)</li>
<li><a
href="https://github.com/google-github-actions/auth/commit/0920706a19e9d22c3d0da43d1db5939c6ad837a8"><code>0920706</code></a>
Update troubleshooting docs for Python (<a
href="https://redirect.github.com/google-github-actions/auth/issues/488">#488</a>)</li>
<li>See full diff in <a
href="https://github.com/google-github-actions/auth/compare/ba79af03959ebeac9769e648f473a284504d9193...140bb5113ffb6b65a7e9b937a81fa96cf5064462">compare
view</a></li>
</ul>
</details>
<br />

Updates `google-github-actions/setup-gcloud` from 2.1.4 to 2.1.5
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/google-github-actions/setup-gcloud/releases">google-github-actions/setup-gcloud's
releases</a>.</em></p>
<blockquote>
<h2>v2.1.5</h2>
<h2>What's Changed</h2>
<ul>
<li>security: bump undici from 5.28.5 to 5.29.0 in the npm_and_yarn
group by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/google-github-actions/setup-gcloud/pull/711">google-github-actions/setup-gcloud#711</a></li>
<li>Update linters by <a
href="https://github.com/sethvargo"><code>@​sethvargo</code></a> in <a
href="https://redirect.github.com/google-github-actions/setup-gcloud/pull/715">google-github-actions/setup-gcloud#715</a></li>
<li>Update deps by <a
href="https://github.com/sethvargo"><code>@​sethvargo</code></a> in <a
href="https://redirect.github.com/google-github-actions/setup-gcloud/pull/716">google-github-actions/setup-gcloud#716</a></li>
<li>Release: v2.1.5 by <a
href="https://github.com/google-github-actions-bot"><code>@​google-github-actions-bot</code></a>
in <a
href="https://redirect.github.com/google-github-actions/setup-gcloud/pull/717">google-github-actions/setup-gcloud#717</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/google-github-actions/setup-gcloud/compare/v2.1.4...v2.1.5">https://github.com/google-github-actions/setup-gcloud/compare/v2.1.4...v2.1.5</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/google-github-actions/setup-gcloud/commit/6a7c903a70c8625ed6700fa299f5ddb4ca6022e9"><code>6a7c903</code></a>
Release: v2.1.5 (<a
href="https://redirect.github.com/google-github-actions/setup-gcloud/issues/717">#717</a>)</li>
<li><a
href="https://github.com/google-github-actions/setup-gcloud/commit/e838bc6edfe3907980c74d5aad506fd6e173b0d6"><code>e838bc6</code></a>
Update deps (<a
href="https://redirect.github.com/google-github-actions/setup-gcloud/issues/716">#716</a>)</li>
<li><a
href="https://github.com/google-github-actions/setup-gcloud/commit/98d8f78fcc2354c736499a506ad9e7be3f4c2640"><code>98d8f78</code></a>
Update linters (<a
href="https://redirect.github.com/google-github-actions/setup-gcloud/issues/715">#715</a>)</li>
<li><a
href="https://github.com/google-github-actions/setup-gcloud/commit/a8b58010a5b2a061afd605f50e88629c9ec7536b"><code>a8b5801</code></a>
security: bump undici from 5.28.5 to 5.29.0 in the npm_and_yarn group
(<a
href="https://redirect.github.com/google-github-actions/setup-gcloud/issues/711">#711</a>)</li>
<li>See full diff in <a
href="https://github.com/google-github-actions/setup-gcloud/compare/77e7a554d41e2ee56fc945c52dfd3f33d12def9a...6a7c903a70c8625ed6700fa299f5ddb4ca6022e9">compare
view</a></li>
</ul>
</details>
<br />

Updates `google-github-actions/get-gke-credentials` from 2.3.3 to 2.3.4
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/google-github-actions/get-gke-credentials/releases">google-github-actions/get-gke-credentials's
releases</a>.</em></p>
<blockquote>
<h2>v2.3.4</h2>
<h2>What's Changed</h2>
<ul>
<li>security: bump undici from 5.28.5 to 5.29.0 in the npm_and_yarn
group by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/google-github-actions/get-gke-credentials/pull/333">google-github-actions/get-gke-credentials#333</a></li>
<li>Update linters by <a
href="https://github.com/sethvargo"><code>@​sethvargo</code></a> in <a
href="https://redirect.github.com/google-github-actions/get-gke-credentials/pull/334">google-github-actions/get-gke-credentials#334</a></li>
<li>Update deps by <a
href="https://github.com/sethvargo"><code>@​sethvargo</code></a> in <a
href="https://redirect.github.com/google-github-actions/get-gke-credentials/pull/335">google-github-actions/get-gke-credentials#335</a></li>
<li>Release: v2.3.4 by <a
href="https://github.com/google-github-actions-bot"><code>@​google-github-actions-bot</code></a>
in <a
href="https://redirect.github.com/google-github-actions/get-gke-credentials/pull/336">google-github-actions/get-gke-credentials#336</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/google-github-actions/get-gke-credentials/compare/v2.3.3...v2.3.4">https://github.com/google-github-actions/get-gke-credentials/compare/v2.3.3...v2.3.4</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/google-github-actions/get-gke-credentials/commit/8e574c49425fa7efed1e74650a449bfa6a23308a"><code>8e574c4</code></a>
Release: v2.3.4 (<a
href="https://redirect.github.com/google-github-actions/get-gke-credentials/issues/336">#336</a>)</li>
<li><a
href="https://github.com/google-github-actions/get-gke-credentials/commit/820551c1d9b3734a98590d5020e3a479a3600019"><code>820551c</code></a>
Update deps (<a
href="https://redirect.github.com/google-github-actions/get-gke-credentials/issues/335">#335</a>)</li>
<li><a
href="https://github.com/google-github-actions/get-gke-credentials/commit/503071673e50fd4fe5973d69174dc780288d61e9"><code>5030716</code></a>
Update linters (<a
href="https://redirect.github.com/google-github-actions/get-gke-credentials/issues/334">#334</a>)</li>
<li><a
href="https://github.com/google-github-actions/get-gke-credentials/commit/36f99de330d5a168c801b87721b96719a0a9ada0"><code>36f99de</code></a>
security: bump undici from 5.28.5 to 5.29.0 in the npm_and_yarn group
(<a
href="https://redirect.github.com/google-github-actions/get-gke-credentials/issues/333">#333</a>)</li>
<li>See full diff in <a
href="https://github.com/google-github-actions/get-gke-credentials/compare/d0cee45012069b163a631894b98904a9e6723729...8e574c49425fa7efed1e74650a449bfa6a23308a">compare
view</a></li>
</ul>
</details>
<br />

Updates `github/codeql-action` from 3.29.2 to 3.29.3
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/github/codeql-action/releases">github/codeql-action's
releases</a>.</em></p>
<blockquote>
<h2>v3.29.3</h2>
<h1>CodeQL Action Changelog</h1>
<p>See the <a
href="https://github.com/github/codeql-action/releases">releases
page</a> for the relevant changes to the CodeQL CLI and language
packs.</p>
<h2>3.29.3 - 21 Jul 2025</h2>
<p>No user facing changes.</p>
<p>See the full <a
href="https://github.com/github/codeql-action/blob/v3.29.3/CHANGELOG.md">CHANGELOG.md</a>
for more information.</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/github/codeql-action/blob/main/CHANGELOG.md">github/codeql-action's
changelog</a>.</em></p>
<blockquote>
<h1>CodeQL Action Changelog</h1>
<p>See the <a
href="https://github.com/github/codeql-action/releases">releases
page</a> for the relevant changes to the CodeQL CLI and language
packs.</p>
<h2>[UNRELEASED]</h2>
<p>No user facing changes.</p>
<h2>3.29.3 - 21 Jul 2025</h2>
<p>No user facing changes.</p>
<h2>3.29.2 - 30 Jun 2025</h2>
<ul>
<li>Experimental: When the <code>quality-queries</code> input for the
<code>init</code> action is provided with an argument, separate
<code>.quality.sarif</code> files are produced and uploaded for each
language with the results of the specified queries. Do not use this in
production as it is part of an internal experiment and subject to change
at any time. <a
href="https://redirect.github.com/github/codeql-action/pull/2935">#2935</a></li>
</ul>
<h2>3.29.1 - 27 Jun 2025</h2>
<ul>
<li>Fix bug in PR analysis where user-provided <code>include</code>
query filter fails to exclude non-included queries. <a
href="https://redirect.github.com/github/codeql-action/pull/2938">#2938</a></li>
<li>Update default CodeQL bundle version to 2.22.1. <a
href="https://redirect.github.com/github/codeql-action/pull/2950">#2950</a></li>
</ul>
<h2>3.29.0 - 11 Jun 2025</h2>
<ul>
<li>Update default CodeQL bundle version to 2.22.0. <a
href="https://redirect.github.com/github/codeql-action/pull/2925">#2925</a></li>
<li>Bump minimum CodeQL bundle version to 2.16.6. <a
href="https://redirect.github.com/github/codeql-action/pull/2912">#2912</a></li>
</ul>
<h2>3.28.20 - 21 July 2025</h2>
<ul>
<li>Remove support for combining SARIF files from a single upload for
GHES 3.18, see <a
href="https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload/">the
changelog post</a>. <a
href="https://redirect.github.com/github/codeql-action/pull/2959">#2959</a></li>
</ul>
<h2>3.28.19 - 03 Jun 2025</h2>
<ul>
<li>The CodeQL Action no longer includes its own copy of the extractor
for the <code>actions</code> language, which is currently in public
preview.
The <code>actions</code> extractor has been included in the CodeQL CLI
since v2.20.6. If your workflow has enabled the <code>actions</code>
language <em>and</em> you have pinned
your <code>tools:</code> property to a specific version of the CodeQL
CLI earlier than v2.20.6, you will need to update to at least CodeQL
v2.20.6 or disable
<code>actions</code> analysis.</li>
<li>Update default CodeQL bundle version to 2.21.4. <a
href="https://redirect.github.com/github/codeql-action/pull/2910">#2910</a></li>
</ul>
<h2>3.28.18 - 16 May 2025</h2>
<ul>
<li>Update default CodeQL bundle version to 2.21.3. <a
href="https://redirect.github.com/github/codeql-action/pull/2893">#2893</a></li>
<li>Skip validating SARIF produced by CodeQL for improved performance.
<a
href="https://redirect.github.com/github/codeql-action/pull/2894">#2894</a></li>
<li>The number of threads and amount of RAM used by CodeQL can now be
set via the <code>CODEQL_THREADS</code> and <code>CODEQL_RAM</code>
runner environment variables. If set, these environment variables
override the <code>threads</code> and <code>ram</code> inputs
respectively. <a
href="https://redirect.github.com/github/codeql-action/pull/2891">#2891</a></li>
</ul>
<h2>3.28.17 - 02 May 2025</h2>
<ul>
<li>Update default CodeQL bundle version to 2.21.2. <a
href="https://redirect.github.com/github/codeql-action/pull/2872">#2872</a></li>
</ul>
<h2>3.28.16 - 23 Apr 2025</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/github/codeql-action/commit/d6bbdef45e766d081b84a2def353b0055f728d3e"><code>d6bbdef</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/2977">#2977</a>
from github/update-v3.29.3-7710ed11e</li>
<li><a
href="https://github.com/github/codeql-action/commit/210cc9bfa2103f4b7c4701ee383183b944c62578"><code>210cc9b</code></a>
Update changelog for v3.29.3</li>
<li><a
href="https://github.com/github/codeql-action/commit/7710ed11e398ea99c7f7004c2b2e0f580458db42"><code>7710ed1</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/2970">#2970</a>
from github/cklin/diff-informed-feature-enable</li>
<li><a
href="https://github.com/github/codeql-action/commit/6a49a8cbce6ecbd74ea251a48dbc84e64ce3be4d"><code>6a49a8c</code></a>
build: refresh js files</li>
<li><a
href="https://github.com/github/codeql-action/commit/3aef4108d1730e17b6fd24f8b9c49d8fcc87d46d"><code>3aef410</code></a>
Add diff-informed-analysis-utils.test.ts</li>
<li><a
href="https://github.com/github/codeql-action/commit/614b64c6ec97a4ad54f7c99c5becbf593144dbfb"><code>614b64c</code></a>
Diff-informed analysis: disable for GHES below 3.19</li>
<li><a
href="https://github.com/github/codeql-action/commit/aefb854fe5563f4650638224c839c6e9b33c25b5"><code>aefb854</code></a>
Feature.DiffInformedQueries: default to true</li>
<li><a
href="https://github.com/github/codeql-action/commit/03a2a17e75d20e4ff461b43f161fb2b52165f632"><code>03a2a17</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/2967">#2967</a>
from github/cklin/overlay-feature-flags</li>
<li><a
href="https://github.com/github/codeql-action/commit/07455ed3c36f739ad76d1c4e55f8b49550f74344"><code>07455ed</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/2972">#2972</a>
from github/koesie10/ghes-satisfies</li>
<li><a
href="https://github.com/github/codeql-action/commit/3fb562ddcce3ca92b83ea1bb7abaa579a1ab882d"><code>3fb562d</code></a>
build: refresh js files</li>
<li>Additional commits viewable in <a
href="https://github.com/github/codeql-action/compare/181d5eefc20863364f96762470ba6f862bdef56b...d6bbdef45e766d081b84a2def353b0055f728d3e">compare
view</a></li>
</ul>
</details>
<br />

Updates `umbrelladocs/action-linkspector` from 1.3.6 to 1.3.7
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/umbrelladocs/action-linkspector/releases">umbrelladocs/action-linkspector's
releases</a>.</em></p>
<blockquote>
<h2>Release v1.3.7</h2>
<p>v1.3.7: PR <a
href="https://redirect.github.com/umbrelladocs/action-linkspector/issues/47">#47</a>
- Update linkspector version to 0.4.7</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/UmbrellaDocs/action-linkspector/commit/874d01cae9fd488e3077b08952093235bd626977"><code>874d01c</code></a>
Merge pull request <a
href="https://redirect.github.com/umbrelladocs/action-linkspector/issues/47">#47</a>
from UmbrellaDocs/update-linkspector-version</li>
<li><a
href="https://github.com/UmbrellaDocs/action-linkspector/commit/bfc5bc55f5a8fc268165639b78b3ce6ae64915ad"><code>bfc5bc5</code></a>
Update linkspector version to 0.4.7</li>
<li>See full diff in <a
href="https://github.com/umbrelladocs/action-linkspector/compare/3a951c1f0dca72300c2320d0eb39c2bafe429ab1...874d01cae9fd488e3077b08952093235bd626977">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 13:21:37 +00:00
Hugo Dutka ceb4b973b4 chore: run full macos and windows pg tests in the nightly gauntlet (#18787)
This PR starts running the full test suite on Windows and macOS in the
nightly gauntlet, since the regular CI only runs agent and cli tests.
The full suite is too slow to be run on every PR.
2025-07-21 15:18:49 +02:00
Danielle Maywood f751f81052 fix(coderd): fix flake in TestAPI/ModifyAutostopWithRunningWorkspace (#18932)
Fixes https://github.com/coder/internal/issues/521

This happened due to a race condition present in how
`AwaitWorkspaceBuildJobCompleted` works.

`AwaitWorkspaceBuildJobCompleted` works by waiting until
`/api/v2/workspacesbuilds/{workspacebuild}/` returns a workspace build
with `.Job.CompletedAt != nil`. The issue here is that _sometimes_ the
returned `codersdk.WorkspaceBuild` can contain a build from _before_ a
provisioner job completed, but contain the provisioner job from _after_
it completed.

Let me demonstrate:

Here we query the database for `database.WorkspaceBuild`.

https://github.com/coder/coder/blob/a3f64f74f794c733126ad21cd1feb0801caf67c4/coderd/coderd.go#L1409-L1415

Inside of the `workspaceBuild` route handler, we call
`workspaceBuildsData`

https://github.com/coder/coder/blob/a3f64f74f794c733126ad21cd1feb0801caf67c4/coderd/workspacebuilds.go#L54

This then calls `GetProvisionerJobsByIDsWithQueuePosition`

https://github.com/coder/coder/blob/a3f64f74f794c733126ad21cd1feb0801caf67c4/coderd/workspacebuilds.go#L852-L856

As these two calls happen _outside of a transaction_, the state of the
world can change underneath. This can result in an in-progress workspace
build having a completed provisioner job attached to it.
2025-07-21 13:04:28 +01:00
Thomas Kosiewski 0d3b7703f7 docs: remove dbmem references from documentation files (#18861)
Change-Id: Ic33bc383d00d0e354c25a0dd6080a4307d9862b6
Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-07-21 11:21:58 +02:00
dependabot[bot] 7c66dcd238 chore: bump terraform-google-modules/container-vm/google from 3.0.0 to 3.2.0 in /examples/templates/gcp-vm-container (#18925)
Bumps
[terraform-google-modules/container-vm/google](https://github.com/terraform-google-modules/terraform-google-container-vm)
from 3.0.0 to 3.2.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/releases">terraform-google-modules/container-vm/google's
releases</a>.</em></p>
<blockquote>
<h2>v3.2.0</h2>
<h2><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/compare/v3.1.1...v3.2.0">3.2.0</a>
(2024-08-29)</h2>
<h3>Features</h3>
<ul>
<li><strong>deps:</strong> Update Terraform Google Provider to v6
(major) (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/138">#138</a>)
(<a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/b8065338e38b51230f06aec573a2f8027c30c566">b806533</a>)</li>
</ul>
<h2>v3.1.1</h2>
<h2><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/compare/v3.1.0...v3.1.1">3.1.1</a>
(2024-01-08)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deps:</strong> lint updates for cft/developer-tools v1.18
(<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/123">#123</a>)
(<a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/2d57bef2f9ff75f5ca0a0b7f5d21985b823be1a6">2d57bef</a>)</li>
<li>upgraded versions.tf to include minor bumps from tpg v5 (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/118">#118</a>)
(<a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/14fcdf3463b254098a5bc4a6e01003b3eee2d75c">14fcdf3</a>)</li>
</ul>
<h2>v3.1.0</h2>
<h2><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/compare/v3.0.1...v3.1.0">3.1.0</a>
(2022-09-19)</h2>
<h3>Features</h3>
<ul>
<li>expose cos_project variable (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/91">#91</a>)
(<a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/b32263d30cf2a61d20ddbca94733bf3abfb7a446">b32263d</a>)</li>
</ul>
<h2>v3.0.1</h2>
<h2><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/compare/v3.0.0...v3.0.1">3.0.1</a>
(2022-07-20)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>restart policy kills konlet-startup container fix for the value
Never (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/87">#87</a>)
(<a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/fcbdafa2d5b00792c388dcda1e1715f5e2a615e6">fcbdafa</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/blob/main/CHANGELOG.md">terraform-google-modules/container-vm/google's
changelog</a>.</em></p>
<blockquote>
<h2><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/compare/v3.1.1...v3.2.0">3.2.0</a>
(2024-08-29)</h2>
<h3>Features</h3>
<ul>
<li><strong>deps:</strong> Update Terraform Google Provider to v6
(major) (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/138">#138</a>)
(<a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/b8065338e38b51230f06aec573a2f8027c30c566">b806533</a>)</li>
</ul>
<h2><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/compare/v3.1.0...v3.1.1">3.1.1</a>
(2024-01-08)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deps:</strong> lint updates for cft/developer-tools v1.18
(<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/123">#123</a>)
(<a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/2d57bef2f9ff75f5ca0a0b7f5d21985b823be1a6">2d57bef</a>)</li>
<li>upgraded versions.tf to include minor bumps from tpg v5 (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/118">#118</a>)
(<a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/14fcdf3463b254098a5bc4a6e01003b3eee2d75c">14fcdf3</a>)</li>
</ul>
<h2><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/compare/v3.0.1...v3.1.0">3.1.0</a>
(2022-09-19)</h2>
<h3>Features</h3>
<ul>
<li>expose cos_project variable (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/91">#91</a>)
(<a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/b32263d30cf2a61d20ddbca94733bf3abfb7a446">b32263d</a>)</li>
</ul>
<h2><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/compare/v3.0.0...v3.0.1">3.0.1</a>
(2022-07-20)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>restart policy kills konlet-startup container fix for the value
Never (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/87">#87</a>)
(<a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/fcbdafa2d5b00792c388dcda1e1715f5e2a615e6">fcbdafa</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/ceba2c777b5fbdc74debcbad63b02f94b6abcb60"><code>ceba2c7</code></a>
chore(master): release 3.2.0 (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/139">#139</a>)</li>
<li><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/b8065338e38b51230f06aec573a2f8027c30c566"><code>b806533</code></a>
feat(deps): Update Terraform Google Provider to v6 (major) (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/138">#138</a>)</li>
<li><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/b9c7fdd2cd0bd09942440ac372fdee47bde57db9"><code>b9c7fdd</code></a>
chore(deps): Update cft/developer-tools Docker tag to v1.22 (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/136">#136</a>)</li>
<li><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/5efa4d20a97b4b30c4392bbf5d788e65f0dd51c7"><code>5efa4d2</code></a>
chore(deps): Update cft/developer-tools Docker tag to v1.21 (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/131">#131</a>)</li>
<li><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/d9045637650a82354f11b4d170b96f20b2a00167"><code>d904563</code></a>
chore(deps): Update Terraform
terraform-google-modules/project-factory/google...</li>
<li><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/30b7909f74ef3228daac07c771366e910059e9f5"><code>30b7909</code></a>
chore(deps): Update Terraform terraform-google-modules/vm/google to v11
(<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/129">#129</a>)</li>
<li><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/5dc397e54a63e9ae63bc165a80e35b2a18ff6d99"><code>5dc397e</code></a>
chore(deps): Update cft/developer-tools Docker tag to v1.19 (<a
href="https://redirect.github.com/terraform-google-modules/terraform-google-container-vm/issues/128">#128</a>)</li>
<li><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/aefea73c5602277b4876e3b0d14f7aaa90151bcc"><code>aefea73</code></a>
chore: update .github/workflows/lint.yaml</li>
<li><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/924324901e4219d7e4d72d8168b2f90dbc1d923b"><code>9243249</code></a>
chore: update CODEOWNERS</li>
<li><a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/commit/8361f4d105e415b166c1ddcbcc080ff31360058b"><code>8361f4d</code></a>
chore: update .github/workflows/stale.yml</li>
<li>Additional commits viewable in <a
href="https://github.com/terraform-google-modules/terraform-google-container-vm/compare/v3.0.0...v3.2.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=terraform-google-modules/container-vm/google&package-manager=terraform&previous-version=3.0.0&new-version=3.2.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-21 09:05:33 +00:00
Thomas Kosiewski fcd361d374 feat: add logo SVG and replace inline SVG with image reference (#18930)
# Replace SVG with external logo file in OAuth2 authorization page

This PR replaces the inline SVG logo in the OAuth2 authorization page with a reference to an external SVG file. The change:

1. Adds a new `logo.svg` file in the static directory with the Coder logo
2. Updates the OAuth2 authorization page to use this external file instead of embedding the SVG directly

This approach improves maintainability by centralizing the logo in a single file and reduces duplication in the codebase.
2025-07-21 11:04:21 +02:00
blink-so[bot] f3c1353322 docs: fix typo 'protyping' to 'prototyping' in AI Coding Agents page (#18928)
Fixes #18926

Simple typo fix: changed 'protyping' to 'prototyping' in the AI Coding
Agents documentation page.

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: bpmct <22407953+bpmct@users.noreply.github.com>
2025-07-20 20:16:19 +00:00
Thomas Kosiewski 7b06fc77ae refactor: simplify OAuth2 authorization flow and use 302 redirects (#18923)
# Refactor OAuth2 Provider Authorization Flow

This PR refactors the OAuth2 provider authorization flow by:

1. Removing the `authorizeMW` middleware and directly implementing its functionality in the `ShowAuthorizePage` handler
2. Simplifying function signatures by removing unnecessary parameters:
   - Removed `db` parameter from `ShowAuthorizePage`
   - Removed `accessURL` parameter from `ProcessAuthorize`
3. Changing the redirect status code in `ProcessAuthorize` from 307 (Temporary Redirect) to 302 (Found) to improve compatibility with external OAuth2 apps and browsers. (Technical explanation: we replied with a 307 to a POST request, thus the browser performs a redirect to that URL as a POST request, but we need it to be a GET request to be compatible. Thus, we use the 302 redirect so that browsers turn it into a GET request when redirecting back to the redirect_uri.)

The changes maintain the same functionality while simplifying the code and improving compatibility with external systems.
2025-07-20 16:22:52 +02:00
Thomas Kosiewski 071383bbe8 feat: add RFC 9728 OAuth2 resource metadata support (#18920)
# Enhanced OAuth2 and MCP Compliance for API Authentication

This PR improves OAuth2 and MCP (Microsoft Cloud for Sovereignty)
compliance by:

1. Adding RFC 9728 compliant `WWW-Authenticate` headers with resource
metadata URLs
2. Passing the configured `AccessURL` to API key middleware for proper
audience validation
3. Creating specialized CORS handling for OAuth2 and MCP endpoints with
appropriate headers
4. Making the `state` parameter optional in OAuth2 authorization
requests

These changes ensure proper OAuth2 token audience validation against the
configured access URL and improve interoperability with OAuth2 clients
by providing better error responses and metadata discovery.

Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-07-19 22:05:15 +02:00
Michael Smith f47efc62ee fix(site): speed up state syncs and validate input for debounce hook logic (#18877)
No issue to link – I'm basically pushing some updates upstream from the
version of the hook I copied over for the Registry website.

## Changes made
- Updated debounce functions to have input validation for timeouts
- Updated `useDebouncedValue` to flush state syncs immediately if
timeout value is `0`
- Updated tests to reflect changes
- Cleaned up some comments and parameter names to make things more clear
2025-07-17 18:15:42 -04:00
DevCats 6746e16502 docs: add contribution documentation for modules and templates (#18820)
draft: add contribution docs for modules and templates individually to
be referenced in coder docs manifest.

---------

Co-authored-by: Atif Ali <atif@coder.com>
2025-07-17 16:23:42 -05:00
Dean Sheather 183a6ebbdf chore: add managed_agent_limit licensing feature (#18876)
Note that enforcement and checking usage will come in a future PR.

This feature is implemented differently than existing features in a few
ways.

It's highly recommended that reviewers read:
- This document which outlines the methods we could've used for license
enforcement:
https://www.notion.so/coderhq/AI-Agent-License-Enforcement-21ed579be59280c088b9c1dc5e364ee8
- Phase 0 of the actual RFC document:
https://www.notion.so/coderhq/Usage-based-Billing-AI-b-210d579be592800eb257de7eecd2d26d

### Multiple features in the license, a single feature in codersdk

Firstly, the feature is represented as a single feature in the codersdk
world, but is represented with multiple features in the license.

E.g. in the license you may have:

    {
      "features": {
        "managed_agent_limit_soft": 100,
        "managed_agent_limit_hard": 200
      }
    }

But the entitlements endpoint will return a single feature:

    {
      "features": {
        "managed_agent_limit": {
          "limit": 200,
          "soft_limit": 100
        }
      }
    }

This is required because of our rigid parsing that uses a
`map[string]int64` for features in the license. To avoid requiring all
customers to upgrade to use new licenses, the decision was made to just
use two features and merge them into one. Older Coder deployments will
parse this feature (from new licenses) as two separate features, but
it's not a problem because they don't get used anywhere obviously.

The reason we want to differentiate between a "soft" and "hard" limit is
so we can show admins how much of the usage is "included" vs. how much
they can use before they get hard cut-off.

### Usage period features will be compared and trump based on license
issuance time

The second major difference to other features is that "usage period"
features such as `managed_agent_limit` will now be primarily compared by
the `iat` (issued at) claim of the license they come from. This differs
from previous features. The reason this was done was so we could reduce
limits with newer licenses, which the current comparison code does not
allow for.

This effectively means if you have two active licenses:
- `iat`: 2025-07-14, `managed_agent_limit_soft`: 100,
`managed_agent_limit_hard`: 200
- `iat`: 2025-07-15, `managed_agent_limit_soft`: 50,
`managed_agent_limit_hard`: 100

Then the resulting `managed_agent_limit` entitlement will come from the
second license, even though the values are smaller than another valid
license. The existing comparison code would prefer the first license
even though it was issued earlier.

### Usage period features will count usage between the start and end
dates of the license

Existing limit features, like the user limit, just measure the current
usage value of the feature. The active user count is a gauge that goes
up and down, whereas agent usage can only be incremented, so it doesn't
make sense to use a continually incrementing counter forever and ever
for managed agents.

For managed agent limit, we count the usage between `nbf` (not before)
and `exp` (expires at) of the license that the entitlement comes from.
In the example above, we'd use the issued at date and expiry of the
second license as this date range.

This essentially means, when you get a new license, the usage resets to
zero.

The actual usage counting code will be implemented in a follow-up PR.

### Managed agent limit has a default entitlement value

Temporarily (until further notice), we will be providing licenses with
`feature_set` set to `premium` a default limit.
- Soft limit: `800 * user_limit`
- Hard limit: `1000 * user_limit`

"Enterprise" licenses do not get any default limit and are not entitled
to use the feature.

Unlicensed customers (e.g. OSS) will be permitted to use the feature as
much as they want without limits. This will be implemented when the
counting code is implemented in a follow-up PR.

Closes https://github.com/coder/internal/issues/760
2025-07-17 20:19:01 +10:00
Dean Sheather a1b87a67c6 fix: use client preferred URL for the default DERP (#18911)
The agentsdk currently does a remap of the DERP map to change the
EmbeddedRelay node's URL to match the agent's access URL.

This PR makes changes to the `workspacesdk` (used by clients like the
CLI) and `vpn` (used by Coder Desktop) to match this behavior.

This enables us the ability to try Coder clients in dogfood over a VPN
without changing the global access URL.
2025-07-17 20:17:44 +10:00
Danielle Maywood fb00cd2c1a fix(agent/agentcontainers): fix TestAPI/NoUpdaterLoopLogspam flake (#18905) 2025-07-17 10:59:02 +01:00
Atif Ali aae5fc243a chore(dogfood): add JetBrains fleet ide module (#18817)
We need to dogfood this new fleet module.

> [!NOTE]
> Only works if Coder CLI or Coder Desktop is installed
2025-07-17 10:17:38 +05:00
Edward Angert d304fb4f2d docs: hotfix mainline version number in docs/install/releases to 2.24.2 (#18906)
hotfix

[preview](https://coder.com/docs/@2-24-mainline/install/releases)

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
2025-07-17 10:16:59 +05:00
Danielle Maywood bfb9aa464d fix(site): only attempt to watch when dev containers enabled (#18892) 2025-07-17 00:03:59 +01:00
Atif Ali ca6b5e3415 docs: update port forwarding docs to include Coder Desktop (#18870)
Noticed that Coder Desktop was missing from port-forwarding docs which
is kind of a big feature for Coder Connect.


[preview](https://coder.com/docs/@atif%2Fdesktop-ports/user-guides/workspace-access/port-forwarding)

---------

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
Co-authored-by: Edward Angert <EdwardAngert@users.noreply.github.com>
2025-07-16 19:57:55 +00:00
Marcin Tojek b4c9725443 chore: update ascii logo (#18899)
This PR updates the ASCII logo in the HTML output.
2025-07-16 14:33:46 -03:00
ケイラ 0cdcf89069 chore: update CODEOWNERS (#18891) 2025-07-15 14:52:05 -06:00
ケイラ 9774264928 chore: add image style for kiro.svg (#18889)
The `whiteWithColor` style gives this image a more appropriate treatment
on light themes
2025-07-15 14:09:00 -06:00
blink-so[bot] e76115c67d chore: add kiro: protocol to external app whitelist (#18884)
Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
2025-07-15 18:45:16 +00:00
Atif Ali 5758594ff7 chore: add kiro icon (#18881) 2025-07-15 23:41:21 +05:00
ケイラ 52c4b61391 feat: add search to parameter dropdowns (#18729) 2025-07-15 11:23:49 -06:00
Susana Ferreira dad033ee3d fix(site): exclude workspace schedule settings for prebuilt workspaces (#18826)
## Description

This PR updates the UI to avoid rendering workspace schedule settings
(autostop, autostart, etc.) for prebuilt workspaces. Instead, it
displays an informational message with a link to the relevant
documentation.

## Changes

* Introduce `IsPrebuild` parameter to `convertWorkspace` to indicate
whether the workspace is a prebuild.
* Prevent the Workspace Schedule settings form from rendering in the UI
for prebuilt workspaces.
* Display an info alert with a link to documentation when viewing a
prebuilt workspace.

<img width="2980" height="864" alt="Screenshot 2025-07-10 at 13 16 13"
src="https://github.com/user-attachments/assets/5f831c21-50bb-4e05-beea-dbeb930ddff8"
/>


Relates with: https://github.com/coder/coder/pull/18762

---------

Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
2025-07-15 14:11:04 +01:00
Jakub Domeracki e4d3453e2b feat: publish CLI binaries and detached signatures to releases.coder.com (#18874)
Starting with version `2.24.X `, Coder CLI binaries & corresponding
detached signatures will get published to the GCS bucket
releases.coder.com.
2025-07-15 13:15:58 +02:00
Danielle Maywood 089f9603ed fix(site): only attempt to watch containers when agent connected (#18873)
This PR ensures we do not attempt to call `containers/watch` on the
agent _before_ it is connected.
2025-07-15 11:16:14 +01:00
dependabot[bot] 43546336c9 chore: bump github.com/gohugoio/hugo from 0.147.0 to 0.148.1 (#18852)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from
0.147.0 to 0.148.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/gohugoio/hugo/releases">github.com/gohugoio/hugo's
releases</a>.</em></p>
<blockquote>
<h2>v0.148.1</h2>
<h2>What's Changed</h2>
<ul>
<li>Fix assignment to entry in nil map 6f42cfbc9 <a
href="https://github.com/bep"><code>@​bep</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/13853">#13853</a></li>
<li>deps: Downgrade github.com/niklasfasching/go-org v1.9.0 =&gt; v1.8.0
a84beee42 <a href="https://github.com/bep"><code>@​bep</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/13846">#13846</a></li>
</ul>
<h2>v0.148.0</h2>
<blockquote>
<p>[!NOTE]<br />
There's some minor breaking changes in this release. Please <a
href="https://discourse.gohugo.io/t/breaking-changes-in-v0-148-0/55257">read
this</a> thread for more information.</p>
</blockquote>
<h2>Note</h2>
<ul>
<li>Fix some uglyURLs issues for home, section and taxonomy kind (note)
b8ba33ca9 <a href="https://github.com/bep"><code>@​bep</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/4428">#4428</a>
<a
href="https://redirect.github.com/gohugoio/hugo/issues/7497">#7497</a></li>
<li>Fix branch paths when OutputFormat.Path is configured (note)
f967212b7 <a href="https://github.com/bep"><code>@​bep</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/13829">#13829</a></li>
</ul>
<h2>Bug fixes</h2>
<ul>
<li>resources/page: Allow full datetime prefix in filenames 1b4c42366 <a
href="https://github.com/jmooring"><code>@​jmooring</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/13830">#13830</a></li>
</ul>
<h2>Improvements</h2>
<ul>
<li>Add Ancestors (plural) method to GitInfo, rename Ancestor field to
Parent 3e2f1cdfd <a href="https://github.com/bep"><code>@​bep</code></a>
<a
href="https://redirect.github.com/gohugoio/hugo/issues/13839">#13839</a></li>
<li>Allow creating home pages from content adapters bba6996e1 <a
href="https://github.com/bep"><code>@​bep</code></a></li>
<li>Remove the internal GitInfo type and make Page.GitInf() return a
pointer 90d397b14 <a
href="https://github.com/bep"><code>@​bep</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/5693">#5693</a></li>
<li>source: Expose Ancestor in GitInfo 61e6c730d <a
href="https://github.com/jenbroek"><code>@​jenbroek</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/5693">#5693</a></li>
<li>config: Increase test coverage 266d46dcc <a
href="https://github.com/pixel365"><code>@​pixel365</code></a></li>
<li>markup/goldmark: Change link and image render hook enablement to
enums 84b31721b <a
href="https://github.com/jmooring"><code>@​jmooring</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/13535">#13535</a></li>
<li>hugolib: Honor implicit &quot;page&quot; type during template
selection cfc8d315b <a
href="https://github.com/jmooring"><code>@​jmooring</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/13826">#13826</a></li>
<li>deploy: walkLocal worker pool for performance dd6e2c872 <a
href="https://github.com/davidejones"><code>@​davidejones</code></a></li>
</ul>
<h2>Dependency Updates</h2>
<ul>
<li>build(deps): bump github.com/evanw/esbuild from 0.25.5 to 0.25.6
0a5b87028 <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]</li>
<li>build(deps): bump github.com/olekukonko/tablewriter from 1.0.7 to
1.0.8 94e2c276a <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]</li>
<li>build(deps): bump github.com/niklasfasching/go-org from 1.8.0 to
1.9.0 e77b2ad8f <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]</li>
<li>build(deps): bump github.com/alecthomas/chroma/v2 from 2.18.0 to
2.19.0 9487acf6a <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]</li>
<li>build(deps): bump golang.org/x/tools from 0.32.0 to 0.34.0 1e9a0b93e
<a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]</li>
</ul>
<h2>v0.147.9</h2>
<h2>Improvements and fixes</h2>
<ul>
<li>Remove WARN with false negatives 6a4a3ab8f <a
href="https://github.com/bep"><code>@​bep</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/13806">#13806</a></li>
<li>resources/page: Make sure a map is always initialized 36f6f987a <a
href="https://github.com/bep"><code>@​bep</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/13810">#13810</a></li>
<li>tpl/tplimpl: Copy embedded HTML table render hook to each output
format 18a9ca7d7 <a
href="https://github.com/jmooring"><code>@​jmooring</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/13351">#13351</a></li>
<li>tpl/tplimpl: Change resources.GetRemote errors to suppressible
warnings b6c8dfa9d <a
href="https://github.com/jmooring"><code>@​jmooring</code></a> <a
href="https://redirect.github.com/gohugoio/hugo/issues/13803">#13803</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/gohugoio/hugo/commit/98ba786f2f5dca0866f47ab79f394370bcb77d2f"><code>98ba786</code></a>
releaser: Bump versions for release of 0.148.1</li>
<li><a
href="https://github.com/gohugoio/hugo/commit/6f42cfbc9b80a6e1639e3c0661f530e84590fa6a"><code>6f42cfb</code></a>
Fix assignment to entry in nil map</li>
<li><a
href="https://github.com/gohugoio/hugo/commit/a84beee429d3b0297b1a97b191d641154f7c2e81"><code>a84beee</code></a>
deps: Downgrade github.com/niklasfasching/go-org v1.9.0 =&gt;
v1.8.0</li>
<li><a
href="https://github.com/gohugoio/hugo/commit/65893efd8d1f52d50bd589d84a4c9031d96e7d8d"><code>65893ef</code></a>
releaser: Prepare repository for 0.149.0-DEV</li>
<li><a
href="https://github.com/gohugoio/hugo/commit/c0d9bebacc6bf42a91a74d8bb0de7bc775c8e573"><code>c0d9beb</code></a>
releaser: Bump versions for release of 0.148.0</li>
<li><a
href="https://github.com/gohugoio/hugo/commit/3e2f1cdfdbeb8a1470b216bfb28b78ab14b8c0f4"><code>3e2f1cd</code></a>
Add Ancestors (plural) method to GitInfo, rename Ancestor field to
Parent</li>
<li><a
href="https://github.com/gohugoio/hugo/commit/0a5b870281a47d1045443c081968fc96f8d5e06f"><code>0a5b870</code></a>
build(deps): bump github.com/evanw/esbuild from 0.25.5 to 0.25.6</li>
<li><a
href="https://github.com/gohugoio/hugo/commit/bba6996e15570e542193a043054de3b00cd96e18"><code>bba6996</code></a>
Allow creating home pages from content adapters</li>
<li><a
href="https://github.com/gohugoio/hugo/commit/94e2c276a8592488eedc07e259147425ddf91c2b"><code>94e2c27</code></a>
build(deps): bump github.com/olekukonko/tablewriter from 1.0.7 to
1.0.8</li>
<li><a
href="https://github.com/gohugoio/hugo/commit/90d397b14299b1cb03a6b3a3e9e1ce6dfc36cdad"><code>90d397b</code></a>
Remove the internal GitInfo type and make Page.GitInf() return a
pointer</li>
<li>Additional commits viewable in <a
href="https://github.com/gohugoio/hugo/compare/v0.147.0...v0.148.1">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/gohugoio/hugo&package-manager=go_modules&previous-version=0.147.0&new-version=0.148.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-15 09:27:09 +00:00
Susana Ferreira f1eec2d267 fix(cli): scope context per subtest to fix flake test in prebuilt workspace delete (#18872)
## Description

This PR fixes a flaky test in
`TestDelete/Prebuilt_workspace_delete_permissions`:
https://github.com/coder/internal/issues/764

Previously, all subtests used the same context created at the top level.
Since the subtests run in parallel, they could run for too long and
cause the shared context to expire. This sometimes led to context
deadline exceeded errors, especially during the `testutil.Eventually`
check for running prebuilt workspaces.

The fix is to create a fresh context per subtest, ensuring they are
isolated and not prematurely cancelled due to other subtests' durations.
2025-07-15 10:21:11 +01:00
dependabot[bot] c643214b47 chore: bump google.golang.org/api from 0.231.0 to 0.241.0 (#18849)
Bumps
[google.golang.org/api](https://github.com/googleapis/google-api-go-client)
from 0.231.0 to 0.241.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/googleapis/google-api-go-client/releases">google.golang.org/api's
releases</a>.</em></p>
<blockquote>
<h2>v0.241.0</h2>
<h2><a
href="https://github.com/googleapis/google-api-go-client/compare/v0.240.0...v0.241.0">0.241.0</a>
(2025-07-09)</h2>
<h3>Features</h3>
<ul>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3219">#3219</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/987e4abe1e113ac37f42f378bb05eac44c65e448">987e4ab</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3221">#3221</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/7e31abbe694798ee20645793367f57ecf9f3740b">7e31abb</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3222">#3222</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/3346ebb0706a0fce703f5ada0182522b7a1d6dc8">3346ebb</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3223">#3223</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/f94c92cafe32e768ec48307db9924d8b746b3d25">f94c92c</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3224">#3224</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/3f1f756570d556a0e26f7594bcc3353eabc0a5ea">3f1f756</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3225">#3225</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/8799cd8e4cadab9c6dad2c63a8c199cd1e0e3f2e">8799cd8</a>)</li>
</ul>
<h2>v0.240.0</h2>
<h2><a
href="https://github.com/googleapis/google-api-go-client/compare/v0.239.0...v0.240.0">0.240.0</a>
(2025-07-02)</h2>
<h3>Features</h3>
<ul>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3210">#3210</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/c0efdb50d507feb4340e7b1ad2be61eaa9960ba7">c0efdb5</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3212">#3212</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/c699558a9c2b574bdda5d9d697c7fadaeb65b3c1">c699558</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3214">#3214</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/7b435988338692bdfcae2c174f41a8bb71c4abb1">7b43598</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3215">#3215</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/22e2c3806882276b2437288c2ebf84204cb7c077">22e2c38</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3216">#3216</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/e8c35043996ce513a5cd829da72a79c1c46206ad">e8c3504</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3217">#3217</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/604190c29e745ca177927b465d3855008b1e1902">604190c</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3218">#3218</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/0a46af7bb3db597ef1d459191b3bc55345c61692">0a46af7</a>)</li>
</ul>
<h2>v0.239.0</h2>
<h2><a
href="https://github.com/googleapis/google-api-go-client/compare/v0.238.0...v0.239.0">0.239.0</a>
(2025-06-25)</h2>
<h3>Features</h3>
<ul>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3199">#3199</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/2bdd042ac9a9b4115ea14239f4ffc6d947b3ead8">2bdd042</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3201">#3201</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/8eff56f43f278eb7072da807eb492969d9b6ec00">8eff56f</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3202">#3202</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/f7c299e9c00588b68e02e6fa464ab92a7d7f70d4">f7c299e</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3203">#3203</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/459c5a8db5a2262fa9d4fd5031f8bd81569fe751">459c5a8</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3205">#3205</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/ca610d5390bb286d5f815ee8d296a7cdf7dd4baa">ca610d5</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3206">#3206</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/98b739881e1fd09b2f2b7c0122b675fb02625b7c">98b7398</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3207">#3207</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/71fe287d9c34180ed81ede37531b37b23a7c11dc">71fe287</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3209">#3209</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/27d1aa43d1fb592c0273a5617af68d397d1c9ac7">27d1aa4</a>)</li>
</ul>
<h2>v0.238.0</h2>
<h2><a
href="https://github.com/googleapis/google-api-go-client/compare/v0.237.0...v0.238.0">0.238.0</a>
(2025-06-17)</h2>
<h3>Features</h3>
<ul>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3192">#3192</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/3ad311895f95da734942ad4bc527f32412d1ad4f">3ad3118</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3196">#3196</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/8cb55ce5040dbcc0de4436f1d47de876bebf607a">8cb55ce</a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md">google.golang.org/api's
changelog</a>.</em></p>
<blockquote>
<h2><a
href="https://github.com/googleapis/google-api-go-client/compare/v0.240.0...v0.241.0">0.241.0</a>
(2025-07-09)</h2>
<h3>Features</h3>
<ul>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3219">#3219</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/987e4abe1e113ac37f42f378bb05eac44c65e448">987e4ab</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3221">#3221</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/7e31abbe694798ee20645793367f57ecf9f3740b">7e31abb</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3222">#3222</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/3346ebb0706a0fce703f5ada0182522b7a1d6dc8">3346ebb</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3223">#3223</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/f94c92cafe32e768ec48307db9924d8b746b3d25">f94c92c</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3224">#3224</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/3f1f756570d556a0e26f7594bcc3353eabc0a5ea">3f1f756</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3225">#3225</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/8799cd8e4cadab9c6dad2c63a8c199cd1e0e3f2e">8799cd8</a>)</li>
</ul>
<h2><a
href="https://github.com/googleapis/google-api-go-client/compare/v0.239.0...v0.240.0">0.240.0</a>
(2025-07-02)</h2>
<h3>Features</h3>
<ul>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3210">#3210</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/c0efdb50d507feb4340e7b1ad2be61eaa9960ba7">c0efdb5</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3212">#3212</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/c699558a9c2b574bdda5d9d697c7fadaeb65b3c1">c699558</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3214">#3214</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/7b435988338692bdfcae2c174f41a8bb71c4abb1">7b43598</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3215">#3215</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/22e2c3806882276b2437288c2ebf84204cb7c077">22e2c38</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3216">#3216</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/e8c35043996ce513a5cd829da72a79c1c46206ad">e8c3504</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3217">#3217</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/604190c29e745ca177927b465d3855008b1e1902">604190c</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3218">#3218</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/0a46af7bb3db597ef1d459191b3bc55345c61692">0a46af7</a>)</li>
</ul>
<h2><a
href="https://github.com/googleapis/google-api-go-client/compare/v0.238.0...v0.239.0">0.239.0</a>
(2025-06-25)</h2>
<h3>Features</h3>
<ul>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3199">#3199</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/2bdd042ac9a9b4115ea14239f4ffc6d947b3ead8">2bdd042</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3201">#3201</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/8eff56f43f278eb7072da807eb492969d9b6ec00">8eff56f</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3202">#3202</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/f7c299e9c00588b68e02e6fa464ab92a7d7f70d4">f7c299e</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3203">#3203</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/459c5a8db5a2262fa9d4fd5031f8bd81569fe751">459c5a8</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3205">#3205</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/ca610d5390bb286d5f815ee8d296a7cdf7dd4baa">ca610d5</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3206">#3206</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/98b739881e1fd09b2f2b7c0122b675fb02625b7c">98b7398</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3207">#3207</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/71fe287d9c34180ed81ede37531b37b23a7c11dc">71fe287</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3209">#3209</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/27d1aa43d1fb592c0273a5617af68d397d1c9ac7">27d1aa4</a>)</li>
</ul>
<h2><a
href="https://github.com/googleapis/google-api-go-client/compare/v0.237.0...v0.238.0">0.238.0</a>
(2025-06-17)</h2>
<h3>Features</h3>
<ul>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3192">#3192</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/3ad311895f95da734942ad4bc527f32412d1ad4f">3ad3118</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3196">#3196</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/8cb55ce5040dbcc0de4436f1d47de876bebf607a">8cb55ce</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3197">#3197</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/98994c400492542ca9f7d89e608dccbdb89caa11">98994c4</a>)</li>
<li><strong>all:</strong> Auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3198">#3198</a>)
(<a
href="https://github.com/googleapis/google-api-go-client/commit/582459736e746998eecb609b0d23ddce778d5d8c">5824597</a>)</li>
</ul>
<h2><a
href="https://github.com/googleapis/google-api-go-client/compare/v0.236.0...v0.237.0">0.237.0</a>
(2025-06-12)</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/f942bc9f863a4851f9d67e0aea8ce7fcafb635e2"><code>f942bc9</code></a>
chore(main): release 0.241.0 (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3220">#3220</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/8799cd8e4cadab9c6dad2c63a8c199cd1e0e3f2e"><code>8799cd8</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3225">#3225</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/3f1f756570d556a0e26f7594bcc3353eabc0a5ea"><code>3f1f756</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3224">#3224</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/f94c92cafe32e768ec48307db9924d8b746b3d25"><code>f94c92c</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3223">#3223</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/3346ebb0706a0fce703f5ada0182522b7a1d6dc8"><code>3346ebb</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3222">#3222</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/7e31abbe694798ee20645793367f57ecf9f3740b"><code>7e31abb</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3221">#3221</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/987e4abe1e113ac37f42f378bb05eac44c65e448"><code>987e4ab</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3219">#3219</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/9f7dd0d6600833ed29eb7dcefe7e9ad1f203ba36"><code>9f7dd0d</code></a>
chore(main): release 0.240.0 (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3211">#3211</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/0a46af7bb3db597ef1d459191b3bc55345c61692"><code>0a46af7</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3218">#3218</a>)</li>
<li><a
href="https://github.com/googleapis/google-api-go-client/commit/604190c29e745ca177927b465d3855008b1e1902"><code>604190c</code></a>
feat(all): auto-regenerate discovery clients (<a
href="https://redirect.github.com/googleapis/google-api-go-client/issues/3217">#3217</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/googleapis/google-api-go-client/compare/v0.231.0...v0.241.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=google.golang.org/api&package-manager=go_modules&previous-version=0.231.0&new-version=0.241.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-15 09:16:22 +00:00
dependabot[bot] bfdacae286 chore: bump the x group across 1 directory with 9 updates (#18851)
Bumps the x group with 4 updates in the / directory:
[golang.org/x/crypto](https://github.com/golang/crypto),
[golang.org/x/mod](https://github.com/golang/mod),
[golang.org/x/net](https://github.com/golang/net) and
[golang.org/x/oauth2](https://github.com/golang/oauth2).

Updates `golang.org/x/crypto` from 0.39.0 to 0.40.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/crypto/commit/459a9db11b9c43bb1d61722bfd371751d6de05c9"><code>459a9db</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="https://github.com/golang/crypto/commit/74e709ad8a8068445173aa5f3e8d7c89caf510c3"><code>74e709a</code></a>
ssh: add AlgorithmNegotiationError</li>
<li><a
href="https://github.com/golang/crypto/commit/b3790b8d914304c8187dc2c86800101c329d77cd"><code>b3790b8</code></a>
acme: fix TLSALPN01ChallengeCert for IP address identifiers</li>
<li><a
href="https://github.com/golang/crypto/commit/1dc4269656dd23b2c4e71c51b8af6bc2b63eecb7"><code>1dc4269</code></a>
acme: add Pebble integration testing</li>
<li><a
href="https://github.com/golang/crypto/commit/97bf78725562ce22e18036873215f2203b3e0e1e"><code>97bf787</code></a>
blake2b: implement hash.XOF</li>
<li><a
href="https://github.com/golang/crypto/commit/952517d181d424f6c77f7460bf728205cb048411"><code>952517d</code></a>
x509roots/fallback: update bundle</li>
<li><a
href="https://github.com/golang/crypto/commit/c6fce028266aa1271946a7dfde94cd71cf077d5e"><code>c6fce02</code></a>
ssh: refuse to parse certificates that use a certificate as signing
key</li>
<li><a
href="https://github.com/golang/crypto/commit/0ae49b8145643036e0e6c266cf4edc0f543ea9e0"><code>0ae49b8</code></a>
ssh: reject certificate keys used as signature keys for SSH certs</li>
<li>See full diff in <a
href="https://github.com/golang/crypto/compare/v0.39.0...v0.40.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `golang.org/x/mod` from 0.25.0 to 0.26.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/mod/commit/ea04085b103002db3b0d02d6ebbd97a0ffa29202"><code>ea04085</code></a>
go.mod: update golang.org/x dependencies</li>
<li>See full diff in <a
href="https://github.com/golang/mod/compare/v0.25.0...v0.26.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `golang.org/x/net` from 0.41.0 to 0.42.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/net/commit/76358aa57e0c5fa267fe08795631a173d0cec833"><code>76358aa</code></a>
go.mod: update golang.org/x dependencies</li>
<li>See full diff in <a
href="https://github.com/golang/net/compare/v0.41.0...v0.42.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `golang.org/x/oauth2` from 0.29.0 to 0.30.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/oauth2/commit/cf1431934151b3a93e0b3286eb6798ca08ea3770"><code>cf14319</code></a>
oauth2: fix expiration time window check</li>
<li><a
href="https://github.com/golang/oauth2/commit/32d34ef364e670a650fe59267b92301ff7ed08f1"><code>32d34ef</code></a>
internal: include clientID in auth style cache key</li>
<li><a
href="https://github.com/golang/oauth2/commit/2d34e3091be3f4b4700842fb663dad98a10ddfb6"><code>2d34e30</code></a>
oauth2: replace a magic number with AuthStyleUnknown</li>
<li><a
href="https://github.com/golang/oauth2/commit/696f7b31289a98558822be146698b7834e477e63"><code>696f7b3</code></a>
all: modernize with doc links and any</li>
<li><a
href="https://github.com/golang/oauth2/commit/471209bbe29fc1e3bf8d4ca3ca89d67f8817d521"><code>471209b</code></a>
oauth2: drop dependency on go-cmp</li>
<li><a
href="https://github.com/golang/oauth2/commit/6968da209b8fd816452d22ad1b4faca197a5b974"><code>6968da2</code></a>
oauth2: sync Token.ExpiresIn from internal Token</li>
<li><a
href="https://github.com/golang/oauth2/commit/d2c4e0a6256426212864554628e234ebe6005347"><code>d2c4e0a</code></a>
oauth2: context instead of golang.org/x/net/context in doc</li>
<li><a
href="https://github.com/golang/oauth2/commit/883dc3c9d87d538c301ebff2ccdcc8b6a0b92890"><code>883dc3c</code></a>
endpoints: add various endpoints from stale CLs</li>
<li><a
href="https://github.com/golang/oauth2/commit/1c06e8705ef848db9c7553a78b630b9b9f138a87"><code>1c06e87</code></a>
all: make use of oauth.Token.ExpiresIn</li>
<li>See full diff in <a
href="https://github.com/golang/oauth2/compare/v0.29.0...v0.30.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `golang.org/x/sync` from 0.15.0 to 0.16.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/sync/commit/7fad2c9213e0821bd78435a9c106806f2fc383f1"><code>7fad2c9</code></a>
errgroup: revert propagation of panics</li>
<li>See full diff in <a
href="https://github.com/golang/sync/compare/v0.15.0...v0.16.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `golang.org/x/sys` from 0.33.0 to 0.34.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/sys/commit/751c3c6ac2a644645976e8e7f3db0b75c87d32c6"><code>751c3c6</code></a>
unix: add missing NFT_PAYLOAD_* consts on linux</li>
<li><a
href="https://github.com/golang/sys/commit/0c740cc0f8b112e19e255caefb622a53779c0481"><code>0c740cc</code></a>
unix: update Go to 1.24.3</li>
<li><a
href="https://github.com/golang/sys/commit/d62d31c6166a69390ea553149bf921e215216610"><code>d62d31c</code></a>
unix: update Linux constants and types to v6.14</li>
<li>See full diff in <a
href="https://github.com/golang/sys/compare/v0.33.0...v0.34.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `golang.org/x/term` from 0.32.0 to 0.33.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/term/commit/30da5dd58fc835bf6704fa7464ac3d23202d8685"><code>30da5dd</code></a>
go.mod: update golang.org/x dependencies</li>
<li>See full diff in <a
href="https://github.com/golang/term/compare/v0.32.0...v0.33.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `golang.org/x/text` from 0.26.0 to 0.27.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/text/commit/b6d26456dd3ff554a56f10b1e388db0f8ca862d1"><code>b6d2645</code></a>
go.mod: update golang.org/x dependencies</li>
<li>See full diff in <a
href="https://github.com/golang/text/compare/v0.26.0...v0.27.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `golang.org/x/tools` from 0.33.0 to 0.34.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/tools/commit/578c1213983a83e6411536ddf6bbf3a1faf97aea"><code>578c121</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="https://github.com/golang/tools/commit/f114dcf97d4f35feb86030bb9e1c5c8fc6fd8942"><code>f114dcf</code></a>
gopls/internal/protocol: refine DocumentURI Clean method and its
usages</li>
<li><a
href="https://github.com/golang/tools/commit/82ee0fd1228b85b95daadd1901e83a9200d661e6"><code>82ee0fd</code></a>
internal/mcp: change paginateList to a generic helper</li>
<li><a
href="https://github.com/golang/tools/commit/64bfecc32e163d2684a85b73472919e02da50180"><code>64bfecc</code></a>
gopls/internal/golang: fix extract bug with anon functions</li>
<li><a
href="https://github.com/golang/tools/commit/4546fbd0b20190ede82382b293ae4440923ecaea"><code>4546fbd</code></a>
internal/mcp: unify json tag parsing</li>
<li><a
href="https://github.com/golang/tools/commit/82473ce934847055bec96f8a96e4d1fc38ecefa9"><code>82473ce</code></a>
gopls/doc/release: tweak v0.19</li>
<li><a
href="https://github.com/golang/tools/commit/f3c581ff0cb8b4b87129f04094005c4b0f962bf9"><code>f3c581f</code></a>
gopls/internal/protocol: add DocumentURI.Base accessor</li>
<li><a
href="https://github.com/golang/tools/commit/d9bacab54dfed6ac3f871f422bb0b2cb5eb5c428"><code>d9bacab</code></a>
gopls/internal/server: improve &quot;editing generated file&quot;
warning</li>
<li><a
href="https://github.com/golang/tools/commit/1afeefa8150f171e0a8f0948015513b31d59d2f3"><code>1afeefa</code></a>
internal/mcp: unexport FileResourceHandler</li>
<li><a
href="https://github.com/golang/tools/commit/33d59880f345d37e4262f5f8e504ddfb6818266b"><code>33d5988</code></a>
gopls/internal/server: Organize Imports of generated files</li>
<li>Additional commits viewable in <a
href="https://github.com/golang/tools/compare/v0.33.0...v0.34.0">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ethan Dickson <ethan@coder.com>
2025-07-15 09:04:20 +00:00
Danielle Maywood bd3d0ea482 fix(agent/agentcontainers): fix TestAPI/IgnoreCustomization flake (#18863) 2025-07-15 10:01:04 +01:00
blink-so[bot] 87e5365f79 docs: add cloud-specific database instance recommendations (#18862)
Enhances the Performance efficiency section in the validated
architectures documentation with specific instance type recommendations
for AWS, Azure, and GCP.

**Changes:**
- Added recommended instance types for small, medium, and large
deployments across all three major cloud providers
- Included guidance on avoiding burstable instances (t-family, B-series)
for production workloads
- Added note about CPU baseline limitations for burstable instances

This addresses customer questions about appropriate database instance
sizing.

---------

Signed-off-by: Danny Kopping <dannykopping@gmail.com>
Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: dannykopping <373762+dannykopping@users.noreply.github.com>
Co-authored-by: Danny Kopping <dannykopping@gmail.com>
2025-07-15 09:53:34 +01:00
Ethan de4a270316 docs: improve audit logs copy (#18807)
Many of the issues with the copy on #18739 were because I blindly copied from the audit logs page. This PR adds Edward's copy suggestions from that PR to the audit logs page.

[preview](https://coder.com/docs/@ethan-improve-audit-logs-copy/admin/security/audit-logs)

I've included this in the PR stack, as the previous PR modifies the auto-gen docs for audit logs.
2025-07-15 16:14:30 +10:00
Ethan ef807e41ce chore: mark workspace apps and workspace agents as unaudited (#18761)
The main goal of this PR is to remove Workspace Apps and Workspace Agents from the auto-generated audit log documentation, that incorrectly claims they are audited resources (no longer true with the addition of the connection log).

Though I believe we haven't touched any codepaths for returning audit logs, this PR also adds a test that ensures we continue to return *existing* connection, disconnect and open events correctly from the audit log API.
2025-07-15 16:08:42 +10:00
Ethan 6b17aee425 docs: add connection logs page (#18739)
This is the final PR for moving connection logs out of the audit log and into the new connection logs page.

This PR documents the feature.

[preview](https://coder.com/docs/@ethan%2Fdocs-add-connection-logs/admin/monitoring/connection-logs)
2025-07-15 15:52:41 +10:00
Ethan f42de9fe12 chore!: delete old connection events from audit log (#18735)
### Breaking change (changelog note):
>With new connection events appearing in the Connection Log, connection events older than 90 days will now be deleted from the Audit Log. If you require this legacy data, we recommend querying it from the REST API or making a backup of the database/these events before upgrading your Coder deployment. Please see the PR for details on what exactly will be deleted. 
Of note is that there are currently no plans to delete connection events from the Connection Log.


### Context

This is the fifth PR for moving connection events out of the audit log.

In previous PRs:
- **New** connection logs have been routed to the `connection_logs` table. They will *not* appear in the audit log.
- These new connection logs are served from the new `/api/v2/connectionlog` endpoint.

In this PR:
- We'll now clean existing connection events out of the audit log, if they are older than 90 days, We do this in batches of 1000, every 10 minutes.

The criteria for deletion is simple:
```
WHERE
(
     action = 'connect'
     OR action = 'disconnect'
     OR action = 'open'
     OR action = 'close'
)
AND "time" < @before_time::timestamp with time zone
```
where `@before_time` is currently configured to 90 days in the past.


Future PRs:
- Write documentation for the endpoint / feature
2025-07-15 15:45:36 +10:00
Ethan b5260d5699 feat(site): add connection log page (#18708)
This is the fourth PR for moving connection events out of the audit log.

This PR adds `/connectionlog` to the frontend. This page is identical in structure to the audit log, but with different filters and contents.

The connection log lists sessions, and the time they start. If we support tracking the end time of a session, and we've received a disconnect event for that session, the end timestamp is also included.
       
Demo:


https://github.com/user-attachments/assets/e0fff799-0ed6-45f7-a8c0-237839659ef9



<img width="346" alt="image" src="https://github.com/user-attachments/assets/6de29945-55c2-4fe5-9a4f-d42e476ded25" />
<img width="184" alt="image" src="https://github.com/user-attachments/assets/e83234bc-4d9d-4f71-b668-9256a600659c" />


Since the styling is identical to that of the audit log, I've continued to use MUI table components. When the audit log is migrated off MUI/restyled, this table can be too, relatively easily.

Future PRs:
- Write a query to delete old events from the audit log, call it from dbpurge.
- Write documentation for the endpoint / feature
2025-07-15 15:11:31 +10:00
Cian Johnston 1ee6b8d5b1 chore: fix flake in TestWorkspaceBuildsProvisionerState (#18839)
Fixes https://github.com/coder/internal/issues/761
2025-07-15 15:07:13 +10:00
Ethan 7c077d39c5 chore: populate connectionlog count using a separate query (#18629)
This is the third PR for moving connection events out of the audit log.

This PR populates `count` on `ConnectionLogResponse` using a separate query, to preemptively mitigate the issue described in #17689. It's structurally identical to a portion of https://github.com/coder/coder/pull/18600, but for the connection log instead of the audit log.
       
Future PRs:
- Implement a table in the Web UI for viewing connection logs.
- Write a query to delete old events from the audit log, call it from dbpurge.
- Write documentation for the endpoint / feature
2025-07-15 15:03:30 +10:00
Ethan 7a339a1ffe feat: add connectionlogs API (#18628)
This is the second PR for moving connection events out of the audit log.

This PR:
- Adds the `/api/v2/connectionlog` endpoint
- Adds filtering for `GetAuthorizedConnectionLogsOffset` and thus the endpoint. 
There's quite a few, but I was aiming for feature parity with the audit log.
  1. `organization:<id|name>`
  2. `workspace_owner:<username>`
  3. `workspace_owner_email:<email>`
  4. `type:<ssh|vscode|jetbrains|reconnecting_pty|workspace_app|port_forwarding>`
  5. `username:<username>` 
     - Only includes web-based connection events (workspace apps, web port forwarding) as only those include user metadata.
  6. `user_email:<email>`
  7. `connected_after:<time>`
  8. `connected_before:<time>`
  9. `workspace_id:<id>`
  10. `connection_id:<id>`
      - If you have one snapshot of the connection log, and some sessions are ongoing in that snapshot, you could use this filter to check if they've been closed since.
  11. `status:<connected|disconnected>`
       - If `connected` only sessions with a null `close_time` are returned, if `disconnected`, only those with a non-null `close_time`. If filter is omitted, both are returned.
       
Future PRs:
- Populate `count` on `ConnectionLogResponse` using a seperate query (to preemptively mitigate the issue described in #17689)
- Implement a table in the Web UI for viewing connection logs.
- Write a query to delete old events from the audit log, call it from dbpurge.
- Write documentation for the endpoint / feature (including these filters)
2025-07-15 14:55:34 +10:00
Ethan 08e17a07fc chore!: route connection logs to new table (#18340)
### Breaking Change (changelog note):
> User connections to workspaces, and the opening of workspace apps or ports will no longer create entries in the audit log. Those events will now be included in the 'Connection Log'.
Please see the 'Connection Log' page in the dashboard, and the Connection Log [documentation](https://coder.com/docs/admin/monitoring/connection-logs) for details. Those with permission to view the Audit Log will also be able to view the Connection Log. The new Connection Log has the same licensing restrictions as the Audit Log, and requires a Premium Coder deployment.

### Context

This is the first PR of a few for moving connection events out of the audit log, and into a new database table and web UI page called the 'Connection Log'.

This PR:
- Creates the new table
- Adds and tests queries for inserting and reading, including reading with an RBAC filter.
- Implements the corresponding RBAC changes, such that anyone who can view the audit log can read from the table
- Implements, under the enterprise package, a `ConnectionLogger` abstraction to replace the `Auditor` abstraction for these logs. (No-op'd in AGPL, like the `Auditor`)
- Routes SSH connection and Workspace App events into the new `ConnectionLogger`
- Updates all existing tests to check the values of the `ConnectionLogger` instead of the `Auditor`.

Future PRs:
- Add filtering to the query
- Add an enterprise endpoint to query the new table
- Write a query to delete old events from the audit log, call it from dbpurge.
- Implement a table in the Web UI for viewing connection logs.


> [!NOTE]
> The PRs in this stack obviously won't be (completely) atomic. Whilst they'll each pass CI, the stack is designed to be merged all at once. I'm splitting them up for the sake of those reviewing, and so changes can be reviewed as early as possible.  Despite this, it's really hard to make this PR any smaller than it already is. I'll be keeping it in draft until it's actually ready to merge.
2025-07-15 14:36:06 +10:00
Danielle Maywood 43b0bb7f61 feat(site): use websocket connection for devcontainer updates (#18808)
Instead of polling every 10 seconds, we instead use a WebSocket
connection for more timely updates.
2025-07-14 21:35:35 +01:00
Edward Angert 7cf3263fbd docs: document issue with macos coder desktop behind vpn (#18855)
docs for https://github.com/coder/coder-desktop-macos/issues/201 and
https://github.com/coder/coder-desktop-windows/issues/147

> If the logged in Coder deployment requires a VPN to connect, Coder
Connect can't establish communication through the VPN,
> and will time out.


[preview](https://coder.com/docs/@201-desktop-mac-vpn/user-guides/desktop)

---------

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
Co-authored-by: Dean Sheather <dean@deansheather.com>
2025-07-14 12:33:48 -04:00
Spike Curtis 4980f18022 ci: remove retries/reruns (#18788)
Removes retries / reruns from our CI as they are masking flaky tests
that don't get fixed.

Also limits the Windows and macOS postgresql tests to the CLI and Agent
for now, since we don't officially support coderd on these platforms and
they are particularly flaky.
2025-07-14 17:40:33 +02:00
dependabot[bot] 2e34a1e404 chore: bump github.com/hashicorp/hcl/v2 from 2.23.0 to 2.24.0 (#18854)
Bumps [github.com/hashicorp/hcl/v2](https://github.com/hashicorp/hcl)
from 2.23.0 to 2.24.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/hashicorp/hcl/releases">github.com/hashicorp/hcl/v2's
releases</a>.</em></p>
<blockquote>
<h2>v2.24.0</h2>
<h3>Enhancements</h3>
<ul>
<li>Add support for decoding block and attribute source ranges when
using <code>gohcl</code>. (<a
href="https://redirect.github.com/hashicorp/hcl/pull/703">#703</a>)</li>
<li>hclsyntax: Detect and reject invalid nested splat result. (<a
href="https://redirect.github.com/hashicorp/hcl/pull/724">#724</a>)</li>
</ul>
<h3>Bugs Fixed</h3>
<ul>
<li>Correct handling of unknown objects in Index function. (<a
href="https://redirect.github.com/hashicorp/hcl/pull/763">#763</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/hashicorp/hcl/blob/main/CHANGELOG.md">github.com/hashicorp/hcl/v2's
changelog</a>.</em></p>
<blockquote>
<h2>v2.24.0 (July 7, 2025)</h2>
<h3>Enhancements</h3>
<ul>
<li>Add support for decoding block and attribute source ranges when
using <code>gohcl</code>. (<a
href="https://redirect.github.com/hashicorp/hcl/pull/703">#703</a>)</li>
<li>hclsyntax: Detect and reject invalid nested splat result. (<a
href="https://redirect.github.com/hashicorp/hcl/pull/724">#724</a>)</li>
</ul>
<h3>Bugs Fixed</h3>
<ul>
<li>Correct handling of unknown objects in Index function. (<a
href="https://redirect.github.com/hashicorp/hcl/pull/763">#763</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/hashicorp/hcl/commit/6b5068090eef06b1f127f61529db5ba0be7ed343"><code>6b50680</code></a>
Update CHANGELOG.md (<a
href="https://redirect.github.com/hashicorp/hcl/issues/764">#764</a>)</li>
<li><a
href="https://github.com/hashicorp/hcl/commit/77ef278eaae165adbe82d39a1b8e7707ad7d501a"><code>77ef278</code></a>
ops: handle unknown objects correctly when looking up by index (<a
href="https://redirect.github.com/hashicorp/hcl/issues/763">#763</a>)</li>
<li><a
href="https://github.com/hashicorp/hcl/commit/dfa124f3c93ff1764fda03702a7a9aa8c9db48d8"><code>dfa124f</code></a>
[Compliance] - PR Template Changes Required (<a
href="https://redirect.github.com/hashicorp/hcl/issues/761">#761</a>)</li>
<li><a
href="https://github.com/hashicorp/hcl/commit/6b5c4c2bac7140d1f676d294e99ff5d696b8fbf9"><code>6b5c4c2</code></a>
fix errors thrown by errcheck linter (<a
href="https://redirect.github.com/hashicorp/hcl/issues/755">#755</a>)</li>
<li><a
href="https://github.com/hashicorp/hcl/commit/61bd79dedd738d45edd16f6eb0ca405d0484a7b7"><code>61bd79d</code></a>
suppress and fix lint errors by unused (<a
href="https://redirect.github.com/hashicorp/hcl/issues/754">#754</a>)</li>
<li><a
href="https://github.com/hashicorp/hcl/commit/8b8cb9c9fa85c1f91083ee866c0ca3d1b910404b"><code>8b8cb9c</code></a>
build(deps): bump golangci/golangci-lint-action</li>
<li><a
href="https://github.com/hashicorp/hcl/commit/aa4e44796409371ce1f3d452c81b334d7bbdbfcc"><code>aa4e447</code></a>
build(deps): bump actions/setup-go</li>
<li><a
href="https://github.com/hashicorp/hcl/commit/72443636fe97ebb2e1ce1aa2bfa87dd426d8a88f"><code>7244363</code></a>
Update go-cty to latest (<a
href="https://redirect.github.com/hashicorp/hcl/issues/749">#749</a>)</li>
<li><a
href="https://github.com/hashicorp/hcl/commit/b4e27ae471da2b5a30329239713f7f3ed630c2dc"><code>b4e27ae</code></a>
test_suite: refactor schema validation of diagnostic file range, pos (<a
href="https://redirect.github.com/hashicorp/hcl/issues/750">#750</a>)</li>
<li><a
href="https://github.com/hashicorp/hcl/commit/314d2366eadcbd243f2988a535587d7fea94442e"><code>314d236</code></a>
fix staticcheck lint errors</li>
<li>Additional commits viewable in <a
href="https://github.com/hashicorp/hcl/compare/v2.23.0...v2.24.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/hashicorp/hcl/v2&package-manager=go_modules&previous-version=2.23.0&new-version=2.24.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-14 14:57:09 +00:00
dependabot[bot] b56c6a1d2d ci: bump the github-actions group with 3 updates (#18853)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-14 14:53:45 +00:00
dependabot[bot] b2cf55fd71 chore: bump github.com/mark3labs/mcp-go from 0.32.0 to 0.33.0 (#18850)
Bumps [github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go)
from 0.32.0 to 0.33.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/mark3labs/mcp-go/releases">github.com/mark3labs/mcp-go's
releases</a>.</em></p>
<blockquote>
<h2>Release v0.33.0</h2>
<h2>What's Changed</h2>
<ul>
<li>fix(server): Fix the logic of the WithStateLess function by <a
href="https://github.com/dcsunny"><code>@​dcsunny</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/387">mark3labs/mcp-go#387</a></li>
<li>fix(srv/stream): correct handleGet status code to 200 by <a
href="https://github.com/cryo-zd"><code>@​cryo-zd</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/379">mark3labs/mcp-go#379</a></li>
<li>Add an example of an in process client by <a
href="https://github.com/edwardcqian"><code>@​edwardcqian</code></a> in
<a
href="https://redirect.github.com/mark3labs/mcp-go/pull/371">mark3labs/mcp-go#371</a></li>
<li>feat: add type-safe array items helper functions by <a
href="https://github.com/davidleitw"><code>@​davidleitw</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/396">mark3labs/mcp-go#396</a></li>
<li>Issue 400 fix by <a
href="https://github.com/ozzyozbourne"><code>@​ozzyozbourne</code></a>
in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/406">mark3labs/mcp-go#406</a></li>
<li>fix(client/transport/stream): check for nil pointer by <a
href="https://github.com/dinistavares"><code>@​dinistavares</code></a>
in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/404">mark3labs/mcp-go#404</a></li>
<li>feat: add ResourceLink type and parsing support by <a
href="https://github.com/chenmingyong0423"><code>@​chenmingyong0423</code></a>
in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/407">mark3labs/mcp-go#407</a></li>
<li>Fix docs by <a
href="https://github.com/ezynda3"><code>@​ezynda3</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/430">mark3labs/mcp-go#430</a></li>
<li>feat: client-side streamable-http transport supports continuously
listening by <a
href="https://github.com/leavez"><code>@​leavez</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/317">mark3labs/mcp-go#317</a></li>
<li>feature: add support ResourceTemplates to mcptest package by <a
href="https://github.com/Slach"><code>@​Slach</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/449">mark3labs/mcp-go#449</a></li>
<li>Add support for MCP host session management by <a
href="https://github.com/C0deKing"><code>@​C0deKing</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/466">mark3labs/mcp-go#466</a></li>
<li>docs: Fix unused import in readme example by <a
href="https://github.com/Squiry"><code>@​Squiry</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/469">mark3labs/mcp-go#469</a></li>
<li>Support creating an <code>Stdio</code> client with options by <a
href="https://github.com/peteski22"><code>@​peteski22</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/457">mark3labs/mcp-go#457</a></li>
<li>Implement sampling in Stdio by <a
href="https://github.com/ezynda3"><code>@​ezynda3</code></a> in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/461">mark3labs/mcp-go#461</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/dcsunny"><code>@​dcsunny</code></a> made
their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/387">mark3labs/mcp-go#387</a></li>
<li><a
href="https://github.com/edwardcqian"><code>@​edwardcqian</code></a>
made their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/371">mark3labs/mcp-go#371</a></li>
<li><a
href="https://github.com/davidleitw"><code>@​davidleitw</code></a> made
their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/396">mark3labs/mcp-go#396</a></li>
<li><a
href="https://github.com/ozzyozbourne"><code>@​ozzyozbourne</code></a>
made their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/406">mark3labs/mcp-go#406</a></li>
<li><a
href="https://github.com/dinistavares"><code>@​dinistavares</code></a>
made their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/404">mark3labs/mcp-go#404</a></li>
<li><a
href="https://github.com/chenmingyong0423"><code>@​chenmingyong0423</code></a>
made their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/407">mark3labs/mcp-go#407</a></li>
<li><a href="https://github.com/Slach"><code>@​Slach</code></a> made
their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/449">mark3labs/mcp-go#449</a></li>
<li><a href="https://github.com/C0deKing"><code>@​C0deKing</code></a>
made their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/466">mark3labs/mcp-go#466</a></li>
<li><a href="https://github.com/Squiry"><code>@​Squiry</code></a> made
their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/469">mark3labs/mcp-go#469</a></li>
<li><a href="https://github.com/peteski22"><code>@​peteski22</code></a>
made their first contribution in <a
href="https://redirect.github.com/mark3labs/mcp-go/pull/457">mark3labs/mcp-go#457</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/mark3labs/mcp-go/compare/v0.32.0...v0.33.0">https://github.com/mark3labs/mcp-go/compare/v0.32.0...v0.33.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/6a54215f5b4cdeb1ab9ed602bcf87ebb0222e691"><code>6a54215</code></a>
Implement sampling in Stdio (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/461">#461</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/656a7b4cab77cb913b5f9613c547859596499d6a"><code>656a7b4</code></a>
Support creating an <code>Stdio</code> client with options (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/457">#457</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/01e802f3854d9591f791a39fc148e57768681267"><code>01e802f</code></a>
Fix unused import in readme example (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/469">#469</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/d0fa06e9209195f89bb22b3c952ec038f7d1905a"><code>d0fa06e</code></a>
Add support for MCP host session management (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/466">#466</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/251da138d6b5ade77bb2155e0aa294843cb16337"><code>251da13</code></a>
feature: add support ResourceTemplates to mcptest package (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/449">#449</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/1eddde7bd69b760f745a1b4064969cffcf97e935"><code>1eddde7</code></a>
feat: client-side streamable-http transport supports continuously
listening ...</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/8f5b048218f6d044c3322f16b8cb0b08e10bf5d0"><code>8f5b048</code></a>
Fix docs (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/430">#430</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/0fdb1974c5728a74ae061e650d25bf90c5c43437"><code>0fdb197</code></a>
feat: add ResourceLink type and parsing support (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/407">#407</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/d807ae7b7ac1c2b3c24347d1d602506b9cdcd998"><code>d807ae7</code></a>
fix(client/transport/stream): check for nil pointer (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/404">#404</a>)</li>
<li><a
href="https://github.com/mark3labs/mcp-go/commit/93176e8a70cffc2886bd446fe8464badcd5035da"><code>93176e8</code></a>
fixed nil error (<a
href="https://redirect.github.com/mark3labs/mcp-go/issues/406">#406</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/mark3labs/mcp-go/compare/v0.32.0...v0.33.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/mark3labs/mcp-go&package-manager=go_modules&previous-version=0.32.0&new-version=0.33.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-14 14:31:57 +00:00
Edward Angert 78af5e0f53 docs: add note about incompatible immutable parameters behavior to parameters doc (#18814)
closes #18370 

workspace creation page checks for

1. required parameters
2. incompatible immutable parameters

and if there's an issue, disables the **Create workspace** button until
it's resolved


[preview](https://coder.com/docs/@18370-immutable-params/admin/templates/extending-templates/parameters#mutability)

---------

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
2025-07-14 11:43:43 +00:00
Atif Ali 3126f21d87 revert: "docs: add coder registry link to docs sidebar" (#18837) 2025-07-11 16:09:23 +00:00
Atif Ali c25e666d12 docs: add coder registry link to docs sidebar (#18585)
I am not sure if this works

---------

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
Co-authored-by: Edward Angert <EdwardAngert@users.noreply.github.com>
2025-07-11 08:12:09 -04:00
Edward Angert 040fa30aba docs: update screenshots with new logo (#18830)
stage 1 of many

- new login screenshot
- remove unused platforms screenshots
- update [screenshots
doc](https://coder.com/docs/@2025-screenshots/about/screenshots)
- update [quickstart
doc](https://coder.com/docs/@2025-screenshots/tutorials/quickstart)

closes #18813 

<details><summary>list of screenshots with old logo or that are
outdated</summary>

|docs/images/|notes?|
|--|--|
|logo-black.png| |
|jupyter-notebook.png| |
|platforms/docker/login.png| |
|platforms/docker/create-workspace.png| |
|platforms/docker/ides.png| |
|platforms/gcp/marketplace.png| |
|platforms/gcp/start.png| |
|platforms/aws/aws-linux.png| |
|platforms/aws/marketplace.png| |
|platforms/kubernetes/template-variables.png| |
|platforms/kubernetes/region-picker.png| |
|platforms/kubernetes/starter-template.png| |
|install/windows-installer.png| |
|install/homebrew.png| |
|screenshots/create-template.png| |
|screenshots/login.png| |
|screenshots/starter_templates.png| |
|screenshots/settings.png| |
|screenshots/audit.png| |
|screenshots/workspace-running-with-topbar.png| |
|screenshots/workspaces_listing.png| |
|screenshots/templates_listing.png| |
|screenshots/welcome-create-admin-user.png| |
|screenshots/workspace_launch.png| |
|screenshots/templates_insights.png| |
|screenshots/healthcheck.png| |
|screenshots/terraform.png| |
|deploy-pr-manually.png| |
|workspace-update.png| |
|custom-app.png| |
|code-server.png| |
|networking/annotatedports.png| |
|networking/portsharingmax.png| |
|networking/portforwarddashboard.png| |
|networking/listeningports.png| |
|agent-metadata.png| |
|jupyter.png| |
|admin/service-banner-maintenance.png| |
|admin/provisioner-tags.png| |
|admin/github-app-register.png| |
|admin/licenses/licenses-screen.png| |
|admin/licenses/licenses-nolicense.png| |
|admin/licenses/add-license-ui.png| |
|admin/service-banner-config.png| |
|admin/group-allowlist.png| |
|admin/networking/workspace-proxies/ws-proxy-picker.png| |
|admin/setup/appearance/application-name-logo-url.png| |
|admin/setup/appearance/announcement_banner_settings.png| |
|admin/setup/appearance/support-links.png| |
|admin/setup/appearance/service-banner-secret.png| |
|admin/quota-buildlog.png| |
|admin/integrations/kube-region-picker.png| |
|admin/integrations/coder-logstream-kube-logs-wrong-image.png| |
|admin/integrations/coder-logstream-kube-logs-pod-crashed.png| |
|admin/integrations/coder-logstream-kube-logs-normal.png| |
|admin/integrations/coder-logstream-kube-logs-quota-exceeded.png| |
|admin/git-auth-template.png| |
|admin/github-app-install.png| |
|admin/users/organizations/role-sync.png| |
|admin/users/organizations/group-sync-empty.png| |
|admin/users/organizations/workspace-list.png| |
|admin/users/organizations/new-organization.png| |
|admin/users/organizations/role-sync-empty.png| |
|admin/users/organizations/template-org-picker.png| |
|admin/users/organizations/organization-members.png| |
|admin/users/organizations/org-dropdown-create.png| |
|admin/users/organizations/default-organization-settings.png| |
|admin/users/organizations/group-sync.png| |
|admin/users/organizations/idp-org-sync.png| |
|admin/users/organizations/admin-settings-orgs.png| |
|admin/users/organizations/custom-roles.png| |
|admin/users/quotas/quota-groups.png| |
|admin/users/create-token.png| |
|admin/users/headless-user.png| |
|admin/provisioners/provisioner-jobs.png| |
|admin/github-app-permissions.png| |
|admin/templates/coder-apps-ui.png| |
|admin/templates/starter-templates.png| |
|admin/templates/create-template.png| |
|admin/templates/schedule/template-schedule-settings.png| |
|admin/templates/schedule/user-quiet-hours.png| |
|admin/templates/coder-metadata-ui.png| |
|admin/templates/duplicate-menu.png| |
|admin/templates/agent-metadata-ui.png| |
|admin/templates/troubleshooting/workspace-build-timings-ui.png| |
|admin/templates/duplicate-page.png| |
|admin/templates/new-duplicate-template.png| |
|admin/templates/import-template.png| |

|admin/templates/extend-templates/prebuilt/replacement-notification.png|
|
|admin/templates/extend-templates/prebuilt/prebuilt-workspaces.png| |

|admin/templates/extend-templates/dyn-params/dynamic-params-compare.png|
|

|admin/templates/extend-templates/dyn-params/enable-dynamic-parameters.png|
|
|admin/templates/extend-templates/template-preset-dropdown.png| |
|admin/monitoring/health-check.png| |
|admin/monitoring/logstream-kube.png| |
|admin/monitoring/notifications/user-notification-preferences.png| |
|admin/monitoring/notifications/notification-admin-prefs.png| |
|admin/workspace-proxy-picker.png| |
|admin/admin-settings-general.png| |
|admin/deployment-id-copy-clipboard.png| |
|icons-gallery.png| |
|start/setup-page.png| |
|start/workspace-schedule-settings.png| |
|start/build-template.png| |
|start/starter-templates.png| |
|start/create-template.png| |
|start/create-workspace.png| |
|start/template-preview.png| |
|start/blank-workspaces.png| |
|start/template-source-code.png| |
|start/first-template.png| |
|start/workspace-ready.png| |
|start/template-edit-source-code.png| |
|start/template-publish.png| |
|start/starter-templates-annotated.png| |
|display-apps.png| |
|workspace-automatic-updates.png| |
|workspaces/autostop.png| |
|workspaces/autostart.png| |
|create-workspace-from-templates-ui.png| |
|ide-row.png| |
|editors.png| |
|delete-template.png| |
|logo-white.png| |
|template-rbac.png| |
|coderapp-port-forward.png| |
|user-guides/terminal-access.png| |
|user-guides/workspace-bulk-actions.png| |
|user-guides/devcontainers/devcontainer-agent-ports.png| |
|user-guides/devcontainers/devcontainer-web-terminal.png| |
|user-guides/create-workspace-ui.png| |
|user-guides/workspace-view-connection-annotated.png| |
|user-guides/remote-desktops/web-rdp-demo.png| |
|user-guides/remote-desktops/amazon-dcv-windows-demo.png| |
|user-guides/desktop/coder-desktop-file-sync-add.png| |
|user-guides/desktop/coder-desktop-session-token.png| |
|user-guides/desktop/coder-desktop-win-pre-sign-in.png| |
|user-guides/desktop/coder-desktop-file-sync-conflicts-mouseover.png| |
|user-guides/desktop/coder-desktop-mac-pre-sign-in.png| |
|user-guides/desktop/coder-desktop-file-sync-watching.png| |
|user-guides/desktop/coder-desktop-win-enable-coder-connect.png| |
|user-guides/desktop/coder-desktop-sign-in.png| |
|user-guides/desktop/coder-desktop-file-sync.png| |
|user-guides/desktop/coder-desktop-file-sync-staging.png| |
|user-guides/desktop/chrome-insecure-origin.png| |
|user-guides/desktop/coder-desktop-workspaces.png| |
|user-guides/jetbrains/toolbox/workspaces.png| |
|user-guides/jetbrains/toolbox/install.png| |
|user-guides/jetbrains/toolbox/login-token.png| |
|user-guides/jetbrains/toolbox/login-url.png| |
|user-guides/schedule-settings-workspace.png| |
|user-guides/dotfiles-module.png| |
|user-guides/workspace-list-ui.png| |
|user-guides/workspace-settings-location.png| |
|template-variables.png| |
|ides/code-web-extensions.png| |
|ides/copilot.png| |
|architecture-multi-region.png| |
|external-apps.png| |
|guides/ai-agents/tasks-ui.png| |
|guides/ai-agents/duplicate.png| |
|guides/ai-agents/landing.png| |
|guides/ai-agents/workspace-page.png| |
|guides/ai-agents/realworld-ui.png| |
|guides/xray-integration/example.png| |
|guides/using-organizations/workspace-list.png| |
|guides/using-organizations/new-organization.png| |
|guides/using-organizations/template-org-picker.png| |
|guides/using-organizations/deployment-organizations.png| |
|guides/using-organizations/organization-members.png| |
|readme-logos.png| |
|metadata-ui.png| |
|secret-metadata-ui.png| |
|projector-intellij.png| |
|schedule.png| |
|ssh-keys.png| |
|template-scheduling.png| |
|templates/general-settings.png| |
|templates/build-template.png| |
|templates/update.png| |
|templates/starter-templates.png| |
|templates/create-template.png| |
|templates/select-template.png| |
|templates/pre-filled-parameters.png| |
|templates/source-code.png| |
|templates/upload-create-your-first-template.png| |
|templates/create-workspace.png| |
|templates/edit-source-code.png| |
|templates/permissions.png| |
|templates/coder-session-token.png| |
|templates/starter-templates-button.png| |
|templates/template-tour.png| |
|templates/edit-files.png| |
|templates/workspace-ready.png| |
|templates/template-menu-settings.png| |
|templates/workspace-apps.png| |
|templates/coder-login-web.png| |
|templates/new-workspace.png| |
|templates/template-variables.png| |
|templates/use-template.png| |
|templates/healthy-workspace-agent.png| |
|templates/update-policies.png| |
|templates/upload-create-template-form.png| |
|templates/develop-in-docker-template.png| |
|templates/publish.png| |
|templates/devcontainers.png| |
|templates/create-template-permissions.png| |
|port-forward-dashboard.png| |
|creating-workspace-ui.png| |
|parameters.png| |
|best-practice/build-timeline.png| |
|file-browser.png| |
|architecture-single-region.png| |
|gateway/plugin-settings-marketplace.png| |
|gateway/plugin-session-token.png| |
|gateway/plugin-connect-to-coder.png| |
|gateway/plugin-select-ide.png| |
|gateway/plugin-ide-list.png| |
|hero-image.png| |

</details>

---------

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
2025-07-10 16:01:20 -04:00
Ethan c1b2304d18 test(agent/agentssh): use fish shell compatible exit status checking (#18824)
This (week-old) test was failing in my workspace because I use fish shell. 
I really do not like that Fish shell does not support `$?`, but I also do like Fish shell! We have a few people at Coder who use it who would appreciate this change.
2025-07-10 19:50:30 +10:00
Edward Angert b882d46d91 docs: fix relative links in about/contributing (#18818)
hotfix

---------

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
2025-07-09 20:04:48 +00:00
Bruno Quaresma 5a8a19be70 feat: auto reconnect the terminal (#18796)
**Changes:**
- Use [websocket-ts](https://www.npmjs.com/package/websocket-ts) to have
auto reconnection out of the box 🙏
- Update the disconnected alert message to "Trying to connect..." since
the connection is always trying to reconnect
- Remove `useWithRetry` because it is not necessary anymore

**Other topics:**
- The disconnected alert is displaying a simple message, but we can
include more info such as the number of attemtps
- The reconnection feature is in a good state and adding value. IMO, any
improvement can be done after getting this merged

Closes https://github.com/coder/internal/issues/659
2025-07-09 15:04:24 -03:00
Steven Masley 00ba0278d2 chore: modify parameter dynamic immutability behavior (#18583)
Immutability behavior is determined by the current build, not affected by the previous
2025-07-09 08:45:24 -06:00
Bruno Quaresma 9c61ef82b0 test: fix DeploymentSidebarView stories (#18812) 2025-07-09 10:09:10 -04:00
Cian Johnston 0367dbac43 chore: optimize GetPrebuiltWorkspaces query (#18717)
* Adds GetRunningPrebuiltWorkspacesOptimized query
* Runs both original and updated query side-by-side and logs diffs
2025-07-09 11:30:42 +01:00
Jakub Domeracki dc0919da33 feat: sign coder binaries with the release key using GPG (#18774)
### Description
This PR introduces GPG signing for all Coder *slim-binaries*.
Detached signatures will allow users to verify the integrity and
authenticity of the binaries they download.

### Changes
  * `scripts/sign_with_gpg.sh`: New script to sign a given binary
     using GPG. It imports the release key, signs the binary, and
     verifies the signature.
   * `scripts/build_go.sh`: Updated to call `sign_with_gpg.sh` when the
     `CODER_SIGN_GPG` environment variable is set to 1.
   * `.github/workflows/release.yaml`: The` CODER_SIGN_GPG` environment
     variable is now set to 1 during the release build, enabling GPG
     signing for all release binaries.
   * `.github/workflows/ci.yaml`: The `CODER_SIGN_GPG` environment
     variable is now set to 1 during the CI build, enabling GPG
     signing for all CI binaries.
* `Makefile`: Detached signatures are moved to the `/site/out/bin/
`directory
2025-07-09 11:53:27 +02:00
Hugo Dutka 3c2f3d640b chore: remove dbmem (#18803)
Remove the in-memory database. Addresses #15109.
2025-07-09 09:46:31 +02:00
Steven Masley 1319ae293f chore: support zip filetypes in the file cache (#18750) 2025-07-08 15:46:39 -06:00
Atif Ali 79d1465e23 chore: update module sources for Windsurf, Zed and JetBrains (#18759) 2025-07-08 20:33:34 +00:00
blink-so[bot] 39ed0c32e6 docs: simplify PostgreSQL setup by using 'postgresql' as release name (#18754)
Fixes #18751

Use `postgresql` as the Helm release name instead of `coder-db` to make
the service name more intuitive and eliminate confusion entirely.

## Changes
- Changed `helm install coder-db bitnami/postgresql` to `helm install
postgresql bitnami/postgresql`
- Updated PostgreSQL URLs from
`coder-db-postgresql.coder.svc.cluster.local` to
`postgresql.coder.svc.cluster.local`
- Removed explanatory notes about service naming (no longer needed)

## Benefits
 Makes examples work out-of-the-box for most users
 Uses the most straightforward and intuitive release name
 Eliminates confusion about service naming entirely
 Simpler documentation without complex explanations

## Testing
- Verified that `helm install postgresql bitnami/postgresql` creates
service named `postgresql`
- Confirmed this approach works with the connection URL
`postgresql.coder.svc.cluster.local`

Suggested by @EdwardAngert as a cleaner solution than explaining the
service naming dependency.

---------

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
Co-authored-by: Edward Angert <EdwardAngert@users.noreply.github.com>
2025-07-08 13:20:15 -04:00
Allen Conlon 10c1e36fff feat: add publishing of helm charts to ghcr registry (#18316) 2025-07-08 22:19:12 +05:00
Mathias Fredriksson 6c4db7a2bc feat(cli): replace open vscode container with devcontainer subagent (#18765)
This change allows a devcontainer to be opened via the agent syntax,
`coder open vscode <workspace>.<agent>` and removes the `--container`
option to simplify the subcommand. Accessing the subagent will behave
similarly to how the `--container` option behaved.

Fixes coder/internal#748
2025-07-08 19:21:41 +03:00
Mathias Fredriksson 5f50dcce5a feat(cli): improve devcontainer support for coder show (#18793)
Fixes coder/internal#747
2025-07-08 16:16:00 +00:00
Hugo Dutka 2f50b3b7bb chore(site): remove dbmem from tests (#18802)
Related to https://github.com/coder/coder/issues/15109.
2025-07-08 15:28:48 +00:00
Hugo Dutka 8e038db463 chore(enterprise/replicasync): remove dbmem from tests (#18801)
Related to https://github.com/coder/coder/issues/15109.
2025-07-08 15:25:01 +00:00
Hugo Dutka 5e9cbe8a1b chore(coderd): remove dbmem from tests (#18800)
Related to https://github.com/coder/coder/issues/15109.
2025-07-08 15:19:14 +00:00
Hugo Dutka 66e490986f chore(enterprise/trialer): remove dbmem from tests (#18798)
Related to https://github.com/coder/coder/issues/15109.
2025-07-09 01:17:14 +10:00
Hugo Dutka b65e133a17 chore(enterprise/coderd): remove dbmem from tests (#18797)
Related to https://github.com/coder/coder/issues/15109.
2025-07-09 01:16:46 +10:00
Susana Ferreira 0dc36127c0 chore(dogfood): update filebrowser module to version 1.1.1 (#18799)
Workspaces with `Write Coder on Coder` template are failing with an
error in the agent related to File Browser:
```
2025/07/08 14:00:29 Using database: /home/coder/filebrowser.db  
2025/07/08 14:00:29 password is too short, minimum length is 12
```
Updating filebrowser module version to 1.1.1:
https://github.com/coder/registry/pull/173
2025-07-08 16:13:36 +01:00
Hugo Dutka 733d3f1287 chore(enterprise/cli): remove dbmem from tests (#18795)
Related to https://github.com/coder/coder/issues/15109.
2025-07-08 14:59:03 +00:00
Hugo Dutka f147ebf37d chore(enterprise/audit): remove dbmem from tests (#18794)
Related to https://github.com/coder/coder/issues/15109.
2025-07-08 14:39:02 +00:00
Hugo Dutka 7f681910e9 chore(coderd/updatecheck): remove dbmem from tests (#18792)
Related to https://github.com/coder/coder/issues/15109.
2025-07-08 14:32:46 +00:00
Hugo Dutka e0fb15eeff chore(coderd/searchquery): remove dbmem from tests (#18791)
Related to https://github.com/coder/coder/issues/15109.
2025-07-08 14:32:24 +00:00
Hugo Dutka 321396d9d6 chore(coderd/rbac/rolestore): remove dbmem from tests (#18789)
Related to https://github.com/coder/coder/issues/15109
2025-07-08 16:31:20 +02:00
Hugo Dutka ac4be155d9 chore(coderd/runtimeconfig): remove dbmem from tests (#18790)
Related to https://github.com/coder/coder/issues/15109.
2025-07-08 14:31:05 +00:00
Spike Curtis bf0271fd65 chore: stop running postgres-only tests if DB is not set (#18784)
Fixes https://github.com/coder/internal/issues/695

PostgreSQL tests are getting run in a non-postgres CI job because the tests don't get skipped if the `DB=` env is unset. This PR adds a skip for them.

They are flaking in the `test-go-race` CI job. They run fine in the `test-go-race-pg` job, which pre-creates the postgres server, so the flakiness is almost certainly related to spinning up the database server.
2025-07-08 15:56:22 +04:00
Susana Ferreira 211393a69c fix: exclude prebuilt workspaces from lifecycle executor (#18762)
## Description

This PR updates the lifecycle executor to explicitly exclude prebuilt
workspaces from being considered for lifecycle operations such as
`autostart`, `autostop`, `dormancy`, `default TTL` and `failure TTL`.

Prebuilt workspaces (i.e., those owned by the prebuild system user) are
handled separately by the prebuild reconciliation loop. Including them
in the lifecycle executor could lead to unintended behavior such as
incorrect scheduling or state transitions.

## Changes

* Updated the lifecycle executor query
`GetWorkspacesEligibleForTransition` to exclude workspaces with
`owner_id = 'c42fdf75-3097-471c-8c33-fb52454d81c0'` (prebuilds).
* Added tests to verify prebuilt workspaces are not considered in:
  * Autostop
  * Autostart
  * Default TTL
  * Dormancy
  * Failure TTL

Fixes: https://github.com/coder/coder/issues/18740
Related to: https://github.com/coder/coder/issues/18658
2025-07-08 11:35:28 +01:00
Danielle Maywood 0118e75009 fix(agent): disable dev container integration inside sub agents (#18781)
It appears we accidentally broke this logic in a previous PR. This
should now correctly disable the agent api as we'd expect.
2025-07-08 11:05:30 +01:00
Cian Johnston 1195f31025 chore(site): reduce fetch interval on workspaces page (#18725)
Relates to https://github.com/coder/internal/issues/720

* Reduces workspaces data refetch interval if no builds are pending
* Sets `refetchOnWindowFocus: always` to mitigate impact of reduced polling duration
2025-07-08 11:00:05 +01:00
Kacper Sawicki 8202514ce0 feat!: add ability to cancel pending workspace build (#18713)
Closes #17791 

This PR adds ability to cancel workspace builds that are in "pending"
status.

Breaking changes:
- CancelWorkspaceBuild method in codersdk now accepts an optional
request parameter

API:
- Added `expect_status` query parameter to the cancel workspace build
endpoint
- This parameter ensures the job hasn't changed state before canceling
- API returns `412 Precondition Failed` if the job is not in the
expected status
- Valid values: `running` or `pending`
- Wrapped the entire cancel method in a database transaction

UI:
- Added confirmation dialog to the `Cancel` button, since it's a
destructive operation

![image](https://github.com/user-attachments/assets/437aa5f4-5669-45b6-82a0-e46f277114bf)

![image](https://github.com/user-attachments/assets/423b5cb1-a4fb-4a10-933b-c1c73f4b838c)


- Enabled cancel action for pending workspaces (`expect_status=pending`
is sent if workspace is in pending status)

![image](https://github.com/user-attachments/assets/32d35ff1-12e6-4f7b-9f6c-fde9da9de6cf)

---------

Co-authored-by: Dean Sheather <dean@deansheather.com>
2025-07-08 11:02:58 +02:00
Edward Angert 2f42b64182 docs: update dynamic parameters for beta release (#18512)
Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
Co-authored-by: Stephen Kirby <kirby@coder.com>
Co-authored-by: Stephen Kirby <58410745+stirby@users.noreply.github.com>
Co-authored-by: Atif Ali <atif@coder.com>
Co-authored-by: Jaayden Halko <jaayden.halko@gmail.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
Co-authored-by: Thomas Kosiewski <tk@coder.com>
Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: bpmct <22407953+bpmct@users.noreply.github.com>
Co-authored-by: Bruno Quaresma <bruno@coder.com>
Co-authored-by: BrunoQuaresma <3165839+BrunoQuaresma@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Ethan <39577870+ethanndickson@users.noreply.github.com>
Co-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>
Co-authored-by: Ben Potter <ben@coder.com>
Co-authored-by: Hugo Dutka <hugo@coder.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: ケイラ <mckayla@hey.com>
2025-07-07 19:46:34 -05:00
blink-so[bot] 83192e2462 docs: restore missing AI agent images to fix 404 errors (#18780)
Fixes #18767

This PR restores the missing `landing.png` and `duplicate.png` images
that were accidentally deleted in commit
b26c9e2432.

## Problem
The images were deleted during a documentation restructure, but external
links and cached website content are still referencing these image URLs,
causing 404 errors:
-
`https://raw.githubusercontent.com/coder/coder/main/docs/images/guides/ai-agents/landing.png`
-
`https://raw.githubusercontent.com/coder/coder/main/docs/images/guides/ai-agents/duplicate.png`

## Solution
Restore the original images from the git history to maintain backward
compatibility for external references while preserving the current
documentation structure.

## Testing
 Verified images are restored to correct location
 Confirmed file sizes match original images
 No conflicts with current documentation structure

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>
2025-07-07 19:48:10 -04:00
Thomas Kosiewski 3dcd2acf1d fix: return 404 instead of 401 for missing OAuth2 apps (#18755)
## Problem

Users were being automatically logged out when deleting OAuth2
applications.

## Root Cause

1. User deletes OAuth2 app successfully
2. React Query automatically refetches the app data  
3. Management API incorrectly returned **401 Unauthorized** for the
missing app
4. Frontend axios interceptor sees 401 and calls `signOut()`
5. User gets logged out unexpectedly

## Solution

- Change management API to return **404 Not Found** for missing OAuth2
apps
- OAuth2 protocol endpoints continue returning 401 per RFC 6749
- Rename `writeInvalidClient` to `writeClientNotFound` for clarity

## Additional Changes

- Add conditional OAuth2 navigation when experiment is enabled or in dev
builds
- Add `isDevBuild()` utility and `buildInfo` to dashboard context
- Minor improvements to format script and warning dialogs

Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-07-07 19:57:32 +02:00
ケイラ f2983164f5 chore: fix some small groups and acl typos (#18732)
- Add `format:"uri"` to `Group.AvatarURL` (matches `User.AvatarURL`
field)
- `<user_id>` and `<group_id>` were backwards in the `example:` tags
- The `@Success` annotation for `/acl [get]` had an incorrect type
2025-07-07 11:01:17 -06:00
dependabot[bot] 935bd340b1 chore: bump github.com/valyala/fasthttp from 1.62.0 to 1.63.0 (#18771)
Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp)
from 1.62.0 to 1.63.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/valyala/fasthttp/releases">github.com/valyala/fasthttp's
releases</a>.</em></p>
<blockquote>
<h2>v1.63.0</h2>
<h2>What's Changed</h2>
<ul>
<li>chore(deps): bump securego/gosec from 2.22.3 to 2.22.4 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2007">valyala/fasthttp#2007</a></li>
<li>fix: removed resolved issue link from readme file, issue no longer
ex… by <a
href="https://github.com/viralkansarav"><code>@​viralkansarav</code></a>
in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2008">valyala/fasthttp#2008</a></li>
<li>feat: Add iter.Seq2 iterator by <a
href="https://github.com/ksw2000"><code>@​ksw2000</code></a> in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2011">valyala/fasthttp#2011</a></li>
<li>Removed old information from main documentation as these functions
does not exist by <a
href="https://github.com/viralkansarav"><code>@​viralkansarav</code></a>
in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2012">valyala/fasthttp#2012</a></li>
<li>Proposal : To add Unsafe Zero-Allocation Conversions Sections in
main documentation by <a
href="https://github.com/viralkansarav"><code>@​viralkansarav</code></a>
in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2013">valyala/fasthttp#2013</a></li>
<li>chore(deps): bump golang.org/x/net from 0.40.0 to 0.41.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2018">valyala/fasthttp#2018</a></li>
<li>Drop support before go1.20 by <a
href="https://github.com/erikdubbelboer"><code>@​erikdubbelboer</code></a>
in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2022">valyala/fasthttp#2022</a></li>
<li>chore(deps): bump securego/gosec from 2.22.4 to 2.22.5 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2025">valyala/fasthttp#2025</a></li>
<li>Implement io.StringWriter on some more types by <a
href="https://github.com/erikdubbelboer"><code>@​erikdubbelboer</code></a>
in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2023">valyala/fasthttp#2023</a></li>
<li>chore(deps): bump github.com/andybalholm/brotli from 1.1.1 to 1.2.0
by <a href="https://github.com/dependabot"><code>@​dependabot</code></a>
in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2029">valyala/fasthttp#2029</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/viralkansarav"><code>@​viralkansarav</code></a>
made their first contribution in <a
href="https://redirect.github.com/valyala/fasthttp/pull/2008">valyala/fasthttp#2008</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/valyala/fasthttp/compare/v1.62.0...v1.63.0">https://github.com/valyala/fasthttp/compare/v1.62.0...v1.63.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/valyala/fasthttp/commit/8b512b7dae68ffb700b3240bcb81bed5f5c9e6e8"><code>8b512b7</code></a>
chore(deps): bump github.com/andybalholm/brotli from 1.1.1 to 1.2.0 (<a
href="https://redirect.github.com/valyala/fasthttp/issues/2029">#2029</a>)</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/d356cacd848d92e7f25f06ec64c29f43e033e369"><code>d356cac</code></a>
Implement io.StringWriter on some more types (<a
href="https://redirect.github.com/valyala/fasthttp/issues/2023">#2023</a>)</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/641dd96586089dd225652745cb1f67492509dd1c"><code>641dd96</code></a>
chore(deps): bump securego/gosec from 2.22.4 to 2.22.5 (<a
href="https://redirect.github.com/valyala/fasthttp/issues/2025">#2025</a>)</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/28ebbd9bf1300bc7d763a0f02facad70ee60190f"><code>28ebbd9</code></a>
Drop support before go1.20 (<a
href="https://redirect.github.com/valyala/fasthttp/issues/2022">#2022</a>)</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/75d2192d37d5cd444850d9d857437fc83165e351"><code>75d2192</code></a>
chore(deps): bump golang.org/x/net from 0.40.0 to 0.41.0 (<a
href="https://redirect.github.com/valyala/fasthttp/issues/2018">#2018</a>)</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/46ae933953a610c389f33c1058b8c2b901113e55"><code>46ae933</code></a>
Proposal : To add Unsafe Zero-Allocation Conversions Sections in main
docume...</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/74f3d4cfc825c095c1c1630bd69e0b8da3cd8755"><code>74f3d4c</code></a>
Removed old information from main documentation as these functions does
not e...</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/a1783ffacc6269de7d37a3a99da1005f404a7a82"><code>a1783ff</code></a>
feat: Add iter.Seq2 iterator <a
href="https://redirect.github.com/valyala/fasthttp/issues/2010">#2010</a>
(<a
href="https://redirect.github.com/valyala/fasthttp/issues/2011">#2011</a>)</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/246634464811c0389369f7a5bd298b85f63670e4"><code>2466344</code></a>
Remove unused file</li>
<li><a
href="https://github.com/valyala/fasthttp/commit/d856840619aa61cff3274ad8403a8f34f15957c7"><code>d856840</code></a>
fix: removed resolved issue link from readme file, issue no longer
exists (<a
href="https://redirect.github.com/valyala/fasthttp/issues/2">#2</a>...</li>
<li>Additional commits viewable in <a
href="https://github.com/valyala/fasthttp/compare/v1.62.0...v1.63.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/valyala/fasthttp&package-manager=go_modules&previous-version=1.62.0&new-version=1.63.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-07 13:59:45 +00:00
dependabot[bot] 52ff531d1f chore: bump github.com/go-playground/validator/v10 from 10.26.0 to 10.27.0 (#18772)
Bumps
[github.com/go-playground/validator/v10](https://github.com/go-playground/validator)
from 10.26.0 to 10.27.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/go-playground/validator/releases">github.com/go-playground/validator/v10's
releases</a>.</em></p>
<blockquote>
<h2>Release 10.27.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Fix Release version badge on README page by <a
href="https://github.com/nodivbyzero"><code>@​nodivbyzero</code></a> in
<a
href="https://redirect.github.com/go-playground/validator/pull/1406">go-playground/validator#1406</a></li>
<li>fix russian E.164 error message by <a
href="https://github.com/prigornitskiy"><code>@​prigornitskiy</code></a>
in <a
href="https://redirect.github.com/go-playground/validator/pull/1349">go-playground/validator#1349</a></li>
<li>chore: remove unnecessary statement by <a
href="https://github.com/qshuai"><code>@​qshuai</code></a> in <a
href="https://redirect.github.com/go-playground/validator/pull/1200">go-playground/validator#1200</a></li>
<li>Re-enable several linters by <a
href="https://github.com/nodivbyzero"><code>@​nodivbyzero</code></a> in
<a
href="https://redirect.github.com/go-playground/validator/pull/1412">go-playground/validator#1412</a></li>
<li>add support to tag validateFn by <a
href="https://github.com/peczenyj"><code>@​peczenyj</code></a> in <a
href="https://redirect.github.com/go-playground/validator/pull/1363">go-playground/validator#1363</a></li>
<li>Bump golang.org/x/crypto from 0.33.0 to 0.35.0 in
/_examples/validate_fn by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-playground/validator/pull/1418">go-playground/validator#1418</a></li>
<li>Bump golang.org/x/net from 0.34.0 to 0.38.0 in
/_examples/validate_fn by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-playground/validator/pull/1419">go-playground/validator#1419</a></li>
<li>Align required_without with the contract stated in the documentation
by <a href="https://github.com/jmfrees"><code>@​jmfrees</code></a> in <a
href="https://redirect.github.com/go-playground/validator/pull/1422">go-playground/validator#1422</a></li>
<li>Add translation example by <a
href="https://github.com/cxlblm"><code>@​cxlblm</code></a> in <a
href="https://redirect.github.com/go-playground/validator/pull/1394">go-playground/validator#1394</a></li>
<li>doc(errors): mention RegisterTagNameFunc for FieldError.Field by <a
href="https://github.com/khan-ajamal"><code>@​khan-ajamal</code></a> in
<a
href="https://redirect.github.com/go-playground/validator/pull/1358">go-playground/validator#1358</a></li>
<li>Bump golangci/golangci-lint-action from 7 to 8 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-playground/validator/pull/1425">go-playground/validator#1425</a></li>
<li>feat(translation): add en translation for urn_rfc2141 by <a
href="https://github.com/ryanmalesic"><code>@​ryanmalesic</code></a> in
<a
href="https://redirect.github.com/go-playground/validator/pull/1431">go-playground/validator#1431</a></li>
<li>fix: panics when private field is validated by <a
href="https://github.com/ykalchevskiy"><code>@​ykalchevskiy</code></a>
in <a
href="https://redirect.github.com/go-playground/validator/pull/1423">go-playground/validator#1423</a></li>
<li>Fix: support validation for map values with struct types by <a
href="https://github.com/JunaidIslam2105"><code>@​JunaidIslam2105</code></a>
in <a
href="https://redirect.github.com/go-playground/validator/pull/1433">go-playground/validator#1433</a></li>
<li>Omitzero does not work with slice and map bug by <a
href="https://github.com/JunaidIslam2105"><code>@​JunaidIslam2105</code></a>
in <a
href="https://redirect.github.com/go-playground/validator/pull/1436">go-playground/validator#1436</a></li>
<li>Fix: Validator panics when 'nil' is used along with required if for
slices and maps by <a
href="https://github.com/JunaidIslam2105"><code>@​JunaidIslam2105</code></a>
in <a
href="https://redirect.github.com/go-playground/validator/pull/1442">go-playground/validator#1442</a></li>
<li>docs: typos by <a
href="https://github.com/eqsdxr"><code>@​eqsdxr</code></a> in <a
href="https://redirect.github.com/go-playground/validator/pull/1440">go-playground/validator#1440</a></li>
<li>fix: make &quot;file://&quot; fail <code>url</code> validation by <a
href="https://github.com/bfabio"><code>@​bfabio</code></a> in <a
href="https://redirect.github.com/go-playground/validator/pull/1444">go-playground/validator#1444</a></li>
<li>disable way too aggressive and disagreeable linters by <a
href="https://github.com/deankarn"><code>@​deankarn</code></a> in <a
href="https://redirect.github.com/go-playground/validator/pull/1445">go-playground/validator#1445</a></li>
<li>use golangci lint file for disables by <a
href="https://github.com/deankarn"><code>@​deankarn</code></a> in <a
href="https://redirect.github.com/go-playground/validator/pull/1447">go-playground/validator#1447</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/prigornitskiy"><code>@​prigornitskiy</code></a>
made their first contribution in <a
href="https://redirect.github.com/go-playground/validator/pull/1349">go-playground/validator#1349</a></li>
<li><a href="https://github.com/qshuai"><code>@​qshuai</code></a> made
their first contribution in <a
href="https://redirect.github.com/go-playground/validator/pull/1200">go-playground/validator#1200</a></li>
<li><a href="https://github.com/peczenyj"><code>@​peczenyj</code></a>
made their first contribution in <a
href="https://redirect.github.com/go-playground/validator/pull/1363">go-playground/validator#1363</a></li>
<li><a href="https://github.com/jmfrees"><code>@​jmfrees</code></a> made
their first contribution in <a
href="https://redirect.github.com/go-playground/validator/pull/1422">go-playground/validator#1422</a></li>
<li><a href="https://github.com/cxlblm"><code>@​cxlblm</code></a> made
their first contribution in <a
href="https://redirect.github.com/go-playground/validator/pull/1394">go-playground/validator#1394</a></li>
<li><a
href="https://github.com/khan-ajamal"><code>@​khan-ajamal</code></a>
made their first contribution in <a
href="https://redirect.github.com/go-playground/validator/pull/1358">go-playground/validator#1358</a></li>
<li><a
href="https://github.com/ryanmalesic"><code>@​ryanmalesic</code></a>
made their first contribution in <a
href="https://redirect.github.com/go-playground/validator/pull/1431">go-playground/validator#1431</a></li>
<li><a
href="https://github.com/ykalchevskiy"><code>@​ykalchevskiy</code></a>
made their first contribution in <a
href="https://redirect.github.com/go-playground/validator/pull/1423">go-playground/validator#1423</a></li>
<li><a
href="https://github.com/JunaidIslam2105"><code>@​JunaidIslam2105</code></a>
made their first contribution in <a
href="https://redirect.github.com/go-playground/validator/pull/1433">go-playground/validator#1433</a></li>
<li><a href="https://github.com/eqsdxr"><code>@​eqsdxr</code></a> made
their first contribution in <a
href="https://redirect.github.com/go-playground/validator/pull/1440">go-playground/validator#1440</a></li>
<li><a href="https://github.com/bfabio"><code>@​bfabio</code></a> made
their first contribution in <a
href="https://redirect.github.com/go-playground/validator/pull/1444">go-playground/validator#1444</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/go-playground/validator/compare/v10.26.0...v10.27.0">https://github.com/go-playground/validator/compare/v10.26.0...v10.27.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/go-playground/validator/commit/bc77d03bfbd951ad1299267754e230b0af36a5aa"><code>bc77d03</code></a>
use golangci lint file for disables (<a
href="https://redirect.github.com/go-playground/validator/issues/1447">#1447</a>)</li>
<li><a
href="https://github.com/go-playground/validator/commit/4a1bc2f2628506a2cab2e3fe88d0cb57ccedbb6a"><code>4a1bc2f</code></a>
disable way too aggressive and disagreeable linters (<a
href="https://redirect.github.com/go-playground/validator/issues/1445">#1445</a>)</li>
<li><a
href="https://github.com/go-playground/validator/commit/cf2267f30e617916a42e6217cd5d3c837100b374"><code>cf2267f</code></a>
fix: make &quot;file://&quot; fail <code>url</code> validation (<a
href="https://redirect.github.com/go-playground/validator/issues/1444">#1444</a>)</li>
<li><a
href="https://github.com/go-playground/validator/commit/3fd4678e4a0346d57ac1ebcb81ceb86a87ed59f0"><code>3fd4678</code></a>
docs: typos (<a
href="https://redirect.github.com/go-playground/validator/issues/1440">#1440</a>)</li>
<li><a
href="https://github.com/go-playground/validator/commit/ec374ef02d93322f9d337c47678fbb45ac055323"><code>ec374ef</code></a>
Fix: Validator panics when 'nil' is used along with required if for
slices an...</li>
<li><a
href="https://github.com/go-playground/validator/commit/0e3e2f997385102062275f226e825b4a109f4833"><code>0e3e2f9</code></a>
Omitzero does not work with slice and map bug (<a
href="https://redirect.github.com/go-playground/validator/issues/1436">#1436</a>)</li>
<li><a
href="https://github.com/go-playground/validator/commit/dfc7ccd4d817cfd6f065273e37d83f7ae7815cce"><code>dfc7ccd</code></a>
Fix: support validation for map values with struct types (<a
href="https://redirect.github.com/go-playground/validator/issues/1433">#1433</a>)</li>
<li><a
href="https://github.com/go-playground/validator/commit/5b9542b93487972cdfa75ed03ebe4286c3f44c01"><code>5b9542b</code></a>
fix: panics when private field is validated (<a
href="https://redirect.github.com/go-playground/validator/issues/1423">#1423</a>)</li>
<li><a
href="https://github.com/go-playground/validator/commit/f9a5a1fa1e61028e09df895cd92dfd31673e245f"><code>f9a5a1f</code></a>
feat(translation): add en translation for urn_rfc2141 (<a
href="https://redirect.github.com/go-playground/validator/issues/1431">#1431</a>)</li>
<li><a
href="https://github.com/go-playground/validator/commit/20f7df64bdd443294349535a5da244ad0b2af71a"><code>20f7df6</code></a>
Bump golangci/golangci-lint-action from 7 to 8 (<a
href="https://redirect.github.com/go-playground/validator/issues/1425">#1425</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/go-playground/validator/compare/v10.26.0...v10.27.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/go-playground/validator/v10&package-manager=go_modules&previous-version=10.26.0&new-version=10.27.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-07 13:59:25 +00:00
Edward Angert e3627fd562 docs: fix markdown in Windsurf doc (#18753)
hotfix


[preview](https://coder.com/docs/@18705-windsurf-md/user-guides/workspace-access/windsurf)

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
2025-07-07 18:52:19 +05:00
dependabot[bot] ededcd0c37 chore: bump go.nhat.io/otelsql from 0.15.0 to 0.16.0 (#18768)
Bumps [go.nhat.io/otelsql](https://github.com/nhatthm/otelsql) from
0.15.0 to 0.16.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/nhatthm/otelsql/releases">go.nhat.io/otelsql's
releases</a>.</em></p>
<blockquote>
<h2>v0.16.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Bump the otel group with 7 updates by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/334">nhatthm/otelsql#334</a></li>
<li>Bump golang.org/x/net from 0.23.0 to 0.33.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/335">nhatthm/otelsql#335</a></li>
<li>Bump github.com/go-sql-driver/mysql from 1.8.1 to 1.9.0 in
/tests/mysql by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/336">nhatthm/otelsql#336</a></li>
<li>Bump github.com/prometheus/client_golang from 1.20.5 to 1.21.0 in
/tests/suite by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/337">nhatthm/otelsql#337</a></li>
<li>Bump github.com/prometheus/client_golang from 1.21.0 to 1.21.1 in
/tests/suite by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/338">nhatthm/otelsql#338</a></li>
<li>Bump the otel group with 7 updates by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/339">nhatthm/otelsql#339</a></li>
<li>Bump golang.org/x/net from 0.33.0 to 0.36.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/340">nhatthm/otelsql#340</a></li>
<li>Bump github.com/golang-jwt/jwt/v4 from 4.5.1 to 4.5.2 in
/tests/mssql by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/342">nhatthm/otelsql#342</a></li>
<li>Bump github.com/go-sql-driver/mysql from 1.9.0 to 1.9.1 in
/tests/mysql by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/341">nhatthm/otelsql#341</a></li>
<li>Bump github.com/jackc/pgx/v5 from 5.7.2 to 5.7.3 in /tests/postgres
by <a href="https://github.com/dependabot"><code>@​dependabot</code></a>
in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/343">nhatthm/otelsql#343</a></li>
<li>Bump dependencies by <a
href="https://github.com/nhatthm"><code>@​nhatthm</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/347">nhatthm/otelsql#347</a></li>
<li>Bump github.com/jackc/pgx/v5 from 5.7.3 to 5.7.4 in /tests/postgres
by <a href="https://github.com/dependabot"><code>@​dependabot</code></a>
in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/344">nhatthm/otelsql#344</a></li>
<li>Bump github.com/go-sql-driver/mysql from 1.9.1 to 1.9.2 in
/tests/mysql by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/345">nhatthm/otelsql#345</a></li>
<li>Bump golang.org/x/net from 0.36.0 to 0.38.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/348">nhatthm/otelsql#348</a></li>
<li>Bump the otel group with 7 updates by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/350">nhatthm/otelsql#350</a></li>
<li>Bump github.com/jackc/pgx/v5 from 5.7.4 to 5.7.5 in /tests/postgres
by <a href="https://github.com/dependabot"><code>@​dependabot</code></a>
in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/349">nhatthm/otelsql#349</a></li>
<li>Bump github.com/bool64/sqluct from 0.2.4 to 0.2.5 in /tests/suite by
<a href="https://github.com/dependabot"><code>@​dependabot</code></a> in
<a
href="https://redirect.github.com/nhatthm/otelsql/pull/351">nhatthm/otelsql#351</a></li>
<li>Bump github.com/bool64/sqluct from 0.2.5 to 0.2.6 in /tests/suite by
<a href="https://github.com/dependabot"><code>@​dependabot</code></a> in
<a
href="https://redirect.github.com/nhatthm/otelsql/pull/353">nhatthm/otelsql#353</a></li>
<li>Bump github.com/go-sql-driver/mysql from 1.9.2 to 1.9.3 in
/tests/mysql by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/352">nhatthm/otelsql#352</a></li>
<li>avoid allocating attributes when the span is not recording by <a
href="https://github.com/boekkooi-impossiblecloud"><code>@​boekkooi-impossiblecloud</code></a>
in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/354">nhatthm/otelsql#354</a></li>
<li>Bump the otel group with 7 updates by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/nhatthm/otelsql/pull/355">nhatthm/otelsql#355</a></li>
<li>Bump github.com/bool64/sqluct from 0.2.6 to 0.2.7 in /tests/suite by
<a href="https://github.com/dependabot"><code>@​dependabot</code></a> in
<a
href="https://redirect.github.com/nhatthm/otelsql/pull/356">nhatthm/otelsql#356</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/nhatthm/otelsql/compare/v0.15.0...v0.16.0">https://github.com/nhatthm/otelsql/compare/v0.15.0...v0.16.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/nhatthm/otelsql/commit/9213586ccd31a41f9a70507245f1970397502d00"><code>9213586</code></a>
Bump github.com/bool64/sqluct from 0.2.6 to 0.2.7 in /tests/suite (<a
href="https://redirect.github.com/nhatthm/otelsql/issues/356">#356</a>)</li>
<li><a
href="https://github.com/nhatthm/otelsql/commit/ff42240692792e9aa1277be17324937d8bbe0f6e"><code>ff42240</code></a>
Bump the otel group with 7 updates (<a
href="https://redirect.github.com/nhatthm/otelsql/issues/355">#355</a>)</li>
<li><a
href="https://github.com/nhatthm/otelsql/commit/324b3bc0c37ff441deddfb4b1c02840f02c45cae"><code>324b3bc</code></a>
avoid allocating attributes when the span is not recording (<a
href="https://redirect.github.com/nhatthm/otelsql/issues/354">#354</a>)</li>
<li><a
href="https://github.com/nhatthm/otelsql/commit/7cf081467d8c0457fe3c4528654a81084b8b569a"><code>7cf0814</code></a>
Bump github.com/go-sql-driver/mysql from 1.9.2 to 1.9.3 in /tests/mysql
(<a
href="https://redirect.github.com/nhatthm/otelsql/issues/352">#352</a>)</li>
<li><a
href="https://github.com/nhatthm/otelsql/commit/c5bf99ad7971c12f4909f103bd026b3592675e0b"><code>c5bf99a</code></a>
Bump github.com/bool64/sqluct from 0.2.5 to 0.2.6 in /tests/suite (<a
href="https://redirect.github.com/nhatthm/otelsql/issues/353">#353</a>)</li>
<li><a
href="https://github.com/nhatthm/otelsql/commit/f7d72a363f1fa3db072c9e6e02955a4221fcc3d7"><code>f7d72a3</code></a>
Bump github.com/bool64/sqluct from 0.2.4 to 0.2.5 in /tests/suite (<a
href="https://redirect.github.com/nhatthm/otelsql/issues/351">#351</a>)</li>
<li><a
href="https://github.com/nhatthm/otelsql/commit/ff0e5865586ec909643aff7cbbccb90d61bbbcbf"><code>ff0e586</code></a>
Bump github.com/jackc/pgx/v5 from 5.7.4 to 5.7.5 in /tests/postgres (<a
href="https://redirect.github.com/nhatthm/otelsql/issues/349">#349</a>)</li>
<li><a
href="https://github.com/nhatthm/otelsql/commit/fb7f15c94a1309d85f67db46114f5a52e6677606"><code>fb7f15c</code></a>
Bump the otel group with 7 updates (<a
href="https://redirect.github.com/nhatthm/otelsql/issues/350">#350</a>)</li>
<li><a
href="https://github.com/nhatthm/otelsql/commit/00a194983cdd2f291e8106da75a210249c5b5ff8"><code>00a1949</code></a>
Bump golang.org/x/net from 0.36.0 to 0.38.0 (<a
href="https://redirect.github.com/nhatthm/otelsql/issues/348">#348</a>)</li>
<li><a
href="https://github.com/nhatthm/otelsql/commit/ebcac0a7fc58469868c9dbfaa8b7ad7cb8fbf0e6"><code>ebcac0a</code></a>
Bump github.com/go-sql-driver/mysql from 1.9.1 to 1.9.2 in /tests/mysql
(<a
href="https://redirect.github.com/nhatthm/otelsql/issues/345">#345</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/nhatthm/otelsql/compare/v0.15.0...v0.16.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=go.nhat.io/otelsql&package-manager=go_modules&previous-version=0.15.0&new-version=0.16.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-07 13:45:01 +00:00
dependabot[bot] 3477ed67a5 ci: bump the github-actions group with 6 updates (#18769)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-07 13:44:06 +00:00
Hugo Dutka 1e715e2f66 chore: add suggestions to the tasks docs (#18766) 2025-07-07 09:15:53 -04:00
Ben Potter b26c9e2432 feat: update tasks docs (#18659)
Preview: https://coder.com/docs/@tasks-docs/ai-coder

---------

Co-authored-by: Hugo Dutka <hugo@coder.com>
2025-07-07 08:21:59 -04:00
blink-so[bot] 65809710e5 feat: make readinessProbe and livenessProbe initialDelaySeconds configurable (#18756)
Makes `initialDelaySeconds` configurable for both `readinessProbe` and
`livenessProbe` in the Helm chart.

**Changes:**
- Added `coder.readinessProbe.initialDelaySeconds` and
`coder.livenessProbe.initialDelaySeconds` to `values.yaml`
- Updated `_coder.tpl` template to use these configurable values
- Defaults to 0 seconds to maintain existing behavior

**Testing:**
- Verified template rendering with default values (0)
- Verified template rendering with custom values (30, 60)
- Both probes correctly use the configured `initialDelaySeconds`

---------

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>
2025-07-07 08:37:19 +01:00
Ethan a1c77e36be fix: handle sql/driver.Valuer types properly in json logs (#18760)
This bumps `slog` to incorporate https://github.com/coder/slog/pull/219.

Before:
```json
{
  "fields": {
      "Code": "{Int32:0 Valid:false}",
      "ValidCode": "{Int32:12 Valid:true}"
  }
}
```

After:
```json
{
  "fields": {
      "Code": null,
      "ValidCode": 12
  }
}
```
2025-07-07 13:39:18 +10:00
Atif Ali aad14b8a6b docs: add RDP desktop button gif (#18758)
Forgot to add this in #18716
2025-07-06 20:15:37 +05:00
Atif Ali ca13b58d57 docs: reorganize remote desktop docs (#18716)
- Reorganize each option in two sections: Web and Desktop Client
- Moves the warning about UDP connections to the bottom
- Move Coder Desktop as the first option
- Links the Coder Desktop RDP module

Preview:
https://coder.com/docs/@remote-desktop-module/user-guides/workspace-access/remote-desktops
2025-07-06 15:46:15 +05:00
Edward Angert 02372caf92 docs: align feature stages for July release (#18752)
some of these changes might also be in other PRs, but hopefully this
doesn't cause any merge conflicts

closes #18197

---------

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
2025-07-04 09:34:49 -04:00
Bruno Quaresma 369bccd52a feat: establish terminal reconnection foundation (#18693)
Adds a new hook called `useWithRetry` as part of
https://github.com/coder/internal/issues/659

---------

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: BrunoQuaresma <3165839+BrunoQuaresma@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-07-03 17:49:52 -03:00
blink-so[bot] 5ad1847c42 fix: add manual confirmation for release calendar update (#18748)
Add a confirmation dialog to the release script that prompts the user to
manually update the release calendar documentation before proceeding
with the release.

## Changes

- Added a confirmation prompt that asks users to update the release
calendar documentation
- Provides the URL to the documentation
(https://coder.com/docs/install/releases#release-schedule)
- Suggests running the `./scripts/update-release-calendar.sh` script
- Requires explicit confirmation before proceeding with the release
- Exits the script if the user hasn't updated the documentation

## Testing

- [x] Script syntax validation passes (`bash -n scripts/release.sh`)
- [x] Changes are placed at the appropriate point in the release flow
(after release notes editing, before actual release creation)

This addresses the issue where the release calendar documentation was
getting out of date. While automation can be added later, this ensures
users manually confirm the documentation is updated before each release.

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: bpmct <22407953+bpmct@users.noreply.github.com>
2025-07-03 19:45:12 +00:00
Steven Masley a099a8a25c feat: use preview to compute workspace tags from terraform (#18720)
If using dynamic parameters, workspace tags are extracted using
`coder/preview`.
2025-07-03 14:35:44 -05:00
Thomas Kosiewski 4607e5113b refactor: organize OAuth2 provider tests into dedicated packages (#18747)
# OAuth2 Provider Code Reorganization

This PR reorganizes the OAuth2 provider code to improve separation of concerns and maintainability. The changes include:

1. Migrating OAuth2 provider app validation tests from `coderd/oauth2_test.go` to `oauth2provider/provider_test.go`
2. Moving OAuth2 client registration validation tests to `oauth2provider/validation_test.go`
3. Adding new comprehensive test files for metadata and validation edge cases
4. Renaming `OAuth2ProviderAppSecret` to `AppSecret` for better naming consistency
5. Simplifying the main integration test in `oauth2_test.go` to focus on core functionality

The PR maintains all existing test coverage while organizing the code more logically, making it easier to understand and maintain the OAuth2 provider implementation. This reorganization will help with future enhancements to the OAuth2 provider functionality.
2025-07-03 20:41:47 +02:00
Thomas Kosiewski c65013384a refactor: move OAuth2 provider code to dedicated package (#18746)
# Refactor OAuth2 Provider Code into Dedicated Package

This PR refactors the OAuth2 provider functionality by moving it from the main `coderd` package into a dedicated `oauth2provider` package. The change improves code organization and maintainability without changing functionality.

Key changes:

- Created a new `oauth2provider` package to house all OAuth2 provider-related code
- Moved existing OAuth2 provider functionality from `coderd/identityprovider` to the new package
- Refactored handler functions to follow a consistent pattern of returning `http.HandlerFunc` instead of being handlers directly
- Split large files into smaller, more focused files organized by functionality:
  - `app_secrets.go` - Manages OAuth2 application secrets
  - `apps.go` - Handles OAuth2 application CRUD operations
  - `authorize.go` - Implements the authorization flow
  - `metadata.go` - Provides OAuth2 metadata endpoints
  - `registration.go` - Handles dynamic client registration
  - `revoke.go` - Implements token revocation
  - `secrets.go` - Manages secret generation and validation
  - `tokens.go` - Handles token issuance and validation

This refactoring improves code organization and makes the OAuth2 provider functionality more maintainable while preserving all existing behavior.
2025-07-03 20:24:45 +02:00
Thomas Kosiewski 7fbb3ced5b feat: add MCP HTTP server experiment and improve experiment middleware (#18712)
# Add MCP HTTP Server Experiment

This PR adds a new experiment flag `mcp-server-http` to enable the MCP HTTP server functionality. The changes include:

1. Added a new experiment constant `ExperimentMCPServerHTTP` with the value "mcp-server-http"
2. Added display name and documentation for the new experiment
3. Improved the experiment middleware to:
   - Support requiring multiple experiments
   - Provide better error messages with experiment display names
   - Add a development mode bypass option
4. Applied the new experiment requirement to the MCP HTTP endpoint
5. Replaced the custom OAuth2 middleware with the standard experiment middleware

The PR also improves the `Enabled()` method on the `Experiments` type by using `slices.Contains()` for better readability.
2025-07-03 20:09:18 +02:00
Thomas Kosiewski 15551541e8 feat: add OAuth2 provider functionality as an experiment (#18692)
# Add OAuth2 Provider Functionality as an Experiment

This PR adds a new experiment flag `oauth2` that enables OAuth2 provider functionality in Coder. When enabled, this experiment allows Coder to act as an OAuth2 provider.

The changes include:
- Added the new `ExperimentOAuth2` constant with appropriate documentation
- Updated the OAuth2 provider middleware to check for the experiment flag
- Modified the error message to indicate that the OAuth2 provider requires enabling the experiment
- Added the new experiment to the known experiments list in the SDK

Previously, OAuth2 provider functionality was only available in development mode. With this change, it can be enabled in production environments by activating the experiment.
2025-07-03 19:44:29 +02:00
blink-so[bot] 2c95a1dd71 chore: update gofumpt from v0.4.0 to v0.8.0 (#18652) 2025-07-03 11:28:00 -06:00
Thomas Kosiewski 494dccc510 feat: implement MCP HTTP server endpoint with authentication (#18670)
# Add MCP HTTP server with streamable transport support

- Add MCP HTTP server with streamable transport support
- Integrate with existing toolsdk for Coder workspace operations
- Add comprehensive E2E tests with OAuth2 bearer token support
- Register MCP endpoint at /api/experimental/mcp/http with authentication
- Support RFC 6750 Bearer token authentication for MCP clients

Change-Id: Ib9024569ae452729908797c42155006aa04330af
Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-07-03 19:27:41 +02:00
Thomas Kosiewski 60b08f0960 fix: remove unique constraint on OAuth2 provider app names (#18669)
# Remove unique constraint on OAuth2 provider app names

This PR removes the unique constraint on the `name` field in the `oauth2_provider_apps` table to comply with RFC 7591, which only requires unique client IDs, not unique client names.

Changes include:
- Removing the unique constraint from the database schema
- Adding migration files for both up and down migrations
- Removing the name uniqueness check in the in-memory database implementation
- Updating the unique constraint constants

Change-Id: Iae7a1a06546fbc8de541a52e291f8a4510d57e8a
Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-07-03 19:13:13 +02:00
Jaayden Halko 90a875d916 chore: implement tests for dynamic parameter component (#18745) 2025-07-03 13:09:59 -04:00
Thomas Kosiewski 4dcf0c3e7e docs: add comprehensive development documentation (#18646)
# Organize Development Documentation into Separate Files

This PR reorganizes the development documentation by splitting the monolithic CLAUDE.md file into multiple focused documents. The main file now provides a concise overview with essential commands and critical patterns, while importing detailed content from specialized guides.

Key improvements:
- Created separate documentation files for specific domains:
  - Database development patterns
  - OAuth2 implementation guidelines
  - Testing best practices
  - Troubleshooting common issues
  - Development workflows and guidelines
- Restructured the main CLAUDE.md to be more scannable with improved formatting
- Added quick-reference tables for common commands
- Maintained all existing content while making it more accessible
- Highlighted critical patterns that must be followed

This organization makes the documentation more maintainable and easier to navigate, allowing developers to quickly find relevant information for their specific tasks.
2025-07-03 18:51:23 +02:00
Thomas Kosiewski 74e1d5c4b6 feat: implement OAuth2 dynamic client registration (RFC 7591/7592) (#18645)
# Implement OAuth2 Dynamic Client Registration (RFC 7591/7592)

This PR implements OAuth2 Dynamic Client Registration according to RFC 7591 and Client Configuration Management according to RFC 7592. These standards allow OAuth2 clients to register themselves programmatically with Coder as an authorization server.

Key changes include:

1. Added database schema extensions to support RFC 7591/7592 fields in the `oauth2_provider_apps` table
2. Implemented `/oauth2/register` endpoint for dynamic client registration (RFC 7591)
3. Added client configuration management endpoints (RFC 7592):
   - GET/PUT/DELETE `/oauth2/clients/{client_id}`
   - Registration access token validation middleware

4. Added comprehensive validation for OAuth2 client metadata:
   - URI validation with support for custom schemes for native apps
   - Grant type and response type validation
   - Token endpoint authentication method validation

5. Enhanced developer documentation with:
   - RFC compliance guidelines
   - Testing best practices to avoid race conditions
   - Systematic debugging approaches for OAuth2 implementations

The implementation follows security best practices from the RFCs, including proper token handling, secure defaults, and appropriate error responses. This enables third-party applications to integrate with Coder's OAuth2 provider capabilities programmatically.
2025-07-03 18:33:47 +02:00
Steven Masley 699dd8e554 chore: create interface for pkgs to return codersdk errors (#18719)
This interface allows it to create rich codersdk errors and pass them up to the `wsbuilder` error handling.
2025-07-03 08:33:45 -05:00
Mathias Fredriksson 7d412c2272 feat(examples/templates): add docker-devcontainer template and rename envbuilder template (#18741)
This change adds a new `docker-devcontainer` template which allows you
to provision a workspace running in Docker, that also creates workspaces
via Docker running inside (DinD).

- **chore(examples/templates): rename `docker-devcontainer` to
`docker-envbuilder`**
- **feat(examples/templates): add `docker-devcontainer` example
template**
2025-07-03 15:50:08 +03:00
Mathias Fredriksson 8b6d70bf1f fix(site): update vs code dev container button URLs (#18696) 2025-07-03 15:03:05 +03:00
Atif Ali 351745752b docs: update release calendar with 2.24 release (#18742) 2025-07-03 11:20:16 +00:00
Jaayden Halko 61b6562f9a feat: display descriptions in multi-select component (#18730)
<img width="528" alt="Screenshot 2025-07-02 at 23 06 51"
src="https://github.com/user-attachments/assets/d6223d99-bc1b-4325-8eb6-d87a687bcec8"
/>
2025-07-03 05:55:20 -04:00
Atif Ali db8ed007f9 chore: add rdp icon (#18736) 2025-07-03 08:22:02 +02:00
Ethan 7500aa4d6c fix(cli): calculate coder ping max correctly (#18734)
Embarassing mistake I made months ago 😦 

*Doesn't effect schmoder, since we don't parse that max, it calculates it itself
2025-07-03 13:22:54 +10:00
Rowan Smith 6db6f48300 chore: fix broken link in docs (#18733)
Fixes the "Helm README" link on
https://coder.com/docs/install/kubernetes so it goes to the right path.

Side note: I don't see any content in
https://coder.com/docs/about/contributing/documentation about to whom
such a PR should be assigned, if any. Edward was suggested and I see
you've worked on other PR's with the `docs` label, so going with that.
2025-07-02 22:34:29 -04:00
Thomas Kosiewski 09c50559f3 feat: implement RFC 6750 Bearer token authentication (#18644)
# Add RFC 6750 Bearer Token Authentication Support

This PR implements RFC 6750 Bearer Token authentication as an additional authentication method for Coder's API. This allows clients to authenticate using standard OAuth 2.0 Bearer tokens in two ways:

1. Using the `Authorization: Bearer <token>` header
2. Using the `access_token` query parameter

Key changes:

- Added support for extracting tokens from both Bearer headers and access_token query parameters
- Implemented proper WWW-Authenticate headers for 401/403 responses with appropriate error descriptions
- Added comprehensive test coverage for the new authentication methods
- Updated the OAuth2 protected resource metadata endpoint to advertise Bearer token support
- Enhanced the OAuth2 testing script to verify Bearer token functionality

These authentication methods are added as fallback options, maintaining backward compatibility with Coder's existing authentication mechanisms. The existing authentication methods (cookies, session token header, etc.) still take precedence.

This implementation follows the OAuth 2.0 Bearer Token specification (RFC 6750) and improves interoperability with standard OAuth 2.0 clients.
2025-07-02 19:14:54 +02:00
Hugo Dutka eade5b019b fix: handle null response from the template presets endpoint (#18723)
The template presets endpoint returns a null response when a template
version does not define any presets.
2025-07-02 19:08:33 +02:00
Thomas Kosiewski 33bbf18a4b feat: add OAuth2 protected resource metadata endpoint for RFC 9728 (#18643)
# Add OAuth2 Protected Resource Metadata Endpoint

This PR implements the OAuth2 Protected Resource Metadata endpoint according to RFC 9728. The endpoint is available at `/.well-known/oauth-protected-resource` and provides information about Coder as an OAuth2 protected resource.

Key changes:
- Added a new endpoint at `/.well-known/oauth-protected-resource` that returns metadata about Coder as an OAuth2 protected resource
- Created a new `OAuth2ProtectedResourceMetadata` struct in the SDK
- Added tests to verify the endpoint functionality
- Updated API documentation to include the new endpoint

The implementation currently returns basic metadata including the resource identifier and authorization server URL. The `scopes_supported` field is empty until a scope system based on RBAC permissions is implemented. The `bearer_methods_supported` field is omitted as Coder uses custom authentication methods rather than standard RFC 6750 bearer tokens.

A TODO has been added to implement RFC 6750 bearer token support in the future.
2025-07-02 18:58:41 +02:00
Thomas Kosiewski 1b73b1a12f docs: add Go LSP MCP configs and tools guide for code navigation (#18613)
# Add Code Navigation and Investigation Guide for Go LSP Tools

Added a new section to the CLAUDE.md documentation that explains how to use Go Language Server Protocol (LSP) tools when working with the Coder codebase. The guide includes:

- Commands for finding function definitions, symbol references, and getting symbol information
- Examples of LSP usage with specific commands
- Guidance on when to use LSP versus other tools like grep or bash
- A structured investigation strategy for navigating the codebase, starting with route registration and tracing through to implementations

This documentation helps developers more efficiently explore and understand the codebase structure.
2025-07-02 18:43:35 +02:00
Cian Johnston 630804ec92 chore: fix duplicate migration 000345 (#18721)
Fixes duplicate migration introduced by
https://github.com/coder/coder/pull/18575
2025-07-02 16:15:10 +00:00
Thomas Kosiewski f0c9c4dbcd feat: oauth2 - add RFC 8707 resource indicators and audience validation (#18575)
This pull request implements RFC 8707, Resource Indicators for OAuth 2.0 (https://datatracker.ietf.org/doc/html/rfc8707), to enhance the security of our OAuth 2.0 provider. 

This change enables proper audience validation and binds access tokens to their intended resource, which is crucial
  for preventing token misuse in multi-tenant environments or deployments with multiple resource servers.

##  Key Changes:


   * Resource Parameter Support: Adds support for the resource parameter in both the authorization (`/oauth2/authorize`) and token (`/oauth2/token`) endpoints, allowing clients to specify the intended resource server.
   * Audience Validation: Implements server-side validation to ensure that the resource parameter provided during the token exchange matches the one from the authorization request.
   * API Middleware Enforcement: Introduces a new validation step in the API authentication middleware (`coderd/httpmw/apikey.go`) to verify that the audience of the access token matches the resource server being accessed.
   * Database Schema Updates:
       * Adds a `resource_uri` column to the `oauth2_provider_app_codes` table to store the resource requested during authorization.
       * Adds an `audience` column to the `oauth2_provider_app_tokens` table to bind the issued token to a specific audience.
   * Enhanced PKCE: Includes a minor enhancement to the PKCE implementation to protect against timing attacks.
   * Comprehensive Testing: Adds extensive new tests to `coderd/oauth2_test.go` to cover various RFC 8707 scenarios, including valid flows, mismatched resources, and refresh token validation.

##  How it Works:


   1. An OAuth2 client specifies the target resource (e.g., https://coder.example.com) using the resource parameter in the authorization request.
   2. The authorization server stores this resource URI with the authorization code.
   3. During the token exchange, the server validates that the client provides the same resource parameter.
   4. The server issues an access token with an audience claim set to the validated resource URI.
   5. When the client uses the access token to call an API endpoint, the middleware verifies that the token's audience matches the URL of the Coder deployment, rejecting any tokens intended for a different resource.


  This ensures that a token issued for one Coder deployment cannot be used to access another, significantly strengthening our authentication security.

---

Change-Id: I3924cb2139e837e3ac0b0bd40a5aeb59637ebc1b
Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-07-02 17:49:00 +02:00
Sas Swart 01163ea57b feat: allow users to pause prebuilt workspace reconciliation (#18700)
This PR provides two commands:
* `coder prebuilds pause`
* `coder prebuilds resume`

These allow the suspension of all prebuilds activity, intended for use
if prebuilds are misbehaving.
2025-07-02 15:05:42 +00:00
Steven Masley 4072d228c5 feat: support dynamic parameters on create template request (#18636)
Future work is to add this checkbox to the UI to opt into dynamic
parameters from the first template create.
2025-07-02 09:44:01 -05:00
blink-so[bot] 91aa583ea4 docs: mention Windsurf module in Windsurf documentation (#18715)
Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: bpmct <22407953+bpmct@users.noreply.github.com>
2025-07-02 19:13:35 +05:00
Spike Curtis 59c8b560fa test: add test that we close stdin on SSH session close (#18711)
closes #18519

Adds a unit test that verifies that we close the stdin to a non-TTY process when the SSH session connected to it exits.

c.f. https://github.com/coder/coder/issues/18519#issuecomment-3027609871

Validates that we match OpenSSH behavior.
2025-07-02 16:23:07 +04:00
Mathias Fredriksson 8a69f6af17 fix(agent/agentcontainers): avoid logspam in API updaterLoop (#18710)
Fixes #18709
2025-07-02 14:29:45 +03:00
Atif Ali 0b8ed9c2bd docs: move the duplicate Coder Desktop install warning to Troubleshooting (#18691)
Co-authored-by: Edward Angert <EdwardAngert@users.noreply.github.com>
2025-07-02 11:22:58 +00:00
ケイラ 0b82f41a24 feat: allow masking workspace parameter inputs (#18595) 2025-07-01 16:27:43 -06:00
ケイラ d22ac1cf65 chore: don't cache errors in file cache (#18555) 2025-07-01 13:50:37 -06:00
Edward Angert ab254adfb9 docs: add section about how to disable path based apps to security best practices (#18419)
add a new section specifically about how to disable path-based apps to
the security best practices doc

## todo

- [x] copy review
- [x] cross-linking

---------

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
Co-authored-by: Dean Sheather <dean@deansheather.com>
2025-07-01 13:18:47 -04:00
Garrett Delfosse d14e9be0fe feat: add Coder registry links to template creation and editing (#18680)
## Summary
- Add "Browse Templates" card to starter templates page
- Add "Browse Modules" button to template editor topbar
- Both link to https://registry.coder.com as requested in #18141

<img width="1248" alt="Screenshot 2025-07-01 at 9 29 26 AM"
src="https://github.com/user-attachments/assets/2295e45c-2056-41cd-a39e-48d4379295be"
/>
<img width="943" alt="Screenshot 2025-07-01 at 9 29 45 AM"
src="https://github.com/user-attachments/assets/e0652b76-43bf-4794-825d-72b4fe7c5e5f"
/>



🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-01 13:18:27 -04:00
Mathias Fredriksson 1158ca25bf fix(dogfood/coder): run go clean cache at workspace shutdown (#18685)
The Go build cache has a tendency to accumulate and waste space
(typically in the realm of 10-70 GB). This change automatically cleans
up the cache on shutdown to prevent accumulation.
2025-07-01 15:22:26 +01:00
Thomas Kosiewski 6f2834f62a feat: oauth2 - add authorization server metadata endpoint and PKCE support (#18548)
## Summary

  This PR implements critical MCP OAuth2 compliance features for Coder's authorization server, adding PKCE support, resource parameter handling, and OAuth2 server metadata discovery. This brings Coder's OAuth2 implementation significantly closer to production readiness for MCP (Model Context Protocol)
  integrations.

  ## What's Added

  ### OAuth2 Authorization Server Metadata (RFC 8414)
  - Add `/.well-known/oauth-authorization-server` endpoint for automatic client discovery
  - Returns standardized metadata including supported grant types, response types, and PKCE methods
  - Essential for MCP client compatibility and OAuth2 standards compliance

  ### PKCE Support (RFC 7636)
  - Implement Proof Key for Code Exchange with S256 challenge method
  - Add `code_challenge` and `code_challenge_method` parameters to authorization flow
  - Add `code_verifier` validation in token exchange
  - Provides enhanced security for public clients (mobile apps, CLIs)

  ### Resource Parameter Support (RFC 8707)
  - Add `resource` parameter to authorization and token endpoints
  - Store resource URI and bind tokens to specific audiences
  - Critical for MCP's resource-bound token model

  ### Enhanced OAuth2 Error Handling
  - Add OAuth2-compliant error responses with proper error codes
  - Use standard error format: `{"error": "code", "error_description": "details"}`
  - Improve error consistency across OAuth2 endpoints

  ### Authorization UI Improvements
  - Fix authorization flow to use POST-based consent instead of GET redirects
  - Remove dependency on referer headers for security decisions
  - Improve CSRF protection with proper state parameter validation

  ## Why This Matters

  **For MCP Integration:** MCP requires OAuth2 authorization servers to support PKCE, resource parameters, and metadata discovery. Without these features, MCP clients cannot securely authenticate with Coder.

  **For Security:** PKCE prevents authorization code interception attacks, especially critical for public clients. Resource binding ensures tokens are only valid for intended services.

  **For Standards Compliance:** These are widely adopted OAuth2 extensions that improve interoperability with modern OAuth2 clients.

  ## Database Changes

  - **Migration 000343:** Adds `code_challenge`, `code_challenge_method`, `resource_uri` to `oauth2_provider_app_codes`
  - **Migration 000343:** Adds `audience` field to `oauth2_provider_app_tokens` for resource binding
  - **Audit Updates:** New OAuth2 fields properly tracked in audit system
  - **Backward Compatibility:** All changes maintain compatibility with existing OAuth2 flows

  ## Test Coverage

  - Comprehensive PKCE test suite in `coderd/identityprovider/pkce_test.go`
  - OAuth2 metadata endpoint tests in `coderd/oauth2_metadata_test.go`
  - Integration tests covering PKCE + resource parameter combinations
  - Negative tests for invalid PKCE verifiers and malformed requests

  ## Testing Instructions

  ```bash
  # Run the comprehensive OAuth2 test suite
  ./scripts/oauth2/test-mcp-oauth2.sh

  Manual Testing with Interactive Server

  # Start Coder in development mode
  ./scripts/develop.sh

  # In another terminal, set up test app and run interactive flow
  eval $(./scripts/oauth2/setup-test-app.sh)
  ./scripts/oauth2/test-manual-flow.sh
  # Opens browser with OAuth2 flow, handles callback automatically

  # Clean up when done
  ./scripts/oauth2/cleanup-test-app.sh

  Individual Component Testing

  # Test metadata endpoint
  curl -s http://localhost:3000/.well-known/oauth-authorization-server | jq .

  # Test PKCE generation
  ./scripts/oauth2/generate-pkce.sh

  # Run specific test suites
  go test -v ./coderd/identityprovider -run TestVerifyPKCE
  go test -v ./coderd -run TestOAuth2AuthorizationServerMetadata
```

  ### Breaking Changes

  None. All changes maintain backward compatibility with existing OAuth2 flows.

---

Change-Id: Ifbd0d9a543d545f9f56ecaa77ff2238542ff954a
Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-07-01 15:39:29 +02:00
Cian Johnston dbfbef6ecb chore(cli): increase reconciliation interval to 1 minute (#18690)
Increase prebuilds reconciliation and backoff interval to 1 minute by
default.
2025-07-01 14:35:02 +01:00
Susana Ferreira 57a6d59d8d docs: add warning about prebuilds incompatibility with certain features (#18689)
## Description

This PR adds a warning to the prebuilds documentation about
incompatibility with Workspace schedule (autostart/autostop), dormancy,
and DevContainers. These configurations can interfere with prebuild
behavior and should be avoided for now.

Preview:
![Screenshot 2025-07-01 at 12 58
02](https://github.com/user-attachments/assets/e1a837de-b66c-4414-bd0b-471474b43b84)
2025-07-01 13:59:07 +01:00
Cian Johnston 4e95b1d20e fix: revert changes to GetRunningPrebuiltWorkspaces (#18688)
… (#18588)"

This reverts commit 258a839d27.
2025-07-01 10:11:43 +00:00
Hugo Dutka 3d22e27f4e fix: handle task sidebar app health check disabled correctly (#18687)
Previously, by mistake, the task sidebar would not display workspace
apps that don't have a health check configured.
2025-07-01 12:01:17 +02:00
Danielle Maywood 7e372f7a35 fix(agent/agentcontainers): reset error at start of rebuild (#18686)
Reset the error associated with a devcontainer when a rebuild is requested.
2025-07-01 10:57:43 +01:00
Cian Johnston 258a839d27 chore(coderd/database): optimize GetRunningPrebuiltWorkspaces (#18588)
Fixes https://github.com/coder/internal/issues/715

After this change, the only use of the `workspace_prebuilds` view is the
`ClaimPrebuiltWorkspace` query. A subsequent PR will update the view.

Before: ~44ms https://explain.dalibo.com/plan/76cbe21d1a4c9329#plan

After: 7.3ms https://explain.dalibo.com/plan/5abbdf926315677e#plan
2025-07-01 09:42:01 +01:00
Danny Kopping 0f56f0029b chore: add which-release script (#18657) 2025-07-01 08:05:44 +00:00
Kacper Sawicki 695de6e0c0 chore(coderd/database): optimize AuditLogs queries (#18600)
Closes #17689

This PR optimizes the audit logs query performance by extracting the
count operation into a separate query and replacing the OR-based
workspace_builds with conditional joins.

## Query changes
* Extracted count query to separate one
* Replaced single `workspace_builds` join with OR conditions with
separate conditional joins
* Added conditional joins
* `wb_build` for workspace_build audit logs (which is a direct lookup)
    * `wb_workspace` for workspace create audit logs (via workspace)

Optimized AuditLogsOffset query:
https://explain.dalibo.com/plan/4g1hbedg4a564bg8

New CountAuditLogs query:
https://explain.dalibo.com/plan/ga2fbcecb9efbce3
2025-07-01 07:31:14 +02:00
Perdjesk 74e1953619 docs: bitnami/postgresql primary prefix for persistence.size config key (#18446)
The `bitnami/postgresql`chart doesn't have a value with key
`persistence.size`. The correct value key which control the size of the
PVC is `primary.persistence.size`.

See:
-
https://github.com/bitnami/charts/blob/postgresql/16.7.12/bitnami/postgresql/values.yaml
- The JSON schema,
[`values.schema.json`](https://github.com/bitnami/charts/blob/postgresql/16.7.12/bitnami/postgresql/values.schema.json)
of the
[`values.yaml`](https://github.com/bitnami/charts/blob/postgresql/16.7.12/bitnami/postgresql/values.yaml)
included in the chart is out of sync.
https://github.com/bitnami/readme-generator-for-helm/issues/142
2025-06-30 16:55:57 -04:00
Danielle Maywood 4756080eb2 feat(site): display devcontainer start error (#18637)
Fixes https://github.com/coder/internal/issues/705

Surface errors on the UI when a devcontainer agent is unable to be
injected.
2025-06-30 21:34:29 +01:00
Asher fc7700a62f fix: improve reliability of app statuses (#18622)
We were discarding all "working" updates from the screen watcher because
we cannot tell the difference between the agent or user changing the
screen, but it makes sense to accept it as the very first update,
because the agent could be working but neglected to report that fact, so
you would never get an initial "working" update (it would just
eventually go straight to "idle").

Also messages can start at zero, so I made a fix for that as well,
although the first message will be from the LLM and we ignore
those anyway, so this probably has no actual effect, but seems more
technically correct.

And it seems I forgot to actually update the last message ID, which 
also does not actually matter for user messages (since I think the
SSE endpoint will not re-emit a user message it has already emitted),
but seems more technically correct to check.

Lastly, if we have the screen watcher, ignore the agent's self-reported
state and always use "working" since it is unreliable.  The idle state will
eventually be caught by the watcher.
2025-06-30 12:12:20 -08:00
Jaayden Halko ad6773360c fix: display error message on delete workspace error (#18654)
resolves coder/preview#155

When deleting a workspace, show an error dialog if deleting the
workspace is not possible.

![Screenshot 2025-06-28 at 10 06
47](https://github.com/user-attachments/assets/650bfb54-6ed9-4f41-a410-1333afeee0a4)
2025-06-30 15:09:51 -04:00
Hugo Dutka 22c5e84a7e fix: handle health status when displaying task apps (#18675)
Previously, we displayed apps in iframes on the task page without
waiting for them to initialize. This would result in 502 errors shown to
the user. This PR makes sure that we only display the app after it
initializes.

### Before
<img width="1920" alt="Screenshot 2025-06-30 at 14 59 07 (2)"
src="https://github.com/user-attachments/assets/63564ac9-abce-4a0c-b58e-b988772fae82"
/>
2025-06-30 20:46:28 +02:00
Spike Curtis b7cb275d7e fix: stop tearing down non-TTY processes on SSH session end (#18673)
(possibly temporary) fix for #18519

Matches OpenSSH for non-tty sessions, where we don't actively terminate
the process.

Adds explicit tracking to the SSH server for these processes so that if
we are shutting down we terminate them: this ensures that we can shut
down quickly to allow shutdown scripts to run. It also ensures our tests
don't leak system resources.
2025-06-30 22:06:05 +04:00
Mathias Fredriksson 9ccaf86099 fix(agent/agentcontainers): always derive devcontainer name from workspace folder (#18666) 2025-06-30 20:56:39 +03:00
Vladislav Rudskoy 715c7b0c24 chore: correct RD limitation comment (#18668)
subj
2025-06-30 22:46:00 +05:00
Atif Ali b1e8d5d5e0 docs: remove beta label from Coder Desktop (#18651)
Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: Edward Angert <EdwardAngert@users.noreply.github.com>
2025-06-30 21:23:09 +05:00
dependabot[bot] 851cda55d6 ci: bump the github-actions group with 3 updates (#18665)
Bumps the github-actions group with 3 updates:
[step-security/harden-runner](https://github.com/step-security/harden-runner),
[fluxcd/flux2](https://github.com/fluxcd/flux2) and
[github/codeql-action](https://github.com/github/codeql-action).

Updates `step-security/harden-runner` from 2.12.1 to 2.12.2
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/step-security/harden-runner/releases">step-security/harden-runner's
releases</a>.</em></p>
<blockquote>
<h2>v2.12.2</h2>
<h2>What's Changed</h2>
<p>Added HTTPS Monitoring for additional destinations -
*.githubusercontent.com
Bug fixes:</p>
<ul>
<li>Implicitly allow local multicast, local unicast and broadcast IP
addresses in block mode</li>
<li>Increased policy map size for block mode</li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/step-security/harden-runner/compare/v2...v2.12.2">https://github.com/step-security/harden-runner/compare/v2...v2.12.2</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/step-security/harden-runner/commit/6c439dc8bdf85cadbbce9ed30d1c7b959517bc49"><code>6c439dc</code></a>
Merge pull request <a
href="https://redirect.github.com/step-security/harden-runner/issues/562">#562</a>
from step-security/rc-22</li>
<li><a
href="https://github.com/step-security/harden-runner/commit/bf5688696d0b2cf8221eadb38e4232386015763a"><code>bf56886</code></a>
update agent</li>
<li><a
href="https://github.com/step-security/harden-runner/commit/5436dac7b5fa76a1a179168f5f4de86c00e22c84"><code>5436dac</code></a>
update agent</li>
<li><a
href="https://github.com/step-security/harden-runner/commit/88d305a3530acfa6d1939000baaa571e520df9c8"><code>88d305a</code></a>
update agent</li>
<li><a
href="https://github.com/step-security/harden-runner/commit/b976878278dbe3bc16039f7165b8faf809c50297"><code>b976878</code></a>
update agent</li>
<li><a
href="https://github.com/step-security/harden-runner/commit/875cc92db280a03598e7492a3e6c165c689f7af6"><code>875cc92</code></a>
Update agent</li>
<li>See full diff in <a
href="https://github.com/step-security/harden-runner/compare/002fdce3c6a235733a90a27c80493a3241e56863...6c439dc8bdf85cadbbce9ed30d1c7b959517bc49">compare
view</a></li>
</ul>
</details>
<br />

Updates `fluxcd/flux2` from 2.6.2 to 2.6.3
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/fluxcd/flux2/releases">fluxcd/flux2's
releases</a>.</em></p>
<blockquote>
<h2>v2.6.3</h2>
<h2>Highlights</h2>
<p>Flux v2.6.3 is a patch release that comes with various fixes. Users
are encouraged to upgrade for the best experience.</p>
<p>Fixes:</p>
<ul>
<li>Fix for <code>rsa-sha2-512</code> and <code>rsa-sha2-256</code>
algorithms not being prioritized for <code>ssh-rsa</code> host keys in
source-controller, image-automation-controller and Flux CLI
bootstrap.</li>
</ul>
<h2>Components changelog</h2>
<ul>
<li>source-controller <a
href="https://github.com/fluxcd/source-controller/blob/v1.6.2/CHANGELOG.md">v1.6.2</a></li>
<li>image-automation-controller <a
href="https://github.com/fluxcd/image-automation-controller/blob/v0.41.2/CHANGELOG.md">v0.41.2</a></li>
</ul>
<h2>CLI changed</h2>
<ul>
<li>[release/v2.6.x] Update toolkit components by <a
href="https://github.com/fluxcdbot"><code>@​fluxcdbot</code></a> in <a
href="https://redirect.github.com/fluxcd/flux2/pull/5427">fluxcd/flux2#5427</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/fluxcd/flux2/compare/v2.6.2...v2.6.3">https://github.com/fluxcd/flux2/compare/v2.6.2...v2.6.3</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/fluxcd/flux2/commit/bda4c8187e436462be0d072e728b67afa215c593"><code>bda4c81</code></a>
Merge pull request <a
href="https://redirect.github.com/fluxcd/flux2/issues/5427">#5427</a>
from fluxcd/backport-5426-to-release/v2.6.x</li>
<li><a
href="https://github.com/fluxcd/flux2/commit/3f281da7381e3984913244d78b9768e4fa5fbb65"><code>3f281da</code></a>
Fix: Prioritize sha2-512 and sha2-256 for ssh-rsa host keys</li>
<li><a
href="https://github.com/fluxcd/flux2/commit/963e99188cb0a77dfbe70a3db7a34c0f6e159dd3"><code>963e991</code></a>
Update toolkit components</li>
<li>See full diff in <a
href="https://github.com/fluxcd/flux2/compare/a48f81a66c4ca9fbd993233ab99dd03a7cfbe09a...bda4c8187e436462be0d072e728b67afa215c593">compare
view</a></li>
</ul>
</details>
<br />

Updates `github/codeql-action` from 3.29.0 to 3.29.1
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/github/codeql-action/releases">github/codeql-action's
releases</a>.</em></p>
<blockquote>
<h2>v3.29.1</h2>
<h1>CodeQL Action Changelog</h1>
<p>See the <a
href="https://github.com/github/codeql-action/releases">releases
page</a> for the relevant changes to the CodeQL CLI and language
packs.</p>
<h2>3.29.1 - 27 Jun 2025</h2>
<ul>
<li>Fix bug in PR analysis where user-provided <code>include</code>
query filter fails to exclude non-included queries. <a
href="https://redirect.github.com/github/codeql-action/pull/2938">#2938</a></li>
<li>Update default CodeQL bundle version to 2.22.1. <a
href="https://redirect.github.com/github/codeql-action/pull/2950">#2950</a></li>
</ul>
<p>See the full <a
href="https://github.com/github/codeql-action/blob/v3.29.1/CHANGELOG.md">CHANGELOG.md</a>
for more information.</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/github/codeql-action/blob/main/CHANGELOG.md">github/codeql-action's
changelog</a>.</em></p>
<blockquote>
<h1>CodeQL Action Changelog</h1>
<p>See the <a
href="https://github.com/github/codeql-action/releases">releases
page</a> for the relevant changes to the CodeQL CLI and language
packs.</p>
<h2>[UNRELEASED]</h2>
<ul>
<li>Experimental: When the <code>quality-queries</code> input for the
<code>init</code> action is provided with an argument, separate
<code>.quality.sarif</code> files are produced and uploaded for each
language with the results of the specified queries. Do not use this in
production as it is part of an internal experiment and subject to change
at any time. <a
href="https://redirect.github.com/github/codeql-action/pull/2935">#2376</a></li>
</ul>
<h2>3.29.1 - 27 Jun 2025</h2>
<ul>
<li>Fix bug in PR analysis where user-provided <code>include</code>
query filter fails to exclude non-included queries. <a
href="https://redirect.github.com/github/codeql-action/pull/2938">#2938</a></li>
<li>Update default CodeQL bundle version to 2.22.1. <a
href="https://redirect.github.com/github/codeql-action/pull/2950">#2950</a></li>
</ul>
<h2>3.29.0 - 11 Jun 2025</h2>
<ul>
<li>Update default CodeQL bundle version to 2.22.0. <a
href="https://redirect.github.com/github/codeql-action/pull/2925">#2925</a></li>
<li>Bump minimum CodeQL bundle version to 2.16.6. <a
href="https://redirect.github.com/github/codeql-action/pull/2912">#2912</a></li>
</ul>
<h2>3.28.19 - 03 Jun 2025</h2>
<ul>
<li>The CodeQL Action no longer includes its own copy of the extractor
for the <code>actions</code> language, which is currently in public
preview.
The <code>actions</code> extractor has been included in the CodeQL CLI
since v2.20.6. If your workflow has enabled the <code>actions</code>
language <em>and</em> you have pinned
your <code>tools:</code> property to a specific version of the CodeQL
CLI earlier than v2.20.6, you will need to update to at least CodeQL
v2.20.6 or disable
<code>actions</code> analysis.</li>
<li>Update default CodeQL bundle version to 2.21.4. <a
href="https://redirect.github.com/github/codeql-action/pull/2910">#2910</a></li>
</ul>
<h2>3.28.18 - 16 May 2025</h2>
<ul>
<li>Update default CodeQL bundle version to 2.21.3. <a
href="https://redirect.github.com/github/codeql-action/pull/2893">#2893</a></li>
<li>Skip validating SARIF produced by CodeQL for improved performance.
<a
href="https://redirect.github.com/github/codeql-action/pull/2894">#2894</a></li>
<li>The number of threads and amount of RAM used by CodeQL can now be
set via the <code>CODEQL_THREADS</code> and <code>CODEQL_RAM</code>
runner environment variables. If set, these environment variables
override the <code>threads</code> and <code>ram</code> inputs
respectively. <a
href="https://redirect.github.com/github/codeql-action/pull/2891">#2891</a></li>
</ul>
<h2>3.28.17 - 02 May 2025</h2>
<ul>
<li>Update default CodeQL bundle version to 2.21.2. <a
href="https://redirect.github.com/github/codeql-action/pull/2872">#2872</a></li>
</ul>
<h2>3.28.16 - 23 Apr 2025</h2>
<ul>
<li>Update default CodeQL bundle version to 2.21.1. <a
href="https://redirect.github.com/github/codeql-action/pull/2863">#2863</a></li>
</ul>
<h2>3.28.15 - 07 Apr 2025</h2>
<ul>
<li>Fix bug where the action would fail if it tried to produce a debug
artifact with more than 65535 files. <a
href="https://redirect.github.com/github/codeql-action/pull/2842">#2842</a></li>
</ul>
<h2>3.28.14 - 07 Apr 2025</h2>
<ul>
<li>Update default CodeQL bundle version to 2.21.0. <a
href="https://redirect.github.com/github/codeql-action/pull/2838">#2838</a></li>
</ul>
<h2>3.28.13 - 24 Mar 2025</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/github/codeql-action/commit/39edc492dbe16b1465b0cafca41432d857bdb31a"><code>39edc49</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/2953">#2953</a>
from github/update-v3.29.1-428aea55f</li>
<li><a
href="https://github.com/github/codeql-action/commit/27c4fb1eef772029c0bbeed96d8538a2af79e541"><code>27c4fb1</code></a>
Update changelog for v3.29.1</li>
<li><a
href="https://github.com/github/codeql-action/commit/428aea55f52aac0db14530fe4e5c97462c533f7d"><code>428aea5</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/2952">#2952</a>
from github/redsun82/fix-swift-test</li>
<li><a
href="https://github.com/github/codeql-action/commit/973250f3d233f50890a597fef853ae3b2a538a31"><code>973250f</code></a>
Swift: recreate a default Swift package to fix test</li>
<li><a
href="https://github.com/github/codeql-action/commit/8ef17824cfb2a3f40cbc7f41bac7e055e53b8164"><code>8ef1782</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/2950">#2950</a>
from github/update-bundle/codeql-bundle-v2.22.1</li>
<li><a
href="https://github.com/github/codeql-action/commit/f3bfb9860305f6e80e048f4785d6bee33bf77356"><code>f3bfb98</code></a>
Add changelog note</li>
<li><a
href="https://github.com/github/codeql-action/commit/2b4afc20b636de8884609ee2a501a68a67766f26"><code>2b4afc2</code></a>
Update default bundle to codeql-bundle-v2.22.1</li>
<li><a
href="https://github.com/github/codeql-action/commit/9b02dc2f60288b463e7a66e39c78829b62780db7"><code>9b02dc2</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/2928">#2928</a>
from github/update-supported-enterprise-server-versions</li>
<li><a
href="https://github.com/github/codeql-action/commit/7ab92d0295a9b09eb653169acdb2c24f7c43614a"><code>7ab92d0</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/2948">#2948</a>
from github/mbg/copilot-instructions</li>
<li><a
href="https://github.com/github/codeql-action/commit/2cae828745579fc9309404e09440d23bba2f7b79"><code>2cae828</code></a>
Merge pull request <a
href="https://redirect.github.com/github/codeql-action/issues/2947">#2947</a>
from github/dependency-proxy/codeql-bundle-v2.22.0</li>
<li>Additional commits viewable in <a
href="https://github.com/github/codeql-action/compare/ce28f5bb42b7a9f2c824e633a3f6ee835bab6858...39edc492dbe16b1465b0cafca41432d857bdb31a">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-30 15:37:51 +00:00
dependabot[bot] 7f23be3874 chore: bump github.com/andybalholm/brotli from 1.1.1 to 1.2.0 (#18661)
Bumps
[github.com/andybalholm/brotli](https://github.com/andybalholm/brotli)
from 1.1.1 to 1.2.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/andybalholm/brotli/commit/676a02057d90cd1e75ede54cdfa79d4cdb574dae"><code>676a020</code></a>
Pathfinder: improve cost calculation, and use it in NewWriterV2</li>
<li><a
href="https://github.com/andybalholm/brotli/commit/fc701daacf9eec30cae7a5cec6e5e38827894d4c"><code>fc701da</code></a>
Pathfinder: change how literals are represented in arrivals.</li>
<li><a
href="https://github.com/andybalholm/brotli/commit/10cf712196eeb5358c7c2dddf1f53c08b6500f38"><code>10cf712</code></a>
Pathfinder: enable starting in the middle of a match</li>
<li><a
href="https://github.com/andybalholm/brotli/commit/d6b3fe07ed7eb3cfe0c42ab708781034a326d7fa"><code>d6b3fe0</code></a>
Pathfinder: separate searching and parsing</li>
<li><a
href="https://github.com/andybalholm/brotli/commit/199839b04846152833e2446e39cf6234712163a2"><code>199839b</code></a>
Pathfinder: pre-compute hash chain (and use 32 bits)</li>
<li><a
href="https://github.com/andybalholm/brotli/commit/e819531509efd8c7d5e79efd9fcabc655c7fbebc"><code>e819531</code></a>
Start experimenting with an optimizing MatchFinder</li>
<li><a
href="https://github.com/andybalholm/brotli/commit/18ac46a8c3d6664cd158ad14ca2fb6ba29752377"><code>18ac46a</code></a>
M4: use 32-bit hash chain</li>
<li><a
href="https://github.com/andybalholm/brotli/commit/1383db2f0e5a87e62c33bb5adf22351ee2acf50a"><code>1383db2</code></a>
M4: When shortening a match, look for a closer option</li>
<li><a
href="https://github.com/andybalholm/brotli/commit/c036c35cb06f667df542773635b0972cd794d2ea"><code>c036c35</code></a>
M4: look for repeat matches</li>
<li><a
href="https://github.com/andybalholm/brotli/commit/6a1a95ec91781f0eedba50cd865eb822ba7e90c7"><code>6a1a95e</code></a>
Add arm64 to GOARCH switches</li>
<li>Additional commits viewable in <a
href="https://github.com/andybalholm/brotli/compare/v1.1.1...v1.2.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/andybalholm/brotli&package-manager=go_modules&previous-version=1.1.1&new-version=1.2.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-30 14:08:44 +00:00
dependabot[bot] c8bc8d3865 chore: bump github.com/moby/moby from 28.2.2+incompatible to 28.3.0+incompatible (#18660)
Bumps [github.com/moby/moby](https://github.com/moby/moby) from
28.2.2+incompatible to 28.3.0+incompatible.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/moby/moby/releases">github.com/moby/moby's
releases</a>.</em></p>
<blockquote>
<h2>28.3.0</h2>
<p>For a full list of pull requests and changes in this release, refer
to the relevant GitHub milestones:</p>
<ul>
<li><a
href="https://github.com/docker/cli/issues?q=is%3Aclosed+milestone%3A28.3.0">docker/cli,
28.3.0 milestone</a></li>
<li><a
href="https://github.com/moby/moby/issues?q=is%3Aclosed+milestone%3A28.3.0">moby/moby,
28.3.0 milestone</a></li>
<li>Deprecated and removed features, see <a
href="https://github.com/docker/cli/blob/v28.3.0/docs/deprecated.md">Deprecated
Features</a>.</li>
<li>Changes to the Engine API, see <a
href="https://github.com/moby/moby/blob/v28.3.0/docs/api/version-history.md">API
version history</a>.</li>
</ul>
<h3>New</h3>
<ul>
<li>Add support for AMD GPUs in <code>docker run --gpus</code>. <a
href="https://redirect.github.com/moby/moby/pull/49952">moby/moby#49952</a></li>
<li>Use <code>DOCKER_AUTH_CONFIG</code> as a credential store. <a
href="https://redirect.github.com/docker/cli/pull/6008">docker/cli#6008</a></li>
</ul>
<h3>Bug fixes and enhancements</h3>
<ul>
<li>Ensure that the state of the container in the daemon database (used
by <a
href="https://docs.docker.com/reference/api/engine/version/v1.49/#tag/Container/operation/ContainerList">/containers/json</a>
API) is up to date when the container is stopped using the <a
href="https://docs.docker.com/reference/api/engine/version/v1.49/#tag/Container/operation/ContainerStop">/containers/{id}/stop</a>
API (before response of API). <a
href="https://redirect.github.com/moby/moby/pull/50136">moby/moby#50136</a></li>
<li>Fix <code>docker image inspect inspect</code> omitting empty fields.
<a
href="https://redirect.github.com/moby/moby/pull/50135">moby/moby#50135</a></li>
<li>Fix <code>docker images --tree</code> not marking images as in-use
when the containerd image store is disabled. <a
href="https://redirect.github.com/docker/cli/pull/6140">docker/cli#6140</a></li>
<li>Fix <code>docker pull/push</code> hang in non-interactive when
authentication is required caused by prompting for login credentials. <a
href="https://redirect.github.com/docker/cli/pull/6141">docker/cli#6141</a></li>
<li>Fix a potential resource leak when a node leaves a Swarm. <a
href="https://redirect.github.com/moby/moby/pull/50115">moby/moby#50115</a></li>
<li>Fix a regression where a login prompt on <code>docker pull</code>
would show Docker Hub-specific hints when logging in on other
registries. <a
href="https://redirect.github.com/docker/cli/pull/6135">docker/cli#6135</a></li>
<li>Fix an issue where all new tasks in the Swarm could get stuck in the
PENDING state forever after scaling up a service with placement
preferences. <a
href="https://redirect.github.com/moby/moby/pull/50211">moby/moby#50211</a></li>
<li>Remove an undocumented, hidden, top-level <code>docker remove</code>
command that was accidentally introduced in Docker 23.0. <a
href="https://redirect.github.com/docker/cli/pull/6144">docker/cli#6144</a></li>
<li>Validate registry-mirrors configuration as part of <code>dockerd
--validate</code> and improve error messages for invalid mirrors. <a
href="https://redirect.github.com/moby/moby/pull/50240">moby/moby#50240</a></li>
<li><code>dockerd-rootless-setuptool.sh</code>: Fix the script from
silently returning with no error message when subuid/subgid system
requirements are not satisfied. <a
href="https://redirect.github.com/moby/moby/pull/50059">moby/moby#50059</a></li>
<li>containerd image store: Fix <code>docker push</code> not creating a
tag on the remote repository. <a
href="https://redirect.github.com/moby/moby/pull/50199">moby/moby#50199</a></li>
<li>containerd image store: Improve handling of errors returned by the
token server during <code>docker pull/push</code>. <a
href="https://redirect.github.com/moby/moby/pull/50176">moby/moby#50176</a></li>
</ul>
<h3>Packaging updates</h3>
<ul>
<li>Allow customizing containerd service name for OpenRC. <a
href="https://redirect.github.com/moby/moby/pull/50156">moby/moby#50156</a></li>
<li>Update BuildKit to <a
href="https://github.com/moby/buildkit/releases/tag/v0.23.1">v0.23.1</a>.
<a
href="https://redirect.github.com/moby/moby/pull/50243">moby/moby#50243</a></li>
<li>Update Buildx to <a
href="https://github.com/docker/buildx/releases/tag/v0.25.0">v0.25.0</a>.
<a
href="https://redirect.github.com/docker/docker-ce-packaging/pull/1217">docker/docker-ce-packaging#1217</a></li>
<li>Update Compose to <a
href="https://github.com/docker/compose/releases/tag/v2.37.2">v2.37.2</a>.
<a
href="https://redirect.github.com/docker/docker-ce-packaging/pull/1219">docker/docker-ce-packaging#1219</a></li>
<li>Update Docker Model CLI plugin to <a
href="https://github.com/docker/model-cli/releases/tag/v0.1.30">v0.1.30</a>.
<a
href="https://redirect.github.com/docker/docker-ce-packaging/pull/1218">docker/docker-ce-packaging#1218</a></li>
<li>Update Go runtime to <a
href="https://go.dev/doc/devel/release#go1.24.4">1.24.4</a>. <a
href="https://redirect.github.com/docker/docker-ce-packaging/pull/1213">docker/docker-ce-packaging#1213</a>,
<a
href="https://redirect.github.com/moby/moby/pull/50153">moby/moby#50153</a>,
<a
href="https://redirect.github.com/docker/cli/pull/6124">docker/cli#6124</a></li>
</ul>
<h3>Networking</h3>
<ul>
<li>Revert Swarm related changes added in 28.2.x builds, due to a
regression reported in <a
href="https://redirect.github.com/moby/moby/issues/50129">moby/moby#50129</a>.
<a
href="https://redirect.github.com/moby/moby/pull/50169">moby/moby#50169</a>
<ul>
<li>Revert: Fix an issue where <code>docker network inspect
--verbose</code> could sometimes crash the daemon (<a
href="https://redirect.github.com/moby/moby/pull/49937">moby/moby#49937</a>).</li>
<li>Revert: Fix an issue where the load-balancer IP address for an
overlay network would not be released in certain cases if the Swarm was
lacking an ingress network (<a
href="https://redirect.github.com/moby/moby/pull/49948">moby/moby#49948</a>).</li>
<li>Revert: Improve the reliability of NetworkDB in busy clusters and
lossy networks (<a
href="https://redirect.github.com/moby/moby/pull/49932">moby/moby#49932</a>).</li>
<li>Revert: Improvements to the reliability and convergence speed of
NetworkDB (<a
href="https://redirect.github.com/moby/moby/pull/49939">moby/moby#49939</a>).</li>
</ul>
</li>
<li>Fix an issue that could cause container startup to fail, or lead to
failed UDP port mappings, when some container ports are mapped to
<code>0.0.0.0</code> and others are mapped to specific host addresses.
<a
href="https://redirect.github.com/moby/moby/pull/50054">moby/moby#50054</a></li>
<li>The <code>network inspect</code> response for an overlay network now
reports that <code>EnableIPv4</code> is true. <a
href="https://redirect.github.com/moby/moby/pull/50147">moby/moby#50147</a></li>
<li>Windows: Improve daemon startup time in cases where the host has
networks of type <code>&quot;Mirrored&quot;</code>. <a
href="https://redirect.github.com/moby/moby/pull/50155">moby/moby#50155</a></li>
<li>Windows: Make sure <code>docker system prune</code> and <code>docker
network prune</code> only remove networks created by Docker. <a
href="https://redirect.github.com/moby/moby/pull/50154">moby/moby#50154</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/moby/moby/commit/265f709647947fb5a1adf7e4f96f2113dcc377bd"><code>265f709</code></a>
Merge pull request <a
href="https://redirect.github.com/moby/moby/issues/50247">#50247</a>
from vvoland/50245-28.x</li>
<li><a
href="https://github.com/moby/moby/commit/b2a9318a1e70deabdf9cda8c08caabd492b6b581"><code>b2a9318</code></a>
docs: cut api docs for v1.51</li>
<li><a
href="https://github.com/moby/moby/commit/b3e2e22b2adee0cff0a20134559074b9481ba2ba"><code>b3e2e22</code></a>
Merge pull request <a
href="https://redirect.github.com/moby/moby/issues/50244">#50244</a>
from vvoland/50177-28.x</li>
<li><a
href="https://github.com/moby/moby/commit/c571cd85133c8e25ce9c9b7eb3a1c8c54f88346e"><code>c571cd8</code></a>
Merge pull request <a
href="https://redirect.github.com/moby/moby/issues/50243">#50243</a>
from vvoland/50238-28.x</li>
<li><a
href="https://github.com/moby/moby/commit/8c713c1af4ad61a9faf8b55e7710b8a17e081275"><code>8c713c1</code></a>
gha: lower timeouts on &quot;build&quot; and &quot;merge&quot;
steps</li>
<li><a
href="https://github.com/moby/moby/commit/539c115023eb01f1dd65b019cd5d50dd36d34188"><code>539c115</code></a>
Merge pull request <a
href="https://redirect.github.com/moby/moby/issues/50240">#50240</a>
from thaJeztah/28.x_backport_validate_mirrors</li>
<li><a
href="https://github.com/moby/moby/commit/8e7ea470cf0720f1988fe9a0af6342d550d86cc3"><code>8e7ea47</code></a>
vendor: update buildkit to v0.23.1</li>
<li><a
href="https://github.com/moby/moby/commit/222baf4ccbcb216fe812ad0300d02dfec3f28a70"><code>222baf4</code></a>
vendor: github.com/moby/buildkit v0.23.0</li>
<li><a
href="https://github.com/moby/moby/commit/1627e828d7e5566ead2c69f63d661ef47f96e61a"><code>1627e82</code></a>
Merge pull request <a
href="https://redirect.github.com/moby/moby/issues/50241">#50241</a>
from thaJeztah/28.x_backport_update_cgroups</li>
<li><a
href="https://github.com/moby/moby/commit/4070ebda88cb8f6448d0725633dc40394e563705"><code>4070ebd</code></a>
Merge pull request <a
href="https://redirect.github.com/moby/moby/issues/50242">#50242</a>
from thaJeztah/28.x_backport_fix_event_ordering</li>
<li>Additional commits viewable in <a
href="https://github.com/moby/moby/compare/v28.2.2...v28.3.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/moby/moby&package-manager=go_modules&previous-version=28.2.2+incompatible&new-version=28.3.0+incompatible)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-30 14:03:08 +00:00
Danny Kopping f89e057c4c chore: add beta badge to tasks (#18656) 2025-06-30 10:51:42 +02:00
Mathias Fredriksson d814fdfa1c fix(.devcontainer): add home volume and fix code-server and filebrowser (#18648) 2025-06-30 09:32:17 +01:00
Spike Curtis e97540afbd chore: work around race in lib/pq (#18655)
Upgrade our lib/pq fork to work around the data race identified here:
https://github.com/coder/internal/issues/731
2025-06-30 12:00:46 +04:00
Bruno Quaresma 4095330041 fix: use only template version ID to create task workspace (#18642)
When creating a new task, the following error was getting returned:

**Error:**
```json
{
    "message": "Validation failed.",
    "validations": [
        {
            "field": "template_id",
            "detail": "Validation failed for tag \"excluded_with\" with value: \"42205a38-845c-4186-8475-f002e0936d53\""
        },
        {
            "field": "template_version_id",
            "detail": "Validation failed for tag \"excluded_with\" with value: \"22b1c4b7-432d-4eb5-9341-cd8efacb8f46\""
        }
    ]
}
```

Caused by https://github.com/coder/coder/pull/18623
2025-06-27 15:07:54 -03:00
ケイラ d4208d23aa refactor: show icons for multi-select parameter options (#18594) 2025-06-27 10:54:47 -06:00
dependabot[bot] 5ae21517e0 chore: bump github.com/go-viper/mapstructure/v2 from 2.2.1 to 2.3.0 (#18647)
Bumps
[github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure)
from 2.2.1 to 2.3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/go-viper/mapstructure/releases">github.com/go-viper/mapstructure/v2's
releases</a>.</em></p>
<blockquote>
<h2>v2.3.0</h2>
<h2>What's Changed</h2>
<ul>
<li>build(deps): bump actions/checkout from 4.1.7 to 4.2.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/46">go-viper/mapstructure#46</a></li>
<li>build(deps): bump golangci/golangci-lint-action from 6.1.0 to 6.1.1
by <a href="https://github.com/dependabot"><code>@​dependabot</code></a>
in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/47">go-viper/mapstructure#47</a></li>
<li>[enhancement] Add check for <code>reflect.Value</code> in
<code>ComposeDecodeHookFunc</code> by <a
href="https://github.com/mahadzaryab1"><code>@​mahadzaryab1</code></a>
in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/52">go-viper/mapstructure#52</a></li>
<li>build(deps): bump actions/setup-go from 5.0.2 to 5.1.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/51">go-viper/mapstructure#51</a></li>
<li>build(deps): bump actions/checkout from 4.2.0 to 4.2.2 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/50">go-viper/mapstructure#50</a></li>
<li>build(deps): bump actions/setup-go from 5.1.0 to 5.2.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/55">go-viper/mapstructure#55</a></li>
<li>build(deps): bump actions/setup-go from 5.2.0 to 5.3.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/58">go-viper/mapstructure#58</a></li>
<li>ci: add Go 1.24 to the test matrix by <a
href="https://github.com/sagikazarmark"><code>@​sagikazarmark</code></a>
in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/74">go-viper/mapstructure#74</a></li>
<li>build(deps): bump golangci/golangci-lint-action from 6.1.1 to 6.5.0
by <a href="https://github.com/dependabot"><code>@​dependabot</code></a>
in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/72">go-viper/mapstructure#72</a></li>
<li>build(deps): bump golangci/golangci-lint-action from 6.5.0 to 6.5.1
by <a href="https://github.com/dependabot"><code>@​dependabot</code></a>
in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/76">go-viper/mapstructure#76</a></li>
<li>build(deps): bump actions/setup-go from 5.3.0 to 5.4.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/78">go-viper/mapstructure#78</a></li>
<li>feat: add decode hook for netip.Prefix by <a
href="https://github.com/tklauser"><code>@​tklauser</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/85">go-viper/mapstructure#85</a></li>
<li>Updates by <a
href="https://github.com/sagikazarmark"><code>@​sagikazarmark</code></a>
in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/86">go-viper/mapstructure#86</a></li>
<li>build(deps): bump github/codeql-action from 2.13.4 to 3.28.15 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/87">go-viper/mapstructure#87</a></li>
<li>build(deps): bump actions/setup-go from 5.4.0 to 5.5.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/93">go-viper/mapstructure#93</a></li>
<li>build(deps): bump github/codeql-action from 3.28.15 to 3.28.17 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/92">go-viper/mapstructure#92</a></li>
<li>build(deps): bump github/codeql-action from 3.28.17 to 3.28.19 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/97">go-viper/mapstructure#97</a></li>
<li>build(deps): bump ossf/scorecard-action from 2.4.1 to 2.4.2 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/96">go-viper/mapstructure#96</a></li>
<li>Update README.md by <a
href="https://github.com/peczenyj"><code>@​peczenyj</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/90">go-viper/mapstructure#90</a></li>
<li>Add omitzero tag. by <a
href="https://github.com/Crystalix007"><code>@​Crystalix007</code></a>
in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/98">go-viper/mapstructure#98</a></li>
<li>Use error structs instead of duplicated strings by <a
href="https://github.com/m1k1o"><code>@​m1k1o</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/102">go-viper/mapstructure#102</a></li>
<li>build(deps): bump github/codeql-action from 3.28.19 to 3.29.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/101">go-viper/mapstructure#101</a></li>
<li>feat: add common error interface by <a
href="https://github.com/sagikazarmark"><code>@​sagikazarmark</code></a>
in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/105">go-viper/mapstructure#105</a></li>
<li>update linter by <a
href="https://github.com/sagikazarmark"><code>@​sagikazarmark</code></a>
in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/106">go-viper/mapstructure#106</a></li>
<li>Feature allow unset pointer by <a
href="https://github.com/rostislaved"><code>@​rostislaved</code></a> in
<a
href="https://redirect.github.com/go-viper/mapstructure/pull/80">go-viper/mapstructure#80</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/tklauser"><code>@​tklauser</code></a>
made their first contribution in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/85">go-viper/mapstructure#85</a></li>
<li><a href="https://github.com/peczenyj"><code>@​peczenyj</code></a>
made their first contribution in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/90">go-viper/mapstructure#90</a></li>
<li><a
href="https://github.com/Crystalix007"><code>@​Crystalix007</code></a>
made their first contribution in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/98">go-viper/mapstructure#98</a></li>
<li><a
href="https://github.com/rostislaved"><code>@​rostislaved</code></a>
made their first contribution in <a
href="https://redirect.github.com/go-viper/mapstructure/pull/80">go-viper/mapstructure#80</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/go-viper/mapstructure/compare/v2.2.1...v2.3.0">https://github.com/go-viper/mapstructure/compare/v2.2.1...v2.3.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/go-viper/mapstructure/commit/8c61ec1924fcfa522f9fc6b4618c672db61d1a38"><code>8c61ec1</code></a>
Merge pull request <a
href="https://redirect.github.com/go-viper/mapstructure/issues/80">#80</a>
from rostislaved/feature-allow-unset-pointer</li>
<li><a
href="https://github.com/go-viper/mapstructure/commit/df765f469ad16a1996fd0f0ae6a32b20535b966a"><code>df765f4</code></a>
Merge pull request <a
href="https://redirect.github.com/go-viper/mapstructure/issues/106">#106</a>
from go-viper/update-linter</li>
<li><a
href="https://github.com/go-viper/mapstructure/commit/5f34b05aa12639380ef7c2af69eb6f8fd629dbd0"><code>5f34b05</code></a>
update linter</li>
<li><a
href="https://github.com/go-viper/mapstructure/commit/36de1e1d74f55681536097ff8467a8ce952ef183"><code>36de1e1</code></a>
Merge pull request <a
href="https://redirect.github.com/go-viper/mapstructure/issues/105">#105</a>
from go-viper/error-refactor</li>
<li><a
href="https://github.com/go-viper/mapstructure/commit/6a283a390ee7bc0f9331f58199db234902e0739f"><code>6a283a3</code></a>
chore: update error type doc</li>
<li><a
href="https://github.com/go-viper/mapstructure/commit/599cb73236404c044abcf278a45c3928d7480dd0"><code>599cb73</code></a>
Merge pull request <a
href="https://redirect.github.com/go-viper/mapstructure/issues/101">#101</a>
from go-viper/dependabot/github_actions/github/codeql...</li>
<li><a
href="https://github.com/go-viper/mapstructure/commit/ed3f92181528ff776a0324107b8b55026e93766a"><code>ed3f921</code></a>
feat: remove value from error messages</li>
<li><a
href="https://github.com/go-viper/mapstructure/commit/a3f8b227dcdae324c070d389152837f0aa635f4b"><code>a3f8b22</code></a>
revert: error message change</li>
<li><a
href="https://github.com/go-viper/mapstructure/commit/9661f6d07c319da00ae0508d99df5f3f0c3953bd"><code>9661f6d</code></a>
feat: add common error interface</li>
<li><a
href="https://github.com/go-viper/mapstructure/commit/f12f6c76fe743c8e4cc6465c6a9f16fcd8cede57"><code>f12f6c7</code></a>
Merge pull request <a
href="https://redirect.github.com/go-viper/mapstructure/issues/102">#102</a>
from m1k1o/prettify-errors2</li>
<li>Additional commits viewable in <a
href="https://github.com/go-viper/mapstructure/compare/v2.2.1...v2.3.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/go-viper/mapstructure/v2&package-manager=go_modules&previous-version=2.2.1&new-version=2.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts page](https://github.com/coder/coder/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-27 16:52:24 +00:00
blink-so[bot] ff3ff0170a chore: update logo description to specify maximum 3:1 aspect ratio (#18641)
Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
2025-06-27 16:38:44 +00:00
Bruno Quaresma 8eebb4fa4c feat: make task panels resizable (#18590)
**Demo:**

https://github.com/user-attachments/assets/cc80b768-197e-42a0-9326-f30c9d9038e3
2025-06-27 13:34:04 -03:00
Mathias Fredriksson 0f3a1e9849 fix(agent/agentcontainers): split Init into Init and Start for early API responses (#18640)
Previously in #18635 we delayed the containers API `Init` to avoid producing
errors due to Docker and `@devcontainers/cli` not yet being installed by startup
scripts. This had an adverse effect on the UX via UI responsiveness as the
detection of devcontainers was greatly delayed.

This change splits `Init` into `Init` and `Start` so that we can immediately
after `Init` start serving known devcontainers (defined in Terraform), improving
the UX.

Related #18635
Related #18640
2025-06-27 19:01:50 +03:00
Mathias Fredriksson e46d892c29 fix(.devcontainer): remove double slash from zed path (#18639) 2025-06-27 18:34:08 +03:00
Mathias Fredriksson b4aa643dfa fix(agent/agentcontainers): ensure proper channel closure for updateTrigger (#18631) 2025-06-27 18:05:48 +03:00
Bruno Quaresma 6d305df67d fix: use default preset when creating a workspace for task (#18623) 2025-06-27 12:01:21 -03:00
Bruno Quaresma 29ef3a8ed6 feat: redirect to the task page after creation (#18626)
Close https://github.com/coder/coder/issues/18184
2025-06-27 14:45:42 +00:00
Bruno Quaresma 1c87796b33 refactor: show the apps as soon as possible (#18625)
Close https://github.com/coder/coder/issues/18617
2025-06-27 14:00:18 +00:00
Mathias Fredriksson 8ee2668b39 fix(agent): fix script filtering for devcontainers (#18635) 2025-06-27 16:59:31 +03:00
Bruno Quaresma 59a65415b4 refactor: move required external auth buttons to the submit side (#18586)
**Before:**
![Screenshot 2025-06-25 at 14 40
16](https://github.com/user-attachments/assets/cbc558f5-6eee-4133-afc9-2474f04a8a67)

**After:**
![Screenshot 2025-06-25 at 14 53
53](https://github.com/user-attachments/assets/3a638f60-d1e4-40a4-a066-8d69fe96c198)
2025-06-27 10:44:39 -03:00
Bruno Quaresma 2d44add81f feat: add task link in the workspace page when it is running a task (#18591)
![image](https://github.com/user-attachments/assets/4db64031-17a9-405c-a233-df2b758ddef5)
2025-06-27 10:32:57 -03:00
Spike Curtis f0251dfc91 chore: retry postgres connection on reset by peer in tests (#18632)
Fixes https://github.com/coder/internal/issues/695

Retries initial connection to postgres in testing up to 3 seconds if we
see "reset by peer", which probably means that some other test proc just
started the container.

---------

Co-authored-by: Hugo Dutka <hugo@coder.com>
2025-06-27 13:03:32 +00:00
Edward Angert d26d0fc269 docs: edit descriptions in ai-coder section (#18373)
Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
2025-06-27 12:09:02 +00:00
Spike Curtis a02d5a69e7 chore: update X11 forward session usage when there is a connection (#18567)
fixes #18263

Adds support to bump `usedAt` for X11 forwarding sessions whenever an application connects over the TCP socket. This should help avoid evicting sessions that are actually in use.
2025-06-27 15:41:45 +04:00
Spike Curtis 73c742a3ce chore: test eviction with used ports (#18566)
relates to #18263

Modifies the eviction unit test to include a port that is already claimed by an external process.
2025-06-27 15:27:38 +04:00
Spike Curtis 66f22d7588 chore: add unit test for X11 eviction (#18565)
relates to #18263


Adds a unit test for X11 listener eviction when all ports in the allowed range are in use.
2025-06-27 15:13:30 +04:00
Mathias Fredriksson 7e99fb7d7e fix(agent): delay containerAPI init to ensure startup scripts run before (#18630) 2025-06-27 14:10:35 +03:00
Susana Ferreira 3cb9b20b11 chore: improve rbac and add benchmark tooling (#18584)
## Description

This PR improves the RBAC package by refactoring the policy, enhancing
documentation, and adding utility scripts.

## Changes

* Refactored `policy.rego` for clarity and readability
* Updated README with OPA section
* Added `benchmark_authz.sh` script for authz performance testing and
comparison
* Added `gen_input.go` to generate input for `opa eval` testing
2025-06-27 12:05:34 +01:00
Spike Curtis a5bfb200fc chore: refactor TestServer_X11 to use inproc networking (#18564)
relates to #18263


Refactors the x11Forwarder to accept a networking `interface` that we can fake out for testing. This isolates the unit tests from other processes listening in the port range used by X11 forwarding. This will become extremely important in up-stack PRs where we listen on every port in the range and need to control which ports have conflicts.
2025-06-27 14:56:33 +04:00
Spike Curtis abcf3df71a chore: move InProcNet to testutil (#18563)
Moves `InProcNet` to `testutil` so that it can be reused by X11 forwarding tests (see up stack PRs).
2025-06-27 14:42:22 +04:00
Spike Curtis 6bebfd0ec6 fix: use memmap file system for TestServer_X11 (#18562)
Changes the TestServer_X11 test to use a memmapped file system, so we don't pollute the XAuthority file of the person running the test.
2025-06-27 14:24:07 +04:00
Spike Curtis 9e1cf1693b fix: cap max X11 forwarding ports and evict old (#18561)
partial for #18263

Caps the X11 forwarding sessions at a maximum port of 6200, and evicts the oldest session if we create new sessions while at the max.

Unit tests included higher in the stack.
2025-06-27 14:05:42 +04:00
Ethan 9ab9c52de8 chore(site): set server.allowedHosts in storybook config to .coder (#18598)
This lets you browse storybook using a Coder Desktop hostname (i.e. `workspace.coder:6006`). The default configuration (including `localhost`) will still work.
2025-06-27 12:59:58 +10:00
Asher 05f6d69455 chore: parse app status link (#18439)
No actual exploit here as far as I can tell, but doing a string check
without parsing was flagged by a scanner.
2025-06-26 13:04:11 -08:00
Mathias Fredriksson d5e34195b0 revert: fix(agent/agentcontainers): refresh containers before status change (#18624)
Reverts coder/coder#18620

This fix exacerbated the problem, reverting until a better fix can be made.
2025-06-26 20:51:06 +00:00
Mathias Fredriksson 7b0b6498fb fix(.devcontainer): start docker and install devcontainer CLI (#18621)
This change starts the Docker daemon in the devcontainer and install
`@devcontainers/cli`.
2025-06-26 20:17:59 +00:00
Mathias Fredriksson 73879056f9 fix(agent/agentcontainers): refresh containers before status change (#18620)
The previous method of refreshing after we change the devcontainer
status introduced an intermediary state where the devcontainer might not
yet have been assigned a container and will flicker as stopped before
going into running.
2025-06-26 20:12:50 +00:00
Jon Ayers 7a3a6d4d26 chore: update README logos (#18619) 2025-06-26 19:27:17 +00:00
Mathias Fredriksson 4f44dd08a9 fix(agent/agentcontainers): prevent reassigning proc.agent until successful (#18609) 2025-06-26 21:30:21 +03:00
ケイラ 09cc906981 chore: remove unnecessary redeclarations in for loops (part 2) (#18593) 2025-06-26 12:28:00 -06:00
Mathias Fredriksson e03d13211c test(agent): fix TestAgent_DevcontainerRecreate (#18618) 2025-06-26 17:50:53 +00:00
Thomas Kosiewski 1b1d09158d fix: pin Nix version to 2.28.4 to avoid JSON type error (#18612)
Pin Nix version to 2.28.4 in dogfood workflow

Pins the Nix version in the dogfood workflow to 2.28.4 to avoid a JSON type error that occurs with Nix 2.29 and above.

Change-Id: Ie024d5070dbe5901952fc52463c6602363ef8886
Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-06-26 18:33:44 +02:00
Danielle Maywood 98c77fece5 fix(agent/agentcontainers): stop logging empty lines (#18605)
This PR makes the devcontainer logs have fewer whitespace lines.
2025-06-26 15:58:10 +00:00
Danielle Maywood 5ae320e79e fix(agent/agentcontainers): chown coder binary (#18611)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-26 16:42:43 +01:00
Mathias Fredriksson 87d052ea93 feat(.devcontainer): add cursor, filebrowser, windsurf and zed (#18608) 2025-06-26 14:09:31 +00:00
Sas Swart c6e0ba12d3 feat: graduate prebuilds to general availability (#18607)
This PR removes the prebuilds experiment and allows the use of prebuilds
without opting into an experiment.
2025-06-26 15:54:52 +02:00
Mathias Fredriksson 872aef3af9 feat(.devcontainer): install dotfiles if present (#18606) 2025-06-26 12:49:58 +00:00
Danielle Maywood f2d229eed3 fix!: use devcontainer ID when rebuilding a devcontainer (#18604)
This PR replaces the use of the **container** ID with the
**devcontainer** ID. This is a breaking change. This allows rebuilding a
devcontainer when there is no valid container ID.
2025-06-26 11:41:57 +01:00
Mathias Fredriksson eca6381314 feat(agent/agentcontainers): add more envs to readconfig for app URL building (#18603) 2025-06-26 09:33:58 +00:00
Sas Swart 634144f94a fix: hide the preset parameter visibility switch when it has no effect (#18574)
When no preset is selected:
<img width="1097" alt="Screenshot 2025-06-25 at 15 49 51"
src="https://github.com/user-attachments/assets/96f1244a-58f1-4e59-b6ac-9319339c764f"
/>

When a preset is selected:
<img width="1097" alt="Screenshot 2025-06-25 at 15 50 00"
src="https://github.com/user-attachments/assets/d0853169-ff93-4b1a-beaf-11012a9a02fb"
/>

Existing frontend stories provide enough validation to cover this
feature. No further testing is required.

---------

Co-authored-by: Susana Ferreira <susana@coder.com>
2025-06-26 11:23:10 +02:00
Atif Ali fb0e7a21a7 docs: add Coder Desktop to remote desktop docs (#18326)
Co-authored-by: Spike Curtis <spike@coder.com>
2025-06-26 11:16:41 +05:00
Bruno Quaresma fdf458eb19 refactor: remove beta label from 'select a preset' menu (#18538) 2025-06-25 17:09:49 -03:00
Mathias Fredriksson 09e1a8ad99 feat(.devcontainer): add code-server feature to devcontainer.json (#18589) 2025-06-25 21:35:43 +03:00
Asher 48bb534a51 chore: fix idle state icon when disabled (#18554)
When the workspace is off, we set a disabled text/stroke color, but for
the idle icon that also needs a fill, this only changed the outline
making it look weird. Instead, move the disabled logic into the
component so we can apply a matching fill.

I felt it looked too thick with both the outline and fill, so I also
removed the outline.

Really I think maybe the workspace status should be a separate column
rather than disabling these icons, but this maintains the status quo.


Before with mismatching stroke and fill color:


![screenshot](https://github.com/user-attachments/assets/961014b7-1e26-49f0-aa87-834f2f367618)


After with disabled fill and stroke removal:


![screenshot](https://github.com/user-attachments/assets/205e4515-dc01-4437-87ec-a0f8a546da3b)


Enabled fill and stroke removal:


![screenshot](https://github.com/user-attachments/assets/04f5914e-f96c-4c75-8873-e3fc9c854d95)
2025-06-25 10:06:57 -08:00
Danielle Maywood 6c713d5c20 fix(coderd/agentapi): make sub agent slugs more unique (#18581)
The incorrect assumption that slugs were unique per-agent was made when
the subagent API was implemented. Whilst this PR doesn't completely
enforce that, we instead compute a stable hash to prefix the slug that
should provide a reasonable level of probability that the slug will be
unique.
2025-06-25 17:36:23 +01:00
dependabot[bot] aef101ffd3 chore: bump google.golang.org/genai from 0.7.0 to 1.12.0 (#18496)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=google.golang.org/genai&package-manager=go_modules&previous-version=0.7.0&new-version=1.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-25 16:01:53 +00:00
dependabot[bot] 9d2f8dc274 chore: bump github.com/openai/openai-go from 0.1.0-beta.10 to 1.6.0 (#18493)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/openai/openai-go&package-manager=go_modules&previous-version=0.1.0-beta.10&new-version=1.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-25 16:01:29 +00:00
Danny Kopping 8e0b6f8157 chore: upgrade aisdk-go lib, remove vestigial code (#18577) 2025-06-25 17:47:42 +02:00
Steven Masley e396b06c25 feat: allow new immutable parameters for existing workspaces (#18579)
Closes https://github.com/coder/coder/issues/18578
2025-06-25 15:41:53 +00:00
Edward Angert 072c81cd73 docs: remove nested alerts (#18580)
hotfix

removes nested gfm alerts, which is a known ~issue~ feature
https://github.com/orgs/community/discussions/16925#discussioncomment-12043928

Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com>
2025-06-25 15:17:49 +00:00
Mathias Fredriksson 3c4d9206bc feat(agent/agentcontainers): add feature options as envs (#18576) 2025-06-25 14:41:36 +00:00
Danny Kopping 688d2ee3eb chore: remove chats experiment (#18535) 2025-06-25 13:03:32 +00:00
Mathias Fredriksson 9fde8353ad test(agent/agentcontainers): add is a test ignore label to integration tests (#18570) 2025-06-25 11:20:14 +00:00
Mathias Fredriksson 434b54657a fix(agent/agentcontainers): filter out "is test run" devcontainers (#18568) 2025-06-25 11:06:20 +00:00
Cian Johnston 42fd1c1291 ci: cache embedded postgres downloaded binaries (#18477)
Updates CI job definitions to cache downloaded binaries for embedded-postgres.
2025-06-25 12:00:20 +01:00
Danielle Maywood c4e4fe85f9 fix(agent): start devcontainers through agentcontainers package (#18471)
Fixes https://github.com/coder/internal/issues/706

Context for the implementation here
https://github.com/coder/internal/issues/706#issuecomment-2990490282

Synchronously starts dev containers defined in terraform with our
`DevcontainerCLI` abstraction, instead of piggybacking off of our
`agentscripts` package. This gives us more control over logs, instead of
being reliant on packages which may or may not exist in the
user-provided image.
2025-06-25 11:52:50 +01:00
Marcin Tojek f6d9765daf fix(site): storybook: move spyOn to beforeEach (#18559)
Fixes: https://github.com/coder/internal/issues/741
2025-06-25 08:45:55 +00:00
Atif Ali b5316d2b42 docs: fix a warning alert type on toolbox docs (#18560) 2025-06-25 08:21:12 +00:00
Emmanuel Ferdman 312d2a46b4 docs: update Claude's guide (#18523)
## PR Summary
Commit 5df70a613d added by mistake the the
following old line to `CLAUDE.md`:
```
For building Frontend refer to [this document](docs/contributing/frontend.md)
```
This PR removes it.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2025-06-25 05:39:26 +00:00
697 changed files with 47604 additions and 21781 deletions
+218
View File
@@ -0,0 +1,218 @@
# Database Development Patterns
## Database Work Overview
### Database Generation Process
1. Modify SQL files in `coderd/database/queries/`
2. Run `make gen`
3. If errors about audit table, update `enterprise/audit/table.go`
4. Run `make gen` again
5. Run `make lint` to catch any remaining issues
## Migration Guidelines
### Creating Migration Files
**Location**: `coderd/database/migrations/`
**Format**: `{number}_{description}.{up|down}.sql`
- Number must be unique and sequential
- Always include both up and down migrations
### Helper Scripts
| Script | Purpose |
|---------------------------------------------------------------------|-----------------------------------------|
| `./coderd/database/migrations/create_migration.sh "migration name"` | Creates new migration files |
| `./coderd/database/migrations/fix_migration_numbers.sh` | Renumbers migrations to avoid conflicts |
| `./coderd/database/migrations/create_fixture.sh "fixture name"` | Creates test fixtures for migrations |
### Database Query Organization
- **MUST DO**: Any changes to database - adding queries, modifying queries should be done in the `coderd/database/queries/*.sql` files
- **MUST DO**: Queries are grouped in files relating to context - e.g. `prebuilds.sql`, `users.sql`, `oauth2.sql`
- After making changes to any `coderd/database/queries/*.sql` files you must run `make gen` to generate respective ORM changes
## Handling Nullable Fields
Use `sql.NullString`, `sql.NullBool`, etc. for optional database fields:
```go
CodeChallenge: sql.NullString{
String: params.codeChallenge,
Valid: params.codeChallenge != "",
}
```
Set `.Valid = true` when providing values.
## Audit Table Updates
If adding fields to auditable types:
1. Update `enterprise/audit/table.go`
2. Add each new field with appropriate action:
- `ActionTrack`: Field should be tracked in audit logs
- `ActionIgnore`: Field should be ignored in audit logs
- `ActionSecret`: Field contains sensitive data
3. Run `make gen` to verify no audit errors
## Database Architecture
### Core Components
- **PostgreSQL 13+** recommended for production
- **Migrations** managed with `migrate`
- **Database authorization** through `dbauthz` package
### Authorization Patterns
```go
// Public endpoints needing system access (OAuth2 registration)
app, err := api.Database.GetOAuth2ProviderAppByClientID(dbauthz.AsSystemRestricted(ctx), clientID)
// Authenticated endpoints with user context
app, err := api.Database.GetOAuth2ProviderAppByClientID(ctx, clientID)
// System operations in middleware
roles, err := db.GetAuthorizationUserRoles(dbauthz.AsSystemRestricted(ctx), userID)
```
## Common Database Issues
### Migration Issues
1. **Migration conflicts**: Use `fix_migration_numbers.sh` to renumber
2. **Missing down migration**: Always create both up and down files
3. **Schema inconsistencies**: Verify against existing schema
### Field Handling Issues
1. **Nullable field errors**: Use `sql.Null*` types consistently
2. **Missing audit entries**: Update `enterprise/audit/table.go`
### Query Issues
1. **Query organization**: Group related queries in appropriate files
2. **Generated code errors**: Run `make gen` after query changes
3. **Performance issues**: Add appropriate indexes in migrations
## Database Testing
### Test Database Setup
```go
func TestDatabaseFunction(t *testing.T) {
db := dbtestutil.NewDB(t)
// Test with real database
result, err := db.GetSomething(ctx, param)
require.NoError(t, err)
require.Equal(t, expected, result)
}
```
## Best Practices
### Schema Design
1. **Use appropriate data types**: VARCHAR for strings, TIMESTAMP for times
2. **Add constraints**: NOT NULL, UNIQUE, FOREIGN KEY as appropriate
3. **Create indexes**: For frequently queried columns
4. **Consider performance**: Normalize appropriately but avoid over-normalization
### Query Writing
1. **Use parameterized queries**: Prevent SQL injection
2. **Handle errors appropriately**: Check for specific error types
3. **Use transactions**: For related operations that must succeed together
4. **Optimize queries**: Use EXPLAIN to understand query performance
### Migration Writing
1. **Make migrations reversible**: Always include down migration
2. **Test migrations**: On copy of production data if possible
3. **Keep migrations small**: One logical change per migration
4. **Document complex changes**: Add comments explaining rationale
## Advanced Patterns
### Complex Queries
```sql
-- Example: Complex join with aggregation
SELECT
u.id,
u.username,
COUNT(w.id) as workspace_count
FROM users u
LEFT JOIN workspaces w ON u.id = w.owner_id
WHERE u.created_at > $1
GROUP BY u.id, u.username
ORDER BY workspace_count DESC;
```
### Conditional Queries
```sql
-- Example: Dynamic filtering
SELECT * FROM oauth2_provider_apps
WHERE
($1::text IS NULL OR name ILIKE '%' || $1 || '%')
AND ($2::uuid IS NULL OR organization_id = $2)
ORDER BY created_at DESC;
```
### Audit Patterns
```go
// Example: Auditable database operation
func (q *sqlQuerier) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error) {
// Implementation here
// Audit the change
if auditor := audit.FromContext(ctx); auditor != nil {
auditor.Record(audit.UserUpdate{
UserID: arg.ID,
Old: oldUser,
New: newUser,
})
}
return newUser, nil
}
```
## Debugging Database Issues
### Common Debug Commands
```bash
# Check database connection
make test-postgres
# Run specific database tests
go test ./coderd/database/... -run TestSpecificFunction
# Check query generation
make gen
# Verify audit table
make lint
```
### Debug Techniques
1. **Enable query logging**: Set appropriate log levels
2. **Use database tools**: pgAdmin, psql for direct inspection
3. **Check constraints**: UNIQUE, FOREIGN KEY violations
4. **Analyze performance**: Use EXPLAIN ANALYZE for slow queries
### Troubleshooting Checklist
- [ ] Migration files exist (both up and down)
- [ ] `make gen` run after query changes
- [ ] Audit table updated for new fields
- [ ] Nullable fields use `sql.Null*` types
- [ ] Authorization context appropriate for endpoint type
+157
View File
@@ -0,0 +1,157 @@
# OAuth2 Development Guide
## RFC Compliance Development
### Implementing Standard Protocols
When implementing standard protocols (OAuth2, OpenID Connect, etc.):
1. **Fetch and Analyze Official RFCs**:
- Always read the actual RFC specifications before implementation
- Use WebFetch tool to get current RFC content for compliance verification
- Document RFC requirements in code comments
2. **Default Values Matter**:
- Pay close attention to RFC-specified default values
- Example: RFC 7591 specifies `client_secret_basic` as default, not `client_secret_post`
- Ensure consistency between database migrations and application code
3. **Security Requirements**:
- Follow RFC security considerations precisely
- Example: RFC 7592 prohibits returning registration access tokens in GET responses
- Implement proper error responses per protocol specifications
4. **Validation Compliance**:
- Implement comprehensive validation per RFC requirements
- Support protocol-specific features (e.g., custom schemes for native OAuth2 apps)
- Test edge cases defined in specifications
## OAuth2 Provider Implementation
### OAuth2 Spec Compliance
1. **Follow RFC 6749 for token responses**
- Use `expires_in` (seconds) not `expiry` (timestamp) in token responses
- Return proper OAuth2 error format: `{"error": "code", "error_description": "details"}`
2. **Error Response Format**
- Create OAuth2-compliant error responses for token endpoint
- Use standard error codes: `invalid_client`, `invalid_grant`, `invalid_request`
- Avoid generic error responses for OAuth2 endpoints
### PKCE Implementation
- Support both with and without PKCE for backward compatibility
- Use S256 method for code challenge
- Properly validate code_verifier against stored code_challenge
### UI Authorization Flow
- Use POST requests for consent, not GET with links
- Avoid dependency on referer headers for security decisions
- Support proper state parameter validation
### RFC 8707 Resource Indicators
- Store resource parameters in database for server-side validation (opaque tokens)
- Validate resource consistency between authorization and token requests
- Support audience validation in refresh token flows
- Resource parameter is optional but must be consistent when provided
## OAuth2 Error Handling Pattern
```go
// Define specific OAuth2 errors
var (
errInvalidPKCE = xerrors.New("invalid code_verifier")
)
// Use OAuth2-compliant error responses
type OAuth2Error struct {
Error string `json:"error"`
ErrorDescription string `json:"error_description,omitempty"`
}
// Return proper OAuth2 errors
if errors.Is(err, errInvalidPKCE) {
writeOAuth2Error(ctx, rw, http.StatusBadRequest, "invalid_grant", "The PKCE code verifier is invalid")
return
}
```
## Testing OAuth2 Features
### Test Scripts
Located in `./scripts/oauth2/`:
- `test-mcp-oauth2.sh` - Full automated test suite
- `setup-test-app.sh` - Create test OAuth2 app
- `cleanup-test-app.sh` - Remove test app
- `generate-pkce.sh` - Generate PKCE parameters
- `test-manual-flow.sh` - Manual browser testing
Always run the full test suite after OAuth2 changes:
```bash
./scripts/oauth2/test-mcp-oauth2.sh
```
### RFC Protocol Testing
1. **Compliance Test Coverage**:
- Test all RFC-defined error codes and responses
- Validate proper HTTP status codes for different scenarios
- Test protocol-specific edge cases (URI formats, token formats, etc.)
2. **Security Boundary Testing**:
- Test client isolation and privilege separation
- Verify information disclosure protections
- Test token security and proper invalidation
## Common OAuth2 Issues
1. **OAuth2 endpoints returning wrong error format** - Ensure OAuth2 endpoints return RFC 6749 compliant errors
2. **Resource indicator validation failing** - Ensure database stores and retrieves resource parameters correctly
3. **PKCE tests failing** - Verify both authorization code storage and token exchange handle PKCE fields
4. **RFC compliance failures** - Verify against actual RFC specifications, not assumptions
5. **Authorization context errors in public endpoints** - Use `dbauthz.AsSystemRestricted(ctx)` pattern
6. **Default value mismatches** - Ensure database migrations match application code defaults
7. **Bearer token authentication issues** - Check token extraction precedence and format validation
8. **URI validation failures** - Support both standard schemes and custom schemes per protocol requirements
## Authorization Context Patterns
```go
// Public endpoints needing system access (OAuth2 registration)
app, err := api.Database.GetOAuth2ProviderAppByClientID(dbauthz.AsSystemRestricted(ctx), clientID)
// Authenticated endpoints with user context
app, err := api.Database.GetOAuth2ProviderAppByClientID(ctx, clientID)
// System operations in middleware
roles, err := db.GetAuthorizationUserRoles(dbauthz.AsSystemRestricted(ctx), userID)
```
## OAuth2/Authentication Work Patterns
- Types go in `codersdk/oauth2.go` or similar
- Handlers go in `coderd/oauth2.go` or `coderd/identityprovider/`
- Database fields need migration + audit table updates
- Always support backward compatibility
## Protocol Implementation Checklist
Before completing OAuth2 or authentication feature work:
- [ ] Verify RFC compliance by reading actual specifications
- [ ] Implement proper error response formats per protocol
- [ ] Add comprehensive validation for all protocol fields
- [ ] Test security boundaries and token handling
- [ ] Update RBAC permissions for new resources
- [ ] Add audit logging support if applicable
- [ ] Create database migrations with proper defaults
- [ ] Add comprehensive test coverage including edge cases
- [ ] Verify linting compliance
- [ ] Test both positive and negative scenarios
- [ ] Document protocol-specific patterns and requirements
+212
View File
@@ -0,0 +1,212 @@
# Testing Patterns and Best Practices
## Testing Best Practices
### Avoiding Race Conditions
1. **Unique Test Identifiers**:
- Never use hardcoded names in concurrent tests
- Use `time.Now().UnixNano()` or similar for unique identifiers
- Example: `fmt.Sprintf("test-client-%s-%d", t.Name(), time.Now().UnixNano())`
2. **Database Constraint Awareness**:
- Understand unique constraints that can cause test conflicts
- Generate unique values for all constrained fields
- Test name isolation prevents cross-test interference
### Testing Patterns
- Use table-driven tests for comprehensive coverage
- Mock external dependencies
- Test both positive and negative cases
- Use `testutil.WaitLong` for timeouts in tests
### Test Package Naming
- **Test packages**: Use `package_test` naming (e.g., `identityprovider_test`) for black-box testing
## RFC Protocol Testing
### Compliance Test Coverage
1. **Test all RFC-defined error codes and responses**
2. **Validate proper HTTP status codes for different scenarios**
3. **Test protocol-specific edge cases** (URI formats, token formats, etc.)
### Security Boundary Testing
1. **Test client isolation and privilege separation**
2. **Verify information disclosure protections**
3. **Test token security and proper invalidation**
## Test Organization
### Test File Structure
```
coderd/
├── oauth2.go # Implementation
├── oauth2_test.go # Main tests
├── oauth2_test_helpers.go # Test utilities
└── oauth2_validation.go # Validation logic
```
### Test Categories
1. **Unit Tests**: Test individual functions in isolation
2. **Integration Tests**: Test API endpoints with database
3. **End-to-End Tests**: Full workflow testing
4. **Race Tests**: Concurrent access testing
## Test Commands
### Running Tests
| Command | Purpose |
|---------|---------|
| `make test` | Run all Go tests |
| `make test RUN=TestFunctionName` | Run specific test |
| `go test -v ./path/to/package -run TestFunctionName` | Run test with verbose output |
| `make test-postgres` | Run tests with Postgres database |
| `make test-race` | Run tests with Go race detector |
| `make test-e2e` | Run end-to-end tests |
### Frontend Testing
| Command | Purpose |
|---------|---------|
| `pnpm test` | Run frontend tests |
| `pnpm check` | Run code checks |
## Common Testing Issues
### Database-Related
1. **SQL type errors** - Use `sql.Null*` types for nullable fields
2. **Race conditions in tests** - Use unique identifiers instead of hardcoded names
### OAuth2 Testing
1. **PKCE tests failing** - Verify both authorization code storage and token exchange handle PKCE fields
2. **Resource indicator validation failing** - Ensure database stores and retrieves resource parameters correctly
### General Issues
1. **Missing newlines** - Ensure files end with newline character
2. **Package naming errors** - Use `package_test` naming for test files
3. **Log message formatting errors** - Use lowercase, descriptive messages without special characters
## Systematic Testing Approach
### Multi-Issue Problem Solving
When facing multiple failing tests or complex integration issues:
1. **Identify Root Causes**:
- Run failing tests individually to isolate issues
- Use LSP tools to trace through call chains
- Check both compilation and runtime errors
2. **Fix in Logical Order**:
- Address compilation issues first (imports, syntax)
- Fix authorization and RBAC issues next
- Resolve business logic and validation issues
- Handle edge cases and race conditions last
3. **Verification Strategy**:
- Test each fix individually before moving to next issue
- Use `make lint` and `make gen` after database changes
- Verify RFC compliance with actual specifications
- Run comprehensive test suites before considering complete
## Test Data Management
### Unique Test Data
```go
// Good: Unique identifiers prevent conflicts
clientName := fmt.Sprintf("test-client-%s-%d", t.Name(), time.Now().UnixNano())
// Bad: Hardcoded names cause race conditions
clientName := "test-client"
```
### Test Cleanup
```go
func TestSomething(t *testing.T) {
// Setup
client := coderdtest.New(t, nil)
// Test code here
// Cleanup happens automatically via t.Cleanup() in coderdtest
}
```
## Test Utilities
### Common Test Patterns
```go
// Table-driven tests
tests := []struct {
name string
input InputType
expected OutputType
wantErr bool
}{
{
name: "valid input",
input: validInput,
expected: expectedOutput,
wantErr: false,
},
// ... more test cases
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, err := functionUnderTest(tt.input)
if tt.wantErr {
require.Error(t, err)
return
}
require.NoError(t, err)
require.Equal(t, tt.expected, result)
})
}
```
### Test Assertions
```go
// Use testify/require for assertions
require.NoError(t, err)
require.Equal(t, expected, actual)
require.NotNil(t, result)
require.True(t, condition)
```
## Performance Testing
### Load Testing
- Use `scaletest/` directory for load testing scenarios
- Run `./scaletest/scaletest.sh` for performance testing
### Benchmarking
```go
func BenchmarkFunction(b *testing.B) {
for i := 0; i < b.N; i++ {
// Function call to benchmark
_ = functionUnderTest(input)
}
}
```
Run benchmarks with:
```bash
go test -bench=. -benchmem ./package/path
```
+231
View File
@@ -0,0 +1,231 @@
# Troubleshooting Guide
## Common Issues
### Database Issues
1. **"Audit table entry missing action"**
- **Solution**: Update `enterprise/audit/table.go`
- Add each new field with appropriate action (ActionTrack, ActionIgnore, ActionSecret)
- Run `make gen` to verify no audit errors
2. **SQL type errors**
- **Solution**: Use `sql.Null*` types for nullable fields
- Set `.Valid = true` when providing values
- Example:
```go
CodeChallenge: sql.NullString{
String: params.codeChallenge,
Valid: params.codeChallenge != "",
}
```
### Testing Issues
3. **"package should be X_test"**
- **Solution**: Use `package_test` naming for test files
- Example: `identityprovider_test` for black-box testing
4. **Race conditions in tests**
- **Solution**: Use unique identifiers instead of hardcoded names
- Example: `fmt.Sprintf("test-client-%s-%d", t.Name(), time.Now().UnixNano())`
- Never use hardcoded names in concurrent tests
5. **Missing newlines**
- **Solution**: Ensure files end with newline character
- Most editors can be configured to add this automatically
### OAuth2 Issues
6. **OAuth2 endpoints returning wrong error format**
- **Solution**: Ensure OAuth2 endpoints return RFC 6749 compliant errors
- Use standard error codes: `invalid_client`, `invalid_grant`, `invalid_request`
- Format: `{"error": "code", "error_description": "details"}`
7. **Resource indicator validation failing**
- **Solution**: Ensure database stores and retrieves resource parameters correctly
- Check both authorization code storage and token exchange handling
8. **PKCE tests failing**
- **Solution**: Verify both authorization code storage and token exchange handle PKCE fields
- Check `CodeChallenge` and `CodeChallengeMethod` field handling
### RFC Compliance Issues
9. **RFC compliance failures**
- **Solution**: Verify against actual RFC specifications, not assumptions
- Use WebFetch tool to get current RFC content for compliance verification
- Read the actual RFC specifications before implementation
10. **Default value mismatches**
- **Solution**: Ensure database migrations match application code defaults
- Example: RFC 7591 specifies `client_secret_basic` as default, not `client_secret_post`
### Authorization Issues
11. **Authorization context errors in public endpoints**
- **Solution**: Use `dbauthz.AsSystemRestricted(ctx)` pattern
- Example:
```go
// Public endpoints needing system access
app, err := api.Database.GetOAuth2ProviderAppByClientID(dbauthz.AsSystemRestricted(ctx), clientID)
```
### Authentication Issues
12. **Bearer token authentication issues**
- **Solution**: Check token extraction precedence and format validation
- Ensure proper RFC 6750 Bearer Token Support implementation
13. **URI validation failures**
- **Solution**: Support both standard schemes and custom schemes per protocol requirements
- Native OAuth2 apps may use custom schemes
### General Development Issues
14. **Log message formatting errors**
- **Solution**: Use lowercase, descriptive messages without special characters
- Follow Go logging conventions
## Systematic Debugging Approach
### Multi-Issue Problem Solving
When facing multiple failing tests or complex integration issues:
1. **Identify Root Causes**:
- Run failing tests individually to isolate issues
- Use LSP tools to trace through call chains
- Check both compilation and runtime errors
2. **Fix in Logical Order**:
- Address compilation issues first (imports, syntax)
- Fix authorization and RBAC issues next
- Resolve business logic and validation issues
- Handle edge cases and race conditions last
3. **Verification Strategy**:
- Test each fix individually before moving to next issue
- Use `make lint` and `make gen` after database changes
- Verify RFC compliance with actual specifications
- Run comprehensive test suites before considering complete
## Debug Commands
### Useful Debug Commands
| Command | Purpose |
|----------------------------------------------|---------------------------------------|
| `make lint` | Run all linters |
| `make gen` | Generate mocks, database queries |
| `go test -v ./path/to/package -run TestName` | Run specific test with verbose output |
| `go test -race ./...` | Run tests with race detector |
### LSP Debugging
#### Go LSP (Backend)
| Command | Purpose |
|----------------------------------------------------|------------------------------|
| `mcp__go-language-server__definition symbolName` | Find function definition |
| `mcp__go-language-server__references symbolName` | Find all references |
| `mcp__go-language-server__diagnostics filePath` | Check for compilation errors |
| `mcp__go-language-server__hover filePath line col` | Get type information |
#### TypeScript LSP (Frontend)
| Command | Purpose |
|----------------------------------------------------------------------------|------------------------------------|
| `mcp__typescript-language-server__definition symbolName` | Find component/function definition |
| `mcp__typescript-language-server__references symbolName` | Find all component/type usages |
| `mcp__typescript-language-server__diagnostics filePath` | Check for TypeScript errors |
| `mcp__typescript-language-server__hover filePath line col` | Get type information |
| `mcp__typescript-language-server__rename_symbol filePath line col newName` | Rename across codebase |
## Common Error Messages
### Database Errors
**Error**: `pq: relation "oauth2_provider_app_codes" does not exist`
- **Cause**: Missing database migration
- **Solution**: Run database migrations, check migration files
**Error**: `audit table entry missing action for field X`
- **Cause**: New field added without audit table update
- **Solution**: Update `enterprise/audit/table.go`
### Go Compilation Errors
**Error**: `package should be identityprovider_test`
- **Cause**: Test package naming convention violation
- **Solution**: Use `package_test` naming for black-box tests
**Error**: `cannot use X (type Y) as type Z`
- **Cause**: Type mismatch, often with nullable fields
- **Solution**: Use appropriate `sql.Null*` types
### OAuth2 Errors
**Error**: `invalid_client` but client exists
- **Cause**: Authorization context issue
- **Solution**: Use `dbauthz.AsSystemRestricted(ctx)` for public endpoints
**Error**: PKCE validation failing
- **Cause**: Missing PKCE fields in database operations
- **Solution**: Ensure `CodeChallenge` and `CodeChallengeMethod` are handled
## Prevention Strategies
### Before Making Changes
1. **Read the relevant documentation**
2. **Check if similar patterns exist in codebase**
3. **Understand the authorization context requirements**
4. **Plan database changes carefully**
### During Development
1. **Run tests frequently**: `make test`
2. **Use LSP tools for navigation**: Avoid manual searching
3. **Follow RFC specifications precisely**
4. **Update audit tables when adding database fields**
### Before Committing
1. **Run full test suite**: `make test`
2. **Check linting**: `make lint`
3. **Test with race detector**: `make test-race`
## Getting Help
### Internal Resources
- Check existing similar implementations in codebase
- Use LSP tools to understand code relationships
- For Go code: Use `mcp__go-language-server__*` commands
- For TypeScript/React code: Use `mcp__typescript-language-server__*` commands
- Read related test files for expected behavior
### External Resources
- Official RFC specifications for protocol compliance
- Go documentation for language features
- PostgreSQL documentation for database issues
### Debug Information Collection
When reporting issues, include:
1. **Exact error message**
2. **Steps to reproduce**
3. **Relevant code snippets**
4. **Test output (if applicable)**
5. **Environment information** (OS, Go version, etc.)
+223
View File
@@ -0,0 +1,223 @@
# Development Workflows and Guidelines
## Quick Start Checklist for New Features
### Before Starting
- [ ] Run `git pull` to ensure you're on latest code
- [ ] Check if feature touches database - you'll need migrations
- [ ] Check if feature touches audit logs - update `enterprise/audit/table.go`
## Development Server
### Starting Development Mode
- **Use `./scripts/develop.sh` to start Coder in development mode**
- This automatically builds and runs with `--dev` flag and proper access URL
- **⚠️ Do NOT manually run `make build && ./coder server --dev` - use the script instead**
### Development Workflow
1. **Always start with the development script**: `./scripts/develop.sh`
2. **Make changes** to your code
3. **The script will automatically rebuild** and restart as needed
4. **Access the development server** at the URL provided by the script
## Code Style Guidelines
### Go Style
- Follow [Effective Go](https://go.dev/doc/effective_go) and [Go's Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments)
- Create packages when used during implementation
- Validate abstractions against implementations
- **Test packages**: Use `package_test` naming (e.g., `identityprovider_test`) for black-box testing
### Error Handling
- Use descriptive error messages
- Wrap errors with context
- Propagate errors appropriately
- Use proper error types
- Pattern: `xerrors.Errorf("failed to X: %w", err)`
### Naming Conventions
- Use clear, descriptive names
- Abbreviate only when obvious
- Follow Go and TypeScript naming conventions
### Comments
- Document exported functions, types, and non-obvious logic
- Follow JSDoc format for TypeScript
- Use godoc format for Go code
## Database Migration Workflows
### Migration Guidelines
1. **Create migration files**:
- Location: `coderd/database/migrations/`
- Format: `{number}_{description}.{up|down}.sql`
- Number must be unique and sequential
- Always include both up and down migrations
2. **Use helper scripts**:
- `./coderd/database/migrations/create_migration.sh "migration name"` - Creates new migration files
- `./coderd/database/migrations/fix_migration_numbers.sh` - Renumbers migrations to avoid conflicts
- `./coderd/database/migrations/create_fixture.sh "fixture name"` - Creates test fixtures for migrations
3. **Update database queries**:
- **MUST DO**: Any changes to database - adding queries, modifying queries should be done in the `coderd/database/queries/*.sql` files
- **MUST DO**: Queries are grouped in files relating to context - e.g. `prebuilds.sql`, `users.sql`, `oauth2.sql`
- After making changes to any `coderd/database/queries/*.sql` files you must run `make gen` to generate respective ORM changes
4. **Handle nullable fields**:
- Use `sql.NullString`, `sql.NullBool`, etc. for optional database fields
- Set `.Valid = true` when providing values
5. **Audit table updates**:
- If adding fields to auditable types, update `enterprise/audit/table.go`
- Add each new field with appropriate action (ActionTrack, ActionIgnore, ActionSecret)
- Run `make gen` to verify no audit errors
### Database Generation Process
1. Modify SQL files in `coderd/database/queries/`
2. Run `make gen`
3. If errors about audit table, update `enterprise/audit/table.go`
4. Run `make gen` again
5. Run `make lint` to catch any remaining issues
## API Development Workflow
### Adding New API Endpoints
1. **Define types** in `codersdk/` package
2. **Add handler** in appropriate `coderd/` file
3. **Register route** in `coderd/coderd.go`
4. **Add tests** in `coderd/*_test.go` files
5. **Update OpenAPI** by running `make gen`
## Testing Workflows
### Test Execution
- Run full test suite: `make test`
- Run specific test: `make test RUN=TestFunctionName`
- Run with Postgres: `make test-postgres`
- Run with race detector: `make test-race`
- Run end-to-end tests: `make test-e2e`
### Test Development
- Use table-driven tests for comprehensive coverage
- Mock external dependencies
- Test both positive and negative cases
- Use `testutil.WaitLong` for timeouts in tests
- Always use `t.Parallel()` in tests
## Commit Style
- Follow [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/)
- Format: `type(scope): message`
- Types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`
- Keep message titles concise (~70 characters)
- Use imperative, present tense in commit titles
## Code Navigation and Investigation
### Using LSP Tools (STRONGLY RECOMMENDED)
**IMPORTANT**: Always use LSP tools for code navigation and understanding. These tools provide accurate, real-time analysis of the codebase and should be your first choice for code investigation.
#### Go LSP Tools (for backend code)
1. **Find function definitions** (USE THIS FREQUENTLY):
- `mcp__go-language-server__definition symbolName`
- Example: `mcp__go-language-server__definition getOAuth2ProviderAppAuthorize`
- Quickly jump to function implementations across packages
2. **Find symbol references** (ESSENTIAL FOR UNDERSTANDING IMPACT):
- `mcp__go-language-server__references symbolName`
- Locate all usages of functions, types, or variables
- Critical for refactoring and understanding data flow
3. **Get symbol information**:
- `mcp__go-language-server__hover filePath line column`
- Get type information and documentation at specific positions
#### TypeScript LSP Tools (for frontend code in site/)
1. **Find component/function definitions** (USE THIS FREQUENTLY):
- `mcp__typescript-language-server__definition symbolName`
- Example: `mcp__typescript-language-server__definition LoginPage`
- Quickly navigate to React components, hooks, and utility functions
2. **Find symbol references** (ESSENTIAL FOR UNDERSTANDING IMPACT):
- `mcp__typescript-language-server__references symbolName`
- Locate all usages of components, types, or functions
- Critical for refactoring React components and understanding prop usage
3. **Get type information**:
- `mcp__typescript-language-server__hover filePath line column`
- Get TypeScript type information and JSDoc documentation
4. **Rename symbols safely**:
- `mcp__typescript-language-server__rename_symbol filePath line column newName`
- Rename components, props, or functions across the entire codebase
5. **Check for TypeScript errors**:
- `mcp__typescript-language-server__diagnostics filePath`
- Get compilation errors and warnings for a specific file
### Investigation Strategy (LSP-First Approach)
#### Backend Investigation (Go)
1. **Start with route registration** in `coderd/coderd.go` to understand API endpoints
2. **Use Go LSP `definition` lookup** to trace from route handlers to actual implementations
3. **Use Go LSP `references`** to understand how functions are called throughout the codebase
4. **Follow the middleware chain** using LSP tools to understand request processing flow
5. **Check test files** for expected behavior and error patterns
#### Frontend Investigation (TypeScript/React)
1. **Start with route definitions** in `site/src/App.tsx` or router configuration
2. **Use TypeScript LSP `definition`** to navigate to React components and hooks
3. **Use TypeScript LSP `references`** to find all component usages and prop drilling
4. **Follow the component hierarchy** using LSP tools to understand data flow
5. **Check for TypeScript errors** with `diagnostics` before making changes
6. **Examine test files** (`.test.tsx`) for component behavior and expected props
## Troubleshooting Development Issues
### Common Issues
1. **Development server won't start** - Use `./scripts/develop.sh` instead of manual commands
2. **Database migration errors** - Check migration file format and use helper scripts
3. **Audit table errors** - Update `enterprise/audit/table.go` with new fields
4. **OAuth2 compliance issues** - Ensure RFC-compliant error responses
### Debug Commands
- Check linting: `make lint`
- Generate code: `make gen`
- Clean build: `make clean`
## Development Environment Setup
### Prerequisites
- Go (version specified in go.mod)
- Node.js and pnpm for frontend development
- PostgreSQL for database testing
- Docker for containerized testing
### First Time Setup
1. Clone the repository
2. Run `./scripts/develop.sh` to start development server
3. Access the development URL provided
4. Create admin user as prompted
5. Begin development
+133
View File
@@ -0,0 +1,133 @@
#!/bin/bash
# Claude Code hook script for file formatting
# This script integrates with the centralized Makefile formatting targets
# and supports the Claude Code hooks system for automatic file formatting.
set -euo pipefail
# A variable to memoize the command for canonicalizing paths.
_CANONICALIZE_CMD=""
# canonicalize_path resolves a path to its absolute, canonical form.
# It tries 'realpath' and 'readlink -f' in order.
# The chosen command is memoized to avoid repeated checks.
# If none of these are available, it returns an empty string.
canonicalize_path() {
local path_to_resolve="$1"
# If we haven't determined a command yet, find one.
if [[ -z "$_CANONICALIZE_CMD" ]]; then
if command -v realpath >/dev/null 2>&1; then
_CANONICALIZE_CMD="realpath"
elif command -v readlink >/dev/null 2>&1 && readlink -f . >/dev/null 2>&1; then
_CANONICALIZE_CMD="readlink"
else
# No command found, so we can't resolve.
# We set a "none" value to prevent re-checking.
_CANONICALIZE_CMD="none"
fi
fi
# Now, execute the command.
case "$_CANONICALIZE_CMD" in
realpath)
realpath "$path_to_resolve" 2>/dev/null
;;
readlink)
readlink -f "$path_to_resolve" 2>/dev/null
;;
*)
# This handles the "none" case or any unexpected error.
echo ""
;;
esac
}
# Read JSON input from stdin
input=$(cat)
# Extract the file path from the JSON input
# Expected format: {"tool_input": {"file_path": "/absolute/path/to/file"}} or {"tool_response": {"filePath": "/absolute/path/to/file"}}
file_path=$(echo "$input" | jq -r '.tool_input.file_path // .tool_response.filePath // empty')
# Secure path canonicalization to prevent path traversal attacks
# Resolve repo root to an absolute, canonical path.
repo_root_raw="$(cd "$(dirname "$0")/../.." && pwd)"
repo_root="$(canonicalize_path "$repo_root_raw")"
if [[ -z "$repo_root" ]]; then
# Fallback if canonicalization fails
repo_root="$repo_root_raw"
fi
# Resolve the input path to an absolute path
if [[ "$file_path" = /* ]]; then
# Already absolute
abs_file_path="$file_path"
else
# Make relative paths absolute from repo root
abs_file_path="$repo_root/$file_path"
fi
# Canonicalize the path (resolve symlinks and ".." segments)
canonical_file_path="$(canonicalize_path "$abs_file_path")"
# Check if canonicalization failed or if the resolved path is outside the repo
if [[ -z "$canonical_file_path" ]] || { [[ "$canonical_file_path" != "$repo_root" ]] && [[ "$canonical_file_path" != "$repo_root"/* ]]; }; then
echo "Error: File path is outside repository or invalid: $file_path" >&2
exit 1
fi
# Handle the case where the file path is the repository root itself.
if [[ "$canonical_file_path" == "$repo_root" ]]; then
echo "Warning: Formatting the repository root is not a supported operation. Skipping." >&2
exit 0
fi
# Convert back to relative path from repo root for consistency
file_path="${canonical_file_path#"$repo_root"/}"
if [[ -z "$file_path" ]]; then
echo "Error: No file path provided in input" >&2
exit 1
fi
# Check if file exists
if [[ ! -f "$file_path" ]]; then
echo "Error: File does not exist: $file_path" >&2
exit 1
fi
# Get the file extension to determine the appropriate formatter
file_ext="${file_path##*.}"
# Change to the project root directory (where the Makefile is located)
cd "$(dirname "$0")/../.."
# Call the appropriate Makefile target based on file extension
case "$file_ext" in
go)
make fmt/go FILE="$file_path"
echo "✓ Formatted Go file: $file_path"
;;
js | jsx | ts | tsx)
make fmt/ts FILE="$file_path"
echo "✓ Formatted TypeScript/JavaScript file: $file_path"
;;
tf | tfvars)
make fmt/terraform FILE="$file_path"
echo "✓ Formatted Terraform file: $file_path"
;;
sh)
make fmt/shfmt FILE="$file_path"
echo "✓ Formatted shell script: $file_path"
;;
md)
make fmt/markdown FILE="$file_path"
echo "✓ Formatted Markdown file: $file_path"
;;
*)
echo "No formatter available for file extension: $file_ext"
exit 0
;;
esac
+15
View File
@@ -0,0 +1,15 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write|MultiEdit",
"hooks": [
{
"type": "command",
"command": ".claude/scripts/format.sh"
}
]
}
]
}
}
+28
View File
@@ -0,0 +1,28 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
# CodeRabbit Configuration
# This configuration disables automatic reviews entirely
language: "en-US"
early_access: false
reviews:
# Disable automatic reviews for new PRs, but allow incremental reviews
auto_review:
enabled: false # Disable automatic review of new/updated PRs
drafts: false # Don't review draft PRs automatically
# Other review settings (only apply if manually requested)
profile: "chill"
request_changes_workflow: false
high_level_summary: false
poem: false
review_status: false
collapse_walkthrough: true
high_level_summary_in_walkthrough: true
chat:
auto_reply: true # Allow automatic chat replies
# Note: With auto_review.enabled: false, CodeRabbit will only perform initial
# reviews when manually requested, but incremental reviews and chat replies remain enabled
+67 -3
View File
@@ -1,11 +1,16 @@
{
"name": "Development environments on your infrastructure",
"image": "codercom/oss-dogfood:latest",
"features": {
// See all possible options here https://github.com/devcontainers/features/tree/main/src/docker-in-docker
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": "false"
},
"ghcr.io/coder/devcontainer-features/code-server:1": {
"auth": "none",
"port": 13337
},
"./filebrowser": {
"folder": "${containerWorkspaceFolder}"
}
},
// SYS_PTRACE to enable go debugging
@@ -13,6 +18,65 @@
"customizations": {
"vscode": {
"extensions": ["biomejs.biome"]
},
"coder": {
"apps": [
{
"slug": "cursor",
"displayName": "Cursor Desktop",
"url": "cursor://coder.coder-remote/openDevContainer?owner=${localEnv:CODER_WORKSPACE_OWNER_NAME}&workspace=${localEnv:CODER_WORKSPACE_NAME}&agent=${localEnv:CODER_WORKSPACE_PARENT_AGENT_NAME}&url=${localEnv:CODER_URL}&token=$SESSION_TOKEN&devContainerName=${localEnv:CONTAINER_ID}&devContainerFolder=${containerWorkspaceFolder}&localWorkspaceFolder=${localWorkspaceFolder}",
"external": true,
"icon": "/icon/cursor.svg",
"order": 1
},
{
"slug": "windsurf",
"displayName": "Windsurf Editor",
"url": "windsurf://coder.coder-remote/openDevContainer?owner=${localEnv:CODER_WORKSPACE_OWNER_NAME}&workspace=${localEnv:CODER_WORKSPACE_NAME}&agent=${localEnv:CODER_WORKSPACE_PARENT_AGENT_NAME}&url=${localEnv:CODER_URL}&token=$SESSION_TOKEN&devContainerName=${localEnv:CONTAINER_ID}&devContainerFolder=${containerWorkspaceFolder}&localWorkspaceFolder=${localWorkspaceFolder}",
"external": true,
"icon": "/icon/windsurf.svg",
"order": 4
},
{
"slug": "zed",
"displayName": "Zed Editor",
"url": "zed://ssh/${localEnv:CODER_WORKSPACE_AGENT_NAME}.${localEnv:CODER_WORKSPACE_NAME}.${localEnv:CODER_WORKSPACE_OWNER_NAME}.coder${containerWorkspaceFolder}",
"external": true,
"icon": "/icon/zed.svg",
"order": 5
},
// Reproduce `code-server` app here from the code-server
// feature so that we can set the correct folder and order.
// Currently, the order cannot be specified via option because
// we parse it as a number whereas variable interpolation
// results in a string. Additionally we set health check which
// is not yet set in the feature.
{
"slug": "code-server",
"displayName": "code-server",
"url": "http://${localEnv:FEATURE_CODE_SERVER_OPTION_HOST:127.0.0.1}:${localEnv:FEATURE_CODE_SERVER_OPTION_PORT:8080}/?folder=${containerWorkspaceFolder}",
"openIn": "${localEnv:FEATURE_CODE_SERVER_OPTION_APPOPENIN:slim-window}",
"share": "${localEnv:FEATURE_CODE_SERVER_OPTION_APPSHARE:owner}",
"icon": "/icon/code.svg",
"group": "${localEnv:FEATURE_CODE_SERVER_OPTION_APPGROUP:Web Editors}",
"order": 3,
"healthCheck": {
"url": "http://${localEnv:FEATURE_CODE_SERVER_OPTION_HOST:127.0.0.1}:${localEnv:FEATURE_CODE_SERVER_OPTION_PORT:8080}/healthz",
"interval": 5,
"threshold": 2
}
}
]
}
}
},
"mounts": [
// Add a volume for the Coder home directory to persist shell history,
// and speed up dotfiles init and/or personalization.
"source=coder-coder-devcontainer-home,target=/home/coder,type=volume",
// Mount the entire home because conditional mounts are not supported.
// See: https://github.com/devcontainers/spec/issues/132
"source=${localEnv:HOME},target=/mnt/home/coder,type=bind,readonly"
],
"postCreateCommand": ["./.devcontainer/scripts/post_create.sh"],
"postStartCommand": ["./.devcontainer/scripts/post_start.sh"]
}
@@ -0,0 +1,46 @@
{
"id": "filebrowser",
"version": "0.0.1",
"name": "File Browser",
"description": "A web-based file browser for your development container",
"options": {
"port": {
"type": "string",
"default": "13339",
"description": "The port to run filebrowser on"
},
"folder": {
"type": "string",
"default": "",
"description": "The root directory for filebrowser to serve"
},
"baseUrl": {
"type": "string",
"default": "",
"description": "The base URL for filebrowser (e.g., /filebrowser)"
}
},
"entrypoint": "/usr/local/bin/filebrowser-entrypoint",
"dependsOn": {
"ghcr.io/devcontainers/features/common-utils:2": {}
},
"customizations": {
"coder": {
"apps": [
{
"slug": "filebrowser",
"displayName": "File Browser",
"url": "http://localhost:${localEnv:FEATURE_FILEBROWSER_OPTION_PORT:13339}",
"icon": "/icon/filebrowser.svg",
"order": 3,
"subdomain": true,
"healthcheck": {
"url": "http://localhost:${localEnv:FEATURE_FILEBROWSER_OPTION_PORT:13339}/health",
"interval": 5,
"threshold": 2
}
}
]
}
}
}
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -euo pipefail
BOLD='\033[0;1m'
printf "%sInstalling filebrowser\n\n" "${BOLD}"
# Check if filebrowser is installed.
if ! command -v filebrowser &>/dev/null; then
curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash
fi
# Create entrypoint.
cat >/usr/local/bin/filebrowser-entrypoint <<EOF
#!/usr/bin/env bash
PORT="${PORT}"
FOLDER="${FOLDER:-}"
FOLDER="\${FOLDER:-\$(pwd)}"
BASEURL="${BASEURL:-}"
LOG_PATH=/tmp/filebrowser.log
export FB_DATABASE="\${HOME}/.filebrowser.db"
printf "🛠️ Configuring filebrowser\n\n"
# Check if filebrowser db exists.
if [[ ! -f "\${FB_DATABASE}" ]]; then
filebrowser config init >>\${LOG_PATH} 2>&1
filebrowser users add admin "" --perm.admin=true --viewMode=mosaic >>\${LOG_PATH} 2>&1
fi
filebrowser config set --baseurl=\${BASEURL} --port=\${PORT} --auth.method=noauth --root=\${FOLDER} >>\${LOG_PATH} 2>&1
printf "👷 Starting filebrowser...\n\n"
printf "📂 Serving \${FOLDER} at http://localhost:\${PORT}\n\n"
filebrowser >>\${LOG_PATH} 2>&1 &
printf "📝 Logs at \${LOG_PATH}\n\n"
EOF
chmod +x /usr/local/bin/filebrowser-entrypoint
printf "🥳 Installation complete!\n\n"
+59
View File
@@ -0,0 +1,59 @@
#!/bin/sh
install_devcontainer_cli() {
npm install -g @devcontainers/cli
}
install_ssh_config() {
echo "🔑 Installing SSH configuration..."
rsync -a /mnt/home/coder/.ssh/ ~/.ssh/
chmod 0700 ~/.ssh
}
install_git_config() {
echo "📂 Installing Git configuration..."
if [ -f /mnt/home/coder/git/config ]; then
rsync -a /mnt/home/coder/git/ ~/.config/git/
elif [ -d /mnt/home/coder/.gitconfig ]; then
rsync -a /mnt/home/coder/.gitconfig ~/.gitconfig
else
echo "⚠️ Git configuration directory not found."
fi
}
install_dotfiles() {
if [ ! -d /mnt/home/coder/.config/coderv2/dotfiles ]; then
echo "⚠️ Dotfiles directory not found."
return
fi
cd /mnt/home/coder/.config/coderv2/dotfiles || return
for script in install.sh install bootstrap.sh bootstrap script/bootstrap setup.sh setup script/setup; do
if [ -x $script ]; then
echo "📦 Installing dotfiles..."
./$script || {
echo "❌ Error running $script. Please check the script for issues."
return
}
echo "✅ Dotfiles installed successfully."
return
fi
done
echo "⚠️ No install script found in dotfiles directory."
}
personalize() {
# Allow script to continue as Coder dogfood utilizes a hack to
# synchronize startup script execution.
touch /tmp/.coder-startup-script.done
if [ -x /mnt/home/coder/personalize ]; then
echo "🎨 Personalizing environment..."
/mnt/home/coder/personalize
fi
}
install_devcontainer_cli
install_ssh_config
install_dotfiles
personalize
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
# Start Docker service if not already running.
sudo service docker start
+3 -1
View File
@@ -15,6 +15,8 @@ provisionersdk/proto/*.go linguist-generated=true
*.tfstate.json linguist-generated=true
*.tfstate.dot linguist-generated=true
*.tfplan.dot linguist-generated=true
site/e2e/google/protobuf/timestampGenerated.ts
site/e2e/provisionerGenerated.ts linguist-generated=true
site/src/api/countriesGenerated.tsx linguist-generated=true
site/src/api/rbacresourcesGenerated.tsx linguist-generated=true
site/src/api/typesGenerated.ts linguist-generated=true
site/src/pages/SetupPage/countries.tsx linguist-generated=true
+1
View File
@@ -25,5 +25,6 @@ ignorePatterns:
- pattern: "docs.github.com"
- pattern: "claude.ai"
- pattern: "splunk.com"
- pattern: "stackoverflow.com/questions"
aliveStatusCodes:
- 200
@@ -0,0 +1,47 @@
name: "Download Embedded Postgres Cache"
description: |
Downloads the embedded postgres cache and outputs today's cache key.
A PR job can use a cache if it was created by its base branch, its current
branch, or the default branch.
https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
outputs:
cache-key:
description: "Today's cache key"
value: ${{ steps.vars.outputs.cache-key }}
inputs:
key-prefix:
description: "Prefix for the cache key"
required: true
cache-path:
description: "Path to the cache directory"
required: true
runs:
using: "composite"
steps:
- name: Get date values and cache key
id: vars
shell: bash
run: |
export YEAR_MONTH=$(date +'%Y-%m')
export PREV_YEAR_MONTH=$(date -d 'last month' +'%Y-%m')
export DAY=$(date +'%d')
echo "year-month=$YEAR_MONTH" >> $GITHUB_OUTPUT
echo "prev-year-month=$PREV_YEAR_MONTH" >> $GITHUB_OUTPUT
echo "cache-key=${{ inputs.key-prefix }}-${YEAR_MONTH}-${DAY}" >> $GITHUB_OUTPUT
# By default, depot keeps caches for 14 days. This is plenty for embedded
# postgres, which changes infrequently.
# https://depot.dev/docs/github-actions/overview#cache-retention-policy
- name: Download embedded Postgres cache
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ${{ inputs.cache-path }}
key: ${{ steps.vars.outputs.cache-key }}
# > If there are multiple partial matches for a restore key, the action returns the most recently created cache.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#matching-a-cache-key
# The second restore key allows non-main branches to use the cache from the previous month.
# This prevents PRs from rebuilding the cache on the first day of the month.
# It also makes sure that once a month, the cache is fully reset.
restore-keys: |
${{ inputs.key-prefix }}-${{ steps.vars.outputs.year-month }}-
${{ github.ref != 'refs/heads/main' && format('{0}-{1}-', inputs.key-prefix, steps.vars.outputs.prev-year-month) || '' }}
@@ -0,0 +1,18 @@
name: "Upload Embedded Postgres Cache"
description: Uploads the embedded Postgres cache. This only runs on the main branch.
inputs:
cache-key:
description: "Cache key"
required: true
cache-path:
description: "Path to the cache directory"
required: true
runs:
using: "composite"
steps:
- name: Upload Embedded Postgres cache
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ${{ inputs.cache-path }}
key: ${{ inputs.cache-key }}
@@ -0,0 +1,33 @@
name: "Setup Embedded Postgres Cache Paths"
description: Sets up a path for cached embedded postgres binaries.
outputs:
embedded-pg-cache:
description: "Value of EMBEDDED_PG_CACHE_DIR"
value: ${{ steps.paths.outputs.embedded-pg-cache }}
cached-dirs:
description: "directories that should be cached between CI runs"
value: ${{ steps.paths.outputs.cached-dirs }}
runs:
using: "composite"
steps:
- name: Override Go paths
id: paths
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
script: |
const path = require('path');
// RUNNER_TEMP should be backed by a RAM disk on Windows if
// coder/setup-ramdisk-action was used
const runnerTemp = process.env.RUNNER_TEMP;
const embeddedPgCacheDir = path.join(runnerTemp, 'embedded-pg-cache');
core.exportVariable('EMBEDDED_PG_CACHE_DIR', embeddedPgCacheDir);
core.setOutput('embedded-pg-cache', embeddedPgCacheDir);
const cachedDirs = `${embeddedPgCacheDir}`;
core.setOutput('cached-dirs', cachedDirs);
- name: Create directories
shell: bash
run: |
set -e
mkdir -p "$EMBEDDED_PG_CACHE_DIR"
+83 -177
View File
@@ -34,7 +34,7 @@ jobs:
tailnet-integration: ${{ steps.filter.outputs.tailnet-integration }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -154,7 +154,7 @@ jobs:
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -187,7 +187,7 @@ jobs:
# Check for any typos
- name: Check for typos
uses: crate-ci/typos@b1ae8d918b6e85bd611117d3d9a3be4f903ee5e4 # v1.33.1
uses: crate-ci/typos@392b78fe18a52790c53f42456e46124f77346842 # v1.34.0
with:
config: .github/workflows/typos.toml
@@ -226,7 +226,7 @@ jobs:
if: ${{ !cancelled() }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -281,7 +281,7 @@ jobs:
timeout-minutes: 7
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -311,94 +311,6 @@ jobs:
- name: Check for unstaged files
run: ./scripts/check_unstaged.sh
test-go:
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'depot-macos-latest' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'depot-windows-2022-16' || matrix.os }}
needs: changes
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-2022
steps:
- name: Harden Runner
# Harden Runner is only supported on Ubuntu runners.
if: runner.os == 'Linux'
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
with:
egress-policy: audit
# Set up RAM disks to speed up the rest of the job. This action is in
# a separate repository to allow its use before actions/checkout.
- name: Setup RAM Disks
if: runner.os == 'Windows'
uses: coder/setup-ramdisk-action@e1100847ab2d7bcd9d14bcda8f2d1b0f07b36f1b
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Setup Go Paths
uses: ./.github/actions/setup-go-paths
- name: Setup Go
uses: ./.github/actions/setup-go
with:
# Runners have Go baked-in and Go will automatically
# download the toolchain configured in go.mod, so we don't
# need to reinstall it. It's faster on Windows runners.
use-preinstalled-go: ${{ runner.os == 'Windows' }}
- name: Setup Terraform
uses: ./.github/actions/setup-tf
- name: Download Test Cache
id: download-cache
uses: ./.github/actions/test-cache/download
with:
key-prefix: test-go-${{ runner.os }}-${{ runner.arch }}
- name: Test with Mock Database
id: test
shell: bash
run: |
# if macOS, install google-chrome for scaletests. As another concern,
# should we really have this kind of external dependency requirement
# on standard CI?
if [ "${{ matrix.os }}" == "macos-latest" ]; then
brew install google-chrome
fi
# By default Go will use the number of logical CPUs, which
# is a fine default.
PARALLEL_FLAG=""
# macOS will output "The default interactive shell is now zsh"
# intermittently in CI...
if [ "${{ matrix.os }}" == "macos-latest" ]; then
touch ~/.bash_profile && echo "export BASH_SILENCE_DEPRECATION_WARNING=1" >> ~/.bash_profile
fi
export TS_DEBUG_DISCO=true
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" --rerun-fails=2 \
--packages="./..." -- $PARALLEL_FLAG -short
- name: Upload Test Cache
uses: ./.github/actions/test-cache/upload
with:
cache-key: ${{ steps.download-cache.outputs.cache-key }}
- name: Upload test stats to Datadog
timeout-minutes: 1
continue-on-error: true
uses: ./.github/actions/upload-datadog
if: success() || failure()
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
test-go-pg:
# make sure to adjust NUM_PARALLEL_PACKAGES and NUM_PARALLEL_TESTS below
# when changing runner sizes
@@ -418,7 +330,7 @@ jobs:
- windows-2022
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -428,6 +340,11 @@ jobs:
- name: Disable Spotlight Indexing
if: runner.os == 'macOS'
run: |
enabled=$(sudo mdutil -a -s | grep "Indexing enabled" | wc -l)
if [ $enabled -eq 0 ]; then
echo "Spotlight indexing is already disabled"
exit 0
fi
sudo mdutil -a -i off
sudo mdutil -X /
sudo launchctl bootout system /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
@@ -473,6 +390,17 @@ jobs:
with:
key-prefix: test-go-pg-${{ runner.os }}-${{ runner.arch }}
- name: Setup Embedded Postgres Cache Paths
id: embedded-pg-cache
uses: ./.github/actions/setup-embedded-pg-cache-paths
- name: Download Embedded Postgres Cache
id: download-embedded-pg-cache
uses: ./.github/actions/embedded-pg-cache/download
with:
key-prefix: embedded-pg-${{ runner.os }}-${{ runner.arch }}
cache-path: ${{ steps.embedded-pg-cache.outputs.cached-dirs }}
- name: Normalize File and Directory Timestamps
shell: bash
# Normalize file modification timestamps so that go test can use the
@@ -497,12 +425,12 @@ jobs:
# Create a temp dir on the R: ramdisk drive for Windows. The default
# C: drive is extremely slow: https://github.com/actions/runner-images/issues/8755
mkdir -p "R:/temp/embedded-pg"
go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg"
go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg" -cache "${EMBEDDED_PG_CACHE_DIR}"
elif [ "${{ runner.os }}" == "macOS" ]; then
# Postgres runs faster on a ramdisk on macOS too
mkdir -p /tmp/tmpfs
sudo mount_tmpfs -o noowners -s 8g /tmp/tmpfs
go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg
go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg -cache "${EMBEDDED_PG_CACHE_DIR}"
elif [ "${{ runner.os }}" == "Linux" ]; then
make test-postgres-docker
fi
@@ -528,16 +456,21 @@ jobs:
# Postgres tends not to choke.
NUM_PARALLEL_PACKAGES=8
NUM_PARALLEL_TESTS=16
# Only the CLI and Agent are officially supported on Windows and the rest are too flaky
PACKAGES="./cli/... ./enterprise/cli/... ./agent/..."
elif [ "${{ runner.os }}" == "macOS" ]; then
# Our macOS runners have 8 cores. We set NUM_PARALLEL_TESTS to 16
# because the tests complete faster and Postgres doesn't choke. It seems
# that macOS's tmpfs is faster than the one on Windows.
NUM_PARALLEL_PACKAGES=8
NUM_PARALLEL_TESTS=16
# Only the CLI and Agent are officially supported on macOS and the rest are too flaky
PACKAGES="./cli/... ./enterprise/cli/... ./agent/..."
elif [ "${{ runner.os }}" == "Linux" ]; then
# Our Linux runners have 8 cores.
NUM_PARALLEL_PACKAGES=8
NUM_PARALLEL_TESTS=8
PACKAGES="./..."
fi
# by default, run tests with cache
@@ -554,10 +487,7 @@ jobs:
# invalidated. See scripts/normalize_path.sh for more details.
normalize_path_with_symlinks "$RUNNER_TEMP/sym" "$(dirname $(which terraform))"
# We rerun failing tests to counteract flakiness coming from Postgres
# choking on macOS and Windows sometimes.
DB=ci gotestsum --rerun-fails=2 --rerun-fails-max-failures=50 \
--format standard-quiet --packages "./..." \
gotestsum --format standard-quiet --packages "$PACKAGES" \
-- -timeout=20m -v -p $NUM_PARALLEL_PACKAGES -parallel=$NUM_PARALLEL_TESTS $TESTCOUNT
- name: Upload Go Build Cache
@@ -571,6 +501,14 @@ jobs:
with:
cache-key: ${{ steps.download-cache.outputs.cache-key }}
- name: Upload Embedded Postgres Cache
uses: ./.github/actions/embedded-pg-cache/upload
# We only use the embedded Postgres cache on macOS and Windows runners.
if: runner.OS == 'macOS' || runner.OS == 'Windows'
with:
cache-key: ${{ steps.download-embedded-pg-cache.outputs.cache-key }}
cache-path: "${{ steps.embedded-pg-cache.outputs.embedded-pg-cache }}"
- name: Upload test stats to Datadog
timeout-minutes: 1
continue-on-error: true
@@ -594,7 +532,7 @@ jobs:
timeout-minutes: 25
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -619,7 +557,6 @@ jobs:
env:
POSTGRES_VERSION: "17"
TS_DEBUG_DISCO: "true"
TEST_RETRIES: 2
run: |
make test-postgres
@@ -636,55 +573,6 @@ jobs:
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
test-go-race:
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
needs: changes
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
timeout-minutes: 25
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Setup Terraform
uses: ./.github/actions/setup-tf
- name: Download Test Cache
id: download-cache
uses: ./.github/actions/test-cache/download
with:
key-prefix: test-go-race-${{ runner.os }}-${{ runner.arch }}
# We run race tests with reduced parallelism because they use more CPU and we were finding
# instances where tests appear to hang for multiple seconds, resulting in flaky tests when
# short timeouts are used.
# c.f. discussion on https://github.com/coder/coder/pull/15106
- name: Run Tests
run: |
gotestsum --junitfile="gotests.xml" --packages="./..." --rerun-fails=2 --rerun-fails-abort-on-data-race -- -race -parallel 4 -p 4
- name: Upload Test Cache
uses: ./.github/actions/test-cache/upload
with:
cache-key: ${{ steps.download-cache.outputs.cache-key }}
- name: Upload test stats to Datadog
timeout-minutes: 1
continue-on-error: true
uses: ./.github/actions/upload-datadog
if: always()
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
test-go-race-pg:
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
needs: changes
@@ -692,7 +580,7 @@ jobs:
timeout-minutes: 25
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -722,7 +610,7 @@ jobs:
POSTGRES_VERSION: "17"
run: |
make test-postgres-docker
DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." --rerun-fails=2 --rerun-fails-abort-on-data-race -- -race -parallel 4 -p 4
gotestsum --junitfile="gotests.xml" --packages="./..." -- -race -parallel 4 -p 4
- name: Upload Test Cache
uses: ./.github/actions/test-cache/upload
@@ -751,7 +639,7 @@ jobs:
timeout-minutes: 20
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -777,7 +665,7 @@ jobs:
timeout-minutes: 20
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -809,7 +697,7 @@ jobs:
name: ${{ matrix.variant.name }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -844,7 +732,6 @@ jobs:
if: ${{ !matrix.variant.premium }}
env:
DEBUG: pw:api
CODER_E2E_TEST_RETRIES: 2
working-directory: site
# Run all of the tests with a premium license
@@ -854,7 +741,6 @@ jobs:
DEBUG: pw:api
CODER_E2E_LICENSE: ${{ secrets.CODER_E2E_LICENSE }}
CODER_E2E_REQUIRE_PREMIUM_TESTS: "1"
CODER_E2E_TEST_RETRIES: 2
working-directory: site
- name: Upload Playwright Failed Tests
@@ -882,7 +768,7 @@ jobs:
if: needs.changes.outputs.site == 'true' || needs.changes.outputs.ci == 'true'
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -902,7 +788,7 @@ jobs:
# the check to pass. This is desired in PRs, but not in mainline.
- name: Publish to Chromatic (non-mainline)
if: github.ref != 'refs/heads/main' && github.repository_owner == 'coder'
uses: chromaui/action@b5848056bb67ce5f1cccca8e62a37cbd9dd42871 # v13.0.1
uses: chromaui/action@4d8ebd13658d795114f8051e25c28d66f14886c6 # v13.1.2
env:
NODE_OPTIONS: "--max_old_space_size=4096"
STORYBOOK: true
@@ -934,7 +820,7 @@ jobs:
# infinitely "in progress" in mainline unless we re-review each build.
- name: Publish to Chromatic (mainline)
if: github.ref == 'refs/heads/main' && github.repository_owner == 'coder'
uses: chromaui/action@b5848056bb67ce5f1cccca8e62a37cbd9dd42871 # v13.0.1
uses: chromaui/action@4d8ebd13658d795114f8051e25c28d66f14886c6 # v13.1.2
env:
NODE_OPTIONS: "--max_old_space_size=4096"
STORYBOOK: true
@@ -962,7 +848,7 @@ jobs:
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -1018,9 +904,7 @@ jobs:
- fmt
- lint
- gen
- test-go
- test-go-pg
- test-go-race
- test-go-race-pg
- test-js
- test-e2e
@@ -1031,7 +915,7 @@ jobs:
if: always()
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -1041,9 +925,7 @@ jobs:
echo "- fmt: ${{ needs.fmt.result }}"
echo "- lint: ${{ needs.lint.result }}"
echo "- gen: ${{ needs.gen.result }}"
echo "- test-go: ${{ needs.test-go.result }}"
echo "- test-go-pg: ${{ needs.test-go-pg.result }}"
echo "- test-go-race: ${{ needs.test-go-race.result }}"
echo "- test-go-race-pg: ${{ needs.test-go-race-pg.result }}"
echo "- test-js: ${{ needs.test-js.result }}"
echo "- test-e2e: ${{ needs.test-e2e.result }}"
@@ -1161,7 +1043,7 @@ jobs:
IMAGE: ghcr.io/coder/coder-preview:${{ steps.build-docker.outputs.tag }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -1183,6 +1065,27 @@ jobs:
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Install rcodesign
run: |
set -euo pipefail
wget -O /tmp/rcodesign.tar.gz https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.22.0/apple-codesign-0.22.0-x86_64-unknown-linux-musl.tar.gz
sudo tar -xzf /tmp/rcodesign.tar.gz \
-C /usr/bin \
--strip-components=1 \
apple-codesign-0.22.0-x86_64-unknown-linux-musl/rcodesign
rm /tmp/rcodesign.tar.gz
- name: Setup Apple Developer certificate
run: |
set -euo pipefail
touch /tmp/{apple_cert.p12,apple_cert_password.txt}
chmod 600 /tmp/{apple_cert.p12,apple_cert_password.txt}
echo "$AC_CERTIFICATE_P12_BASE64" | base64 -d > /tmp/apple_cert.p12
echo "$AC_CERTIFICATE_PASSWORD" > /tmp/apple_cert_password.txt
env:
AC_CERTIFICATE_P12_BASE64: ${{ secrets.AC_CERTIFICATE_P12_BASE64 }}
AC_CERTIFICATE_PASSWORD: ${{ secrets.AC_CERTIFICATE_PASSWORD }}
# Necessary for signing Windows binaries.
- name: Setup Java
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
@@ -1218,14 +1121,14 @@ jobs:
# Setup GCloud for signing Windows binaries.
- name: Authenticate to Google Cloud
id: gcloud_auth
uses: google-github-actions/auth@ba79af03959ebeac9769e648f473a284504d9193 # v2.1.10
uses: google-github-actions/auth@140bb5113ffb6b65a7e9b937a81fa96cf5064462 # v2.1.11
with:
workload_identity_provider: ${{ secrets.GCP_CODE_SIGNING_WORKLOAD_ID_PROVIDER }}
service_account: ${{ secrets.GCP_CODE_SIGNING_SERVICE_ACCOUNT }}
token_format: "access_token"
- name: Setup GCloud SDK
uses: google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a # v2.1.4
uses: google-github-actions/setup-gcloud@6a7c903a70c8625ed6700fa299f5ddb4ca6022e9 # v2.1.5
- name: Download dylibs
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
@@ -1261,6 +1164,9 @@ jobs:
CODER_WINDOWS_RESOURCES: "1"
CODER_SIGN_GPG: "1"
CODER_GPG_RELEASE_KEY_BASE64: ${{ secrets.GPG_RELEASE_KEY_BASE64 }}
CODER_SIGN_DARWIN: "1"
AC_CERTIFICATE_FILE: /tmp/apple_cert.p12
AC_CERTIFICATE_PASSWORD_FILE: /tmp/apple_cert_password.txt
EV_KEY: ${{ secrets.EV_KEY }}
EV_KEYSTORE: ${{ secrets.EV_KEYSTORE }}
EV_TSA_URL: ${{ secrets.EV_TSA_URL }}
@@ -1509,7 +1415,7 @@ jobs:
id-token: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -1519,22 +1425,22 @@ jobs:
fetch-depth: 0
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@ba79af03959ebeac9769e648f473a284504d9193 # v2.1.10
uses: google-github-actions/auth@140bb5113ffb6b65a7e9b937a81fa96cf5064462 # v2.1.11
with:
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a # v2.1.4
uses: google-github-actions/setup-gcloud@6a7c903a70c8625ed6700fa299f5ddb4ca6022e9 # v2.1.5
- name: Set up Flux CLI
uses: fluxcd/flux2/action@a48f81a66c4ca9fbd993233ab99dd03a7cfbe09a # v2.6.2
uses: fluxcd/flux2/action@6bf37f6a560fd84982d67f853162e4b3c2235edb # v2.6.4
with:
# Keep this and the github action up to date with the version of flux installed in dogfood cluster
version: "2.5.1"
- name: Get Cluster Credentials
uses: google-github-actions/get-gke-credentials@d0cee45012069b163a631894b98904a9e6723729 # v2.3.3
uses: google-github-actions/get-gke-credentials@8e574c49425fa7efed1e74650a449bfa6a23308a # v2.3.4
with:
cluster_name: dogfood-v2
location: us-central1-a
@@ -1573,7 +1479,7 @@ jobs:
if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -1608,7 +1514,7 @@ jobs:
if: needs.changes.outputs.db == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
+1 -1
View File
@@ -38,7 +38,7 @@ jobs:
if: github.repository_owner == 'coder'
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
+1 -1
View File
@@ -28,7 +28,7 @@ jobs:
- name: Setup Node
uses: ./.github/actions/setup-node
- uses: tj-actions/changed-files@666c9d29007687c52e3c7aa2aac6c0ffcadeadc3 # v45.0.7
- uses: tj-actions/changed-files@055970845dd036d7345da7399b7e89f2e10f2b04 # v45.0.7
id: changed-files
with:
files: |
+8 -4
View File
@@ -27,7 +27,7 @@ jobs:
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || 'ubuntu-latest' }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -35,7 +35,11 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Nix
uses: nixbuild/nix-quick-install-action@889f3180bb5f064ee9e3201428d04ae9e41d54ad # v31
uses: nixbuild/nix-quick-install-action@63ca48f939ee3b8d835f4126562537df0fee5b91 # v32
with:
# Pinning to 2.28 here, as Nix gets a "error: [json.exception.type_error.302] type must be array, but is string"
# on version 2.29 and above.
nix_version: "2.28.4"
- uses: nix-community/cache-nix-action@135667ec418502fa5a3598af6fb9eb733888ce6a # v6.1.3
with:
@@ -114,7 +118,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -125,7 +129,7 @@ jobs:
uses: ./.github/actions/setup-tf
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@ba79af03959ebeac9769e648f473a284504d9193 # v2.1.10
uses: google-github-actions/auth@140bb5113ffb6b65a7e9b937a81fa96cf5064462 # v2.1.11
with:
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com
+203
View File
@@ -0,0 +1,203 @@
# The nightly-gauntlet runs tests that are either too flaky or too slow to block
# every PR.
name: nightly-gauntlet
on:
schedule:
# Every day at 4AM
- cron: "0 4 * * 1-5"
workflow_dispatch:
permissions:
contents: read
jobs:
test-go-pg:
# make sure to adjust NUM_PARALLEL_PACKAGES and NUM_PARALLEL_TESTS below
# when changing runner sizes
runs-on: ${{ matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'depot-macos-latest' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'depot-windows-2022-16' || matrix.os }}
# This timeout must be greater than the timeout set by `go test` in
# `make test-postgres` to ensure we receive a trace of running
# goroutines. Setting this to the timeout +5m should work quite well
# even if some of the preceding steps are slow.
timeout-minutes: 25
strategy:
matrix:
os:
- macos-latest
- windows-2022
steps:
- name: Harden Runner
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
with:
egress-policy: audit
# macOS indexes all new files in the background. Our Postgres tests
# create and destroy thousands of databases on disk, and Spotlight
# tries to index all of them, seriously slowing down the tests.
- name: Disable Spotlight Indexing
if: runner.os == 'macOS'
run: |
sudo mdutil -a -i off
sudo mdutil -X /
sudo launchctl bootout system /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
# Set up RAM disks to speed up the rest of the job. This action is in
# a separate repository to allow its use before actions/checkout.
- name: Setup RAM Disks
if: runner.os == 'Windows'
uses: coder/setup-ramdisk-action@e1100847ab2d7bcd9d14bcda8f2d1b0f07b36f1b
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1
- name: Setup Go
uses: ./.github/actions/setup-go
with:
# Runners have Go baked-in and Go will automatically
# download the toolchain configured in go.mod, so we don't
# need to reinstall it. It's faster on Windows runners.
use-preinstalled-go: ${{ runner.os == 'Windows' }}
- name: Setup Terraform
uses: ./.github/actions/setup-tf
- name: Setup Embedded Postgres Cache Paths
id: embedded-pg-cache
uses: ./.github/actions/setup-embedded-pg-cache-paths
- name: Download Embedded Postgres Cache
id: download-embedded-pg-cache
uses: ./.github/actions/embedded-pg-cache/download
with:
key-prefix: embedded-pg-${{ runner.os }}-${{ runner.arch }}
cache-path: ${{ steps.embedded-pg-cache.outputs.cached-dirs }}
- name: Test with PostgreSQL Database
env:
POSTGRES_VERSION: "13"
TS_DEBUG_DISCO: "true"
LC_CTYPE: "en_US.UTF-8"
LC_ALL: "en_US.UTF-8"
shell: bash
run: |
set -o errexit
set -o pipefail
if [ "${{ runner.os }}" == "Windows" ]; then
# Create a temp dir on the R: ramdisk drive for Windows. The default
# C: drive is extremely slow: https://github.com/actions/runner-images/issues/8755
mkdir -p "R:/temp/embedded-pg"
go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg" -cache "${EMBEDDED_PG_CACHE_DIR}"
elif [ "${{ runner.os }}" == "macOS" ]; then
# Postgres runs faster on a ramdisk on macOS too
mkdir -p /tmp/tmpfs
sudo mount_tmpfs -o noowners -s 8g /tmp/tmpfs
go run scripts/embedded-pg/main.go -path /tmp/tmpfs/embedded-pg -cache "${EMBEDDED_PG_CACHE_DIR}"
elif [ "${{ runner.os }}" == "Linux" ]; then
make test-postgres-docker
fi
# if macOS, install google-chrome for scaletests
# As another concern, should we really have this kind of external dependency
# requirement on standard CI?
if [ "${{ matrix.os }}" == "macos-latest" ]; then
brew install google-chrome
fi
# macOS will output "The default interactive shell is now zsh"
# intermittently in CI...
if [ "${{ matrix.os }}" == "macos-latest" ]; then
touch ~/.bash_profile && echo "export BASH_SILENCE_DEPRECATION_WARNING=1" >> ~/.bash_profile
fi
if [ "${{ runner.os }}" == "Windows" ]; then
# Our Windows runners have 16 cores.
# On Windows Postgres chokes up when we have 16x16=256 tests
# running in parallel, and dbtestutil.NewDB starts to take more than
# 10s to complete sometimes causing test timeouts. With 16x8=128 tests
# Postgres tends not to choke.
NUM_PARALLEL_PACKAGES=8
NUM_PARALLEL_TESTS=16
elif [ "${{ runner.os }}" == "macOS" ]; then
# Our macOS runners have 8 cores. We set NUM_PARALLEL_TESTS to 16
# because the tests complete faster and Postgres doesn't choke. It seems
# that macOS's tmpfs is faster than the one on Windows.
NUM_PARALLEL_PACKAGES=8
NUM_PARALLEL_TESTS=16
elif [ "${{ runner.os }}" == "Linux" ]; then
# Our Linux runners have 8 cores.
NUM_PARALLEL_PACKAGES=8
NUM_PARALLEL_TESTS=8
fi
# run tests without cache
TESTCOUNT="-count=1"
DB=ci gotestsum \
--format standard-quiet --packages "./..." \
-- -timeout=20m -v -p $NUM_PARALLEL_PACKAGES -parallel=$NUM_PARALLEL_TESTS $TESTCOUNT
- name: Upload Embedded Postgres Cache
uses: ./.github/actions/embedded-pg-cache/upload
# We only use the embedded Postgres cache on macOS and Windows runners.
if: runner.OS == 'macOS' || runner.OS == 'Windows'
with:
cache-key: ${{ steps.download-embedded-pg-cache.outputs.cache-key }}
cache-path: "${{ steps.embedded-pg-cache.outputs.embedded-pg-cache }}"
- name: Upload test stats to Datadog
timeout-minutes: 1
continue-on-error: true
uses: ./.github/actions/upload-datadog
if: success() || failure()
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
notify-slack-on-failure:
needs:
- test-go-pg
runs-on: ubuntu-latest
if: failure() && github.ref == 'refs/heads/main'
steps:
- name: Send Slack notification
run: |
curl -X POST -H 'Content-type: application/json' \
--data '{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "❌ Nightly gauntlet failed",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Workflow:*\n${{ github.workflow }}"
},
{
"type": "mrkdwn",
"text": "*Committer:*\n${{ github.actor }}"
},
{
"type": "mrkdwn",
"text": "*Commit:*\n${{ github.sha }}"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*View failure:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Click here>"
}
}
]
}' ${{ secrets.CI_FAILURE_SLACK_WEBHOOK }}
+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
+1 -1
View File
@@ -19,7 +19,7 @@ jobs:
packages: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
+5 -5
View File
@@ -39,7 +39,7 @@ jobs:
PR_OPEN: ${{ steps.check_pr.outputs.pr_open }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -74,7 +74,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -174,7 +174,7 @@ jobs:
pull-requests: write # needed for commenting on PRs
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -218,7 +218,7 @@ jobs:
CODER_IMAGE_TAG: ${{ needs.get_info.outputs.CODER_IMAGE_TAG }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -276,7 +276,7 @@ jobs:
PR_HOSTNAME: "pr${{ needs.get_info.outputs.PR_NUMBER }}.${{ secrets.PR_DEPLOYMENTS_DOMAIN }}"
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
+34 -9
View File
@@ -60,7 +60,7 @@ jobs:
- name: Switch XCode Version
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
with:
xcode-version: "16.0.0"
xcode-version: "16.1.0"
- name: Setup Go
uses: ./.github/actions/setup-go
@@ -134,7 +134,7 @@ jobs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -286,14 +286,14 @@ jobs:
# Setup GCloud for signing Windows binaries.
- name: Authenticate to Google Cloud
id: gcloud_auth
uses: google-github-actions/auth@ba79af03959ebeac9769e648f473a284504d9193 # v2.1.10
uses: google-github-actions/auth@140bb5113ffb6b65a7e9b937a81fa96cf5064462 # v2.1.11
with:
workload_identity_provider: ${{ secrets.GCP_CODE_SIGNING_WORKLOAD_ID_PROVIDER }}
service_account: ${{ secrets.GCP_CODE_SIGNING_SERVICE_ACCOUNT }}
token_format: "access_token"
- name: Setup GCloud SDK
uses: google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a # v2.1.4
uses: google-github-actions/setup-gcloud@6a7c903a70c8625ed6700fa299f5ddb4ca6022e9 # v2.1.5
- name: Download dylibs
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
@@ -634,6 +634,29 @@ jobs:
- name: ls build
run: ls -lh build
- name: Publish Coder CLI binaries and detached signatures to GCS
if: ${{ !inputs.dry_run && github.ref == 'refs/heads/main' && github.repository_owner == 'coder'}}
run: |
set -euxo pipefail
version="$(./scripts/version.sh)"
binaries=(
"coder-darwin-amd64"
"coder-darwin-arm64"
"coder-linux-amd64"
"coder-linux-arm64"
"coder-linux-armv7"
"coder-windows-amd64.exe"
"coder-windows-arm64.exe"
)
for binary in "${binaries[@]}"; do
detached_signature="${binary}.asc"
gcloud storage cp "./site/out/bin/${binary}" "gs://releases.coder.com/coder-cli/${version}/${binary}"
gcloud storage cp "./site/out/bin/${detached_signature}" "gs://releases.coder.com/coder-cli/${version}/${detached_signature}"
done
- name: Publish release
run: |
set -euo pipefail
@@ -673,13 +696,13 @@ jobs:
CODER_GPG_RELEASE_KEY_BASE64: ${{ secrets.GPG_RELEASE_KEY_BASE64 }}
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@ba79af03959ebeac9769e648f473a284504d9193 # v2.1.10
uses: google-github-actions/auth@140bb5113ffb6b65a7e9b937a81fa96cf5064462 # v2.1.11
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_ID_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Setup GCloud SDK
uses: google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a # 2.1.4
uses: google-github-actions/setup-gcloud@6a7c903a70c8625ed6700fa299f5ddb4ca6022e9 # 2.1.5
- name: Publish Helm Chart
if: ${{ !inputs.dry_run }}
@@ -695,6 +718,8 @@ jobs:
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/provisioner_helm_${version}.tgz gs://helm.coder.com/v2
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/index.yaml gs://helm.coder.com/v2
gsutil -h "Cache-Control:no-cache,max-age=0" cp helm/artifacthub-repo.yml gs://helm.coder.com/v2
helm push build/coder_helm_${version}.tgz oci://ghcr.io/coder/chart
helm push build/provisioner_helm_${version}.tgz oci://ghcr.io/coder/chart
- name: Upload artifacts to actions (if dry-run)
if: ${{ inputs.dry_run }}
@@ -739,7 +764,7 @@ jobs:
# TODO: skip this if it's not a new release (i.e. a backport). This is
# fine right now because it just makes a PR that we can close.
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -815,7 +840,7 @@ jobs:
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -905,7 +930,7 @@ jobs:
if: ${{ !inputs.dry_run }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
+2 -2
View File
@@ -20,7 +20,7 @@ jobs:
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -47,6 +47,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
uses: github/codeql-action/upload-sarif@d6bbdef45e766d081b84a2def353b0055f728d3e # v3.29.3
with:
sarif_file: results.sarif
+6 -6
View File
@@ -27,7 +27,7 @@ jobs:
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -38,7 +38,7 @@ jobs:
uses: ./.github/actions/setup-go
- name: Initialize CodeQL
uses: github/codeql-action/init@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
uses: github/codeql-action/init@d6bbdef45e766d081b84a2def353b0055f728d3e # v3.29.3
with:
languages: go, javascript
@@ -48,7 +48,7 @@ jobs:
rm Makefile
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
uses: github/codeql-action/analyze@d6bbdef45e766d081b84a2def353b0055f728d3e # v3.29.3
- name: Send Slack notification on failure
if: ${{ failure() }}
@@ -67,7 +67,7 @@ jobs:
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -142,7 +142,7 @@ jobs:
echo "image=$(cat "$image_job")" >> $GITHUB_OUTPUT
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@76071ef0d7ec797419534a183b498b4d6366cf37
uses: aquasecurity/trivy-action@dc5a429b52fcf669ce959baa2c2dd26090d2a6c4
with:
image-ref: ${{ steps.build.outputs.image }}
format: sarif
@@ -150,7 +150,7 @@ jobs:
severity: "CRITICAL,HIGH"
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
uses: github/codeql-action/upload-sarif@d6bbdef45e766d081b84a2def353b0055f728d3e # v3.29.3
with:
sarif_file: trivy-results.sarif
category: "Trivy"
+3 -3
View File
@@ -18,7 +18,7 @@ jobs:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -96,7 +96,7 @@ jobs:
contents: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -118,7 +118,7 @@ jobs:
actions: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
+1 -1
View File
@@ -19,7 +19,7 @@ jobs:
timeout-minutes: 5
steps:
- name: Start Coder workspace
uses: coder/start-workspace-action@35a4608cefc7e8cc56573cae7c3b85304575cb72
uses: coder/start-workspace-action@f97a681b4cc7985c9eef9963750c7cc6ebc93a19
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-username: >-
+2 -2
View File
@@ -21,7 +21,7 @@ jobs:
pull-requests: write # required to post PR review comments by the action
steps:
- name: Harden Runner
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
@@ -29,7 +29,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Check Markdown links
uses: umbrelladocs/action-linkspector@e2ccef58c4b9eb89cd71ee23a8629744bba75aa6 # v1.3.5
uses: umbrelladocs/action-linkspector@874d01cae9fd488e3077b08952093235bd626977 # v1.3.7
id: markdown-link-check
# checks all markdown files from /docs including all subfolders
with:
-1
View File
@@ -181,7 +181,6 @@ linters-settings:
issues:
exclude-dirs:
- coderd/database/dbmem
- node_modules
- .git
+36
View File
@@ -0,0 +1,36 @@
{
"mcpServers": {
"go-language-server": {
"type": "stdio",
"command": "go",
"args": [
"run",
"github.com/isaacphi/mcp-language-server@latest",
"-workspace",
"./",
"-lsp",
"go",
"--",
"run",
"golang.org/x/tools/gopls@latest"
],
"env": {}
},
"typescript-language-server": {
"type": "stdio",
"command": "go",
"args": [
"run",
"github.com/isaacphi/mcp-language-server@latest",
"-workspace",
"./site/",
"-lsp",
"pnpx",
"--",
"typescript-language-server",
"--stdio"
],
"env": {}
}
}
}
+99 -67
View File
@@ -1,21 +1,25 @@
# Coder Development Guidelines
Read [cursor rules](.cursorrules).
@.claude/docs/WORKFLOWS.md
@.cursorrules
@README.md
@package.json
## Build/Test/Lint Commands
## 🚀 Essential Commands
### Main Commands
- `make build` or `make build-fat` - Build all "fat" binaries (includes "server" functionality)
- `make build-slim` - Build "slim" binaries
- `make test` - Run Go tests
- `make test RUN=TestFunctionName` or `go test -v ./path/to/package -run TestFunctionName` - Test single
- `make test-postgres` - Run tests with Postgres database
- `make test-race` - Run tests with Go race detector
- `make test-e2e` - Run end-to-end tests
- `make lint` - Run all linters
- `make fmt` - Format all code
- `make gen` - Generates mocks, database queries and other auto-generated files
| Task | Command | Notes |
|-------------------|--------------------------|----------------------------------|
| **Development** | `./scripts/develop.sh` | ⚠️ Don't use manual build |
| **Build** | `make build` | Fat binaries (includes server) |
| **Build Slim** | `make build-slim` | Slim binaries |
| **Test** | `make test` | Full test suite |
| **Test Single** | `make test RUN=TestName` | Faster than full suite |
| **Test Postgres** | `make test-postgres` | Run tests with Postgres database |
| **Test Race** | `make test-race` | Run tests with Go race detector |
| **Lint** | `make lint` | Always run after changes |
| **Generate** | `make gen` | After database changes |
| **Format** | `make fmt` | Auto-format code |
| **Clean** | `make clean` | Clean build artifacts |
### Frontend Commands (site directory)
@@ -26,81 +30,109 @@ Read [cursor rules](.cursorrules).
- `pnpm lint` - Lint frontend code
- `pnpm test` - Run frontend tests
## Code Style Guidelines
### Documentation Commands
### Go
- `pnpm run format-docs` - Format markdown tables in docs
- `pnpm run lint-docs` - Lint and fix markdown files
- `pnpm run storybook` - Run Storybook (from site directory)
- Follow [Effective Go](https://go.dev/doc/effective_go) and [Go's Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments)
- Use `gofumpt` for formatting
- Create packages when used during implementation
- Validate abstractions against implementations
## 🔧 Critical Patterns
### Error Handling
### Database Changes (ALWAYS FOLLOW)
- Use descriptive error messages
- Wrap errors with context
- Propagate errors appropriately
- Use proper error types
- (`xerrors.Errorf("failed to X: %w", err)`)
1. Modify `coderd/database/queries/*.sql` files
2. Run `make gen`
3. If audit errors: update `enterprise/audit/table.go`
4. Run `make gen` again
### Naming
### LSP Navigation (USE FIRST)
- Use clear, descriptive names
- Abbreviate only when obvious
- Follow Go and TypeScript naming conventions
#### Go LSP (for backend code)
### Comments
- **Find definitions**: `mcp__go-language-server__definition symbolName`
- **Find references**: `mcp__go-language-server__references symbolName`
- **Get type info**: `mcp__go-language-server__hover filePath line column`
- **Rename symbol**: `mcp__go-language-server__rename_symbol filePath line column newName`
- Document exported functions, types, and non-obvious logic
- Follow JSDoc format for TypeScript
- Use godoc format for Go code
#### TypeScript LSP (for frontend code in site/)
## Commit Style
- **Find definitions**: `mcp__typescript-language-server__definition symbolName`
- **Find references**: `mcp__typescript-language-server__references symbolName`
- **Get type info**: `mcp__typescript-language-server__hover filePath line column`
- **Rename symbol**: `mcp__typescript-language-server__rename_symbol filePath line column newName`
- Follow [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/)
- Format: `type(scope): message`
- Types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`
- Keep message titles concise (~70 characters)
- Use imperative, present tense in commit titles
### OAuth2 Error Handling
## Database queries
```go
// OAuth2-compliant error responses
writeOAuth2Error(ctx, rw, http.StatusBadRequest, "invalid_grant", "description")
```
- MUST DO! Any changes to database - adding queries, modifying queries should be done in the `coderd\database\queries\*.sql` files. Use `make gen` to generate necessary changes after.
- MUST DO! Queries are grouped in files relating to context - e.g. `prebuilds.sql`, `users.sql`, `provisionerjobs.sql`.
- After making changes to any `coderd\database\queries\*.sql` files you must run `make gen` to generate respective ORM changes.
### Authorization Context
## Architecture
```go
// Public endpoints needing system access
app, err := api.Database.GetOAuth2ProviderAppByClientID(dbauthz.AsSystemRestricted(ctx), clientID)
### Core Components
// Authenticated endpoints with user context
app, err := api.Database.GetOAuth2ProviderAppByClientID(ctx, clientID)
```
- **coderd**: Main API service connecting workspaces, provisioners, and users
- **provisionerd**: Execution context for infrastructure-modifying providers
- **Agents**: Services in remote workspaces providing features like SSH and port forwarding
- **Workspaces**: Cloud resources defined by Terraform
## 📋 Quick Reference
## Sub-modules
### Full workflows available in imported WORKFLOWS.md
### Template System
### New Feature Checklist
- Templates define infrastructure for workspaces using Terraform
- Environment variables pass context between Coder and templates
- Official modules extend development environments
- [ ] Run `git pull` to ensure latest code
- [ ] Check if feature touches database - you'll need migrations
- [ ] Check if feature touches audit logs - update `enterprise/audit/table.go`
### RBAC System
## 🏗️ Architecture
- Permissions defined at site, organization, and user levels
- Object-Action model protects resources
- Built-in roles: owner, member, auditor, templateAdmin
- Permission format: `<sign>?<level>.<object>.<id>.<action>`
- **coderd**: Main API service
- **provisionerd**: Infrastructure provisioning
- **Agents**: Workspace services (SSH, port forwarding)
- **Database**: PostgreSQL with `dbauthz` authorization
### Database
## 🧪 Testing
- PostgreSQL 13+ recommended for production
- Migrations managed with `migrate`
- Database authorization through `dbauthz` package
### Race Condition Prevention
## Frontend
- Use unique identifiers: `fmt.Sprintf("test-client-%s-%d", t.Name(), time.Now().UnixNano())`
- Never use hardcoded names in concurrent tests
The frontend is contained in the site folder.
### OAuth2 Testing
For building Frontend refer to [this document](docs/about/contributing/frontend.md)
- Full suite: `./scripts/oauth2/test-mcp-oauth2.sh`
- Manual testing: `./scripts/oauth2/test-manual-flow.sh`
### Timing Issues
NEVER use `time.Sleep` to mitigate timing issues. If an issue
seems like it should use `time.Sleep`, read through https://github.com/coder/quartz and specifically the [README](https://github.com/coder/quartz/blob/main/README.md) to better understand how to handle timing issues.
## 🎯 Code Style
### Detailed guidelines in imported WORKFLOWS.md
- Follow [Uber Go Style Guide](https://github.com/uber-go/guide/blob/master/style.md)
- Commit format: `type(scope): message`
## 📚 Detailed Development Guides
@.claude/docs/OAUTH2.md
@.claude/docs/TESTING.md
@.claude/docs/TROUBLESHOOTING.md
@.claude/docs/DATABASE.md
## 🚨 Common Pitfalls
1. **Audit table errors** → Update `enterprise/audit/table.go`
2. **OAuth2 errors** → Return RFC-compliant format
3. **Race conditions** → Use unique test identifiers
4. **Missing newlines** → Ensure files end with newline
---
*This file stays lean and actionable. Detailed workflows and explanations are imported automatically.*
+27 -4
View File
@@ -1,8 +1,31 @@
# These APIs are versioned, so any changes need to be carefully reviewed for whether
# to bump API major or minor versions.
# These APIs are versioned, so any changes need to be carefully reviewed for
# whether to bump API major or minor versions.
agent/proto/ @spikecurtis @johnstcn
provisionerd/proto/ @spikecurtis @johnstcn
provisionersdk/proto/ @spikecurtis @johnstcn
tailnet/proto/ @spikecurtis @johnstcn
vpn/vpn.proto @spikecurtis @johnstcn
vpn/version.go @spikecurtis @johnstcn
provisionerd/proto/ @spikecurtis @johnstcn
provisionersdk/proto/ @spikecurtis @johnstcn
# This caching code is particularly tricky, and one must be very careful when
# altering it.
coderd/files/ @aslilac
coderd/dynamicparameters/ @Emyrk
coderd/rbac/ @Emyrk
# Mainly dependent on coder/guts, which is maintained by @Emyrk
scripts/apitypings/ @Emyrk
scripts/gensite/ @aslilac
site/ @aslilac
site/src/hooks/ @Parkreiner
# These rules intentionally do not specify any owners. More specific rules
# override less specific rules, so these files are "ignored" by the site/ rule.
site/e2e/google/protobuf/timestampGenerated.ts
site/e2e/provisionerGenerated.ts
site/src/api/countriesGenerated.ts
site/src/api/rbacresourcesGenerated.ts
site/src/api/typesGenerated.ts
site/CLAUDE.md
+51 -4
View File
@@ -460,16 +460,31 @@ fmt: fmt/ts fmt/go fmt/terraform fmt/shfmt fmt/biome fmt/markdown
.PHONY: fmt
fmt/go:
ifdef FILE
# Format single file
if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.go ]] && ! grep -q "DO NOT EDIT" "$(FILE)"; then \
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/go$(RESET) $(FILE)"; \
go run mvdan.cc/gofumpt@v0.8.0 -w -l "$(FILE)"; \
fi
else
go mod tidy
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/go$(RESET)"
# VS Code users should check out
# https://github.com/mvdan/gofumpt#visual-studio-code
find . $(FIND_EXCLUSIONS) -type f -name '*.go' -print0 | \
xargs -0 grep --null -L "DO NOT EDIT" | \
xargs -0 go run mvdan.cc/gofumpt@v0.4.0 -w -l
xargs -0 grep -E --null -L '^// Code generated .* DO NOT EDIT\.$$' | \
xargs -0 go run mvdan.cc/gofumpt@v0.8.0 -w -l
endif
.PHONY: fmt/go
fmt/ts: site/node_modules/.installed
ifdef FILE
# Format single TypeScript/JavaScript file
if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.ts ]] || [[ "$(FILE)" == *.tsx ]] || [[ "$(FILE)" == *.js ]] || [[ "$(FILE)" == *.jsx ]]; then \
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/ts$(RESET) $(FILE)"; \
(cd site/ && pnpm exec biome format --write "../$(FILE)"); \
fi
else
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/ts$(RESET)"
cd site
# Avoid writing files in CI to reduce file write activity
@@ -478,9 +493,17 @@ ifdef CI
else
pnpm run check:fix
endif
endif
.PHONY: fmt/ts
fmt/biome: site/node_modules/.installed
ifdef FILE
# Format single file with biome
if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.ts ]] || [[ "$(FILE)" == *.tsx ]] || [[ "$(FILE)" == *.js ]] || [[ "$(FILE)" == *.jsx ]]; then \
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/biome$(RESET) $(FILE)"; \
(cd site/ && pnpm exec biome format --write "../$(FILE)"); \
fi
else
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/biome$(RESET)"
cd site/
# Avoid writing files in CI to reduce file write activity
@@ -489,14 +512,30 @@ ifdef CI
else
pnpm run format
endif
endif
.PHONY: fmt/biome
fmt/terraform: $(wildcard *.tf)
ifdef FILE
# Format single Terraform file
if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.tf ]] || [[ "$(FILE)" == *.tfvars ]]; then \
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/terraform$(RESET) $(FILE)"; \
terraform fmt "$(FILE)"; \
fi
else
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/terraform$(RESET)"
terraform fmt -recursive
endif
.PHONY: fmt/terraform
fmt/shfmt: $(SHELL_SRC_FILES)
ifdef FILE
# Format single shell script
if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.sh ]]; then \
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/shfmt$(RESET) $(FILE)"; \
shfmt -w "$(FILE)"; \
fi
else
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/shfmt$(RESET)"
# Only do diff check in CI, errors on diff.
ifdef CI
@@ -504,11 +543,20 @@ ifdef CI
else
shfmt -w $(SHELL_SRC_FILES)
endif
endif
.PHONY: fmt/shfmt
fmt/markdown: node_modules/.installed
ifdef FILE
# Format single markdown file
if [[ -f "$(FILE)" ]] && [[ "$(FILE)" == *.md ]]; then \
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/markdown$(RESET) $(FILE)"; \
pnpm exec markdown-table-formatter "$(FILE)"; \
fi
else
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/markdown$(RESET)"
pnpm format-docs
endif
.PHONY: fmt/markdown
lint: lint/shellcheck lint/go lint/ts lint/examples lint/helm lint/site-icons lint/markdown
@@ -555,7 +603,6 @@ DB_GEN_FILES := \
coderd/database/dump.sql \
coderd/database/querier.go \
coderd/database/unique_constraint.go \
coderd/database/dbmem/dbmem.go \
coderd/database/dbmetrics/dbmetrics.go \
coderd/database/dbauthz/dbauthz.go \
coderd/database/dbmock/dbmock.go
@@ -929,7 +976,7 @@ sqlc-vet: test-postgres-docker
test-postgres: test-postgres-docker
# The postgres test is prone to failure, so we limit parallelism for
# more consistent execution.
$(GIT_FLAGS) DB=ci gotestsum \
$(GIT_FLAGS) gotestsum \
--junitfile="gotests.xml" \
--jsonfile="gotests.json" \
$(GOTESTSUM_RETRY_FLAGS) \
+15 -20
View File
@@ -98,7 +98,7 @@ type Client interface {
ConnectRPC26(ctx context.Context) (
proto.DRPCAgentClient26, tailnetproto.DRPCTailnetClient26, error,
)
RewriteDERPMap(derpMap *tailcfg.DERPMap)
tailnet.DERPMapRewriter
}
type Agent interface {
@@ -336,18 +336,16 @@ func (a *agent) init() {
// will not report anywhere.
a.scriptRunner.RegisterMetrics(a.prometheusRegistry)
if a.devcontainers {
containerAPIOpts := []agentcontainers.Option{
agentcontainers.WithExecer(a.execer),
agentcontainers.WithCommandEnv(a.sshServer.CommandEnv),
agentcontainers.WithScriptLogger(func(logSourceID uuid.UUID) agentcontainers.ScriptLogger {
return a.logSender.GetScriptLogger(logSourceID)
}),
}
containerAPIOpts = append(containerAPIOpts, a.containerAPIOptions...)
a.containerAPI = agentcontainers.NewAPI(a.logger.Named("containers"), containerAPIOpts...)
containerAPIOpts := []agentcontainers.Option{
agentcontainers.WithExecer(a.execer),
agentcontainers.WithCommandEnv(a.sshServer.CommandEnv),
agentcontainers.WithScriptLogger(func(logSourceID uuid.UUID) agentcontainers.ScriptLogger {
return a.logSender.GetScriptLogger(logSourceID)
}),
}
containerAPIOpts = append(containerAPIOpts, a.containerAPIOptions...)
a.containerAPI = agentcontainers.NewAPI(a.logger.Named("containers"), containerAPIOpts...)
a.reconnectingPTYServer = reconnectingpty.NewServer(
a.logger.Named("reconnecting-pty"),
@@ -565,7 +563,6 @@ func (a *agent) reportMetadata(ctx context.Context, aAPI proto.DRPCAgentClient26
// channel to synchronize the results and avoid both messy
// mutex logic and overloading the API.
for _, md := range manifest.Metadata {
md := md
// We send the result to the channel in the goroutine to avoid
// sending the same result multiple times. So, we don't care about
// the return values.
@@ -1163,7 +1160,7 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
scripts = manifest.Scripts
devcontainerScripts map[uuid.UUID]codersdk.WorkspaceAgentScript
)
if a.containerAPI != nil {
if a.devcontainers {
// Init the container API with the manifest and client so that
// we can start accepting requests. The final start of the API
// happens after the startup scripts have been executed to
@@ -1171,7 +1168,7 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
// return existing devcontainers but actual container detection
// and creation will be deferred.
a.containerAPI.Init(
agentcontainers.WithManifestInfo(manifest.OwnerName, manifest.WorkspaceName, manifest.AgentName),
agentcontainers.WithManifestInfo(manifest.OwnerName, manifest.WorkspaceName, manifest.AgentName, manifest.Directory),
agentcontainers.WithDevcontainers(manifest.Devcontainers, manifest.Scripts),
agentcontainers.WithSubAgentClient(agentcontainers.NewSubAgentClientFromAPI(a.logger, aAPI)),
)
@@ -1198,7 +1195,7 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
// autostarted devcontainer will be included in this time.
err := a.scriptRunner.Execute(a.gracefulCtx, agentscripts.ExecuteStartScripts)
if a.containerAPI != nil {
if a.devcontainers {
// Start the container API after the startup scripts have
// been executed to ensure that the required tools can be
// installed.
@@ -1929,10 +1926,8 @@ func (a *agent) Close() error {
a.logger.Error(a.hardCtx, "script runner close", slog.Error(err))
}
if a.containerAPI != nil {
if err := a.containerAPI.Close(); err != nil {
a.logger.Error(a.hardCtx, "container API close", slog.Error(err))
}
if err := a.containerAPI.Close(); err != nil {
a.logger.Error(a.hardCtx, "container API close", slog.Error(err))
}
// Wait for the graceful shutdown to complete, but don't wait forever so
+10 -6
View File
@@ -2130,7 +2130,7 @@ func TestAgent_DevcontainerAutostart(t *testing.T) {
"name": "mywork",
"image": "ubuntu:latest",
"cmd": ["sleep", "infinity"],
"runArgs": ["--network=host"]
"runArgs": ["--network=host", "--label=`+agentcontainers.DevcontainerIsTestRunLabel+`=true"]
}`), 0o600)
require.NoError(t, err, "write devcontainer.json")
@@ -2167,6 +2167,7 @@ func TestAgent_DevcontainerAutostart(t *testing.T) {
// Only match this specific dev container.
agentcontainers.WithClock(mClock),
agentcontainers.WithContainerLabelIncludeFilter("devcontainer.local_folder", tempWorkspaceFolder),
agentcontainers.WithContainerLabelIncludeFilter(agentcontainers.DevcontainerIsTestRunLabel, "true"),
agentcontainers.WithSubAgentURL(srv.URL),
// The agent will copy "itself", but in the case of this test, the
// agent is actually this test binary. So we'll tell the test binary
@@ -2288,7 +2289,8 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
err = os.WriteFile(devcontainerFile, []byte(`{
"name": "mywork",
"image": "busybox:latest",
"cmd": ["sleep", "infinity"]
"cmd": ["sleep", "infinity"],
"runArgs": ["--label=`+agentcontainers.DevcontainerIsTestRunLabel+`=true"]
}`), 0o600)
require.NoError(t, err, "write devcontainer.json")
@@ -2315,6 +2317,7 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
o.Devcontainers = true
o.DevcontainerAPIOptions = append(o.DevcontainerAPIOptions,
agentcontainers.WithContainerLabelIncludeFilter("devcontainer.local_folder", workspaceFolder),
agentcontainers.WithContainerLabelIncludeFilter(agentcontainers.DevcontainerIsTestRunLabel, "true"),
)
})
@@ -2369,7 +2372,7 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
// devcontainer, we do it in a goroutine so we can process logs
// concurrently.
go func(container codersdk.WorkspaceAgentContainer) {
_, err := conn.RecreateDevcontainer(ctx, container.ID)
_, err := conn.RecreateDevcontainer(ctx, devcontainerID.String())
assert.NoError(t, err, "recreate devcontainer should succeed")
}(container)
@@ -2438,7 +2441,8 @@ func TestAgent_DevcontainersDisabledForSubAgent(t *testing.T) {
// Setup the agent with devcontainers enabled initially.
//nolint:dogsled
conn, _, _, _, _ := setupAgent(t, manifest, 0, func(*agenttest.Client, *agent.Options) {
conn, _, _, _, _ := setupAgent(t, manifest, 0, func(_ *agenttest.Client, o *agent.Options) {
o.Devcontainers = true
})
// Query the containers API endpoint. This should fail because
@@ -2450,8 +2454,8 @@ func TestAgent_DevcontainersDisabledForSubAgent(t *testing.T) {
require.Error(t, err)
// Verify the error message contains the expected text.
require.Contains(t, err.Error(), "The agent dev containers feature is experimental and not enabled by default.")
require.Contains(t, err.Error(), "To enable this feature, set CODER_AGENT_DEVCONTAINERS_ENABLE=true in your template.")
require.Contains(t, err.Error(), "Dev Container feature not supported.")
require.Contains(t, err.Error(), "Dev Container integration inside other Dev Containers is explicitly not supported.")
}
func TestAgent_Dial(t *testing.T) {
+334 -8
View File
@@ -2,8 +2,11 @@ package agentcontainers
import (
"context"
"encoding/json"
"errors"
"fmt"
"io/fs"
"maps"
"net/http"
"os"
"path"
@@ -18,10 +21,13 @@ import (
"github.com/fsnotify/fsnotify"
"github.com/go-chi/chi/v5"
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
"github.com/google/uuid"
"github.com/spf13/afero"
"golang.org/x/xerrors"
"cdr.dev/slog"
"github.com/coder/coder/v2/agent/agentcontainers/ignore"
"github.com/coder/coder/v2/agent/agentcontainers/watcher"
"github.com/coder/coder/v2/agent/agentexec"
"github.com/coder/coder/v2/agent/usershell"
@@ -30,6 +36,7 @@ import (
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/provisioner"
"github.com/coder/quartz"
"github.com/coder/websocket"
)
const (
@@ -53,10 +60,12 @@ type API struct {
cancel context.CancelFunc
watcherDone chan struct{}
updaterDone chan struct{}
discoverDone chan struct{}
updateTrigger chan chan error // Channel to trigger manual refresh.
updateInterval time.Duration // Interval for periodic container updates.
logger slog.Logger
watcher watcher.Watcher
fs afero.Fs
execer agentexec.Execer
commandEnv CommandEnv
ccli ContainerCLI
@@ -68,12 +77,17 @@ type API struct {
subAgentURL string
subAgentEnv []string
ownerName string
workspaceName string
parentAgent string
projectDiscovery bool // If we should perform project discovery or not.
discoveryAutostart bool // If we should autostart discovered projects.
ownerName string
workspaceName string
parentAgent string
agentDirectory string
mu sync.RWMutex // Protects the following fields.
initDone chan struct{} // Closed by Init.
updateChans []chan struct{}
closed bool
containers codersdk.WorkspaceAgentListContainersResponse // Output from the last list operation.
containersErr error // Error from the last list operation.
@@ -130,7 +144,9 @@ func WithCommandEnv(ce CommandEnv) Option {
strings.HasPrefix(s, "CODER_WORKSPACE_AGENT_URL=") ||
strings.HasPrefix(s, "CODER_AGENT_TOKEN=") ||
strings.HasPrefix(s, "CODER_AGENT_AUTH=") ||
strings.HasPrefix(s, "CODER_AGENT_DEVCONTAINERS_ENABLE=")
strings.HasPrefix(s, "CODER_AGENT_DEVCONTAINERS_ENABLE=") ||
strings.HasPrefix(s, "CODER_AGENT_DEVCONTAINERS_PROJECT_DISCOVERY_ENABLE=") ||
strings.HasPrefix(s, "CODER_AGENT_DEVCONTAINERS_DISCOVERY_AUTOSTART_ENABLE=")
})
return shell, dir, env, nil
}
@@ -188,11 +204,12 @@ func WithSubAgentEnv(env ...string) Option {
// WithManifestInfo sets the owner name, and workspace name
// for the sub-agent.
func WithManifestInfo(owner, workspace, parentAgent string) Option {
func WithManifestInfo(owner, workspace, parentAgent, agentDirectory string) Option {
return func(api *API) {
api.ownerName = owner
api.workspaceName = workspace
api.parentAgent = parentAgent
api.agentDirectory = agentDirectory
}
}
@@ -257,6 +274,29 @@ func WithWatcher(w watcher.Watcher) Option {
}
}
// WithFileSystem sets the file system used for discovering projects.
func WithFileSystem(fileSystem afero.Fs) Option {
return func(api *API) {
api.fs = fileSystem
}
}
// WithProjectDiscovery sets if the API should attempt to discover
// projects on the filesystem.
func WithProjectDiscovery(projectDiscovery bool) Option {
return func(api *API) {
api.projectDiscovery = projectDiscovery
}
}
// WithDiscoveryAutostart sets if the API should attempt to autostart
// projects that have been discovered
func WithDiscoveryAutostart(discoveryAutostart bool) Option {
return func(api *API) {
api.discoveryAutostart = discoveryAutostart
}
}
// ScriptLogger is an interface for sending devcontainer logs to the
// controlplane.
type ScriptLogger interface {
@@ -327,6 +367,9 @@ func NewAPI(logger slog.Logger, options ...Option) *API {
api.watcher = watcher.NewNoop()
}
}
if api.fs == nil {
api.fs = afero.NewOsFs()
}
if api.subAgentClient.Load() == nil {
var c SubAgentClient = noopSubAgentClient{}
api.subAgentClient.Store(&c)
@@ -368,6 +411,12 @@ func (api *API) Start() {
return
}
if api.projectDiscovery && api.agentDirectory != "" {
api.discoverDone = make(chan struct{})
go api.discover()
}
api.watcherDone = make(chan struct{})
api.updaterDone = make(chan struct{})
@@ -375,6 +424,162 @@ func (api *API) Start() {
go api.updaterLoop()
}
func (api *API) discover() {
defer close(api.discoverDone)
defer api.logger.Debug(api.ctx, "project discovery finished")
api.logger.Debug(api.ctx, "project discovery started")
if err := api.discoverDevcontainerProjects(); err != nil {
api.logger.Error(api.ctx, "discovering dev container projects", slog.Error(err))
}
if err := api.RefreshContainers(api.ctx); err != nil {
api.logger.Error(api.ctx, "refreshing containers after discovery", slog.Error(err))
}
}
func (api *API) discoverDevcontainerProjects() error {
isGitProject, err := afero.DirExists(api.fs, filepath.Join(api.agentDirectory, ".git"))
if err != nil {
return xerrors.Errorf(".git dir exists: %w", err)
}
// If the agent directory is a git project, we'll search
// the project for any `.devcontainer/devcontainer.json`
// files.
if isGitProject {
return api.discoverDevcontainersInProject(api.agentDirectory)
}
// The agent directory is _not_ a git project, so we'll
// search the top level of the agent directory for any
// git projects, and search those.
entries, err := afero.ReadDir(api.fs, api.agentDirectory)
if err != nil {
return xerrors.Errorf("read agent directory: %w", err)
}
for _, entry := range entries {
if !entry.IsDir() {
continue
}
isGitProject, err = afero.DirExists(api.fs, filepath.Join(api.agentDirectory, entry.Name(), ".git"))
if err != nil {
return xerrors.Errorf(".git dir exists: %w", err)
}
// If this directory is a git project, we'll search
// it for any `.devcontainer/devcontainer.json` files.
if isGitProject {
if err := api.discoverDevcontainersInProject(filepath.Join(api.agentDirectory, entry.Name())); err != nil {
return err
}
}
}
return nil
}
func (api *API) discoverDevcontainersInProject(projectPath string) error {
logger := api.logger.
Named("project-discovery").
With(slog.F("project_path", projectPath))
globalPatterns, err := ignore.LoadGlobalPatterns(api.fs)
if err != nil {
return xerrors.Errorf("read global git ignore patterns: %w", err)
}
patterns, err := ignore.ReadPatterns(api.ctx, logger, api.fs, projectPath)
if err != nil {
return xerrors.Errorf("read git ignore patterns: %w", err)
}
matcher := gitignore.NewMatcher(append(globalPatterns, patterns...))
devcontainerConfigPaths := []string{
"/.devcontainer/devcontainer.json",
"/.devcontainer.json",
}
return afero.Walk(api.fs, projectPath, func(path string, info fs.FileInfo, err error) error {
if err != nil {
logger.Error(api.ctx, "encountered error while walking for dev container projects",
slog.F("path", path),
slog.Error(err))
return nil
}
pathParts := ignore.FilePathToParts(path)
// We know that a directory entry cannot be a `devcontainer.json` file, so we
// always skip processing directories. If the directory happens to be ignored
// by git then we'll make sure to ignore all of the children of that directory.
if info.IsDir() {
if matcher.Match(pathParts, true) {
return fs.SkipDir
}
return nil
}
if matcher.Match(pathParts, false) {
return nil
}
for _, relativeConfigPath := range devcontainerConfigPaths {
if !strings.HasSuffix(path, relativeConfigPath) {
continue
}
workspaceFolder := strings.TrimSuffix(path, relativeConfigPath)
logger := logger.With(slog.F("workspace_folder", workspaceFolder))
logger.Debug(api.ctx, "discovered dev container project")
api.mu.Lock()
if _, found := api.knownDevcontainers[workspaceFolder]; !found {
logger.Debug(api.ctx, "adding dev container project")
dc := codersdk.WorkspaceAgentDevcontainer{
ID: uuid.New(),
Name: "", // Updated later based on container state.
WorkspaceFolder: workspaceFolder,
ConfigPath: path,
Status: codersdk.WorkspaceAgentDevcontainerStatusStopped,
Dirty: false, // Updated later based on config file changes.
Container: nil,
}
if api.discoveryAutostart {
config, err := api.dccli.ReadConfig(api.ctx, workspaceFolder, path, []string{})
if err != nil {
logger.Error(api.ctx, "read project configuration", slog.Error(err))
} else if config.Configuration.Customizations.Coder.AutoStart {
dc.Status = codersdk.WorkspaceAgentDevcontainerStatusStarting
}
}
api.knownDevcontainers[workspaceFolder] = dc
api.broadcastUpdatesLocked()
if dc.Status == codersdk.WorkspaceAgentDevcontainerStatusStarting {
api.asyncWg.Add(1)
go func() {
defer api.asyncWg.Done()
_ = api.CreateDevcontainer(dc.WorkspaceFolder, dc.ConfigPath)
}()
}
}
api.mu.Unlock()
}
return nil
})
}
func (api *API) watcherLoop() {
defer close(api.watcherDone)
defer api.logger.Debug(api.ctx, "watcher loop stopped")
@@ -449,6 +654,7 @@ func (api *API) updaterLoop() {
// We utilize a TickerFunc here instead of a regular Ticker so that
// we can guarantee execution of the updateContainers method after
// advancing the clock.
var prevErr error
ticker := api.clock.TickerFunc(api.ctx, api.updateInterval, func() error {
done := make(chan error, 1)
var sent bool
@@ -466,9 +672,15 @@ func (api *API) updaterLoop() {
if err != nil {
if errors.Is(err, context.Canceled) {
api.logger.Warn(api.ctx, "updater loop ticker canceled", slog.Error(err))
} else {
return nil
}
// Avoid excessive logging of the same error.
if prevErr == nil || prevErr.Error() != err.Error() {
api.logger.Error(api.ctx, "updater loop ticker failed", slog.Error(err))
}
prevErr = err
} else {
prevErr = nil
}
default:
api.logger.Debug(api.ctx, "updater loop ticker skipped, update in progress")
@@ -528,6 +740,7 @@ func (api *API) Routes() http.Handler {
r.Use(ensureInitDoneMW)
r.Get("/", api.handleList)
r.Get("/watch", api.watchContainers)
// TODO(mafredri): Simplify this route as the previous /devcontainers
// /-route was dropped. We can drop the /devcontainers prefix here too.
r.Route("/devcontainers/{devcontainer}", func(r chi.Router) {
@@ -537,6 +750,88 @@ func (api *API) Routes() http.Handler {
return r
}
func (api *API) broadcastUpdatesLocked() {
// Broadcast state changes to WebSocket listeners.
for _, ch := range api.updateChans {
select {
case ch <- struct{}{}:
default:
}
}
}
func (api *API) watchContainers(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()
conn, err := websocket.Accept(rw, r, nil)
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Failed to upgrade connection to websocket.",
Detail: err.Error(),
})
return
}
// Here we close the websocket for reading, so that the websocket library will handle pings and
// close frames.
_ = conn.CloseRead(context.Background())
ctx, wsNetConn := codersdk.WebsocketNetConn(ctx, conn, websocket.MessageText)
defer wsNetConn.Close()
go httpapi.Heartbeat(ctx, conn)
updateCh := make(chan struct{}, 1)
api.mu.Lock()
api.updateChans = append(api.updateChans, updateCh)
api.mu.Unlock()
defer func() {
api.mu.Lock()
api.updateChans = slices.DeleteFunc(api.updateChans, func(ch chan struct{}) bool {
return ch == updateCh
})
close(updateCh)
api.mu.Unlock()
}()
encoder := json.NewEncoder(wsNetConn)
ct, err := api.getContainers()
if err != nil {
api.logger.Error(ctx, "unable to get containers", slog.Error(err))
return
}
if err := encoder.Encode(ct); err != nil {
api.logger.Error(ctx, "encode container list", slog.Error(err))
return
}
for {
select {
case <-api.ctx.Done():
return
case <-ctx.Done():
return
case <-updateCh:
ct, err := api.getContainers()
if err != nil {
api.logger.Error(ctx, "unable to get containers", slog.Error(err))
continue
}
if err := encoder.Encode(ct); err != nil {
api.logger.Error(ctx, "encode container list", slog.Error(err))
return
}
}
}
}
// handleList handles the HTTP request to list containers.
func (api *API) handleList(rw http.ResponseWriter, r *http.Request) {
ct, err := api.getContainers()
@@ -576,8 +871,26 @@ func (api *API) updateContainers(ctx context.Context) error {
api.mu.Lock()
defer api.mu.Unlock()
var previouslyKnownDevcontainers map[string]codersdk.WorkspaceAgentDevcontainer
if len(api.updateChans) > 0 {
previouslyKnownDevcontainers = maps.Clone(api.knownDevcontainers)
}
api.processUpdatedContainersLocked(ctx, updated)
if len(api.updateChans) > 0 {
statesAreEqual := maps.EqualFunc(
previouslyKnownDevcontainers,
api.knownDevcontainers,
func(dc1, dc2 codersdk.WorkspaceAgentDevcontainer) bool {
return dc1.Equals(dc2)
})
if !statesAreEqual {
api.broadcastUpdatesLocked()
}
}
api.logger.Debug(ctx, "containers updated successfully", slog.F("container_count", len(api.containers.Containers)), slog.F("warning_count", len(api.containers.Warnings)), slog.F("devcontainer_count", len(api.knownDevcontainers)))
return nil
@@ -717,6 +1030,9 @@ func (api *API) processUpdatedContainersLocked(ctx context.Context, updated code
err := api.maybeInjectSubAgentIntoContainerLocked(ctx, dc)
if err != nil {
logger.Error(ctx, "inject subagent into container failed", slog.Error(err))
dc.Error = err.Error()
} else {
dc.Error = ""
}
}
@@ -943,7 +1259,10 @@ func (api *API) handleDevcontainerRecreate(w http.ResponseWriter, r *http.Reques
// devcontainer multiple times in parallel.
dc.Status = codersdk.WorkspaceAgentDevcontainerStatusStarting
dc.Container = nil
dc.Error = ""
api.knownDevcontainers[dc.WorkspaceFolder] = dc
api.broadcastUpdatesLocked()
go func() {
_ = api.CreateDevcontainer(dc.WorkspaceFolder, dc.ConfigPath, WithRemoveExistingContainer())
}()
@@ -1032,6 +1351,7 @@ func (api *API) CreateDevcontainer(workspaceFolder, configPath string, opts ...D
api.mu.Lock()
dc = api.knownDevcontainers[dc.WorkspaceFolder]
dc.Status = codersdk.WorkspaceAgentDevcontainerStatusError
dc.Error = err.Error()
api.knownDevcontainers[dc.WorkspaceFolder] = dc
api.recreateErrorTimes[dc.WorkspaceFolder] = api.clock.Now("agentcontainers", "recreate", "errorTimes")
api.mu.Unlock()
@@ -1055,8 +1375,10 @@ func (api *API) CreateDevcontainer(workspaceFolder, configPath string, opts ...D
}
}
dc.Dirty = false
dc.Error = ""
api.recreateSuccessTimes[dc.WorkspaceFolder] = api.clock.Now("agentcontainers", "recreate", "successTimes")
api.knownDevcontainers[dc.WorkspaceFolder] = dc
api.broadcastUpdatesLocked()
api.mu.Unlock()
// Ensure an immediate refresh to accurately reflect the
@@ -1523,7 +1845,9 @@ func (api *API) maybeInjectSubAgentIntoContainerLocked(ctx context.Context, dc c
originalName := subAgentConfig.Name
for attempt := 1; attempt <= maxAttemptsToNameAgent; attempt++ {
if proc.agent, err = client.Create(ctx, subAgentConfig); err == nil {
agent, err := client.Create(ctx, subAgentConfig)
if err == nil {
proc.agent = agent // Only reassign on success.
if api.usingWorkspaceFolderName[dc.WorkspaceFolder] {
api.devcontainerNames[dc.Name] = true
delete(api.usingWorkspaceFolderName, dc.WorkspaceFolder)
@@ -1531,7 +1855,6 @@ func (api *API) maybeInjectSubAgentIntoContainerLocked(ctx context.Context, dc c
break
}
// NOTE(DanielleMaywood):
// Ordinarily we'd use `errors.As` here, but it didn't appear to work. Not
// sure if this is because of the communication protocol? Instead I've opted
@@ -1686,6 +2009,9 @@ func (api *API) Close() error {
if api.updaterDone != nil {
<-api.updaterDone
}
if api.discoverDone != nil {
<-api.discoverDone
}
// Wait for all async tasks to complete.
api.asyncWg.Wait()
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -61,7 +61,7 @@ fi
exec 3>&-
# Format the generated code.
go run mvdan.cc/gofumpt@v0.4.0 -w -l "${TMPDIR}/${DEST_FILENAME}"
go run mvdan.cc/gofumpt@v0.8.0 -w -l "${TMPDIR}/${DEST_FILENAME}"
# Add a header so that Go recognizes this as a generated file.
if grep -q -- "\[-i extension\]" < <(sed -h 2>&1); then
+33 -32
View File
@@ -91,6 +91,7 @@ type CoderCustomization struct {
Apps []SubAgentApp `json:"apps,omitempty"`
Name string `json:"name,omitempty"`
Ignore bool `json:"ignore,omitempty"`
AutoStart bool `json:"autoStart,omitempty"`
}
type DevcontainerWorkspace struct {
@@ -106,63 +107,63 @@ type DevcontainerCLI interface {
// DevcontainerCLIUpOptions are options for the devcontainer CLI Up
// command.
type DevcontainerCLIUpOptions func(*devcontainerCLIUpConfig)
type DevcontainerCLIUpOptions func(*DevcontainerCLIUpConfig)
type devcontainerCLIUpConfig struct {
args []string // Additional arguments for the Up command.
stdout io.Writer
stderr io.Writer
type DevcontainerCLIUpConfig struct {
Args []string // Additional arguments for the Up command.
Stdout io.Writer
Stderr io.Writer
}
// WithRemoveExistingContainer is an option to remove the existing
// container.
func WithRemoveExistingContainer() DevcontainerCLIUpOptions {
return func(o *devcontainerCLIUpConfig) {
o.args = append(o.args, "--remove-existing-container")
return func(o *DevcontainerCLIUpConfig) {
o.Args = append(o.Args, "--remove-existing-container")
}
}
// WithUpOutput sets additional stdout and stderr writers for logs
// during Up operations.
func WithUpOutput(stdout, stderr io.Writer) DevcontainerCLIUpOptions {
return func(o *devcontainerCLIUpConfig) {
o.stdout = stdout
o.stderr = stderr
return func(o *DevcontainerCLIUpConfig) {
o.Stdout = stdout
o.Stderr = stderr
}
}
// DevcontainerCLIExecOptions are options for the devcontainer CLI Exec
// command.
type DevcontainerCLIExecOptions func(*devcontainerCLIExecConfig)
type DevcontainerCLIExecOptions func(*DevcontainerCLIExecConfig)
type devcontainerCLIExecConfig struct {
args []string // Additional arguments for the Exec command.
stdout io.Writer
stderr io.Writer
type DevcontainerCLIExecConfig struct {
Args []string // Additional arguments for the Exec command.
Stdout io.Writer
Stderr io.Writer
}
// WithExecOutput sets additional stdout and stderr writers for logs
// during Exec operations.
func WithExecOutput(stdout, stderr io.Writer) DevcontainerCLIExecOptions {
return func(o *devcontainerCLIExecConfig) {
o.stdout = stdout
o.stderr = stderr
return func(o *DevcontainerCLIExecConfig) {
o.Stdout = stdout
o.Stderr = stderr
}
}
// WithExecContainerID sets the container ID to target a specific
// container.
func WithExecContainerID(id string) DevcontainerCLIExecOptions {
return func(o *devcontainerCLIExecConfig) {
o.args = append(o.args, "--container-id", id)
return func(o *DevcontainerCLIExecConfig) {
o.Args = append(o.Args, "--container-id", id)
}
}
// WithRemoteEnv sets environment variables for the Exec command.
func WithRemoteEnv(env ...string) DevcontainerCLIExecOptions {
return func(o *devcontainerCLIExecConfig) {
return func(o *DevcontainerCLIExecConfig) {
for _, e := range env {
o.args = append(o.args, "--remote-env", e)
o.Args = append(o.Args, "--remote-env", e)
}
}
}
@@ -185,8 +186,8 @@ func WithReadConfigOutput(stdout, stderr io.Writer) DevcontainerCLIReadConfigOpt
}
}
func applyDevcontainerCLIUpOptions(opts []DevcontainerCLIUpOptions) devcontainerCLIUpConfig {
conf := devcontainerCLIUpConfig{stdout: io.Discard, stderr: io.Discard}
func applyDevcontainerCLIUpOptions(opts []DevcontainerCLIUpOptions) DevcontainerCLIUpConfig {
conf := DevcontainerCLIUpConfig{Stdout: io.Discard, Stderr: io.Discard}
for _, opt := range opts {
if opt != nil {
opt(&conf)
@@ -195,8 +196,8 @@ func applyDevcontainerCLIUpOptions(opts []DevcontainerCLIUpOptions) devcontainer
return conf
}
func applyDevcontainerCLIExecOptions(opts []DevcontainerCLIExecOptions) devcontainerCLIExecConfig {
conf := devcontainerCLIExecConfig{stdout: io.Discard, stderr: io.Discard}
func applyDevcontainerCLIExecOptions(opts []DevcontainerCLIExecOptions) DevcontainerCLIExecConfig {
conf := DevcontainerCLIExecConfig{Stdout: io.Discard, Stderr: io.Discard}
for _, opt := range opts {
if opt != nil {
opt(&conf)
@@ -241,7 +242,7 @@ func (d *devcontainerCLI) Up(ctx context.Context, workspaceFolder, configPath st
if configPath != "" {
args = append(args, "--config", configPath)
}
args = append(args, conf.args...)
args = append(args, conf.Args...)
cmd := d.execer.CommandContext(ctx, "devcontainer", args...)
// Capture stdout for parsing and stream logs for both default and provided writers.
@@ -251,14 +252,14 @@ func (d *devcontainerCLI) Up(ctx context.Context, workspaceFolder, configPath st
&devcontainerCLILogWriter{
ctx: ctx,
logger: logger.With(slog.F("stdout", true)),
writer: conf.stdout,
writer: conf.Stdout,
},
)
// Stream stderr logs and provided writer if any.
cmd.Stderr = &devcontainerCLILogWriter{
ctx: ctx,
logger: logger.With(slog.F("stderr", true)),
writer: conf.stderr,
writer: conf.Stderr,
}
if err := cmd.Run(); err != nil {
@@ -293,17 +294,17 @@ func (d *devcontainerCLI) Exec(ctx context.Context, workspaceFolder, configPath
if configPath != "" {
args = append(args, "--config", configPath)
}
args = append(args, conf.args...)
args = append(args, conf.Args...)
args = append(args, cmd)
args = append(args, cmdArgs...)
c := d.execer.CommandContext(ctx, "devcontainer", args...)
c.Stdout = io.MultiWriter(conf.stdout, &devcontainerCLILogWriter{
c.Stdout = io.MultiWriter(conf.Stdout, &devcontainerCLILogWriter{
ctx: ctx,
logger: logger.With(slog.F("stdout", true)),
writer: io.Discard,
})
c.Stderr = io.MultiWriter(conf.stderr, &devcontainerCLILogWriter{
c.Stderr = io.MultiWriter(conf.Stderr, &devcontainerCLILogWriter{
ctx: ctx,
logger: logger.With(slog.F("stderr", true)),
writer: io.Discard,
@@ -593,7 +593,7 @@ func setupDevcontainerWorkspace(t *testing.T, workspaceFolder string) string {
"containerEnv": {
"TEST_CONTAINER": "true"
},
"runArgs": ["--label", "com.coder.test=devcontainercli"]
"runArgs": ["--label=com.coder.test=devcontainercli", "--label=` + agentcontainers.DevcontainerIsTestRunLabel + `=true"]
}`
err = os.WriteFile(configPath, []byte(content), 0o600)
require.NoError(t, err, "create devcontainer.json file")
+124
View File
@@ -0,0 +1,124 @@
package ignore
import (
"bytes"
"context"
"errors"
"io/fs"
"os"
"path/filepath"
"strings"
"github.com/go-git/go-git/v5/plumbing/format/config"
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
"github.com/spf13/afero"
"golang.org/x/xerrors"
"cdr.dev/slog"
)
const (
gitconfigFile = ".gitconfig"
gitignoreFile = ".gitignore"
gitInfoExcludeFile = ".git/info/exclude"
)
func FilePathToParts(path string) []string {
components := []string{}
if path == "" {
return components
}
for segment := range strings.SplitSeq(filepath.Clean(path), string(filepath.Separator)) {
if segment != "" {
components = append(components, segment)
}
}
return components
}
func readIgnoreFile(fileSystem afero.Fs, path, ignore string) ([]gitignore.Pattern, error) {
var ps []gitignore.Pattern
data, err := afero.ReadFile(fileSystem, filepath.Join(path, ignore))
if err != nil && !errors.Is(err, os.ErrNotExist) {
return nil, err
}
for s := range strings.SplitSeq(string(data), "\n") {
if !strings.HasPrefix(s, "#") && len(strings.TrimSpace(s)) > 0 {
ps = append(ps, gitignore.ParsePattern(s, FilePathToParts(path)))
}
}
return ps, nil
}
func ReadPatterns(ctx context.Context, logger slog.Logger, fileSystem afero.Fs, path string) ([]gitignore.Pattern, error) {
var ps []gitignore.Pattern
subPs, err := readIgnoreFile(fileSystem, path, gitInfoExcludeFile)
if err != nil {
return nil, err
}
ps = append(ps, subPs...)
if err := afero.Walk(fileSystem, path, func(path string, info fs.FileInfo, err error) error {
if err != nil {
logger.Error(ctx, "encountered error while walking for git ignore files",
slog.F("path", path),
slog.Error(err))
return nil
}
if !info.IsDir() {
return nil
}
subPs, err := readIgnoreFile(fileSystem, path, gitignoreFile)
if err != nil {
return err
}
ps = append(ps, subPs...)
return nil
}); err != nil {
return nil, err
}
return ps, nil
}
func loadPatterns(fileSystem afero.Fs, path string) ([]gitignore.Pattern, error) {
data, err := afero.ReadFile(fileSystem, path)
if err != nil && !errors.Is(err, os.ErrNotExist) {
return nil, err
}
decoder := config.NewDecoder(bytes.NewBuffer(data))
conf := config.New()
if err := decoder.Decode(conf); err != nil {
return nil, xerrors.Errorf("decode config: %w", err)
}
excludes := conf.Section("core").Options.Get("excludesfile")
if excludes == "" {
return nil, nil
}
return readIgnoreFile(fileSystem, "", excludes)
}
func LoadGlobalPatterns(fileSystem afero.Fs) ([]gitignore.Pattern, error) {
home, err := os.UserHomeDir()
if err != nil {
return nil, err
}
return loadPatterns(fileSystem, filepath.Join(home, gitconfigFile))
}
+38
View File
@@ -0,0 +1,38 @@
package ignore_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/agent/agentcontainers/ignore"
)
func TestFilePathToParts(t *testing.T) {
t.Parallel()
tests := []struct {
path string
expected []string
}{
{"", []string{}},
{"/", []string{}},
{"foo", []string{"foo"}},
{"/foo", []string{"foo"}},
{"./foo/bar", []string{"foo", "bar"}},
{"../foo/bar", []string{"..", "foo", "bar"}},
{"foo/bar/baz", []string{"foo", "bar", "baz"}},
{"/foo/bar/baz", []string{"foo", "bar", "baz"}},
{"foo/../bar", []string{"bar"}},
}
for _, tt := range tests {
t.Run(fmt.Sprintf("`%s`", tt.path), func(t *testing.T) {
t.Parallel()
parts := ignore.FilePathToParts(tt.path)
require.Equal(t, tt.expected, parts)
})
}
}
+16 -8
View File
@@ -188,7 +188,7 @@ func (a *subAgentAPIClient) List(ctx context.Context) ([]SubAgent, error) {
return agents, nil
}
func (a *subAgentAPIClient) Create(ctx context.Context, agent SubAgent) (SubAgent, error) {
func (a *subAgentAPIClient) Create(ctx context.Context, agent SubAgent) (_ SubAgent, err error) {
a.logger.Debug(ctx, "creating sub agent", slog.F("name", agent.Name), slog.F("directory", agent.Directory))
displayApps := make([]agentproto.CreateSubAgentRequest_DisplayApp, 0, len(agent.DisplayApps))
@@ -233,19 +233,27 @@ func (a *subAgentAPIClient) Create(ctx context.Context, agent SubAgent) (SubAgen
if err != nil {
return SubAgent{}, err
}
defer func() {
if err != nil {
// Best effort.
_, _ = a.api.DeleteSubAgent(ctx, &agentproto.DeleteSubAgentRequest{
Id: resp.GetAgent().GetId(),
})
}
}()
agent.Name = resp.Agent.Name
agent.ID, err = uuid.FromBytes(resp.Agent.Id)
agent.Name = resp.GetAgent().GetName()
agent.ID, err = uuid.FromBytes(resp.GetAgent().GetId())
if err != nil {
return agent, err
return SubAgent{}, err
}
agent.AuthToken, err = uuid.FromBytes(resp.Agent.AuthToken)
agent.AuthToken, err = uuid.FromBytes(resp.GetAgent().GetAuthToken())
if err != nil {
return agent, err
return SubAgent{}, err
}
for _, appError := range resp.AppCreationErrors {
app := apps[appError.Index]
for _, appError := range resp.GetAppCreationErrors() {
app := apps[appError.GetIndex()]
a.logger.Warn(ctx, "unable to create app",
slog.F("agent_name", agent.Name),
+26 -15
View File
@@ -4,6 +4,7 @@ import (
"context"
"os"
"path/filepath"
"runtime"
"testing"
"github.com/fsnotify/fsnotify"
@@ -88,24 +89,34 @@ func TestFSNotifyWatcher(t *testing.T) {
break
}
err = os.WriteFile(testFile+".atomic", []byte(`{"test": "atomic"}`), 0o600)
require.NoError(t, err, "write new atomic test file failed")
// TODO(DanielleMaywood):
// Unfortunately it appears this atomic-rename phase of the test is flakey on macOS.
//
// This test flake could be indicative of an issue that may present itself
// in a running environment. Fortunately, we only use this (as of 2025-07-29)
// for our dev container integration. We do not expect the host workspace
// (where this is used), to ever be run on macOS, as containers are a linux
// paradigm.
if runtime.GOOS != "darwin" {
err = os.WriteFile(testFile+".atomic", []byte(`{"test": "atomic"}`), 0o600)
require.NoError(t, err, "write new atomic test file failed")
err = os.Rename(testFile+".atomic", testFile)
require.NoError(t, err, "rename atomic test file failed")
err = os.Rename(testFile+".atomic", testFile)
require.NoError(t, err, "rename atomic test file failed")
// Verify that we receive the event we want.
for {
event, err := wut.Next(ctx)
require.NoError(t, err, "next event failed")
require.NotNil(t, event, "want non-nil event")
if !event.Has(fsnotify.Create) {
t.Logf("Ignoring event: %s", event)
continue
// Verify that we receive the event we want.
for {
event, err := wut.Next(ctx)
require.NoError(t, err, "next event failed")
require.NotNil(t, event, "want non-nil event")
if !event.Has(fsnotify.Create) {
t.Logf("Ignoring event: %s", event)
continue
}
require.Truef(t, event.Has(fsnotify.Create), "want create event: %s", event.String())
require.Equal(t, event.Name, testFile, "want event for test file")
break
}
require.Truef(t, event.Has(fsnotify.Create), "want create event: %s", event.String())
require.Equal(t, event.Name, testFile, "want event for test file")
break
}
// Test removing the file from the watcher.
-2
View File
@@ -149,7 +149,6 @@ func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript, scriptCompleted S
if script.Cron == "" {
continue
}
script := script
_, err := r.cron.AddFunc(script.Cron, func() {
err := r.trackRun(r.cronCtx, script, ExecuteCronScripts)
if err != nil {
@@ -224,7 +223,6 @@ func (r *Runner) Execute(ctx context.Context, option ExecuteOption) error {
continue
}
script := script
eg.Go(func() error {
err := r.trackRun(ctx, script, option)
if err != nil {
+29 -5
View File
@@ -117,6 +117,10 @@ type Config struct {
// Note that this is different from the devcontainers feature, which uses
// subagents.
ExperimentalContainers bool
// X11Net allows overriding the networking implementation used for X11
// forwarding listeners. When nil, a default implementation backed by the
// standard library networking package is used.
X11Net X11Network
}
type Server struct {
@@ -131,9 +135,10 @@ type Server struct {
// a lock on mu but protected by closing.
wg sync.WaitGroup
Execer agentexec.Execer
logger slog.Logger
srv *ssh.Server
Execer agentexec.Execer
logger slog.Logger
srv *ssh.Server
x11Forwarder *x11Forwarder
config *Config
@@ -190,6 +195,20 @@ func NewServer(ctx context.Context, logger slog.Logger, prometheusRegistry *prom
config: config,
metrics: metrics,
x11Forwarder: &x11Forwarder{
logger: logger,
x11HandlerErrors: metrics.x11HandlerErrors,
fs: fs,
displayOffset: *config.X11DisplayOffset,
sessions: make(map[*x11Session]struct{}),
connections: make(map[net.Conn]struct{}),
network: func() X11Network {
if config.X11Net != nil {
return config.X11Net
}
return osNet{}
}(),
},
}
srv := &ssh.Server{
@@ -457,7 +476,7 @@ func (s *Server) sessionHandler(session ssh.Session) {
x11, hasX11 := session.X11()
if hasX11 {
display, handled := s.x11Handler(ctx, x11)
display, handled := s.x11Forwarder.x11Handler(ctx, session)
if !handled {
logger.Error(ctx, "x11 handler failed")
closeCause("x11 handler failed")
@@ -590,7 +609,9 @@ func (s *Server) startNonPTYSession(logger slog.Logger, session ssh.Session, mag
// and SSH server close may be delayed.
cmd.SysProcAttr = cmdSysProcAttr()
// to match OpenSSH, we don't actually tear a non-TTY command down, even if the session ends.
// to match OpenSSH, we don't actually tear a non-TTY command down, even if the session ends. OpenSSH closes the
// pipes to the process when the session ends; which is what happens here since we wire the command up to the
// session for I/O.
// c.f. https://github.com/coder/coder/issues/18519#issuecomment-3019118271
cmd.Cancel = nil
@@ -1154,6 +1175,9 @@ func (s *Server) Close() error {
s.mu.Unlock()
s.logger.Debug(ctx, "closing X11 forwarding")
_ = s.x11Forwarder.Close()
s.logger.Debug(ctx, "waiting for all goroutines to exit")
s.wg.Wait() // Wait for all goroutines to exit.
+77
View File
@@ -8,7 +8,9 @@ import (
"context"
"fmt"
"net"
"os"
"os/user"
"path/filepath"
"runtime"
"strings"
"sync"
@@ -403,6 +405,81 @@ func TestNewServer_Signal(t *testing.T) {
})
}
func TestSSHServer_ClosesStdin(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("bash doesn't exist on Windows")
}
ctx := testutil.Context(t, testutil.WaitMedium)
logger := testutil.Logger(t)
s, err := agentssh.NewServer(ctx, logger, prometheus.NewRegistry(), afero.NewMemMapFs(), agentexec.DefaultExecer, nil)
require.NoError(t, err)
defer s.Close()
err = s.UpdateHostSigner(42)
assert.NoError(t, err)
ln, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)
done := make(chan struct{})
go func() {
defer close(done)
err := s.Serve(ln)
assert.Error(t, err) // Server is closed.
}()
defer func() {
err := s.Close()
require.NoError(t, err)
<-done
}()
c := sshClient(t, ln.Addr().String())
sess, err := c.NewSession()
require.NoError(t, err)
stdout, err := sess.StdoutPipe()
require.NoError(t, err)
stdin, err := sess.StdinPipe()
require.NoError(t, err)
defer stdin.Close()
dir := t.TempDir()
err = os.MkdirAll(dir, 0o755)
require.NoError(t, err)
filePath := filepath.Join(dir, "result.txt")
// the shell command `read` will block until data is written to stdin, or closed. It will return
// exit code 1 if it hits EOF, which is what we want to test.
cmdErrCh := make(chan error, 1)
go func() {
cmdErrCh <- sess.Start(fmt.Sprintf(`echo started; echo "read exit code: $(read && echo 0 || echo 1)" > %s`, filePath))
}()
cmdErr := testutil.RequireReceive(ctx, t, cmdErrCh)
require.NoError(t, cmdErr)
readCh := make(chan error, 1)
go func() {
buf := make([]byte, 8)
_, err := stdout.Read(buf)
assert.Equal(t, "started\n", string(buf))
readCh <- err
}()
err = testutil.RequireReceive(ctx, t, readCh)
require.NoError(t, err)
sess.Close()
var content []byte
testutil.Eventually(ctx, t, func(_ context.Context) bool {
content, err = os.ReadFile(filePath)
return err == nil
}, testutil.IntervalFast)
require.NoError(t, err)
require.Equal(t, "read exit code: 1\n", string(content))
}
func sshClient(t *testing.T, addr string) *ssh.Client {
conn, err := net.Dial("tcp", addr)
require.NoError(t, err)
+291 -76
View File
@@ -7,15 +7,16 @@ import (
"errors"
"fmt"
"io"
"math"
"net"
"os"
"path/filepath"
"strconv"
"sync"
"time"
"github.com/gliderlabs/ssh"
"github.com/gofrs/flock"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/afero"
gossh "golang.org/x/crypto/ssh"
"golang.org/x/xerrors"
@@ -29,8 +30,51 @@ const (
X11StartPort = 6000
// X11DefaultDisplayOffset is the default offset for X11 forwarding.
X11DefaultDisplayOffset = 10
X11MaxDisplays = 200
// X11MaxPort is the highest port we will ever use for X11 forwarding. This limits the total number of TCP sockets
// we will create. It seems more useful to have a maximum port number than a direct limit on sockets with no max
// port because we'd like to be able to tell users the exact range of ports the Agent might use.
X11MaxPort = X11StartPort + X11MaxDisplays
)
// X11Network abstracts the creation of network listeners for X11 forwarding.
// It is intended mainly for testing; production code uses the default
// implementation backed by the operating system networking stack.
type X11Network interface {
Listen(network, address string) (net.Listener, error)
}
// osNet is the default X11Network implementation that uses the standard
// library network stack.
type osNet struct{}
func (osNet) Listen(network, address string) (net.Listener, error) {
return net.Listen(network, address)
}
type x11Forwarder struct {
logger slog.Logger
x11HandlerErrors *prometheus.CounterVec
fs afero.Fs
displayOffset int
// network creates X11 listener sockets. Defaults to osNet{}.
network X11Network
mu sync.Mutex
sessions map[*x11Session]struct{}
connections map[net.Conn]struct{}
closing bool
wg sync.WaitGroup
}
type x11Session struct {
session ssh.Session
display int
listener net.Listener
usedAt time.Time
}
// x11Callback is called when the client requests X11 forwarding.
func (*Server) x11Callback(_ ssh.Context, _ ssh.X11) bool {
// Always allow.
@@ -39,115 +83,243 @@ func (*Server) x11Callback(_ ssh.Context, _ ssh.X11) bool {
// x11Handler is called when a session has requested X11 forwarding.
// It listens for X11 connections and forwards them to the client.
func (s *Server) x11Handler(ctx ssh.Context, x11 ssh.X11) (displayNumber int, handled bool) {
serverConn, valid := ctx.Value(ssh.ContextKeyConn).(*gossh.ServerConn)
if !valid {
s.logger.Warn(ctx, "failed to get server connection")
func (x *x11Forwarder) x11Handler(sshCtx ssh.Context, sshSession ssh.Session) (displayNumber int, handled bool) {
x11, hasX11 := sshSession.X11()
if !hasX11 {
return -1, false
}
serverConn, valid := sshCtx.Value(ssh.ContextKeyConn).(*gossh.ServerConn)
if !valid {
x.logger.Warn(sshCtx, "failed to get server connection")
return -1, false
}
ctx := slog.With(sshCtx, slog.F("session_id", fmt.Sprintf("%x", serverConn.SessionID())))
hostname, err := os.Hostname()
if err != nil {
s.logger.Warn(ctx, "failed to get hostname", slog.Error(err))
s.metrics.x11HandlerErrors.WithLabelValues("hostname").Add(1)
x.logger.Warn(ctx, "failed to get hostname", slog.Error(err))
x.x11HandlerErrors.WithLabelValues("hostname").Add(1)
return -1, false
}
ln, display, err := createX11Listener(ctx, *s.config.X11DisplayOffset)
x11session, err := x.createX11Session(ctx, sshSession)
if err != nil {
s.logger.Warn(ctx, "failed to create X11 listener", slog.Error(err))
s.metrics.x11HandlerErrors.WithLabelValues("listen").Add(1)
x.logger.Warn(ctx, "failed to create X11 listener", slog.Error(err))
x.x11HandlerErrors.WithLabelValues("listen").Add(1)
return -1, false
}
s.trackListener(ln, true)
defer func() {
if !handled {
s.trackListener(ln, false)
_ = ln.Close()
x.closeAndRemoveSession(x11session)
}
}()
err = addXauthEntry(ctx, s.fs, hostname, strconv.Itoa(display), x11.AuthProtocol, x11.AuthCookie)
err = addXauthEntry(ctx, x.fs, hostname, strconv.Itoa(x11session.display), x11.AuthProtocol, x11.AuthCookie)
if err != nil {
s.logger.Warn(ctx, "failed to add Xauthority entry", slog.Error(err))
s.metrics.x11HandlerErrors.WithLabelValues("xauthority").Add(1)
x.logger.Warn(ctx, "failed to add Xauthority entry", slog.Error(err))
x.x11HandlerErrors.WithLabelValues("xauthority").Add(1)
return -1, false
}
// clean up the X11 session if the SSH session completes.
go func() {
// Don't leave the listener open after the session is gone.
<-ctx.Done()
_ = ln.Close()
x.closeAndRemoveSession(x11session)
}()
go func() {
defer ln.Close()
defer s.trackListener(ln, false)
go x.listenForConnections(ctx, x11session, serverConn, x11)
x.logger.Debug(ctx, "X11 forwarding started", slog.F("display", x11session.display))
for {
conn, err := ln.Accept()
if err != nil {
if errors.Is(err, net.ErrClosed) {
return
}
s.logger.Warn(ctx, "failed to accept X11 connection", slog.Error(err))
return x11session.display, true
}
func (x *x11Forwarder) trackGoroutine() (closing bool, done func()) {
x.mu.Lock()
defer x.mu.Unlock()
if !x.closing {
x.wg.Add(1)
return false, func() { x.wg.Done() }
}
return true, func() {}
}
func (x *x11Forwarder) listenForConnections(
ctx context.Context, session *x11Session, serverConn *gossh.ServerConn, x11 ssh.X11,
) {
defer x.closeAndRemoveSession(session)
if closing, done := x.trackGoroutine(); closing {
return
} else { // nolint: revive
defer done()
}
for {
conn, err := session.listener.Accept()
if err != nil {
if errors.Is(err, net.ErrClosed) {
return
}
if x11.SingleConnection {
s.logger.Debug(ctx, "single connection requested, closing X11 listener")
_ = ln.Close()
}
tcpConn, ok := conn.(*net.TCPConn)
if !ok {
s.logger.Warn(ctx, fmt.Sprintf("failed to cast connection to TCPConn. got: %T", conn))
_ = conn.Close()
continue
}
tcpAddr, ok := tcpConn.LocalAddr().(*net.TCPAddr)
if !ok {
s.logger.Warn(ctx, fmt.Sprintf("failed to cast local address to TCPAddr. got: %T", tcpConn.LocalAddr()))
_ = conn.Close()
continue
}
channel, reqs, err := serverConn.OpenChannel("x11", gossh.Marshal(struct {
OriginatorAddress string
OriginatorPort uint32
}{
OriginatorAddress: tcpAddr.IP.String(),
// #nosec G115 - Safe conversion as TCP port numbers are within uint32 range (0-65535)
OriginatorPort: uint32(tcpAddr.Port),
}))
if err != nil {
s.logger.Warn(ctx, "failed to open X11 channel", slog.Error(err))
_ = conn.Close()
continue
}
go gossh.DiscardRequests(reqs)
if !s.trackConn(ln, conn, true) {
s.logger.Warn(ctx, "failed to track X11 connection")
_ = conn.Close()
continue
}
go func() {
defer s.trackConn(ln, conn, false)
Bicopy(ctx, conn, channel)
}()
x.logger.Warn(ctx, "failed to accept X11 connection", slog.Error(err))
return
}
}()
return display, true
// Update session usage time since a new X11 connection was forwarded.
x.mu.Lock()
session.usedAt = time.Now()
x.mu.Unlock()
if x11.SingleConnection {
x.logger.Debug(ctx, "single connection requested, closing X11 listener")
x.closeAndRemoveSession(session)
}
var originAddr string
var originPort uint32
if tcpConn, ok := conn.(*net.TCPConn); ok {
if tcpAddr, ok := tcpConn.LocalAddr().(*net.TCPAddr); ok {
originAddr = tcpAddr.IP.String()
// #nosec G115 - Safe conversion as TCP port numbers are within uint32 range (0-65535)
originPort = uint32(tcpAddr.Port)
}
}
// Fallback values for in-memory or non-TCP connections.
if originAddr == "" {
originAddr = "127.0.0.1"
}
channel, reqs, err := serverConn.OpenChannel("x11", gossh.Marshal(struct {
OriginatorAddress string
OriginatorPort uint32
}{
OriginatorAddress: originAddr,
OriginatorPort: originPort,
}))
if err != nil {
x.logger.Warn(ctx, "failed to open X11 channel", slog.Error(err))
_ = conn.Close()
continue
}
go gossh.DiscardRequests(reqs)
if !x.trackConn(conn, true) {
x.logger.Warn(ctx, "failed to track X11 connection")
_ = conn.Close()
continue
}
go func() {
defer x.trackConn(conn, false)
Bicopy(ctx, conn, channel)
}()
}
}
// closeAndRemoveSession closes and removes the session.
func (x *x11Forwarder) closeAndRemoveSession(x11session *x11Session) {
_ = x11session.listener.Close()
x.mu.Lock()
delete(x.sessions, x11session)
x.mu.Unlock()
}
// createX11Session creates an X11 forwarding session.
func (x *x11Forwarder) createX11Session(ctx context.Context, sshSession ssh.Session) (*x11Session, error) {
var (
ln net.Listener
display int
err error
)
// retry listener creation after evictions. Limit to 10 retries to prevent pathological cases looping forever.
const maxRetries = 10
for try := range maxRetries {
ln, display, err = x.createX11Listener(ctx)
if err == nil {
break
}
if try == maxRetries-1 {
return nil, xerrors.New("max retries exceeded while creating X11 session")
}
x.logger.Warn(ctx, "failed to create X11 listener; will evict an X11 forwarding session",
slog.F("num_current_sessions", x.numSessions()),
slog.Error(err))
x.evictLeastRecentlyUsedSession()
}
x.mu.Lock()
defer x.mu.Unlock()
if x.closing {
closeErr := ln.Close()
if closeErr != nil {
x.logger.Error(ctx, "error closing X11 listener", slog.Error(closeErr))
}
return nil, xerrors.New("server is closing")
}
x11Sess := &x11Session{
session: sshSession,
display: display,
listener: ln,
usedAt: time.Now(),
}
x.sessions[x11Sess] = struct{}{}
return x11Sess, nil
}
func (x *x11Forwarder) numSessions() int {
x.mu.Lock()
defer x.mu.Unlock()
return len(x.sessions)
}
func (x *x11Forwarder) popLeastRecentlyUsedSession() *x11Session {
x.mu.Lock()
defer x.mu.Unlock()
var lru *x11Session
for s := range x.sessions {
if lru == nil {
lru = s
continue
}
if s.usedAt.Before(lru.usedAt) {
lru = s
continue
}
}
if lru == nil {
x.logger.Debug(context.Background(), "tried to pop from empty set of X11 sessions")
return nil
}
delete(x.sessions, lru)
return lru
}
func (x *x11Forwarder) evictLeastRecentlyUsedSession() {
lru := x.popLeastRecentlyUsedSession()
if lru == nil {
return
}
err := lru.listener.Close()
if err != nil {
x.logger.Error(context.Background(), "failed to close evicted X11 session listener", slog.Error(err))
}
// when we evict, we also want to force the SSH session to be closed as well. This is because we intend to reuse
// the X11 TCP listener port for a new X11 forwarding session. If we left the SSH session up, then graphical apps
// started in that session could potentially connect to an unintended X11 Server (i.e. the display on a different
// computer than the one that started the SSH session). Most likely, this session is a zombie anyway if we've
// reached the maximum number of X11 forwarding sessions.
err = lru.session.Close()
if err != nil {
x.logger.Error(context.Background(), "failed to close evicted X11 SSH session", slog.Error(err))
}
}
// createX11Listener creates a listener for X11 forwarding, it will use
// the next available port starting from X11StartPort and displayOffset.
func createX11Listener(ctx context.Context, displayOffset int) (ln net.Listener, display int, err error) {
var lc net.ListenConfig
func (x *x11Forwarder) createX11Listener(ctx context.Context) (ln net.Listener, display int, err error) {
// Look for an open port to listen on.
for port := X11StartPort + displayOffset; port < math.MaxUint16; port++ {
ln, err = lc.Listen(ctx, "tcp", fmt.Sprintf("localhost:%d", port))
for port := X11StartPort + x.displayOffset; port <= X11MaxPort; port++ {
if ctx.Err() != nil {
return nil, -1, ctx.Err()
}
ln, err = x.network.Listen("tcp", fmt.Sprintf("localhost:%d", port))
if err == nil {
display = port - X11StartPort
return ln, display, nil
@@ -156,6 +328,49 @@ func createX11Listener(ctx context.Context, displayOffset int) (ln net.Listener,
return nil, -1, xerrors.Errorf("failed to find open port for X11 listener: %w", err)
}
// trackConn registers the connection with the x11Forwarder. If the server is
// closed, the connection is not registered and should be closed.
//
//nolint:revive
func (x *x11Forwarder) trackConn(c net.Conn, add bool) (ok bool) {
x.mu.Lock()
defer x.mu.Unlock()
if add {
if x.closing {
// Server or listener closed.
return false
}
x.wg.Add(1)
x.connections[c] = struct{}{}
return true
}
x.wg.Done()
delete(x.connections, c)
return true
}
func (x *x11Forwarder) Close() error {
x.mu.Lock()
x.closing = true
for s := range x.sessions {
sErr := s.listener.Close()
if sErr != nil {
x.logger.Debug(context.Background(), "failed to close X11 listener", slog.Error(sErr))
}
}
for c := range x.connections {
cErr := c.Close()
if cErr != nil {
x.logger.Debug(context.Background(), "failed to close X11 connection", slog.Error(cErr))
}
}
x.mu.Unlock()
x.wg.Wait()
return nil
}
// addXauthEntry adds an Xauthority entry to the Xauthority file.
// The Xauthority file is located at ~/.Xauthority.
func addXauthEntry(ctx context.Context, fs afero.Fs, host string, display string, authProtocol string, authCookie string) error {
+227 -14
View File
@@ -3,9 +3,9 @@ package agentssh_test
import (
"bufio"
"bytes"
"context"
"encoding/hex"
"fmt"
"io"
"net"
"os"
"path/filepath"
@@ -32,10 +32,19 @@ func TestServer_X11(t *testing.T) {
t.Skip("X11 forwarding is only supported on Linux")
}
ctx := context.Background()
ctx := testutil.Context(t, testutil.WaitShort)
logger := testutil.Logger(t)
fs := afero.NewOsFs()
s, err := agentssh.NewServer(ctx, logger, prometheus.NewRegistry(), fs, agentexec.DefaultExecer, &agentssh.Config{})
fs := afero.NewMemMapFs()
// Use in-process networking for X11 forwarding.
inproc := testutil.NewInProcNet()
// Create server config with custom X11 listener.
cfg := &agentssh.Config{
X11Net: inproc,
}
s, err := agentssh.NewServer(ctx, logger, prometheus.NewRegistry(), fs, agentexec.DefaultExecer, cfg)
require.NoError(t, err)
defer s.Close()
err = s.UpdateHostSigner(42)
@@ -93,17 +102,15 @@ func TestServer_X11(t *testing.T) {
x11Chans := c.HandleChannelOpen("x11")
payload := "hello world"
require.Eventually(t, func() bool {
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", agentssh.X11StartPort+displayNumber))
if err == nil {
_, err = conn.Write([]byte(payload))
assert.NoError(t, err)
_ = conn.Close()
}
return err == nil
}, testutil.WaitShort, testutil.IntervalFast)
go func() {
conn, err := inproc.Dial(ctx, testutil.NewAddr("tcp", fmt.Sprintf("localhost:%d", agentssh.X11StartPort+displayNumber)))
assert.NoError(t, err)
_, err = conn.Write([]byte(payload))
assert.NoError(t, err)
_ = conn.Close()
}()
x11 := <-x11Chans
x11 := testutil.RequireReceive(ctx, t, x11Chans)
ch, reqs, err := x11.Accept()
require.NoError(t, err)
go gossh.DiscardRequests(reqs)
@@ -121,3 +128,209 @@ func TestServer_X11(t *testing.T) {
_, err = fs.Stat(filepath.Join(home, ".Xauthority"))
require.NoError(t, err)
}
func TestServer_X11_EvictionLRU(t *testing.T) {
t.Parallel()
if runtime.GOOS != "linux" {
t.Skip("X11 forwarding is only supported on Linux")
}
ctx := testutil.Context(t, testutil.WaitLong)
logger := testutil.Logger(t)
fs := afero.NewMemMapFs()
// Use in-process networking for X11 forwarding.
inproc := testutil.NewInProcNet()
cfg := &agentssh.Config{
X11Net: inproc,
}
s, err := agentssh.NewServer(ctx, logger, prometheus.NewRegistry(), fs, agentexec.DefaultExecer, cfg)
require.NoError(t, err)
defer s.Close()
err = s.UpdateHostSigner(42)
require.NoError(t, err)
ln, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)
done := testutil.Go(t, func() {
err := s.Serve(ln)
assert.Error(t, err)
})
c := sshClient(t, ln.Addr().String())
// block off one port to test x11Forwarder evicts at highest port, not number of listeners.
externalListener, err := inproc.Listen("tcp",
fmt.Sprintf("localhost:%d", agentssh.X11StartPort+agentssh.X11DefaultDisplayOffset+1))
require.NoError(t, err)
defer externalListener.Close()
// Calculate how many simultaneous X11 sessions we can create given the
// configured port range.
startPort := agentssh.X11StartPort + agentssh.X11DefaultDisplayOffset
maxSessions := agentssh.X11MaxPort - startPort + 1 - 1 // -1 for the blocked port
require.Greater(t, maxSessions, 0, "expected a positive maxSessions value")
// shellSession holds references to the session and its standard streams so
// that the test can keep them open (and optionally interact with them) for
// the lifetime of the test. If we don't start the Shell with pipes in place,
// the session will be torn down asynchronously during the test.
type shellSession struct {
sess *gossh.Session
stdin io.WriteCloser
stdout io.Reader
stderr io.Reader
// scanner is used to read the output of the session, line by line.
scanner *bufio.Scanner
}
sessions := make([]shellSession, 0, maxSessions)
for i := 0; i < maxSessions; i++ {
sess, err := c.NewSession()
require.NoError(t, err)
_, err = sess.SendRequest("x11-req", true, gossh.Marshal(ssh.X11{
AuthProtocol: "MIT-MAGIC-COOKIE-1",
AuthCookie: hex.EncodeToString([]byte(fmt.Sprintf("cookie%d", i))),
ScreenNumber: uint32(0),
}))
require.NoError(t, err)
stdin, err := sess.StdinPipe()
require.NoError(t, err)
stdout, err := sess.StdoutPipe()
require.NoError(t, err)
stderr, err := sess.StderrPipe()
require.NoError(t, err)
require.NoError(t, sess.Shell())
// The SSH server lazily starts the session. We need to write a command
// and read back to ensure the X11 forwarding is started.
scanner := bufio.NewScanner(stdout)
msg := fmt.Sprintf("ready-%d", i)
_, err = stdin.Write([]byte("echo " + msg + "\n"))
require.NoError(t, err)
// Read until we get the message (first token may be empty due to shell prompt)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if strings.Contains(line, msg) {
break
}
}
require.NoError(t, scanner.Err())
sessions = append(sessions, shellSession{
sess: sess,
stdin: stdin,
stdout: stdout,
stderr: stderr,
scanner: scanner,
})
}
// Connect X11 forwarding to the first session. This is used to test that
// connecting counts as a use of the display.
x11Chans := c.HandleChannelOpen("x11")
payload := "hello world"
go func() {
conn, err := inproc.Dial(ctx, testutil.NewAddr("tcp", fmt.Sprintf("localhost:%d", agentssh.X11StartPort+agentssh.X11DefaultDisplayOffset)))
assert.NoError(t, err)
_, err = conn.Write([]byte(payload))
assert.NoError(t, err)
_ = conn.Close()
}()
x11 := testutil.RequireReceive(ctx, t, x11Chans)
ch, reqs, err := x11.Accept()
require.NoError(t, err)
go gossh.DiscardRequests(reqs)
got := make([]byte, len(payload))
_, err = ch.Read(got)
require.NoError(t, err)
assert.Equal(t, payload, string(got))
_ = ch.Close()
// Create one more session which should evict a session and reuse the display.
// The first session was used to connect X11 forwarding, so it should not be evicted.
// Therefore, the second session should be evicted and its display reused.
extraSess, err := c.NewSession()
require.NoError(t, err)
_, err = extraSess.SendRequest("x11-req", true, gossh.Marshal(ssh.X11{
AuthProtocol: "MIT-MAGIC-COOKIE-1",
AuthCookie: hex.EncodeToString([]byte("extra")),
ScreenNumber: uint32(0),
}))
require.NoError(t, err)
// Ask the remote side for the DISPLAY value so we can extract the display
// number that was assigned to this session.
out, err := extraSess.Output("echo DISPLAY=$DISPLAY")
require.NoError(t, err)
// Example output line: "DISPLAY=localhost:10.0".
var newDisplayNumber int
{
sc := bufio.NewScanner(bytes.NewReader(out))
for sc.Scan() {
line := strings.TrimSpace(sc.Text())
if strings.HasPrefix(line, "DISPLAY=") {
parts := strings.SplitN(line, ":", 2)
require.Len(t, parts, 2)
displayPart := parts[1]
if strings.Contains(displayPart, ".") {
displayPart = strings.SplitN(displayPart, ".", 2)[0]
}
var convErr error
newDisplayNumber, convErr = strconv.Atoi(displayPart)
require.NoError(t, convErr)
break
}
}
require.NoError(t, sc.Err())
}
// The display number reused should correspond to the SECOND session (display offset 12)
expectedDisplay := agentssh.X11DefaultDisplayOffset + 2 // +1 was blocked port
assert.Equal(t, expectedDisplay, newDisplayNumber, "second session should have been evicted and its display reused")
// First session should still be alive: send cmd and read output.
msgFirst := "still-alive"
_, err = sessions[0].stdin.Write([]byte("echo " + msgFirst + "\n"))
require.NoError(t, err)
for sessions[0].scanner.Scan() {
line := strings.TrimSpace(sessions[0].scanner.Text())
if strings.Contains(line, msgFirst) {
break
}
}
require.NoError(t, sessions[0].scanner.Err())
// Second session should now be closed.
_, err = sessions[1].stdin.Write([]byte("echo dead\n"))
require.ErrorIs(t, err, io.EOF)
err = sessions[1].sess.Wait()
require.Error(t, err)
// Cleanup.
for i, sh := range sessions {
if i == 1 {
// already closed
continue
}
err = sh.stdin.Close()
require.NoError(t, err)
err = sh.sess.Wait()
require.NoError(t, err)
}
err = extraSess.Close()
require.ErrorIs(t, err, io.EOF)
err = s.Close()
require.NoError(t, err)
_ = testutil.TryReceive(ctx, t, done)
}
+10 -2
View File
@@ -6,6 +6,7 @@ import (
"time"
"github.com/go-chi/chi/v5"
"github.com/google/uuid"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/codersdk"
@@ -36,12 +37,19 @@ func (a *agent) apiHandler() http.Handler {
cacheDuration: cacheDuration,
}
if a.containerAPI != nil {
if a.devcontainers {
r.Mount("/api/v0/containers", a.containerAPI.Routes())
} else if manifest := a.manifest.Load(); manifest != nil && manifest.ParentID != uuid.Nil {
r.HandleFunc("/api/v0/containers", func(w http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), w, http.StatusForbidden, codersdk.Response{
Message: "Dev Container feature not supported.",
Detail: "Dev Container integration inside other Dev Containers is explicitly not supported.",
})
})
} else {
r.HandleFunc("/api/v0/containers", func(w http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), w, http.StatusForbidden, codersdk.Response{
Message: "The agent dev containers feature is experimental and not enabled by default.",
Message: "Dev Container feature not enabled.",
Detail: "To enable this feature, set CODER_AGENT_DEVCONTAINERS_ENABLE=true in your template.",
})
})
+19
View File
@@ -0,0 +1,19 @@
package archivefs
import (
"archive/zip"
"io"
"io/fs"
"github.com/spf13/afero"
"github.com/spf13/afero/zipfs"
)
// FromZipReader creates a read-only in-memory FS
func FromZipReader(r io.ReaderAt, size int64) (fs.FS, error) {
zr, err := zip.NewReader(r, size)
if err != nil {
return nil, err
}
return afero.NewIOFS(zipfs.New(zr)), nil
}
+10
View File
@@ -0,0 +1,10 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: coder
annotations:
github.com/project-slug: 'coder/coder'
spec:
type: service
lifecycle: production
owner: rd
+34 -16
View File
@@ -40,22 +40,24 @@ import (
func (r *RootCmd) workspaceAgent() *serpent.Command {
var (
auth string
logDir string
scriptDataDir string
pprofAddress string
noReap bool
sshMaxTimeout time.Duration
tailnetListenPort int64
prometheusAddress string
debugAddress string
slogHumanPath string
slogJSONPath string
slogStackdriverPath string
blockFileTransfer bool
agentHeaderCommand string
agentHeader []string
devcontainers bool
auth string
logDir string
scriptDataDir string
pprofAddress string
noReap bool
sshMaxTimeout time.Duration
tailnetListenPort int64
prometheusAddress string
debugAddress string
slogHumanPath string
slogJSONPath string
slogStackdriverPath string
blockFileTransfer bool
agentHeaderCommand string
agentHeader []string
devcontainers bool
devcontainerProjectDiscovery bool
devcontainerDiscoveryAutostart bool
)
cmd := &serpent.Command{
Use: "agent",
@@ -364,6 +366,8 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
Devcontainers: devcontainers,
DevcontainerAPIOptions: []agentcontainers.Option{
agentcontainers.WithSubAgentURL(r.agentURL.String()),
agentcontainers.WithProjectDiscovery(devcontainerProjectDiscovery),
agentcontainers.WithDiscoveryAutostart(devcontainerDiscoveryAutostart),
},
})
@@ -510,6 +514,20 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
Description: "Allow the agent to automatically detect running devcontainers.",
Value: serpent.BoolOf(&devcontainers),
},
{
Flag: "devcontainers-project-discovery-enable",
Default: "true",
Env: "CODER_AGENT_DEVCONTAINERS_PROJECT_DISCOVERY_ENABLE",
Description: "Allow the agent to search the filesystem for devcontainer projects.",
Value: serpent.BoolOf(&devcontainerProjectDiscovery),
},
{
Flag: "devcontainers-discovery-autostart-enable",
Default: "false",
Env: "CODER_AGENT_DEVCONTAINERS_DISCOVERY_AUTOSTART_ENABLE",
Description: "Allow the agent to autostart devcontainer projects it discovers based on their configuration.",
Value: serpent.BoolOf(&devcontainerDiscoveryAutostart),
},
}
return cmd
+121 -28
View File
@@ -12,6 +12,7 @@ import (
"golang.org/x/mod/semver"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/coderd/util/slice"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/pretty"
)
@@ -29,6 +30,7 @@ type WorkspaceResourcesOptions struct {
ServerVersion string
ListeningPorts map[uuid.UUID]codersdk.WorkspaceAgentListeningPortsResponse
Devcontainers map[uuid.UUID]codersdk.WorkspaceAgentListContainersResponse
ShowDetails bool
}
// WorkspaceResources displays the connection status and tree-view of provided resources.
@@ -69,7 +71,11 @@ func WorkspaceResources(writer io.Writer, resources []codersdk.WorkspaceResource
totalAgents := 0
for _, resource := range resources {
totalAgents += len(resource.Agents)
for _, agent := range resource.Agents {
if !agent.ParentID.Valid {
totalAgents++
}
}
}
for _, resource := range resources {
@@ -94,12 +100,15 @@ func WorkspaceResources(writer io.Writer, resources []codersdk.WorkspaceResource
"",
})
// Display all agents associated with the resource.
for index, agent := range resource.Agents {
agents := slice.Filter(resource.Agents, func(agent codersdk.WorkspaceAgent) bool {
return !agent.ParentID.Valid
})
for index, agent := range agents {
tableWriter.AppendRow(renderAgentRow(agent, index, totalAgents, options))
for _, row := range renderListeningPorts(options, agent.ID, index, totalAgents) {
tableWriter.AppendRow(row)
}
for _, row := range renderDevcontainers(options, agent.ID, index, totalAgents) {
for _, row := range renderDevcontainers(resources, options, agent.ID, index, totalAgents) {
tableWriter.AppendRow(row)
}
}
@@ -125,7 +134,7 @@ func renderAgentRow(agent codersdk.WorkspaceAgent, index, totalAgents int, optio
}
if !options.HideAccess {
sshCommand := "coder ssh " + options.WorkspaceName
if totalAgents > 1 {
if totalAgents > 1 || len(options.Devcontainers) > 0 {
sshCommand += "." + agent.Name
}
sshCommand = pretty.Sprint(DefaultStyles.Code, sshCommand)
@@ -164,45 +173,129 @@ func renderPortRow(port codersdk.WorkspaceAgentListeningPort, idx, total int) ta
return table.Row{sb.String()}
}
func renderDevcontainers(wro WorkspaceResourcesOptions, agentID uuid.UUID, index, totalAgents int) []table.Row {
func renderDevcontainers(resources []codersdk.WorkspaceResource, wro WorkspaceResourcesOptions, agentID uuid.UUID, index, totalAgents int) []table.Row {
var rows []table.Row
if wro.Devcontainers == nil {
return []table.Row{}
}
dc, ok := wro.Devcontainers[agentID]
if !ok || len(dc.Containers) == 0 {
if !ok || len(dc.Devcontainers) == 0 {
return []table.Row{}
}
rows = append(rows, table.Row{
fmt.Sprintf(" %s─ %s", renderPipe(index, totalAgents), "Devcontainers"),
})
for idx, container := range dc.Containers {
rows = append(rows, renderDevcontainerRow(container, idx, len(dc.Containers)))
for idx, devcontainer := range dc.Devcontainers {
rows = append(rows, renderDevcontainerRow(resources, devcontainer, idx, len(dc.Devcontainers), wro)...)
}
return rows
}
func renderDevcontainerRow(container codersdk.WorkspaceAgentContainer, index, total int) table.Row {
var row table.Row
var sb strings.Builder
_, _ = sb.WriteString(" ")
_, _ = sb.WriteString(renderPipe(index, total))
_, _ = sb.WriteString("─ ")
_, _ = sb.WriteString(pretty.Sprintf(DefaultStyles.Code, "%s", container.FriendlyName))
row = append(row, sb.String())
sb.Reset()
if container.Running {
_, _ = sb.WriteString(pretty.Sprintf(DefaultStyles.Keyword, "(%s)", container.Status))
} else {
_, _ = sb.WriteString(pretty.Sprintf(DefaultStyles.Error, "(%s)", container.Status))
func renderDevcontainerRow(resources []codersdk.WorkspaceResource, devcontainer codersdk.WorkspaceAgentDevcontainer, index, total int, wro WorkspaceResourcesOptions) []table.Row {
var rows []table.Row
// If the devcontainer is running and has an associated agent, we want to
// display the agent's details. Otherwise, we just display the devcontainer
// name and status.
var subAgent *codersdk.WorkspaceAgent
displayName := devcontainer.Name
if devcontainer.Agent != nil && devcontainer.Status == codersdk.WorkspaceAgentDevcontainerStatusRunning {
for _, resource := range resources {
if agent, found := slice.Find(resource.Agents, func(agent codersdk.WorkspaceAgent) bool {
return agent.ID == devcontainer.Agent.ID
}); found {
subAgent = &agent
break
}
}
if subAgent != nil {
displayName = subAgent.Name
displayName += fmt.Sprintf(" (%s, %s)", subAgent.OperatingSystem, subAgent.Architecture)
}
}
if devcontainer.Container != nil {
displayName += " " + pretty.Sprint(DefaultStyles.Keyword, "["+devcontainer.Container.FriendlyName+"]")
}
// Build the main row.
row := table.Row{
fmt.Sprintf(" %s─ %s", renderPipe(index, total), displayName),
}
// Add status, health, and version columns.
if !wro.HideAgentState {
if subAgent != nil {
row = append(row, renderAgentStatus(*subAgent))
row = append(row, renderAgentHealth(*subAgent))
row = append(row, renderAgentVersion(subAgent.Version, wro.ServerVersion))
} else {
row = append(row, renderDevcontainerStatus(devcontainer.Status))
row = append(row, "") // No health for devcontainer without agent.
row = append(row, "") // No version for devcontainer without agent.
}
}
// Add access column.
if !wro.HideAccess {
if subAgent != nil {
accessString := fmt.Sprintf("coder ssh %s.%s", wro.WorkspaceName, subAgent.Name)
row = append(row, pretty.Sprint(DefaultStyles.Code, accessString))
} else {
row = append(row, "") // No access for devcontainers without agent.
}
}
rows = append(rows, row)
// Add error message if present.
if errorMessage := devcontainer.Error; errorMessage != "" {
// Cap error message length for display.
if !wro.ShowDetails && len(errorMessage) > 80 {
errorMessage = errorMessage[:79] + "…"
}
errorRow := table.Row{
" × " + pretty.Sprint(DefaultStyles.Error, errorMessage),
"",
"",
"",
}
if !wro.HideAccess {
errorRow = append(errorRow, "")
}
rows = append(rows, errorRow)
}
// Add listening ports for the devcontainer agent.
if subAgent != nil {
portRows := renderListeningPorts(wro, subAgent.ID, index, total)
for _, portRow := range portRows {
// Adjust indentation for ports under devcontainer agent.
if len(portRow) > 0 {
if str, ok := portRow[0].(string); ok {
portRow[0] = " " + str // Add extra indentation.
}
}
rows = append(rows, portRow)
}
}
return rows
}
func renderDevcontainerStatus(status codersdk.WorkspaceAgentDevcontainerStatus) string {
switch status {
case codersdk.WorkspaceAgentDevcontainerStatusRunning:
return pretty.Sprint(DefaultStyles.Keyword, "▶ running")
case codersdk.WorkspaceAgentDevcontainerStatusStopped:
return pretty.Sprint(DefaultStyles.Placeholder, "⏹ stopped")
case codersdk.WorkspaceAgentDevcontainerStatusStarting:
return pretty.Sprint(DefaultStyles.Warn, "⧗ starting")
case codersdk.WorkspaceAgentDevcontainerStatusError:
return pretty.Sprint(DefaultStyles.Error, "✘ error")
default:
return pretty.Sprint(DefaultStyles.Placeholder, "○ "+string(status))
}
row = append(row, sb.String())
sb.Reset()
// "health" is not applicable here.
row = append(row, sb.String())
_, _ = sb.WriteString(container.Image)
row = append(row, sb.String())
return row
}
func renderAgentStatus(agent codersdk.WorkspaceAgent) string {
+1 -1
View File
@@ -446,7 +446,7 @@ func (r *RootCmd) configSSH() *serpent.Command {
if !bytes.Equal(configRaw, configModified) {
sshDir := filepath.Dir(sshConfigFile)
if err := os.MkdirAll(sshDir, 0700); err != nil {
if err := os.MkdirAll(sshDir, 0o700); err != nil {
return xerrors.Errorf("failed to create directory %q: %w", sshDir, err)
}
+7 -4
View File
@@ -204,10 +204,11 @@ func TestConfigSSH_MissingDirectory(t *testing.T) {
_, err = os.Stat(sshConfigPath)
require.NoError(t, err, "config file should exist")
// Check that the directory has proper permissions (0700)
// Check that the directory has proper permissions (rwx for owner, none for
// group and everyone)
sshDirInfo, err := os.Stat(sshDir)
require.NoError(t, err)
require.Equal(t, os.FileMode(0700), sshDirInfo.Mode().Perm(), "directory should have 0700 permissions")
require.Equal(t, os.FileMode(0o700), sshDirInfo.Mode().Perm(), "directory should have rwx------ permissions")
}
func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
@@ -358,7 +359,8 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
strings.Join([]string{
headerEnd,
"",
}, "\n")},
}, "\n"),
},
},
args: []string{"--ssh-option", "ForwardAgent=yes"},
matches: []match{
@@ -383,7 +385,8 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
strings.Join([]string{
headerEnd,
"",
}, "\n")},
}, "\n"),
},
},
args: []string{"--ssh-option", "ForwardAgent=yes"},
matches: []match{
+128 -2
View File
@@ -2,6 +2,7 @@ package cli
import (
"context"
"errors"
"fmt"
"io"
"slices"
@@ -21,10 +22,18 @@ import (
"github.com/coder/serpent"
)
// PresetNone represents the special preset value "none".
// It is used when a user runs `create --preset none`,
// indicating that the CLI should not apply any preset.
const PresetNone = "none"
var ErrNoPresetFound = xerrors.New("no preset found")
func (r *RootCmd) create() *serpent.Command {
var (
templateName string
templateVersion string
presetName string
startAt string
stopAfter time.Duration
workspaceName string
@@ -263,11 +272,45 @@ func (r *RootCmd) create() *serpent.Command {
}
}
// Get presets for the template version
tvPresets, err := client.TemplateVersionPresets(inv.Context(), templateVersionID)
if err != nil {
return xerrors.Errorf("failed to get presets: %w", err)
}
var preset *codersdk.Preset
var presetParameters []codersdk.WorkspaceBuildParameter
// If the template has no presets, or the user explicitly used --preset none,
// skip applying a preset
if len(tvPresets) > 0 && strings.ToLower(presetName) != PresetNone {
// Attempt to resolve which preset to use
preset, err = resolvePreset(tvPresets, presetName)
if err != nil {
if !errors.Is(err, ErrNoPresetFound) {
return xerrors.Errorf("unable to resolve preset: %w", err)
}
// If no preset found, prompt the user to choose a preset
if preset, err = promptPresetSelection(inv, tvPresets); err != nil {
return xerrors.Errorf("unable to prompt user for preset: %w", err)
}
}
// Convert preset parameters into workspace build parameters
presetParameters = presetParameterAsWorkspaceBuildParameters(preset.Parameters)
// Inform the user which preset was applied and its parameters
displayAppliedPreset(inv, preset, presetParameters)
} else {
// Inform the user that no preset was applied
_, _ = fmt.Fprintf(inv.Stdout, "%s", cliui.Bold("No preset applied."))
}
richParameters, err := prepWorkspaceBuild(inv, client, prepWorkspaceBuildArgs{
Action: WorkspaceCreate,
TemplateVersionID: templateVersionID,
NewWorkspaceName: workspaceName,
PresetParameters: presetParameters,
RichParameterFile: parameterFlags.richParameterFile,
RichParameters: cliBuildParameters,
RichParameterDefaults: cliBuildParameterDefaults,
@@ -291,14 +334,21 @@ func (r *RootCmd) create() *serpent.Command {
ttlMillis = ptr.Ref(stopAfter.Milliseconds())
}
workspace, err := client.CreateUserWorkspace(inv.Context(), workspaceOwner, codersdk.CreateWorkspaceRequest{
req := codersdk.CreateWorkspaceRequest{
TemplateVersionID: templateVersionID,
Name: workspaceName,
AutostartSchedule: schedSpec,
TTLMillis: ttlMillis,
RichParameterValues: richParameters,
AutomaticUpdates: codersdk.AutomaticUpdates(autoUpdates),
})
}
// If a preset exists, update the create workspace request's preset ID
if preset != nil {
req.TemplateVersionPresetID = preset.ID
}
workspace, err := client.CreateUserWorkspace(inv.Context(), workspaceOwner, req)
if err != nil {
return xerrors.Errorf("create workspace: %w", err)
}
@@ -333,6 +383,12 @@ func (r *RootCmd) create() *serpent.Command {
Description: "Specify a template version name.",
Value: serpent.StringOf(&templateVersion),
},
serpent.Option{
Flag: "preset",
Env: "CODER_PRESET_NAME",
Description: "Specify the name of a template version preset. Use 'none' to explicitly indicate that no preset should be used.",
Value: serpent.StringOf(&presetName),
},
serpent.Option{
Flag: "start-at",
Env: "CODER_WORKSPACE_START_AT",
@@ -377,12 +433,81 @@ type prepWorkspaceBuildArgs struct {
PromptEphemeralParameters bool
EphemeralParameters []codersdk.WorkspaceBuildParameter
PresetParameters []codersdk.WorkspaceBuildParameter
PromptRichParameters bool
RichParameters []codersdk.WorkspaceBuildParameter
RichParameterFile string
RichParameterDefaults []codersdk.WorkspaceBuildParameter
}
// resolvePreset returns the preset matching the given presetName (if specified),
// or the default preset (if any).
// Returns ErrNoPresetFound if no matching or default preset is found.
func resolvePreset(presets []codersdk.Preset, presetName string) (*codersdk.Preset, error) {
// If preset name is specified, find it
if presetName != "" {
for _, p := range presets {
if p.Name == presetName {
return &p, nil
}
}
return nil, xerrors.Errorf("preset %q not found", presetName)
}
// No preset name specified, search for the default preset
for _, p := range presets {
if p.Default {
return &p, nil
}
}
// No preset found
return nil, ErrNoPresetFound
}
// promptPresetSelection shows a CLI selection menu of the presets defined in the template version.
// Returns the selected preset
func promptPresetSelection(inv *serpent.Invocation, presets []codersdk.Preset) (*codersdk.Preset, error) {
presetMap := make(map[string]*codersdk.Preset)
var presetOptions []string
for _, preset := range presets {
var option string
if preset.Description == "" {
option = preset.Name
} else {
option = fmt.Sprintf("%s: %s", preset.Name, preset.Description)
}
presetOptions = append(presetOptions, option)
presetMap[option] = &preset
}
// Show selection UI
_, _ = fmt.Fprintln(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Wrap, "Select a preset below:"))
selected, err := cliui.Select(inv, cliui.SelectOptions{
Options: presetOptions,
HideSearch: true,
})
if err != nil {
return nil, xerrors.Errorf("failed to select preset: %w", err)
}
return presetMap[selected], nil
}
// displayAppliedPreset shows the user which preset was applied and its parameters
func displayAppliedPreset(inv *serpent.Invocation, preset *codersdk.Preset, parameters []codersdk.WorkspaceBuildParameter) {
label := fmt.Sprintf("Preset '%s'", preset.Name)
if preset.Default {
label += " (default)"
}
_, _ = fmt.Fprintf(inv.Stdout, "%s applied:\n", cliui.Bold(label))
for _, param := range parameters {
_, _ = fmt.Fprintf(inv.Stdout, " %s: '%s'\n", cliui.Bold(param.Name), param.Value)
}
}
// prepWorkspaceBuild will ensure a workspace build will succeed on the latest template version.
// Any missing params will be prompted to the user. It supports rich parameters.
func prepWorkspaceBuild(inv *serpent.Invocation, client *codersdk.Client, args prepWorkspaceBuildArgs) ([]codersdk.WorkspaceBuildParameter, error) {
@@ -411,6 +536,7 @@ func prepWorkspaceBuild(inv *serpent.Invocation, client *codersdk.Client, args p
WithSourceWorkspaceParameters(args.SourceWorkspaceParameters).
WithPromptEphemeralParameters(args.PromptEphemeralParameters).
WithEphemeralParameters(args.EphemeralParameters).
WithPresetParameters(args.PresetParameters).
WithPromptRichParameters(args.PromptRichParameters).
WithRichParameters(args.RichParameters).
WithRichParametersFile(parameterFile).
+639 -1
View File
@@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/cli"
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/coderd/externalauth"
@@ -298,7 +299,7 @@ func TestCreate(t *testing.T) {
})
}
func prepareEchoResponses(parameters []*proto.RichParameter) *echo.Responses {
func prepareEchoResponses(parameters []*proto.RichParameter, presets ...*proto.Preset) *echo.Responses {
return &echo.Responses{
Parse: echo.ParseComplete,
ProvisionPlan: []*proto.Response{
@@ -306,6 +307,7 @@ func prepareEchoResponses(parameters []*proto.RichParameter) *echo.Responses {
Type: &proto.Response_Plan{
Plan: &proto.PlanComplete{
Parameters: parameters,
Presets: presets,
},
},
},
@@ -663,6 +665,642 @@ func TestCreateWithRichParameters(t *testing.T) {
})
}
func TestCreateWithPreset(t *testing.T) {
t.Parallel()
const (
firstParameterName = "first_parameter"
firstParameterDisplayName = "First Parameter"
firstParameterDescription = "This is the first parameter"
firstParameterValue = "1"
firstOptionalParameterName = "first_optional_parameter"
firstOptionalParameterDescription = "This is the first optional parameter"
firstOptionalParameterValue = "1"
secondOptionalParameterName = "second_optional_parameter"
secondOptionalParameterDescription = "This is the second optional parameter"
secondOptionalParameterValue = "2"
thirdParameterName = "third_parameter"
thirdParameterDescription = "This is the third parameter"
thirdParameterValue = "3"
)
echoResponses := func(presets ...*proto.Preset) *echo.Responses {
return prepareEchoResponses([]*proto.RichParameter{
{
Name: firstParameterName,
DisplayName: firstParameterDisplayName,
Description: firstParameterDescription,
Mutable: true,
DefaultValue: firstParameterValue,
Options: []*proto.RichParameterOption{
{
Name: firstOptionalParameterName,
Description: firstOptionalParameterDescription,
Value: firstOptionalParameterValue,
},
{
Name: secondOptionalParameterName,
Description: secondOptionalParameterDescription,
Value: secondOptionalParameterValue,
},
},
},
{
Name: thirdParameterName,
Description: thirdParameterDescription,
DefaultValue: thirdParameterValue,
Mutable: true,
},
}, presets...)
}
// This test verifies that when a template has presets,
// including a default preset, and the user specifies a `--preset` flag,
// the CLI uses the specified preset instead of the default
t.Run("PresetFlag", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: a template and a template version with two presets, including a default
defaultPreset := proto.Preset{
Name: "preset-default",
Default: true,
Parameters: []*proto.PresetParameter{
{Name: thirdParameterName, Value: thirdParameterValue},
},
}
preset := proto.Preset{
Name: "preset-test",
Parameters: []*proto.PresetParameter{
{Name: firstParameterName, Value: secondOptionalParameterValue},
{Name: thirdParameterName, Value: thirdParameterValue},
},
}
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses(&defaultPreset, &preset))
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
// When: running the create command with the specified preset
workspaceName := "my-workspace"
inv, root := clitest.New(t, "create", workspaceName, "--template", template.Name, "-y", "--preset", preset.Name)
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t).Attach(inv)
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
err := inv.Run()
require.NoError(t, err)
// Should: display the selected preset as well as its parameters
presetName := fmt.Sprintf("Preset '%s' applied:", preset.Name)
pty.ExpectMatch(presetName)
pty.ExpectMatch(fmt.Sprintf("%s: '%s'", firstParameterName, secondOptionalParameterValue))
pty.ExpectMatch(fmt.Sprintf("%s: '%s'", thirdParameterName, thirdParameterValue))
// Verify if the new workspace uses expected parameters.
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
defer cancel()
tvPresets, err := client.TemplateVersionPresets(ctx, version.ID)
require.NoError(t, err)
require.Len(t, tvPresets, 2)
var selectedPreset *codersdk.Preset
for _, tvPreset := range tvPresets {
if tvPreset.Name == preset.Name {
selectedPreset = &tvPreset
}
}
require.NotNil(t, selectedPreset)
workspaces, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
Name: workspaceName,
})
require.NoError(t, err)
require.Len(t, workspaces.Workspaces, 1)
// Should: create a workspace using the expected template version and the preset-defined parameters
workspaceLatestBuild := workspaces.Workspaces[0].LatestBuild
require.Equal(t, version.ID, workspaceLatestBuild.TemplateVersionID)
require.Equal(t, selectedPreset.ID, *workspaceLatestBuild.TemplateVersionPresetID)
buildParameters, err := client.WorkspaceBuildParameters(ctx, workspaceLatestBuild.ID)
require.NoError(t, err)
require.Len(t, buildParameters, 2)
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: firstParameterName, Value: secondOptionalParameterValue})
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: thirdParameterName, Value: thirdParameterValue})
})
// This test verifies that when a template has presets,
// including a default preset, and the user does not specify the `--preset` flag,
// the CLI automatically uses the default preset to create the workspace
t.Run("DefaultPreset", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: a template and a template version with two presets, including a default
defaultPreset := proto.Preset{
Name: "preset-default",
Default: true,
Parameters: []*proto.PresetParameter{
{Name: firstParameterName, Value: secondOptionalParameterValue},
{Name: thirdParameterName, Value: thirdParameterValue},
},
}
preset := proto.Preset{
Name: "preset-test",
Parameters: []*proto.PresetParameter{
{Name: thirdParameterName, Value: thirdParameterValue},
},
}
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses(&defaultPreset, &preset))
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
// When: running the create command without a preset
workspaceName := "my-workspace"
inv, root := clitest.New(t, "create", workspaceName, "--template", template.Name, "-y")
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t).Attach(inv)
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
err := inv.Run()
require.NoError(t, err)
// Should: display the default preset as well as its parameters
presetName := fmt.Sprintf("Preset '%s' (default) applied:", defaultPreset.Name)
pty.ExpectMatch(presetName)
pty.ExpectMatch(fmt.Sprintf("%s: '%s'", firstParameterName, secondOptionalParameterValue))
pty.ExpectMatch(fmt.Sprintf("%s: '%s'", thirdParameterName, thirdParameterValue))
// Verify if the new workspace uses expected parameters.
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
defer cancel()
tvPresets, err := client.TemplateVersionPresets(ctx, version.ID)
require.NoError(t, err)
require.Len(t, tvPresets, 2)
var selectedPreset *codersdk.Preset
for _, tvPreset := range tvPresets {
if tvPreset.Default {
selectedPreset = &tvPreset
}
}
require.NotNil(t, selectedPreset)
workspaces, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
Name: workspaceName,
})
require.NoError(t, err)
require.Len(t, workspaces.Workspaces, 1)
// Should: create a workspace using the expected template version and the default preset parameters
workspaceLatestBuild := workspaces.Workspaces[0].LatestBuild
require.Equal(t, version.ID, workspaceLatestBuild.TemplateVersionID)
require.Equal(t, selectedPreset.ID, *workspaceLatestBuild.TemplateVersionPresetID)
buildParameters, err := client.WorkspaceBuildParameters(ctx, workspaceLatestBuild.ID)
require.NoError(t, err)
require.Len(t, buildParameters, 2)
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: firstParameterName, Value: secondOptionalParameterValue})
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: thirdParameterName, Value: thirdParameterValue})
})
// This test verifies that when a template has presets but no default preset,
// and the user does not provide the `--preset` flag,
// the CLI prompts the user to select a preset.
t.Run("NoDefaultPresetPromptUser", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: a template and a template version with two presets
preset := proto.Preset{
Name: "preset-test",
Description: "Preset Test.",
Parameters: []*proto.PresetParameter{
{Name: firstParameterName, Value: secondOptionalParameterValue},
{Name: thirdParameterName, Value: thirdParameterValue},
},
}
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses(&preset))
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
// When: running the create command without specifying a preset
workspaceName := "my-workspace"
inv, root := clitest.New(t, "create", workspaceName, "--template", template.Name,
"--parameter", fmt.Sprintf("%s=%s", firstParameterName, firstOptionalParameterValue),
"--parameter", fmt.Sprintf("%s=%s", thirdParameterName, thirdParameterValue))
clitest.SetupConfig(t, member, root)
doneChan := make(chan struct{})
pty := ptytest.New(t).Attach(inv)
go func() {
defer close(doneChan)
err := inv.Run()
assert.NoError(t, err)
}()
// Should: prompt the user for the preset
pty.ExpectMatch("Select a preset below:")
pty.WriteLine("\n")
pty.ExpectMatch("Preset 'preset-test' applied")
pty.ExpectMatch("Confirm create?")
pty.WriteLine("yes")
<-doneChan
// Verify if the new workspace uses expected parameters.
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
defer cancel()
tvPresets, err := client.TemplateVersionPresets(ctx, version.ID)
require.NoError(t, err)
require.Len(t, tvPresets, 1)
workspaces, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
Name: workspaceName,
})
require.NoError(t, err)
require.Len(t, workspaces.Workspaces, 1)
// Should: create a workspace using the expected template version and the preset-defined parameters
workspaceLatestBuild := workspaces.Workspaces[0].LatestBuild
require.Equal(t, version.ID, workspaceLatestBuild.TemplateVersionID)
require.Equal(t, tvPresets[0].ID, *workspaceLatestBuild.TemplateVersionPresetID)
buildParameters, err := client.WorkspaceBuildParameters(ctx, workspaceLatestBuild.ID)
require.NoError(t, err)
require.Len(t, buildParameters, 2)
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: firstParameterName, Value: secondOptionalParameterValue})
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: thirdParameterName, Value: thirdParameterValue})
})
// This test verifies that when a template version has no presets,
// the CLI does not prompt the user to select a preset and proceeds
// with workspace creation without applying any preset.
t.Run("TemplateVersionWithoutPresets", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: a template and a template version without presets
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses())
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
// When: running the create command without a preset
workspaceName := "my-workspace"
inv, root := clitest.New(t, "create", workspaceName, "--template", template.Name, "-y",
"--parameter", fmt.Sprintf("%s=%s", firstParameterName, firstOptionalParameterValue),
"--parameter", fmt.Sprintf("%s=%s", thirdParameterName, thirdParameterValue))
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t).Attach(inv)
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
err := inv.Run()
require.NoError(t, err)
pty.ExpectMatch("No preset applied.")
// Verify if the new workspace uses expected parameters.
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
defer cancel()
workspaces, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
Name: workspaceName,
})
require.NoError(t, err)
require.Len(t, workspaces.Workspaces, 1)
// Should: create a workspace using the expected template version and no preset
workspaceLatestBuild := workspaces.Workspaces[0].LatestBuild
require.Equal(t, version.ID, workspaceLatestBuild.TemplateVersionID)
require.Nil(t, workspaceLatestBuild.TemplateVersionPresetID)
buildParameters, err := client.WorkspaceBuildParameters(ctx, workspaceLatestBuild.ID)
require.NoError(t, err)
require.Len(t, buildParameters, 2)
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: firstParameterName, Value: firstOptionalParameterValue})
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: thirdParameterName, Value: thirdParameterValue})
})
// This test verifies that when the user provides `--preset none`,
// the CLI skips applying any preset, even if the template version has a default preset.
// The workspace should be created without using any preset-defined parameters.
t.Run("PresetFlagNone", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: a template and a template version with a default preset
preset := proto.Preset{
Name: "preset-test",
Default: true,
Parameters: []*proto.PresetParameter{
{Name: firstParameterName, Value: secondOptionalParameterValue},
{Name: thirdParameterName, Value: thirdParameterValue},
},
}
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses(&preset))
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
// When: running the create command with flag '--preset none'
workspaceName := "my-workspace"
inv, root := clitest.New(t, "create", workspaceName, "--template", template.Name, "-y", "--preset", cli.PresetNone,
"--parameter", fmt.Sprintf("%s=%s", firstParameterName, firstOptionalParameterValue),
"--parameter", fmt.Sprintf("%s=%s", thirdParameterName, thirdParameterValue))
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t).Attach(inv)
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
err := inv.Run()
require.NoError(t, err)
pty.ExpectMatch("No preset applied.")
// Verify that the new workspace doesn't use the preset parameters.
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
defer cancel()
tvPresets, err := client.TemplateVersionPresets(ctx, version.ID)
require.NoError(t, err)
require.Len(t, tvPresets, 1)
workspaces, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
Name: workspaceName,
})
require.NoError(t, err)
require.Len(t, workspaces.Workspaces, 1)
// Should: create a workspace using the expected template version and no preset
workspaceLatestBuild := workspaces.Workspaces[0].LatestBuild
require.Equal(t, version.ID, workspaceLatestBuild.TemplateVersionID)
require.Nil(t, workspaceLatestBuild.TemplateVersionPresetID)
buildParameters, err := client.WorkspaceBuildParameters(ctx, workspaceLatestBuild.ID)
require.NoError(t, err)
require.Len(t, buildParameters, 2)
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: firstParameterName, Value: firstOptionalParameterValue})
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: thirdParameterName, Value: thirdParameterValue})
})
// This test verifies that the CLI returns an appropriate error
// when a user provides a `--preset` value that does not correspond
// to any existing preset in the template version.
t.Run("FailsWhenPresetDoesNotExist", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: a template and a template version where the preset defines values for all required parameters
preset := proto.Preset{
Name: "preset-test",
Parameters: []*proto.PresetParameter{
{Name: firstParameterName, Value: secondOptionalParameterValue},
{Name: thirdParameterName, Value: thirdParameterValue},
},
}
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses(&preset))
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
// When: running the create command with a non-existent preset
workspaceName := "my-workspace"
inv, root := clitest.New(t, "create", workspaceName, "--template", template.Name, "-y", "--preset", "invalid-preset")
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t).Attach(inv)
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
err := inv.Run()
// Should: fail with an error indicating the preset was not found
require.Contains(t, err.Error(), "preset \"invalid-preset\" not found")
})
// This test verifies that when both a preset and a user-provided
// `--parameter` flag define a value for the same parameter,
// the preset's value takes precedence over the user's.
//
// The preset defines one parameter (A), and two `--parameter` flags provide A and B.
// The workspace should be created using:
// - the value of parameter A from the preset (overriding the parameter flag's value),
// - and the value of parameter B from the parameter flag.
t.Run("PresetOverridesParameterFlagValues", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: a template version with a preset that defines one parameter
preset := proto.Preset{
Name: "preset-test",
Parameters: []*proto.PresetParameter{
{Name: firstParameterName, Value: secondOptionalParameterValue},
},
}
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses(&preset))
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
// When: creating a workspace with a preset and passing overlapping and additional parameters via `--parameter`
workspaceName := "my-workspace"
inv, root := clitest.New(t, "create", workspaceName, "--template", template.Name, "-y",
"--preset", preset.Name,
"--parameter", fmt.Sprintf("%s=%s", firstParameterName, firstOptionalParameterValue),
"--parameter", fmt.Sprintf("%s=%s", thirdParameterName, thirdParameterValue))
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t).Attach(inv)
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
err := inv.Run()
require.NoError(t, err)
// Should: display the selected preset as well as its parameter
presetName := fmt.Sprintf("Preset '%s' applied:", preset.Name)
pty.ExpectMatch(presetName)
pty.ExpectMatch(fmt.Sprintf("%s: '%s'", firstParameterName, secondOptionalParameterValue))
// Verify if the new workspace uses expected parameters.
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
defer cancel()
tvPresets, err := client.TemplateVersionPresets(ctx, version.ID)
require.NoError(t, err)
require.Len(t, tvPresets, 1)
workspaces, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
Name: workspaceName,
})
require.NoError(t, err)
require.Len(t, workspaces.Workspaces, 1)
// Should: include both parameters, one from the preset and one from the `--parameter` flag
workspaceLatestBuild := workspaces.Workspaces[0].LatestBuild
require.Equal(t, version.ID, workspaceLatestBuild.TemplateVersionID)
require.Equal(t, tvPresets[0].ID, *workspaceLatestBuild.TemplateVersionPresetID)
buildParameters, err := client.WorkspaceBuildParameters(ctx, workspaceLatestBuild.ID)
require.NoError(t, err)
require.Len(t, buildParameters, 2)
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: firstParameterName, Value: secondOptionalParameterValue})
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: thirdParameterName, Value: thirdParameterValue})
})
// This test verifies that when both a preset and a user-provided
// `--rich-parameter-file` define a value for the same parameter,
// the preset's value takes precedence over the one in the file.
//
// The preset defines one parameter (A), and the parameter file provides two parameters (A and B).
// The workspace should be created using:
// - the value of parameter A from the preset (overriding the file's value),
// - and the value of parameter B from the file.
t.Run("PresetOverridesParameterFileValues", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: a template version with a preset that defines one parameter
preset := proto.Preset{
Name: "preset-test",
Parameters: []*proto.PresetParameter{
{Name: firstParameterName, Value: secondOptionalParameterValue},
},
}
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses(&preset))
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
// When: creating a workspace with the preset and passing the second required parameter via `--rich-parameter-file`
workspaceName := "my-workspace"
tempDir := t.TempDir()
removeTmpDirUntilSuccessAfterTest(t, tempDir)
parameterFile, _ := os.CreateTemp(tempDir, "testParameterFile*.yaml")
_, _ = parameterFile.WriteString(
firstParameterName + ": " + firstOptionalParameterValue + "\n" +
thirdParameterName + ": " + thirdParameterValue)
inv, root := clitest.New(t, "create", workspaceName, "--template", template.Name, "-y",
"--preset", preset.Name,
"--rich-parameter-file", parameterFile.Name())
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t).Attach(inv)
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
err := inv.Run()
require.NoError(t, err)
// Should: display the selected preset as well as its parameter
presetName := fmt.Sprintf("Preset '%s' applied:", preset.Name)
pty.ExpectMatch(presetName)
pty.ExpectMatch(fmt.Sprintf("%s: '%s'", firstParameterName, secondOptionalParameterValue))
// Verify if the new workspace uses expected parameters.
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
defer cancel()
tvPresets, err := client.TemplateVersionPresets(ctx, version.ID)
require.NoError(t, err)
require.Len(t, tvPresets, 1)
workspaces, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
Name: workspaceName,
})
require.NoError(t, err)
require.Len(t, workspaces.Workspaces, 1)
// Should: include both parameters, one from the preset and one from the `--rich-parameter-file` flag
workspaceLatestBuild := workspaces.Workspaces[0].LatestBuild
require.Equal(t, version.ID, workspaceLatestBuild.TemplateVersionID)
require.Equal(t, tvPresets[0].ID, *workspaceLatestBuild.TemplateVersionPresetID)
buildParameters, err := client.WorkspaceBuildParameters(ctx, workspaceLatestBuild.ID)
require.NoError(t, err)
require.Len(t, buildParameters, 2)
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: firstParameterName, Value: secondOptionalParameterValue})
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: thirdParameterName, Value: thirdParameterValue})
})
// This test verifies that when a preset provides only some parameters,
// and the remaining ones are not provided via flags,
// the CLI prompts the user for input to fill in the missing parameters.
t.Run("PromptsForMissingParametersWhenPresetIsIncomplete", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: a template version with a preset that defines one parameter
preset := proto.Preset{
Name: "preset-test",
Parameters: []*proto.PresetParameter{
{Name: firstParameterName, Value: secondOptionalParameterValue},
},
}
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses(&preset))
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
// When: running the create command with the specified preset
workspaceName := "my-workspace"
inv, root := clitest.New(t, "create", workspaceName, "--template", template.Name, "--preset", preset.Name)
clitest.SetupConfig(t, member, root)
doneChan := make(chan struct{})
pty := ptytest.New(t).Attach(inv)
go func() {
defer close(doneChan)
err := inv.Run()
assert.NoError(t, err)
}()
// Should: display the selected preset as well as its parameters
presetName := fmt.Sprintf("Preset '%s' applied:", preset.Name)
pty.ExpectMatch(presetName)
pty.ExpectMatch(fmt.Sprintf("%s: '%s'", firstParameterName, secondOptionalParameterValue))
// Should: prompt for the missing parameter
pty.ExpectMatch(thirdParameterDescription)
pty.WriteLine(thirdParameterValue)
pty.ExpectMatch("Confirm create?")
pty.WriteLine("yes")
<-doneChan
// Verify if the new workspace uses expected parameters.
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
tvPresets, err := client.TemplateVersionPresets(ctx, version.ID)
require.NoError(t, err)
require.Len(t, tvPresets, 1)
workspaces, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
Name: workspaceName,
})
require.NoError(t, err)
require.Len(t, workspaces.Workspaces, 1)
// Should: create a workspace using the expected template version and the preset-defined parameters
workspaceLatestBuild := workspaces.Workspaces[0].LatestBuild
require.Equal(t, version.ID, workspaceLatestBuild.TemplateVersionID)
require.Equal(t, tvPresets[0].ID, *workspaceLatestBuild.TemplateVersionPresetID)
buildParameters, err := client.WorkspaceBuildParameters(ctx, workspaceLatestBuild.ID)
require.NoError(t, err)
require.Len(t, buildParameters, 2)
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: firstParameterName, Value: secondOptionalParameterValue})
require.Contains(t, buildParameters, codersdk.WorkspaceBuildParameter{Name: thirdParameterName, Value: thirdParameterValue})
})
}
func TestCreateValidateRichParameters(t *testing.T) {
t.Parallel()
+3 -3
View File
@@ -233,9 +233,6 @@ func TestDelete(t *testing.T) {
t.Skip("this test requires postgres")
}
clock := quartz.NewMock(t)
ctx := testutil.Context(t, testutil.WaitSuperLong)
// Setup
db, pb := dbtestutil.NewDB(t, dbtestutil.WithDumpOnFailure())
client, _ := coderdtest.NewWithProvisionerCloser(t, &coderdtest.Options{
@@ -301,6 +298,9 @@ func TestDelete(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
clock := quartz.NewMock(t)
ctx := testutil.Context(t, testutil.WaitSuperLong)
// Create one prebuilt workspace (owned by system user) and one normal workspace (owned by a user)
// Each workspace is persisted in the DB along with associated workspace jobs and builds.
dbPrebuiltWorkspace := setupTestDBWorkspace(t, clock, db, pb, orgID, database.PrebuildsSystemUserID, template.ID, version.ID, preset.ID)
+17 -7
View File
@@ -127,6 +127,7 @@ func (r *RootCmd) mcpConfigureClaudeCode() *serpent.Command {
appStatusSlug string
testBinaryName string
aiAgentAPIURL url.URL
claudeUseBedrock string
deprecatedCoderMCPClaudeAPIKey string
)
@@ -154,14 +155,15 @@ func (r *RootCmd) mcpConfigureClaudeCode() *serpent.Command {
configureClaudeEnv[envAgentURL] = agentClient.SDK.URL.String()
configureClaudeEnv[envAgentToken] = agentClient.SDK.SessionToken()
}
if claudeAPIKey == "" {
if deprecatedCoderMCPClaudeAPIKey == "" {
cliui.Warnf(inv.Stderr, "CLAUDE_API_KEY is not set.")
} else {
cliui.Warnf(inv.Stderr, "CODER_MCP_CLAUDE_API_KEY is deprecated, use CLAUDE_API_KEY instead")
claudeAPIKey = deprecatedCoderMCPClaudeAPIKey
}
if deprecatedCoderMCPClaudeAPIKey != "" {
cliui.Warnf(inv.Stderr, "CODER_MCP_CLAUDE_API_KEY is deprecated, use CLAUDE_API_KEY instead")
claudeAPIKey = deprecatedCoderMCPClaudeAPIKey
}
if claudeAPIKey == "" && claudeUseBedrock != "1" {
cliui.Warnf(inv.Stderr, "CLAUDE_API_KEY is not set.")
}
if appStatusSlug != "" {
configureClaudeEnv[envAppStatusSlug] = appStatusSlug
}
@@ -280,6 +282,14 @@ func (r *RootCmd) mcpConfigureClaudeCode() *serpent.Command {
Value: serpent.StringOf(&testBinaryName),
Hidden: true,
},
{
Name: "claude-code-use-bedrock",
Description: "Use Amazon Bedrock.",
Env: "CLAUDE_CODE_USE_BEDROCK",
Flag: "claude-code-use-bedrock",
Value: serpent.StringOf(&claudeUseBedrock),
Hidden: true,
},
},
}
return cmd
+1 -1
View File
@@ -97,7 +97,7 @@ func handleRPTY(inv *serpent.Invocation, client *codersdk.Client, args handleRPT
reconnectID = uuid.New()
}
ws, agt, err := getWorkspaceAndAgent(ctx, inv, client, true, args.NamedWorkspace)
ws, agt, _, err := getWorkspaceAndAgent(ctx, inv, client, true, args.NamedWorkspace)
if err != nil {
return err
}
+1
View File
@@ -118,6 +118,7 @@ func TestExpRpty(t *testing.T) {
_ = agenttest.New(t, client.URL, agentToken, func(o *agent.Options) {
o.Devcontainers = true
o.DevcontainerAPIOptions = append(o.DevcontainerAPIOptions,
agentcontainers.WithProjectDiscovery(false),
agentcontainers.WithContainerLabelIncludeFilter(wantLabel, "true"),
)
})
+85 -49
View File
@@ -11,7 +11,9 @@ import (
"runtime"
"slices"
"strings"
"time"
"github.com/google/uuid"
"github.com/skratchdot/open-golang/open"
"golang.org/x/xerrors"
@@ -42,7 +44,6 @@ func (r *RootCmd) openVSCode() *serpent.Command {
generateToken bool
testOpenError bool
appearanceConfig codersdk.AppearanceConfig
containerName string
)
client := new(codersdk.Client)
@@ -71,7 +72,7 @@ func (r *RootCmd) openVSCode() *serpent.Command {
// need to wait for the agent to start.
workspaceQuery := inv.Args[0]
autostart := true
workspace, workspaceAgent, err := getWorkspaceAndAgent(ctx, inv, client, autostart, workspaceQuery)
workspace, workspaceAgent, otherWorkspaceAgents, err := getWorkspaceAndAgent(ctx, inv, client, autostart, workspaceQuery)
if err != nil {
return xerrors.Errorf("get workspace and agent: %w", err)
}
@@ -79,6 +80,70 @@ func (r *RootCmd) openVSCode() *serpent.Command {
workspaceName := workspace.Name + "." + workspaceAgent.Name
insideThisWorkspace := insideAWorkspace && inWorkspaceName == workspaceName
// To properly work with devcontainers, VS Code has to connect to
// parent workspace agent. It will then proceed to enter the
// container given the correct parameters. There is inherently no
// dependency on the devcontainer agent in this scenario, but
// relying on it simplifies the logic and ensures the devcontainer
// is ready. To eliminate the dependency we would need to know that
// a sub-agent that hasn't been created yet may be a devcontainer,
// and thus will be created at a later time as well as expose the
// container folder on the API response.
var parentWorkspaceAgent codersdk.WorkspaceAgent
var devcontainer codersdk.WorkspaceAgentDevcontainer
if workspaceAgent.ParentID.Valid {
// This is likely a devcontainer agent, so we need to find the
// parent workspace agent as well as the devcontainer.
for _, otherAgent := range otherWorkspaceAgents {
if otherAgent.ID == workspaceAgent.ParentID.UUID {
parentWorkspaceAgent = otherAgent
break
}
}
if parentWorkspaceAgent.ID == uuid.Nil {
return xerrors.Errorf("parent workspace agent %s not found", workspaceAgent.ParentID.UUID)
}
printedWaiting := false
for {
resp, err := client.WorkspaceAgentListContainers(ctx, parentWorkspaceAgent.ID, nil)
if err != nil {
return xerrors.Errorf("list parent workspace agent containers: %w", err)
}
for _, dc := range resp.Devcontainers {
if dc.Agent.ID == workspaceAgent.ID {
devcontainer = dc
break
}
}
if devcontainer.ID == uuid.Nil {
cliui.Warnf(inv.Stderr, "Devcontainer %q not found, opening as a regular workspace...", workspaceAgent.Name)
parentWorkspaceAgent = codersdk.WorkspaceAgent{} // Reset to empty, so we don't use it later.
break
}
// Precondition, the devcontainer must be running to enter
// it. Once running, devcontainer.Container will be set.
if devcontainer.Status == codersdk.WorkspaceAgentDevcontainerStatusRunning {
break
}
if devcontainer.Status != codersdk.WorkspaceAgentDevcontainerStatusStarting {
return xerrors.Errorf("devcontainer %q is in unexpected status %q, expected %q or %q",
devcontainer.Name, devcontainer.Status,
codersdk.WorkspaceAgentDevcontainerStatusRunning,
codersdk.WorkspaceAgentDevcontainerStatusStarting,
)
}
if !printedWaiting {
_, _ = fmt.Fprintf(inv.Stderr, "Waiting for devcontainer %q status to change from %q to %q...\n", devcontainer.Name, devcontainer.Status, codersdk.WorkspaceAgentDevcontainerStatusRunning)
printedWaiting = true
}
time.Sleep(5 * time.Second) // Wait a bit before retrying.
}
}
if !insideThisWorkspace {
// Wait for the agent to connect, we don't care about readiness
// otherwise (e.g. wait).
@@ -99,6 +164,9 @@ func (r *RootCmd) openVSCode() *serpent.Command {
// the created state, so we need to wait for that to happen.
// However, if no directory is set, the expanded directory will
// not be set either.
//
// Note that this is irrelevant for devcontainer sub agents, as
// they always have a directory set.
if workspaceAgent.Directory != "" {
workspace, workspaceAgent, err = waitForAgentCond(ctx, client, workspace, workspaceAgent, func(_ codersdk.WorkspaceAgent) bool {
return workspaceAgent.LifecycleState != codersdk.WorkspaceAgentLifecycleCreated
@@ -114,41 +182,6 @@ func (r *RootCmd) openVSCode() *serpent.Command {
directory = inv.Args[1]
}
if containerName != "" {
containers, err := client.WorkspaceAgentListContainers(ctx, workspaceAgent.ID, map[string]string{"devcontainer.local_folder": ""})
if err != nil {
return xerrors.Errorf("list workspace agent containers: %w", err)
}
var foundContainer bool
for _, container := range containers.Containers {
if container.FriendlyName != containerName {
continue
}
foundContainer = true
if directory == "" {
localFolder, ok := container.Labels["devcontainer.local_folder"]
if !ok {
return xerrors.New("container missing `devcontainer.local_folder` label")
}
directory, ok = container.Volumes[localFolder]
if !ok {
return xerrors.New("container missing volume for `devcontainer.local_folder`")
}
}
break
}
if !foundContainer {
return xerrors.New("no container found")
}
}
directory, err = resolveAgentAbsPath(workspaceAgent.ExpandedDirectory, directory, workspaceAgent.OperatingSystem, insideThisWorkspace)
if err != nil {
return xerrors.Errorf("resolve agent path: %w", err)
@@ -174,14 +207,16 @@ func (r *RootCmd) openVSCode() *serpent.Command {
u *url.URL
qp url.Values
)
if containerName != "" {
if devcontainer.ID != uuid.Nil {
u, qp = buildVSCodeWorkspaceDevContainerLink(
token,
client.URL.String(),
workspace,
workspaceAgent,
containerName,
parentWorkspaceAgent,
devcontainer.Container.FriendlyName,
directory,
devcontainer.WorkspaceFolder,
devcontainer.ConfigPath,
)
} else {
u, qp = buildVSCodeWorkspaceLink(
@@ -247,13 +282,6 @@ func (r *RootCmd) openVSCode() *serpent.Command {
),
Value: serpent.BoolOf(&generateToken),
},
{
Flag: "container",
FlagShorthand: "c",
Description: "Container name to connect to in the workspace.",
Value: serpent.StringOf(&containerName),
Hidden: true, // Hidden until this features is at least in beta.
},
{
Flag: "test.open-error",
Description: "Don't run the open command.",
@@ -288,7 +316,7 @@ func (r *RootCmd) openApp() *serpent.Command {
}
workspaceName := inv.Args[0]
ws, agt, err := getWorkspaceAndAgent(ctx, inv, client, false, workspaceName)
ws, agt, _, err := getWorkspaceAndAgent(ctx, inv, client, false, workspaceName)
if err != nil {
var sdkErr *codersdk.Error
if errors.As(err, &sdkErr) && sdkErr.StatusCode() == http.StatusNotFound {
@@ -430,8 +458,14 @@ func buildVSCodeWorkspaceDevContainerLink(
workspaceAgent codersdk.WorkspaceAgent,
containerName string,
containerFolder string,
localWorkspaceFolder string,
localConfigFile string,
) (*url.URL, url.Values) {
containerFolder = filepath.ToSlash(containerFolder)
localWorkspaceFolder = filepath.ToSlash(localWorkspaceFolder)
if localConfigFile != "" {
localConfigFile = filepath.ToSlash(localConfigFile)
}
qp := url.Values{}
qp.Add("url", clientURL)
@@ -440,6 +474,8 @@ func buildVSCodeWorkspaceDevContainerLink(
qp.Add("agent", workspaceAgent.Name)
qp.Add("devContainerName", containerName)
qp.Add("devContainerFolder", containerFolder)
qp.Add("localWorkspaceFolder", localWorkspaceFolder)
qp.Add("localConfigFile", localConfigFile)
if token != "" {
qp.Add("token", token)
@@ -469,7 +505,7 @@ func waitForAgentCond(ctx context.Context, client *codersdk.Client, workspace co
}
for workspace = range wc {
workspaceAgent, err = getWorkspaceAgent(workspace, workspaceAgent.Name)
workspaceAgent, _, err = getWorkspaceAgent(workspace, workspaceAgent.Name)
if err != nil {
return workspace, workspaceAgent, xerrors.Errorf("get workspace agent: %w", err)
}
+132 -213
View File
@@ -1,8 +1,10 @@
package cli_test
import (
"context"
"net/url"
"os"
"path"
"path/filepath"
"runtime"
"strings"
@@ -11,11 +13,11 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/agent"
"github.com/coder/coder/v2/agent/agentcontainers"
"github.com/coder/coder/v2/agent/agentcontainers/acmock"
"github.com/coder/coder/v2/agent/agentcontainers/watcher"
"github.com/coder/coder/v2/agent/agenttest"
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/coderd/coderdtest"
@@ -289,6 +291,60 @@ func TestOpenVSCode_NoAgentDirectory(t *testing.T) {
}
}
type fakeContainerCLI struct {
resp codersdk.WorkspaceAgentListContainersResponse
}
func (f *fakeContainerCLI) List(ctx context.Context) (codersdk.WorkspaceAgentListContainersResponse, error) {
return f.resp, nil
}
func (*fakeContainerCLI) DetectArchitecture(ctx context.Context, containerID string) (string, error) {
return runtime.GOARCH, nil
}
func (*fakeContainerCLI) Copy(ctx context.Context, containerID, src, dst string) error {
return nil
}
func (*fakeContainerCLI) ExecAs(ctx context.Context, containerID, user string, args ...string) ([]byte, error) {
return nil, nil
}
type fakeDevcontainerCLI struct {
config agentcontainers.DevcontainerConfig
execAgent func(ctx context.Context, token string) error
}
func (f *fakeDevcontainerCLI) ReadConfig(ctx context.Context, workspaceFolder, configFile string, env []string, opts ...agentcontainers.DevcontainerCLIReadConfigOptions) (agentcontainers.DevcontainerConfig, error) {
return f.config, nil
}
func (f *fakeDevcontainerCLI) Exec(ctx context.Context, workspaceFolder, configFile string, name string, args []string, opts ...agentcontainers.DevcontainerCLIExecOptions) error {
var opt agentcontainers.DevcontainerCLIExecConfig
for _, o := range opts {
o(&opt)
}
var token string
for _, arg := range opt.Args {
if strings.HasPrefix(arg, "CODER_AGENT_TOKEN=") {
token = strings.TrimPrefix(arg, "CODER_AGENT_TOKEN=")
break
}
}
if token == "" {
return xerrors.New("no agent token provided in args")
}
if f.execAgent == nil {
return nil
}
return f.execAgent(ctx, token)
}
func (*fakeDevcontainerCLI) Up(ctx context.Context, workspaceFolder, configFile string, opts ...agentcontainers.DevcontainerCLIUpOptions) (string, error) {
return "", nil
}
func TestOpenVSCodeDevContainer(t *testing.T) {
t.Parallel()
@@ -296,56 +352,85 @@ func TestOpenVSCodeDevContainer(t *testing.T) {
t.Skip("DevContainers are only supported for agents on Linux")
}
agentName := "agent1"
agentDir, err := filepath.Abs(filepath.FromSlash("/tmp"))
require.NoError(t, err)
parentAgentName := "agent1"
devcontainerID := uuid.New()
devcontainerName := "wilson"
workspaceFolder := "/home/coder/wilson"
configFile := path.Join(workspaceFolder, ".devcontainer", "devcontainer.json")
containerID := uuid.NewString()
containerName := testutil.GetRandomName(t)
containerFolder := "/workspace/coder"
ctrl := gomock.NewController(t)
mccli := acmock.NewMockContainerCLI(ctrl)
mccli.EXPECT().List(gomock.Any()).Return(
codersdk.WorkspaceAgentListContainersResponse{
Containers: []codersdk.WorkspaceAgentContainer{
{
ID: uuid.NewString(),
CreatedAt: dbtime.Now(),
FriendlyName: containerName,
Image: "busybox:latest",
Labels: map[string]string{
"devcontainer.local_folder": "/home/coder/coder",
},
Running: true,
Status: "running",
Volumes: map[string]string{
"/home/coder/coder": containerFolder,
},
},
},
}, nil,
).AnyTimes()
containerFolder := "/workspaces/wilson"
client, workspace, agentToken := setupWorkspaceForAgent(t, func(agents []*proto.Agent) []*proto.Agent {
agents[0].Directory = agentDir
agents[0].Name = agentName
agents[0].Name = parentAgentName
agents[0].OperatingSystem = runtime.GOOS
return agents
})
fCCLI := &fakeContainerCLI{
resp: codersdk.WorkspaceAgentListContainersResponse{
Containers: []codersdk.WorkspaceAgentContainer{
{
ID: containerID,
CreatedAt: dbtime.Now(),
FriendlyName: containerName,
Image: "busybox:latest",
Labels: map[string]string{
agentcontainers.DevcontainerLocalFolderLabel: workspaceFolder,
agentcontainers.DevcontainerConfigFileLabel: configFile,
agentcontainers.DevcontainerIsTestRunLabel: "true",
"coder.test": t.Name(),
},
Running: true,
Status: "running",
},
},
},
}
fDCCLI := &fakeDevcontainerCLI{
config: agentcontainers.DevcontainerConfig{
Workspace: agentcontainers.DevcontainerWorkspace{
WorkspaceFolder: containerFolder,
},
},
execAgent: func(ctx context.Context, token string) error {
t.Logf("Starting devcontainer subagent with token: %s", token)
_ = agenttest.New(t, client.URL, token)
<-ctx.Done()
return ctx.Err()
},
}
_ = agenttest.New(t, client.URL, agentToken, func(o *agent.Options) {
o.Devcontainers = true
o.DevcontainerAPIOptions = append(o.DevcontainerAPIOptions,
agentcontainers.WithContainerCLI(mccli),
agentcontainers.WithContainerLabelIncludeFilter("this.label.does.not.exist.ignore.devcontainers", "true"),
agentcontainers.WithProjectDiscovery(false),
agentcontainers.WithContainerCLI(fCCLI),
agentcontainers.WithDevcontainerCLI(fDCCLI),
agentcontainers.WithWatcher(watcher.NewNoop()),
agentcontainers.WithDevcontainers(
[]codersdk.WorkspaceAgentDevcontainer{{
ID: devcontainerID,
Name: devcontainerName,
WorkspaceFolder: workspaceFolder,
Status: codersdk.WorkspaceAgentDevcontainerStatusStopped,
}},
[]codersdk.WorkspaceAgentScript{{
ID: devcontainerID,
LogSourceID: uuid.New(),
}},
),
agentcontainers.WithContainerLabelIncludeFilter("coder.test", t.Name()),
)
})
_ = coderdtest.NewWorkspaceAgentWaiter(t, client, workspace.ID).Wait()
coderdtest.NewWorkspaceAgentWaiter(t, client, workspace.ID).AgentNames([]string{parentAgentName, devcontainerName}).Wait()
insideWorkspaceEnv := map[string]string{
"CODER": "true",
"CODER_WORKSPACE_NAME": workspace.Name,
"CODER_WORKSPACE_AGENT_NAME": agentName,
"CODER_WORKSPACE_AGENT_NAME": devcontainerName,
}
wd, err := os.Getwd()
@@ -361,215 +446,47 @@ func TestOpenVSCodeDevContainer(t *testing.T) {
}{
{
name: "nonexistent container",
args: []string{"--test.open-error", workspace.Name, "--container", containerName + "bad"},
args: []string{"--test.open-error", workspace.Name + "." + devcontainerName + "bad"},
wantError: true,
},
{
name: "ok",
args: []string{"--test.open-error", workspace.Name, "--container", containerName},
wantDir: containerFolder,
args: []string{"--test.open-error", workspace.Name + "." + devcontainerName},
wantError: false,
},
{
name: "ok with absolute path",
args: []string{"--test.open-error", workspace.Name, "--container", containerName, containerFolder},
wantDir: containerFolder,
args: []string{"--test.open-error", workspace.Name + "." + devcontainerName, containerFolder},
wantError: false,
},
{
name: "ok with relative path",
args: []string{"--test.open-error", workspace.Name, "--container", containerName, "my/relative/path"},
wantDir: filepath.Join(agentDir, filepath.FromSlash("my/relative/path")),
args: []string{"--test.open-error", workspace.Name + "." + devcontainerName, "my/relative/path"},
wantDir: path.Join(containerFolder, "my/relative/path"),
wantError: false,
},
{
name: "ok with token",
args: []string{"--test.open-error", workspace.Name, "--container", containerName, "--generate-token"},
wantDir: containerFolder,
args: []string{"--test.open-error", workspace.Name + "." + devcontainerName, "--generate-token"},
wantError: false,
wantToken: true,
},
// Inside workspace, does not require --test.open-error
{
name: "ok inside workspace",
env: insideWorkspaceEnv,
args: []string{workspace.Name, "--container", containerName},
wantDir: containerFolder,
},
{
name: "ok inside workspace relative path",
env: insideWorkspaceEnv,
args: []string{workspace.Name, "--container", containerName, "foo"},
wantDir: filepath.Join(wd, "foo"),
},
{
name: "ok inside workspace token",
env: insideWorkspaceEnv,
args: []string{workspace.Name, "--container", containerName, "--generate-token"},
wantDir: containerFolder,
wantToken: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
inv, root := clitest.New(t, append([]string{"open", "vscode"}, tt.args...)...)
clitest.SetupConfig(t, client, root)
pty := ptytest.New(t)
inv.Stdin = pty.Input()
inv.Stdout = pty.Output()
ctx := testutil.Context(t, testutil.WaitLong)
inv = inv.WithContext(ctx)
for k, v := range tt.env {
inv.Environ.Set(k, v)
}
w := clitest.StartWithWaiter(t, inv)
if tt.wantError {
w.RequireError()
return
}
me, err := client.User(ctx, codersdk.Me)
require.NoError(t, err)
line := pty.ReadLine(ctx)
u, err := url.ParseRequestURI(line)
require.NoError(t, err, "line: %q", line)
qp := u.Query()
assert.Equal(t, client.URL.String(), qp.Get("url"))
assert.Equal(t, me.Username, qp.Get("owner"))
assert.Equal(t, workspace.Name, qp.Get("workspace"))
assert.Equal(t, agentName, qp.Get("agent"))
assert.Equal(t, containerName, qp.Get("devContainerName"))
if tt.wantDir != "" {
assert.Equal(t, tt.wantDir, qp.Get("devContainerFolder"))
} else {
assert.Equal(t, containerFolder, qp.Get("devContainerFolder"))
}
if tt.wantToken {
assert.NotEmpty(t, qp.Get("token"))
} else {
assert.Empty(t, qp.Get("token"))
}
w.RequireSuccess()
})
}
}
func TestOpenVSCodeDevContainer_NoAgentDirectory(t *testing.T) {
t.Parallel()
if runtime.GOOS != "linux" {
t.Skip("DevContainers are only supported for agents on Linux")
}
agentName := "agent1"
containerName := testutil.GetRandomName(t)
containerFolder := "/workspace/coder"
ctrl := gomock.NewController(t)
mccli := acmock.NewMockContainerCLI(ctrl)
mccli.EXPECT().List(gomock.Any()).Return(
codersdk.WorkspaceAgentListContainersResponse{
Containers: []codersdk.WorkspaceAgentContainer{
{
ID: uuid.NewString(),
CreatedAt: dbtime.Now(),
FriendlyName: containerName,
Image: "busybox:latest",
Labels: map[string]string{
"devcontainer.local_folder": "/home/coder/coder",
},
Running: true,
Status: "running",
Volumes: map[string]string{
"/home/coder/coder": containerFolder,
},
},
},
}, nil,
).AnyTimes()
client, workspace, agentToken := setupWorkspaceForAgent(t, func(agents []*proto.Agent) []*proto.Agent {
agents[0].Name = agentName
agents[0].OperatingSystem = runtime.GOOS
return agents
})
_ = agenttest.New(t, client.URL, agentToken, func(o *agent.Options) {
o.Devcontainers = true
o.DevcontainerAPIOptions = append(o.DevcontainerAPIOptions,
agentcontainers.WithContainerCLI(mccli),
agentcontainers.WithContainerLabelIncludeFilter("this.label.does.not.exist.ignore.devcontainers", "true"),
)
})
_ = coderdtest.NewWorkspaceAgentWaiter(t, client, workspace.ID).Wait()
insideWorkspaceEnv := map[string]string{
"CODER": "true",
"CODER_WORKSPACE_NAME": workspace.Name,
"CODER_WORKSPACE_AGENT_NAME": agentName,
}
wd, err := os.Getwd()
require.NoError(t, err)
tests := []struct {
name string
env map[string]string
args []string
wantDir string
wantError bool
wantToken bool
}{
{
name: "ok",
args: []string{"--test.open-error", workspace.Name, "--container", containerName},
},
{
name: "no agent dir error relative path",
args: []string{"--test.open-error", workspace.Name, "--container", containerName, "my/relative/path"},
wantDir: filepath.FromSlash("my/relative/path"),
wantError: true,
},
{
name: "ok with absolute path",
args: []string{"--test.open-error", workspace.Name, "--container", containerName, "/home/coder"},
wantDir: "/home/coder",
},
{
name: "ok with token",
args: []string{"--test.open-error", workspace.Name, "--container", containerName, "--generate-token"},
wantToken: true,
},
// Inside workspace, does not require --test.open-error
{
name: "ok inside workspace",
env: insideWorkspaceEnv,
args: []string{workspace.Name, "--container", containerName},
args: []string{workspace.Name + "." + devcontainerName},
},
{
name: "ok inside workspace relative path",
env: insideWorkspaceEnv,
args: []string{workspace.Name, "--container", containerName, "foo"},
args: []string{workspace.Name + "." + devcontainerName, "foo"},
wantDir: filepath.Join(wd, "foo"),
},
{
name: "ok inside workspace token",
env: insideWorkspaceEnv,
args: []string{workspace.Name, "--container", containerName, "--generate-token"},
args: []string{workspace.Name + "." + devcontainerName, "--generate-token"},
wantToken: true,
},
}
@@ -610,8 +527,10 @@ func TestOpenVSCodeDevContainer_NoAgentDirectory(t *testing.T) {
assert.Equal(t, client.URL.String(), qp.Get("url"))
assert.Equal(t, me.Username, qp.Get("owner"))
assert.Equal(t, workspace.Name, qp.Get("workspace"))
assert.Equal(t, agentName, qp.Get("agent"))
assert.Equal(t, parentAgentName, qp.Get("agent"))
assert.Equal(t, containerName, qp.Get("devContainerName"))
assert.Equal(t, workspaceFolder, qp.Get("localWorkspaceFolder"))
assert.Equal(t, configFile, qp.Get("localConfigFile"))
if tt.wantDir != "" {
assert.Equal(t, tt.wantDir, qp.Get("devContainerFolder"))
-1
View File
@@ -435,7 +435,6 @@ func applyOrgResourceActions(role *codersdk.Role, resource string, actions []str
// Construct new site perms with only new perms for the resource
keep := make([]codersdk.Permission, 0)
for _, perm := range role.OrganizationPermissions {
perm := perm
if string(perm.ResourceType) != resource {
keep = append(keep, perm)
}
-2
View File
@@ -116,7 +116,6 @@ func (r *RootCmd) setOrganizationSettings(orgContext *OrganizationContext, setti
}
for _, set := range settings {
set := set
patch := set.Patch
cmd.Children = append(cmd.Children, &serpent.Command{
Use: set.Name,
@@ -192,7 +191,6 @@ func (r *RootCmd) printOrganizationSetting(orgContext *OrganizationContext, sett
}
for _, set := range settings {
set := set
fetch := set.Fetch
cmd.Children = append(cmd.Children, &serpent.Command{
Use: set.Name,
+23 -1
View File
@@ -100,6 +100,14 @@ func (wpf *workspaceParameterFlags) alwaysPrompt() serpent.Option {
}
}
func presetParameterAsWorkspaceBuildParameters(presetParameters []codersdk.PresetParameter) []codersdk.WorkspaceBuildParameter {
var params []codersdk.WorkspaceBuildParameter
for _, parameter := range presetParameters {
params = append(params, codersdk.WorkspaceBuildParameter(parameter))
}
return params
}
func asWorkspaceBuildParameters(nameValuePairs []string) ([]codersdk.WorkspaceBuildParameter, error) {
var params []codersdk.WorkspaceBuildParameter
for _, nameValue := range nameValuePairs {
@@ -145,9 +153,11 @@ func parseParameterMapFile(parameterFile string) (map[string]string, error) {
return parameterMap, nil
}
// buildFlags contains options relating to troubleshooting provisioner jobs.
// buildFlags contains options relating to troubleshooting provisioner jobs
// and setting the reason for the workspace build.
type buildFlags struct {
provisionerLogDebug bool
reason string
}
func (bf *buildFlags) cliOptions() []serpent.Option {
@@ -160,5 +170,17 @@ This is useful for troubleshooting build issues.`,
Value: serpent.BoolOf(&bf.provisionerLogDebug),
Hidden: true,
},
{
Flag: "reason",
Description: `Sets the reason for the workspace build (cli, vscode_connection, jetbrains_connection).`,
Value: serpent.EnumOf(
&bf.reason,
string(codersdk.BuildReasonCLI),
string(codersdk.BuildReasonVSCodeConnection),
string(codersdk.BuildReasonJetbrainsConnection),
),
Default: string(codersdk.BuildReasonCLI),
Hidden: true,
},
}
}
+24
View File
@@ -26,6 +26,7 @@ type ParameterResolver struct {
lastBuildParameters []codersdk.WorkspaceBuildParameter
sourceWorkspaceParameters []codersdk.WorkspaceBuildParameter
presetParameters []codersdk.WorkspaceBuildParameter
richParameters []codersdk.WorkspaceBuildParameter
richParametersDefaults map[string]string
richParametersFile map[string]string
@@ -45,6 +46,11 @@ func (pr *ParameterResolver) WithSourceWorkspaceParameters(params []codersdk.Wor
return pr
}
func (pr *ParameterResolver) WithPresetParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver {
pr.presetParameters = params
return pr
}
func (pr *ParameterResolver) WithRichParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver {
pr.richParameters = params
return pr
@@ -80,6 +86,8 @@ func (pr *ParameterResolver) WithPromptEphemeralParameters(promptEphemeralParame
return pr
}
// Resolve gathers workspace build parameters in a layered fashion, applying values from various sources
// in order of precedence: parameter file < CLI/ENV < source build < last build < preset < user input.
func (pr *ParameterResolver) Resolve(inv *serpent.Invocation, action WorkspaceCLIAction, templateVersionParameters []codersdk.TemplateVersionParameter) ([]codersdk.WorkspaceBuildParameter, error) {
var staged []codersdk.WorkspaceBuildParameter
var err error
@@ -88,6 +96,7 @@ func (pr *ParameterResolver) Resolve(inv *serpent.Invocation, action WorkspaceCL
staged = pr.resolveWithCommandLineOrEnv(staged)
staged = pr.resolveWithSourceBuildParameters(staged, templateVersionParameters)
staged = pr.resolveWithLastBuildParameters(staged, templateVersionParameters)
staged = pr.resolveWithPreset(staged) // Preset parameters take precedence from all other parameters
if err = pr.verifyConstraints(staged, action, templateVersionParameters); err != nil {
return nil, err
}
@@ -97,6 +106,21 @@ func (pr *ParameterResolver) Resolve(inv *serpent.Invocation, action WorkspaceCL
return staged, nil
}
func (pr *ParameterResolver) resolveWithPreset(resolved []codersdk.WorkspaceBuildParameter) []codersdk.WorkspaceBuildParameter {
next:
for _, presetParameter := range pr.presetParameters {
for i, r := range resolved {
if r.Name == presetParameter.Name {
resolved[i].Value = presetParameter.Value
continue next
}
}
resolved = append(resolved, presetParameter)
}
return resolved
}
func (pr *ParameterResolver) resolveWithParametersMapFile(resolved []codersdk.WorkspaceBuildParameter) []codersdk.WorkspaceBuildParameter {
next:
for name, value := range pr.richParametersFile {
+2 -2
View File
@@ -53,7 +53,7 @@ func (s *pingSummary) addResult(r *ipnstate.PingResult) {
if s.Min == nil || r.LatencySeconds < s.Min.Seconds() {
s.Min = ptr.Ref(time.Duration(r.LatencySeconds * float64(time.Second)))
}
if s.Max == nil || r.LatencySeconds > s.Min.Seconds() {
if s.Max == nil || r.LatencySeconds > s.Max.Seconds() {
s.Max = ptr.Ref(time.Duration(r.LatencySeconds * float64(time.Second)))
}
s.latencySum += r.LatencySeconds
@@ -110,7 +110,7 @@ func (r *RootCmd) ping() *serpent.Command {
defer notifyCancel()
workspaceName := inv.Args[0]
_, workspaceAgent, err := getWorkspaceAndAgent(
_, workspaceAgent, _, err := getWorkspaceAndAgent(
ctx, inv, client,
false, // Do not autostart for a ping.
workspaceName,
+2 -2
View File
@@ -21,11 +21,11 @@ func TestBuildSummary(t *testing.T) {
},
{
Err: "",
LatencySeconds: 0.2,
LatencySeconds: 0.3,
},
{
Err: "",
LatencySeconds: 0.3,
LatencySeconds: 0.2,
},
{
Err: "ping error",
+1 -1
View File
@@ -84,7 +84,7 @@ func (r *RootCmd) portForward() *serpent.Command {
return xerrors.New("no port-forwards requested")
}
workspace, workspaceAgent, err := getWorkspaceAndAgent(ctx, inv, client, !disableAutostart, inv.Args[0])
workspace, workspaceAgent, _, err := getWorkspaceAndAgent(ctx, inv, client, !disableAutostart, inv.Args[0])
if err != nil {
return err
}
+12 -108
View File
@@ -13,7 +13,6 @@ import (
"github.com/pion/udp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/agent"
"github.com/coder/coder/v2/agent/agenttest"
@@ -161,7 +160,7 @@ func TestPortForward(t *testing.T) {
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
iNet := newInProcNet()
iNet := testutil.NewInProcNet()
inv.Net = iNet
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
@@ -177,10 +176,10 @@ func TestPortForward(t *testing.T) {
// sync.
dialCtx, dialCtxCancel := context.WithTimeout(ctx, testutil.WaitShort)
defer dialCtxCancel()
c1, err := iNet.dial(dialCtx, addr{c.network, c.localAddress[0]})
c1, err := iNet.Dial(dialCtx, testutil.NewAddr(c.network, c.localAddress[0]))
require.NoError(t, err, "open connection 1 to 'local' listener")
defer c1.Close()
c2, err := iNet.dial(dialCtx, addr{c.network, c.localAddress[0]})
c2, err := iNet.Dial(dialCtx, testutil.NewAddr(c.network, c.localAddress[0]))
require.NoError(t, err, "open connection 2 to 'local' listener")
defer c2.Close()
testDial(t, c2)
@@ -218,7 +217,7 @@ func TestPortForward(t *testing.T) {
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
iNet := newInProcNet()
iNet := testutil.NewInProcNet()
inv.Net = iNet
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
@@ -232,10 +231,10 @@ func TestPortForward(t *testing.T) {
// then test them out of order.
dialCtx, dialCtxCancel := context.WithTimeout(ctx, testutil.WaitShort)
defer dialCtxCancel()
c1, err := iNet.dial(dialCtx, addr{c.network, c.localAddress[0]})
c1, err := iNet.Dial(dialCtx, testutil.NewAddr(c.network, c.localAddress[0]))
require.NoError(t, err, "open connection 1 to 'local' listener 1")
defer c1.Close()
c2, err := iNet.dial(dialCtx, addr{c.network, c.localAddress[1]})
c2, err := iNet.Dial(dialCtx, testutil.NewAddr(c.network, c.localAddress[1]))
require.NoError(t, err, "open connection 2 to 'local' listener 2")
defer c2.Close()
testDial(t, c2)
@@ -257,7 +256,7 @@ func TestPortForward(t *testing.T) {
t.Run("All", func(t *testing.T) {
t.Parallel()
var (
dials = []addr{}
dials = []testutil.Addr{}
flags = []string{}
)
@@ -265,10 +264,7 @@ func TestPortForward(t *testing.T) {
for _, c := range cases {
p := setupTestListener(t, c.setupRemote(t))
dials = append(dials, addr{
network: c.network,
addr: c.localAddress[0],
})
dials = append(dials, testutil.NewAddr(c.network, c.localAddress[0]))
flags = append(flags, fmt.Sprintf(c.flag[0], p))
}
@@ -279,7 +275,7 @@ func TestPortForward(t *testing.T) {
pty := ptytest.New(t).Attach(inv)
inv.Stderr = pty.Output()
iNet := newInProcNet()
iNet := testutil.NewInProcNet()
inv.Net = iNet
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
@@ -296,7 +292,7 @@ func TestPortForward(t *testing.T) {
)
defer dialCtxCancel()
for i, a := range dials {
c, err := iNet.dial(dialCtx, a)
c, err := iNet.Dial(dialCtx, a)
require.NoErrorf(t, err, "open connection %v to 'local' listener %v", i+1, i+1)
t.Cleanup(func() {
_ = c.Close()
@@ -340,7 +336,7 @@ func TestPortForward(t *testing.T) {
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
iNet := newInProcNet()
iNet := testutil.NewInProcNet()
inv.Net = iNet
// listen on port 5555 on IPv6 so it's busy when we try to port forward
@@ -361,7 +357,7 @@ func TestPortForward(t *testing.T) {
// Test IPv4 still works
dialCtx, dialCtxCancel := context.WithTimeout(ctx, testutil.WaitShort)
defer dialCtxCancel()
c1, err := iNet.dial(dialCtx, addr{"tcp", "127.0.0.1:5555"})
c1, err := iNet.Dial(dialCtx, testutil.NewAddr("tcp", "127.0.0.1:5555"))
require.NoError(t, err, "open connection 1 to 'local' listener")
defer c1.Close()
testDial(t, c1)
@@ -473,95 +469,3 @@ func assertWritePayload(t *testing.T, w io.Writer, payload []byte) {
assert.NoError(t, err, "write payload")
assert.Equal(t, len(payload), n, "payload length does not match")
}
type addr struct {
network string
addr string
}
func (a addr) Network() string {
return a.network
}
func (a addr) Address() string {
return a.addr
}
func (a addr) String() string {
return a.network + "|" + a.addr
}
type inProcNet struct {
sync.Mutex
listeners map[addr]*inProcListener
}
type inProcListener struct {
c chan net.Conn
n *inProcNet
a addr
o sync.Once
}
func newInProcNet() *inProcNet {
return &inProcNet{listeners: make(map[addr]*inProcListener)}
}
func (n *inProcNet) Listen(network, address string) (net.Listener, error) {
a := addr{network, address}
n.Lock()
defer n.Unlock()
if _, ok := n.listeners[a]; ok {
return nil, xerrors.New("busy")
}
l := newInProcListener(n, a)
n.listeners[a] = l
return l, nil
}
func (n *inProcNet) dial(ctx context.Context, a addr) (net.Conn, error) {
n.Lock()
defer n.Unlock()
l, ok := n.listeners[a]
if !ok {
return nil, xerrors.Errorf("nothing listening on %s", a)
}
x, y := net.Pipe()
select {
case <-ctx.Done():
return nil, ctx.Err()
case l.c <- x:
return y, nil
}
}
func newInProcListener(n *inProcNet, a addr) *inProcListener {
return &inProcListener{
c: make(chan net.Conn),
n: n,
a: a,
}
}
func (l *inProcListener) Accept() (net.Conn, error) {
c, ok := <-l.c
if !ok {
return nil, net.ErrClosed
}
return c, nil
}
func (l *inProcListener) Close() error {
l.o.Do(func() {
l.n.Lock()
defer l.n.Unlock()
delete(l.n.listeners, l.a)
close(l.c)
})
return nil
}
func (l *inProcListener) Addr() net.Addr {
return l.a
}
+1 -1
View File
@@ -166,7 +166,7 @@ func (r *RootCmd) provisionerJobsCancel() *serpent.Command {
err = client.CancelTemplateVersion(ctx, ptr.NilToEmpty(job.Input.TemplateVersionID))
case codersdk.ProvisionerJobTypeWorkspaceBuild:
_, _ = fmt.Fprintf(inv.Stdout, "Canceling workspace build job %s...\n", job.ID)
err = client.CancelWorkspaceBuild(ctx, ptr.NilToEmpty(job.Input.WorkspaceBuildID))
err = client.CancelWorkspaceBuild(ctx, ptr.NilToEmpty(job.Input.WorkspaceBuildID), codersdk.CancelWorkspaceBuildParams{})
}
if err != nil {
return xerrors.Errorf("cancel provisioner job: %w", err)
+9
View File
@@ -51,8 +51,17 @@ func (r *RootCmd) restart() *serpent.Command {
return err
}
stopParamValues, err := asWorkspaceBuildParameters(parameterFlags.ephemeralParameters)
if err != nil {
return xerrors.Errorf("parse ephemeral parameters: %w", err)
}
wbr := codersdk.CreateWorkspaceBuildRequest{
Transition: codersdk.WorkspaceTransitionStop,
// Ephemeral parameters should be passed to both stop and start builds.
// TODO: maybe these values should be sourced from the previous build?
// It has to be manually sourced, as ephemeral parameters do not carry across
// builds.
RichParameterValues: stopParamValues,
}
if bflags.provisionerLogDebug {
wbr.LogLevel = codersdk.ProvisionerLogLevelDebug
+27 -6
View File
@@ -10,6 +10,7 @@ import (
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/coderd/util/ptr"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/provisioner/echo"
"github.com/coder/coder/v2/provisionersdk/proto"
@@ -70,8 +71,14 @@ func TestRestart(t *testing.T) {
member, memberUser := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses())
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, member, template.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID, func(request *codersdk.CreateTemplateRequest) {
request.UseClassicParameterFlow = ptr.Ref(true) // TODO: Remove when dynamic parameters prompt missing ephemeral parameters.
})
workspace := coderdtest.CreateWorkspace(t, member, template.ID, func(request *codersdk.CreateWorkspaceRequest) {
request.RichParameterValues = []codersdk.WorkspaceBuildParameter{
{Name: ephemeralParameterName, Value: "placeholder"},
}
})
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
inv, root := clitest.New(t, "restart", workspace.Name, "--prompt-ephemeral-parameters")
@@ -125,7 +132,11 @@ func TestRestart(t *testing.T) {
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses())
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, member, template.ID)
workspace := coderdtest.CreateWorkspace(t, member, template.ID, func(request *codersdk.CreateWorkspaceRequest) {
request.RichParameterValues = []codersdk.WorkspaceBuildParameter{
{Name: ephemeralParameterName, Value: "placeholder"},
}
})
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
inv, root := clitest.New(t, "restart", workspace.Name,
@@ -178,8 +189,14 @@ func TestRestart(t *testing.T) {
member, memberUser := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses())
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, member, template.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID, func(request *codersdk.CreateTemplateRequest) {
request.UseClassicParameterFlow = ptr.Ref(true) // TODO: Remove when dynamic parameters prompts missing ephemeral parameters
})
workspace := coderdtest.CreateWorkspace(t, member, template.ID, func(request *codersdk.CreateWorkspaceRequest) {
request.RichParameterValues = []codersdk.WorkspaceBuildParameter{
{Name: ephemeralParameterName, Value: "placeholder"},
}
})
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
inv, root := clitest.New(t, "restart", workspace.Name, "--build-options")
@@ -233,7 +250,11 @@ func TestRestart(t *testing.T) {
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses())
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, member, template.ID)
workspace := coderdtest.CreateWorkspace(t, member, template.ID, func(request *codersdk.CreateWorkspaceRequest) {
request.RichParameterValues = []codersdk.WorkspaceBuildParameter{
{Name: ephemeralParameterName, Value: "placeholder"},
}
})
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
inv, root := clitest.New(t, "restart", workspace.Name,
+31 -39
View File
@@ -77,7 +77,6 @@ import (
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/awsiamrds"
"github.com/coder/coder/v2/coderd/database/dbauthz"
"github.com/coder/coder/v2/coderd/database/dbmem"
"github.com/coder/coder/v2/coderd/database/dbmetrics"
"github.com/coder/coder/v2/coderd/database/dbpurge"
"github.com/coder/coder/v2/coderd/database/migrations"
@@ -423,7 +422,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
builtinPostgres := false
// Only use built-in if PostgreSQL URL isn't specified!
if !vals.InMemoryDatabase && vals.PostgresURL == "" {
if vals.PostgresURL == "" {
var closeFunc func() error
cliui.Infof(inv.Stdout, "Using built-in PostgreSQL (%s)", config.PostgresPath())
customPostgresCacheDir := ""
@@ -726,42 +725,37 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
// nil, that case of the select will just never fire, but it's important not to have a
// "bare" read on this channel.
var pubsubWatchdogTimeout <-chan struct{}
if vals.InMemoryDatabase {
// This is only used for testing.
options.Database = dbmem.New()
options.Pubsub = pubsub.NewInMemory()
} else {
sqlDB, dbURL, err := getAndMigratePostgresDB(ctx, logger, vals.PostgresURL.String(), codersdk.PostgresAuth(vals.PostgresAuth), sqlDriver)
if err != nil {
return xerrors.Errorf("connect to postgres: %w", err)
}
defer func() {
_ = sqlDB.Close()
}()
if options.DeploymentValues.Prometheus.Enable {
// At this stage we don't think the database name serves much purpose in these metrics.
// It requires parsing the DSN to determine it, which requires pulling in another dependency
// (i.e. https://github.com/jackc/pgx), but it's rather heavy.
// The conn string (https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING) can
// take different forms, which make parsing non-trivial.
options.PrometheusRegistry.MustRegister(collectors.NewDBStatsCollector(sqlDB, ""))
}
options.Database = database.New(sqlDB)
ps, err := pubsub.New(ctx, logger.Named("pubsub"), sqlDB, dbURL)
if err != nil {
return xerrors.Errorf("create pubsub: %w", err)
}
options.Pubsub = ps
if options.DeploymentValues.Prometheus.Enable {
options.PrometheusRegistry.MustRegister(ps)
}
defer options.Pubsub.Close()
psWatchdog := pubsub.NewWatchdog(ctx, logger.Named("pswatch"), ps)
pubsubWatchdogTimeout = psWatchdog.Timeout()
defer psWatchdog.Close()
sqlDB, dbURL, err := getAndMigratePostgresDB(ctx, logger, vals.PostgresURL.String(), codersdk.PostgresAuth(vals.PostgresAuth), sqlDriver)
if err != nil {
return xerrors.Errorf("connect to postgres: %w", err)
}
defer func() {
_ = sqlDB.Close()
}()
if options.DeploymentValues.Prometheus.Enable {
// At this stage we don't think the database name serves much purpose in these metrics.
// It requires parsing the DSN to determine it, which requires pulling in another dependency
// (i.e. https://github.com/jackc/pgx), but it's rather heavy.
// The conn string (https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING) can
// take different forms, which make parsing non-trivial.
options.PrometheusRegistry.MustRegister(collectors.NewDBStatsCollector(sqlDB, ""))
}
options.Database = database.New(sqlDB)
ps, err := pubsub.New(ctx, logger.Named("pubsub"), sqlDB, dbURL)
if err != nil {
return xerrors.Errorf("create pubsub: %w", err)
}
options.Pubsub = ps
if options.DeploymentValues.Prometheus.Enable {
options.PrometheusRegistry.MustRegister(ps)
}
defer options.Pubsub.Close()
psWatchdog := pubsub.NewWatchdog(ctx, logger.Named("pswatch"), ps)
pubsubWatchdogTimeout = psWatchdog.Timeout()
defer psWatchdog.Close()
if options.DeploymentValues.Prometheus.Enable && options.DeploymentValues.Prometheus.CollectDBMetrics {
options.Database = dbmetrics.NewQueryMetrics(options.Database, options.Logger, options.PrometheusRegistry)
@@ -1107,7 +1101,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
autobuildTicker := time.NewTicker(vals.AutobuildPollInterval.Value())
defer autobuildTicker.Stop()
autobuildExecutor := autobuild.NewExecutor(
ctx, options.Database, options.Pubsub, coderAPI.FileCache, options.PrometheusRegistry, coderAPI.TemplateScheduleStore, &coderAPI.Auditor, coderAPI.AccessControlStore, logger, autobuildTicker.C, options.NotificationsEnqueuer, coderAPI.Experiments)
ctx, options.Database, options.Pubsub, coderAPI.FileCache, options.PrometheusRegistry, coderAPI.TemplateScheduleStore, &coderAPI.Auditor, coderAPI.AccessControlStore, coderAPI.BuildUsageChecker, logger, autobuildTicker.C, options.NotificationsEnqueuer, coderAPI.Experiments)
autobuildExecutor.Run()
jobReaperTicker := time.NewTicker(vals.JobReaperDetectorInterval.Value())
@@ -1184,7 +1178,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
var wg sync.WaitGroup
for i, provisionerDaemon := range provisionerDaemons {
id := i + 1
provisionerDaemon := provisionerDaemon
wg.Add(1)
go func() {
defer wg.Done()
@@ -1662,7 +1655,6 @@ func configureServerTLS(ctx context.Context, logger slog.Logger, tlsMinVersion,
// Expensively check which certificate matches the client hello.
for _, cert := range certs {
cert := cert
if err := hi.SupportsCertificate(&cert); err == nil {
return &cert, nil
}
-3
View File
@@ -59,9 +59,6 @@ import (
)
func dbArg(t *testing.T) string {
if !dbtestutil.WillUsePostgres() {
return "--in-memory"
}
dbURL, err := dbtestutil.Open(t)
require.NoError(t, err)
return "--postgres-url=" + dbURL
+18 -2
View File
@@ -8,6 +8,7 @@ import (
"github.com/google/uuid"
"github.com/coder/coder/v2/agent/agentcontainers"
"github.com/coder/coder/v2/cli/cliui"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/serpent"
@@ -15,9 +16,18 @@ import (
func (r *RootCmd) show() *serpent.Command {
client := new(codersdk.Client)
var details bool
return &serpent.Command{
Use: "show <workspace>",
Short: "Display details of a workspace's resources and agents",
Options: serpent.OptionSet{
{
Flag: "details",
Description: "Show full error messages and additional details.",
Default: "false",
Value: serpent.BoolOf(&details),
},
},
Middleware: serpent.Chain(
serpent.RequireNArgs(1),
r.InitClient(client),
@@ -35,6 +45,7 @@ func (r *RootCmd) show() *serpent.Command {
options := cliui.WorkspaceResourcesOptions{
WorkspaceName: workspace.Name,
ServerVersion: buildInfo.Version,
ShowDetails: details,
}
if workspace.LatestBuild.Status == codersdk.WorkspaceStatusRunning {
// Get listening ports for each agent.
@@ -42,6 +53,7 @@ func (r *RootCmd) show() *serpent.Command {
options.ListeningPorts = ports
options.Devcontainers = devcontainers
}
return cliui.WorkspaceResources(inv.Stdout, workspace.LatestBuild.Resources, options)
},
}
@@ -68,13 +80,17 @@ func fetchRuntimeResources(inv *serpent.Invocation, client *codersdk.Client, res
ports[agent.ID] = lp
mu.Unlock()
}()
if agent.ParentID.Valid {
continue
}
wg.Add(1)
go func() {
defer wg.Done()
dc, err := client.WorkspaceAgentListContainers(inv.Context(), agent.ID, map[string]string{
// Labels set by VSCode Remote Containers and @devcontainers/cli.
"devcontainer.config_file": "",
"devcontainer.local_folder": "",
agentcontainers.DevcontainerConfigFileLabel: "",
agentcontainers.DevcontainerLocalFolderLabel: "",
})
if err != nil {
cliui.Warnf(inv.Stderr, "Failed to get devcontainers for agent %s: %v", agent.Name, err)
+358
View File
@@ -1,12 +1,19 @@
package cli_test
import (
"bytes"
"testing"
"time"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/agent/agentcontainers"
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/cli/cliui"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/pty/ptytest"
)
@@ -53,3 +60,354 @@ func TestShow(t *testing.T) {
<-doneChan
})
}
func TestShowDevcontainers_Golden(t *testing.T) {
t.Parallel()
mainAgentID := uuid.MustParse("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")
agentID := mainAgentID
testCases := []struct {
name string
showDetails bool
devcontainers []codersdk.WorkspaceAgentDevcontainer
listeningPorts map[uuid.UUID]codersdk.WorkspaceAgentListeningPortsResponse
}{
{
name: "running_devcontainer_with_agent",
devcontainers: []codersdk.WorkspaceAgentDevcontainer{
{
ID: uuid.MustParse("11111111-1111-1111-1111-111111111111"),
Name: "web-dev",
WorkspaceFolder: "/workspaces/web-dev",
ConfigPath: "/workspaces/web-dev/.devcontainer/devcontainer.json",
Status: codersdk.WorkspaceAgentDevcontainerStatusRunning,
Dirty: false,
Container: &codersdk.WorkspaceAgentContainer{
ID: "container-web-dev",
FriendlyName: "quirky_lovelace",
Image: "mcr.microsoft.com/devcontainers/typescript-node:1.0.0",
Running: true,
Status: "running",
CreatedAt: time.Now().Add(-1 * time.Hour),
Labels: map[string]string{
agentcontainers.DevcontainerConfigFileLabel: "/workspaces/web-dev/.devcontainer/devcontainer.json",
agentcontainers.DevcontainerLocalFolderLabel: "/workspaces/web-dev",
},
},
Agent: &codersdk.WorkspaceAgentDevcontainerAgent{
ID: uuid.MustParse("22222222-2222-2222-2222-222222222222"),
Name: "web-dev",
Directory: "/workspaces/web-dev",
},
},
},
listeningPorts: map[uuid.UUID]codersdk.WorkspaceAgentListeningPortsResponse{
uuid.MustParse("22222222-2222-2222-2222-222222222222"): {
Ports: []codersdk.WorkspaceAgentListeningPort{
{
ProcessName: "node",
Network: "tcp",
Port: 3000,
},
{
ProcessName: "webpack-dev-server",
Network: "tcp",
Port: 8080,
},
},
},
},
},
{
name: "running_devcontainer_without_agent",
devcontainers: []codersdk.WorkspaceAgentDevcontainer{
{
ID: uuid.MustParse("33333333-3333-3333-3333-333333333333"),
Name: "web-server",
WorkspaceFolder: "/workspaces/web-server",
ConfigPath: "/workspaces/web-server/.devcontainer/devcontainer.json",
Status: codersdk.WorkspaceAgentDevcontainerStatusRunning,
Dirty: false,
Container: &codersdk.WorkspaceAgentContainer{
ID: "container-web-server",
FriendlyName: "amazing_turing",
Image: "nginx:latest",
Running: true,
Status: "running",
CreatedAt: time.Now().Add(-30 * time.Minute),
Labels: map[string]string{
agentcontainers.DevcontainerConfigFileLabel: "/workspaces/web-server/.devcontainer/devcontainer.json",
agentcontainers.DevcontainerLocalFolderLabel: "/workspaces/web-server",
},
},
Agent: nil, // No agent for this running container.
},
},
},
{
name: "stopped_devcontainer",
devcontainers: []codersdk.WorkspaceAgentDevcontainer{
{
ID: uuid.MustParse("44444444-4444-4444-4444-444444444444"),
Name: "api-dev",
WorkspaceFolder: "/workspaces/api-dev",
ConfigPath: "/workspaces/api-dev/.devcontainer/devcontainer.json",
Status: codersdk.WorkspaceAgentDevcontainerStatusStopped,
Dirty: false,
Container: &codersdk.WorkspaceAgentContainer{
ID: "container-api-dev",
FriendlyName: "clever_darwin",
Image: "mcr.microsoft.com/devcontainers/go:1.0.0",
Running: false,
Status: "exited",
CreatedAt: time.Now().Add(-2 * time.Hour),
Labels: map[string]string{
agentcontainers.DevcontainerConfigFileLabel: "/workspaces/api-dev/.devcontainer/devcontainer.json",
agentcontainers.DevcontainerLocalFolderLabel: "/workspaces/api-dev",
},
},
Agent: nil, // No agent for stopped container.
},
},
},
{
name: "starting_devcontainer",
devcontainers: []codersdk.WorkspaceAgentDevcontainer{
{
ID: uuid.MustParse("55555555-5555-5555-5555-555555555555"),
Name: "database-dev",
WorkspaceFolder: "/workspaces/database-dev",
ConfigPath: "/workspaces/database-dev/.devcontainer/devcontainer.json",
Status: codersdk.WorkspaceAgentDevcontainerStatusStarting,
Dirty: false,
Container: &codersdk.WorkspaceAgentContainer{
ID: "container-database-dev",
FriendlyName: "nostalgic_hawking",
Image: "mcr.microsoft.com/devcontainers/postgres:1.0.0",
Running: false,
Status: "created",
CreatedAt: time.Now().Add(-5 * time.Minute),
Labels: map[string]string{
agentcontainers.DevcontainerConfigFileLabel: "/workspaces/database-dev/.devcontainer/devcontainer.json",
agentcontainers.DevcontainerLocalFolderLabel: "/workspaces/database-dev",
},
},
Agent: nil, // No agent yet while starting.
},
},
},
{
name: "error_devcontainer",
devcontainers: []codersdk.WorkspaceAgentDevcontainer{
{
ID: uuid.MustParse("66666666-6666-6666-6666-666666666666"),
Name: "failed-dev",
WorkspaceFolder: "/workspaces/failed-dev",
ConfigPath: "/workspaces/failed-dev/.devcontainer/devcontainer.json",
Status: codersdk.WorkspaceAgentDevcontainerStatusError,
Dirty: false,
Error: "Failed to pull image mcr.microsoft.com/devcontainers/go:latest: timeout after 5m0s",
Container: nil, // No container due to error.
Agent: nil, // No agent due to error.
},
},
},
{
name: "mixed_devcontainer_states",
devcontainers: []codersdk.WorkspaceAgentDevcontainer{
{
ID: uuid.MustParse("88888888-8888-8888-8888-888888888888"),
Name: "frontend",
WorkspaceFolder: "/workspaces/frontend",
Status: codersdk.WorkspaceAgentDevcontainerStatusRunning,
Container: &codersdk.WorkspaceAgentContainer{
ID: "container-frontend",
FriendlyName: "vibrant_tesla",
Image: "node:18",
Running: true,
Status: "running",
CreatedAt: time.Now().Add(-30 * time.Minute),
},
Agent: &codersdk.WorkspaceAgentDevcontainerAgent{
ID: uuid.MustParse("99999999-9999-9999-9999-999999999999"),
Name: "frontend",
Directory: "/workspaces/frontend",
},
},
{
ID: uuid.MustParse("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"),
Name: "backend",
WorkspaceFolder: "/workspaces/backend",
Status: codersdk.WorkspaceAgentDevcontainerStatusStopped,
Container: &codersdk.WorkspaceAgentContainer{
ID: "container-backend",
FriendlyName: "peaceful_curie",
Image: "python:3.11",
Running: false,
Status: "exited",
CreatedAt: time.Now().Add(-1 * time.Hour),
},
Agent: nil,
},
{
ID: uuid.MustParse("bbbbbbbb-cccc-dddd-eeee-ffffffffffff"),
Name: "error-container",
WorkspaceFolder: "/workspaces/error-container",
Status: codersdk.WorkspaceAgentDevcontainerStatusError,
Error: "Container build failed: dockerfile syntax error on line 15",
Container: nil,
Agent: nil,
},
},
listeningPorts: map[uuid.UUID]codersdk.WorkspaceAgentListeningPortsResponse{
uuid.MustParse("99999999-9999-9999-9999-999999999999"): {
Ports: []codersdk.WorkspaceAgentListeningPort{
{
ProcessName: "vite",
Network: "tcp",
Port: 5173,
},
},
},
},
},
{
name: "running_devcontainer_with_agent_and_error",
devcontainers: []codersdk.WorkspaceAgentDevcontainer{
{
ID: uuid.MustParse("cccccccc-dddd-eeee-ffff-000000000000"),
Name: "problematic-dev",
WorkspaceFolder: "/workspaces/problematic-dev",
ConfigPath: "/workspaces/problematic-dev/.devcontainer/devcontainer.json",
Status: codersdk.WorkspaceAgentDevcontainerStatusRunning,
Dirty: false,
Error: "Warning: Container started but healthcheck failed",
Container: &codersdk.WorkspaceAgentContainer{
ID: "container-problematic",
FriendlyName: "cranky_mendel",
Image: "mcr.microsoft.com/devcontainers/python:1.0.0",
Running: true,
Status: "running",
CreatedAt: time.Now().Add(-15 * time.Minute),
Labels: map[string]string{
agentcontainers.DevcontainerConfigFileLabel: "/workspaces/problematic-dev/.devcontainer/devcontainer.json",
agentcontainers.DevcontainerLocalFolderLabel: "/workspaces/problematic-dev",
},
},
Agent: &codersdk.WorkspaceAgentDevcontainerAgent{
ID: uuid.MustParse("dddddddd-eeee-ffff-aaaa-111111111111"),
Name: "problematic-dev",
Directory: "/workspaces/problematic-dev",
},
},
},
listeningPorts: map[uuid.UUID]codersdk.WorkspaceAgentListeningPortsResponse{
uuid.MustParse("dddddddd-eeee-ffff-aaaa-111111111111"): {
Ports: []codersdk.WorkspaceAgentListeningPort{
{
ProcessName: "python",
Network: "tcp",
Port: 8000,
},
},
},
},
},
{
name: "long_error_message",
devcontainers: []codersdk.WorkspaceAgentDevcontainer{
{
ID: uuid.MustParse("eeeeeeee-ffff-0000-1111-222222222222"),
Name: "long-error-dev",
WorkspaceFolder: "/workspaces/long-error-dev",
ConfigPath: "/workspaces/long-error-dev/.devcontainer/devcontainer.json",
Status: codersdk.WorkspaceAgentDevcontainerStatusError,
Dirty: false,
Error: "Failed to build devcontainer: dockerfile parse error at line 25: unknown instruction 'INSTALL', did you mean 'RUN apt-get install'? This is a very long error message that should be truncated when detail flag is not used",
Container: nil,
Agent: nil,
},
},
},
{
name: "long_error_message_with_detail",
showDetails: true,
devcontainers: []codersdk.WorkspaceAgentDevcontainer{
{
ID: uuid.MustParse("eeeeeeee-ffff-0000-1111-222222222222"),
Name: "long-error-dev",
WorkspaceFolder: "/workspaces/long-error-dev",
ConfigPath: "/workspaces/long-error-dev/.devcontainer/devcontainer.json",
Status: codersdk.WorkspaceAgentDevcontainerStatusError,
Dirty: false,
Error: "Failed to build devcontainer: dockerfile parse error at line 25: unknown instruction 'INSTALL', did you mean 'RUN apt-get install'? This is a very long error message that should be truncated when detail flag is not used",
Container: nil,
Agent: nil,
},
},
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
var allAgents []codersdk.WorkspaceAgent
mainAgent := codersdk.WorkspaceAgent{
ID: mainAgentID,
Name: "main",
OperatingSystem: "linux",
Architecture: "amd64",
Status: codersdk.WorkspaceAgentConnected,
Health: codersdk.WorkspaceAgentHealth{Healthy: true},
Version: "v2.15.0",
}
allAgents = append(allAgents, mainAgent)
for _, dc := range tc.devcontainers {
if dc.Agent != nil {
devcontainerAgent := codersdk.WorkspaceAgent{
ID: dc.Agent.ID,
ParentID: uuid.NullUUID{UUID: mainAgentID, Valid: true},
Name: dc.Agent.Name,
OperatingSystem: "linux",
Architecture: "amd64",
Status: codersdk.WorkspaceAgentConnected,
Health: codersdk.WorkspaceAgentHealth{Healthy: true},
Version: "v2.15.0",
}
allAgents = append(allAgents, devcontainerAgent)
}
}
resources := []codersdk.WorkspaceResource{
{
Type: "compute",
Name: "main",
Agents: allAgents,
},
}
options := cliui.WorkspaceResourcesOptions{
WorkspaceName: "test-workspace",
ServerVersion: "v2.15.0",
ShowDetails: tc.showDetails,
Devcontainers: map[uuid.UUID]codersdk.WorkspaceAgentListContainersResponse{
agentID: {
Devcontainers: tc.devcontainers,
},
},
ListeningPorts: tc.listeningPorts,
}
var buf bytes.Buffer
err := cliui.WorkspaceResources(&buf, resources, options)
require.NoError(t, err)
replacements := map[string]string{}
clitest.TestGoldenFile(t, "TestShowDevcontainers_Golden/"+tc.name, buf.Bytes(), replacements)
})
}
}
+1 -1
View File
@@ -83,7 +83,7 @@ func (r *RootCmd) speedtest() *serpent.Command {
return xerrors.Errorf("--direct (-d) is incompatible with --%s", varDisableDirect)
}
_, workspaceAgent, err := getWorkspaceAndAgent(ctx, inv, client, false, inv.Args[0])
_, workspaceAgent, _, err := getWorkspaceAndAgent(ctx, inv, client, false, inv.Args[0])
if err != nil {
return err
}
+31 -26
View File
@@ -754,7 +754,8 @@ func findWorkspaceAndAgentByHostname(
hostname = strings.TrimSuffix(hostname, qualifiedSuffix)
}
hostname = normalizeWorkspaceInput(hostname)
return getWorkspaceAndAgent(ctx, inv, client, !disableAutostart, hostname)
ws, agent, _, err := getWorkspaceAndAgent(ctx, inv, client, !disableAutostart, hostname)
return ws, agent, err
}
// watchAndClose ensures closer is called if the context is canceled or
@@ -827,9 +828,10 @@ startWatchLoop:
}
// getWorkspaceAgent returns the workspace and agent selected using either the
// `<workspace>[.<agent>]` syntax via `in`.
// `<workspace>[.<agent>]` syntax via `in`. It will also return any other agents
// in the workspace as a slice for use in child->parent lookups.
// If autoStart is true, the workspace will be started if it is not already running.
func getWorkspaceAndAgent(ctx context.Context, inv *serpent.Invocation, client *codersdk.Client, autostart bool, input string) (codersdk.Workspace, codersdk.WorkspaceAgent, error) { //nolint:revive
func getWorkspaceAndAgent(ctx context.Context, inv *serpent.Invocation, client *codersdk.Client, autostart bool, input string) (codersdk.Workspace, codersdk.WorkspaceAgent, []codersdk.WorkspaceAgent, error) { //nolint:revive
var (
workspace codersdk.Workspace
// The input will be `owner/name.agent`
@@ -840,27 +842,27 @@ func getWorkspaceAndAgent(ctx context.Context, inv *serpent.Invocation, client *
workspace, err = namedWorkspace(ctx, client, workspaceParts[0])
if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil, err
}
if workspace.LatestBuild.Transition != codersdk.WorkspaceTransitionStart {
if !autostart {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, xerrors.New("workspace must be started")
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil, xerrors.New("workspace must be started")
}
// Autostart the workspace for the user.
// For some failure modes, return a better message.
if workspace.LatestBuild.Transition == codersdk.WorkspaceTransitionDelete {
// Any sort of deleting status, we should reject with a nicer error.
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, xerrors.Errorf("workspace %q is deleted", workspace.Name)
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil, xerrors.Errorf("workspace %q is deleted", workspace.Name)
}
if workspace.LatestBuild.Job.Status == codersdk.ProvisionerJobFailed {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{},
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil,
xerrors.Errorf("workspace %q is in failed state, unable to autostart the workspace", workspace.Name)
}
// The workspace needs to be stopped before we can start it.
// It cannot be in any pending or failed state.
if workspace.LatestBuild.Status != codersdk.WorkspaceStatusStopped {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{},
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil,
xerrors.Errorf("workspace must be started; was unable to autostart as the last build job is %q, expected %q",
workspace.LatestBuild.Status,
codersdk.WorkspaceStatusStopped,
@@ -871,7 +873,9 @@ func getWorkspaceAndAgent(ctx context.Context, inv *serpent.Invocation, client *
// It's possible for a workspace build to fail due to the template requiring starting
// workspaces with the active version.
_, _ = fmt.Fprintf(inv.Stderr, "Workspace was stopped, starting workspace to allow connecting to %q...\n", workspace.Name)
_, err = startWorkspace(inv, client, workspace, workspaceParameterFlags{}, buildFlags{}, WorkspaceStart)
_, err = startWorkspace(inv, client, workspace, workspaceParameterFlags{}, buildFlags{
reason: string(codersdk.BuildReasonSSHConnection),
}, WorkspaceStart)
if cerr, ok := codersdk.AsError(err); ok {
switch cerr.StatusCode() {
case http.StatusConflict:
@@ -881,48 +885,48 @@ func getWorkspaceAndAgent(ctx context.Context, inv *serpent.Invocation, client *
case http.StatusForbidden:
_, err = startWorkspace(inv, client, workspace, workspaceParameterFlags{}, buildFlags{}, WorkspaceUpdate)
if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, xerrors.Errorf("start workspace with active template version: %w", err)
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil, xerrors.Errorf("start workspace with active template version: %w", err)
}
_, _ = fmt.Fprintln(inv.Stdout, "Unable to start the workspace with template version from last build. Your workspace has been updated to the current active template version.")
}
} else if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, xerrors.Errorf("start workspace with current template version: %w", err)
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil, xerrors.Errorf("start workspace with current template version: %w", err)
}
// Refresh workspace state so that `outdated`, `build`,`template_*` fields are up-to-date.
workspace, err = namedWorkspace(ctx, client, workspaceParts[0])
if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil, err
}
}
if workspace.LatestBuild.Job.CompletedAt == nil {
err := cliui.WorkspaceBuild(ctx, inv.Stderr, client, workspace.LatestBuild.ID)
if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil, err
}
// Fetch up-to-date build information after completion.
workspace.LatestBuild, err = client.WorkspaceBuild(ctx, workspace.LatestBuild.ID)
if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil, err
}
}
if workspace.LatestBuild.Transition == codersdk.WorkspaceTransitionDelete {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, xerrors.Errorf("workspace %q is being deleted", workspace.Name)
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil, xerrors.Errorf("workspace %q is being deleted", workspace.Name)
}
var agentName string
if len(workspaceParts) >= 2 {
agentName = workspaceParts[1]
}
workspaceAgent, err := getWorkspaceAgent(workspace, agentName)
workspaceAgent, otherWorkspaceAgents, err := getWorkspaceAgent(workspace, agentName)
if err != nil {
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, err
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, nil, err
}
return workspace, workspaceAgent, nil
return workspace, workspaceAgent, otherWorkspaceAgents, nil
}
func getWorkspaceAgent(workspace codersdk.Workspace, agentName string) (workspaceAgent codersdk.WorkspaceAgent, err error) {
func getWorkspaceAgent(workspace codersdk.Workspace, agentName string) (workspaceAgent codersdk.WorkspaceAgent, otherAgents []codersdk.WorkspaceAgent, err error) {
resources := workspace.LatestBuild.Resources
var (
@@ -936,22 +940,23 @@ func getWorkspaceAgent(workspace codersdk.Workspace, agentName string) (workspac
}
}
if len(agents) == 0 {
return codersdk.WorkspaceAgent{}, xerrors.Errorf("workspace %q has no agents", workspace.Name)
return codersdk.WorkspaceAgent{}, nil, xerrors.Errorf("workspace %q has no agents", workspace.Name)
}
slices.Sort(availableNames)
if agentName != "" {
for _, otherAgent := range agents {
if otherAgent.Name != agentName {
for i, agent := range agents {
if agent.Name != agentName || agent.ID.String() == agentName {
continue
}
return otherAgent, nil
otherAgents := slices.Delete(agents, i, i+1)
return agent, otherAgents, nil
}
return codersdk.WorkspaceAgent{}, xerrors.Errorf("agent not found by name %q, available agents: %v", agentName, availableNames)
return codersdk.WorkspaceAgent{}, nil, xerrors.Errorf("agent not found by name %q, available agents: %v", agentName, availableNames)
}
if len(agents) == 1 {
return agents[0], nil
return agents[0], nil, nil
}
return codersdk.WorkspaceAgent{}, xerrors.Errorf("multiple agents found, please specify the agent name, available agents: %v", availableNames)
return codersdk.WorkspaceAgent{}, nil, xerrors.Errorf("multiple agents found, please specify the agent name, available agents: %v", availableNames)
}
// Attempt to poll workspace autostop. We write a per-workspace lockfile to
+9 -6
View File
@@ -376,7 +376,7 @@ func Test_getWorkspaceAgent(t *testing.T) {
agent := createAgent("main")
workspace := createWorkspaceWithAgents([]codersdk.WorkspaceAgent{agent})
result, err := getWorkspaceAgent(workspace, "")
result, _, err := getWorkspaceAgent(workspace, "")
require.NoError(t, err)
assert.Equal(t, agent.ID, result.ID)
assert.Equal(t, "main", result.Name)
@@ -388,7 +388,7 @@ func Test_getWorkspaceAgent(t *testing.T) {
agent2 := createAgent("main2")
workspace := createWorkspaceWithAgents([]codersdk.WorkspaceAgent{agent1, agent2})
_, err := getWorkspaceAgent(workspace, "")
_, _, err := getWorkspaceAgent(workspace, "")
require.Error(t, err)
assert.Contains(t, err.Error(), "multiple agents found")
assert.Contains(t, err.Error(), "available agents: [main1 main2]")
@@ -400,10 +400,13 @@ func Test_getWorkspaceAgent(t *testing.T) {
agent2 := createAgent("main2")
workspace := createWorkspaceWithAgents([]codersdk.WorkspaceAgent{agent1, agent2})
result, err := getWorkspaceAgent(workspace, "main1")
result, other, err := getWorkspaceAgent(workspace, "main1")
require.NoError(t, err)
assert.Equal(t, agent1.ID, result.ID)
assert.Equal(t, "main1", result.Name)
assert.Len(t, other, 1)
assert.Equal(t, agent2.ID, other[0].ID)
assert.Equal(t, "main2", other[0].Name)
})
t.Run("AgentNameSpecified_NotFound", func(t *testing.T) {
@@ -412,7 +415,7 @@ func Test_getWorkspaceAgent(t *testing.T) {
agent2 := createAgent("main2")
workspace := createWorkspaceWithAgents([]codersdk.WorkspaceAgent{agent1, agent2})
_, err := getWorkspaceAgent(workspace, "nonexistent")
_, _, err := getWorkspaceAgent(workspace, "nonexistent")
require.Error(t, err)
assert.Contains(t, err.Error(), `agent not found by name "nonexistent"`)
assert.Contains(t, err.Error(), "available agents: [main1 main2]")
@@ -422,7 +425,7 @@ func Test_getWorkspaceAgent(t *testing.T) {
t.Parallel()
workspace := createWorkspaceWithAgents([]codersdk.WorkspaceAgent{})
_, err := getWorkspaceAgent(workspace, "")
_, _, err := getWorkspaceAgent(workspace, "")
require.Error(t, err)
assert.Contains(t, err.Error(), `workspace "test-workspace" has no agents`)
})
@@ -435,7 +438,7 @@ func Test_getWorkspaceAgent(t *testing.T) {
agent3 := createAgent("krypton")
workspace := createWorkspaceWithAgents([]codersdk.WorkspaceAgent{agent2, agent1, agent3})
_, err := getWorkspaceAgent(workspace, "nonexistent")
_, _, err := getWorkspaceAgent(workspace, "nonexistent")
require.Error(t, err)
// Available agents should be sorted alphabetically.
assert.Contains(t, err.Error(), "available agents: [clark krypton zod]")
+3 -1
View File
@@ -2031,6 +2031,7 @@ func TestSSH_Container(t *testing.T) {
_ = agenttest.New(t, client.URL, agentToken, func(o *agent.Options) {
o.Devcontainers = true
o.DevcontainerAPIOptions = append(o.DevcontainerAPIOptions,
agentcontainers.WithProjectDiscovery(false),
agentcontainers.WithContainerLabelIncludeFilter("this.label.does.not.exist.ignore.devcontainers", "true"),
)
})
@@ -2072,6 +2073,7 @@ func TestSSH_Container(t *testing.T) {
o.Devcontainers = true
o.DevcontainerAPIOptions = append(o.DevcontainerAPIOptions,
agentcontainers.WithContainerCLI(mLister),
agentcontainers.WithProjectDiscovery(false),
agentcontainers.WithContainerLabelIncludeFilter("this.label.does.not.exist.ignore.devcontainers", "true"),
)
})
@@ -2104,7 +2106,7 @@ func TestSSH_Container(t *testing.T) {
clitest.SetupConfig(t, client, root)
err := inv.WithContext(ctx).Run()
require.ErrorContains(t, err, "The agent dev containers feature is experimental and not enabled by default.")
require.ErrorContains(t, err, "Dev Container feature not enabled.")
})
}
+3
View File
@@ -169,6 +169,9 @@ func buildWorkspaceStartRequest(inv *serpent.Invocation, client *codersdk.Client
if buildFlags.provisionerLogDebug {
wbr.LogLevel = codersdk.ProvisionerLogLevelDebug
}
if buildFlags.reason != "" {
wbr.Reason = codersdk.CreateWorkspaceBuildReason(buildFlags.reason)
}
return wbr, nil
}
+56 -4
View File
@@ -113,10 +113,18 @@ func TestStart(t *testing.T) {
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses())
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, member, template.ID)
workspace := coderdtest.CreateWorkspace(t, member, template.ID, func(request *codersdk.CreateWorkspaceRequest) {
request.RichParameterValues = []codersdk.WorkspaceBuildParameter{
{Name: ephemeralParameterName, Value: "foo"}, // Value is required, set it to something
}
})
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
// Stop the workspace
workspaceBuild := coderdtest.CreateWorkspaceBuild(t, client, workspace, database.WorkspaceTransitionStop)
workspaceBuild := coderdtest.CreateWorkspaceBuild(t, client, workspace, database.WorkspaceTransitionStop, func(request *codersdk.CreateWorkspaceBuildRequest) {
request.RichParameterValues = []codersdk.WorkspaceBuildParameter{
{Name: ephemeralParameterName, Value: "foo"}, // Value is required, set it to something
}
})
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspaceBuild.ID)
inv, root := clitest.New(t, "start", workspace.Name, "--prompt-ephemeral-parameters")
@@ -167,10 +175,18 @@ func TestStart(t *testing.T) {
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses())
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, member, template.ID)
workspace := coderdtest.CreateWorkspace(t, member, template.ID, func(request *codersdk.CreateWorkspaceRequest) {
request.RichParameterValues = []codersdk.WorkspaceBuildParameter{
{Name: ephemeralParameterName, Value: "foo"}, // Value is required, set it to something
}
})
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
// Stop the workspace
workspaceBuild := coderdtest.CreateWorkspaceBuild(t, client, workspace, database.WorkspaceTransitionStop)
workspaceBuild := coderdtest.CreateWorkspaceBuild(t, client, workspace, database.WorkspaceTransitionStop, func(request *codersdk.CreateWorkspaceBuildRequest) {
request.RichParameterValues = []codersdk.WorkspaceBuildParameter{
{Name: ephemeralParameterName, Value: "foo"}, // Value is required, set it to something
}
})
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspaceBuild.ID)
inv, root := clitest.New(t, "start", workspace.Name,
@@ -477,3 +493,39 @@ func TestStart_NoWait(t *testing.T) {
pty.ExpectMatch("workspace has been started in no-wait mode")
_ = testutil.TryReceive(ctx, t, doneChan)
}
func TestStart_WithReason(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitShort)
// Prepare user, template, workspace
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
version1 := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil)
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version1.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version1.ID)
workspace := coderdtest.CreateWorkspace(t, member, template.ID)
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
// Stop the workspace
build := coderdtest.CreateWorkspaceBuild(t, member, workspace, database.WorkspaceTransitionStop)
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, build.ID)
// Start the workspace with reason
inv, root := clitest.New(t, "start", workspace.Name, "--reason", "cli")
clitest.SetupConfig(t, member, root)
doneChan := make(chan struct{})
pty := ptytest.New(t).Attach(inv)
go func() {
defer close(doneChan)
err := inv.Run()
assert.NoError(t, err)
}()
pty.ExpectMatch("workspace has been started")
_ = testutil.TryReceive(ctx, t, doneChan)
workspace = coderdtest.MustWorkspace(t, member, workspace.ID)
require.Equal(t, codersdk.BuildReasonCLI, workspace.LatestBuild.Reason)
}
+177
View File
@@ -0,0 +1,177 @@
package cli
import (
"fmt"
"strconv"
"strings"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/cli/cliui"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/serpent"
)
func (r *RootCmd) templatePresets() *serpent.Command {
cmd := &serpent.Command{
Use: "presets",
Short: "Manage presets of the specified template",
Aliases: []string{"preset"},
Long: FormatExamples(
Example{
Description: "List presets for the active version of a template",
Command: "coder templates presets list my-template",
},
Example{
Description: "List presets for a specific version of a template",
Command: "coder templates presets list my-template --template-version my-template-version",
},
),
Handler: func(inv *serpent.Invocation) error {
return inv.Command.HelpHandler(inv)
},
Children: []*serpent.Command{
r.templatePresetsList(),
},
}
return cmd
}
func (r *RootCmd) templatePresetsList() *serpent.Command {
defaultColumns := []string{
"name",
"description",
"parameters",
"default",
"desired prebuild instances",
}
formatter := cliui.NewOutputFormatter(
cliui.TableFormat([]TemplatePresetRow{}, defaultColumns),
cliui.JSONFormat(),
)
client := new(codersdk.Client)
orgContext := NewOrganizationContext()
var templateVersion string
cmd := &serpent.Command{
Use: "list <template>",
Middleware: serpent.Chain(
serpent.RequireNArgs(1),
r.InitClient(client),
),
Short: "List all presets of the specified template. Defaults to the active template version.",
Options: serpent.OptionSet{
{
Name: "template-version",
Description: "Specify a template version to list presets for. Defaults to the active version.",
Flag: "template-version",
Value: serpent.StringOf(&templateVersion),
},
},
Handler: func(inv *serpent.Invocation) error {
organization, err := orgContext.Selected(inv, client)
if err != nil {
return xerrors.Errorf("get current organization: %w", err)
}
template, err := client.TemplateByName(inv.Context(), organization.ID, inv.Args[0])
if err != nil {
return xerrors.Errorf("get template by name: %w", err)
}
// If a template version is specified via flag, fetch that version by name
var version codersdk.TemplateVersion
if len(templateVersion) > 0 {
version, err = client.TemplateVersionByName(inv.Context(), template.ID, templateVersion)
if err != nil {
return xerrors.Errorf("get template version by name: %w", err)
}
} else {
// Otherwise, use the template's active version
version, err = client.TemplateVersion(inv.Context(), template.ActiveVersionID)
if err != nil {
return xerrors.Errorf("get active template version: %w", err)
}
}
presets, err := client.TemplateVersionPresets(inv.Context(), version.ID)
if err != nil {
return xerrors.Errorf("get template versions presets by template version: %w", err)
}
if len(presets) == 0 {
cliui.Infof(
inv.Stdout,
"No presets found for template %q and template-version %q.\n", template.Name, version.Name,
)
return nil
}
// Only display info message for table output
if formatter.FormatID() == "table" {
cliui.Infof(
inv.Stdout,
"Showing presets for template %q and template version %q.\n", template.Name, version.Name,
)
}
rows := templatePresetsToRows(presets...)
out, err := formatter.Format(inv.Context(), rows)
if err != nil {
return xerrors.Errorf("render table: %w", err)
}
_, err = fmt.Fprintln(inv.Stdout, out)
return err
},
}
orgContext.AttachOptions(cmd)
formatter.AttachOptions(&cmd.Options)
return cmd
}
type TemplatePresetRow struct {
// For json format
TemplatePreset codersdk.Preset `table:"-"`
// For table format:
Name string `json:"-" table:"name,default_sort"`
Description string `json:"-" table:"description"`
Parameters string `json:"-" table:"parameters"`
Default bool `json:"-" table:"default"`
DesiredPrebuildInstances string `json:"-" table:"desired prebuild instances"`
}
func formatPresetParameters(params []codersdk.PresetParameter) string {
var paramsStr []string
for _, p := range params {
paramsStr = append(paramsStr, fmt.Sprintf("%s=%s", p.Name, p.Value))
}
return strings.Join(paramsStr, ",")
}
// templatePresetsToRows converts a list of presets to a list of rows
// for outputting.
func templatePresetsToRows(presets ...codersdk.Preset) []TemplatePresetRow {
rows := make([]TemplatePresetRow, len(presets))
for i, preset := range presets {
prebuildInstances := "-"
if preset.DesiredPrebuildInstances != nil {
prebuildInstances = strconv.Itoa(*preset.DesiredPrebuildInstances)
}
rows[i] = TemplatePresetRow{
// For json format
TemplatePreset: preset,
// For table format
Name: preset.Name,
Description: preset.Description,
Parameters: formatPresetParameters(preset.Parameters),
Default: preset.Default,
DesiredPrebuildInstances: prebuildInstances,
}
}
return rows
}
+295
View File
@@ -0,0 +1,295 @@
package cli_test
import (
"bytes"
"encoding/json"
"fmt"
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/cli"
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/provisioner/echo"
"github.com/coder/coder/v2/provisionersdk/proto"
"github.com/coder/coder/v2/pty/ptytest"
"github.com/coder/coder/v2/testutil"
)
func TestTemplatePresets(t *testing.T) {
t.Parallel()
t.Run("NoPresets", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: a template version without presets
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, templateWithPresets([]*proto.Preset{}))
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
// When: listing presets for that template
inv, root := clitest.New(t, "templates", "presets", "list", template.Name)
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t).Attach(inv)
doneChan := make(chan struct{})
var runErr error
go func() {
defer close(doneChan)
runErr = inv.Run()
}()
<-doneChan
require.NoError(t, runErr)
// Should return a message when no presets are found for the given template and version.
notFoundMessage := fmt.Sprintf("No presets found for template %q and template-version %q.", template.Name, version.Name)
pty.ExpectRegexMatch(notFoundMessage)
})
t.Run("ListsPresetsForDefaultTemplateVersion", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: an active template version that includes presets
presets := []*proto.Preset{
{
Name: "preset-multiple-params",
Parameters: []*proto.PresetParameter{
{
Name: "k1",
Value: "v1",
}, {
Name: "k2",
Value: "v2",
},
},
},
{
Name: "preset-default",
Default: true,
Parameters: []*proto.PresetParameter{
{
Name: "k1",
Value: "v2",
},
},
Prebuild: &proto.Prebuild{
Instances: 0,
},
},
{
Name: "preset-prebuilds",
Description: "Preset without parameters and 2 prebuild instances.",
Parameters: []*proto.PresetParameter{},
Prebuild: &proto.Prebuild{
Instances: 2,
},
},
}
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, templateWithPresets(presets))
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
require.Equal(t, version.ID, template.ActiveVersionID)
// When: listing presets for that template
inv, root := clitest.New(t, "templates", "presets", "list", template.Name)
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t).Attach(inv)
doneChan := make(chan struct{})
var runErr error
go func() {
defer close(doneChan)
runErr = inv.Run()
}()
<-doneChan
require.NoError(t, runErr)
// Should: return the active version's presets sorted by name
message := fmt.Sprintf("Showing presets for template %q and template version %q.", template.Name, version.Name)
pty.ExpectMatch(message)
pty.ExpectRegexMatch(`preset-default\s+k1=v2\s+true\s+0`)
// The parameter order is not guaranteed in the output, so we match both possible orders
pty.ExpectRegexMatch(`preset-multiple-params\s+(k1=v1,k2=v2)|(k2=v2,k1=v1)\s+false\s+-`)
pty.ExpectRegexMatch(`preset-prebuilds\s+Preset without parameters and 2 prebuild instances.\s+\s+false\s+2`)
})
t.Run("ListsPresetsForSpecifiedTemplateVersion", func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitMedium)
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: a template with an active version that has no presets,
// and another template version that includes presets
presets := []*proto.Preset{
{
Name: "preset-multiple-params",
Parameters: []*proto.PresetParameter{
{
Name: "k1",
Value: "v1",
}, {
Name: "k2",
Value: "v2",
},
},
},
{
Name: "preset-default",
Default: true,
Parameters: []*proto.PresetParameter{
{
Name: "k1",
Value: "v2",
},
},
Prebuild: &proto.Prebuild{
Instances: 0,
},
},
{
Name: "preset-prebuilds",
Description: "Preset without parameters and 2 prebuild instances.",
Parameters: []*proto.PresetParameter{},
Prebuild: &proto.Prebuild{
Instances: 2,
},
},
}
// Given: first template version with presets
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, templateWithPresets(presets))
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
// Given: second template version without presets
activeVersion := coderdtest.UpdateTemplateVersion(t, client, owner.OrganizationID, templateWithPresets([]*proto.Preset{}), template.ID)
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, activeVersion.ID)
// Given: second template version is the active version
err := client.UpdateActiveTemplateVersion(ctx, template.ID, codersdk.UpdateActiveTemplateVersion{
ID: activeVersion.ID,
})
require.NoError(t, err)
updatedTemplate, err := client.Template(ctx, template.ID)
require.NoError(t, err)
require.Equal(t, activeVersion.ID, updatedTemplate.ActiveVersionID)
// Given: template has two versions
templateVersions, err := client.TemplateVersionsByTemplate(ctx, codersdk.TemplateVersionsByTemplateRequest{
TemplateID: updatedTemplate.ID,
})
require.NoError(t, err)
require.Len(t, templateVersions, 2)
// When: listing presets for a specific template and its specified version
inv, root := clitest.New(t, "templates", "presets", "list", updatedTemplate.Name, "--template-version", version.Name)
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t).Attach(inv)
doneChan := make(chan struct{})
var runErr error
go func() {
defer close(doneChan)
runErr = inv.Run()
}()
<-doneChan
require.NoError(t, runErr)
// Should: return the specified version's presets sorted by name
message := fmt.Sprintf("Showing presets for template %q and template version %q.", template.Name, version.Name)
pty.ExpectMatch(message)
pty.ExpectRegexMatch(`preset-default\s+k1=v2\s+true\s+0`)
// The parameter order is not guaranteed in the output, so we match both possible orders
pty.ExpectRegexMatch(`preset-multiple-params\s+(k1=v1,k2=v2)|(k2=v2,k1=v1)\s+false\s+-`)
pty.ExpectRegexMatch(`preset-prebuilds\s+Preset without parameters and 2 prebuild instances.\s+\s+false\s+2`)
})
t.Run("ListsPresetsJSON", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
// Given: an active template version that includes presets
preset := proto.Preset{
Name: "preset-default",
Description: "Preset with parameters and 2 prebuild instances.",
Icon: "/emojis/1f60e.png",
Default: true,
Parameters: []*proto.PresetParameter{
{
Name: "k1",
Value: "v2",
},
},
Prebuild: &proto.Prebuild{
Instances: 2,
},
}
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, templateWithPresets([]*proto.Preset{&preset}))
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
require.Equal(t, version.ID, template.ActiveVersionID)
// When: listing presets for that template
inv, root := clitest.New(t, "templates", "presets", "list", template.Name, "-o", "json")
clitest.SetupConfig(t, member, root)
buf := bytes.NewBuffer(nil)
inv.Stdout = buf
doneChan := make(chan struct{})
var runErr error
go func() {
defer close(doneChan)
runErr = inv.Run()
}()
<-doneChan
require.NoError(t, runErr)
// Should: return the active version's preset
var jsonPresets []cli.TemplatePresetRow
err := json.Unmarshal(buf.Bytes(), &jsonPresets)
require.NoError(t, err, "unmarshal JSON output")
require.Len(t, jsonPresets, 1)
jsonPreset := jsonPresets[0].TemplatePreset
require.Equal(t, preset.Name, jsonPreset.Name)
require.Equal(t, preset.Description, jsonPreset.Description)
require.Equal(t, preset.Icon, jsonPreset.Icon)
require.Equal(t, preset.Default, jsonPreset.Default)
require.Equal(t, len(preset.Parameters), len(jsonPreset.Parameters))
require.Equal(t, preset.Parameters[0].Name, jsonPreset.Parameters[0].Name)
require.Equal(t, preset.Parameters[0].Value, jsonPreset.Parameters[0].Value)
require.Equal(t, int(preset.Prebuild.Instances), *jsonPreset.DesiredPrebuildInstances)
})
}
func templateWithPresets(presets []*proto.Preset) *echo.Responses {
return &echo.Responses{
Parse: echo.ParseComplete,
ProvisionPlan: []*proto.Response{
{
Type: &proto.Response_Plan{
Plan: &proto.PlanComplete{
Presets: presets,
},
},
},
},
}
}
+1
View File
@@ -509,6 +509,7 @@ func TestTemplatePush(t *testing.T) {
default = "1"
}
data "coder_parameter" "b" {
name = "b"
type = string
default = "2"
}
+1
View File
@@ -33,6 +33,7 @@ func (r *RootCmd) templates() *serpent.Command {
r.templateList(),
r.templatePush(),
r.templateVersions(),
r.templatePresets(),
r.templateDelete(),
r.templatePull(),
r.archiveTemplateVersions(),
@@ -0,0 +1,9 @@
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ RESOURCE STATUS HEALTH VERSION ACCESS │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ compute.main │
│ └─ main (linux, amd64) ⦿ connected ✔ healthy v2.15.0 coder ssh test-workspace.main │
│ └─ Devcontainers │
│ └─ failed-dev ✘ error │
× Failed to pull image mcr.microsoft.com/devcontainers/go:latest: timeout after 5… │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
@@ -0,0 +1,9 @@
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ RESOURCE STATUS HEALTH VERSION ACCESS │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ compute.main │
│ └─ main (linux, amd64) ⦿ connected ✔ healthy v2.15.0 coder ssh test-workspace.main │
│ └─ Devcontainers │
│ └─ long-error-dev ✘ error │
× Failed to build devcontainer: dockerfile parse error at line 25: unknown instru… │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
@@ -0,0 +1,9 @@
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ RESOURCE STATUS HEALTH VERSION ACCESS │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ compute.main │
│ └─ main (linux, amd64) ⦿ connected ✔ healthy v2.15.0 coder ssh test-workspace.main │
│ └─ Devcontainers │
│ └─ long-error-dev ✘ error │
× Failed to build devcontainer: dockerfile parse error at line 25: unknown instruction 'INSTALL', did you mean 'RUN apt-get install'? This is a very long error message that should be truncated when detail flag is not used │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
@@ -0,0 +1,13 @@
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ RESOURCE STATUS HEALTH VERSION ACCESS │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ compute.main │
│ └─ main (linux, amd64) ⦿ connected ✔ healthy v2.15.0 coder ssh test-workspace.main │
│ └─ Devcontainers │
│ ├─ frontend (linux, amd64) [vibrant_tesla] ⦿ connected ✔ healthy v2.15.0 coder ssh test-workspace.frontend │
│ ├─ Open Ports │
│ └─ 5173/tcp [vite] │
│ ├─ backend [peaceful_curie] ⏹ stopped │
│ └─ error-container ✘ error │
× Container build failed: dockerfile syntax error on line 15 │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
@@ -0,0 +1,11 @@
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ RESOURCE STATUS HEALTH VERSION ACCESS │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ compute.main │
│ └─ main (linux, amd64) ⦿ connected ✔ healthy v2.15.0 coder ssh test-workspace.main │
│ └─ Devcontainers │
│ └─ web-dev (linux, amd64) [quirky_lovelace] ⦿ connected ✔ healthy v2.15.0 coder ssh test-workspace.web-dev │
│ └─ Open Ports │
│ ├─ 3000/tcp [node] │
│ └─ 8080/tcp [webpack-dev-server] │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
@@ -0,0 +1,11 @@
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ RESOURCE STATUS HEALTH VERSION ACCESS │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ compute.main │
│ └─ main (linux, amd64) ⦿ connected ✔ healthy v2.15.0 coder ssh test-workspace.main │
│ └─ Devcontainers │
│ └─ problematic-dev (linux, amd64) [cranky_mendel] ⦿ connected ✔ healthy v2.15.0 coder ssh test-workspace.problematic-dev │
× Warning: Container started but healthcheck failed │
│ └─ Open Ports │
│ └─ 8000/tcp [python] │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Some files were not shown because too many files have changed in this diff Show More