Compare commits

...

3572 Commits

Author SHA1 Message Date
Ben Potter d843735c02 docs: explain Template inheritance with Terraform modules (#8328)
* docs: explain Template inheritance with Terraform modules

* make fmt & title renaming

---------

Co-authored-by: Eric <ericpaulsen@coder.com>
2023-07-05 15:06:16 -04:00
Colin Adler c0835c443d chore: pin terraform to 1.5.2 (#8322)
The Alpine ARM builders are no longer behind on releases.
2023-07-05 12:59:58 -05:00
Steven Masley 418c9b8743 docs: update template acl example params (#8320)
Param examples were unhelpful
2023-07-05 17:24:21 +00:00
Steven Masley 4a008a8f34 chore: prevent nil dereferences on cmd handlers (#8319)
* chore: detect nil cmd handlers

Prevent nil panic dereferences on cmd handlers. Add a unit test
to prevent future mistakes
2023-07-05 17:20:12 +00:00
Steven Masley d70e2d97de chore: use correct prettier version in ci (#8321)
Install prettier in package.json + yarn.lock. Global install was using incorrect version
2023-07-05 13:11:08 -04:00
Steven Masley 0f5a1ad480 feat: add spinner to latencies when refetching (#8278)
* feat: add spinner to latencies when refetching
2023-07-05 13:06:09 -04:00
Steven Masley 9a7705c656 feat: generate a new session with coder login --token (#8275)
* feat: coder login --token generates a new session

Makes sure /logout does not delete the inputted token
* flag to enable previous behavior if needed
2023-07-05 08:59:38 -04:00
Mathias Fredriksson 88c35d3f04 fix(pty): close output writer before reader on Windows to unblock close (#8299) 2023-07-05 15:25:07 +03:00
Colin Adler 59246e054f chore(dogfood): add libssl-dev to image (#8312) 2023-07-05 00:24:32 -05:00
sharkymark 65112ecc04 docs: update examples of IDEs: remove JetBrains Projector and add VS Code Server (#8310)
* docs: remove mention of jetbrains projector; add vs code server web IDE example

* fmt

---------

Co-authored-by: Ben <me@bpmct.net>
2023-07-04 13:27:49 +00:00
dependabot[bot] 647fd7699b chore: bump github.com/prometheus/client_golang from 1.15.1 to 1.16.0 (#8300)
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.15.1 to 1.16.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.15.1...v1.16.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-03 13:00:37 -05:00
dependabot[bot] 865f49af35 chore: bump github.com/gohugoio/hugo from 0.114.1 to 0.115.0 (#8301)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.114.1 to 0.115.0.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/hugoreleaser.toml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.114.1...v0.115.0)

---
updated-dependencies:
- dependency-name: github.com/gohugoio/hugo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-03 13:00:31 -05:00
dependabot[bot] 2fc8a275fe chore: bump google.golang.org/api from 0.128.0 to 0.129.0 (#8303)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.128.0 to 0.129.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.128.0...v0.129.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-03 13:00:15 -05:00
dependabot[bot] 82a6405bfa chore: bump golang.org/x/tools from 0.9.3 to 0.10.0 (#8304)
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.9.3 to 0.10.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.9.3...v0.10.0)

---
updated-dependencies:
- dependency-name: golang.org/x/tools
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-03 13:00:05 -05:00
Jon Ayers 4a9c8f407a feat: add auto-locking/deleting workspace based on template config (#8240) 2023-07-02 21:29:52 -05:00
dependabot[bot] 818c4a7f23 chore: bump yup from 0.32.11 to 1.2.0 in /site (#8287)
Bumps [yup](https://github.com/jquense/yup) from 0.32.11 to 1.2.0.
- [Release notes](https://github.com/jquense/yup/releases)
- [Changelog](https://github.com/jquense/yup/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jquense/yup/compare/v0.32.11...v1.2.0)

---
updated-dependencies:
- dependency-name: yup
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-02 10:32:43 -05:00
dependabot[bot] 2af41a439b chore: bump @vitejs/plugin-react from 2.1.0 to 4.0.1 in /site (#8288)
Bumps [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react) from 2.1.0 to 4.0.1.
- [Release notes](https://github.com/vitejs/vite-plugin-react/releases)
- [Changelog](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite-plugin-react/commits/plugin-react@4.0.1/packages/plugin-react)

---
updated-dependencies:
- dependency-name: "@vitejs/plugin-react"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-02 10:32:36 -05:00
dependabot[bot] 2899b9431d chore: bump monaco-editor from 0.38.0 to 0.39.0 in /site (#8289)
Bumps [monaco-editor](https://github.com/microsoft/monaco-editor) from 0.38.0 to 0.39.0.
- [Changelog](https://github.com/microsoft/monaco-editor/blob/main/CHANGELOG.md)
- [Commits](https://github.com/microsoft/monaco-editor/compare/v0.38.0...v0.39.0)

---
updated-dependencies:
- dependency-name: monaco-editor
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-02 10:32:30 -05:00
dependabot[bot] c19541e28f chore: bump eslint-plugin-unicorn from 44.0.0 to 47.0.0 in /site (#8291)
Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 44.0.0 to 47.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v44.0.0...v47.0.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-unicorn
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-02 10:32:19 -05:00
Jon Ayers 681e2db9ec Revert "fix: add front-end fixes for minor workspace action bugs (#8252)" (#8286)
This reverts commit c569528fb7.
2023-06-30 20:26:38 -05:00
Muhammad Atif Ali 83bee35c36 chore: prevent running ci when other workflows are updated (#8285) 2023-06-30 22:38:50 +00:00
Muhammad Atif Ali dad4876e90 chore: react to deploy-pr comment (#8284) 2023-06-30 22:25:23 +00:00
Asher 6015319e9d feat: show service banner in SSH/TTY sessions (#8186)
* Allow workspace agents to get appearance
* Poll for service banner every two minutes
* Show service banner before MOTD if not quiet
2023-06-30 10:41:29 -08:00
Steven Masley eb0497ff82 feat: fetch proxy latencies at most once per 30s (#8277)
* feat: fetch proxy latencies at most once per 30s
2023-06-30 12:45:02 -04:00
Steven Masley f0bd258ff1 feat: move proxy settings page to deployment options (#8246)
* feat: Move workspace proxy page to deployment options

Workspace proxy settings page is now an admin feature

* WorkspaceProxy response extends region
2023-06-30 11:32:35 -04:00
Cian Johnston 1e8cc2ca8d feat: scaletest: scale down nodegroups by default (#8276)
* feat: allow scaling down scaletest environments

* fix bugged namespace deletion

* misc fixes to scaletest.sh

* destroy namespaces is a no-op as the cluster will be gone anyway
2023-06-30 16:07:47 +01:00
Cian Johnston a6bd85df38 feat: scaletest: add Grafana dashboard for scale testing (#8274)
* feat: scaletest: add Grafana dashboard for scale testing

Fixes #7600.

* make fmt
2023-06-30 14:04:46 +00:00
Kira Pilot c569528fb7 fix: add front-end fixes for minor workspace action bugs (#8252)
* fix: incorrect copy on inactivity_ttl field

* disabling locked fields unless inactivity TTL is set

* scoping inactivity dialog message to template

* fixed pluralization for inactivity dialog

* amending logic gate to show inactivity dialog

* fixed pagination bug
2023-06-30 09:45:44 -04:00
Steven Masley 9f76dab348 chore: Bump migration to remove conflict (#8273) 2023-06-30 13:12:40 +00:00
Cian Johnston 8b2d4b87fc fix: examples/lima: use new parameter name when creating template (#8272) 2023-06-30 12:45:47 +00:00
Steven Masley b5f26d9bdf feat: add ability for users to convert their password login type to oauth/github login (#8105)
* Currently toggled by experiment flag

---------

Co-authored-by: Bruno Quaresma <bruno@coder.com>
2023-06-30 08:38:48 -04:00
Cian Johnston 357f3b38f7 fix: scaletest: mount CODER_CACHE volume under /tmp (#8271)
Mounting the CODER_CACHE volume under /tmp/coder causes
template creation to fail due to read-only tmp dir.
2023-06-30 12:48:34 +01:00
Marcin Tojek 6639c69fad feat: add "display_order" column to coder_parameter to keep parameters sorted in UI (#8227) 2023-06-30 12:41:55 +02:00
Colin Adler 72a48bee52 fix: pin datadog-ci version (#8270) 2023-06-30 03:42:13 +00:00
Kyle Carberry 34467a3289 feat: add github device flow for authentication (#8232)
* feat: add github device flow for authentication

This will allow us to add a GitHub OAuth provider out-of-the-box
to reduce setup requirements.

* Improve askpass view

* Add routes to improve clarity of git auth

* Redesign the git auth page

* Refactor to add a page view

* Fix sideways layout

* Remove legacy notify

* Fix git auth redirects

* Add E2E tests

* Fix route documentation

* Fix imports

* Remove unused imports

* Fix E2E web test

* Fix friendly message appearance

* Fix layout shifting for full-screen sign-in

* Fix height going to 100%

* Fix comments
2023-06-29 18:58:01 +00:00
Eric Paulsen 7f82eca64a docs: note SSH key location in workspaces (#8264) 2023-06-29 12:01:07 -04:00
Cian Johnston 7072b8eff5 chore: update scaletest terraform with latest findings (#8249)
Updates scaletest terraform with learnings from #8213:

- Increase max pods per node to 256
- Decrease CPU requests for test workspace to allow maxing out workspaces per node
- Explicitly set CODER_ACCESS_URL for ssh to work
- Explicitly disable rate limits in coderd
- Increase DB size for medium and large scenarios
- Mount cache volume directly under /tmp/coder instead of /tmp.
- Plumb through requests and limits for workspaces
- Plumb through requests for coderd
2023-06-29 14:03:11 +00:00
Marcin Tojek 83fee4b192 feat: enable Terraform debug mode via deployment configuration (#8260) 2023-06-29 15:22:21 +02:00
Kira Pilot 7ca624eceb fix: removing prettier path in vscode config (#8255) 2023-06-29 09:00:51 -04:00
Jon Ayers 749307ef08 feat: provide endpoint to lock/unlock workspace (#8239) 2023-06-28 16:12:49 -05:00
Steven Masley 72e83df578 hotfix: fix broken link in the group sync docs (#8251) 2023-06-28 13:55:50 -04:00
Marcin Tojek 3dbc96d597 feat: show queue position of pending workspace build (#8244) 2023-06-28 14:48:58 +02:00
Mathias Fredriksson d3c39b60c9 feat: add agent log streaming and follow provisioner format (#8170) 2023-06-28 10:54:13 +02:00
Spike Curtis c0a01ec81c fix: fix TestPGCoordinatorDual_Mainline flake (#8228)
* fix TestPGCoordinatorDual_Mainline flake

Signed-off-by: Spike Curtis <spike@coder.com>

* use slices.Contains instead of local function

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-28 11:37:45 +04:00
Eric Paulsen df95cf7ab2 feat: helm rbac perms for deployments (#8233) 2023-06-27 15:14:39 -04:00
Colin Adler b8a143566b fix: use *string instead of error in healthcheck response (#8234) 2023-06-27 19:13:54 +00:00
Asher e2e07b01e9 fix: revert to canvas renderer for xterm (#8138)
The default changed from canvas to DOM in the last update.  The canvas
renderer resolves line spacing issues and has better performance, as
well as bringing us back to the previous status quo.

In the new version the canvas is enabled via an addon.
2023-06-27 09:57:16 -08:00
Mathias Fredriksson b4751c72d8 fix(cli/agent): wrap lumberjack logger to prevent re-open (#8229) 2023-06-27 12:49:44 +00:00
Mathias Fredriksson 6d176aee5d test(agent): fix lifecycle test flakeyness (#8230) 2023-06-27 12:44:16 +00:00
Muhammad Atif Ali 25decc152a chore: fix broken docs links (#8198)
* chore: add examples templates to docs filter

* chore: fix broken docs links

* Discard changes to .github/workflows/ci.yaml
2023-06-27 08:20:57 -04:00
Ben Potter 70cd87140d docs: mark agent metadata as GA (#8111)
* docs: agent metadata is now GA

* fmt
2023-06-27 07:35:01 -04:00
Muhammad Atif Ali 9cefd46bcf chore: delete skipped workflow runs of pr-deploy.yaml (#8225) 2023-06-27 14:26:21 +03:00
Marcin Tojek b83cdfe428 chore: update nix flake to include sqlc v1.18.0 (#8226) 2023-06-27 12:50:04 +02:00
Spike Curtis 7943a5b85e fix PG coordinator context and RBAC subject (#8223)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-27 10:14:31 +00:00
Spike Curtis 5d26637686 feat(scaletest): add license and experiment to scaletest (#8222)
* add license and experiment to scaletest

Signed-off-by: Spike Curtis <spike@coder.com>

* appease lint & fmt

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-27 10:13:36 +00:00
Muhammad Atif Ali 96435ee2ce chore: fix condition in pr-deploy.yaml (#8224) 2023-06-27 09:59:15 +00:00
dependabot[bot] c969da469d chore: bump semver from 7.3.7 to 7.5.2 in /site (#8162)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-27 12:54:19 +03:00
Muhammad Atif Ali b4ca285582 chore: ignore sub directories in examples for go files check (#8197)
There are no go files in any of the subdirectories in examples directory.
2023-06-27 00:35:09 +03:00
Steven Masley 140683813d chore: reword wsproxy help (#8168) 2023-06-26 12:32:47 -05:00
Mathias Fredriksson 31076ad665 fix(enterprise/coderd): prevent deadlock during entitlements update (#8215) 2023-06-26 20:22:28 +03:00
Steven Masley 56395410bd chore: disable auto proxy selection based on latency (#8137)
* chore: disable auto pick proxy based on latency

* Remove latency pulled from storage
2023-06-26 13:08:32 -04:00
Steven Masley 82415a6541 chore: add documentation to address common group sync errors (#8212)
* chore: Add documentation to address common group sync errors
2023-06-26 13:08:20 -04:00
Cian Johnston 80ef147060 fix(cli): stat: explicitly specify resource SI prefix (#8206)
* fix(cli): move to explicitly specifying units

* make gen
2023-06-26 18:06:38 +01:00
dependabot[bot] 1558ef52f1 chore: bump github.com/gohugoio/hugo from 0.113.0 to 0.114.1 (#8201)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-26 10:48:39 -05:00
dependabot[bot] 98457e993b chore: bump github.com/valyala/fasthttp from 1.47.0 to 1.48.0 (#8204)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-26 15:40:21 +00:00
Kyle Carberry f40865bc2f chore: use mutex around blockEndpoints (#8209)
https://github.com/coder/coder/actions/runs/5378950122/jobs/9759972142
2023-06-26 10:01:50 -05:00
dependabot[bot] 4539ce7db6 chore: bump golang.org/x/oauth2 from 0.8.0 to 0.9.0 (#8203)
Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.8.0 to 0.9.0.
- [Commits](https://github.com/golang/oauth2/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: golang.org/x/oauth2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-26 10:01:10 -05:00
Cian Johnston b8437ce453 fix(scaletest): adjust sessionAffinity and scenario resources (#8205)
* scaletest: adjust scenario resources
* scaletest: set sessionAffinity=None for coder service
2023-06-26 15:54:05 +01:00
Muhammad Atif Ali cfbe96a379 chore: return success if pr-cleanup.yaml faisl to find a PR image tag (#8208) 2023-06-26 14:47:10 +00:00
Marcin Tojek b4f14cc6a9 feat: include coder_parameters from external modules (#8195) 2023-06-26 13:46:30 +00:00
Muhammad Atif Ali 0a6e6442b8 chore: add examples templates to docs filter (#8196) 2023-06-26 09:48:23 +00:00
野漫横江 bdecf53413 Update additional-clusters.md (#8190)
Domain name should not be localhost
2023-06-25 15:41:17 +00:00
野漫横江 e27cfe6e6a docs: fix incorrect command in project documentation (#8191) 2023-06-25 15:12:10 +00:00
Dean Sheather 98a5ae7f48 feat: add provisioner job hang detector (#7927) 2023-06-25 13:17:00 +00:00
Eric Paulsen 3671846b1b docs: add default dir for VS Code Desktop (#8184) 2023-06-23 17:52:01 -05:00
Eric Paulsen 46df6c58bc docs: add max lifetime docs and refactor UI helper text (#8185) 2023-06-23 17:51:42 -05:00
Spike Curtis 5d48122f12 fix: fix PG Coordinator to update when heartbeats (re)start (#8178)
* fix: fix PG Coordinator to update when heartbeats (re)start

Signed-off-by: Spike Curtis <spike@coder.com>

* rename resetExpiryTimer(WithLock)

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-23 10:38:58 +00:00
Spike Curtis ba9d038d42 feat: add periodic cleanup of PG Coordinator state (#8142)
* PG Coordinator cleans orphaned state

Signed-off-by: Spike Curtis <spike@coder.com>

* Don't need pubsub

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-23 13:23:28 +04:00
Rodrigo Maia c594f02948 fix(site): display correct user_limit on license ui (#8118) 2023-06-23 08:38:36 +02:00
Steven Masley 797e91d4c6 feat: add flag for Windows to create unix compatible filepaths (#8164)
* feat: add flag for Windows to create unix compatible filepaths
2023-06-22 17:08:12 -05:00
Marcin Tojek 5d45218a5d docs: application logs (#8166) 2023-06-22 23:25:17 +02:00
Mathias Fredriksson 3b9b06fe5a feat(codersdk/agentsdk): add StartupLogsSender and StartupLogsWriter (#8129)
This commit adds two new `agentsdk` functions, `StartupLogsSender` and
`StartupLogsWriter` that can be used by any client looking to send
startup logs to coderd.

We also refactor the `agent` to use these new functions.

As a bonus, agent startup logs are separated into "info" and "error"
levels to separate stdout and stderr.

---------

Co-authored-by: Marcin Tojek <mtojek@users.noreply.github.com>
2023-06-22 23:28:59 +03:00
Steven Masley f56db1b41b feat: add user search query param on last_seen (#8139)
* feat: add sql filter for before/after on last_seen column
2023-06-22 15:24:48 -05:00
Colin Adler 97945ae272 fix(scripts): properly shift for --build-base option (#8167) 2023-06-22 15:24:03 -05:00
Colin Adler 41e7216df7 chore: upgrade terraform to 1.5.1 (#8160) 2023-06-22 19:08:40 +00:00
Marcin Tojek 8e2422d42c feat: use named loggers in coderd (#8148) 2023-06-22 20:09:33 +02:00
Muhammad Atif Ali 1417c12229 ci: get PR number correctly from pull_request event (#8158) 2023-06-22 17:19:14 +00:00
Muhammad Atif Ali 2c046ef475 ci: use single quotes when we have backticks in title (#8159) 2023-06-22 16:57:44 +00:00
Muhammad Atif Ali f4a712b271 ci: delete old workflow runs for pr-cleanup.yaml(#8146) 2023-06-22 19:16:06 +03:00
Muhammad Atif Ali ea4b9a4354 ci: fix syntax issue in pr-deploy.yaml (#8154) 2023-06-22 16:06:15 +00:00
Muhammad Atif Ali eee4f835ec ci: fix wrong trigger pr-deploy.yaml (#8151) 2023-06-22 18:29:27 +03:00
Muhammad Atif Ali 1ffc8058c2 ci: deploy automatic PR deployments on request (#8121) 2023-06-22 14:35:58 +00:00
Spike Curtis e856491476 feat: enable PG Coordinator as experiment (#8144)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-22 13:12:29 +04:00
Spike Curtis e738123a9c chore: log ssh connection disconnects with errors (#8143)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-22 11:37:50 +04:00
Jon Ayers 1b0124ecdb feat: automatically stop workspaces based on failure_ttl (#7989) 2023-06-22 00:33:22 -04:00
Kyle Carberry d434181941 feat: add cohesive e2e tests for the web terminal, apps, and workspaces (#8140)
* feat: add cohesive e2e tests for the web terminal, apps, and workspaces

* Fix web terminal flake
2023-06-22 00:21:40 +00:00
Kyle Carberry 2a492b7008 chore: improve the setup experience with various fixes (#8130)
* Move updatecheck logs to debug mode

This was causing logs to be emitted immediately after
initial setup, which seemed odd for the user.

* Fix setup page text to say "Create" instead of "Setup" account

* Improve copy on the empty workspaces page

- This view can be seen after the user creates their first workspace, so saying first is bad.
- It should describe what a workspace is, so I modified the description.
- The create from template button wasn't helpful!

* Improve the copy for the empty templates view

- This didn't describe what a template actually is.
- The title had the same problem as workspaces, where first makes no sense.

* Improve text consistency on the Create Template page

* Fix "View activity" displaying for non-Enterprise users

This was causing an exception to be thrown.

* Improve messaging of empty groups view

* Appropriately capitalize Workspace and Template

* Improve Docker template taglines

* Fix types
2023-06-21 18:23:59 -05:00
Dean Sheather a28d422c35 feat: add flag to disable all direct connections (#7936) 2023-06-21 22:02:05 +00:00
Asher 96f9e61ca1 Strip CORS headers from applications (#8057)
The problem is that the headers get doubled up (not overwritten) and
browsers do not like multiple values for the allowed origin even though
it appears the spec allows for it.

We could prefer the application's headers instead of ours but since we
control OPTIONS I think preferring ours will by the more consistent
experience and also aligns with the original RFC.
2023-06-21 13:41:27 -08:00
Dean Sheather 24b95e16c4 feat: add --disable-direct flag to CLI (#8131) 2023-06-21 20:22:43 +00:00
Colin Adler bc739bdfce feat(cli): add hidden netcheck command (#8136) 2023-06-21 14:33:19 -05:00
Colin Adler 7703bb77a7 ci: update sqlc version in security scan (#8135) 2023-06-21 13:53:41 -05:00
Eric Paulsen a0d0e0e72d docs: add coder ping example for troubleshooting (#8133) 2023-06-21 18:07:24 +00:00
Bruno Quaresma 1faed639c4 fix(site): show error when parameter is invalid (#8125) 2023-06-21 11:39:28 -03:00
Bruno Quaresma bce8a983fe chore(site): remove new filter from experimental (#8112) 2023-06-21 10:20:37 -03:00
Spike Curtis cc17d2feea refactor: add postgres tailnet coordinator (#8044)
* postgres tailnet coordinator

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix db migration; tests

Signed-off-by: Spike Curtis <spike@coder.com>

* Add fixture, regenerate

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix fixtures

Signed-off-by: Spike Curtis <spike@coder.com>

* review comments, run clean gen

Signed-off-by: Spike Curtis <spike@coder.com>

* Rename waitForConn -> cleanupConn

Signed-off-by: Spike Curtis <spike@coder.com>

* code review updates

Signed-off-by: Spike Curtis <spike@coder.com>

* db migration order

Signed-off-by: Spike Curtis <spike@coder.com>

* fix log field name last_heartbeat

Signed-off-by: Spike Curtis <spike@coder.com>

* fix heartbeat_from log field

Signed-off-by: Spike Curtis <spike@coder.com>

* fix slog fields for linting

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-21 16:20:58 +04:00
Marcin Tojek 4fb4c9b270 chore: add more rules to ensure logs consistency (#8104) 2023-06-21 12:00:38 +02:00
Spike Curtis 1c8f564fdb feat: add logging of ssh connections to agent (#8096)
* feat: adds logging of ssh connections to agent

Signed-off-by: Spike Curtis <spike@coder.com>

* code review improvements

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-21 13:49:58 +04:00
Colin Adler 4a431b6eb8 feat(helm): add coder.command to control pod command (#8116) 2023-06-20 22:59:01 +00:00
Colin Adler 15cba05dfc ci: scan images with sysdig (#8037) 2023-06-20 22:58:17 +00:00
Eric Paulsen b398814ab0 docs: add prometheus scrape_config example (#8113)
* docs: add prometheus scrape_config example

* make: fmt

* add: label

* fix: spelling

* scheme: http
2023-06-20 21:09:35 +00:00
Colin Adler 7d43f4ceee chore: update dogfood image (#8114) 2023-06-20 15:08:15 -05:00
Kyle Carberry 69f911dfd5 feat: add queue_position and queue_size to provisioner jobs (#8074) 2023-06-20 15:07:18 -05:00
Kyle Carberry bbb0fab1de chore: merge database gen scripts (#8073)
* chore: merge database gen scripts

* Fix type params gen

* Merge enum into dbgen
2023-06-20 16:24:33 +00:00
Kyle Carberry f3b2009499 chore: reorder helm chart to improve ux (#8108)
It makes no sense that the primary option `env` was so far
below infrequently used options.
2023-06-20 16:23:56 +00:00
Kyle Carberry 467b0a1004 chore: restyle provisioner job output format (#8106)
Reduce colors and formatting to reduce bugs and increase UNIX-feel.
2023-06-20 16:16:27 +00:00
Colin Adler 823127e761 feat: add healthcheck database section (#8060) 2023-06-20 15:13:22 +00:00
Bruno Quaresma 2db4488337 fix(site): fix filters errors display (#8103) 2023-06-20 12:08:05 -03:00
Mathias Fredriksson ea4b7d60d7 fix(agent): refactor trackScriptLogs to avoid deadlock (#8084)
During agent close it was possible for the startup script logs consumer
to enter a deadlock state where by agent close was waiting via
`a.trackConnGoroutine` and the log reader for a flush event.

This refactor removes the mutex in favor of channel communication and
relies on two goroutines without shared state.
2023-06-20 18:05:11 +03:00
Colin Adler adf14f1917 chore(cli): warn on template push or create when no lockfile present (#8059) 2023-06-20 15:02:44 +00:00
Bruno Quaresma a47a9b1cfe fix(site): prevent filter input update when focused (#8102) 2023-06-20 13:46:04 +00:00
Mathias Fredriksson b8ba287128 fix: disable websocket compression for startup logs in Safari (#8087) 2023-06-20 16:29:32 +03:00
Bruno Quaresma c3781d95b4 fix(site): fix build logs route (#8100) 2023-06-20 13:24:48 +00:00
Cian Johnston eb0783ff24 chore(cli): do not assert non-zero host cpu usage (#8097) 2023-06-20 13:03:56 +00:00
Cian Johnston 0f754f0bb9 fix(clistat): do not include buffers/cache for host memory used (#8095) 2023-06-20 13:29:27 +01:00
Marcin Tojek 06a5e24f5b skip: TestStatCPUCmd/JSON (#8093) 2023-06-20 12:08:11 +00:00
Mathias Fredriksson 8dac0356ed refactor: replace startup script logs EOF with starting/ready time (#8082)
This commit reverts some of the changes in #8029 and implements an
alternative method of keeping track of when the startup script has ended
and there will be no more logs.

This is achieved by adding new agent fields for tracking when the agent
enters the "starting" and "ready"/"start_error" lifecycle states. The
timestamps simplify logic since we don't need understand if the current
state is before or after the state we're interested in. They can also be
used to show data like how long the startup script took to execute. This
also allowed us to remove the EOF field from the logs as the
implementation was problematic when we returned the EOF log entry in the
response since requesting _after_ that ID would give no logs and the API
would thus lose track of EOF.
2023-06-20 14:41:55 +03:00
Marcin Tojek b1d1b63113 chore: ensure logs consistency across Coder (#8083) 2023-06-20 12:30:45 +02:00
Cian Johnston d6f8bd7847 feat(cli): add coder stat command (#8005) 2023-06-20 11:16:57 +02:00
Jon Ayers c3aef9363b feat: add locked TTL field to template meta (#8020) 2023-06-19 22:37:55 -04:00
dependabot[bot] 1ecc371ade chore: bump google.golang.org/grpc from 1.55.0 to 1.56.0 (#8079)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.55.0 to 1.56.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.55.0...v1.56.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-19 20:48:05 -05:00
Mathias Fredriksson af45e64b1d chore(coderd/database/gen): improve generated fake stub (#8088)
* chore(coderd/database/gen): generate arg validation where applicable
* fix(coderd/database/gen): support pointers and slices as return types
2023-06-20 00:05:26 +03:00
Kyle Carberry f444100aa6 feat: add region querying to pre-fetched html (#8077) 2023-06-19 11:23:26 -05:00
dependabot[bot] e083cbca6a chore: bump golang.org/x/mod from 0.10.0 to 0.11.0 (#8078)
Bumps [golang.org/x/mod](https://github.com/golang/mod) from 0.10.0 to 0.11.0.
- [Commits](https://github.com/golang/mod/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: golang.org/x/mod
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-19 10:00:37 -05:00
dependabot[bot] 020c6fb71e chore: bump google.golang.org/api from 0.127.0 to 0.128.0 (#8080)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.127.0 to 0.128.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.127.0...v0.128.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-19 10:00:21 -05:00
dependabot[bot] 456ad85ce3 chore: bump golang.org/x/crypto from 0.9.0 to 0.10.0 (#8081)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.9.0 to 0.10.0.
- [Commits](https://github.com/golang/crypto/compare/v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-19 10:00:13 -05:00
Kyle Carberry 5b9c3784bc docs: add steps for registering a github app with coder (#7976)
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-06-18 14:01:37 -05:00
Kyle Carberry 9df9ad4503 feat: embed common client requests into the template html (#8076)
This should reduce the number of API requests a client makes
when loading the dashboard dramatically!
2023-06-18 13:57:27 -05:00
Kyle Carberry 2a10c9127f fix: show git provider id instead of type (#8075)
Fixes #6343.
2023-06-18 17:01:44 +00:00
Ammar Bandukwala ca6b9e9368 chore: use robust RNG in cryptorand (#8040) 2023-06-17 17:33:40 -05:00
Montasser abd majid ZEHRI c8e67833f5 docs: add oidc keycloak docs (#8042)
* adding docs for keycloak to solve the problem with the refraish token

* fmt
2023-06-16 10:18:26 -05:00
Mathias Fredriksson 0c5077464b fix: avoid missed logs when streaming startup logs (#8029)
* feat(coderd,agent): send startup log eof at the end

* fix(coderd): fix edge case in startup log pubsub

* fix(coderd): ensure startup logs are closed on lifecycle state change (fallback)

* fix(codersdk): fix startup log channel shared memory bug

* fix(site): remove the EOF log line
2023-06-16 17:14:22 +03:00
Marcin Tojek 247f8a973f feat: replace ssh maxTimeout with keep-alive mechanism (#8062)
* Bump up coder/ssh

* feat: Set default agent timeout to ~72h

* Address PR comments

* Fix
2023-06-16 15:22:18 +02:00
Cian Johnston 751c0505bf chore: add benchmark for prometheusmetrics.MetricsAggregator (#8066)
* add benchmark for prom metrics aggregator

* fixup! add benchmark for prom metrics aggregator

* make fmt
2023-06-16 14:04:28 +01:00
Colin Adler 3ec2e96ff4 chore: tidy up grafana example dashboard (#8056) 2023-06-15 14:22:31 -05:00
dependabot[bot] 137b51e2c7 chore: bump cronstrue from 2.21.0 to 2.27.0 in /site (#7851)
Bumps [cronstrue](https://github.com/bradymholt/cronstrue) from 2.21.0 to 2.27.0.
- [Release notes](https://github.com/bradymholt/cronstrue/releases)
- [Changelog](https://github.com/bradymholt/cRonstrue/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bradymholt/cronstrue/compare/v2.21.0...v2.27.0)

---
updated-dependencies:
- dependency-name: cronstrue
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-06-15 14:34:00 -03:00
Bruno Quaresma e4d23ff5fe fix(site): add test and fix username params in terminal (#8052) 2023-06-15 13:18:19 -03:00
Bruno Quaresma f61001d049 chore(docs): optimize images (#8047) 2023-06-15 10:49:47 -03:00
dependabot[bot] 33c0674d76 chore: bump react-router-dom from 6.4.1 to 6.12.1 in /site (#7950)
* chore: bump react-router-dom from 6.4.1 to 6.12.1 in /site

Bumps [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) from 6.4.1 to 6.12.1.
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router-dom@6.12.1/packages/react-router-dom)

---
updated-dependencies:
- dependency-name: react-router-dom
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix what needs to be fixed

* fix storybook

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
2023-06-15 10:34:49 -03:00
Cian Johnston 6e598234b6 fix: only collect prometheus database metrics when explicitly enabled (#8045)
* fix: only collect prometheus database metrics when explicitly enabled

* add missing test

* de-duplicate wrapping
2023-06-15 12:34:16 +01:00
Mathias Fredriksson 3f81f38fcc ci: fix commit type prefix regexp in release script (#8046)
Previously we were incorrectly categorizing `fix(a/b): ...` as other
because the regexp only expected letters, not `/`. Now we accept any
input within the parenthesis.

---------

Co-authored-by: Cian Johnston <cian@coder.com>
2023-06-15 10:57:18 +00:00
Cian Johnston b1588fa596 fix(helm): use /healthz for liveness and readiness probes instead of /api/v2/buildinfo (#8035) 2023-06-15 10:08:48 +01:00
Eric Paulsen 977e9ef505 docs: add steps for configuring trusted headers & origins in Helm chart (#8031) 2023-06-14 16:20:40 -04:00
Kyle Carberry 8ac68c95a4 chore: lazily initialize find commands in makefile (#8030)
Improves make performance for small targets!
2023-06-14 13:17:16 -05:00
Bruno Quaresma af06e80949 fix(site): fix footer year (#8036) 2023-06-14 14:59:33 -03:00
Steven Masley 6c4c3d6ce5 feat: add login type 'none' to prevent password login (#8009)
* feat: add login type 'none' to prevent login

Users with this login type must use tokens to authenticate.
Tokens must come from some other source, not a /login with password
authentication
2023-06-14 12:48:43 -05:00
Bruno Quaresma cbd49abfcd fix(site): resize terminal when dismissing warning (#8028) 2023-06-14 14:40:55 -03:00
Steven Masley 3619a3a6dd feat: add disabling of default 'everyone' group access to template (#7982)
* feat: add disabling of default 'everyone' group access to template
* add FE to disable everyone group
* require entitlement to uncheck box
2023-06-14 11:08:58 -05:00
Kyle Carberry e4b6f5695b chore: separate pubsub into a new package (#8017)
* chore: rename store to dbmock for consistency

* chore: remove redundant dbtype package

This wasn't necessary and forked how we do DB types.

* chore: separate pubsub into a new package

This didn't need to be in database and was bloating it.
2023-06-14 15:34:54 +00:00
Dean Sheather 2c843f4011 fix: fix --header flag in CLI (#8023) 2023-06-14 21:52:01 +10:00
Cian Johnston df842b31e8 chore: fix miscellaneous issues in scaletest scripts (#8006)
* chore: scaletest: plumb through more options

* bump terraform version

* scaletest.sh: pprof during traffic gen

* cli/scaletest: actually wait for prometheus metrics to be scraped

* increase prometheus wait
2023-06-14 09:38:04 +01:00
Rodrigo Maia 1da2570e14 feat(site): add documentation links to webterminal notifications (#8019)
* feat(site): add documentation links to webterminal notifications

* change button variant
2023-06-14 00:27:40 +00:00
dependabot[bot] 7a7ee63225 chore: bump github.com/hashicorp/terraform-json from 0.16.0 to 0.17.0 (#7972)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-13 22:19:01 +00:00
dependabot[bot] af50ef76f9 chore: bump google.golang.org/api from 0.125.0 to 0.127.0 (#8018)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-14 01:15:08 +03:00
dependabot[bot] 299260361a chore: bump github.com/gohugoio/hugo from 0.111.3 to 0.113.0 (#7969)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-13 16:50:45 -05:00
Kyle Carberry 8c4b7c01e2 chore: remove redundant dbtype package (#8014)
* chore: rename store to dbmock for consistency

* chore: remove redundant dbtype package

This wasn't necessary and forked how we do DB types.
2023-06-13 19:14:55 +00:00
Mathias Fredriksson 4f512fb230 chore: use gcr.io for postgres image in OpenContainerized (#8015)
Refs #7935
2023-06-13 22:03:33 +03:00
Kyle Carberry 7d54fd5e0d chore: rename store to dbmock for consistency (#8013) 2023-06-13 13:57:43 -05:00
Kyle Carberry a658c94a67 chore: automatically generate dbauthz when new queries are added (#8007)
* chore: automatically generate dbauthz when new queries are added

* Merge system functions
2023-06-13 13:40:46 -05:00
Mathias Fredriksson c12c9f1f4e chore(go.mod): update cdr.dev/slog (#7994)
* chore(mod): update cdr.dev/slog

* fix: change uses of []slog.Field to []any to match new API
2023-06-13 18:17:04 +00:00
Mathias Fredriksson 74fdcb1ace fix(agent/agentssh): wait for sessions to exit (#8008) 2023-06-13 17:52:31 +00:00
Kyle Carberry 794a551176 chore: generate dbmetrics automatically when adding new queries (#7999)
* chore: rename dbgen package files and remove small file

* chore: automatically generate dbmetrics when new queries are added
2023-06-13 12:35:12 -05:00
Colin Adler f2758fcb33 feat: add example grafana dashboard (#7987)
* feat: add example grafana dashboard

* fixup! feat: add example grafana dashboard

* fixup! feat: add example grafana dashboard

* fixup! feat: add example grafana dashboard
2023-06-13 12:26:42 -05:00
Mathias Fredriksson 51226c55ab test(coderd): close metricscache and avoid background context (#7996) 2023-06-13 20:18:31 +03:00
Kyle Carberry 2e7e99b135 fix: scope errors to subtests for flake (#8004)
See: https://github.com/coder/coder/actions/runs/5257676837/jobs/9500882394
2023-06-13 11:52:17 -05:00
Kyle Carberry 24953869a6 chore: remove key comparison check to fix gitsshkey flake (#8002)
In tests we use weak randomness and the same key was generated which
caused a test flake here.
2023-06-13 15:51:45 +00:00
Kyle Carberry 75078fafa2 chore: try removing cache from fmt and lint (#8001) 2023-06-13 10:48:53 -05:00
Steven Masley 9cf3c582cb test: add unit test that deletes abandoned workspace (#7990)
* test: add unit test that deletes abandoned workspace

This is to ensure we do not break this functionality in future.
This is important incase this edge case happens, an admin can
clean up the abandoned resources.
2023-06-13 10:42:18 -05:00
Mathias Fredriksson c916a9e67f fix(agent): guard against multiple rpty race for same id (#7998)
* fix(agent): guard against multiple rpty race for same id
* fix(agent): ensure pty is closed on error
2023-06-13 15:14:07 +00:00
Kyle Carberry 9440b3da66 chore: rename dbgen package files and remove small file (#7997) 2023-06-13 09:21:12 -05:00
Mathias Fredriksson 1d0fae83a2 fix(coderd): prevent lost messages in watchWorkspaceAgentMetadata (#7934)
* fix(codersdk): wait for subscription in WatchWorkspaceAgentMetadata
* fix(coderd): subscribe before sending initial metadata event
* test(coderd): add retries to TestWorkspaceAgent_Metadata to avoid flake
2023-06-13 12:21:06 +00:00
Mathias Fredriksson 518300a26c fix(coderd/database): improve pubsub closure and context cancellation (#7993) 2023-06-13 15:19:56 +03:00
Ben Potter aba5cb8377 fix(docs): capture and export audit logs (#7991)
* hotfix(docs): Capturing/exporting audit logs

We frequntly get questions about this!

* fmt
2023-06-12 23:06:58 -05:00
Jon Ayers 31bd2b0bdc chore: update legacy parameters in envbox template (#7898) 2023-06-12 20:53:12 -05:00
Colin Adler ac605bad3d ci: scan images with prisma (#7988) 2023-06-12 23:11:45 +00:00
Kyle Carberry 28f35393e7 chore: generate and order dbfake funcs automatically (#7986)
* chore: rename `databasefake` to `dbfake`

* Remove unused method

* chore: add generation to dbfake

* Auto gen on make gen

* Fix preserving imports

* gen dbfake

* Add goimports

* Fix the makefile

* Make it panic instead of a comment
2023-06-12 17:40:58 -05:00
Kyle Carberry 685abfc6d7 chore: rename databasefake to dbfake (#7979)
* chore: rename `databasefake` to `dbfake`

* Remove unused method
2023-06-12 16:05:37 -05:00
Asher 4a0ac13bb7 docs: document CORS behavior between forwarded apps (#7944)
* docs: document CORS behavior

* docs: move CORS documentation under dashboard section

None of this applies to ports forwarded in other ways.
2023-06-12 20:59:47 +00:00
Kyle Carberry 6ac7d86c93 chore: prevent gen from rerunning every time (#7985) 2023-06-12 14:45:17 -05:00
Steven Masley b70d2b1767 fix: correct the correct cli output for 'template version list --output=json' (#7984)
* fix: correct 'template version list --output=json' cli cmd
2023-06-12 14:35:51 -05:00
Kira Pilot f13632cea8 feat: add impending deletion filter to workspaces page (#7860)
* add workspace deletion dialog

* add deleting_by query param

* added test

* filtering on workspaces to be deleted

* cleaned up form

* added story

* added banner filter

* PR feedback

* fix lint and stories

* PR feedback

* added enterprise test

* added unit tests in search_test.go

* remove unused fn

* unstaged changes
2023-06-12 11:55:51 -07:00
Mathias Fredriksson 4068f70d2b fix(coderd): avoid deadlock in (*logFollower).follow (#7983) 2023-06-12 18:38:46 +00:00
Ammar Bandukwala aa9dbf2eb3 ci: reduce Windows parallelism (#7981)
We have seen an uptick in Windows failures.
2023-06-12 18:24:54 +00:00
dependabot[bot] 0d71314ae1 chore: Bump aquasecurity/trivy-action from 0.10.0 to 0.11.2 (#7967)
Bumps [aquasecurity/trivy-action](https://github.com/aquasecurity/trivy-action) from 0.10.0 to 0.11.2.
- [Release notes](https://github.com/aquasecurity/trivy-action/releases)
- [Commits](https://github.com/aquasecurity/trivy-action/compare/e5f43133f6e8736992c9f3c1b3296e24b37e17f2...41f05d9ecffa2ed3f1580af306000f734b733e54)

---
updated-dependencies:
- dependency-name: aquasecurity/trivy-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-12 21:22:10 +03:00
Ammar Bandukwala a540e629e5 ci: improve caching (#7954) 2023-06-12 12:09:54 -05:00
Mathias Fredriksson 4bc4e63637 fix(cli/ssh): fix lint error (#7974) 2023-06-12 16:17:41 +00:00
Muhammad Atif Ali 68ebf93fdb ci: add fmt and lint to required tests (#7975) 2023-06-12 10:43:45 -05:00
Ammar Bandukwala 5de1084639 feat(cli/ssh): simplify log file flags (#7863)
And, fix a race condition.
2023-06-12 09:18:33 +04:00
Dean Sheather ec7b117878 chore: add gen and test-go-race to required check (#7952) 2023-06-10 04:07:17 +00:00
dependabot[bot] 1ec463d74d chore: bump i18next from 21.9.1 to 22.5.0 in /site (#7812)
* chore: Bump i18next from 21.9.1 to 22.5.0 in /site

Bumps [i18next](https://github.com/i18next/i18next) from 21.9.1 to 22.5.0.
- [Release notes](https://github.com/i18next/i18next/releases)
- [Changelog](https://github.com/i18next/i18next/blob/master/CHANGELOG.md)
- [Commits](https://github.com/i18next/i18next/compare/v21.9.1...v22.5.0)

---
updated-dependencies:
- dependency-name: i18next
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix i18n types

* prettier

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rodrigo Maia <rodrigo.maia.pereira@gmail.com>
2023-06-09 18:54:17 -05:00
Dean Sheather 634e146032 ci: skip ts or go tests based on changed files (#7134)
* chore: skip ts or go tests based on files changed

* comments

* chore: add 'required' job

* fixup! chore: add 'required' job

* fake go modification

* merge main into dean/skip-tests-fe-be

* fix typo

* remove x_test.go

* remove duplicate setup-node action

* condition test-go-race too

* skip ete on docs changes

* allows tests to run if changes are made .github directory

---------

Co-authored-by: Atif Ali <atif@coder.com>
2023-06-10 02:53:16 +03:00
Ammar Bandukwala 71c908974c ci: improve caching (#7943) 2023-06-09 16:46:44 -05:00
Cian Johnston 2bbe650eb0 chore: scaletest: collect database metrics using prometheus-postgres-exporter (#7945)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-06-09 21:21:08 +00:00
Muhammad Atif Ali 175561bf36 docs: update CONTRIBUTING.md (#7937) 2023-06-09 19:38:16 +03:00
Steven Masley 065206345e test: add golden files to enterprise cli (#7924)
* test: Add golden files to enterprise cli
2023-06-09 11:35:20 -05:00
Dean Sheather 4f9d3155c9 ci: use macos-latest-xl runners (#7938) 2023-06-09 11:22:29 -05:00
Muhammad Atif Ali 16ebe10ff2 docs(admin/workspace-proxies): add instructions to run using the Docker image (#7915)
* docs(admin/workspace-proxies): add instructions to run using the Docker image.

* make fmt
2023-06-09 10:53:04 -05:00
Eric Paulsen 53969415ec docs: add multi git providers to enterprise chart (#7941)
* docs: add multi git providers to enterprise chart

* make: fmt
2023-06-09 14:52:51 +00:00
Dean Sheather c60ea38691 chore: use gcr.io for postgres image in CI (#7935) 2023-06-09 13:39:55 +00:00
Mathias Fredriksson e4744686ec fix(codersdk): handle API older than client for startup script behavior (#7933) 2023-06-09 13:01:56 +00:00
Colin Adler 30a635aa5f fix(enterprise): ensure scim usernames are validated (#7925) 2023-06-08 17:59:49 -05:00
Steven Masley a4cc883be1 chore: add proxy health interval flag/env config (#7919)
* chore: plumbing for proxy health interval from flag/env
2023-06-08 12:58:24 -05:00
Steven Masley fa8153a0fd chore: make default workspace proxy editable (#7903)
* chore: add editing the default workspace proxy
2023-06-08 10:30:15 -05:00
Steven Masley 5e647ba07a chore: improve workspace proxy create cli flow (#7907)
* chore: improve workspace proxy create cli flow
2023-06-08 10:02:35 -05:00
Muhammad Atif Ali 26f575e284 ci: prevent running nightly-gauntlet.yaml on PRs (#7920) 2023-06-08 14:57:39 +00:00
Mathias Fredriksson 976d23e3dc docs(templates): fix docs for updated --wait flag (#7918) 2023-06-08 14:31:22 +00:00
Mathias Fredriksson 03034dc508 chore(cli/configssh): add comment about wait and skip proxy (#7917) 2023-06-08 14:23:03 +00:00
Mathias Fredriksson fa91e11105 fix(cli/help): show deprecation notice properly for flags (#7904) 2023-06-08 14:14:42 +00:00
Mathias Fredriksson a1c32954d9 feat(cli/configssh): add support for wait yes/no/auto (#7893)
Refs #7768
2023-06-08 14:06:50 +00:00
Mathias Fredriksson 94aa9be33a feat(cli/ssh): implement wait options and deprecate no-wait (#7894)
Fixes #7768
Refs #7893
2023-06-08 16:52:44 +03:00
Steven Masley b2324325fa chore: add warning log if misconfigured groups oidc (#7874)
* chore: add warning log if misconfigured groups oidc

This is not perfect, but if we find a 'groups' claim and it is not
configured, put out a warning log to give some information
2023-06-08 08:51:59 -05:00
Montasser abd majid ZEHRI 479467473e docs: add RStudio community template without requiring a subdomain (#7909)
* adding a comunity template

* make fmt

* fixing typo in url

---------

Co-authored-by: Atif Ali <atif@coder.com>
2023-06-08 13:07:20 +00:00
Cian Johnston efbb55803b chore: add scaletest convenience script (#7819)
- Adds a convenience script `scaletest.sh` to automate process of running scale tests
- Enables pprof endpoint by default, and captures pprof traces before tearing down infra.
- Improves idempotency of coder_init.sh
- Removes the promtest.Float64 invocations in workspacetraffic runner, these metrics will be in prometheus.
- Increases default workspace traffic output to 40KB/s/workspace.
2023-06-08 09:30:02 +01:00
Ammar Bandukwala 9ec1fcf1a7 ci: move timing tests to nightly gauntlet (#7910)
Test_Runner_Timing was one of our flakiest tests before.
2023-06-08 04:03:03 +00:00
Ammar Bandukwala fcca639d38 test(agent/agentssh): close SSH servers in all tests (#7911)
Potentially solves the flake seen here:

https://github.com/coder/coder/actions/runs/5167029213/jobs/9307647816.
2023-06-07 23:43:38 +00:00
Ammar Bandukwala f6db95e71c test(coderd/database/migrations): increase fixture test timeout 2023-06-07 23:17:29 +00:00
Technofab 52ead3d933 feat(provisioner): add support for .tf.json templates (#7835)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2023-06-08 08:06:50 +10:00
Asher f0c5201617 feat: allow cross-origin requests between users' own apps (#7688) 2023-06-07 11:08:14 -08:00
Asher 125e9ef00e fix: validate that parameter names are unique (#7882) 2023-06-07 09:44:50 -08:00
Bruno Quaresma fbdbc8a6c5 fix(site): return correct useer when using me on filter menu (#7906) 2023-06-07 14:32:52 -03:00
Bruno Quaresma 5be2b77830 fix(site): format numbers in pagination text (#7900) 2023-06-07 15:25:03 +00:00
Bruno Quaresma df82f29945 fix(site): improve filter on smaller screens (#7899) 2023-06-07 15:01:49 +00:00
Bruno Quaresma 2a5025c84c feat(site): add view activity on user context menu (#7897) 2023-06-07 11:58:40 -03:00
Mathias Fredriksson eb11b50bd1 docs(templates): improve workspace incomplete and session docs (#7896) 2023-06-07 17:34:49 +03:00
Bruno Quaresma d793564937 feat(site): add new filter to audit logs (#7878) 2023-06-07 14:10:58 +00:00
Mathias Fredriksson ab3a649520 docs(templates): improve startup_script_behavior docs (#7892)
Refs #7857
2023-06-07 13:39:44 +00:00
Steven Masley 1376ba3724 chore: use a cache to select best latency (#7879)
* chore: Testing using a cache to choose the best latency
* Allow storing more latencies if needed

This PR enables a feature to record and save latencies to local storage for later analysis
2023-06-07 08:29:18 -05:00
Kira Pilot 74ffd2756a fix: respect uppercase letters in username filter for audit (#7880)
* fix: respect uppercase letters in username filter for audit

* updated documentation
2023-06-07 05:48:08 -07:00
Bruno Quaresma 91dd3fbfab feat(site): add presets back to the filters (#7876) 2023-06-07 09:46:16 -03:00
Mathias Fredriksson a77b48a5e3 docs(templates): document startup_script_behavior in-depth (#7857)
Fixes #7759

---------

Co-authored-by: Cian Johnston <cian@coder.com>
2023-06-07 12:29:19 +03:00
Cian Johnston 4f29f9abe3 fixup! fix(cli): speed up CLI over SSH (#7885) (#7888) 2023-06-07 09:13:22 +00:00
Muhammad Atif Ali 8c4b6b02e7 ci: rename cron-weekly.yaml to weekly-docs.yaml (#7886)
Renames `cron-weekly.yaml` to `weekly-docs.yaml`
2023-06-07 07:56:19 +00:00
Ammar Bandukwala 5eaf809851 fix(cli): speed up CLI over SSH (#7885)
By caching the terminal's color profile, we avoid myriad round trips during command execution.
2023-06-07 05:22:58 +00:00
Colin Adler 1288a83e42 chore: upgrade openssl (#7883) 2023-06-06 16:59:56 -05:00
goodspark 0665a6c2f2 feat: add metric for provisioner daemons (#7858) 2023-06-06 16:50:11 -05:00
Muhammad Atif Ali 4954052ff6 ci: use builder runners to build dogfood image (#7881) 2023-06-06 16:11:25 -05:00
Colin Adler 003120882f chore: update Go to 1.20.5 (#7877) 2023-06-06 14:05:09 -05:00
Steven Masley 72f59950f2 chore: add prometheus timing to latency endpoint (#7742)
* chore: Prometheus timing to latency endpoint
2023-06-06 10:26:13 -05:00
Bruno Quaresma 944c42dcb6 docs: add docs for the available query filter for workspaces and users (#7875)
* Add docs for user filtering

* Add filter for workspace

* Apply suggestions from code review

Co-authored-by: Muhammad Atif Ali <atif@coder.com>

---------

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-06-06 15:12:10 +00:00
Bruno Quaresma 3121ccc7ff fix(site): Update the template form when a value is changed (#7873) 2023-06-06 11:25:25 -03:00
Bruno Quaresma 6d3dc30207 refactor(site): Remove terminal padding and add border to bottom bar (#7871) 2023-06-06 11:08:07 -03:00
Bruno Quaresma baa9922a82 feat(site): add new filter to the users page (#7818) 2023-06-06 09:59:15 -03:00
Marcin Tojek ee45b3df77 fix: ignore case while sorting usernames (#7870) 2023-06-06 12:37:41 +02:00
Mathias Fredriksson 660bbb8d38 refactor: deprecate login_before_ready in favor of startup_script_behavior (#7837)
Fixes #7758
2023-06-06 11:58:07 +03:00
Marcin Tojek 93378daeb3 feat: sort users by username (#7838) 2023-06-06 08:47:59 +02:00
Muhammad Atif Ali 2ad1308450 ci: run dogfood.yaml action when the action is updated (#7866) 2023-06-06 06:34:20 +00:00
Muhammad Atif Ali 2be7ef88e8 ci: use coder binary from the server (#7865) 2023-06-06 09:13:25 +03:00
dependabot[bot] 7332acc935 chore: bump vite from 4.3.0 to 4.3.9 in /site (#7864)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.3.0 to 4.3.9.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v4.3.9/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 21:57:53 -05:00
sharkymark 8e655b42b1 chore(docs): Added macOS self-signed cert add step and moved plugin docs to top (#7859) 2023-06-05 19:59:01 -04:00
Steven Masley fa8f50a169 fix: fix workspace status filter returning more statuses that requested (#7732) 2023-06-05 18:12:10 -05:00
Bruno Quaresma b9e3226612 refactor(site): give default error message when description is missing (#7846) 2023-06-05 17:43:24 -03:00
Bruno Quaresma 7ec16cf779 feat(site): add latency to the terminal (#7801) 2023-06-05 18:32:49 +00:00
dependabot[bot] 0413ed0178 chore: update xterm, xterm-addon-fit, and xterm-addon-web-links in /site (#7765)
* chore: bump xterm, xterm-addon-fit and xterm-addon-web-links in /site

Bumps [xterm](https://github.com/xtermjs/xterm.js), [xterm-addon-fit](https://github.com/xtermjs/xterm.js) and [xterm-addon-web-links](https://github.com/xtermjs/xterm.js). These dependencies needed to be updated together.

Updates `xterm` from 4.19.0 to 5.1.0
- [Release notes](https://github.com/xtermjs/xterm.js/releases)
- [Commits](https://github.com/xtermjs/xterm.js/compare/4.19.0...5.1.0)

Updates `xterm-addon-fit` from 0.5.0 to 0.7.0
- [Release notes](https://github.com/xtermjs/xterm.js/releases)
- [Commits](https://github.com/xtermjs/xterm.js/compare/0.5...0.7)

Updates `xterm-addon-web-links` from 0.6.0 to 0.8.0
- [Release notes](https://github.com/xtermjs/xterm.js/releases)
- [Commits](https://github.com/xtermjs/xterm.js/compare/0.6...0.8)

---
updated-dependencies:
- dependency-name: xterm
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: xterm-addon-fit
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: xterm-addon-web-links
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Remove rendererType

This option no longer exists.  Renderers other than the DOM renderer
have been split into addons.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Asher <ash@coder.com>
2023-06-05 13:53:27 -03:00
dependabot[bot] a2e129083e chore: bump github.com/hashicorp/hcl/v2 from 2.14.0 to 2.17.0 (#7853)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 11:30:20 -05:00
dependabot[bot] 3a7c92a56f chore: bump go.uber.org/atomic from 1.10.0 to 1.11.0 (#7854)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 11:27:57 -05:00
dependabot[bot] b79bfb2874 chore: bump alpine from 3.16 to 3.18 in /dogfood (#7847)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 11:26:58 -05:00
Colin Adler 1ab2450250 fix(provisioner/terraform): ensure ordering rich parameters produces no nil values (#7824) 2023-06-05 11:26:04 -05:00
dependabot[bot] 5a3d6b589a chore: bump eslint-plugin-jsx-a11y from 6.6.1 to 6.7.1 in /site (#7850)
Bumps [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y) from 6.6.1 to 6.7.1.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/compare/v6.6.1...v6.7.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-jsx-a11y
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 08:33:38 -07:00
Muhammad Atif Ali 466c530525 ci: add dogfood to dependabot (#7844) 2023-06-05 18:12:15 +03:00
dependabot[bot] 3fa7ee969d chore: bump github.com/elastic/go-sysinfo from 1.9.0 to 1.11.0 (#7841)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 09:56:41 -05:00
dependabot[bot] 82c709b1ba chore: bump google.golang.org/api from 0.122.0 to 0.125.0 (#7843)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 09:54:44 -05:00
dependabot[bot] cb42396596 chore: bump github.com/ory/dockertest/v3 from 3.9.1 to 3.10.0 (#7840)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 09:52:26 -05:00
sharkymark 88dc66ae47 chore(docs): Add clarifying language that resetting a user password must run on the coderd host (#7845) 2023-06-05 13:37:12 +00:00
Bruno Quaresma 6fde86d1ac fix(site): remove tar file type limitation (#7817) 2023-06-05 10:34:36 -03:00
dependabot[bot] cdba0744a2 chore: Bump jest-runner-eslint from 2.0.0 to 2.1.0 in /site (#7810)
Bumps [jest-runner-eslint](https://github.com/jest-community/jest-runner-eslint) from 2.0.0 to 2.1.0.
- [Release notes](https://github.com/jest-community/jest-runner-eslint/releases)
- [Changelog](https://github.com/jest-community/jest-runner-eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/jest-runner-eslint/compare/v2.0.0...v2.1.0)

---
updated-dependencies:
- dependency-name: jest-runner-eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-05 06:08:25 -07:00
Steven Masley bbecff28ae feat: return better error if file size is too big to upload (#7775)
* feat: return better error if file size is too big to upload
* Use a limit writer to capture actual tar size
2023-06-05 11:19:25 +00:00
Spike Curtis e016c307ae Fix postgres ephemeral ports; don't use for TestPubsub_Disconnect (#7798)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-05 09:24:44 +04:00
dependabot[bot] f14f011abf chore: Bump github.com/hashicorp/yamux (#7808) 2023-06-04 07:30:36 +03:00
dependabot[bot] 53e5625292 chore: Bump @typescript-eslint/parser from 5.45.1 to 5.59.8 in /site (#7807) 2023-06-04 07:29:30 +03:00
dependabot[bot] 4d5f723740 chore: Bump golangci/golangci-lint-action from 3.3.1 to 3.5.0 (#7805)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.3.1 to 3.5.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.3.1...v3.5.0)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-04 03:37:18 +00:00
dependabot[bot] 2bf3cae3cb chore: Bump crate-ci/typos from 1.14.11 to 1.14.12 (#7804)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.14.11 to 1.14.12.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.14.11...v1.14.12)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-04 03:31:41 +00:00
dependabot[bot] e10644f86a chore: Bump monaco-editor from 0.37.1 to 0.38.0 in /site (#7814)
Bumps [monaco-editor](https://github.com/microsoft/monaco-editor) from 0.37.1 to 0.38.0.
- [Changelog](https://github.com/microsoft/monaco-editor/blob/main/CHANGELOG.md)
- [Commits](https://github.com/microsoft/monaco-editor/compare/v0.37.1...v0.38.0)

---
updated-dependencies:
- dependency-name: monaco-editor
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-03 22:40:59 +00:00
goodspark e2613c91a7 feat(cli): support non-active template version pushes (#7488)
So that we can push template updates for testing without impacting
normal users of the template.

---------

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>
Co-authored-by: Muhammad Atif Ali <matifali@live.com>
Co-authored-by: Atif Ali <atif@coder.com>
2023-06-03 22:39:00 +00:00
Muhammad Atif Ali 1f8e817da7 ci: delete CODEOWNERS (#7830) 2023-06-03 17:08:55 -05:00
Ammar Bandukwala 38d0f6fb74 perf(provisioner/terraform): upgrade hc-install (#7832)
By upgrading hc-install, we benefit from increased performance
in checksum verification introduced here:

- https://github.com/hashicorp/hc-install/commit/858962c71d47df1ea505b9031bccd5fdf7c8e07f

Also:

- Made minor improvements to tests
- Excluded TestInstall from the race detector
2023-06-03 22:03:41 +00:00
Ammar Bandukwala b62e22766f ci: skip DataDog upload for dependabot (#7831) 2023-06-03 20:47:09 +00:00
Marcin Tojek b26dd4b802 docs: remove unsupported legacy parameters (#7799)
* docs: unsupported legacy parameters

* Update docs/templates/parameters.md

Co-authored-by: Muhammad Atif Ali <atif@coder.com>

---------

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-06-03 06:05:06 +02:00
Colin Adler 14a63d7b4a revert(provisionersdk): remove support for .tf.json files (#7829) 2023-06-02 23:13:41 +00:00
Colin Adler c6cd042e80 fix(clitest): use slogtest for logging stdin and stdout (#7828) 2023-06-02 22:38:31 +00:00
Ammar Bandukwala a4424205c7 ci: truly fix repo name detection 2023-06-02 22:03:21 +00:00
Muhammad Atif Ali 887bbea72a hotfix(docs): fix broken link reported by ci (#7825)
Resolves
https://github.com/coder/coder/actions/runs/5159895963/jobs/9295371489#step:4:188
2023-06-03 00:53:06 +03:00
Ammar Bandukwala f37e007b8e ci: fix repo name detection 2023-06-02 21:40:18 +00:00
dependabot[bot] ea03c7276b chore: Bump github.com/golang-migrate/migrate/v4 from 4.15.2 to 4.16.0 (#7811)
Bumps [github.com/golang-migrate/migrate/v4](https://github.com/golang-migrate/migrate) from 4.15.2 to 4.16.0.
- [Release notes](https://github.com/golang-migrate/migrate/releases)
- [Changelog](https://github.com/golang-migrate/migrate/blob/master/.goreleaser.yml)
- [Commits](https://github.com/golang-migrate/migrate/compare/v4.15.2...v4.16.0)

---
updated-dependencies:
- dependency-name: github.com/golang-migrate/migrate/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-03 00:12:20 +03:00
Eric Paulsen 6715cb6a95 docs: resolve README 404s (#7822) 2023-06-02 20:56:06 +00:00
Colin Adler edccd2de73 fix(agent): configure logger for both reaper and agent (#7823) 2023-06-02 15:51:10 -05:00
Ammar Bandukwala 97fb5020cf hotfix(ci): correctly detect repo name (#7820) 2023-06-02 20:18:09 +00:00
Eric Paulsen d082ab59b4 docs: add note on log truncation (#7821) 2023-06-02 19:36:43 +00:00
Ammar Bandukwala 2631a8436c hotfix: disable nightly-flake on all pushes 2023-06-02 18:11:04 +00:00
Ammar Bandukwala 6d8caf6f14 ci: add nightly flake workflow (#7803) 2023-06-02 12:48:51 -05:00
Ammar Bandukwala 902265bdd7 hotfix(ci): skip DataDog upload on forks (#7802)
* hotfix(ci): skip DataDog upload on forks

* fixup! hotfix(ci): skip DataDog upload on forks
2023-06-02 17:47:14 +00:00
Colin Adler 6fdebd8a07 hotfix(agent): only retain 1 logfile at a time (#7815) 2023-06-02 12:28:38 -05:00
Colin Adler 8f736fe5f5 fix(prometheusmetrics): ensure periodic metrics tick on startup (#7585) 2023-06-02 11:56:37 -05:00
Muhammad Atif Ali 9f810b1964 chore(dependabot): assign frontend team to review dependabot PRs automatically (#7800)
* chore(dependabot): assign frontend tam to review dependabot PRs automatically

* fix team name
2023-06-02 16:34:40 +00:00
Spike Curtis 078926f612 fix: select on context to avoid leak in logFollower (#7792)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-02 11:25:46 -05:00
dependabot[bot] 004ad1755f chore: bump formik from 2.2.9 to 2.4.1 in /site (#7763)
* chore: bump formik from 2.2.9 to 2.4.1 in /site

Bumps [formik](https://github.com/formium/formik) from 2.2.9 to 2.4.1.
- [Release notes](https://github.com/formium/formik/releases)
- [Commits](https://github.com/formium/formik/compare/formik@2.2.9...formik@2.4.1)

---
updated-dependencies:
- dependency-name: formik
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix ESLINT

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
2023-06-02 09:58:59 -03:00
Marcin Tojek 10036ab5fb fix: use minDisabled, maxDisabled for parameter validation (#7755) 2023-06-02 11:43:48 +02:00
Marcin Tojek a7366a8b76 feat!: drop support for legacy parameters (#7663) 2023-06-02 11:16:46 +02:00
Colin Adler 2b63492649 feat(healthcheck): add failing sections to report (#7789) 2023-06-01 19:21:24 -05:00
Colin Adler 9b8e5c2d8a feat(provisionersdk): add support for .tf.json templates (#7744) 2023-06-02 00:03:59 +00:00
Bruno Quaresma 9dbbe82cf8 fix(site): proxy menu not showing latency (#7785) 2023-06-01 20:03:27 -03:00
Asher 9704945428 fix: standardize on CODER_PG_CONNECTION_URL (#7781)
Fixes #7513.
2023-06-01 15:02:29 -08:00
Ammar Bandukwala 613f90cf2b ci: send test statistics to DataDog (#7786) 2023-06-01 16:25:52 -05:00
dependabot[bot] 083449c438 chore: bump github.com/gin-gonic/gin from 1.9.0 to 1.9.1 (#7787)
Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.9.0 to 1.9.1.
- [Release notes](https://github.com/gin-gonic/gin/releases)
- [Changelog](https://github.com/gin-gonic/gin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gin-gonic/gin/compare/v1.9.0...v1.9.1)

---
updated-dependencies:
- dependency-name: github.com/gin-gonic/gin
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-01 16:25:09 -05:00
sharkymark 49ae49095c docs: make template git auth example in sync with git auth setup example (#7784) 2023-06-01 19:34:52 +00:00
Eric Paulsen 4acf36b84a docs: describe gateway and internal certs (#7747)
* docs: gateway & self-signed certs

* docs: update trust store locations

* toolbox paths

* fix: windows cacerts location

---------

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>
2023-06-01 14:49:30 -04:00
Bruno Quaresma 62b2560bd0 chore(site): add type check on lint (#7778) 2023-06-01 15:45:15 -03:00
Bruno Quaresma 1a615778e6 chore(site): add workspace filter experiments into all (#7779) 2023-06-01 15:45:04 -03:00
dependabot[bot] 0bed8b57bc chore: bump eslint from 8.35.0 to 8.41.0 in /site (#7761)
Bumps [eslint](https://github.com/eslint/eslint) from 8.35.0 to 8.41.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.35.0...v8.41.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-01 15:44:33 -03:00
dependabot[bot] 33f1e468cb chore: bump @fontsource/inter from 4.5.11 to 5.0.2 in /site (#7762)
Bumps [@fontsource/inter](https://github.com/fontsource/font-files/tree/HEAD/fonts/google/inter) from 4.5.11 to 5.0.2.
- [Changelog](https://github.com/fontsource/font-files/blob/main/fonts/google/inter/CHANGELOG.md)
- [Commits](https://github.com/fontsource/font-files/commits/HEAD/fonts/google/inter)

---
updated-dependencies:
- dependency-name: "@fontsource/inter"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-01 15:44:22 -03:00
dependabot[bot] 93f4a5008e chore: bump @types/jest from 29.4.0 to 29.5.2 in /site (#7764)
Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 29.4.0 to 29.5.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

---
updated-dependencies:
- dependency-name: "@types/jest"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-01 15:43:26 -03:00
Bruno Quaresma 0f439d5374 hotfix: initial options as empty array (#7782) 2023-06-01 18:25:54 +00:00
Ammar Bandukwala ba3e6cea51 hotfix: remove cryptorand.Bool (#7780)
It caused a CI flake and we we weren't using it anywhere.

`cryptorand.Float64() < 0.5` can be used in the future too.
2023-06-01 17:59:08 +00:00
Bruno Quaresma 332362cf4b chore(site): simplify the logic to load workspace initial data (#7772) 2023-06-01 14:20:17 -03:00
Bruno Quaresma 4de4e8ee21 feat(site): Show total of items in the workspaces table (#7774) 2023-06-01 13:21:16 -03:00
Bruno Quaresma 80b60e158d refactor(site): make vscode dropdown button thiner (#7773) 2023-06-01 16:17:56 +00:00
Bruno Quaresma e80e88e019 refactor(site): add default owner:me filter to workspaces (#7738) 2023-06-01 12:04:10 -03:00
Bruno Quaresma 1952c042e1 fix(site): Fix navbar alignment on small screens (#7739)
Co-authored-by: Ammar Bandukwala <ammar@ammar.io>
2023-06-01 13:49:20 +00:00
Steven Masley b32ed2d97e chore: add function to refetch latencies to ProxyContext (#7769)
* Allow refetching of proxy latencies
* Pass refetch funtion up the context stack
* Add to menu bar
2023-06-01 13:37:20 +00:00
Steven Masley cf8d2bc096 feat: use tz_offset when doing deployment dau query (#7736)
* Have FE query correct tz_offset data
2023-06-01 09:23:50 -04:00
Ammar Bandukwala 555ea64669 ci: deduplicate language setup (#7753)
* Deduplicate actions

* Split up go-race and go-pg
2023-06-01 08:20:49 +00:00
Muhammad Atif Ali 80269ba1b9 hotfix(.github): fix dependency in contrib.yaml (#7754)
`title` job was removed in #7743, so this job was falling.
2023-06-01 10:29:07 +03:00
Spike Curtis a46e8f2e49 fix: concurrent writes to executor stats (#7731)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-06-01 05:23:51 +00:00
Ammar Bandukwala 9810339fd6 ci: use Buildjet and faster Windows runners (#7751) 2023-06-01 00:06:37 -05:00
Ben Potter 36f4e0dc35 hotfix(docs): minor updates to workspace proxies (#7735) 2023-05-31 21:32:26 +00:00
Colin Adler f1d27ba42d hotfix(healthcheck): properly calculate healthy status (#7746) 2023-05-31 20:17:33 +00:00
Ammar Bandukwala 828f33ac7b hotfix(.github): remove legacy title validator (#7743)
* hotfix(.github): remove legacy title validator

`cdr-bot` centralizes the behavior and can enforce stricter
standards.

* Increase jest timeout
2023-05-31 19:39:41 +00:00
Muhammad Atif Ali b80756e4f5 feat(site): Add support for insiders channel to "VS Code Desktop" button (#7730) 2023-05-31 16:28:27 +00:00
Cian Johnston 784696dfa5 feat: add prometheus metrics to database.Store (#7713)
* Adds dbmetrics package and wraps database.Store with a Prometheus HistogramVec of timings.
* Adds Wrappers method to database.Store to avoid double-wrapping interfaces
* Fixes test flake in TestLicensesListFake
2023-05-31 14:55:57 +01:00
Bruno Quaresma 00a30775bc refactor(site): Improve and fix loading buttons (#7719) 2023-05-31 10:00:30 -03:00
Bruno Quaresma b34894977d fix(site): Confirm delete on press Enter in delete dialog (#7720) 2023-05-31 09:59:36 -03:00
Bruno Quaresma be2067bb0d fix(site): Make current user first in the list and fix search (#7722) 2023-05-31 09:59:25 -03:00
Muhammad Atif Ali ce6b698048 hotfix(ci): fix a syntax issue in contrib.yaml (#7727) 2023-05-31 07:21:25 +00:00
Spike Curtis 7c3dbbbe93 fix: stream provisioner logs (#7712)
* stream provisioner logs

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix imports

Signed-off-by: Spike Curtis <spike@coder.com>

* Better logging, naming, arg order

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-31 06:15:58 +00:00
Spike Curtis 583b777251 fix: wildcard dns docs (#7709)
* Fix wildcard dns docs

Signed-off-by: Spike Curtis <spike@coder.com>

* Clarify

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-31 10:10:30 +04:00
dependabot[bot] ec3ef167d2 chore: bump eslint-config-prettier from 8.5.0 to 8.8.0 in /site (#7556)
Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 8.5.0 to 8.8.0.
- [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-config-prettier/compare/v8.5.0...v8.8.0)

---
updated-dependencies:
- dependency-name: eslint-config-prettier
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-30 23:30:13 -05:00
dependabot[bot] ae82a5985d chore: bump xstate from 4.33.5 to 4.37.2 in /site (#7560)
Bumps [xstate](https://github.com/statelyai/xstate) from 4.33.5 to 4.37.2.
- [Release notes](https://github.com/statelyai/xstate/releases)
- [Commits](https://github.com/statelyai/xstate/compare/xstate@4.33.5...xstate@4.37.2)

---
updated-dependencies:
- dependency-name: xstate
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-30 23:29:23 -05:00
Ammar Bandukwala 43eee35ae8 chore(cli): correctly report telemetry even when transport replaced (#7670)
By introducing the "ExtraHeaders" map, we can apply headers even when
handlers replace the transport, as in the case of our scaletests.

Also, only send telemetry header when it's small.
2023-05-31 00:11:56 +00:00
Ammar Bandukwala 867996aa18 chore(.github): specify PR types 2023-05-30 23:57:45 +00:00
Colin Adler 43e0968dac feat: format healthcheck responses (#7723) 2023-05-30 16:59:39 -05:00
Steven Masley 73d795f426 chore: Revert to only using 1 timezone support for template DAUs (#7721)
* chore: Revert to only using 1 timezone support for template DAUs

Keeping the logic to support more in case we optimize later
2023-05-30 15:37:07 -04:00
Colin Adler 022372dd73 feat(healthcheck): add websocket report (#7689) 2023-05-30 14:22:32 -05:00
Bruno Quaresma 77b0ca0b53 refactor(site): Improve workspaces filtering (#7681) 2023-05-30 14:52:13 -03:00
Steven Masley c795a0e500 feat: Fix Deployment DAUs to work with local timezones (#7647)
* chore: Add timezone param to DAU SQL query
* Merge DAUs response
* Pass time offsets to metricscache
2023-05-30 13:18:27 -04:00
dependabot[bot] 68658b5197 chore: bump github.com/valyala/fasthttp from 1.44.0 to 1.47.0 (#7703)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2023-05-30 11:48:56 -05:00
dependabot[bot] 2aa48d4143 chore: bump crate-ci/typos from 1.14.10 to 1.14.11 (#7701)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-30 11:38:33 -05:00
dependabot[bot] 115f80737a chore: bump github.com/coder/retry (#7705)
Bumps [github.com/coder/retry](https://github.com/coder/retry) from 1.3.1-0.20230210155434-e90a2e1e091d to 1.4.0.
- [Commits](https://github.com/coder/retry/commits/v1.4.0)

---
updated-dependencies:
- dependency-name: github.com/coder/retry
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-30 11:09:12 -05:00
Bruno Quaresma c2d2751897 feat(site): Add proxy menu into navbar (#7715) 2023-05-30 11:41:23 -03:00
Ammar Bandukwala e8eb28adb4 chore(.github): remove stalebot messages 2023-05-30 14:10:39 +00:00
Marcin Tojek 702c9081e0 fix: do not skip parameter validation if min or max = 0 (#7707) 2023-05-30 14:57:06 +02:00
Marcin Tojek 4eb0baa849 chore: update protoc-gen-go (#7708) 2023-05-30 10:24:34 +02:00
Rodrigo Maia 61dc875454 feat(cli): show license_expires as rfc3339 date instead of unix time (#7687)
* feat(licenses): show license_expires time as rfc3339 date

* fix review comments
2023-05-26 14:36:26 +00:00
Mathias Fredriksson 66f5d39ff5 test(agent): Improve use of inv.Context() (#7696)
This will ensure tests timeout instead of hang indefinitely since
`inv.Context()` is assigned a timeout by default.
2023-05-26 13:48:39 +00:00
Mathias Fredriksson 05efd64320 test: Skip tests that send os.Interrupt to test pid (#7695)
This can cause test flakes due to clitest commands running in memory and
listening to interrupt signals.
2023-05-26 16:17:09 +03:00
Cian Johnston 795050bba3 chore: add prometheus monitoring of workspace traffic generation (#7583)
- Exposes reads/writes from scaletest traffic generation (default: 0.0.0.0:21112)
- Adds self-hosted prometheus with remote_write to loadtest terraform
- Adds convenience script to run a traffic generation test
2023-05-26 13:53:35 +01:00
Mathias Fredriksson 0fd2ea4044 test(coderd/rbac): Increase TestFilter timeout (#7694) 2023-05-26 15:44:05 +03:00
Muhammad Atif Ali e5add7292f chore: Only run deploy_template after deploy_image has been completed (#7693) 2023-05-26 12:20:14 +00:00
Bruno Quaresma 79ab72fbb1 fix(site): Fix retry on debug mode alert (#7686) 2023-05-25 17:22:57 -03:00
Kira Pilot 4d4ffa2d99 feat: add expiration indicators to license card (#7684)
* sorting licenses; add expiration badge

* updated story
2023-05-25 11:37:51 -07:00
Kira Pilot 0c665235ff feat: add impending deletion banner to workspace page (#7634)
* add banner to workspace page

* fix prettier and lint

* color-code banner

* using warning instead

* improve prop name for clarity
2023-05-25 10:55:41 -07:00
Marcin Tojek 5d2b2c577b fix: add mockgen to nix env (#7682) 2023-05-25 12:44:32 -04:00
Rodrigo Maia d9299caa12 feat: order workspaces by running first (#7656)
* wip

* use updated sql

* wip

* Implement sorting in databasefake.go

* More fixes

* sql fmt

---------

Co-authored-by: Marcin Tojek <marcin@coder.com>
2023-05-25 13:35:47 -03:00
Spike Curtis 96a2e63809 chore: upgrade to golangci-lint 1.52.2 (#7674)
* Disable ioutilDeprecated lint

Signed-off-by: Spike Curtis <spike@coder.com>

* Upgrade to golangci-lint 1.52.2

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-25 14:56:31 +04:00
Marcin Tojek 14efdadd3c feat: Collect agent SSH metrics (#7584) 2023-05-25 12:52:36 +02:00
Spike Curtis 05da1e94a2 Fix pubsub goroutines in tests (#7677)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-25 14:46:32 +04:00
Spike Curtis 67cc196c92 feat: pubsub reports dropped messages (#7660)
* Implementation; need linux tests

Signed-off-by: Spike Curtis <spike@coder.com>

* Pubsub with errors tests and fixes

Signed-off-by: Spike Curtis <spike@coder.com>

* Deal with test goroutines

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-25 06:22:30 +00:00
Spike Curtis 6a1e7ee1d0 feat: add file logger to coder ssh (#7646)
* coder ssh can log to file

Signed-off-by: Spike Curtis <spike@coder.com>

* Update golden file

Signed-off-by: Spike Curtis <spike@coder.com>

* generate CLI docs

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix imports, typo

Signed-off-by: Spike Curtis <spike@coder.com>

* log more things!

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-25 05:07:39 +00:00
Colin Adler a903d7c249 fix(ci): use env for Go version in release workflow (#7673) 2023-05-24 22:52:18 +00:00
Colin Adler dd69cc9148 fix: use different terraform cache dir (#7672) 2023-05-24 22:35:00 +00:00
Colin Adler 5eb41e8794 feat(cli): allow specifying the listen address in coder port-forward (#7635) 2023-05-24 15:38:40 -04:00
Ammar Bandukwala d413b261d8 chore: deduplicate CLI telemetry reports (#7669) 2023-05-24 12:45:41 -05:00
Ammar Bandukwala ec117e841a chore: add CLI invokation telemetry (#7589) 2023-05-24 11:08:03 -05:00
sharkymark b6604e8845 chore(docs): AWS EKS load balancer setup steps (#7665) 2023-05-24 10:19:45 -05:00
goodspark 71c52ea93c feat: Add logging options for coder agent (#7474)
Similar to logging options in the coderd server, but for the agent
running in workspaces. Meant to make hollistic log collection and
querying simpler.
2023-05-24 14:32:40 +00:00
Mathias Fredriksson b6c8e5be48 fix(cli/ssh): Fetch up-to-date build info to avoid ws has no agents (#7650)
Fixes #5836
2023-05-24 12:37:22 +03:00
Cian Johnston f47ecc29f0 chore(dogfood): Update sqlc version in dogfood image to match CI (#7661) 2023-05-24 09:30:56 +00:00
Colin Adler 0c074742a5 fix(ci): manually select Go version (#7654) 2023-05-24 07:47:44 +00:00
Colin Adler f72d8e95a4 fix(ci): add mockgen to trivy scan (#7655) 2023-05-23 17:09:16 -04:00
Colin Adler 02cc325047 chore(mod): symbolically bump tailscale (#7653) 2023-05-23 15:20:22 -04:00
dependabot[bot] 8f13c145c4 chore: bump github.com/moby/moby from 20.10.23+incompatible to 24.0.1+incompatible (#7622)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-23 19:04:00 +00:00
Colin Adler c8ea76c7fa fix(cli): correctly use cache dir for provisionerd work dir (#7651) 2023-05-23 13:37:27 -04:00
Bruno Quaresma ba02dc8f3a chore(site): Force exact deps (#7649) 2023-05-23 07:43:46 -08:00
Steven Masley d203f5259d fix: Port forward should ignore coder ports (#7645)
Ports opened by coder agent should be ignored in the listening ports
map.
2023-05-23 17:14:05 +02:00
Spike Curtis cd416c86dd refactor: workspace builds (#7541)
* refactor workspace builds

Signed-off-by: Spike Curtis <spike@coder.com>

* make gen

Signed-off-by: Spike Curtis <spike@coder.com>

* Remove ParameterResolver from typescript

Signed-off-by: Spike Curtis <spike@coder.com>

* rename conversion -> database/db2sdk

Signed-off-by: Spike Curtis <spike@coder.com>

* tests for db2sdk

Signed-off-by: Spike Curtis <spike@coder.com>

* Tests for ParameterResolver

Signed-off-by: Spike Curtis <spike@coder.com>

* wsbuilder tests

Signed-off-by: Spike Curtis <spike@coder.com>

* Move parameter validation tests to richparameters_test.go

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix CI generation; rename mock->dbmock

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix test imports

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-23 12:06:33 +04:00
Spike Curtis 622456faf8 docs: Add autoscale recommendations docs (#7617)
* Add autoscale recommendations

Signed-off-by: Spike Curtis <spike@coder.com>

* review updates

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-23 09:22:29 +04:00
Rodrigo Maia 4a320617b4 feat(workspaces): change sorting order of the workspace list (#7594)
* feat(workspaces): implement sorting order on workspace list

* split slice into its own function and test it

* use require instead of assert

* Update coderd/workspaces_internal_test.go

Co-authored-by: Cian Johnston <cian@coder.com>

* refactor tests into table tests

* fix test

---------

Co-authored-by: Cian Johnston <cian@coder.com>
2023-05-22 20:51:29 +00:00
Steven Masley 5d711fc95a chore: CORs option for yarn dev server (#7630)
* chore: Yarn dev servers require CORs headers for external proxies

Adds a flag to set CORs headers to `*` for yarn dev servers
2023-05-22 20:02:39 +02:00
dependabot[bot] 1f4f0efed6 chore: bump github.com/prometheus/client_golang from 1.14.0 to 1.15.1 (#7620)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-22 13:18:44 -04:00
dependabot[bot] 808e83f87d chore: bump golang.org/x/tools from 0.6.0 to 0.9.1 (#7619)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-22 13:16:27 -04:00
dependabot[bot] 7d1ca7c12f chore: bump crate-ci/typos from 1.14.9 to 1.14.10 (#7618)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-22 13:13:03 -04:00
dependabot[bot] 9c923d71ca chore: bump github.com/hashicorp/terraform-json from 0.14.0 to 0.16.0 (#7621)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-22 13:10:11 -04:00
Steven Masley b8c07ff014 feat: Auto select workspace proxy based on lowest latency (#7515)
* feat: Proxy auto select and user selection state
* chore: Auto select based on latency
* Add extra test for unknown latencies
* Mock latencies for unit tests
2023-05-22 16:56:41 +02:00
Marcin Tojek f9a97c25dc fix: disable TCP SACK (#7624) 2023-05-22 13:37:05 +00:00
dependabot[bot] b38fb90e06 chore: bump @emotion/styled from 11.10.8 to 11.11.0 in /site (#7561)
Bumps [@emotion/styled](https://github.com/emotion-js/emotion) from 11.10.8 to 11.11.0.
- [Release notes](https://github.com/emotion-js/emotion/releases)
- [Changelog](https://github.com/emotion-js/emotion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/emotion-js/emotion/compare/@emotion/styled@11.10.8...@emotion/styled@11.11.0)

---
updated-dependencies:
- dependency-name: "@emotion/styled"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-22 09:23:33 -03:00
dependabot[bot] 1bd3ed9ecd chore: bump chromatic from 6.15.0 to 6.17.4 in /site (#7554)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.15.0 to 6.17.4.
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.15.0...v6.17.4)

---
updated-dependencies:
- dependency-name: chromatic
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-21 13:12:03 -05:00
Muhammad Atif Ali 51130540af docs: Add steps to migrate from the built-in database to an external database (#7614) 2023-05-21 10:31:06 -05:00
Colin Adler ef2411ef17 fix(provisionersdk): allow .terraform.lock.hcl files to be archived (#7604) 2023-05-19 13:22:59 -04:00
Cian Johnston a29c4c543d chore(dogfood): fix dogfood image (#7603)
* chore(dogfood): update keys, add script to do so

* chore(dogfood): fix urls in Dockerfile

* fmt
2023-05-19 15:09:34 +01:00
Muhammad Atif Ali e375169ac0 chore: remove CPU usage calculation for hosts on cgroup v1 (#7602) 2023-05-19 14:08:20 +00:00
Muhammad Atif Ali ef635f12ea chore(dogfood): update the dogfood template to add workspace CPU and RAM usage from cgroup (#7529)
Co-authored-by: Cian Johnston <cian@coder.com>
2023-05-19 15:15:48 +03:00
Colin Adler dd5b0b2721 fix(scim): ensure scim users aren't created with their own org (#7595) 2023-05-18 20:54:45 -04:00
Kira Pilot 0b15b1bcd1 feat: add impending deletion indicators to the workspace page (#7588)
* created WorkspaceDeletion directory

* remove commented code

* attempting to fix workspace stories

* fix lint

* fix the rest of the stories

* fix right stories

* PR comments

* fix lint
2023-05-18 11:08:55 -07:00
Bruno Quaresma 8e31ed4072 refactor(site): Refactor alerts (#7587) 2023-05-18 13:17:16 -03:00
Muhammad Atif Ali 63a9e34381 fix: correct free disk space reported by agent metadata in fly.io example (#7592) 2023-05-18 11:42:04 +03:00
Jon Ayers ec5ef51b49 feat: add session token injection to provisioner (#7461) 2023-05-17 23:29:22 -05:00
Jon Ayers 00a2413c03 feat: add telemetry support for workspace agent subsystem (#7579) 2023-05-17 22:49:25 -05:00
dependabot[bot] 52bb84a26f chore: bump google.golang.org/api from 0.108.0 to 0.122.0 (#7558)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-17 14:06:17 -04:00
Bruno Quaresma 12f87cb98d refactor(site): Show update notification as snackbar (#7546) 2023-05-17 13:56:26 -03:00
Bruno Quaresma a7f14f89e3 fix(site): Fix loading buttons (#7549) 2023-05-17 13:56:15 -03:00
dependabot[bot] 119098a1eb chore: bump github.com/coreos/go-oidc/v3 from 3.4.0 to 3.6.0 (#7553)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-17 16:29:42 +00:00
Kyle Carberry 6e7175b589 chore: fix lengthy tests in psql (#7545)
* chore: fix lengthy tests in psql

This was adding at a minimum 3mins to our psql tests!

* fix: automatically cancel tests on cleanup
2023-05-17 11:26:53 -05:00
dependabot[bot] d1b1122690 chore: bump github.com/gohugoio/hugo from 0.110.0 to 0.111.3 (#7562)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-17 12:14:38 -04:00
dependabot[bot] bfa136276c chore: bump crate-ci/typos from 1.14.8 to 1.14.9 (#7552)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-17 12:11:56 -04:00
dependabot[bot] ce91009d6b chore: bump beatlabs/delete-old-branches-action from 0.0.9 to 0.0.10 (#7551)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-17 12:11:43 -04:00
Ben Potter e951778147 fix: indentation in rootless podman docs (#7577)
* fix: indentation in rootless podman docs

* fmt
2023-05-17 01:26:13 +00:00
Colin Adler 75b0643623 chore: enable dependabot for coder base image (#7550) 2023-05-16 19:09:45 +00:00
Colin Adler e3b324a1a1 chore(dogfood): update dependency versions (#7548) 2023-05-16 18:26:06 +00:00
Steve Coder 04f68e8f15 doc:fixed enterprise feature 404s. (#7547) 2023-05-16 12:32:54 -05:00
Pfau, Sascha ad9a29dfa6 feat(site): added URL param name to allow setting workspace name (#7528)
* feat: added URL param name to allow setting workspace name

* fix: format

---------

Co-authored-by: SaschaPfau <Sascha.Pfau@ilabnordlb.onmicrosoft.com>
2023-05-16 13:26:13 -03:00
Kira Pilot dca77ba487 feat: add workspaces banner for impending deletion (#7538)
* feat: add workspaces banner for impending deletion

* added storybook

* remove storybook - cannot add because of hook used in badge component
2023-05-16 07:01:22 -07:00
Marcin Tojek 97b4743a47 Revert "fix: set default sshMaxTimeout to 60s (#7532)" (#7544)
This reverts commit 049e557675.
2023-05-16 15:28:15 +02:00
Kyle Carberry c6055c64be chore: improve input hover color (#7534) 2023-05-16 09:00:20 -03:00
dependabot[bot] a1853f2fa2 chore: bump date-fns from 2.29.3 to 2.30.0 in /site (#7335)
Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.29.3 to 2.30.0.
- [Release notes](https://github.com/date-fns/date-fns/releases)
- [Changelog](https://github.com/date-fns/date-fns/blob/v2.30.0/CHANGELOG.md)
- [Commits](https://github.com/date-fns/date-fns/compare/v2.29.3...v2.30.0)

---
updated-dependencies:
- dependency-name: date-fns
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-15 16:05:52 -03:00
dependabot[bot] 4997b86548 chore: bump eslint-plugin-compat from 4.0.2 to 4.1.4 in /site (#7339)
Bumps [eslint-plugin-compat](https://github.com/amilajack/eslint-plugin-compat) from 4.0.2 to 4.1.4.
- [Release notes](https://github.com/amilajack/eslint-plugin-compat/releases)
- [Changelog](https://github.com/amilajack/eslint-plugin-compat/blob/main/CHANGELOG.md)
- [Commits](https://github.com/amilajack/eslint-plugin-compat/compare/v4.0.2...v4.1.4)

---
updated-dependencies:
- dependency-name: eslint-plugin-compat
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-15 15:45:54 -03:00
Ben Potter 78f862eedc chore: rename "external workspace proxies" and "external provisioners" (#7454) 2023-05-15 21:38:49 +03:00
Bruno Quaresma 11b7732720 feat(site): Show confirmation dialog on restart (#7531) 2023-05-15 14:43:51 -03:00
Bruno Quaresma d9fc94f9a9 fix(site): Fix focus state on buttons (#7526) 2023-05-15 14:43:16 -03:00
Spike Curtis 0b156420de Make coder dotfiles symlinking idempotent (#7525)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-15 21:00:50 +04:00
Kyle Carberry 424f954b91 fix: use password style for session token auth (#7533) 2023-05-15 11:27:39 -05:00
Ben Potter 2aea5b76aa docs: parameters are not alpha (#7487) 2023-05-15 16:14:59 +00:00
Bruno Quaresma 6f62204d38 feat(site): Add template embed page (#7501) 2023-05-15 13:07:39 -03:00
Marcin Tojek 049e557675 fix: set default sshMaxTimeout to 60s (#7532)
* fix: set default sshMaxTimeout to 60s

* fix
2023-05-15 10:40:19 -05:00
Kira Pilot 224d25d4e1 feat: add 'impending deletion' badges to workspaces page (#7530)
* update deleting logic

* added status badge on workspaces page

* licensing and feature flagging

* preset filter for failed workspaces

* remove comment

* PR feedback

* Revert "PR feedback"

This reverts commit 2dfbb50acd.

* PR feedback 2
2023-05-15 07:59:17 -07:00
Cian Johnston 854e974bb4 chore: add terraform for spinning up load test cluster (#7504)
Adds terraform configs for spinning up loadtest environments
2023-05-15 15:56:47 +01:00
Bruno Quaresma dab1d1fe20 fix(site): Fix terminal elements size (#7527) 2023-05-15 10:48:41 -03:00
Marcin Tojek 87784493e8 fix: use mtojek/gvisor to tweak RTO (#7500)
* fix: use mtojek/gvisor to tweak RTO

* fix
2023-05-15 09:12:45 +02:00
Kyle Carberry a08e8a16ab chore: switch make test to use the standard go format (#7519)
I find it easier to read.
2023-05-14 21:20:19 -05:00
Kyle Carberry 70d2203b9e chore: reduce the log output of skipped tests (#7520)
With the introduction of the workspace proxy tests there was a lot
of output if a test was eventually skipped.
2023-05-14 19:37:00 -05:00
Ammar Bandukwala 9bb0253290 chore: update various dependencies (#7503)
This will help us pass the security scanners.
2023-05-14 20:37:50 +00:00
Kyle Carberry 26490aecca chore: improve postgres test time by removing cleanup (#7522)
We don't need to delete databases on cleanup... and we don't need to
always run without a cache either!
2023-05-14 15:32:44 -05:00
Kyle Carberry 778cb7494a chore: adjust the style and wording of the license page (#7396)
- Reduce the size of the card to improve the use of space
- Adjust the language of the add page to remove word redundancy
- Change from using background colors to text colors
2023-05-14 15:31:54 -05:00
Kyle Carberry 8e1da5e628 chore: run yarn-deduplicate to speed up yarn install (#7523) 2023-05-14 15:28:07 -05:00
Ammar Bandukwala f05f12231d feat: update slog to use logfmt (#7477) 2023-05-14 20:23:13 +00:00
Ammar Bandukwala 0f4717e471 hotfix(.github): only push dogfood template when /dogfood changes 2023-05-14 20:13:37 +00:00
Kyle Carberry 50f2d0c7e9 fix: add a mutex around reading logs from scaletests (#7521) 2023-05-14 12:16:00 -05:00
Ammar Bandukwala fcde77b35f chore(.github): only deploy dogfood on main (#7518) 2023-05-14 11:32:22 -05:00
Ben Potter 6bb4a4c3c5 chore: add latest dogfood template (#7321)
Co-authored-by: Muhammad Atif Ali <matifali@live.com>
2023-05-13 15:42:10 +03:00
Muhammad Atif Ali 8d4a8fde66 docs: add instructions for connecting via RDP (#7510) 2023-05-12 11:41:10 -05:00
Marcin Tojek cd38cb8290 feat: Add template version warnings (#7483) 2023-05-12 09:21:49 +00:00
Steven Masley 8f768f8276 feat: Workspace Proxy picker show latency to each proxy (#7486)
* chore: Add cors to workspace proxies to allow for latency checks
* Add latency check to wsproxy

Use performance API timings.
- Fix cors and timing headers
- Accept custom headers
2023-05-11 15:42:30 -05:00
Ammar Bandukwala 640fcf450c chore: improve terraform install performance (#7478) 2023-05-11 19:30:51 +00:00
Eric Paulsen 0e6361383c fix(helm): change proxy to wsproxy (#7499) 2023-05-11 17:55:04 +00:00
Kira Pilot ae3473dc1b feat: add deleted_at field to workspace model (#7475)
* added impending_deletion workspace field

* gen docs

* update golden files

* added test

* PR comments
2023-05-11 08:47:53 -07:00
Eric Paulsen fe0e94ece9 docs: add docs for disabling email/pass auth (#7494) 2023-05-11 10:09:14 -05:00
Ben Potter 892bddfb7b fix: scroll to reveal template create errors (#7464)
Co-authored-by: Kira Pilot <kira@coder.com>
2023-05-11 14:47:51 +03:00
Steven Masley b7f4f3a771 chore: Implement workspace proxy going away (graceful shutdown) (#7459)
* chore: Implement workspace proxy going away

When a workspace proxy shuts down, the health status of that
proxy should immediately be updated. This is purely a courtesy
and technically not required
2023-05-10 19:23:16 -05:00
Kira Pilot a42a36a474 feat: add workspace actions cleanup configuration flags to CLI template create and edit (#7453)
* added cleanup flags on template create

* added cleanup flags on template edit

* fixed tests

* added to tests
2023-05-10 12:57:11 -07:00
Bruno Quaresma 816c37dd0d chore(site): Upgrade to MUI v5 (#7437) 2023-05-10 19:42:40 +00:00
Steven Masley fb86ac2608 chore: If selecting an unhealthy proxy, default to primary (#7472)
* chore: If selecting an unhealthy proxy, default to primary
2023-05-10 13:10:06 -05:00
Steven Masley 3f9af6f5e7 chore: Allow cors requests to workspace proxies for latency checks (#7484)
* CSP addition for web requests
* chore: Add cors to workspace proxies to allow for latency checks
2023-05-10 17:19:55 +00:00
Muhammad Atif Ali d17ea84b4a docs: change --ttl to --default-ttl (#7479) 2023-05-10 07:03:50 -05:00
Spike Curtis d35a458767 feat: Windows on Azure example template (#7469)
* WIP Azure template for windows machine

Signed-off-by: Spike Curtis <spike@coder.com>

* WIP windows uses data disk

Signed-off-by: Spike Curtis <spike@coder.com>

* Data drive working

Signed-off-by: Spike Curtis <spike@coder.com>

* Add az cli commands to start & stop

Signed-off-by: Spike Curtis <spike@coder.com>

* Remove commented line

Signed-off-by: Spike Curtis <spike@coder.com>

* Prettierify

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-10 05:56:19 +00:00
Steven Masley b5ad628460 chore: Allow editing proxy fields via api. (#7435)
* chore: Add ability to update workspace proxy fields
2023-05-09 13:46:50 -05:00
Steven Masley fc1bc374cb chore: Drop application host call, default to regions for info (#7457)
* chore: Drop application host call, default to regions for info
2023-05-09 09:28:25 -05:00
Ben Potter 2d62cbc83a chore: minor change to workspace actions copy (#7458) 2023-05-09 08:31:07 -05:00
Eric Paulsen 503e94a5c2 docs: fix proxy cmd ref (#7460) 2023-05-08 19:22:35 -04:00
Kira Pilot 0755ff32ef label change (#7455) 2023-05-08 16:13:14 -03:00
Steven Masley 1aac8200fa chore: Fix column name in proxy ls command (#7450) 2023-05-08 12:23:12 -05:00
Ben Potter 3931a6c7bc fix: accurate list of experiments in docs (#7449) 2023-05-08 14:58:07 +00:00
Steven Masley c3e60dcdfb chore: Fix proxy description wording on workspace proxy page (#7448) 2023-05-08 14:41:14 +00:00
Ben Potter 8f9a3ea1a7 docs: add docs for selecting a proxy (#7444) 2023-05-08 14:37:56 +00:00
Ammar Bandukwala 8899dd89ca chore: add global caching to rbac (#7439)
Co-authored-by: Steven Masley <stevenmasley@coder.com>
2023-05-08 08:59:01 -05:00
Bruno Quaresma 643a9efea9 chore(site): Add type checking (#7441) 2023-05-05 18:46:51 -03:00
Steven Masley 52d2bc930b chore: Make better error message if missing license (#7440)
* chore: Make better error message if missing license

* Change word to proxies
2023-05-05 14:22:56 -05:00
Steven Masley 07608fc3fb chore: fix proxy 404 page (#7421)
* chore: fix proxy 404 page

---------

Co-authored-by: Kyle Carberry <kyle@coder.com>
2023-05-05 13:53:19 -05:00
Steven Masley 2624ee8f12 chore: Remove extra opt and fix 'proxy' alias (#7413)
* chore: Remove extra opt and fix 'proxy' alias
* proxy -> wsproxy
2023-05-05 13:09:04 -05:00
Bruno Quaresma ec11405208 chore(site): Remove dead code (#7436) 2023-05-05 16:30:08 +00:00
Spike Curtis dc3d39baf8 fix: agent disconnects from coordinator (#7430)
* work around websocket deadline bug

Signed-off-by: Spike Curtis <spike@coder.com>

* Use test context to hold websocket open

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix race creating test websocket

Signed-off-by: Spike Curtis <spike@coder.com>

* set write deadline to time.Time zero

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-05 20:29:03 +04:00
Kira Pilot 5ffa6dae50 feat: add inactivity cleanup and failure cleanup configuration fields to Template Schedule Form (#7402)
* added workspace actions entitlement

* added workspace actions experiment

* added new route for template enterprise meta

* removing new route; repurposing old

* add new fields to get endpoints

* removed workspace actions experiment

* added logic to enterprise template store

* added new form fields

* feature flagged new fields

* fix validation

* fixed submit btn

* fix tests

* changed ttl defaults

* added FE tests

* added BE tests

* fixed lint

* adjusted comment language

* fixing unstaged changes check

* fix test

* Update coderd/database/migrations/000122_add_template_cleanup_ttls.down.sql

Co-authored-by: Dean Sheather <dean@deansheather.com>

* Update coderd/database/migrations/000122_add_template_cleanup_ttls.up.sql

Co-authored-by: Dean Sheather <dean@deansheather.com>

---------

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-05-05 08:19:26 -07:00
Bruno Quaresma 3632ac8c01 refactor(site): Update workspace header (#7433) 2023-05-05 15:02:21 +00:00
Cian Johnston 7f02fa696a chore(docs): update openshift documentation re psp (#7432) 2023-05-05 13:00:07 +01:00
Cian Johnston 08fb9a6f1b feat(cli): add trafficgen command for load testing (#7307)
This PR adds a scaletest workspace-traffic command for load testing. This opens a
ReconnectingPTY connection to each scaletest workspace (via coderd) and 
concurrently writes and reads random data to/from the PTY. Payloads are of the
form #${RANDOM_ALPHANUMERIC_STRING}, which essentially drops garbage
comments in the remote shell, and should not result in any commands being executed.
2023-05-05 10:34:58 +01:00
Cian Johnston a172e073e3 chore(ci): update golden files (#7431) 2023-05-05 09:05:45 +00:00
Spike Curtis a6a44896bf fix: pubsub ordering (#7404)
* fix: pubsub sends messages in order

Signed-off-by: Spike Curtis <spike@coder.com>

* Drop messages rather than block

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-05 09:39:07 +04:00
Dean Sheather 667d9a7557 chore: add workspaceProxy to helm chart (#7398) 2023-05-05 07:07:49 +10:00
Bruno Quaresma 164146c462 feat(site): Show update confirmation dialog (#7420) 2023-05-04 15:40:41 -03:00
Steven Masley 6d24f7c894 feat: Add documentation for workspace proxy creation (#7377)
* feat: Add documentation for workspace proxy creation
2023-05-04 13:30:06 -05:00
Bruno Quaresma 8909110f58 fix(site): Fix template icon field validation (#7394) 2023-05-04 14:30:48 -03:00
Jon Ayers 614bdfbf3c fix: update envbox template to use hostname (#7417) 2023-05-04 12:21:20 -05:00
Kyle Carberry 11ac3be4d8 fix: redirect to login on gitauth invalid session (#7416) 2023-05-04 17:19:44 +00:00
Steven Masley 9908c84b2a test: Return early and avoid using nil handler (#7411)
* test: Return early and avoid using nil handler
2023-05-04 11:14:53 -05:00
Cian Johnston b4d913e24f fix(helm): explode verbs instead of wildcarding (#7405)
Updates the Helm chart role specification for Coder to explicitly list required verbs instead of requesting wildcard.
2023-05-04 10:45:51 +00:00
Spike Curtis b3689c8f64 Only send tailnet nodes updates with preferred DERP (#7387)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-04 14:30:57 +04:00
Colin Adler 4e52112112 fix: template versions test flake (#7400) 2023-05-03 20:19:49 -05:00
Colin Adler 8bd9f9c351 feat: unified tracing between coderd<->provisionerd (#7370) 2023-05-03 23:02:35 +00:00
Steven Masley 3368b8b65f chore: Minor rbac memory optimization (#7391)
* test: Add benchmark for static rbac roles
* static roles should only be allocated once
* A unit test that modifies the ast value should not mess with the globals
* Cache subject AST values to avoid reallocating slices
2023-05-03 14:42:24 -05:00
Kira Pilot 2e9310b203 chore: add workspace actions entitlement and experiment (#7361)
* added workspace actions entitlement

* added workspace actions experiment
2023-05-03 11:34:43 -07:00
Dean Sheather 5961cf900d chore: bump terraform from 1.3.4-r3 to r4 in image (#7393)
Looks like 1.3.4-r3 isn't available anymore, and 1.3.4-r4 is available
instead.
2023-05-03 18:21:11 +00:00
Bruno Quaresma 2ea438cf4f refactor(site): Show immutable parameters in the settings (#7383) 2023-05-03 14:40:47 -03:00
Steven Masley 434c4be9f1 chore: Add listing proxies to cli 'coder proxy ls' (#7376)
* feat: Add listing proxies to cli 'coder proxy ls'

* Add unit test

* Ignore errors

* Make gen and update golden files

* Update golden files
2023-05-03 10:12:56 -05:00
Kyle Carberry 90c57a538c fix: make telemetry source a string not an enum (#7390) 2023-05-03 14:33:51 +00:00
Spike Curtis 9c030a8888 fix: pty.Start respects context on Windows too (#7373)
* fix: pty.Start respects context on Windows too

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix windows imports; rename ToExec -> AsExec

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix import in windows test

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-03 11:43:05 +04:00
Bruno Quaresma e6931d6920 refactor(site): Remove optimistic workspace action (#7385) 2023-05-02 18:38:53 -03:00
Steven Masley dd67283323 chore: Adjust wording to mention only browser connections (#7384) 2023-05-02 13:39:23 -05:00
Bruno Quaresma 730039f35f feat(site): Show warning if startup script is running (#7326) 2023-05-02 14:49:16 -03:00
Colin Adler 75ad72de56 fix(server): prevent otel tracer provider from immediately being closed (#7369) 2023-05-02 12:06:58 -05:00
Spike Curtis bd630113b2 fix: coordinator node update race (#7345)
* fix: coordinator node update race

Signed-off-by: Spike Curtis <spike@coder.com>

* Lint fixes, make core private

Signed-off-by: Spike Curtis <spike@coder.com>

* Don't log broken connections as errors

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-02 20:58:21 +04:00
Bruno Quaresma 0e78d0a502 fix(site): Remove extra spacing between ssh button (#7380) 2023-05-02 13:54:52 -03:00
dependabot[bot] 6dfce5a2c9 chore: bump jest-runner-eslint from 1.1.0 to 2.0.0 in /site (#7343)
Bumps [jest-runner-eslint](https://github.com/jest-community/jest-runner-eslint) from 1.1.0 to 2.0.0.
- [Release notes](https://github.com/jest-community/jest-runner-eslint/releases)
- [Changelog](https://github.com/jest-community/jest-runner-eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/jest-runner-eslint/compare/v1.1.0...v2.0.0)

---
updated-dependencies:
- dependency-name: jest-runner-eslint
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-02 09:56:58 -05:00
Muhammad Atif Ali f5ce911b8d docs: make use of display_name and name in Open with Coder (#7372)
This PR removed the spaces from `name` and makes it equal to the resource name as we now have a sperate field `display_name` https://github.com/coder/coder/pull/6919

The docs references https://github.com/bpmct/coder-templates/tree/main/kubernetes-open-in-coder example which does not yet makes use of  `display name` and needs updating.
2023-05-02 09:51:50 -05:00
Steven Masley a1db82582f chore: Dynamic CSP connect-src to support terminals connecting to workspace proxies (#7352)
* chore: Expose proxy hostnames to csp header
2023-05-02 08:30:44 -05:00
Ammar Bandukwala 465fe8658d chore: skip timing-sensistive AgentMetadata test in the standard suite (#7237)
* chore: skip timing-sensistive AgentMetadata test in the standard suite

* Add test-timing target

* fix windows?

* Works on my Windows desktop?

* Use tag system

* fixup! Use tag system
2023-05-02 10:41:41 +00:00
Dean Sheather 398d08a0cf chore: fix ci.yaml deploy step for other regions 2 (#7368) 2023-05-02 01:34:21 +00:00
Dean Sheather 41726a785e chore: fix ci.yaml deploy step for other regions (#7367) 2023-05-02 01:00:55 +00:00
Dean Sheather 140637448c chore: fix nfpm.yaml (#7366) 2023-05-01 22:44:11 +00:00
Dean Sheather 3b15234660 chore: add continuous deployment for workspace proxies (#7364) 2023-05-02 08:02:51 +10:00
Ammar Bandukwala 4b9621f9ae fix(coderd): don't hang on first gitauth clone (#7331)
Previously, the `coder git ssh` command would hang on the API, which was endlessly polling the database for oauth tokens that expire in the future.

Some oAuth implementations (including GitHub by default) will not give back a token expiry date, and the absence of such a date was represented as a zero data in the database as opposed to a null value.

Follow-up calls to `git clone` would succeed because this hot path doesn't check expiry, perhaps originally by mistake.

In addition to fixing the zero date issue, this PR removes all gitauth PubSub, which added too much complexity when the polling interval is 1 second.
2023-05-01 19:19:41 +00:00
Steven Masley 55824986bc chore: 404 Requests to workspace proxy direct back to the primary (#7353)
* chore: 404 Requests to workspace proxy direct back to the primary

* Remove unnecessary sprintf
2023-05-01 13:58:36 -05:00
dependabot[bot] 04f9ca824f chore: bump golang.org/x/mod from 0.8.0 to 0.10.0 (#7338)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-01 16:51:28 +00:00
dependabot[bot] 6030847c94 chore: bump golang.org/x/crypto from 0.7.0 to 0.8.0 (#7336)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-01 11:39:40 -05:00
dependabot[bot] 4dec828c88 chore: bump tj-actions/branch-names from 6.4 to 6.5 (#7334)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-01 16:26:52 +00:00
dependabot[bot] 38fd4c0820 chore: bump gopkg.in/natefinch/lumberjack.v2 from 2.0.0 to 2.2.1 (#7337)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-01 11:15:38 -05:00
dependabot[bot] 0bf00d6122 chore: bump aquasecurity/trivy-action from 0.9.2 to 0.10.0 (#7333)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-01 11:15:09 -05:00
dependabot[bot] a3f3d7e682 chore: bump github.com/hashicorp/hc-install from 0.4.1-0.20220912074615-4487b02cbcbb to 0.5.1 (#7342)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-01 16:14:43 +00:00
dependabot[bot] 97c8bb5c1d chore: bump crate-ci/typos from 1.14.3 to 1.14.8 (#7332)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-01 11:14:15 -05:00
Steven Masley 079d2821f5 chore: Set proxy health checks to 1 minute intervals (#7351) 2023-05-01 16:06:29 +00:00
Rodrigo Maia d3a9d7c497 chore: minor tweaks to license ui (#7314)
* chore: minor tweaks to license ui

* minor license ui tweaks

* rename stories
2023-04-28 21:49:54 +00:00
Steven Masley 4a9d1c16c7 chore: UI/UX for regions (#7283)
* chore: Allow regular users to query for all workspaces
* FE to add workspace proxy options to account settings
* WorkspaceProxy context syncs with coderd on region responses

---------

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-04-28 16:04:52 -05:00
Colin Adler c00f5e499a fix(server): retry initial connection to postgres (#7325) 2023-04-28 13:51:31 -05:00
Kira Pilot a2ff674158 fix(UI): workspace restart button stops build before starting a new one (#7301)
* feat(UI): add workspace restart button (#7137)

* Refactor primary buttons

* refactor(site): Always show the main actions

* Remove tests that are testes on Storybook

* Fix tests

* Fix keys

* added restart btn

---------

Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>

* added restart hook

* added error handling

* going back to chaining in success callback

* add restarting btn

* added test

* PR feedback

---------

Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
2023-04-28 11:16:04 -07:00
Eric Paulsen 3078cd3d98 fix: envbox template 404 (#7324) 2023-04-28 12:49:26 -05:00
Ben Potter 8d1f163cae chore: remove login_before_ready from example templates (#7322) 2023-04-28 14:59:50 +00:00
Bruno Quaresma 88c362dfdc refactor(site): Refactor error state (#7313) 2023-04-28 13:03:01 +00:00
Marley e747aad2b6 docs: added additional documentation for azure devops git provider (#6923)
Co-authored-by: Ben Potter <me@bpmct.net>
Co-authored-by: Atif Ali <matifali@live.com>
2023-04-28 11:41:47 +00:00
Colin Adler 59efa4a528 fix(audit): ensure template creation errors are audited (#7315) 2023-04-27 18:55:34 -05:00
Marcin Tojek 77d9937dc4 fix: vite fatals on receiving HTTP4xx (#7306)
* fix: vite fatals on receiving HTTP4xx

* tune Vite

* fmt

* rewrite

* fmt
2023-04-27 19:04:24 +02:00
Eric Paulsen ed1b33acd6 docs: clarify quota allocation (#7310) 2023-04-27 16:51:05 +00:00
Ben Potter fe323a159e fix: keep "workspace create" form when rendering errors (#7289)
* fix: keep "workspace create" form when rendering errors

* fmt

* scroll to top if errors are present
2023-04-27 16:31:42 +00:00
Marcin Tojek bb0a38b161 feat: Implement aggregator for agent metrics (#7259) 2023-04-27 12:34:00 +02:00
Spike Curtis b6666cf1cf chore: tailnet debug logging (#7260)
* Enable discovery (disco) debug

Signed-off-by: Spike Curtis <spike@coder.com>

* Better debug on reconnectingPTY

Signed-off-by: Spike Curtis <spike@coder.com>

* Agent logging in appstest

Signed-off-by: Spike Curtis <spike@coder.com>

* More reconnectingPTY logging

Signed-off-by: Spike Curtis <spike@coder.com>

* Add logging to coordinator

Signed-off-by: Spike Curtis <spike@coder.com>

* Update agent/agent.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update agent/agent.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update agent/agent.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update agent/agent.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Clarify logs; remove unrelated changes

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-04-27 13:59:01 +04:00
winter0mute 7aa07cfc8d docs: Fix relay link in HA doc (#7159)
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-04-27 08:25:15 +00:00
Jon Ayers f1763f2aa5 chore: add envbox documentation (#7198) 2023-04-26 16:42:33 -05:00
Rodrigo Maia 87b7537878 feat: add license settings UI (#7210)
* wip: license page

* WIP

* WIP

* wip

* wip

* wip

* wip

* wip

* wip

* Apply suggestions from code review

Co-authored-by: Ben Potter <ben@coder.com>

* wip: ui improvements

* wip: extract components

* wip: stories

* wip: stories

* fixes from PR reviews

* fix stories

* fix empty license page

* fix copy

* fix

* wip

* add golang test

---------

Co-authored-by: Ben Potter <ben@coder.com>
2023-04-26 17:47:46 -03:00
Rodrigo Maia c3fe2515a7 feat: add license expiration warning (#7264)
* wip: add expiration warning

* Use GraceAt

* show expiration warning for trial accounts

* fix test

* only show license banner for users with deployment permission

---------

Co-authored-by: Marcin Tojek <marcin@coder.com>
2023-04-26 16:39:39 -03:00
Colin Adler 3eb7f06bf1 feat(agent): add http debug routes for magicsock (#7287) 2023-04-26 13:01:49 -05:00
Ben Potter 272573e9f0 chore: change some wording in the dashboard (#7293) 2023-04-26 11:34:17 -05:00
Bruno Quaresma 0e469031b8 fix(site): Fix secondary buttons with popovers (#7296) 2023-04-26 15:33:23 +00:00
Bruno Quaresma 218d6a92d4 docs(site): Mention template editor in template edit docs (#7261) 2023-04-26 12:11:12 +00:00
Spike Curtis 29cbc5404a Reconnecting PTY waits for command output or EOF (#7279)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-04-26 09:02:06 +04:00
Dean Sheather f1dfeb03db chore: fix flake in apptest reconnecting-pty test (#7281) 2023-04-26 00:31:41 +00:00
Bruno Quaresma 35b3ed255c fix(site): Fix default value for options (#7265) 2023-04-25 17:26:42 -03:00
Bruno Quaresma 1134e78b7b fix(site): Do not show template params if there is no param to be displayed (#7263) 2023-04-25 19:54:33 +00:00
Cian Johnston 9afad8241b chore: add security advisories to docs (#7282)
* chore: add security advisories to docs

* Update docs/security/0001_user_apikeys_invalidation.md

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>

---------

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>
2023-04-25 16:56:09 +01:00
Colin Adler b62b6af0eb fix(healthcheck): don't allow panics to exit coderd (#7276) 2023-04-25 15:11:45 +00:00
Dean Sheather a98341612c feat: add regions endpoint for proxies feature (#7277)
* feat: add regions endpoint for proxies feature
2023-04-25 09:37:52 -05:00
Spike Curtis 6e8ff2d95c Fix macOS pty race with dropped output (#7278)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-04-25 12:32:28 +04:00
Colin Adler e2d8bda246 chore(dogfood): remove unnecessary docker host replace (#7269) 2023-04-25 04:58:09 +00:00
Cian Johnston 8fc8559076 fix(coderd): ensure that user API keys are deleted when a user is (#7270)
Fixes an issue where API tokens belonging to a deleted user were
not invalidated:
- Adds a trigger to delete rows from the api_key stable when the
  column deleted is set to true in the users table.
- Adds a trigger to the api_keys table to ensure that new rows
  may not be added where user_id corresponds to a deleted user.
- Adds a migration to delete all API keys from deleted users.
- Adds tests + dbfake implementation for the above.
2023-04-24 21:48:26 +01:00
Bruno Quaresma ad82a60806 refactor(site): Group app and agent actions together (#7267) 2023-04-24 16:59:52 -03:00
Kira Pilot 96a12d17ef Revert "feat(UI): add workspace restart button (#7137)" (#7268)
This reverts commit 9ec16d4454.
2023-04-24 12:44:22 -07:00
Steven Masley 3129741e08 chore: Proxy health status checks + endpoint (#7233)
* chore: Implement workspace proxy health check cron

At a given interval will check the reachability of workspace proxies.

* Proxyhealth is an enterprise feature
* Start proxyhealth go routine on enterprise coder
2023-04-24 10:25:35 -05:00
Nathanial Spearing 63e68c11d1 feat(community-templates): Added vscode-server-template (#7219)
Co-authored-by: Kyle Carberry <kyle@carberry.com>
2023-04-24 15:22:18 +03:00
Spike Curtis daee91c6dc refactor: PTY & SSH (#7100)
* Add ssh tests for longoutput, orphan

Signed-off-by: Spike Curtis <spike@coder.com>

* PTY/SSH tests & improvements

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix some tests

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix linting

Signed-off-by: Spike Curtis <spike@coder.com>

* fmt

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix windows test

Signed-off-by: Spike Curtis <spike@coder.com>

* Windows copy test

Signed-off-by: Spike Curtis <spike@coder.com>

* WIP Windows pty handling

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix truncation tests

Signed-off-by: Spike Curtis <spike@coder.com>

* Appease linter/fmt

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix typo

Signed-off-by: Spike Curtis <spike@coder.com>

* Rework truncation test to not assume OS buffers

Signed-off-by: Spike Curtis <spike@coder.com>

* Disable orphan test on Windows --- uses sh

Signed-off-by: Spike Curtis <spike@coder.com>

* agent_test running SSH in pty use ptytest.Start

Signed-off-by: Spike Curtis <spike@coder.com>

* More detail about closing pseudoconsole on windows

Signed-off-by: Spike Curtis <spike@coder.com>

* Code review fixes

Signed-off-by: Spike Curtis <spike@coder.com>

* Rearrange ptytest method order

Signed-off-by: Spike Curtis <spike@coder.com>

* Protect pty.Resize on windows from races

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix windows bugs

Signed-off-by: Spike Curtis <spike@coder.com>

* PTY doesn't extend PTYCmd

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix windows types

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-04-24 14:53:57 +04:00
Marcin Tojek c000f2ec28 fix: coder_parameter fallbacks to default (#7240) 2023-04-24 09:51:34 +02:00
sharkymark ab077d1f15 docs: fixed broken podman template link and added already-installed ide gateway doc (#6352)
Co-authored-by: Eric Paulsen <ericpaulsen@coder.com>
2023-04-21 20:43:19 +00:00
Mathias Fredriksson 712098fa2b test(agent): Increase the time to wait for agent reachable (#7245) 2023-04-21 19:40:17 +00:00
Colin Adler 501dfeedf7 fix: invalid version for github.com/coder/ssh (#7250) 2023-04-21 18:10:35 +00:00
Colin Adler 1fc32b1c3d ci: disable caching in setup/go action (#7251) 2023-04-21 13:01:42 -05:00
Kyle Carberry fd84df769d fix: add DISPLAY env var for X11 connections (#7248)
* fix: add `DISPLAY` env var for X11 connections

* Update agent/agentssh/agentssh.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

---------

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-04-21 16:43:49 +00:00
Mathias Fredriksson f9da2631e9 test(cli): Fix portforward test timeouts (#7241) 2023-04-21 11:40:31 -05:00
Kyle Carberry f39e6a79de feat: add support for X11 forwarding (#7205)
* feat: add support for X11 forwarding

* Only run X forwarding on Linux

* Fix piping

* Fix comments
2023-04-21 15:52:40 +00:00
Mathias Fredriksson 6f06f8dadb test: Fix test timeouts due to contexts created too early (#7242) 2023-04-21 17:32:25 +03:00
Mathias Fredriksson ea78ca5dff test(coderd/workspaceapps): Fix incorrect use of testing.T (#7243) 2023-04-21 17:32:10 +03:00
Dean Sheather 3680e158d9 chore: fix lint in main caused by incompatible merge (#7239) 2023-04-21 10:27:56 +00:00
Steven Masley 4353ad7940 chore: Remove url and wildcard url from moon create (#7224)
* chore: Remove url and wildcard url from moon create
2023-04-20 21:09:14 -05:00
Dean Sheather 68667323f3 chore: support signed token query param for web terminal (#7197)
* chore: add endpoint to get token for web terminal

* chore: support signed token query param for web terminal
2023-04-20 23:59:45 +00:00
Colin Adler ac3c530283 fix(cli/clitest): race between Start/StartWithWaiter cleanup order (#7232) 2023-04-20 23:41:56 +00:00
Colin Adler 745868fd8a revert: chore: upgrade tailscale (#7236) 2023-04-20 17:58:22 -05:00
Mathias Fredriksson 300ae4a6bf test(agent): Fix TestAgent_UnixRemoteForwarding timeout (#7235) 2023-04-21 01:35:51 +03:00
Mathias Fredriksson 38a6d546ab fix(enterprise/replicasync): Avoid deadlock during Close^2 (#7230) 2023-04-20 22:48:44 +03:00
Colin Adler 34c6ad671c fix(clitest): use separate channel when waiting for exit (#7231) 2023-04-20 14:37:44 -05:00
Mathias Fredriksson ad0070354f test: Fix generated workspace name length (#7228) 2023-04-20 18:40:36 +00:00
Bruno Quaresma d8eda97dbe refactor(site): Redesign the agent row (#7226) 2023-04-20 18:37:10 +00:00
Colin Adler a86830a283 chore: upgrade tailscale (#7207) 2023-04-20 13:29:56 -05:00
Kira Pilot e2a7448cc8 fix: allow update of empty template description (#7225) 2023-04-20 10:59:57 -07:00
Colin Adler ea27129348 chore: upgrade github.com/open-policy-agent/opa (#7204) 2023-04-20 12:50:21 -05:00
Bruno Quaresma e90a076fad fix(site): Fix websocket connections (#7187) 2023-04-20 17:01:08 +00:00
Steven Masley 7fa1112958 chore: Enforce workspace proxy unique name case insensitive (#7202)
* chore: Enforce workspace proxy unique name case insensitive
2023-04-20 11:30:52 -05:00
Bruno Quaresma 9abfe97dcc Revert "fix(site): Fix update when missing parameters (#7221)" (#7223)
This reverts commit 7d9a7636e9.
2023-04-20 12:40:31 -03:00
Steven Masley a5a5c4d400 chore: Add workspace proxy enterprise cli commands (#7176)
* feat: Add workspace proxy enterprise cli commands
* chore: Handle custom workspace proxy options. Remove excess
* chore: Add endpoint to register workspace proxies
2023-04-20 09:48:47 -05:00
Muhammad Atif Ali 8926c10b7d chore: remove disk metadata from Kubernetes examples (#7215) 2023-04-20 09:42:35 -05:00
Bruno Quaresma 7d9a7636e9 fix(site): Fix update when missing parameters (#7221) 2023-04-20 09:32:20 -05:00
Bruno Quaresma 93d0956465 chore(site): Upgrade Vite to 4.3 (#7222) 2023-04-20 14:28:56 +00:00
Mathias Fredriksson 8d27978760 fix(enterprise/replicasync): Avoid deadlock during Close (#7220) 2023-04-20 15:37:30 +03:00
Dean Sheather 528a0686c0 chore: fix deadlock in dbfake and incorrect lock types (#7218)
I manually went through every single dbfake function and ensured it has
the correct lock type depending on whether it writes or only reads.
There were a surprising amount of methods that had the wrong lock type
(Lock when only reading, or RLock when writing (!!!)).

This also manually fixes every method that acquires a RLock and then
calls a method that also acquires it's own RLock to use noLock methods
instead. You cannot rely on acquiring a RLock twice in the same
goroutine as RWMutex prioritizes any waiting Lock calls.

I tried writing a ruleguard rule for this but because of limitations in
ruleguard it doesn't seem possible.
2023-04-20 21:53:34 +10:00
Colin Adler 5f5edb18b0 chore(healthcheck): fix DERP test flakes (#7211) 2023-04-19 20:03:05 -05:00
Colin Adler f60b5579a7 chore: remove usage of k8s.io/utils/pointer (#7209) 2023-04-19 15:53:47 -05:00
Mathias Fredriksson c2871e12aa fix(cli/ssh): Avoid connection hang when workspace is stopped (#7201)
* fix(cli/ssh): Avoid connection hang when workspace is stopped

Two issues are addressed here:
1. We were not detecting disconnects due to waiting for Stdin to close
   (disconnect would only propagate after entering input and failing to
   write to the connection).
2. In other scenarios, where the connection drop is not detected, we now
   also watch workspace status and drop the connection when a workspace
   reaches the stopped state.

Fixes: https://github.com/coder/jetbrains-coder/issues/199

Refs: #6180, #6175
2023-04-19 21:32:28 +03:00
Marc fff2b1dc90 fix(cli): Fix postgres TDE failing version check (#7203) 2023-04-19 11:59:56 -05:00
Ammar Bandukwala 2b9d12828a cli: add --debug-http flag (#7192)
This makes it easier to help debug client issues.
2023-04-19 11:07:53 -05:00
Marcin Tojek f94ac55f02 feat(agent): Expose magicsock metrics (#7183)
* feat: Expose magicsock metrics

* golden-files
2023-04-19 09:09:23 +02:00
Colin Adler fbf329fbb7 fix(tailnet): set TCP keepalive idle to 72 hours for SSH conns (#7196) 2023-04-18 17:53:11 -05:00
Colin Adler 57c4de4647 feat(healthcheck): add accessurl check (#7193) 2023-04-18 15:52:00 -05:00
Dean Sheather fa5387ce07 chore: fix make gen (#7190) 2023-04-18 17:56:52 +00:00
Kyle Carberry 888eb238ec fix: use CODER_HTTP_ADDRESS in docker-compose.yml (#7185)
Fixes #7184.
2023-04-18 11:44:41 -05:00
Steven Masley 7f041fecd8 test: Enable filter test with cancelled context (#7189)
* test: Enable filter test with cancelled context

* fixup! test: Enable filter test with cancelled context
2023-04-18 11:06:10 -05:00
Cian Johnston b26826ee3f chore(docs): update advice for cache dir (#7182)
* Adds a note in openshift documentation regarding CODER_CACHE_DIRECTORY with readOnlyRootFS=true
2023-04-18 14:13:45 +01:00
Kyle Carberry 693e5d94bc fix: add global headers to vscodessh command (#7181) 2023-04-18 08:07:10 -05:00
Bruno Quaresma 56bf9cfdbe fix(site): Handle carriage on logs output (#7172) 2023-04-17 20:45:48 +00:00
Colin Adler b44e6e6711 fix(healthcheck): remove t.Parallel() from healthcheck tests (#7174) 2023-04-17 15:01:47 -05:00
Steven Masley 658246d5f2 chore: add workspace proxies to the backend (#7032)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-04-17 19:57:21 +00:00
Kira Pilot dc5e16ae22 feat: add success modal with token value to create token page (#7170)
* added token success modal

* added a test for new modal
2023-04-17 11:54:43 -07:00
Bruno Quaresma 76b5deea78 chore(site): Remove template editor out of experimental (#7165) 2023-04-17 14:40:21 -03:00
Ammar Bandukwala 80bf042528 chore(coderd): remove timing check (#7144) 2023-04-17 17:40:02 +00:00
Mathias Fredriksson b3b26a62f2 test(agent/reaper): Fix restructure issue (#7168)
In #7164 we accidentally removed the "in CI" check, this fixes it.
2023-04-17 17:39:10 +00:00
Bruno Quaresma bb3b8bab78 fix(site): Reset delete modal data when selected user changes (#7167) 2023-04-17 12:29:08 -05:00
Mathias Fredriksson bf0fed4f3f chore: Update pion/udp and improve parallel/non-parallel tests (#7164)
* test(all): Improve and fix subtests with parallell/nonparallel parents

* chore: Update pion/udp to fix buffer close
2023-04-17 20:23:10 +03:00
Ammar Bandukwala c6b2861493 feat: allow disabling stun addresses via env (#7066)
* feat: allow disabling stun addresses via env

Resolves #6791

* Specify a dummy access URL so the tunnel wouldn't start

* Document

---------

Co-authored-by: Kyle Carberry <kyle@carberry.com>
2023-04-17 17:20:26 +00:00
Cian Johnston 25c1e45930 chore(helm): add unit tests for setting labels / annotations on serviceaccount / deployment / pod (#7156)
* chore(helm): add unit tests for setting sa annotations

* chore(cli): also add test for labels / annotations / podLabels / podAnnotations
2023-04-17 16:49:25 +01:00
Kyle Carberry 26cfc18b74 fix: use proper deployment access setting name (#7162) 2023-04-17 10:01:51 -05:00
Mathias Fredriksson 51841e9e11 test(cli): Fix TestTemplatePush/UseWorkingDir bad use of chdir (#7160) 2023-04-17 17:58:25 +03:00
Bruno Quaresma 53f521aaf9 chore(site): Make requests when offline (#7161) 2023-04-17 14:44:38 +00:00
Muhammad Atif Ali 4061a254a5 docs: fix a broken link in docs/README.md (#7150) 2023-04-17 13:05:12 +00:00
Mathias Fredriksson 8b2aead7f4 test(coderd/rbac): Use static name for tests (#7155) 2023-04-17 12:17:18 +00:00
Bruno Quaresma d639e6b898 feat(site): Ask for missing template variables in the template editor (#7108) 2023-04-17 09:12:28 -03:00
Marcin Tojek c39c0dcc7c fix: select default option value (#7152) 2023-04-17 12:55:28 +02:00
Ammar Bandukwala 285646bf24 docs: disclaim write load for agent metadata (#7048)
* docs: disclaim write load for agent metadata

* Update docs/templates/agent-metadata.md

Co-authored-by: Muhammad Atif Ali <atif@coder.com>

* Update docs/templates/agent-metadata.md

Co-authored-by: Muhammad Atif Ali <atif@coder.com>

---------

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-04-16 05:46:04 +00:00
Kyle Carberry d3356fa48e fix: upgrade terraform in apk (#7146) 2023-04-14 20:10:17 -05:00
Eric Paulsen c37f22ba78 feat(helm): add labels for coder pod (#7139)
* feat(helm): add labels for coder pod

* feedback & syntax fix

* ordering

* fix: notation
2023-04-14 18:55:38 +00:00
am009 706326715d fix(docs): fix a wrong word. (#7113) 2023-04-14 18:32:38 +00:00
Ben Potter 9afbd152fc chore: fix one broken link (#7143)
* fix one broken link

* Fix the hopefully last broken link

---------

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-04-14 18:28:58 +00:00
Steven Masley 2137db0445 test: Handle Filter flake with ctx errors (#7119)
* test: Handle Fitler flake with ctx errors
* Add unit test to check filter for proper error
* Correctly return category of errors
2023-04-14 12:30:35 -05:00
Ammar Bandukwala c87ec484ff docs: restore supportLinks (#7142)
* docs: restore supportLinks

* fixup! docs: restore supportLinks
2023-04-14 17:28:34 +00:00
Kyle Carberry 7f12020229 fix: remove irrelevant help info from coder tokens create (#7135)
The additional text didn't help much, and made it much harder to script around.
2023-04-14 12:18:01 -05:00
Ammar Bandukwala f36a4a0b07 chore: fix race check for AgentMetadata test (#7141) 2023-04-14 20:02:44 +03:00
Muhammad Atif Ali 0e50afe4cf fix(docs): fix broken docs (#7138)
* fixing a lot of broken links

* more fixes

* add 0 as valid status codes

https://tools.ietf.org/html/rfc7231#section-6.3.1 --> 0 as status code
2023-04-14 11:11:51 -05:00
Kira Pilot 9ec16d4454 feat(UI): add workspace restart button (#7137)
* Refactor primary buttons

* refactor(site): Always show the main actions

* Remove tests that are testes on Storybook

* Fix tests

* Fix keys

* added restart btn

---------

Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
2023-04-14 08:48:05 -07:00
Bruno Quaresma 7bbbb91df5 refactor(site): Refactor workspace actions (#7124) 2023-04-14 15:28:52 +00:00
Muhammad Atif Ali 9c0f59e3e5 chore: Also check README.md for dead links (#7130) 2023-04-14 14:46:16 +00:00
Muhammad Atif Ali 69797add49 chore: turn on experiments while developing (#7121) 2023-04-14 17:42:03 +03:00
Kyle Carberry 0bbe1562f3 fix: adjust manifest for networking doc (#7136) 2023-04-14 09:36:23 -05:00
Muhammad Atif Ali bb43713d38 fix: VSCode desktop connection (#7120)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-04-14 17:32:18 +03:00
Marcin Tojek 942aba3a66 feat: expose agent stats via Prometheus endpoint (#7115)
* WIP

* WIP

* WIP

* Agents

* fix

* 1min

* fix

* WIP

* Test

* docs

* fmt

* Add timer to measure the metrics collection

* Use CachedGaugeVec

* Unit tests

* WIP

* WIP

* db: GetWorkspaceAgentStatsAndLabels

* fmt

* WIP

* gauges

* feat: collect

* fix

* fmt

* minor fixes

* Prometheus flag

* fix

* WIP

* fix tests

* WIP

* fix json

* Rx Tx bytes

* CloseFunc

* fix

* fix

* Fixes

* fix

* fix: IgnoreErrors

* Fix: Windows

* fix

* reflect.DeepEquals
2023-04-14 16:14:52 +02:00
Mathias Fredriksson e0689456cb fix(scripts): Use gh api to fetch ci logs more reliably (#7133) 2023-04-14 16:29:13 +03:00
Bruno Quaresma dafb7663c5 fix(site): Fix button text overflow (#7132) 2023-04-14 15:13:55 +02:00
Bruno Quaresma ad665cef91 fix(site): Load monaco locally (#7092) 2023-04-14 13:11:28 +00:00
Bruno Quaresma 17bb1a1ff1 chore(site): Upgrade storybook to 7.0.4 (#7127) 2023-04-13 21:36:20 +00:00
Colin Adler 085330ad96 fix(provisionerd): only heartbeat when logs aren't being flushed (#7110) 2023-04-13 14:02:10 -05:00
Colin Adler f5a8a27714 fix(healthcheck): prevent infinite loop if DERP message exchange fails (#7112) 2023-04-13 13:46:16 -05:00
Steven Masley 38e5b9679b chore: Rbac errors should be returned, and not hidden behind 404 (#7122)
* chore: Rbac errors should be returned, and not hidden behind 404

SqlErrNoRows was hiding actual errors
* Replace sql.ErrNoRow checks
* Remove sql err no rows check from dbauthz test
* Fix to use dbauthz system user
2023-04-13 13:06:16 -05:00
Steven Masley fa64c58e56 chore: Export all functions used by server cmd (#7118)
* chore: Export all functions used by server cmd

Required to make workspace proxy cmd
* Factor out httpservers and tracer
2023-04-13 09:07:19 -05:00
Cian Johnston 87fe16cde9 feat(cli): add --id parameter to templates init command (#7116)
This PR makes the following changes:

- Adds an --id parameter to coder templates init so that you can non-interactively initialize a specific example template by ID (e.g. folder name)
- Updates develop.sh and lima/coder.yaml to use this parameter to select the docker example template.
2023-04-13 15:02:49 +01:00
Colin Adler 17f692a89a fix(scaletest): correctly validate configs using SessionToken (#7111) 2023-04-12 17:36:05 -05:00
Ben Potter f517724caa chore: reorganize some docs (#7062)
* chore: move docs pages into corresponding folder

* chore: prioritize clouds in platforms list

* chore: fix networking docs links

* chore: rename to "docker in workspaces"

* mention CLI documentation

* fmt
2023-04-12 21:47:25 +00:00
Muhammad Atif Ali 114d4aac23 chore: update example templates to use display_name (#7001)
* add `display_name`

* fix typos and `terraform validate`

* update display_name

* Update examples/templates/aws-windows/main.tf

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/templates/aws-linux/main.tf

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/templates/azure-linux/main.tf

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/templates/azure-linux/main.tf

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/templates/do-linux/main.tf

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/templates/do-linux/main.tf

Co-authored-by: Ben Potter <me@bpmct.net>

* Update main.tf

* Update main.tf

* Update main.tf

* Update main.tf

* Update main.tf

---------

Co-authored-by: Ben Potter <me@bpmct.net>
2023-04-12 16:33:38 -05:00
Kira Pilot f6c89a2615 feat: differentiate new user registration from user login in the audit log (#7096)
* auditing register events

* fix tests

* update docs

* update comments

* Update coderd/audit/request.go

Co-authored-by: Colin Adler <colin1adler@gmail.com>

---------

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2023-04-12 11:46:16 -07:00
Rodrigo Maia d1d459cb79 feat(site): add advanced schedule settings to UI (#7061)
* feat: add advanced schedule settings

* Update site/src/pages/CreateTemplatePage/CreateTemplateForm.tsx

Co-authored-by: Dean Sheather <dean@deansheather.com>

* rename variable

* fix optionText css

---------

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-04-12 17:47:48 +00:00
Muhammad Atif Ali 264093a874 chore: add agent metadata to example templates (#7044)
* add `display_name`

* fix typos and `terraform validate`

* update display_name

* Add agent metadata

* add % to cpu usage

* update disk usage check script

* remove metadata from containers and pods workspaces

* removes disk metadata from container workspaces

---------

Co-authored-by: Ben <me@bpmct.net>
2023-04-12 12:05:16 -05:00
Ben Potter af24aea04f chore: reduce docker examples (#6849) 2023-04-12 16:26:03 +00:00
Mathias Fredriksson 770712e1f5 ci: Add script for fetching past test stats from CI (#7086)
Refs: #6677, #6675
2023-04-12 10:03:26 +00:00
Muhammad Atif Ali 531fd23fd2 fix(docs): fix broken markdown links (#7081)
* fix(docs): fix markdown docs links

More than half of them were actually valid links but, due to missing file extensions were flagged as invalid. I added a file extension, so it should pass now.

* Updated docgen to include extension
2023-04-11 15:05:51 -05:00
Colin Adler a44070e2ec feat(scaletest): allow scaletests to run using the host credentials (#7075) 2023-04-11 19:49:28 +00:00
Steven Masley 2585249014 chore: Move writeConfig to a cli middleware (#7093)
* chore: Move writeConfig to a cli middleware

Trying to reduce the server LoC, it's very long and unwieldy.
The workspace proxy code needs to replicate, and trying to reuse
as much as possible

* Move deprecation warnings too
2023-04-11 14:47:07 -05:00
Marcin Tojek e1db64a1e8 chore: bump up coder/tailscale (#7089) 2023-04-11 11:44:47 -05:00
Bruno Quaresma b86ed11bc0 refactor(site): Refactor the schedule controls in the workspace page (#7083) 2023-04-11 13:33:24 -03:00
Bruno Quaresma b92e7d4fab refactor(site): Refactor workspace schedule page (#7069) 2023-04-11 16:27:52 +00:00
Kevin Conley 4dd5d79412 fix: Parse CODER_GITAUTH_N_NO_REFRESH env var value instead of key (#7051) 2023-04-11 09:18:17 -05:00
Marcin Tojek 3b10e89047 Revert "fix: change auto-start to automatically update workspaces (#6053)" (#7084)
This reverts commit bdddc3e7ae.
2023-04-11 14:14:35 +00:00
Steven Masley 9d39371ee0 feat: Option to remove WorkspaceExec from owner role (#7050)
* chore: Add AllResources option for listing all RBAC objects
* Owners cannot do workspace exec site wide
* Fix FE authchecks to valid RBAC resources
2023-04-11 08:57:23 -05:00
Marcin Tojek ad2353c3d8 chore: improve syntax in metrics collector (#7085) 2023-04-11 13:50:34 +00:00
Muhammad Atif Ali 63af4c6ed1 chore: Add exceptions for markdown check (#7078)
* rename and run slack step on failure

* add exceptions
2023-04-11 13:15:44 +02:00
Ben Potter 45776e57f6 docs: remove RBAC section (#7040) 2023-04-10 21:57:00 -05:00
Muhammad Atif Ali fb44dc653e fix(ci): fix typo in cron-weekly.yaml (#7059)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-04-11 01:58:37 +00:00
Kyle Carberry 81e2b2500a feat: add level support for startup logs (#7067)
This allows external services like our devcontainer support to display
errors and warnings with custom styles to indicate failures to users.
2023-04-10 14:29:59 -05:00
Bruno Quaresma aa2468b16e fix(site): Handle rename a folder to a file (#7063) 2023-04-10 13:30:21 -03:00
Eric Paulsen e5c6ebdc96 docs: bump tf version in offline docs (#7065) 2023-04-10 11:04:31 -04:00
Ammar Bandukwala 4b99e2d07e feat: add YAML support to server (#6934) 2023-04-07 22:58:21 +00:00
Colin Adler a3c6cb1768 fix: don't query workspace in UpdateWorkspaceAgentConnectionByID (#7042) 2023-04-07 15:21:52 -05:00
Muhammad Atif Ali 592b84984f chore: Update code-server in example templates (#6806)
Update code-server from `4.8.3` to `4.11.0`
2023-04-07 12:09:46 -05:00
Muhammad Atif Ali 7e530b0652 chore: check for invalid markdown links in docs weekly (#6795)
* chore(ci): add an automatic check to verify markdown links. 

As per #6793, there are multiple broken links in our docs. This action will check if all markdown links are valid.

cc: @ammario @bpmct

* Revert "chore(ci): add an automatic check to verify markdown links. "

This reverts commit 294767e056.

* Create cron-weekly.yaml

* add workflow dispatch for testing

* fmt

* Update cron-weekly.yaml

* remove slack notification for now

* Add slack notification

* Update cron-weekly.yaml

* Add logs URL

* fmt
2023-04-07 16:50:08 +00:00
Marcin Tojek 3e250c6609 chore: clidocgen: generate consistent docs (#7047)
* chore: clidocgen: ensure same generated docs

* fix
2023-04-07 18:32:06 +02:00
Marcin Tojek 0347231bb8 feat: expose agent metrics via Prometheus endpoint (#7011)
* WIP

* WIP

* WIP

* Agents

* fix

* 1min

* fix

* WIP

* Test

* docs

* fmt

* Add timer to measure the metrics collection

* Use CachedGaugeVec

* Unit tests

* Address PR comments
2023-04-07 17:48:52 +02:00
Ammar Bandukwala dd85ea8977 feat: tolerate disconnects in agent metadata frontend (#6939) 2023-04-06 19:51:52 -05:00
Dean Sheather 5398150c25 chore: move workspace apps tests to new package (#7025)
* chore: move workspace apps tests to new package
* chore: move reconnecting pty to apptest package
2023-04-06 16:35:27 -05:00
Steven Masley b2892c3d17 test: Increase test coverage on auditable resources (#7038)
* test: Increase test coverage on auditable resources

When adding a new audit resource, we also need to add it to the
function switch statements. This is a likely mistake, now a unit
test will check this for you
2023-04-06 16:16:53 -05:00
Ammar Bandukwala 24d8644c0b chore: de-flake TestWorkspaceAgent_Metadata (round 2) (#7039)
This time, we keep the timing / "racey" tests, but avoid running
them in the harsher CI conditions.
2023-04-06 21:10:13 +00:00
Kyle Carberry e1149992d8 feat: support ansi colors in startup script logs (#7037)
This will help with beautiful output for devcontainers!
2023-04-06 12:39:09 -05:00
Ammar Bandukwala 2637f5501b chore: de-flake TestWorkspaceAgent_Metadata (#7036) 2023-04-06 17:20:16 +00:00
Kyle Carberry c68ab7d9a8 fix: support X-Forwarded-Host with CODER_REDIRECT_TO_ACCESS_URL (#7035)
Fixes #7026.
2023-04-06 12:07:24 -05:00
Mathias Fredriksson aa660e0631 feat(agentssh): Gracefully close SSH sessions on Close (#7027)
By tracking and closing sessions manually before closing the underlying
connections, we ensure that the termination is propagated to SSH/SFTP
clients and they're not left waiting for a connection timeout.

Refs: #6177
2023-04-06 19:57:30 +03:00
Colin Adler f4f40d0ed2 fix: increase workspace name randomess in tests (#7018) 2023-04-06 11:53:02 -05:00
Mathias Fredriksson 0224426e5b refactor(agent): Move SSH server into agentssh package (#7004)
Refs: #6177
2023-04-06 19:39:22 +03:00
Kyle Carberry 3ff2ae1b1a fix: output askpass to stderr (#7034)
This fixes askpass not outputting a prompt.
2023-04-06 11:32:43 -05:00
Marcin Tojek 5bd02917ec docs: Update description for mutable parameters (#7003) 2023-04-06 18:23:47 +02:00
Mathias Fredriksson 121c2bcde8 test(agent): Fix tests without cmd.Wait() (#7029) 2023-04-06 16:45:53 +03:00
Eric Paulsen 2da0702009 fix(helm): missing templating for deployment labels (#6869)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-04-06 17:03:21 +10:00
Colin Adler a32951c46a fix: reduce idle workspace queries (#7022) 2023-04-06 01:58:54 +00:00
Dean Sheather 63f9ef2480 chore: fix minor int coercion codeql vulnerability (#7024) 2023-04-05 21:43:24 +00:00
Dean Sheather c18ed6197c chore: fix trivy ci workflow (#7023) 2023-04-05 21:36:04 +00:00
Eric Paulsen 0167d76a7c docs: add helm example for OIDC_GROUP_MAPPING var (#7007)
* docs: add helm example for OIDC_GROU_MAPPING var

* fix: fmt
2023-04-05 21:05:48 +00:00
Colin Adler e0f7cf5ec6 chore: fix postGroupByOrganization swagger tag (#7021) 2023-04-05 20:17:36 +00:00
Colin Adler 391738cc25 chore: remove documented groups endpoint that doesn't exist (#7020) 2023-04-05 14:26:21 -05:00
Ben Potter 865c8b7c09 docs: additional kubernetes clusters (#7019)
* docs: additional kubernetes clusters

* fmt and change wording

* fmt
2023-04-05 14:03:36 -05:00
Dean Sheather eb66cc9f35 chore: move app proxying code to workspaceapps pkg (#6998)
* chore: move app proxying code to workspaceapps pkg

Moves path-app, subdomain-app and reconnecting PTY proxying to the new
workspaceapps.WorkspaceAppServer struct. This is in preparation for
external workspace proxies.

Updates app logout flow to avoid redirecting to coder-logout.${app_host}
on logout. Instead, all subdomain app tokens owned by the logging-out
user will be deleted every time you logout for simplicity sake.

Tests will remain in their original package, pending being moved to an
apptest package (or similar).

Co-authored-by: Steven Masley <stevenmasley@coder.com>
2023-04-05 13:41:55 -05:00
ElliotG 0069831e8d fix: use error log when failing provisioner job (#6812)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2023-04-05 13:30:53 -05:00
dependabot[bot] bf1a0791f7 chore: bump github.com/docker/docker from 20.10.17+incompatible to 20.10.24+incompatible (#7009)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-05 18:29:27 +00:00
Colin Adler 72c84c5b0a fix(loadtest): use cryptorand.String to generate user password (#7006) 2023-04-05 12:52:47 -05:00
Colin Adler 407f80a1ef fix(dbpurge): use dbauthz.AsSystemRestricted (#7017) 2023-04-05 17:48:39 +00:00
Steven Masley a361673ad8 fix: Include 'CODER' env var prefix on group mappings (#7015)
* fix: Include 'CODER' env var prefix on group mappings
* Unit test to force CODER prefix
2023-04-05 17:47:40 +00:00
Cian Johnston 00d468b964 feat(cli): add --output={text,json} to version cmd (#7010)
* feat(cliui): add TextFormat
* feat(cli): add --format={text,json} to version cmd
2023-04-05 13:16:05 +01:00
Cian Johnston 9c4ccd76a0 fix(coderd)!: add CODER_OIDC_IGNORE_USERINFO configuration option (#6922)
* add CODER_OIDC_IGNORE_USERINFO option
* chore: update docs for CODER_OIDC_IGNORE_USERINFO w.r.t ADFS
* fix!: codersdk: fix incorrectly named OIDC_GROUP_MAPPING -> CODER_OIDC_GROUP_MAPPING
2023-04-05 09:07:43 +01:00
sharkymark 929589ddfa docs: fixed incorrect agent metadata docs (#7005)
* docs: fixed incorrect agent metadata docs

* docs: prettier; fixed incorrect agent metadata docs
2023-04-04 15:50:27 -05:00
Steven Masley b4afbe7720 feat: Implement experiment gated CRUD for workspace proxies (#6928)
* feat: Implement basic moon crud
* chore: Implement enterprise endpoints for moons
2023-04-04 15:07:29 -05:00
Kyle Carberry 385a4262e2 fix: remove audit-logging flag from the server (#6991)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2023-04-04 12:11:10 -05:00
Bruno Quaresma 29e9b9e663 feat(site): Add change version for template admins (#6988) 2023-04-04 10:25:49 -03:00
Kyle Carberry c12bc39821 fix: always show a newly created workspace at the top of the list (#6984)
Fixes #5795.
2023-04-04 08:24:04 -05:00
Bruno Quaresma 46f42ea9ac fix(site): Prompting user for missing variables (#7002) 2023-04-04 13:15:35 +00:00
Dean Sheather e33941b7c2 feat: allow disabling autostart and custom autostop for template (#6933)
API only, frontend in upcoming PR.
2023-04-04 12:48:35 +00:00
Marcin Tojek 083fc89f93 feat: accept immutable parameters when used first time (#7000)
* Backend fixes

* CLI: adjust update flow
2023-04-04 14:22:46 +02:00
Josh Vawdrey e84061e2be feat(provisioner): bump the maximum terraform version (#6995) 2023-04-04 06:19:48 +00:00
Steven Masley a96376e02e chore: Add "required" to allow requring url params (#6994) 2023-04-03 20:59:59 -05:00
Dean Sheather 3cca30c770 chore: make version.sh work in forks (#6993) 2023-04-04 01:13:32 +00:00
Dean Sheather 34593e3944 chore: ticket provider interface (#6915) 2023-04-04 00:59:41 +00:00
Colin Adler e0f7f011d8 fix(healthcheck): ensure STUNOnly nodes aren't marked as unhealthy (#6990) 2023-04-03 16:14:48 -05:00
Rodrigo Maia a1371dbd60 feat(site): move template's readme to its own tab (#6863)
* feat(site): display template's readme first on template page

* chore: prettier

* move readme to a new docs tab

* test

* prettier

* fix tests

* prettier
2023-04-03 18:18:28 +00:00
Colin Adler 95e578ba10 fix: derp healthcheck test flake (#6982) 2023-04-03 11:36:26 -05:00
Kyle Carberry 861d4afdd8 fix: update tailscale to remove websocket logs (#6981) 2023-04-03 16:28:49 +00:00
Kyle Carberry bc18f6c113 fix: add CODER_AGENT_TAILNET_LISTEN_PORT for specifying a static tailnet port (#6980)
Fixes #5175.
2023-04-03 16:20:19 +00:00
Kyle Carberry 4ee01dc95c fix: remove orphan rbac warning message (#6979)
The request will fail if the user doesn't have permissions, so it seems
useless to output this.
2023-04-03 11:15:56 -05:00
Kyle Carberry 55c0b26977 fix: update status text for the workspace progress bar (#6977)
Fixes #4691.
2023-04-03 11:00:56 -05:00
dependabot[bot] 8e69f02695 chore: bump axios from 0.26.1 to 1.3.4 in /site (#6954)
Bumps [axios](https://github.com/axios/axios) from 0.26.1 to 1.3.4.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v0.26.1...v1.3.4)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-03 10:30:39 -05:00
Ben Potter ded931f0f6 docs: rename quickstart to platforms + Kubernetes guide (#6972)
* rename quickstart to platforms + Kubernetes guide

* fmt
2023-04-03 09:51:07 -05:00
Kyle Carberry 2d051094e7 fix: ignore deleted workspaces in global stats (#6973)
Fixes #6568.
2023-04-03 14:46:09 +00:00
Bruno Quaresma aa43f998d4 feat(site): Promote template version (#6929) 2023-04-03 14:27:17 +00:00
Steven Masley fab8da633b chore: Merge more rbac files (#6927)
* chore: Merge more rbac files

- Remove cache.go -> authz.go
- Remove query.go -> authz.go
- Remove role.go -> roles.go

* Order imports

* fmt
2023-04-03 09:05:06 -05:00
Ben Potter 333718d1fa docs: remove mention of support links (#6970)
* docs: remove mention of support links

* fmt
2023-04-03 13:18:28 +00:00
Marcin Tojek 633dfbdb2e feat: rich parameters: introduce display_name (#6919)
* model

* DB

* fix: DisplayName

* proto

* Proto

* Update go dep

* fixme

* fix format

* config

* fmt

* fix

* Fix

* fix

* chore(UI): redirecting from workspace page if 404 (#6880)

* model

* CLI: Display parameter

* fix

* update dep

* fix

* fix

* fix

* UI changes

* fmt

---------

Co-authored-by: Kira Pilot <kira@coder.com>
2023-04-03 14:37:47 +02:00
Mathias Fredriksson d9d44c1188 ci: Print go test stats (#6855)
Fixes #6676
2023-04-03 11:07:25 +00:00
Colin Adler 7738274b3e feat(coderd): add DERP healthcheck (#6936) 2023-04-03 06:28:42 +00:00
Colin Adler f4d16a1ae5 fix: add span.SetStatus to codersdk.Request (#6964) 2023-04-03 05:52:42 +00:00
dependabot[bot] 47afafa4d4 chore: bump github.com/klauspost/compress from 1.15.15 to 1.16.3 (#6948)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-03 00:35:35 -05:00
Colin Adler a29fc7dd6f chore: update otel to v1.14.0 (#6963) 2023-04-03 00:31:39 -05:00
dependabot[bot] f6f927e44f chore: bump github.com/go-playground/validator/v10 from 10.11.0 to 10.12.0 (#6950)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-03 04:59:49 +00:00
Colin Adler 8683169e71 fix: agent metadata flake (#6962) 2023-04-03 04:45:23 +00:00
dependabot[bot] d2bfa2b9a0 chore: bump aquasecurity/trivy-action from 0.9.1 to 0.9.2 (#6945)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-02 23:37:06 -05:00
dependabot[bot] 390f29cf8c chore: bump actions/stale from 7.0.0 to 8.0.0 (#6944)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-02 23:32:22 -05:00
Eric Paulsen caec0b8aae rm: mac from docker quickstart (#6958) 2023-04-01 22:31:53 -05:00
dependabot[bot] 31690c4b3d chore: bump @xstate/react from 3.0.1 to 3.2.1 in /site (#6955)
Bumps [@xstate/react](https://github.com/statelyai/xstate) from 3.0.1 to 3.2.1.
- [Release notes](https://github.com/statelyai/xstate/releases)
- [Commits](https://github.com/statelyai/xstate/compare/@xstate/react@3.0.1...@xstate/react@3.2.1)

---
updated-dependencies:
- dependency-name: "@xstate/react"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-01 16:37:57 -05:00
Ammar Bandukwala 512fdbf634 chore: debounce agent watch-metadata stream (#6940) 2023-04-01 16:36:21 -05:00
dependabot[bot] e40b0778e9 chore: bump crate-ci/typos from 1.13.14 to 1.14.3 (#6942)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.13.14 to 1.14.3.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.13.14...v1.14.3)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-01 16:35:19 -05:00
dependabot[bot] e60460b120 chore: bump jaxxstorm/action-install-gh-release from 1.9.0 to 1.10.0 (#6943)
Bumps [jaxxstorm/action-install-gh-release](https://github.com/jaxxstorm/action-install-gh-release) from 1.9.0 to 1.10.0.
- [Release notes](https://github.com/jaxxstorm/action-install-gh-release/releases)
- [Commits](https://github.com/jaxxstorm/action-install-gh-release/compare/v1.9.0...v1.10.0)

---
updated-dependencies:
- dependency-name: jaxxstorm/action-install-gh-release
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-01 16:35:11 -05:00
dependabot[bot] 5200591264 chore: bump actions/setup-go from 3 to 4 (#6946)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-01 16:34:58 -05:00
dependabot[bot] 87d64baf7a chore: bump golang.org/x/crypto from 0.6.0 to 0.7.0 (#6949)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/golang/crypto/releases)
- [Commits](https://github.com/golang/crypto/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-01 16:34:50 -05:00
Ammar Bandukwala 34debbf837 fix(agent): prevent goroutine pile up in reportMetadataLoop (#6957) 2023-04-01 16:34:42 -05:00
Ammar Bandukwala ccadd0f286 docs: tweak some words and fix a typo in agent-metadata.md 2023-03-31 23:20:30 +00:00
Kyle Carberry 84956c16cc fix: reduce spacing when agent metadata doesn't exist (#6937) 2023-03-31 22:08:42 +00:00
Ammar Bandukwala ca4fa81570 feat: add agent metadata (#6614) 2023-03-31 15:26:19 -05:00
Ammar Bandukwala c191692751 chore(cli): send help to stdout (#6865)
Minimizes pesky `2>&1` when working with help.
2023-03-31 18:51:55 +00:00
Ammar Bandukwala c2a96bdc7c fix: compilation failure with (*OptionSet).SetDefaults
This slipped through CI due to a merge race.
2023-03-31 18:02:55 +00:00
Ammar Bandukwala 599699b3a9 fix: truly allow overridding default string array (#6874) 2023-03-31 12:12:03 -05:00
Cian Johnston 96ff400587 chore(clibase): add some more tests for parsing options from env (#6930) 2023-03-31 17:21:56 +01:00
Steven Masley ce51435507 chore: Merge some rbac files, move some functions around (#6916)
* chore: Merge some rbac files, move some functions around

* Fix imports
2023-03-31 09:46:38 -05:00
Steven Masley 27e17ff2c3 chore: Remove unused Experimental field (#6924) 2023-03-31 09:44:29 -05:00
Kyle Carberry cd807bc0c8 fix: delete old addresses from the active derp mesh mapping (#6926) 2023-03-31 14:25:01 +00:00
Cian Johnston 334d9820fa fix(coderd): update provisionderd authz policy to allow updating user data (#6925) 2023-03-31 15:11:07 +01:00
Bruno Quaresma 90e2bab078 feat(site): Display workspace build error + option to retry in debug mode (#6903) 2023-03-31 14:01:12 +00:00
Steven Masley 901045a95f fix: FE show correct config-ssh prefix (#6904)
* fix: Push correct ssh prefix to FE
2023-03-31 08:48:44 -05:00
Kira Pilot a364318462 chore(UI): redirecting from workspace page if 404 (#6880) 2023-03-31 06:31:48 -07:00
Marcin Tojek 56f00a82e1 chore: update sqlc to v1.17.2 (#6920)
* WIP

* chore: Update sqlc to v1.17.2
2023-03-31 14:05:20 +02:00
Marcin Tojek 2612e32bac chore: image for support links (#6902) 2023-03-30 18:07:27 +00:00
Kira Pilot 3b52d4f336 chore(UI): remove template link from workspaces page row (#6882)
* chore(UI): remove template link from workspaces page row

* remove stack and span as per PR comment
2023-03-30 10:32:23 -07:00
Kyle Carberry b5f5740d0b chore: ensure agent conn routine is closed before exit (#6900)
This caused a leak in `main`!
2023-03-30 17:20:14 +00:00
Kyle Carberry e496bdb687 chore: update slog to fix local leak with http.Transport (#6899) 2023-03-30 12:13:15 -05:00
Kyle Carberry a63c97b8de chore: wrap audit logs in a mutex to fix data race (#6898)
This was seen in `main`!
2023-03-30 12:13:03 -05:00
Kyle Carberry 5780006adb chore: use http-swagger/v2 for go:embed to reduce binary size (#6897)
I'm testing how much this will reduce the size, but it should
be by a few MB!
2023-03-30 16:46:58 +00:00
Cian Johnston afcc179244 chore: fix duplicated sentence in docs/auth.md (#6895) 2023-03-30 16:29:57 +00:00
Kyle Carberry 8f55f5c28b chore: ensure go.mod has proper references to forked deps (#6893)
There were a few that have been merged upstream!
2023-03-30 11:19:11 -05:00
Ben Potter 5953a46785 docs: Open in Coder (#6859)
* docs: git auth via template

* add page

* docs: Open in Coder

* fmt
2023-03-30 16:12:47 +00:00
Kyle Carberry a6b7e8c43a chore: use an older version of fastclock to resolve leak (#6892) 2023-03-30 10:58:56 -05:00
Kyle Carberry 04e404e448 chore: dial the remote socket continually until connect (#6891)
It's possible that the command starts but the socket isn't ready
even when the file exists.
2023-03-30 15:36:23 +00:00
Kyle Carberry 5686fc9983 chore: skip chdir template push test on windows (#6890)
See https://github.com/coder/coder/actions/runs/4565958214/jobs/8057842941
2023-03-30 10:21:13 -05:00
Kyle Carberry 401b9276ae chore: clone styles to prevent race (#6888)
See https://github.com/coder/coder/actions/runs/4565541977/jobs/8056830691?pr=6885
2023-03-30 10:18:24 -05:00
Kyle Carberry 5c1dc1b7fe fix: iterate through all workspace updates on logs overflow (#6885)
This was causing some flakes!
2023-03-30 10:05:45 -05:00
Kyle Carberry e470162305 chore: move away from set-output in GitHub Actions (#6884)
This is deprecated! See:
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
2023-03-30 09:58:56 -05:00
Kyle Carberry 1f600fc526 chore: use defer instead of t.Cleanup for chdir (#6887)
This _might_ resolve the races in `TestTemplatePush`.
2023-03-30 09:48:03 -05:00
Bruno Quaresma b26f30688f feat(site): Duplicate template (#6853) 2023-03-30 11:42:29 -03:00
Kyle Carberry 6378294071 chore: upgrade from deprecated protobuf import (#6883)
This was displaying a warning when running `go get ./...`.
2023-03-30 14:17:44 +00:00
Marcin Tojek 0ba200c2a1 feat: Enable workspace debug logging (#6838)
* feat: Enable workspace debug logging

* Fix

* Fix

* Fix

* fix

* fix

* Enable RBAC

* unit tests

* Fix

* fix

* fix

* fix

* more tests

* fix: workspacebuild_test use roles

* fix: swagger comment

* fix: ctx.Done

* fix: address PR comments

* break loop
2023-03-30 16:00:33 +02:00
Dean Sheather 665b84de0d feat: use app tickets for web terminal (#6628) 2023-03-30 23:24:51 +10:00
Muhammad Atif Ali a07209efa1 fix: very small typo (#6877) 2023-03-30 07:56:19 -05:00
Bruno Quaresma 7d7aa789b3 fix(site): Only patch version name if name is changed (#6878) 2023-03-30 12:22:55 +00:00
Bruno Quaresma d8762c676f feat(site): Show main.tf file first on template files page (#6854) 2023-03-30 11:33:42 +00:00
Marcin Tojek b120247213 fix: extend regex for template version name (#6876) 2023-03-30 13:27:58 +02:00
Cian Johnston 563c3ade06 feat: allow configuring OIDC email claim and OIDC auth url parameters (#6867)
This commit:

- Allows configuring the OIDC claim Coder uses for email addresses (by default, this is still email)
- Allows customising the parameters sent to the upstream identity provider when requesting a token. This is still access_type=offline by default.
- Updates documentation related to the above.
2023-03-30 09:36:57 +01:00
Ammar Bandukwala 6981f89cd8 Revert "fix: allow overridding default string array (#6873)"
This reverts commit 58d650c2bb.
2023-03-29 20:24:07 -05:00
Ammar Bandukwala 58d650c2bb fix: allow overridding default string array (#6873)
* fix: allow overridding default string array

* Cleanup code

* fixup! Cleanup code

* fixup! Cleanup code

* fixup! Cleanup code

* fixup! Cleanup code
2023-03-30 01:09:20 +00:00
dependabot[bot] 1c7adc0ebd chore: bump github.com/fatih/color from 1.14.1 to 1.15.0 (#6868)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-29 21:42:35 +00:00
Rodrigo Maia 3d91fe8895 fix(site): fix redirection to login after logout/change password (#6870)
* fix(site): fix redirection to login after logout/change password

* chore: add login verification assert

* prettier
2023-03-29 21:39:56 +00:00
Steven Masley 90da09bc2c chore: Make deployment admin page show better durations (#6856)
* chore: Make deployment admin page show better durations

Also fix group mappings
2023-03-29 16:26:20 -05:00
Colin Adler 872037bf85 feat: allow http2 in coder server (#6871) 2023-03-29 14:45:57 -05:00
Bruno Quaresma 175dde1c52 chore(site): Try to fix flake test (#6848) 2023-03-29 16:10:04 -03:00
Mathias Fredriksson 90d18dd2e5 fix(agent): Close stdin and stdout separately to fix pty output loss (#6862)
Fixes #6656
Closes #6840
2023-03-29 21:58:38 +03:00
dependabot[bot] 349bfad2e9 chore: bump github.com/opencontainers/runc from 1.1.2 to 1.1.5 (#6864)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-29 17:46:54 +00:00
Ben Potter 311327cb11 docs: git auth via template (#6850) 2023-03-28 17:11:30 -05:00
Steven Masley a8346bd8ea feat: Allow unsetting ssh config options from deployment (#6847)
This allows deleting ssh config options
2023-03-28 11:06:42 -05:00
Ammar Bandukwala 1176256a44 feat: improve CLI error messages (#6778) 2023-03-28 16:03:34 +00:00
Cian Johnston b38d1ed4a5 Revert "fix(UI): redirect if user is not permissioned to see workspace (#6786)" (#6836)
This reverts commit fc21e159b8.
2023-03-28 09:38:39 +00:00
Mathias Fredriksson 891bbda995 fix(agent): More protection for lost output of SSH PTY commands (#6833)
Fixes #6656 (part 2)
2023-03-28 09:11:15 +00:00
Ammar Bandukwala 164528176a fix(clibase): allow empty values to unset defaults (#6832) 2023-03-28 01:58:06 +00:00
Ammar Bandukwala 773580c7c9 fix: correct minor formatting issues in CLI (#6813)
* fix: remove excess newlines from server startup

* Don't log benign closed pipe errors
2023-03-28 01:01:25 +00:00
Ammar Bandukwala 42b3d90221 chore: rename "InsertOrUpdate" to Upsert around the codebase (#6823)
* chore: rename "InsertOrUpdate" to Upsert around the codebase

The shorter name uses up less line width, is easier to read
and is used more often.

* make gen
2023-03-28 00:55:10 +00:00
Ammar Bandukwala f88f273cd6 fix: resolve template name from working directory "." (#6822) 2023-03-27 22:58:20 +00:00
Kyle Carberry a2d3635207 fix: update tailscale to resolve h2 vs http/1.1 (#6827)
DERP will always fallback to WebSockets if h2 is chosen now!
2023-03-27 21:05:10 +00:00
Kyle Carberry 5e01e6e448 fix: check if logs are completed before publishing (#6824) 2023-03-27 15:50:53 -05:00
Muhammad Atif Ali 48f9521fcb fix: fix PATH of flyctl cli in fly-docker-image template (#6772)
* Update main.tf

Upgrade coder provider

* fix path in startup_script

* Revert "Update main.tf"

This reverts commit 5037f87a36.
2023-03-27 20:04:03 +00:00
Kyle Carberry ad0c0df104 chore: update tailscale to fix http2 upgrade (#6811)
See https://github.com/coder/tailscale/pull/15
2023-03-27 14:22:11 -05:00
Kyle Carberry ffb4cd5962 chore: fix race when expecting parameters (#6814)
See https://github.com/coder/coder/actions/runs/4532378002/jobs/7983840014
2023-03-27 14:18:33 -05:00
Bruno Quaresma dd4e1f74ff feat(site): Ask for version name and if it is active when publishing a new version on editor (#6756) 2023-03-27 17:26:57 +00:00
Ammar Bandukwala b439c3e167 fix: permit SSH by default when startup script fails (#6798) 2023-03-27 14:59:58 +00:00
Steven Masley 7fa5afa268 fix: Users that can update a template can also read the file (#6776)
* fix: Users that can update a template can also read the file

This currently has a strange RBAC story. An issue will be filed
to streamline this.
This is a hotfix to resolve current functionality

* Only showsource code tab if the user has permission to edit the template


---------

Co-authored-by: Bruno Quaresma <bruno_nonato_quaresma@hotmail.com>
2023-03-27 09:21:41 -05:00
Kira Pilot fc21e159b8 fix(UI): redirect if user is not permissioned to see workspace (#6786)
* fix(UI): redirect if user is not permissioned to see workspace

* fix tests
2023-03-27 06:25:31 -07:00
Kira Pilot 08afe3cfad chore(UI): remove private icon from apps in dashboard (#6801)
* chore(UI): remove private icon from apps in dashboard

* clean up redudant snapshots
2023-03-27 06:24:42 -07:00
Muhammad Atif Ali 0b22c88538 fix(docs): fix broken links (#6796)
* Update change-management.md to fix broken links

* Update offline.md

* Update docker-in-docker.md

* fmt
2023-03-27 09:21:47 -04:00
Marcin Tojek 8187992e7f fix: Validate template version name (#6804)
* WIP

* Update

* Validation
2023-03-27 13:54:01 +02:00
Ammar Bandukwala e0cc4ee7f8 fix: correct english in CreateWorkspacePage (#6797) 2023-03-27 08:49:18 -03:00
Bruno Quaresma e3a965bcc9 fix(site): Add page header into permissions page (#6760) 2023-03-27 11:32:20 +00:00
Eric Paulsen b287ec5eec docs: clarify mac docker install (#6788)
* clarify mac docker install

* point MacOS users to standalone binary

* macOS
2023-03-26 12:39:20 +00:00
Ammar Bandukwala 6c0f37c28e fix: probably fix lipgloss race condition (#6784) 2023-03-24 21:24:51 +02:00
Mathias Fredriksson 76bdde7f1b fix(agent): Prevent SSH TTYs from losing command output on exit (#6777) 2023-03-24 18:23:41 +00:00
Kyle Carberry d7d210de36 Revert "chore: update tailscale to fix http2 upgrade (#6761)" (#6779)
This reverts commit 622fc6d9c2.
2023-03-24 12:40:05 -05:00
Kyle Carberry 622fc6d9c2 chore: update tailscale to fix http2 upgrade (#6761)
See https://github.com/coder/tailscale/pull/15
2023-03-24 11:20:21 -05:00
Marcin Tojek c9cbc63cd4 feat: Fine-tune logs presentation (#6771)
* Process debug mode logs

* Debug logs are grey

* Fix
2023-03-24 13:29:18 +01:00
Marcin Tojek c7fb5f960c feat: preserve original order of rich parameters (#6747)
* WIP

* orderedParameters

* fix

* WIP

* TestS
2023-03-24 09:37:27 +01:00
Ammar Bandukwala 9822745365 fix: accept CODER_AGENT_TOKEN (#6765) 2023-03-23 18:38:15 -05:00
Ammar Bandukwala 2bd6d2908e feat: convert entire CLI to clibase (#6491)
I'm sorry.
2023-03-23 17:42:20 -05:00
Bruno Quaresma b71b8daa21 fix(site): Add helper text and prevent undefined when deleting empty value (#6757) 2023-03-23 20:44:40 +00:00
Kyle Carberry 2383f64d89 fix: add dbauthz for streaming startup logs (#6758)
This was causing logs to end early!
2023-03-23 15:02:29 -05:00
Bruno Quaresma 88e24db643 refactor(site): Group template permissions, settings and variables under a settings layout (#6737) 2023-03-23 16:43:12 -03:00
Kyle Carberry cb7375450b feat: add startup script logs to the ui (#6558)
* Add startup script logs to the database

* Add coderd endpoints for startup script logs

* Push startup script logs from agent

* Pull startup script logs on frontend

* Rename queries

* Add constraint

* Start creating log sending loop

* Add log sending to the agent

* Add tests for streaming logs

* Shorten notify channel name

* Add FE

* Improve bulk log performance

* Finish UI display

* Fix startup log visibility

* Add warning for overflow

* Fix agent queue logs overflow

* Display staartup logs in a virtual DOM for performance

* Fix agent queue with loads of logs

* Fix authorize test

* Remove faulty test

* Fix startup and shutdown reporting error

* Fix gen

* Fix comments

* Periodically purge old database entries

* Add test fixture for migration

* Add Storybook

* Check if there are logs when displaying features

* Fix startup component overflow gap

* Fix startup log wrapping

---------

Co-authored-by: Asher <ash@coder.com>
2023-03-23 14:09:13 -05:00
Steven Masley a6fa8cac58 chore: add typescript api for ssh config (#6741)
* chore: add typescript api for ssh config
2023-03-23 17:46:39 +00:00
Bruno Quaresma 8857971552 feat(coder): Add PATCH /templateversions/:templateversion endpoint (#6698) 2023-03-23 13:26:50 -03:00
Kyle Carberry ed9a3b9251 fix: use a background context when piping derp connections (#6750)
This was causing boatloads of connects to reestablish every time...

See https://github.com/coder/coder/issues/6746
2023-03-23 09:54:07 -05:00
Eric Paulsen 7949db8e03 docs: add GHE token & auth URLs (#6751)
* docs: add GHE token & auth URLs

* cleanup
2023-03-23 09:53:42 -05:00
Bruno Quaresma eaacc26da7 fix(site): Fix missing parameters detection on update workspace (#6740) 2023-03-23 08:05:19 +01:00
Kyle Carberry dab4a0e6ef fix: add ResourceUserData to provisionerd to allow git auth (#6743)
This was breaking passing a git auth token through!
2023-03-22 17:23:49 -05:00
Kira Pilot 25e92fd2f4 fix(audit): audit login/logout for new 3rd-party auth (#6733)
* fix(audit): audit login/logout for new 3rd-party auth

* no longer auditing unknown users
2023-03-22 12:52:13 -07:00
Kyle Carberry df31636e72 feat: pass access_token to coder_git_auth resource (#6713)
This allows template authors to leverage git auth to perform
custom actions, like clone repositories.
2023-03-22 19:37:08 +00:00
Colin Adler 79ae7cd639 chore: add artifacthub-repo.yml (#6739) 2023-03-22 19:09:40 +00:00
Colin Adler c1e1c47c45 chore: bump github.com/u-root/u-root (#6738) 2023-03-22 13:52:50 -05:00
Eric Paulsen c71fa498b5 feat: podAnnotations (#6703)
* feat: podAnnotations

* rm: test values

* feedback

* fix: unknown revision
2023-03-22 14:35:24 -04:00
Steven Masley 250ee17933 fix: Page offset on workspace pagination was incorrect (#6693)
* fix: Page offset on workspace pagination was incorrect
2023-03-22 18:17:49 +00:00
Kira Pilot 1ccbd54ea2 chore(UI): update autocomplete no options text (#6735) 2023-03-22 11:14:07 -07:00
Marcin Tojek f1d7809ef0 chore: update terraform-provider-coder to v0.6.21 (#6736) 2023-03-22 18:04:56 +00:00
Kyle Carberry ad9c9b468f fix: block updating mutable parameters (#6717) 2023-03-22 11:05:04 -05:00
Steven Masley ab764db8c8 chore: dbgen passing nil slices to postgres is not valid (#6714) 2023-03-22 09:10:49 -05:00
Dean Sheather 5460ab4ba6 chore: switch to new wgtunnel via tunnelsdk (#6489) 2023-03-22 13:13:48 +00:00
Marcin Tojek e85a17b0c8 docs: describe list of strings (#6719) 2023-03-22 07:45:26 -05:00
Kyle Carberry 38d278ac46 fix: use the default value for a rich parameter if unset (#6715)
This fixes an error thrown on the workspace settings page when
a new parameter is added and the workspace hasn't been built yet.
2023-03-22 00:02:55 +00:00
Kyle Carberry abe1e89f80 chore: increase parallelism of TestWorkspaceQuota (#6710)
This does a lot of build operations, so having multiple provisioner
daemons is great.

We were actually approaching the ceiling here for test duration!
2023-03-21 22:44:01 +00:00
Bruno Quaresma 5cbe360176 fix(site): Fix CSP directives for monaco (#6709) 2023-03-21 12:51:02 -07:00
Colin Adler 00860cf1c8 feat: add group mapping option for group sync (#6705)
* feat: add group mapping option for group sync

* fixup! feat: add group mapping option for group sync
2023-03-21 14:25:45 -05:00
Bruno Quaresma 120bc4b750 refactor(site): Only show status after first edition (#6701) 2023-03-21 16:23:33 -03:00
Kyle Carberry 7e854adbb3 fix: poll audit logs to ensure write is last (#6708) 2023-03-21 19:19:09 +00:00
Kyle Carberry 71eecb3515 chore: embed build info in the html to reduce requests (#6605)
This will reduce a request on every page load of Coder!
2023-03-21 19:04:54 +00:00
Ben Potter 74be9c6c55 fix: dallas region in fly.io template (#6700) 2023-03-21 14:04:04 -05:00
Josh Vawdrey 97f77c4507 feat: allow DERP headers to be set (#6572)
* feat: allow DERP headers to be set

* chore: remove custom flag

* Clone DERP header on client create

* Adjust to use interface to cast headers

---------

Co-authored-by: Kyle Carberry <kyle@carberry.com>
2023-03-21 18:43:20 +00:00
Eric Paulsen d8aee26776 docs: clean up OIDC duplicates (#6583)
* docs: clean up OIDC duplicates

* make fmt

* add: upgrade command
2023-03-21 13:40:20 -05:00
Kyle Carberry e1c755be81 chore: remove fast metric cache interval for apps tests (#6702)
This wasn't helping CI run fast, that's for sure!
2023-03-21 18:13:34 +00:00
Kyle Carberry aaa3b31a0b chore: add echo helper to create an agent with token (#6576)
This should reduce some LOC and duplication in tests!
2023-03-21 18:03:38 +00:00
Kyle Carberry d05b48267a fix: update tailscale to resolve websocket stun fallback (#6696)
See https://github.com/coder/tailscale/pull/14
2023-03-21 12:37:34 -05:00
Bruno Quaresma 29d71bb3dd feat(site): Add source code tab on template page, group buttons and add edit file option (#6681) 2023-03-21 16:52:42 +00:00
Bruno Quaresma f97c22540a fix: Only show mutable parameters on workspace settings form (#6690) 2023-03-21 13:47:54 -03:00
Kyle Carberry 247470b1d6 fix: increase timeout of CreateTemplatePage initial render (#6694)
This might fix some test flakes we've been seeing!
2023-03-21 13:24:07 -03:00
Kyle Carberry 1b35ac80f2 fix: ensure agent DisconnectedAt is greater than or equal LastConnectedAt (#6692)
See https://github.com/coder/coder/actions/runs/4471502401/jobs/7856475920
2023-03-21 11:08:39 -05:00
Marcin Tojek fce8a4adf0 feat: preserve order of rich parameters (#6689)
* WIP

* TDD

* Implement

* WIP
2023-03-21 16:28:17 +01:00
Steven Masley 2321160c62 feat: Dbauthz is now default, remove out of experimental (#6650)
* feat: dbauthz always on, out of experimental
* Add ability to do rbac checks in unit tests
* Remove AuthorizeAllEndpoints
* Remove duplicate rbac checks
2023-03-21 09:10:22 -05:00
Dean Sheather 8aae0b64d3 chore: avoid logging http.ErrAbortHandler panics (#6686) 2023-03-21 03:51:21 +00:00
Ben Potter 4bf012cefb fix: typo in kubernetes template (#6683) 2023-03-20 22:39:45 +00:00
Steven Masley 65945aef16 chore: Return copied templates to prevent reference issues (#6679) 2023-03-20 13:13:21 -05:00
Bruno Quaresma cb846bab46 fix(site): Show job error on updating template variables (#6674) 2023-03-20 12:51:59 -03:00
Marcin Tojek de83723310 feat: show Terraform error details (#6643) 2023-03-20 13:23:40 +00:00
Bruno Quaresma a4d86e9d78 fix(site): Don't handle 304 as error (#6655) 2023-03-20 10:08:06 -03:00
Cian Johnston 331a49bf75 fix: dbauthz: fix RBAC call for GetTemplateVersionVariables (#6670)
In GetTemplateVersionVariables we were effectively asking the provisionerd role to call rbac.ActionCreate on rbac.ResourceTemplate, which will never work. Updated this to be rbac.ActionRead instead.
2023-03-20 10:22:16 +00:00
Eric Paulsen 39510f4163 docs: add openshift install (#6165)
* docs: add openshift install

* make: fmt

* Apply suggestions from code review

Update securityContext: set project-specific uid/gid, set readOnlyRootFilesystem=false

* add steps for creating compatible image and template

* Update docs/install/openshift.md

* make fmt

* docs: make changes on feedback

* combine helm steps

---------

Co-authored-by: Cian Johnston <cian@coder.com>
2023-03-20 03:48:53 -05:00
Eric Paulsen fadeb2ba3a docs: add k8s & aws to offline Dockerfile (#6663) 2023-03-20 03:47:36 -05:00
Muhammad Atif Ali 856a8028a5 chore: update fly-docker-image example template (#6661)
* update fly-docker-image example template

* Add unites for volume storage
2023-03-19 14:55:11 -05:00
Kyle Carberry c3fb1b325f feat: add owner_oidc_access_token to coder_workspace data source (#6042)
See the discussion in Discord here:
https://discord.com/channels/747933592273027093/1071182088490987542/1071182088490987542

Related provider PR: coder/terraform-provider-coder#91
2023-03-17 15:25:08 -05:00
Bruno Quaresma ca067cf004 feat(site): Support list(string) rich parameter field (#6653) 2023-03-17 18:53:11 +00:00
Kira Pilot 090e37fc46 feat(audit): auditing token addition and removal (#6649)
* auditing tokens

* adding diffs for token auditing

* added test

* generating docs

* auditing owner field
2023-03-17 10:41:44 -07:00
Kira Pilot 5b07f1e2a3 feat(tokens): improve delete confirmation dialog (#6651) 2023-03-17 10:29:51 -07:00
Marcin Tojek db40c29f26 fix: CLI do not ignore autostop (#6647)
* fix: CLI do not ignore autostop

* make gen
2023-03-17 18:14:46 +01:00
Muhammad Atif Ali e6d52b07b7 docs: add template to provision docker image based workspaces on fly.io (#6526)
* add fly.io example

* fix: `fly_volume` does not allow using - in name.

fix: `fly_volume` does not allow using - in the name.

* fix: provider versions  and settings

* fix: valid `fly_app` name

* chore: ipv6 is not used

* fix: names

strangely `fly_volume` does not allow `-` and `fly_app` does not allow `_`.

* chore: update max RAM

* add fly-auth-api managed variables

* Update README.md

* improve setup flow

- user is not prompted in UI for default values
- org slug is best fetched via CLI

* add metadata

* add to starter templates

---------

Co-authored-by: Ben <me@bpmct.net>
2023-03-17 11:46:44 -05:00
Steven Masley e55d921537 chore: Typescript generator TODOs resolved, adding explainations (#6633)
* chore: Explain usage of eslint comments

* Conform comment

* Fix wording

* Linting
2023-03-17 09:28:16 -05:00
Bruno Quaresma b1c1e1a8a6 refactor(site): Remove wave animation from skeleton (#6644) 2023-03-17 10:44:17 -03:00
Bruno Quaresma 01a6af98b4 fix(site): Do not require immutable parameters (#6637) 2023-03-17 10:09:10 -03:00
Dean Sheather 446bd30c32 chore: regenerate helm golden tests (#6642) 2023-03-17 12:56:40 +01:00
Michael H f59bf732c9 feat: Add ability to configure coder container lifecycle hooks in helm chart (#6432) 2023-03-17 00:55:24 +00:00
Colin Adler 1c05b46b02 chore: add debug logs for OIDC responses (#6641) 2023-03-16 19:33:45 -05:00
Kyle Carberry ffca3a5fb3 fix: remove noop templates plan command (#6617)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2023-03-16 21:28:22 +00:00
Cian Johnston a1d2c057a2 chore(lima): increase random password length from 8 to 12 (#6639) 2023-03-16 18:42:30 +00:00
Steven Masley fe247c86eb feat: Add deployment side config-ssh options (#6613)
* feat: Allow setting deployment wide ssh config settings
* feat: config-ssh respects deployment ssh config
* The '.' is now configurable
* Move buildinfo into deployment.go
2023-03-16 13:03:37 -05:00
Ben Potter 25e8abd63e chore: rewrite provisioner docs (#6445)
* chore: rewrite provisioner docs

* add checkout
2023-03-16 12:51:39 -05:00
Kyle Carberry b693b9f599 chore: fix workspace audit log flake (#6494)
This happened because sometimes a build would be queued
and completed intermittently in CI.

See https://github.com/coder/coder/actions/runs/4358121985/jobs/7618290591
2023-03-16 12:47:54 -05:00
Marcin Tojek 1f9ae15409 feat: CLI use multiselect for list(string) (#6631)
* feat: CLI use multiselect for list(string)

* fix

* select ui tests

* cli test

* Fix

* Fix
2023-03-16 17:17:48 +01:00
Bruno Quaresma 95177ad0e5 refactor(site): Remove change version from the UI (#6621) 2023-03-16 13:07:33 -03:00
Bruno Quaresma ab90651a7e refactor(site): Add skeletons for table loading state (#6626) 2023-03-16 13:06:15 -03:00
Kira Pilot 811a69f371 feat(site): add ability to create tokens from account tokens page (#6608)
* add token actions

* added basic token form

* removed token switch

* refined date field

* limiting lifetime days to maxTokenLifetime

* broke apart files

* added loader and error

* fixed form layout

* added some unit tests

* fixed be tests

* no authorize check
2023-03-16 08:25:08 -07:00
Bruno Quaresma af618477bd feat(site): Show stop button when workspace is failed (#6622) 2023-03-16 14:34:55 +00:00
Bruno Quaresma 107ae55642 feat(site): Add workspace settings page (#6612) 2023-03-16 11:00:19 -03:00
Bruno Quaresma 854bcce5e0 fix(site): Fix filter hover (#6624) 2023-03-16 06:31:41 -07:00
Marcin Tojek a7c734c60b feat: support list(string) as coder_parameter (#6618)
* feat: support list(string) as coder_parameter

* Fix
2023-03-16 11:07:10 +01:00
Benjamin Sejas 7076dee522 feat(agent): Add SSH max timeout option for coder agent (#6596)
* feat(agent): Add SSH max timeout option for coder agent

* Fix lint and update test golden snapshot
2023-03-15 09:08:50 -05:00
Eric Paulsen 2f3848e9b2 rm: aws windows count (#6485)
Co-authored-by: Ben Potter <ben@coder.com>
2023-03-15 13:53:32 +00:00
Muhammad Atif Ali c5475912c9 refactor(docs): refactoring to remove dublication (#6297) 2023-03-15 13:25:51 +00:00
Muhammad Atif Ali a0e096bcfe chore: update templates to use rich parameters (#6397) 2023-03-15 13:11:52 +00:00
Bruno Quaresma 3cf235c564 feat(site): Ask for parameter values when updating a workspace (#6586) 2023-03-14 13:20:49 -03:00
Kyle Carberry f91b3acf93 fix: group routine workspace agent stats by id (#6601)
Before this was creating separate rows for distinct stat entries, which
resulted in significantly more data being sent to telemetry.
2023-03-14 10:52:03 -05:00
Kyle Carberry 17bc5794d4 fix: direct embedded derp traffic directly to the server (#6595)
Prior to this change, DERP traffic would route from `coderd` to the
`CODER_ACCESS_URL` to reach the internal DERP server, which may have
resulted in slower connections due to proxying, or the failure of
web traffic entirely.

If your Coder deployment has a proxy in front of it, your traffic through
web terminals, apps, and port-forwarding is about to get a lot faster!
2023-03-14 14:46:47 +00:00
Bruno Quaresma e3768495e4 docs: Add more info about slow tests in the FE (#6584) 2023-03-14 06:54:17 -07:00
Bruno Quaresma b806d1cfcf fix(site): Display delete template error from the API (#6589) 2023-03-14 10:44:27 -03:00
Mathias Fredriksson 348530000f fix(coderd): Ensure agent disconnect happens after timeout (#6600)
Fixes #6598
2023-03-14 13:14:47 +00:00
Marcin Tojek 7587850a1c feat: import value from legacy variable to build parameter (#6556) 2023-03-14 12:02:44 +00:00
Marcin Tojek bc26c4a27f chore: skip scaletest/reconnectingpty (#6599) 2023-03-14 11:37:31 +00:00
Dean Sheather aafd2803bb chore: update dogfood IP for Sydney (#6597) 2023-03-14 15:29:52 +10:00
Kyle Carberry 35df1b10d0 feat: add workspace agent stat reporting to telemetry (#6577)
This aggregates stats periodically and sends them by agent ID to
our telemetry server. It should help us identify which editors are
primarily in use.
2023-03-13 14:16:54 -05:00
Bruno Quaresma 813b54942f chore(site): Make FE tests faster (#6543) 2023-03-13 13:35:09 -03:00
Cian Johnston 9b2abf0952 chore(helm): add unit tests for helm chart (#6557)
This PR adds a minimum set of Helm tests for the Helm chart.
It's heavily based on the approach in [1], but uses a golden-files-based approach instead.
It also runs helm template directly instead of importing the entire Kubernetes API.
Golden files can be updated by running go test ./helm/tests -update or by running make update-golden-files.

[1] https://github.com/coder/enterprise-helm

Fixes #6552
2023-03-13 13:48:44 +00:00
Mathias Fredriksson 179d9e0d24 fix(coderd): Detect agent disconnect via inactivity (#6528)
Fixes #5901
2023-03-13 11:54:53 +02:00
Kyle Carberry 7fa6483d84 fix: allow the BINARY_DIR to be configured in the agent script (#6567) 2023-03-11 19:39:40 +00:00
Steven Masley 37c859ec4c chore: Ensure all audit types in ResourceTable match APGL (#6563)
* chore: Ensure all audit types in ResourceTable match APGL
* Implement more checks to ensure all tracked fields are present
* Add unit test to ensure all types are represented in audit table
* Trade compile time safety for syntax
2023-03-10 13:59:42 -06:00
Ammar Bandukwala a65a16122d chore: early merge clibase foundations (#6542) 2023-03-10 13:41:32 -06:00
Cian Johnston 144f374f60 refactor(dbauthz): add authz for system-level functions (#6513)
- Introduces rbac.ResourceSystem
- Grants system.* to system and provisionerd rbac subjects
- Updates dbauthz system queries where applicable
- coderd: Avoid index out of bounds in api.workspaceBuilds
- dbauthz: move GetUsersByIDs out of system, modify RBAC check to ResourceUser
- workspaceapps: Add test case for when owner of app is not found
2023-03-10 18:09:28 +00:00
Kyle Carberry 1db2b12b8e chore: add a test to ensure audit code works with AGPL (#6561)
Fixes the regression seen in v0.19.1.
2023-03-10 17:04:40 +00:00
Kyle Carberry 7eb2c2ff6d Revert "chore: Implement joins with golang templates (#6429)" (#6560)
This reverts commit 8b125d6c5d.
2023-03-10 10:39:02 -06:00
Steven Masley a8433b18e4 fix: Prevent infinite redirects on oidc errors (#6550)
* fix: Prevent infinite redirects on bad oidc scopes
* Show oidc errors
2023-03-10 10:12:29 -06:00
Kyle Carberry 4a07fcd9d2 fix: ensure local derp uses the hostname (#6559)
This broke deployments that use a custom port with an access
URL. We should write a test for this!
2023-03-10 09:58:31 -06:00
Steven Masley 8b125d6c5d chore: Implement joins with golang templates (#6429)
* feat: Implement view for workspace builds to include rbac info

* Removes the need to fetch the workspace to run an rbac check.
* chore: Use workspace build as RBAC object
* chore: Use golang templates instead of sqlc files
2023-03-10 09:44:38 -06:00
Eric Paulsen a666539bfa helm: add value for labels (#6544) 2023-03-10 07:39:55 -05:00
Marcin Tojek 90901ca129 fix: panic on deleted template (#6553) 2023-03-10 12:26:11 +01:00
Marcin Tojek 6023264a81 fix: typo in error message (#6551)
* fix: typo in error message

* fix
2023-03-10 09:20:22 +00:00
Steven Masley 7f25d31745 feat: Allow changing the 'group' oidc claim field (#6546)
* feat: Allow changing the 'group' oidc claim field
* Enable empty groups support
* fix: Delete was wiping all groups, not just the single user's groups
* Update docs
* fix: Dbfake delete group member fixed
2023-03-09 23:31:38 -06:00
Steven Masley 11a930e779 !fix: Disallow access urls without valid scheme (#6548)
Existing deployments will need to prepend a scheme if they have not already.
2023-03-09 21:37:19 -06:00
Kyle Carberry 65878b04ce fix: remove "something went wrong" text for watching a workspace (#6541)
This text wasn't useful to a customer anyways, because we don't get
an error from EventSource. This can happen if you close your laptop
and open it again, so it's better if we don't display it.
2023-03-09 20:54:28 +00:00
Ammar Bandukwala 50432b89be fix: pass git auth config read from environment through server (#6540) 2023-03-09 20:27:54 +00:00
Kyle Carberry 1b3b0ea962 fix: adjust workspace filter query when the path changes (#6539)
Previously, when a status would change the filter wouldn't update.
This makes it update if a new value is passed in.
2023-03-09 14:23:23 -06:00
Kyle Carberry 9a7998301b fix: remove deployment bar info icon and adjust language (#6537)
Re @bpmct's feedback
2023-03-09 20:08:50 +00:00
Ammar Bandukwala 4c2977050d fix: treat empty env as defaults (#6538) 2023-03-09 19:58:58 +00:00
Ammar Bandukwala 62a64d5a34 fix: remove deprecation warnings when option unset (#6532)
Resolves #6531
2023-03-09 19:22:21 +00:00
Ammar Bandukwala 761ed7bf63 fix: rm pull request template (#6533)
It doesn't seem like this was helping anything.
2023-03-10 03:53:48 +10:00
Steven Masley 2abae42cec feat: Ignore agent pprof port in listening ports (#6515)
* feat: Ignore agent pprof port in listening ports
2023-03-09 10:53:00 -06:00
Steven Masley 3de29307b5 chore: Remove some of the external enum comments in typescript (#6530)
* chore: Remove some of the external enum comments in typescript

handle clibase types manually
2023-03-09 10:46:23 -06:00
Marcin Tojek c2787e3a8e docs: describe rich parameters (#6527)
* WIP

* WIP

* docs: describe rich parameters

* Update docs/templates/parameters.md

Co-authored-by: Cian Johnston <public@cianjohnston.ie>

* Update docs/templates/parameters.md

Co-authored-by: Cian Johnston <public@cianjohnston.ie>

* Update docs/templates/parameters.md

Co-authored-by: Cian Johnston <public@cianjohnston.ie>

* Update docs/templates/parameters.md

Co-authored-by: Cian Johnston <public@cianjohnston.ie>

* Update docs/templates/parameters.md

Co-authored-by: Cian Johnston <public@cianjohnston.ie>

* Update docs/templates/parameters.md

Co-authored-by: Cian Johnston <public@cianjohnston.ie>

* Update docs/templates/parameters.md

Co-authored-by: Cian Johnston <public@cianjohnston.ie>

* Update docs/templates/parameters.md

Co-authored-by: Cian Johnston <public@cianjohnston.ie>

* Update docs/templates/parameters.md

Co-authored-by: Cian Johnston <public@cianjohnston.ie>

* Strip migration

* Fix

---------

Co-authored-by: Cian Johnston <public@cianjohnston.ie>
2023-03-09 17:19:48 +01:00
Kyle Carberry 70b093ff2a fix: filter session count sums by created_at (#6529)
Fixes the session totals being waaaaay too high!
2023-03-09 17:08:41 +02:00
Kyle Carberry 1cc10f2ffb fix: only sum connection latencies when they are set (#6524)
This was producing a median that didn't make sense.
2023-03-09 03:53:09 +00:00
Ben Potter 1199a9330a chore: add fly.io install source (#6509) 2023-03-09 03:16:55 +00:00
Kyle Carberry a78786119d chore: resolve race when running load tests with logs (#6523)
See https://github.com/coder/coder/actions/runs/4370166746/jobs/7644793277
2023-03-08 21:12:20 -06:00
Kyle Carberry 5304b4e483 feat: add connection statistics for workspace agents (#6469)
* fix: don't make session counts cumulative

This made for some weird tracking... we want the point-in-time
number of counts!

* Add databasefake query for getting agent stats

* Add deployment stats endpoint

* The query... works?!?

* Fix aggregation query

* Select from multiple tables instead

* Fix continuous stats

* Increase period of stat refreshes

* Add workspace counts to deployment stats

* fmt

* Add a slight bit of responsiveness

* Fix template version editor overflow

* Add refresh button

* Fix font family on button

* Fix latest stat being reported

* Revert agent conn stats

* Fix linting error

* Fix tests

* Fix gen

* Fix migrations

* Block on sending stat updates

* Add test fixtures

* Fix response structure

* make gen
2023-03-08 21:05:45 -06:00
Kyle Carberry 9d40d2ffdc fix: remove create first user from the cli message (#6493)
This adjusts our setup to just show the Web UI, since you
can now create everything from there!
2023-03-09 02:54:46 +00:00
Kyle Carberry db2bdd1cab fix: pass sdk header transport to websocket connections (#6521)
Fixes #6520.
2023-03-09 02:29:02 +00:00
Kyle Carberry d67552f852 fix: add more cached certificates to azure instance identity (#6519)
This was failing for GovCloud. Now it falls back to fetch, and a test
has been added to notify when certificates are becoming outdated.
2023-03-08 19:32:10 -06:00
Bruno Quaresma 54bbed8c3c chore: Fix default password and add more docs about scripts/develop.sh (#6514) 2023-03-08 21:50:55 +00:00
Kyle Carberry 7df1e3bdd6 fix: centralize deployment config blocks to resolve race (#6512)
See https://github.com/coder/coder/actions/runs/4365865438/jobs/7635236079
2023-03-08 16:55:52 +00:00
Ammar Bandukwala 95626d2076 fix: use correct LOG env names (#6511) 2023-03-08 16:27:32 +00:00
Marcin Tojek 3b87316ad7 feat: propagate job error codes (#6507)
* feat: propagate job error_code

* fix

* Fix

* Fix

* Fix

* add errors to typesGenerated

* Address PR comments

* Fix
2023-03-08 16:32:00 +01:00
Kyle Carberry 524b14adbc fix: fetch provisioner logs after end of logs message (#6495)
I think this should _actually_ fix it. See
https://github.com/coder/coder/actions/runs/4358242625/jobs/7618562167

The problem was that this loop is ran async so even though
messages are sent in order, we were processing too slowly and
the end of logs was published first.
2023-03-09 01:13:08 +10:00
Cian Johnston 26a725f86d fix: provisionerd: add more context to logs emitted, fix log level (#6508)
- Previously, we were logging all provision response logs at level INFO, regardless of the log level of the log streamed from the provisioner. We now log these at the original level (defaulting to INFO).
- Now logging "provision failed" message at level ERROR WARN and including the error field in the message.
2023-03-08 15:12:52 +00:00
Bruno Quaresma 89008125c0 refactor(site): Highlight immutable parameters and do a few tweaks (#6490) 2023-03-08 10:52:42 -03:00
Cian Johnston fe10ba1157 fix: add audit information for WorkspaceBuild.MaxDeadilne (#6504)
* fix: add audit information for WorkspaceBuild.MaxDeadilne

* make gen
2023-03-08 12:41:57 +00:00
Ammar Bandukwala 3b73321a6c feat: refactor deployment config (#6347) 2023-03-07 15:10:01 -06:00
Kyle Carberry bb0a996fc2 chore: fix buffered provisioner job logs close flake (#6492)
See https://github.com/coder/coder/actions/runs/4357599919/jobs/7617111287
2023-03-07 20:08:13 +00:00
Dean Sheather 1bdd2abed7 feat: use JWT ticket to avoid DB queries on apps (#6148)
Issue a JWT ticket on the first request with a short expiry that
contains details about which workspace/agent/app combo the ticket is
valid for.
2023-03-07 19:38:11 +00:00
Hannes Rehburg f8494d2bac Update binary.md (#6415)
Fixed broken Link to release archive
2023-03-07 12:30:50 -06:00
Kyle Carberry f287889cd7 chore: move client pubsub for HA coordinator after register (#6487)
Similar fix that happened for the agent. See:
https://github.com/coder/coder/actions/runs/4356099388/jobs/7613634277
2023-03-07 16:46:54 +00:00
Kyle Carberry 4c204fc348 chore: ensure auto-approve-docs has a deep enough depth (#6484)
* chore: ensure auto-approve-docs has a deep enough depth

This was failing on numerous PRs.

* Remove check because it isn't working
2023-03-07 10:05:00 -06:00
Kyle Carberry 23bebb40e2 fix: bump migration to resolve duplicate id (#6486)
This happened because two PRs with different migrations
merged at the same time!
2023-03-07 10:04:06 -06:00
Marcin Tojek 2d4706ac33 feat: mark coder_parameter as "required" (#6433)
* Add required column

* Pass through providerd

* Pass the required property down

* Optional

* Fix

* Fix

* Fix

* fix

* CLI create: support for optional fields

* Use HTML API to mark fields required

* Fix

* Improve validation

* more fixes

* make fmt

* Fix

* WIP

* Fix: test

* CLI update tets

* OptionalParameterAdded

* Fix: migration
2023-03-07 16:38:31 +01:00
Kyle Carberry f19076cf06 chore: fix coordinator flake by moving pubsub below register (#6482)
After making the in-memory pubsub conform to the expectations of
PostgreSQL, this flake started appearing.

This fixes it because the agent socket is registered when a message
is received.
2023-03-07 09:38:18 -06:00
Kira Pilot ef2e86f309 increase default max-token-duration (#6467) 2023-03-07 06:35:48 -08:00
Kyle Carberry 87ed7a7dba chore: use nil map on agent stats to check if report interval should be returned (#6479)
See https://github.com/coder/coder/actions/runs/4350638262/jobs/7601537088
2023-03-07 14:25:04 +00:00
Dean Sheather 66a6b590a1 feat: add template max_ttl (#6114)
Co-authored-by: Bruno Quaresma <bruno@coder.com>
2023-03-07 14:14:58 +00:00
Cian Johnston 248c53d68d fix: install terraform in base Docker image (#6263)
Updates the base Docker image to install Terraform version 1.3.4 (max supported version) by default.
Also updates documentation to reflect this change.
2023-03-07 13:52:45 +00:00
Mathias Fredriksson 0c2b432c1b feat: Add migration fixer script (for branches) (#6466) 2023-03-07 14:47:33 +02:00
Kyle Carberry fd02f73708 chore: ensure pubsub messages are delivered in order for in-memory variant (#6474)
PostgreSQL provides this guarantee, which led to some flakes in tests.
See: https://github.com/coder/coder/actions/runs/4350034299/jobs/7600478096
2023-03-07 04:36:25 +00:00
Kyle Carberry 74632e460c fix: adjust build state permission to require template update (#6472) 2023-03-07 04:24:32 +00:00
Kyle Carberry 29ced72cda chore: fix stats leaking in tests (#6478)
See https://github.com/coder/coder/actions/runs/4350254306/jobs/7601134509
2023-03-07 04:09:02 +00:00
Kyle Carberry 034641dc77 chore: migrate security checks to run on a cron (#6477)
They were taking a long time and seemed to be reducing concurrency
for our other CI actions.
2023-03-06 21:46:40 -06:00
Kyle Carberry 7a8ccda40e chore: copy forced derp websockets to fix flake (#6475)
See: https://github.com/coder/coder/actions/runs/4350034299/jobs/7600478389
2023-03-06 21:29:41 -06:00
Kyle Carberry 964032d783 chore: ignore query cancel error in activitybump (#6476)
See https://github.com/coder/coder/actions/runs/4350254306/jobs/7600782432

It's fine to ignore this, because workspace agent stats happen async
and might occur when shutting down.
2023-03-06 21:27:21 -06:00
Kyle Carberry 09f87d1df1 chore: remove empty case for metricscache (#6473)
This wasn't necessary to test and just caused flakes.
See: https://github.com/coder/coder/actions/runs/4350034299/jobs/7600340648
2023-03-06 21:13:08 -06:00
Kyle Carberry cf75d7e1fb fix: clean up idle http conns on wsconncache close (#6471)
See https://github.com/coder/coder/actions/runs/4346769070/jobs/7593243836
2023-03-06 20:45:49 -06:00
Kyle Carberry e0137bcff1 fix: ensure tailnet websockets are closed (#6470)
See: https://github.com/coder/tailscale/pull/10
2023-03-06 20:45:24 -06:00
sharkymark d8abe37cd7 docs: AWS EKS sessionAffinity for LB external IP to be issued (#6425) 2023-03-06 23:40:05 +00:00
Steven Masley 8a6635bf5f chore: Never run v2 migrations on v1 database (#6438) 2023-03-06 13:49:03 -06:00
Mathias Fredriksson 22e3ff96be feat(agent): Add shutdown lifecycle states and shutdown_script support (#6139)
* feat(api): Add agent shutdown lifecycle states

* feat(agent): Add shutdown_script support

* feat(agent): Add shutdown_script timeout

* feat(site): Support new agent lifecycle states

---

Co-authored-by: Marcin Tojek <marcin@coder.com>
2023-03-06 21:34:00 +02:00
Ben Potter 02100c64b5 fix: docs auto-approval (#6450)
* fix: docs auto-approval

* empty commit
2023-03-06 13:31:07 -06:00
Bruno Quaresma 136f23fb4c refactor(site): Suport template version variables on template creation (#6434) 2023-03-06 18:36:19 +00:00
Steven Masley 84dd59ecc2 fix: 'coder update' should always start a workspace (#6437)
* fix: 'coder update' should always start a workspace
2023-03-06 08:37:11 -06:00
Steven Masley 260b2b2333 fix: 404 template shows error page (#6441) 2023-03-06 13:58:36 +00:00
Bruno Quaresma a3201bd658 fix(site): Fix template version editor rename (#6251) 2023-03-06 13:53:24 +00:00
Cian Johnston 1483b42259 fix(provisionerd): emit workspace build transition in lower case (#6455) 2023-03-06 11:14:19 +00:00
Steven Masley e78c272a72 chore: System context to oidc login (#6427) 2023-03-04 14:32:07 -06:00
Ammar Bandukwala 02f0968b33 chore: automatically approve Ben's docs PRs (#6444) 2023-03-04 08:07:45 -06:00
Ben Potter 573a8d5717 docs: external provisioners (#6443)
* docs: external provisioners

* better wording

* fix wording

* fix wording in various places

* keep fixing wording

* add another note about template management
2023-03-03 23:49:03 +00:00
Steven Masley 973df199b0 test: Check created_at for prepareData to ensure user order (#6436)
* test: Check created_at for prepareData to ensure user order

* test: Consistent user ordering in dbfake

* import order

* Linting
2023-03-03 13:09:04 -06:00
Muhammad Atif Ali 3cb9b3de24 docs: clarify how to set max token life in ci/cd docs (#6416)
* docs: clarify max token life in ci/cd docs

* Update docs/templates/change-management.md

---------

Co-authored-by: Ben Potter <me@bpmct.net>
2023-03-02 22:22:53 +00:00
Ben Potter 175a41567e docs: clarify requirements for offline deployments (#6418)
* docs: clarify requirements for offline deployments

* fix punctuation

* fix typo and add postgres

* mention update check

* disable update checks
2023-03-02 14:59:31 -06:00
Ben Potter 25b05ed8a4 fix: minimal AWS policy for templates (#6419) 2023-03-02 12:21:02 -06:00
Kira Pilot 71d1e63af0 feat: add ability to name tokens (#6365)
* add tokens switch

* reorged TokensPage

* using Trans component for description

* using Trans component on DeleteDialog

* add owner col

* simplify hook return

* lint

* type for response

* added flag for name

* fixed auth

* lint, prettier, tests

* added unique index for login type token

* remove tokens by name

* better check for unique constraint

* docs

* test: Fix dbfake to insert token name

* fix doc tests

* Update cli/tokens.go

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>

* Update coderd/database/migrations/000102_add_apikey_name.down.sql

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>

* add more specificity to IsUniqueViolation check

* fix tests

* Fix AutorizeAllEndpoints

* rename migration

---------

Co-authored-by: Steven Masley <stevenmasley@coder.com>
Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
2023-03-02 09:39:38 -08:00
Muhammad Atif Ali e3a4861e93 docs: update example coder.conf file (#6319)
Updated example configuration file to match the configuration in tutorial.
2023-03-02 09:55:50 -06:00
Ben Potter ea7a80c5ff docs: clearer postgres sizing recommendations (#6302) 2023-03-02 15:53:55 +00:00
Kyle Carberry 2ff1c6d613 feat: add agent stats for different connection types (#6412)
This allows us to track when our extensions are used, when the
web terminal is used, and average connection latency to the agent.
2023-03-02 08:06:00 -06:00
Ben Potter 537547fcc3 fix: outdated message in latency tooltip (#6043) 2023-03-02 13:24:44 +00:00
Marcin Tojek 67db36bf81 feat: Add form to modify managed Template variables (#6257) 2023-03-02 14:11:16 +01:00
Steven Masley 8cf292f50a feat: Guard search queries against common mistakes (#6404)
* feat: Error on excessive invalid search keys
* feat: Guard search queries against common mistakes
* Raise errors in FE on workspaces table
* All errors should be on newlines
2023-03-01 23:28:56 -06:00
Kyle Carberry 1724cbf872 feat: automatically use websockets if DERP upgrade is unavailable (#6381)
* feat: automatically use websockets if DERP upgrade is unavailable

This might be our biggest hangup for deployments at the moment...

Load balancers by default do not support the DERP protocol, so many
of our prospects and customers run into failing workspace connections.
This automatically swaps to use WebSockets, and reports the reason to
coderd.

In a future contribution, a warning will appear by the agent if it was
forced to use WebSockets instead of DERP.

* Fix nil pointer type in Tailscale dep

* Fix requested changes
2023-03-01 22:18:14 +00:00
dependabot[bot] ce11400b56 chore: bump eslint-plugin-import from 2.26.0 to 2.27.5 in /site (#6391)
Bumps [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) from 2.26.0 to 2.27.5.
- [Release notes](https://github.com/import-js/eslint-plugin-import/releases)
- [Changelog](https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-plugin-import/compare/v2.26.0...v2.27.5)

---
updated-dependencies:
- dependency-name: eslint-plugin-import
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 21:55:27 +00:00
dependabot[bot] 28e002e8bb chore: bump eslint-plugin-jest from 27.0.1 to 27.2.1 in /site (#6396)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 27.0.1 to 27.2.1.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v27.0.1...v27.2.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-jest
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 15:21:30 -06:00
dependabot[bot] 454da9e0ef chore: bump eslint from 8.33.0 to 8.35.0 in /site (#6395)
Bumps [eslint](https://github.com/eslint/eslint) from 8.33.0 to 8.35.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.33.0...v8.35.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 15:21:23 -06:00
dependabot[bot] 32ecb853ed chore: bump github.com/gohugoio/hugo from 0.109.0 to 0.110.0 (#6394)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.109.0 to 0.110.0.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/hugoreleaser.toml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.109.0...v0.110.0)

---
updated-dependencies:
- dependency-name: github.com/gohugoio/hugo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 15:21:13 -06:00
dependabot[bot] 570b7f95d2 chore: bump aquasecurity/trivy-action from 0.8.0 to 0.9.1 (#6385)
Bumps [aquasecurity/trivy-action](https://github.com/aquasecurity/trivy-action) from 0.8.0 to 0.9.1.
- [Release notes](https://github.com/aquasecurity/trivy-action/releases)
- [Commits](https://github.com/aquasecurity/trivy-action/compare/9ab158e8597f3b310480b9a69402b419bc03dbd5...8bd2f9fbda2109502356ff8a6a89da55b1ead252)

---
updated-dependencies:
- dependency-name: aquasecurity/trivy-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 15:19:13 -06:00
dependabot[bot] b2671639a7 chore: bump crate-ci/typos from 1.13.9 to 1.13.14 (#6386)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.13.9 to 1.13.14.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.13.9...v1.13.14)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 15:18:59 -06:00
dependabot[bot] 991c720c09 chore: bump github.com/cenkalti/backoff/v4 from 4.1.3 to 4.2.0 (#6390)
Bumps [github.com/cenkalti/backoff/v4](https://github.com/cenkalti/backoff) from 4.1.3 to 4.2.0.
- [Release notes](https://github.com/cenkalti/backoff/releases)
- [Commits](https://github.com/cenkalti/backoff/compare/v4.1.3...v4.2.0)

---
updated-dependencies:
- dependency-name: github.com/cenkalti/backoff/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 15:18:48 -06:00
Dean Sheather 31a37025c4 fix: build for all platforms in depot release pt. 2 (#6407) 2023-03-01 19:48:22 +00:00
Dean Sheather 9af03d6180 fix: build for all platforms in depot release (#6406) 2023-03-01 18:29:02 +00:00
Bruno Quaresma 4dd95c5e01 fix(site): Fix long template descriptions (#6403) 2023-03-01 17:53:59 +00:00
Kyle Carberry 9ea21bf8ee fix: hardcode azure instance identity intermediate certificates (#6402)
This was broken for an airgapped customer!
2023-03-01 17:39:24 +00:00
Kira Pilot 6304bfb5c0 feat: add 'Show all tokens' toggle for owners (#6325)
* add tokens switch

* reorged TokensPage

* using Trans component for description

* using Trans component on DeleteDialog

* add owner col

* simplify hook return

* lint

* type for response

* PR feedback

* fix lint
2023-03-01 08:35:55 -08:00
dependabot[bot] b56e1bb002 chore: bump contributor-assistant/github-action from 2.2.1 to 2.3.0 (#6384)
Bumps [contributor-assistant/github-action](https://github.com/contributor-assistant/github-action) from 2.2.1 to 2.3.0.
- [Release notes](https://github.com/contributor-assistant/github-action/releases)
- [Commits](https://github.com/contributor-assistant/github-action/compare/v2.2.1...v2.3.0)

---
updated-dependencies:
- dependency-name: contributor-assistant/github-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 09:18:01 -06:00
dependabot[bot] c560d6d2ae chore: bump actions/upload-artifact from 2 to 3 (#6383)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 09:17:34 -06:00
Ammar Bandukwala 5f6dd0ca2a docs: fix very small typo 2023-02-28 16:51:53 -06:00
Kyle Carberry 8850ce0d9a fix: use bigint instead of integer in stats migration (#6380)
This broke dogfood!
2023-02-28 13:55:37 -06:00
Kyle Carberry 05e449943d chore: convert agent stats to use a table (#6374)
* chore: convert workspace agent stats from json to table

* chore: convert agent stats to use a table

Backwards compatibility becomes hard when all agent stats are in a JSON blob.
We also want to query this table for new agents that are failing health checks
so we can display it in the UI.

* Fix migration using default values
2023-02-28 13:33:33 -06:00
Ben Potter 7cf1e20aac docs: clarify alpha state of rich parameters (#6369) 2023-02-28 17:16:49 +00:00
Steven Masley 418a8a77dc chore: Skip authz on various functions used for api data building (#6366)
* chore: Skip authz on various functions used for api data building

API already fetches the parent object and does the rbac check. Until
these functions are optimized, skipping authz is better.
It leaves us no worse off than the status quo
2023-02-28 11:04:39 -06:00
Ammar Bandukwala d30da81f42 ci: make fmt 2023-02-27 21:43:14 +00:00
Ammar Bandukwala dc6639bf69 ci: automatically assign new PRs 2023-02-27 16:52:00 +00:00
Kyle Carberry 7f226d4f90 feat: add support for coder_git_auth data source (#6334)
* Add git auth providers schema

* Pipe git auth providers to the schema

* Add git auth providers to the API

* Add gitauth endpoint to query authenticated state

* Add endpoint to query git state

* Use BroadcastChannel to automatically authenticate with Git

* Add error validation for submitting the create workspace form

* Fix panic on template dry-run

* Add tests for the template version Git auth endpoint

* Show error if no gitauth is configured

* Add gitauth to cliui

* Fix unused method receiver

* Fix linting errors

* Fix dbauthz querier test

* Fix make gen

* Add JavaScript test for git auth

* Fix bad error message

* Fix provisionerd test race

See https://github.com/coder/coder/actions/runs/4277960646/jobs/7447232814

* Fix requested changes

* Add comment to CreateWorkspacePageView
2023-02-27 10:18:19 -06:00
Kyle Carberry 3d8b77d6f1 chore: improve clarity of the agent logs (#6345)
I looked through these logs when debugging and there was a bit of spam!
2023-02-27 09:20:24 -06:00
Marcin Tojek ec6f78d09e docs: Describe support links (#6353)
* docs: Describe support links

* Fix: size

* Address PR comments
2023-02-27 15:33:34 +01:00
Marcin Tojek 2e53fb55da feat: Enable custom support links (#6313)
* backend: support links

* frontend: Support links

* fmt

* test: CODER_SUPPORT_LINKS_0_NAME

* Go tests

* Use UpdateAppearanceConfig

* ui: UpdateAppearanceConfig

* fix: fmt

* Fix: site

* Fix: site tests

* fix: fmt

* fix

* test: check default support links
2023-02-27 09:25:04 +01:00
Eric Paulsen 16364db483 add: resource reqs/limits on K8s template (#6308) 2023-02-26 19:23:45 -05:00
Kyle Carberry 7c46f76c82 chore: fetch templates by id without lock in dbfake (#6351)
See https://github.com/coder/coder/actions/runs/4276632002/jobs/7444857508
2023-02-26 15:29:43 -06:00
Kyle Carberry acbe968f41 chore: increase activitybump deadline duration to fix flake (#6350)
This is a bad fix because the test is still dependant on time, but it's
still an improvement.
2023-02-26 13:42:01 -06:00
Kyle Carberry 1fb7365cb1 fix: use -U when installing with rpm (#6349)
Fixes #6275.
2023-02-26 18:11:23 +00:00
Kyle Carberry 17adfd1134 chore: improve times of ratelimit tests (#6346)
From 5s to 130ms!
2023-02-25 22:01:01 +00:00
Muhammad Atif Ali acf000aaa5 add common ml logos (#6318) 2023-02-25 11:22:07 -06:00
Kyle Carberry d613ba9987 security: add X-Content-Type-Options: nosniff to block MIME-sniffing (#6344)
coder/security#12
2023-02-25 11:18:45 -06:00
Mathias Fredriksson cae8b88f60 fix(tailnet): Avoid logging netmap (#6342) 2023-02-25 08:06:38 +00:00
Mathias Fredriksson 5876dc1f97 test(cli): Improve speedtest debugging (#6341) 2023-02-24 20:09:16 +02:00
Ben Potter 29dbfe067c docs: parameters (#6332)
* docs: parameters

* mention legacy parameters
2023-02-24 11:04:07 -07:00
Mathias Fredriksson 677721e4a1 fix(tailnet): Skip nodes without DERP, avoid use of RemoveAllPeers (#6320)
* fix(tailnet): Skip nodes without DERP, avoid use of RemoveAllPeers
2023-02-24 18:16:29 +02:00
Mathias Fredriksson a414de9e81 fix(tailnet): Improve tailnet setup and agentconn stability (#6292)
* fix(tailnet): Improve start and close to detect connection races

* fix: Prevent agentConn use before ready via AwaitReachable

* fix(tailnet): Ensure connstats are closed on conn close

* fix(codersdk): Use AwaitReachable in DialWorkspaceAgent

* fix(tailnet): Improve logging via slog.Helper()
2023-02-24 13:11:28 +02:00
Cian Johnston 473ab208af fix: replace owner_email with workspace_owner, change action to workspace_transition (#6337) 2023-02-24 04:38:58 +00:00
Marcin Tojek 16363fd1ff chore: update terraform-provider-coder (#6333) 2023-02-23 17:32:52 -07:00
Cian Johnston 282507f0fb fix(provisionerd): add more detailed workspace build logging (#6331) 2023-02-24 00:03:12 +00:00
Marcin Tojek 50db90c33d fix: rephrase rich parameters error (#6327) 2023-02-23 21:49:40 +00:00
Dean Sheather 8abe48c155 chore: update docs to recommend MFA via iDP (#6324) 2023-02-23 18:07:21 +00:00
Kyle Carberry 8a4a179565 fix: use proper generated cli.md for deploy (#6323) 2023-02-23 11:07:57 -06:00
Muhammad Atif Ali 7f65a837b1 docs: Update the troubleshooting section (#6287)
* docs: Update the troubleshooting section

Update the troubleshooting section to link web-server docs

* make fmt

* Update docs/templates.md

Co-authored-by: Ben Potter <me@bpmct.net>

---------

Co-authored-by: Ben Potter <me@bpmct.net>
2023-02-23 09:35:02 -07:00
Bruno Quaresma 0bf6229edb fix(site): Fix cancel button borders (#6315) 2023-02-23 15:47:09 +00:00
Cian Johnston 1ba6fab0e0 chore: skip flaky TestSpeedtest (#6322) 2023-02-23 15:29:57 +00:00
Bruno Quaresma 8298a924f6 fix(site): Fix login flow (#6294) 2023-02-23 15:25:12 +00:00
Kira Pilot a32169ccb5 feat: add flag to see all tokens if owner (#6227)
* added query for tokens by user id

* updated query args

* adding owner col

* fix request params

* update-golden-files

* added owners col to ls table output

* added ttoken translations

* prettier

* format table according to arg

* using slice.Contains

* refactored token state

* cleanup
2023-02-23 07:00:27 -08:00
Ammar Bandukwala 7a52a9cfc8 fix: flake in template pull (#6317) 2023-02-23 04:59:07 +00:00
Ammar Bandukwala f6a8c360e5 feat(docs): rework CLI docs (#6312) 2023-02-23 01:53:21 +00:00
Cian Johnston 43e8ba0811 feat(api): add prometheus metric coderd_workspace_builds_total (#6314)
This PR adds the prometheus metric coderd_workspace_builds_total.
It measures the total number of workspace builds, along with a number of labels intended to be useful for an operator debugging a failed workspace build trying to discover the scope of the issue.
2023-02-23 01:28:10 +00:00
Kyle Carberry 2a8a147e7d fix: don't log disconnect error when the database is shutting down (#6309)
* fix: don't log disconnect error when the database is shutting down

Seen in: https://github.com/coder/coder/actions/runs/4244980490/jobs/7379867681

* Generalize the query close error
2023-02-22 16:07:26 -06:00
Colin Adler bbdf24686d chore(examples): update provider versions (#6311) 2023-02-22 14:43:32 -07:00
Muhammad Atif Ali 457ad74d83 fix(docs): update Apache docs to correctly forward WebSockets (#6296)
This revolves #6295
2023-02-22 12:51:51 -07:00
Ammar Bandukwala f7c10adb04 feat(cli): extract tar in template pull (#6289) 2023-02-22 19:29:51 +00:00
Ammar Bandukwala 8231de94ca feat(cli): make minor improvements to speedtest (#6266)
- Remove mostly redundant "Transferred" column
- Rename "Bandwidth" to "Throughput"
- Replace "--reverse" (which has an ambiguous starting state) with "--direction=(up|down)"
- Tolerate AgentStartErrors which may be caused by failing startup
  script
2023-02-22 19:09:37 +00:00
Cian Johnston 6149905a83 fix: disallow deleting self (#6306)
* fix: api: disallow user self-deletion

* feat(site): TableRowMenu: allow disabling individual menu items

* fix(site): UsersTable: disallow deleting self
2023-02-22 16:48:16 +00:00
Bruno Quaresma b412ef0dbb chore(site): Fix chromatic errors (#6301) 2023-02-22 16:11:25 +00:00
Bruno Quaresma d993a97fee refactor(site): Minor design refactoring on template version editor (#6265) 2023-02-22 07:42:37 -07:00
Ammar Bandukwala 3f75f6b8cc chore: update potentially insecure deps (#6290) 2023-02-21 06:15:25 +00:00
Mathias Fredriksson 2bb9b4ac80 test: Fix azureidentity verification test (#6284) 2023-02-20 15:50:39 +00:00
Ammar Bandukwala f05609b4da chore: format Go more aggressively 2023-02-18 18:32:09 -06:00
Colin Adler 19ae411f05 fix: actually test httpapi.WebsocketCloseSprintf (#6261) 2023-02-17 17:50:21 +00:00
Kyle Carberry a79f4a095d fix: allow mapped resources in our terraform provider (#6255) 2023-02-17 16:05:38 +00:00
Bruno Quaresma 7a864bdb28 refactor(site): Refactor template settings (#6239) 2023-02-17 13:27:35 +00:00
Marcin Tojek e161c45b47 Revert "fix: allow mapped resources in our terraform provider (#6242)" (#6248)
This reverts commit d5af536ea2.
2023-02-17 12:55:54 +01:00
Marcin Tojek a69137b1f7 feat: Update CLI to handle managed variables (#6220)
* WIP

* hcl

* useManagedVariables

* fix

* Fix

* Fix

* fix

* go:build

* Fix

* fix: bool flag

* Insert template variables

* API

* fix

* Expose via API

* More wiring

* CLI for testing purposes

* WIP

* Delete FIXME

* planVars

* WIP

* WIP

* UserVariableValues

* no dry run

* Dry run

* Done FIXME

* Fix

* Fix: CLI

* Fix: migration

* API tests

* Test info

* Tests

* More tests

* fix: lint

* Fix: authz

* Address PR comments

* Fix

* fix

* fix

* CLI: create

* unit tests: create templates with variables

* Use last variables

* Fix

* Fix

* Fix

* Push tests

* fix: variable is required if Default is nil

* WIP

* Redact sensitive values

* Fixes

* Fixes

* Fix: arg description

* Fix

* Variable param

* Fix: gen

* Fix

* Fix: goldens
2023-02-17 09:07:45 +01:00
Kyle Carberry d5af536ea2 fix: allow mapped resources in our terraform provider (#6242)
Fixes #6234.
2023-02-16 13:04:40 -06:00
Bruno Quaresma 2c309194e9 refactor(site): Remove untar dep and support nested folders on template version page (#6244) 2023-02-16 18:38:14 +00:00
Bruno Quaresma 8360357834 refactor(site): Redesign dialogs (#6237) 2023-02-16 14:03:07 -03:00
Bruno Quaresma 909fbb6d2c fix(site): Upload template files on template version editor (#6222) 2023-02-16 13:59:48 -03:00
Ben 4c799798c6 fix: use autoplay for AWS quickstart 2023-02-16 16:45:53 +00:00
Ben Potter 779c6549b4 fix: proper video URL in AWS quickstart doc (#6238)
* chore: fixes video in AWS quickstart

* minor language tweaks
2023-02-16 10:39:14 -06:00
Cian Johnston 81c29c018a fix(coder): actually ignore email verified if config value is set (#6236) 2023-02-16 15:17:37 +00:00
Ben Potter fdad136905 fix: add notes to helm chart about access URL (#6231) 2023-02-16 08:46:49 -06:00
Ben Potter 9c22c51d3b docs: use marketplace for AWS quickstart (#6233) 2023-02-16 08:44:48 -06:00
Muhammad Atif Ali 26876dc734 docs: add apache reverse-proxy example (#6213)
* docs: apache reverse proxy

* fixed to correctly pass WebSocket headers

* add a sample configuration file

* updating with suggestions

* Update coder.conf

* fix http to https redirection

* fix: upgrade http to https

* Update examples/web-server/apache/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* add other dns providers documentation link

---------

Co-authored-by: Ben Potter <me@bpmct.net>
Co-authored-by: Ben Potter <ben@coder.com>
2023-02-16 04:50:18 +00:00
Muhammad Atif Ali 99306642bb docs: update caddy reverse proxy example (#6228)
Update caddy reverse proxy example to use `CODER_HTTP_ADDRESS` instead of deprecated `CODER_ADDRESS`

This resolved #5449
2023-02-16 04:31:43 +00:00
Ben Potter 22cc6a3fb6 docs: feature stages (#6223) 2023-02-15 15:51:31 -06:00
Muhammad Atif Ali 786ad8d8b1 docs: add nginx reverse-proxy example (#6185)
* docs: Add nginx reverse-proxy example

This PR adds nginx reverse-proxy example to provision coder with tls certificate using letsencrypt certbot.

This will partially resolve #6086.

* change nginx example to to absolute path

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* refactor: replaced bullets with numbered lists

* remove the ambiguous ip addr.

* fixed a typo

* correctly handle the wildcard subdomain

* simplified after testing

* fmt: prettier formatting

* Adapt to the coder style guide

* fix: agent disconnection

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update docs/admin/configure.md

Co-authored-by: Ben Potter <me@bpmct.net>

* Update examples/web-server/nginx/README.md

Co-authored-by: Ben Potter <me@bpmct.net>

* updated with suggested changes

* updated with requested changes

* add reference to certbot docs for other dns providers

---------

Co-authored-by: Ben Potter <me@bpmct.net>
2023-02-15 13:18:54 -06:00
Marcin Tojek 3b7b96ac28 feat: Expose managed variables via API (#6134)
* WIP

* hcl

* useManagedVariables

* fix

* Fix

* Fix

* fix

* go:build

* Fix

* fix: bool flag

* Insert template variables

* API

* fix

* Expose via API

* More wiring

* CLI for testing purposes

* WIP

* Delete FIXME

* planVars

* WIP

* WIP

* UserVariableValues

* no dry run

* Dry run

* Done FIXME

* Fix

* Fix: CLI

* Fix: migration

* API tests

* Test info

* Tests

* More tests

* fix: lint

* Fix: authz

* Address PR comments

* Fix

* fix

* fix
2023-02-15 18:24:15 +01:00
Cian Johnston f0f39b4892 chore: break down dbauthz.System into smaller roles (#6218)
- rbac: export rbac.Permissions
- dbauthz: move GetDeploymentDAUs, GetTemplateDAUs,
  GetTemplateAverageBuildTime from querier.go to system.go
  and removes auth checks
- dbauthz: remove AsSystem(), add individual roles for
  autostart, provisionerd, add restricted system role for 
  everything else
2023-02-15 16:14:37 +00:00
Eric Paulsen 84da6056b2 docs: add template-level URL override (#6212) 2023-02-15 10:27:40 -05:00
Steven Masley 4cbbd1376d feat: Turn on rbac check caching (#6202)
* chore: Turn on rbac check caching.

Should not affect much unless authz_querier experiment is
enabled
2023-02-15 08:56:07 -06:00
Mathias Fredriksson fac7c02eeb ci: Add support for release/experimental label (#6208)
Co-authored-by: Ben Potter <ben@coder.com>
2023-02-15 14:23:06 +00:00
Ammar Bandukwala 5e4931efaf chore: add comment that explains require_telemetry behavior (#6211) 2023-02-15 01:40:08 +00:00
Kira Pilot 5e60879fb8 feat: audit addition and removal of licenses (#6125)
* added license audit resource

* audit delete licenses

* added filtering

* remove logs

* making the best of the current UUID situation

* fixed lint

* fix tests

* regen docs

* PR feedback

* PR feedback
2023-02-14 16:34:13 -05:00
Ammar Bandukwala 6e3330a03f feat: add support for telemetry-required licenses (#6194) 2023-02-14 20:26:47 +00:00
Eric Paulsen 15c862fcb5 fix: set Coder read-only fs to null (#6207)
* fix: set Coder read-only fs to null

* chore: readme fixes

* chore: readme fixes v2
2023-02-14 11:04:16 -06:00
Steven Masley 80bde1e2c9 chore: Ensure cancelled errors return proper (#6200)
The authz library returns a 404 if the authorization fails. If the
context is cancelled, then a 404 message is inaccurate.
Add a unit test to ensure context cancelled errors are raised
properly
2023-02-14 10:57:19 -06:00
Mathias Fredriksson 860e2829c5 fix: Prevent race between provisionerd connect and close (#6206)
* fix: Prevent race between provisionerd connect and close

* test: Add detection for provisioner creation after test completion
2023-02-14 16:37:43 +00:00
Steven Masley cde7ff8a2d chore: Fix import rbac on userauth.go (#6205) 2023-02-14 15:57:34 +00:00
Kyle Carberry 51f17b1820 fix: allow disabling all password auth even if owner (#6193)
* fix: allow disabling all password auth even if owner

Removes any and all ability to auth with a password.

* Hide create user if password auth is disabled
2023-02-14 08:58:12 -06:00
Mathias Fredriksson 41ae01d2e9 fix: Improve closure of provisioner and agent tailnet dial (#6199) 2023-02-14 14:57:48 +00:00
Mathias Fredriksson 5df7872661 fix: Improve use of context in websocket.NetConn code paths (#6198) 2023-02-14 16:42:55 +02:00
Steven Masley 6fb8aff6d0 feat: Add initial AuthzQuerier implementation (#5919)
feat: Add initial AuthzQuerier implementation
- Adds package database/dbauthz that adds a database.Store implementation where each method goes through AuthZ checks
- Implements all database.Store methods on AuthzQuerier
- Updates and fixes unit tests where required
- Updates coderd initialization to use AuthzQuerier if codersdk.ExperimentAuthzQuerier is enabled
2023-02-14 14:27:06 +00:00
Mathias Fredriksson ebdfdc749d test: Make cli speedtest more reliable (#6187)
We now wait for the agent to be connected/ready before start.
2023-02-14 11:23:04 +02:00
dependabot[bot] 1c4e1d8ded chore: bump github.com/gin-gonic/gin from 1.7.0 to 1.7.7 (#6146)
Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.7.0 to 1.7.7.
- [Release notes](https://github.com/gin-gonic/gin/releases)
- [Changelog](https://github.com/gin-gonic/gin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gin-gonic/gin/compare/v1.7.0...v1.7.7)

---
updated-dependencies:
- dependency-name: github.com/gin-gonic/gin
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-13 19:33:11 -06:00
Kyle Carberry 2d0a69ba47 fix: require client pipe to be closed in provisionerd test (#6188)
https://github.com/coder/coder/actions/runs/4165019548/jobs/7207442687
2023-02-14 00:46:05 +00:00
Steven Masley 733f58c76d chore: Force license uuids to not be null (#6012)
* chore: Force license uuids to not be null

* All unit tests generate uuids for licenses

* Update migration files to new numbers

* Put migration in transaction
2023-02-13 18:21:58 -06:00
Colin Adler a54de6093b feat: add coder ping (#6161) 2023-02-13 10:38:00 -06:00
Mathias Fredriksson 2157bff13f fix: Clean up conn on NewStream error in memDRPC (#6182) 2023-02-13 17:27:10 +02:00
Mathias Fredriksson d355783faa test: Fix cli delete test (#6183)
We were waiting for Cleaning Up which never appeared:

https://github.com/coder/coder/actions/runs/4163971602/jobs/7205007285
2023-02-13 14:54:38 +00:00
Marcin Tojek a064678b8a fix: Update flake.lock to fix Go build (#6173) 2023-02-13 11:05:28 +01:00
Mathias Fredriksson a56df46d0f fix: Update github.com/coder/retry to remove initial delay (#6160) 2023-02-13 11:54:43 +02:00
Kyle Carberry c0c83f17b2 fix: follow tailscale idioms for when to update nodes (#6164) 2023-02-10 16:59:24 -06:00
Bruno Quaresma b171cb562c fix(site): Support underscore files (#6159) 2023-02-10 16:52:56 -03:00
Mathias Fredriksson 2dbe00ae44 fix(api): Allow workspace agent coordinate to report disconnect (#6152) 2023-02-10 20:23:02 +02:00
Steven Masley 6189035e98 feat: Add option to enable hsts header (#6147)
* feat: Add option to enable hsts header
* Update golden files
2023-02-10 10:52:49 -06:00
Bruno Quaresma 77afdf71dc fix(site): Show folders in the template version editor (#6145) 2023-02-10 13:22:20 -03:00
Steven Masley 32fbd10a1f chore: Optimize parial rego execution byte allocations (#6144)
* chore: Implement benchmark for authorizer.Prepare

Identify time + alloc cost before optimizing
2023-02-10 08:39:45 -06:00
Cian Johnston ab9cba9396 chore: update template examples and docs to install code-server under /tmp (#6138)
Updates templates examples and docs to pass the --method standalone argument
to code-server install script, and installs code-server under /tmp/code-server.

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

---------

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-02-10 13:36:46 +00:00
Colin Adler 4432cd08d6 chore: update tailscale (#6091) 2023-02-09 21:43:18 -06:00
Steven Masley e6da7afd33 feat: Add cachable authorizer to elimate duplicate rbac calls (#6107)
* feat: Add cachable authorizer to elimate duplicate rbac calls

Cache is context bound, so only prevents duplicate rbac calls in
the same request context.
2023-02-09 20:14:31 -06:00
Mathias Fredriksson 6f3f7f2937 fix(agent): Allow signal propagation when running as PID 1 (#6141) 2023-02-09 23:07:21 +02:00
Steven Masley af59e2bcfa chore: Optimize rego policy input allocations (#6135)
* chore: Optimize rego policy evaluation allocations

Manually convert to ast.Value instead of using generic
json.Marshal conversion.

* Add a unit test that prevents regressions of rego input

The optimized input is always compared to the normal json
marshal parser.
2023-02-09 13:47:17 -06:00
Eric Paulsen 22f6400ea5 helm: add deployment securityContext values (#6136)
* helm: add deployment securityContext values

* rm: podSecurityContext
2023-02-09 13:26:35 -05:00
Mathias Fredriksson b46d0d693f fix: Extend migration fixture test with down and fix 000045 (#6130) 2023-02-09 16:59:54 +02:00
Marcin Tojek 049984ce7f docs: Add missing body parameter (#6132) 2023-02-09 14:02:03 +00:00
Bruno Quaresma 4493649d7e refactor(site): Add bottom spacing to the dashboard layout (#6084) 2023-02-08 21:53:42 -03:00
Kyle Carberry 4827d9edb8 fix: increase generated password length resolve flake (#6116) 2023-02-08 20:59:07 +00:00
Kyle Carberry d803bb76d5 feat: automatically open workspaces in vscode in the dir specified (#6115)
This makes a one-click magical experience not only possible, but really nice too!
2023-02-09 06:38:34 +10:00
Kyle Carberry 2ed0eafd75 feat: add minimum password entropy requirements (#6090)
* feat: add minimum password entropy requirements

* Fix all the tests

* Fix E2E tests
2023-02-08 14:10:08 -06:00
Marcin Tojek fe725f76bb fix: Allow to stop or remove workspaces using rich and old parameters (#6099)
* fix: Allow to stop or remove workspaces using rich and old parameters

* Fix
2023-02-08 14:09:52 -06:00
Kyle Carberry 1617268859 fix: stop redirecting away from wildcard url (#6113)
Fixes #6097.
2023-02-08 13:48:17 -06:00
Steven Masley 8dba66c535 chore: Use dbgen in unit test (#6111)
* chore: Use dbgen in unit test

- organizationparam_test
- templateparam_test

* Use dbgen in all unit tests vs insert methods

* fixup! Use dbgen in all unit tests vs insert methods

---------

Co-authored-by: Cian Johnston <cian@coder.com>
2023-02-08 13:47:05 -06:00
Kira Pilot 7a1731b620 chore: change build audit log string to be clearer (#6093)
* changed bbuild string

* clean up friendly string

* using Trans component

* general cleanup

* fixed tests

* fix lint

* fixing bolding

* removing dead strings in auditLogRow

* fix tests
2023-02-08 13:06:57 -05:00
Dean Sheather d60ec3e4bf feat: add JSON output format to many CLI commands (#6082) 2023-02-08 17:09:38 +00:00
Ben Potter 5655ec6862 Revert "fix: open terminal and coder_app in a new tab, not window (#6044)" (#6106)
This reverts commit a655f03a1e.
2023-02-08 15:57:27 +00:00
Ben Potter 0ccab0c420 fix: do not build Packer images on dry runs (#6105) 2023-02-08 15:51:16 +00:00
Dean Sheather b5e5959649 chore: fix flake in create-admin-user test (#6103) 2023-02-08 15:36:43 +00:00
Kira Pilot 3da33d23a4 chore: fix status color for redirects on audit page (#6096) 2023-02-08 09:40:51 -05:00
Dean Sheather e17ed9f5e6 chore: diable ironbank image scanning (#6104) 2023-02-08 14:40:27 +00:00
Mathias Fredriksson 33f2c8fef5 ci: Fix scripts/release/publish.sh execrelative path (#6101)
Behavior of `lib.sh` changed in: #5934
2023-02-08 13:32:06 +00:00
Mathias Fredriksson f6da0a6945 ci: Fix silent missing metadata for release notes (#6089)
* Fix use of `mapfile < <(cmd)` which silently hid errors

* Fix script paths since `SCRIPT_DIR` changed in `lib.sh`

* Set `GITHUB_TOKEN` in release.yaml
2023-02-08 14:40:52 +02:00
Marcin Tojek 1dc477819e feat: render Markdown in rich parameter descriptions (#6098) 2023-02-08 12:57:12 +01:00
Eric Paulsen f24547ecb1 feat: add iron bank Dockerfile & manifest (#5934)
* feat: add iron bank Dockerfile & manifest

Co-authored-by: Dean Sheather <dean@deansheather.com>

* add: tfrc file

* mv: ironbank/ /scripts

* fixup! Merge branch 'main' into iron-bank

* feat: add ironbank trivy scanning

* fixup! feat: add ironbank trivy scanning

* fixup! feat: add ironbank trivy scanning

* fixup! feat: add ironbank trivy scanning

* fixup! feat: add ironbank trivy scanning

---------

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-02-07 18:09:33 -05:00
Kyle Carberry 691495d761 feat: add expanded_directory to the agent for extension support (#6087)
This will enable opening the default `dir` of an agent in
the VS Code extension!
2023-02-07 21:35:09 +00:00
Kyle Carberry f6effdb63e fix: redirect the user to the home directory if dir is not set (#6085)
This was blocking SSH connections from being established if a dir
that wasn't created yet is set.
2023-02-07 20:28:41 +00:00
Colin Adler bde4ffebe5 docs: add auth paragraph about oidc group sync (#6064) 2023-02-07 13:22:02 -06:00
Mathias Fredriksson c63dcf13c2 fix(dogfood): Enable pipefail for startup_script (#6017) 2023-02-07 20:15:09 +02:00
Ben Potter a5f3f02ef8 fix: duplicate list when updating workspaces (#6032) 2023-02-07 10:26:04 -06:00
Kyle Carberry e7ebcb54dc fix: use workspace name when opening links via the terminal (#6077)
This was using the `<workspace>.<agent>` syntax before, which was invalid.
2023-02-07 09:58:11 -06:00
Ben Potter c82e38e2d8 docs: using Coder behind a corporate proxy (#6079)
* docs: using Coder with a corporate proxy

* fix typo
2023-02-07 15:11:03 +00:00
Kira Pilot 4155b085b7 feat: add preset filter for audit logins (#6066) 2023-02-07 09:17:06 -05:00
Kyle Carberry bed37b4208 feat: use wildcard url for local links in the web terminal (#6070) 2023-02-07 07:21:06 -06:00
Marcin Tojek 135a4d87f1 fix: use correct migration number (#6071) 2023-02-07 10:28:44 +01:00
Marcin Tojek b86bce8494 feat!: Validate monotonic numbers for rich parameters (#6046)
* Database changes

* protobuf

* Fix: docs

* workspaces_test

* Validation in coderd

* Fix: resources

* omitempty

* UI changes

* UI tests

* fix
2023-02-07 09:36:13 +01:00
Kyle Carberry e3ae664a29 fix: add typegen for templateVersionEditorXService (#6069)
This was borked before, and actually broken!
2023-02-06 20:30:54 -06:00
Kyle Carberry dd9e1f3d3f feat: add template editor to the ui (#5963)
* Add initial editor

* Fix editor file being reset onChange

* Add updating the active build version

* Update nav height

* Add tabs

* Fix title

* Hide timestamps in build logs

* Add create file dialog

* Add validation for empty path

* Hide resources tab

* Fix label names

* Add rename and delete

* Improve UX

* Add padding to the editor

* Add dirty state

* Hide build logs until a build is made

* Add stories

* Add experiment to enable the template editor

* Fix linting errors

* Fix duplicate fields

* Fix theme type
2023-02-07 01:24:04 +00:00
Kyle Carberry 71a893764e chore: remove CreateAnotherUserWithUser (#6068)
This was not idiomatic Go!
2023-02-06 23:48:21 +00:00
Colin Adler b81d8464df fix: audit log query when Postgres TZ isn't UTC (#6067) 2023-02-06 21:36:39 +00:00
Ben Potter d9e22d74ba fix: wrong URL in rootless podman docs (#6063) 2023-02-06 15:32:59 -06:00
Ammar Bandukwala 3724d81413 chore: simplify error handling in template push (#6065) 2023-02-06 20:35:48 +00:00
Kira Pilot 46fe59f5e7 feat: audit login (#5925)
* added migration for api key resource

* sort of working

* auditing login

* passing  the correct user id

* added and fixed tests

* gen documentation

* formatting and lint

* lint

* audit Github oauth and write tests

* audit oauth and write  tests

* added defer fn for login error auditing

* fixed test

* feat: audit logout (#5998)

* Update coderd/userauth.go

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>

* fix test

* bypassing diff generation if login/logout

* lint

---------

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
2023-02-06 15:12:50 -05:00
Dean Sheather 060eeed5c3 chore: fix depot build pt.2 (#6059) 2023-02-07 03:26:29 +10:00
Kyle Carberry bdddc3e7ae fix: change auto-start to automatically update workspaces (#6053)
Fixes #6049.
2023-02-06 11:12:58 -06:00
Dean Sheather d6947aeaca chore: fix depot build (#6057) 2023-02-06 16:49:33 +00:00
Dean Sheather b45c445255 feat: add git to Docker image (#6034) 2023-02-07 02:30:35 +10:00
Ben Potter a655f03a1e fix: open terminal and coder_app in a new tab, not window (#6044)
* fix!: open coder_app in a new tab, not window

* terminal too
2023-02-06 10:22:24 -06:00
Dean Sheather 4fe221a700 feat: add flag to disable password auth (#5991)
Adds a flag --disable-password-auth that prevents the password login
endpoint from working unless the user has the "owner" (aka. site admin)
role.

Adds a subcommand `coder server create-admin-user` which creates a user
directly in the database with the "owner" role, the "admin" role in
every organization, and password auth. This is to avoid lock-out
situations where all accounts have the login type set to an identity
provider and nobody can login.
2023-02-06 14:58:21 +00:00
Ben Potter 968d7e4dc5 docs: rootless podman support (#6026)
* rootless podman WIP

* docs: rootless podman support
2023-02-06 08:05:38 -06:00
Ben Potter e70b3f2973 chore: add alias helper to develop.sh (#6031)
* chore: add alias helper to develop.sh

* restore formatting

* change alias from feedback
2023-02-06 05:02:34 +00:00
Ben Potter 5931d12d4b chore: use node 16 in dogfood images (#5939) 2023-02-05 22:48:41 -06:00
Ben Potter 90bc5d5b5f docs: add note around offline docs provider versions (#6018) 2023-02-06 04:36:20 +00:00
sharkymark a5e386e54b chore: remove jetbrains projector web ide docs, examples. specify no support (#6033) 2023-02-05 19:40:40 -06:00
Ammar Bandukwala f096915c27 chore(ci): automatically delete stale branches (#6036) 2023-02-04 15:18:11 -06:00
Ammar Bandukwala a422cc00e8 Stream template upload (#6035)
Resolves #5718
2023-02-04 20:07:09 +00:00
Steven Masley 77fd34be94 chore: Action consts should actually be typed as an Action (#6027) 2023-02-03 20:36:37 +00:00
Steven Masley b359dbbd8b chore: Allow RecordingAuthorizer to record multiple rbac authz calls (#6024)
* chore: Allow RecordingAuthorizer to record multiple rbac authz calls

Prior iteration only recorded the last call. This is required for
more comprehensive testing
2023-02-03 19:03:46 +00:00
Cian Johnston 571f5d0e02 chore: add log_statement=all for test-postgres-docker (#6025) 2023-02-03 18:58:31 +00:00
Kyle Carberry 2c2bbcc019 chore: update tests to support fish (#6023)
* fix: update tests to add fish support

* Track connections for SSH sessions to prevent leaks

* Revert SSH conn handling
2023-02-03 12:25:11 -06:00
Dean Sheather cf9abe3a6c feat: add session expiry control flags (#5976)
Adds --session-duration which lets admins customize the default session
expiration for browser sessions.

Adds --disable-session-expiry-refresh which allows admins to prevent
session expiry from being automatically bumped upon the API key being
used.
2023-02-03 17:38:36 +00:00
mh013370 2285a5e8a0 feat: add ability to deploy extra k8s yamls with helm chart (#5942) 2023-02-03 17:32:02 +00:00
Steven Masley a750b1948b test: Use database.Now() for UTC in all tests (#6022)
Fixes a lot of comparison issues with timezones
2023-02-03 17:13:54 +00:00
Mathias Fredriksson 95ff29c2be test: Fix golden gen for long wd paths (#6021) 2023-02-03 18:43:33 +02:00
Bruno Quaresma dffd7953bc fix(site): Minor UI fixes related to avatar components (#6019) 2023-02-03 13:09:16 -03:00
Kira Pilot 6c90701a73 chore: ignore trend line in storybook (#6003) 2023-02-03 09:05:38 -05:00
Steven Masley aab9e3a0f7 chore: Add more objects to dbgen (#6013)
* chore: Add WorkspaceApps to dbgen

* GitSSHKey, UserLink, GitAuthLink
2023-02-03 09:34:35 +00:00
Steven Masley fd2f9dc176 test: Fix unit test to use dbfake over databasefake (#6014) 2023-02-03 03:55:26 +00:00
Kyle Carberry 381d6674ca chore: add install_source to telemetry (#6008)
This will help determine the number of installs from marketplaces!
2023-02-03 01:30:54 +00:00
Steven Masley 8b424f03c2 chore: Rename databasefake --> dbfake (#6011) 2023-02-02 19:28:55 -06:00
Bruno Quaresma f60f06e2c6 fix(site): Only display fields with redisplay enabled during workspace creation (#6004)
* fix(site): Only display fields with redisplay_value during workspace creation

* Fix test

---------

Co-authored-by: Kyle Carberry <kyle@carberry.com>
2023-02-03 01:28:47 +00:00
Steven Masley 2384e9c565 fix: Do not try and write to malformed ssh configs (#6000)
Abort writing the ssh config if it has:
- Out of order coder headers
- More than 1 of each coder header
- Missing 1 or the other coder header
2023-02-02 19:23:42 -06:00
Ben Potter c16b93847a feat: build Packer images every release (#6009) 2023-02-03 01:01:06 +00:00
Steven Masley 2478012827 chore: Add organizationmember and parameter gen functions (#6007) 2023-02-02 18:24:59 -06:00
Steven Masley 41e52310bf chore: Add more dbgen functions (#6005) 2023-02-02 17:21:29 -06:00
Steven Masley 5fe4819669 chore: Pass through AllowUserCancelWorkspaceJobs value to fake db insert (#6006) 2023-02-02 23:08:57 +00:00
Kyle Carberry a5e8911d67 fix: index template versions by template and name (#5993)
* fix: index template versions by template and name

We were incorrectly returning template versions by name relative
to organizations. This could result in an incorrect version being
returned if multiple templates had versions with the same name.

* Fix auth referencing

* Fix route location

* Fix authorize route name

* Fix previous call

* Fix authorize route name
2023-02-02 15:47:53 -06:00
Bruno Quaresma ea7e55fcf9 refactor(site): Adjust icon sizes and show password btn in login page (#5992) 2023-02-02 18:28:30 -03:00
Bruno Quaresma 9ff313a260 refactor(site): Remove version and add template link in workspaces page (#5990) 2023-02-02 18:27:56 -03:00
Kira Pilot a70e722e7f fix: hide IP on workspace build logs (#5997) 2023-02-02 20:22:36 +00:00
Kyle Carberry 2fab310ca4 fix: match ubuntu tags on dogfood (#5996)
* fix: match ubuntu tags on dogfood

golangci-lint needs GLIBC>=2.32 which made me notice
that we're building binaries on a difference Ubuntu
version than we dev on.

* Fix sources
2023-02-02 13:58:53 -06:00
Colin Adler 496138b086 feat: assign users to groups returned by OIDC provider (#5965) 2023-02-02 19:53:48 +00:00
Kyle Carberry 026b1cd2a4 chore: update to go 1.20 (#5968)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2023-02-02 12:36:27 -06:00
Bruno Quaresma 4df1031f8b refactor(site): Add press any key option to reconnect on terminal screen (#5969) 2023-02-02 15:19:18 -03:00
Bruno Quaresma 7b49517c18 refactor(site): Add more info on agent outdated tooltip and update action (#5967) 2023-02-02 15:18:59 -03:00
dependabot[bot] 5f089cb5eb chore: bump aquasecurity/trivy-action from 0.5.0 to 0.8.0 (#5944)
Bumps [aquasecurity/trivy-action](https://github.com/aquasecurity/trivy-action) from 0.5.0 to 0.8.0.
- [Release notes](https://github.com/aquasecurity/trivy-action/releases)
- [Commits](https://github.com/aquasecurity/trivy-action/compare/7b7aa264d83dc58691451798b4d117d53d21edfe...9ab158e8597f3b310480b9a69402b419bc03dbd5)

---
updated-dependencies:
- dependency-name: aquasecurity/trivy-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-02 12:11:09 -06:00
dependabot[bot] 5d9263f050 chore: bump chromatic from 6.11.4 to 6.15.0 in /site (#5954)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.11.4 to 6.15.0.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.11.4...v6.15.0)

---
updated-dependencies:
- dependency-name: chromatic
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-02 12:06:51 -06:00
dependabot[bot] e6426d477f chore: bump google.golang.org/grpc from 1.51.0 to 1.52.3 (#5949)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.51.0 to 1.52.3.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.51.0...v1.52.3)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-02 12:05:41 -06:00
dependabot[bot] f5242be0d1 chore: bump github.com/valyala/fasthttp from 1.43.0 to 1.44.0 (#5951)
Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.43.0 to 1.44.0.
- [Release notes](https://github.com/valyala/fasthttp/releases)
- [Commits](https://github.com/valyala/fasthttp/compare/v1.43.0...v1.44.0)

---
updated-dependencies:
- dependency-name: github.com/valyala/fasthttp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-02 12:05:30 -06:00
Kyle Carberry 944c9f6307 chore: downgrade linux runner size to 8 cores (#5984)
I doubt the difference in speed is worth the 2x cost.
2023-02-02 12:00:19 -06:00
Kyle Carberry be00e2541c chore: remove unused workspace_owner_count field (#5958)
This added unnecessary database load, because it's not used!
2023-02-02 17:59:43 +00:00
dependabot[bot] 92c5be971c chore: bump @typescript-eslint/eslint-plugin in /site (#5955)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.38.1 to 5.50.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.50.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-02 11:45:48 -06:00
dependabot[bot] c4b70f3ae1 chore: bump eslint from 8.29.0 to 8.33.0 in /site (#5956)
Bumps [eslint](https://github.com/eslint/eslint) from 8.29.0 to 8.33.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.29.0...v8.33.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-02 11:45:29 -06:00
dependabot[bot] 57ad53c850 chore: bump github.com/moby/moby (#5947)
Bumps [github.com/moby/moby](https://github.com/moby/moby) from 20.10.21+incompatible to 20.10.23+incompatible.
- [Release notes](https://github.com/moby/moby/releases)
- [Commits](https://github.com/moby/moby/compare/v20.10.21...v20.10.23)

---
updated-dependencies:
- dependency-name: github.com/moby/moby
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-02 11:44:55 -06:00
dependabot[bot] f545586320 chore: bump ludeeus/action-shellcheck from 1.1.0 to 2.0.0 (#5945)
Bumps [ludeeus/action-shellcheck](https://github.com/ludeeus/action-shellcheck) from 1.1.0 to 2.0.0.
- [Release notes](https://github.com/ludeeus/action-shellcheck/releases)
- [Commits](https://github.com/ludeeus/action-shellcheck/compare/1.1.0...2.0.0)

---
updated-dependencies:
- dependency-name: ludeeus/action-shellcheck
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-02 11:44:43 -06:00
dependabot[bot] e8e61250a6 chore: bump docker/build-push-action from 3 to 4 (#5946)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 3 to 4.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-02 11:44:27 -06:00
dependabot[bot] 445811b0e0 chore: bump golang.org/x/crypto from 0.3.0 to 0.5.0 (#5950)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.3.0 to 0.5.0.
- [Release notes](https://github.com/golang/crypto/releases)
- [Commits](https://github.com/golang/crypto/compare/v0.3.0...v0.5.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-02 11:44:14 -06:00
Kyle Carberry b9b402cd0c feat!: generate a self-signed certificate if no certificates are specified (#5973)
* feat: generate a self-signed certificate if no certificates are specified

Clouds like AWS automatically navigate to https://<ip-here>. This
allows us to bind to that immediately, serve a self-signed certificate,
then reroute to the access URL.

* Add new flag and deprecate old one

* Fix redirect if not using tunnel

* Add deprecation notice

* Fix TLS redirect

* Run `make gen`

* Fix bad test

* Fix gen
2023-02-02 17:08:35 +00:00
Marcin Tojek e27f7accd7 feat: Group immutable and mutable rich parameters (#5975) 2023-02-02 18:01:18 +01:00
Steven Masley ab1f6ce090 fix: Deleting a user from a group should only delete from a single group (#5977) 2023-02-02 09:46:42 -06:00
Marcin Tojek 271d68c862 feat: Disallow using legacy params with rich params (#5974)
* feat: Disallow using legacy params with rich params

* Fix

* nolint
2023-02-02 16:44:57 +01:00
Bruno Quaresma 01ebfdc9dd fiix(site): Fix custom logo size in Safari (#5966) 2023-02-02 10:42:05 -03:00
Bruno Quaresma c9f3acabd3 fix(site): Don't hide/show errors during requests (#5962) 2023-02-02 10:38:05 -03:00
Bruno Quaresma 8ef0306c08 Revert "docs: Change console to shell and remove unused elements (#5960)" (#5964)
This reverts commit 61dcf643e8.
2023-02-01 17:05:45 -03:00
Ben Potter 936bd5b231 chore: fix broken link in offline docs 2023-02-01 13:16:46 -06:00
Ben Potter bca6244c4e chore: change docs links to latest release 2023-02-01 13:14:49 -06:00
Bruno Quaresma 61dcf643e8 docs: Change console to shell and remove unused elements (#5960) 2023-02-01 18:27:11 +00:00
Mathias Fredriksson e6f5623627 chore: Rename agent statistics server to http api server (#5961) 2023-02-01 20:05:57 +02:00
Marcin Tojek f9ae105a26 feat: Adjust forms to include Rich Parameters (#5856)
* XService: GetTemplateParameters

* Rich parameter input shows up

* Render option icons

* Icons

* WIP

* For testing purposes: template

* Fix: useState

* WIP: dynamic validation

* Yup validation

* Translations

* Remove temporary template

* make fmt

* WIP

* Fix: tests

* Fix: fmt

* URL param

* Refactor

* Test: rich param value

* Storybook

* Fix

* Refactor for testing purposes

* Typo

* test: string validation

* Button: build parameters

* Full screen page

* Fix: navigate

* XState done

* refactor: postWorkspaceBuild

* RichParameterInput rendered

* Fix: bad initial value

* Validation works

* Maybe

* Fix

* Go back button

* GoBack button

* Form

* Fix

* Storybook

* Fix: CreateWorkspacePage

* fmt

* Test

* ns

* fmt

* All tests

* feat: WorkspaceActions depend on template parameters

* Fix
2023-02-01 18:13:11 +01:00
Ben Potter d5e2454b1b chore: rework docker in docker docs (#5876)
* chore: rework docker in docker docs

* Update docs/templates/docker-in-docker.md

Co-authored-by: Kyle Carberry <kyle@coder.com>

* fix typos

---------

Co-authored-by: Kyle Carberry <kyle@coder.com>
2023-02-01 14:55:57 +00:00
Mathias Fredriksson 52ace4b207 fix(agent): Work around lumberjack reopening log file after close (#5941) 2023-02-01 16:04:09 +02:00
Ammar Bandukwala 89bf8dd169 docs: fix broken link in secrets.md
Resolves #5888
2023-01-31 22:49:08 +00:00
Steven Masley 4a6fc40949 feat: Add database data generator to make fakedbs easier to populate (#5922)
* feat: Add database data generator to make fakedbs easier to populate
2023-01-31 15:10:03 -06:00
Jon Ayers c162c0f284 fix: omit users for 'Everyone' group in response (#5937) 2023-01-31 13:30:20 -06:00
Arthur Normand 69fce0488e feat: Allow hiding password auth, changing OpenID Connect text and OpenID Connect icon (#5101)
* Allow hiding password entry, changing OpenID Connect text and OpenID Connect icon

* Docs

* Cleaning

* Fix Prettier and Go test and TS compile error

* Fix LoginPage test

* Prettier

* Fix storybook

* Add query param to un-hide password auth

* Cleaning

* Hide password by default when OIDC enabled

* Ran prettier, updated goldenfiles and ran "make gen"

* Fixed and added LoginPage test

* Ran prettier

* PR Feedback and split up SignInForm.tsx

* Updated golden files

* Fix auto-genned-files

* make gen -B

* Revert provisioner files?

* Fix lint error

---------

Co-authored-by: Kyle Carberry <kyle@coder.com>
2023-01-31 18:33:25 +00:00
Dean Sheather 480f3b6e43 fix: correct gpg key secret name (#5932) 2023-02-01 04:14:05 +10:00
Ben Potter aa53b86a2d chore: add some helpers to install/upgrade Coder (#5926)
* chore: add some helpers to install/upgrade Coder

* mention winget
2023-01-31 17:33:42 +00:00
Ben Potter ea4a845248 docs: dedicated instructions for Windows installer (#5924)
* docs: dedicated instructions for Windows installer

* changes from feedback
2023-01-31 17:26:37 +00:00
Spike Curtis ac4adabb0a feat: set service account name in helm (#5913)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-01-31 10:35:32 +04:00
Eric Paulsen 5290d5b14a docs: add gitauth validate url var (#5927) 2023-01-30 20:35:22 -05:00
Kyle Carberry 9c1d67e192 docs: support dark and light mode in the readme (#5928)
Shoutout @cmoog
2023-01-30 16:53:54 -06:00
Eric Paulsen e6a3ce7180 docs: add GitLab auth docs (#5923) 2023-01-30 16:14:18 -05:00
Kira Pilot b31b0fd189 fix: audit log broken build links (#5895)
* pushing for guidance

* added test

* PR feedback

* fixed tests

* Update coderd/audit.go

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>

* runnig make gen

---------

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
2023-01-30 18:43:29 +00:00
Kira Pilot 88b5d42967 chore: add more specificity to check_enterprise_imports script (#5920) 2023-01-30 12:00:19 -05:00
Mathias Fredriksson f4d6afb01d feat(agent): Allow specifying log directory via flag or env (#5915) 2023-01-30 18:39:52 +02:00
Kira Pilot fa5b6125a9 fix: ensure fields show up for group resource in docs (#5918)
* fix: ensure fields show up for group resource  in docs

* ran prettier
2023-01-30 10:54:58 -05:00
Marcin Tojek 23176bf036 feat: Support rich parameters in autobuilds (#5916) 2023-01-30 15:34:38 +01:00
Mathias Fredriksson cf8d4029fb feat(agent): Handle signals and shutdown gracefully (#5914)
This change allows the agent to handle common shutdown signals like
interrupt, hangup and terminate and initiate a graceful shutdown.

As long as terraform providers initiate graceful shutdowns via the
aforementioned signals, things like SSH connections will be closed
immediately on shutdown instead of being left hanging/timing out due to
the agent being abruptly killed.

Refs: #4677, #5901
2023-01-30 15:59:13 +02:00
sharkymark 91ef8d90d5 chore: remove code-server release limitation and add image push policy in kubernetes example template (#5831)
* chore: remove code-server release limitation and add image push policy

* restore code-server changes

* chore: remove spaces in pod space

* Format terraform

---------

Co-authored-by: Eric Paulsen <ericpaulsen@coder.com>
Co-authored-by: Kyle Carberry <kyle@carberry.com>
2023-01-30 06:58:45 -05:00
Kyle Carberry 896158c352 fix: remove authentication requirement for /users/login (#5717)
This was noticed by a member of our Discord being incorrectly documented!

https://discord.com/channels/747933592273027093/1063494965130432632/1063503805016182875
2023-01-30 02:46:04 +00:00
dependabot[bot] f5db4bc8be chore: bump ua-parser-js from 1.0.2 to 1.0.33 in /site (#5842)
Bumps [ua-parser-js](https://github.com/faisalman/ua-parser-js) from 1.0.2 to 1.0.33.
- [Release notes](https://github.com/faisalman/ua-parser-js/releases)
- [Changelog](https://github.com/faisalman/ua-parser-js/blob/master/changelog.md)
- [Commits](https://github.com/faisalman/ua-parser-js/compare/1.0.2...1.0.33)

---
updated-dependencies:
- dependency-name: ua-parser-js
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-29 20:33:45 -06:00
mh013370 d5d9cc8d8a feat: add init containers to the helm chart (#5874)
* add init containers to coder deployment

* fix formatting issues
2023-01-29 20:02:55 -06:00
dependabot[bot] 3980f15340 chore: bump crate-ci/typos from 1.13.3 to 1.13.9 (#5906)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.13.3 to 1.13.9.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.13.3...v1.13.9)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-30 01:56:34 +00:00
Ammar Bandukwala 4eaa2d63b0 chore(.github): relax stale bot (#5902)
At 60 days it was more spammy than helpful.
2023-01-29 19:52:44 -06:00
Kyle Carberry 12314d7dc5 update readme (#5911) 2023-01-29 19:45:00 -06:00
Kyle Carberry b423218615 chore: remove markdown-lint-check
It's broken for some unfortunate reason!
2023-01-29 23:34:52 +00:00
Kyle Carberry b4a1c32ed3 chore: run markdown-link-check before linting types 2023-01-29 23:29:57 +00:00
Kyle Carberry 0d08065488 fix: use a waitgroup to ensure all connections are cleaned up in agent (#5910)
* fix: use a waitgroup to ensure all connections are cleaned up in agent

There was a race where connections would be created at the same time as close.
The `net.Conn` produced by Tailscale doesn't close then the listener does.

* Remove accidental test
2023-01-29 17:20:30 -06:00
Kyle Carberry ce36a84dd5 fix: specify folder path for markdown-lint-check
This was checking node_modules I believe causing it to hang.
2023-01-29 22:36:47 +00:00
Kyle Carberry a911ddaa7b fix: access GetUserByID in database fake without lock to resolve race (#5909)
See: https://github.com/coder/coder/actions/runs/4038615993/jobs/6942750837
2023-01-29 16:03:29 -06:00
Kyle Carberry 7ad87505c8 chore: move agent functions from codersdk into agentsdk (#5903)
* chore: rename `AgentConn` to `WorkspaceAgentConn`

The codersdk was becoming bloated with consts for the workspace
agent that made no sense to a reader. `Tailnet*` is an example
of these consts.

* chore: remove `Get` prefix from *Client functions

* chore: remove `BypassRatelimits` option in `codersdk.Client`

It feels wrong to have this as a direct option because it's so infrequently
needed by API callers. It's better to directly modify headers in the two
places that we actually use it.

* Merge `appearance.go` and `buildinfo.go` into `deployment.go`

* Merge `experiments.go` and `features.go` into `deployment.go`

* Fix `make gen` referencing old type names

* Merge `error.go` into `client.go`

`codersdk.Response` lived in `error.go`, which is wrong.

* chore: refactor workspace agent functions into agentsdk

It was odd conflating the codersdk that clients should use
with functions that only the agent should use. This separates
them into two SDKs that are closely coupled, but separate.

* Merge `insights.go` into `deployment.go`

* Merge `organizationmember.go` into `organizations.go`

* Merge `quota.go` into `workspaces.go`

* Rename `sse.go` to `serversentevents.go`

* Rename `codersdk.WorkspaceAppHostResponse` to `codersdk.AppHostResponse`

* Format `.vscode/settings.json`

* Fix outdated naming in `api.ts`

* Fix app host response

* Fix unsupported type

* Fix imported type
2023-01-29 15:47:24 -06:00
Kyle Carberry e49f41652f chore: merge codeql checks to run in parallel (#5907)
* chore: merge codeql checks to run in parallel

This reduces a check and should maintain ~the same CI time.

* fix: close reconnecting pty conn when exiting agent

Fixes https://github.com/coder/coder/actions/runs/4038282899/jobs/6942170850

* Fix closing when agent fails

* Fix conpty

* Fix contrib

* Skip runner tests for being flakes

* Fix gpg key test

* Fix golden files

* Fix comments

* Fix closed

* Fix capitalized title

* Add a timeout when checking for dead links
2023-01-29 15:28:22 -06:00
Kyle Carberry 8487127f5c chore: skip reconnecting pty scale tests (#5908)
* fix: close reconnecting pty conn when exiting agent

Fixes https://github.com/coder/coder/actions/runs/4038282899/jobs/6942170850

* Fix conpty

* Fix contrib

* Skip runner tests for being flakes

* Fix gpg key test

* Fix golden files

* Fix comments
2023-01-29 14:53:49 -06:00
Kyle Carberry 33c6260efb chore: merge CI linting jobs (#5904)
* chore: merge CI linting jobs

* Merge the `markdown-lint-check` step into `lint`

* Rename `coder.yaml` to `ci.yaml`

* Improve casing of security workflow

* Remove unused workflows and merge into contrib

* Format ci.yaml

* Fix CodeQL language

* Fix github action name
2023-01-29 13:16:48 -06:00
Kyle Carberry eaf1b95e70 chore: disable auto generated tag for CLI docs (#5905)
This was causing `make gen` to fail as the days went on!
2023-01-29 12:58:12 -06:00
sharkymark 2312bc4a6e docs: added alpha jetbrains gateway coder plugin | remove code-server version parameter (#5900) 2023-01-28 19:09:41 -06:00
Kyle Carberry 7880b941b8 docs: remove quote from README 2023-01-27 21:24:54 -06:00
Mathias Fredriksson a1212014df chore(examples): Add login_before_ready and startup_script_timeout (#5880) 2023-01-27 21:01:48 +00:00
Mathias Fredriksson 90c4d5d28a docs: Document agent readiness issues (startup script) (#5877)
Refs: #5749, #5851
2023-01-27 22:23:47 +02:00
Mathias Fredriksson 981cac5e28 chore: Invert delay_login_until_ready, now login_before_ready (#5893) 2023-01-27 20:07:47 +00:00
Kira Pilot 8a5760a2fe chore: replace AuditableGroup label in docs (#5894) 2023-01-27 13:36:00 -05:00
Bruno Quaresma e0d48e7d79 docs: Add CLI docs (#5879) 2023-01-27 18:10:40 +00:00
Mathias Fredriksson a753703e47 feat(cli): Add support for delay_login_until_ready (#5851) 2023-01-27 19:05:40 +02:00
Kira Pilot cf93fbd39a chore: update Audit docs to include Audit Actions (#5887)
* chore: update Audit docs to include Audit Actions

* regenerated audit docs

* adjusted check_enterprise_imports.sh

* PR feedback

* changing script back for now as CI faiiling
2023-01-27 11:50:21 -05:00
Kyle Carberry b20cb993bd fix: loop variable captured by func literal in parameters test (#5878)
I noticed this when adding a new parameter type. There's a test
case for an empty string that returned false for validation,
but appears like it could be true.

If there is no value for a string, then the default is used.
In this case there is no default, but that's technically fine
I believe.
2023-01-27 09:37:55 -06:00
Kira Pilot e663eaad96 chore: remove flaking e2e test (#5884) 2023-01-26 23:10:01 -03:00
Kira Pilot 3d58e6912a chore: removing unaudited resources (#5885)
* chore: removing unaudited resources

* cleaned up tests

* CI errors
2023-01-26 18:14:09 -05:00
Kira Pilot e2bea2d20f chore: autogenerate audit log documentation (#5862)
* added script for table creation

* added tags to audit-logs.md

* removed log

* removed empty block line

* PR feedback

* modify check_unstaged

* third times the charm maybe

* spelling

* relative path

* excluding from the right script this time

* sorted resources to ensure table order

* running make cmd

* running make again

* ensuring order on subtable
2023-01-26 18:12:12 -05:00
Colin Adler cc694a55bc feat: add debug info to HA coordinator (#5883) 2023-01-26 16:32:38 -06:00
Colin Adler 52ecd35c8f fix(wsconncache): only allow one peer per connection (#5886)
If an agent went away and reconnected, the wsconncache connection would
be polluted for about 10m because there would be two peers with the
same IP. The old peer always had priority, which caused the dashboard to
try and always dial the old peer until it was removed.

Fixes: https://github.com/coder/coder/issues/5292
2023-01-26 22:23:35 +00:00
Steven Masley b0a16150a3 chore: Implement standard rbac.Subject to be reused everywhere (#5881)
* chore: Implement standard rbac.Subject to be reused everywhere

An rbac subject is created in multiple spots because of the way we
expand roles, scopes, etc. This difference in use creates a list
of arguments which is unwieldy.

Use of the expander interface lets us conform to a single subject
in every case
2023-01-26 14:42:54 -06:00
ElliotG 5c54d8b8cd docs: create a SECURITY.md file (#5875) 2023-01-26 14:13:36 -06:00
Mathias Fredriksson 496beae807 Revert "feat(dogfood): install nix package manager (#5308)" (#5871) 2023-01-26 15:41:59 +00:00
Geoffrey Huntley bfc8a1094b feat(dogfood): install nix package manager (#5308)
Co-authored-by: Dean Sheather <dean@deansheather.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Co-authored-by: Kyle Carberry <kyle@carberry.com>
2023-01-26 16:39:30 +02:00
Bruno Quaresma 721957dee3 chore(site): Ignore progress build bar on Chromatic (#5869) 2023-01-26 10:45:59 -03:00
Josh Goldberg 43a441fe63 chore(site): align ESLint config to typescript-eslint's recommended-requiring-type-checking (#5797) 2023-01-26 10:32:50 -03:00
Colin Adler dd8eab5675 fix: cache disconnected agent names in tailnet coordinator debug (#5870) 2023-01-25 21:23:14 -06:00
Presley Pizzo 16d8cc4176 feat(site): Add deployment-wide DAU chart (#5810) 2023-01-25 22:03:47 -03:00
Bruno Quaresma e7b8318b87 refactor(site): Normalize avatar components (#5860) 2023-01-26 00:54:53 +00:00
Colin Adler 233492b75d fix: ensure coordinator debug output is always sorted (#5867) 2023-01-26 00:29:51 +00:00
Ammar Bandukwala 5da4b5358a docs: use and in enterprise feature matrix (#5866)
The grey X was ambiguous.
2023-01-25 22:58:53 +00:00
Eric Paulsen 98011570be fix: agent log location (#5742) 2023-01-25 17:45:50 -05:00
Cian Johnston 8735f51047 feat(coder): add authz_querier experiment (#5858)
* feat(coderd): add authz_querier experiment

* coderdtest: wire up authz_querier

* wire up AuthzQuerier in coderd

* remove things that do not yet exist in this timeline

* add newline

* comment unreachable code
2023-01-25 21:35:53 +00:00
Colin Adler 1cd5f38cb0 feat: add debug server for tailnet coordinators (#5861)
Implements a Tailscale-like debug server for our in-memory coordinator. This should provide some visibility into why connections could be failing.
Resolves: https://github.com/coder/coder/issues/5845

![image](https://user-images.githubusercontent.com/6332295/214680832-2724d633-2d54-44d6-a7ce-5841e5824ee5.png)
2023-01-25 21:27:36 +00:00
Kyle Carberry 8830ddfd56 docs: update the readme to reduce unnecessary text (#5837)
The README was starting to get quite large, and I felt it was a bit bloaty.

- Removes Twitter badge (the API was removed, so it wasn't working anyways)
- Adds tagline to the title (an experiment, but worth a shot)
- Reduces highlights
- Removes recommended reading (people want to get started asap on a repo)
- Updates doc links `/docs/coder-oss` -> `/docs/v2`
- Moves comparison to the bottom
- Removes adopters.md (we never promoted this, so it hasn't been used)
2023-01-25 14:49:15 -06:00
Steven Masley 08412fd1af chore: Remove unused SQL functions (#5857)
* chore: Remove unused sql functions
- GetProvisionerDaemonByID
- UpdateProvisionerDaemonByID
- GetUserGroups
- GetWorkspaceCountByUserID
- GetLatestAgentStat
2023-01-25 11:30:12 -06:00
Steven Masley b678309fc9 chore: Authz should support non-named roles (#5855)
* chore: Authz should support non-named roles

Named roles are a construct for users to assign/interact with roles.
For authzlayer implementation, we need to create "system" users.
To enforce strict security, we are making specific roles with
the exact required permissions for the system action.
These new roles should not be available to the user. There is a
clear code divide with this implementation that allows a RoleNames
implemenation for users to user, and system users can create their
own implementation
2023-01-25 10:54:16 -06:00
Bruno Quaresma de66f0d540 docs: Add frontend guide (#5852) 2023-01-25 16:15:06 +00:00
Mathias Fredriksson 5c5ddc6b23 fix(site): Hide agent lifecycle unless opted in via delay_login_until_ready (#5850)
Refs: #5835, #5749
2023-01-25 15:23:31 +02:00
Mathias Fredriksson 78ede50be8 ci: Add authors to release notes (#5834) 2023-01-25 11:13:42 +02:00
Kira Pilot 322a4d93e1 feat: add audit log filter for autostarted and autostopped workspace builds (#5830)
* added query

* fixed query

* added example to dropdown

* added documentation

* added test

* fixed formatting

* fixed format
2023-01-24 15:34:29 -05:00
Bruno Quaresma 36384aa3c1 chore(site): Use react-query and refactor the workspaces page to use it (#5838) 2023-01-24 16:22:42 -03:00
Bruno Quaresma bef9e72078 refactor(site): Update agent status to include the lifecycle (#5835) 2023-01-24 14:48:03 -03:00
Bruno Quaresma f65c7ca6b3 chore(site): Improve the e2e setup (#5840) 2023-01-24 14:45:44 -03:00
Kira Pilot 1213162163 feat: adding template version id to workspace build diff (#5841)
* adding template-version-id to build diff

* fix tests
2023-01-24 10:53:04 -05:00
Marcin Tojek 26c69525d1 feat: Validate workspace build parameters (#5807) 2023-01-24 14:22:00 +01:00
Mathias Fredriksson 138887de7e feat: Add workspace agent lifecycle state reporting (#5785) 2023-01-24 14:24:27 +02:00
Kyle Carberry dbfeb5630c fix: update docs link for configuration (#5827)
This was set to the old URL pre docs move!
2023-01-23 18:42:47 -06:00
Colin Adler c3731a1be0 fix: ensure agent websocket only removes its own conn (#5828) 2023-01-23 17:22:34 -06:00
Kira Pilot 443e2180fa feat: indicate when workspace builds are stopped/started by Coder (#5813)
* feat: indicate when workspace_builds are stopped/started by Coder

* added translattion

* added json tags and adjust type
2023-01-23 15:47:58 -05:00
Kira Pilot 882832cc51 chore: removed FE code owners (#5826) 2023-01-23 20:29:18 +00:00
Colin Adler d2ae16dd22 fix: routinely ping agent websocket to ensure liveness (#5824) 2023-01-23 20:05:29 +00:00
Kyle Carberry ba8dd496c3 chore: manually specify templates to embed (#5823)
This is part of a multi-step cleanup for the example templates.
The goal is to have a lot of templates here, and only embed
specific ones we feel are impactful during setup.
2023-01-23 18:12:11 +00:00
Marcin Tojek bbb208e29c feat: Add CLI support for workspace build parameters (#5768)
* WIP

* WIP

* CLI: handle workspace build parameters

* fix: golintci

* Fix: dry run

* fix

* CLI: is mutable

* coderd: mutable

* fix: golanci

* fix: richParameterFile

* CLI: create unit tests

* CLI: update test

* Fix

* fix: order

* fix
2023-01-23 15:01:22 +01:00
Mathias Fredriksson 6a245ab1cc test: Fix GPG test so it does not inherit parent parallelism (#5820)
* test: Fix GPG test so it does not inherit parent parallelism

Running a subtest in a parent with `t.Parallel()` and using `t.Setenv`
is not allowed in Go 1.20, so we move it to a separate test function.

* Fix shadowed import
2023-01-23 11:40:41 +00:00
Cian Johnston 73afdd7c09 chore: agent_test.go: use ptty.Peek() instead of expecting caret in TestAgent_SessionTTYShell (#5821) 2023-01-23 11:23:25 +00:00
Mathias Fredriksson 8afdf24d10 chore: Update sqlc to v1.16.0 (#5788)
* chore: Update sqlc to v1.16.0

* chore: Fix cases where types became Null-types

* chore: Set parameter_schemas default_destination_scheme and default_source_scheme to NOT NULL

* chore: Add enum validation to database fake

* chore: Fix all tests that skipping enum values

* fix: Use correct err in providionerdserver audit log failure log
2023-01-23 13:14:47 +02:00
sharkymark f67acac2b7 docs: updated diagram with git provider logos (#5816) 2023-01-21 11:07:39 -08:00
Dean Sheather 37628c8b5b fix: comment on winget PR correctly (#5789) 2023-01-21 00:27:58 +00:00
Bruno Quaresma b045734b6a feat: Add use template button to template row (#5811) 2023-01-20 17:29:16 -03:00
Kira Pilot 0e58772f5b fix: filter workspace_build resource on start/stop action (#5809)
* fix: ufilter workspace_build resource on start/stop action

* added preset filter for workspace_build filtering

* cleaning up the preset filters
2023-01-20 13:23:13 -05:00
Bruno Quaresma 918c37c358 chore: Ignore expired at on chromatic (#5808) 2023-01-20 12:41:54 -03:00
Colin Adler 8819f798f8 fix(helm): revert app.kubernetes.io/part-of as a selector (#5806)
Deployment selectors are immutable!
2023-01-20 05:31:05 +00:00
Kyle Carberry 546a8931aa chore: move vscode local out of experiments (#5773)
We've been dogfooding the VS Code extension for a while,
and it seems stable enough that it's overall positive
to release!
2023-01-20 04:32:59 +00:00
Ammar Bandukwala b91b4533d8 docs: fix typo 2023-01-19 20:30:50 -06:00
Bruno Quaresma ff69c0e70f refactor: Refactor auth provider (#5782) 2023-01-19 21:02:29 -03:00
Kira Pilot a0a959c7a5 feat: better display secret audit values (#5801) 2023-01-19 17:47:53 -05:00
Colin Adler 341b7caff6 fix(examples): move k8s email label to an annotation (#5802) 2023-01-19 22:03:53 +00:00
Mathias Fredriksson 320cd3f3bc feat(cli): Add restart subcommand (#5799)
Fixes #2464
2023-01-19 23:56:41 +02:00
Ben Potter 8e5aefb841 docs: architecture diagram improvements (#5784)
* docs: architecture diagram improvements

* use new diagram
2023-01-19 21:39:04 +00:00
Ben Potter 9c563af459 fix: disable autocomplete for deletion dialogs (#5794) 2023-01-19 20:24:41 +00:00
Steven Masley 08cce81ac8 feat: Implement allow_list for scopes for resource specific permissions (#5769)
* feat: Implement allow_list for scopes for resource specific permissions

Feature that adds an allow_list for scopes to specify particular resources.
This enables workspace agent tokens to use the same RBAC system as users.

- Add ID to compileSQL matchers
* Plumb through WithID on rbac objects
* Rename Scope -> ScopeName
* Update input.json with scope allow_list

Co-authored-by: Cian Johnston <cian@coder.com>
2023-01-19 13:41:36 -06:00
Mathias Fredriksson f0df0686f9 chore(dogfood): Avoid calling ~/personalize unless executable (#5793) 2023-01-19 19:02:15 +00:00
Mathias Fredriksson 2ed70c7af9 chore: Fix make gen for docs/manifest.json (#5792) 2023-01-19 18:16:36 +00:00
Bruno Quaresma 36e97e3fa1 chore: update JS teests in CI (#5786) 2023-01-19 16:48:32 +00:00
Ben Potter 9e346b3251 docs: scaling Coder (#5550)
* docs: scaling Coder

* change icon

* Update docs/admin/scale/index.md

Co-authored-by: Dean Sheather <dean@deansheather.com>

* Update docs/admin/scale/index.md

Co-authored-by: Dean Sheather <dean@deansheather.com>

* Update docs/admin/scale/index.md

Co-authored-by: Dean Sheather <dean@deansheather.com>

* add prom link

* add plumbing for gke doc

* add limits/requests

* changes from feedback

* change

* simplify

* changes from colin feedback

* more edits from testing

* more fixes from Colin feedback

* clarify providers have different resource requirments

* kylecarbs feedback

* format

* explain concurrency

* move doc

* consolidate table

* fix broken links

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-01-19 07:12:39 -08:00
Mathias Fredriksson 1f3b7b658f docs: Add documentation for releases and commit style (#5675) 2023-01-19 15:13:11 +02:00
Bruno Quaresma bd8437b679 refactor: Refactor tokens layout a bit (#5771) 2023-01-19 10:00:59 -03:00
Ben Potter a040bcc0cf docs: clarify access URL in install flow (#5626)
* fix: TLS disabled copy

* clarify default access URL

* add docs for coder address
2023-01-18 23:23:55 +00:00
Dean Sheather 0374af23b2 fix(security)!: path-based app sharing changes (#5772)
This commit disables path-based app sharing by default. It is possible
for a workspace app on a path (not a subdomain) to make API requests to
the Coder API. When accessing your own workspace, this is not much of a
problem. When accessing a shared workspace app, the workspace owner
could include malicious javascript in the page that makes requests to
the Coder API on behalf of the visitor.

This vulnerability does not affect subdomain apps.

- Disables path-based app sharing by default. Previous behavior can be
  restored using the `--dangerous-allow-path-app-sharing` flag which is
  not recommended.

- Disables users with the site "owner" role from accessing path-based
  apps from workspaces they do not own. Previous behavior can be
  restored using the `--dangerous-allow-path-app-site-owner-access` flag
  which is not recommended.

- Adds a flag `--disable-path-apps` which can be used by
  security-conscious admins to disable all path-based apps across the
  entire deployment. This check is enforced at app-access time, not at
  template-ingest time.
2023-01-18 22:56:14 +00:00
Colin Adler b42e2ae81f feat(examples): add labels and antiAffinity to k8s example (#5774) 2023-01-18 22:53:54 +00:00
Colin Adler 45eb26d5d0 fix(scaletest): increase time range check causing flake on MacOS (#5776) 2023-01-18 22:41:14 +00:00
Kyle Carberry 41145a6842 fix: improve error handling when posting workspace agent version (#5775)
A customer ran into an unfortunate error here that we miss!
2023-01-18 22:03:11 +00:00
Kira Pilot 6b68fbbf18 feat: Auditing group members as part of group resource (#5730)
* added AuditableGroup type

* added json tags

* Anonymizing gGroup struct

* adding support on the FE for nested group diffs

* added type for GroupMember

* Update coderd/database/modelmethods.go

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>

* Update coderd/database/modelmethods.go

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>

* fetching group members in group.delete

* passing through right error

* broke out into util function and added tests

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
2023-01-18 15:13:39 -05:00
Cian Johnston 56b996532f feat: add --experiments flag to replace --experimental (#5767)
- Deprecates the --experimental flag
- Adds a new flag --experiments which supports passing multiple comma-separated values or a wildcard value.
- Exposes a new endpoint /api/v2/experiments that returns the list of enabled experiments.
- Deprecates the field Features.Experimental in favour of this new API.
- Updates apidocgen to support type aliases (shoutout to @mtojek).
- Modifies apitypings to support generating slice types.
- Updates develop.sh to pass additional args after -- to $CODERD_SHIM.
2023-01-18 19:12:53 +00:00
Kyle Carberry 47c3d72294 docs: add support for the coder remote extension (#5764) 2023-01-18 13:02:26 -06:00
Bruno Quaresma 537b9df357 refactor: Form page loaders (#5762) 2023-01-18 17:51:48 +00:00
Bruno Quaresma 2117eb4f31 chore: Improve bundle size (#5761) 2023-01-18 17:31:31 +00:00
Colin Adler 6ed4e21e8b feat(examples): add labels and antiAffinity to k8s example (#5763) 2023-01-18 17:01:00 +00:00
Bruno Quaresma 6252f782d8 fix: Setup redirect state (#5759) 2023-01-18 15:28:46 +00:00
Ammar Bandukwala 501cfa9e8d refactor: deduplicate / type license feature code (#5734) 2023-01-17 17:04:29 -06:00
Bruno Quaresma ea1b03f7c9 chore: Remove FE dead code (#5760) 2023-01-17 23:00:10 +00:00
Bruno Quaresma a13614e93d feat: Pre-fill param inputs with query string values (#5758) 2023-01-17 22:56:29 +00:00
Bruno Quaresma 28b2bbd095 refactor: Make navbar and users tab href consistent (#5754) 2023-01-17 19:05:54 -03:00
Mathias Fredriksson c6fb469655 test: Improve TestSSH/ForwardAgent stability on macOS (#5745) 2023-01-17 23:38:27 +02:00
Bruno Quaresma 99f5f44482 fix: Only fetch groups when it is enabled (#5753) 2023-01-17 18:33:34 -03:00
Bruno Quaresma 35d4766810 chore: Remove unused deps (#5756) 2023-01-17 15:56:00 -03:00
Dean Sheather 53c456a442 feat: PGP sign the checksum file in releases (#5757) 2023-01-18 04:45:27 +10:00
Dean Sheather b19d644162 feat: add etag to slim binaries endpoint (#5750) 2023-01-18 04:38:08 +10:00
Bruno Quaresma c377cd0fa9 fix: Move CLI auth screen outside of dashboard (#5755) 2023-01-17 15:24:22 -03:00
Kira Pilot f0eddbaab4 chore: Support anonymously embedded fields for audit diffs (#5746)
- Anonymously embedded structs are expanded as top level fields.
- Unit tests for anonymously embedded structs

Co-authored-by: Steven Masley <stevenmasley@coder.com>
2023-01-17 12:13:16 -06:00
Ben Potter e37bff6a85 docs: REST API docs are now complete (#5748) 2023-01-17 09:47:54 -08:00
Presley Pizzo 63956eafbf chore: turn e2e tests back on with fixes (#5719)
* Improvement - wip

* Cut out extra waits, increase timeouts

* Fix timeout syntax

* Extend timeouts for safety

* Turn e2e back on

* Format
2023-01-17 12:12:37 -05:00
Dean Sheather 7f5dcc3d6c feat: remove server subcommand from slim binaries (#5747) 2023-01-17 16:58:00 +00:00
Marcin Tojek 1b0560ceb4 feat: Expose workspace build parameters via API (#5743) 2023-01-17 16:24:45 +01:00
Dean Sheather 985fac642e chore: combine dogfood regions, use tailscale (#5741) 2023-01-17 14:20:48 +00:00
Mathias Fredriksson 145d101512 test: Refactor ptytest to use contexts and less duplication (#5740) 2023-01-17 16:02:38 +02:00
Mathias Fredriksson 77e71f3ca4 test: Improve TestSSH/ForwardGPG stability on macOS via pty.ReadRune (#5739)
Writing to stdin for `coder ssh` too early could result in the input
being discarded. To work around this we add a new `ptytest` method
called `ReadRune` that lets us read one character of output. This will
indicate the command is ready to accept input.

It could be one character of the prompt, or of the loading message
waiting for connection to be established.
2023-01-17 15:30:47 +02:00
Mathias Fredriksson db7877012c test: Fix flaky TestServer/Logging/{Multiple,Stackdriver} (#5727)
* test: Fix flaky TestServer/Logging/Multiple

* test: Fix flaky TestServer/Logging/Stackdriver

* test: Add testutil.TempFile and testutil.CreateTemp, cleanup tests
        relying on temp file
2023-01-17 14:14:29 +02:00
Marcin Tojek 6ebadabe4e feat: Add basic support for rich parameters to coderd and provisionerd (#5710) 2023-01-17 11:22:11 +01:00
Kyle Carberry 70fd78673d fix: remove old versions from docs manifest (#5736) 2023-01-16 22:37:31 +00:00
Kyle Carberry bbc1a9a1d8 fix: use UserInfo endpoint with OIDC (#5735)
This resolves a user issue surfaced in Discord:
https://discord.com/channels/747933592273027093/1064566338875576361/1064566338875576361

Both methods of obtaining claims need to be used according
to the OIDC specification.
2023-01-16 16:06:39 -06:00
Ammar Bandukwala 592ce3b118 feat(cli): allow direct tar upload in template update/create (#5720) 2023-01-16 14:32:11 -06:00
Ammar Bandukwala 5f7cce775b fix(site): always use 95th percentile in progress bar (#5733)
This fixes the issue where the bar flickers from "Up to X seconds
remaining" to "X seconds remaining".
2023-01-16 20:31:44 +00:00
Ammar Bandukwala 4420985fad feat(coderd): activity bump for full TTL instead of 1h (#5732) 2023-01-16 20:13:34 +00:00
Kyle Carberry e558a252e7 chore: remove dead docs links from README.md (#5731) 2023-01-16 12:27:39 -06:00
Dean Sheather b55cb0cc73 chore: add trivy vulnerability scanning (#5729) 2023-01-17 03:43:37 +10:00
Mathias Fredriksson f3bbf627a3 chore: Update gotestsum to v1.9.0 and remove debugging (#5726)
* chore: Update gotestsum to v1.9.0 and remove debugging

* chore: Update cloud.google.gpg to fix dogfood build
2023-01-16 17:58:57 +02:00
Dean Sheather 1d777c41f2 chore: move winget publish into release pipeline (#5728) 2023-01-16 15:40:27 +00:00
Mathias Fredriksson 8ae28a321e ci: Add release labels job to pr.yaml to sync labels/title (#5724) 2023-01-16 09:40:42 +00:00
Ammar Bandukwala 8db87c6bae feat(dogfood): run personalize script (#5723) 2023-01-15 18:20:12 -06:00
Olivier Lance cd7b36d41a fix(examples): use correct build args for Docker template (#5721) 2023-01-13 17:24:19 -06:00
Steven Masley eb48341696 chore: More complete tracing for RBAC functions (#5690)
* chore: More complete tracing for RBAC functions
* Add input.json as example rbac input for rego cli

The input.json is required to play with the rego cli and debug
the policy without golang. It is good to have an example to run
the commands in the readme.md

* Add span events to capture authorize and prepared results
* chore: Add prometheus metrics to rbac authorizer
2023-01-13 16:07:15 -06:00
Mathias Fredriksson e821b98918 ci: Revert to local tag creation and push for releases (#5714) 2023-01-13 20:45:31 +02:00
Garrett Delfosse 0cf713869b feat: Manage tokens in dashboard (#5444) 2023-01-13 17:20:03 +00:00
Steven Masley f76ef98a32 chore!: Standardize prometheus time metrics to seconds (#5709)
* chore!: Standardize prometheus time metrics to seconds
* Update prometheus docs
2023-01-13 11:15:25 -06:00
Marcin Tojek f91a0d8c37 chore: mark apidoc files as linguist-generated (#5713) 2023-01-13 18:01:40 +01:00
Bruno Quaresma de16e29566 refactor: Refactor update check banner (#5708) 2023-01-13 13:48:45 -03:00
Presley Pizzo d6543c042f chore: skip e2e tests (#5711)
* Skip e2e tests

* Skip with if
2023-01-13 10:35:18 -06:00
Marcin Tojek dad242a788 feat: Add more swagger checks (#5707) 2023-01-13 16:47:38 +01:00
Ben A 54cc587dad Updated PreconditionFailed status occurences to more appropriate statuses. (#5513) 2023-01-13 08:30:48 -06:00
Ben Potter 967d25fdf7 docs: HA is not experimental (fix) (#5686) 2023-01-13 08:30:22 -06:00
Marcin Tojek deebfcbd53 feat: Validate swagger definitions (#5694)
* docs: audit, deploymentconfig, files, parameters

* Swagger comments in workspacebuilds.go

* structs in workspacebuilds.go

* workspaceagents: instance identity

* workspaceagents.go in progress

* workspaceagents.go in progress

* Agents

* workspacebuilds.go

* /workspaces

* templates.go, templateversions.go

* templateversion.go in progress

* cancel

* templateversions

* wip

* Merge

* x-apidocgen

* NullTime hack not needed anymore

* Fix: x-apidocgen

* Members

* Fixes

* Fix

* WIP

* WIP

* Users

* Logout

* User profile

* Status suspend activate

* User roles

* User tokens

* Keys

* SSH key

* All

* Typo

* Fix

* Entitlements

* Groups

* SCIM

* Fix

* Fix

* Clean templates

* Sort API pages

* Fix: HashedSecret

* WIP

* WIP

* WIP

* Fix: cover workspaceagents

* Assert: consistent ID and summary

* Assert: success or failure defined

* Fix: parallel

* Refactor

* Support enterprise

* Go comment goes to top

* Security

* assertPathParametersDefined

* assertUniqueRoutes

* assertRequestBody

* More fixes

* Fix: exceptions

* Fix field format

* Address PR comments

* Refactor
2023-01-13 12:27:21 +01:00
Colin Adler dcab87358e feat: add stackdriver and json log options to coder server (#5682) 2023-01-12 20:08:23 -06:00
Bruno Quaresma 1229fda1a6 refactor: Clean up routes (#5702)
* refactor: Clean up routes

* Fix tests
2023-01-12 21:03:38 -03:00
Kyle Carberry 67952cf95e fix: move the web terminal out of the dashboard authentication layout (#5699)
Fixes #5698. This was a regression.
2023-01-12 21:44:29 +00:00
Mathias Fredriksson 269e0b3261 ci: Fix release tag push (#5696) 2023-01-12 22:18:10 +02:00
Bruno Quaresma 3861d1c555 refactor: Wrap forms into dashboard layout (#5697) 2023-01-12 17:08:31 -03:00
sharkymark bef6f67b70 docs: remove plans to license restrict oidc and git auth (#5672) 2023-01-12 19:21:56 +00:00
Bruno Quaresma e6072eff59 refactor: Wrap authenticated routes (#5695) 2023-01-12 15:52:16 -03:00
Bruno Quaresma f9f7283e16 refactor: Move deploy settings machine to the layout (#5693) 2023-01-12 17:02:11 +00:00
Bruno Quaresma cd1a2d2d5d refactor: Refactor site roles machine to be used in the page (#5692) 2023-01-12 13:53:46 -03:00
Bruno Quaresma f5a7538637 refactor: Make the navbar wider (#5689) 2023-01-12 16:34:56 +00:00
Mathias Fredriksson a5073a8770 ci: Fix release workflow input booleans, remove snapshot (#5688)
* s/github.event.inputs/inputs/g

* Add run name and prevent non-dry-run releases on non-main branches

* Add logrun to lib.sh
2023-01-12 15:50:58 +00:00
Kira Pilot 575bfabfcb fix: audit log workspace build URL should form with the correct workspace owner (#5674)
* removing workspaceOwner

* querying for workspace build
2023-01-12 09:51:30 -05:00
Kyle Carberry 41b58cd027 fix: open VS Code Remote in the same window to prevent flashing (#5684)
Fixes #5676.
2023-01-11 23:47:44 +00:00
Mathias Fredriksson c7e1ecfe36 ci: Fix release workflow inputs (#5681) 2023-01-11 23:32:25 +00:00
Presley Pizzo 1df72ee093 fix: handle NaN in build time estimate (#5679) 2023-01-11 15:56:21 -05:00
Mathias Fredriksson c0d9e32300 ci: Allow missing commit metadata to be ignored in releases (#5678) 2023-01-11 20:14:04 +00:00
Presley Pizzo 627fbe5874 fix: make build table show empty instead of loading when none are recent (#5666)
* Fix builds to show empty instead of loading

* Switch to backend fix

* Increase e2e test timeout

* Format
2023-01-11 12:18:06 -05:00
Bruno Quaresma a5d39adf3e refactor: Extract ssh logic from auth service (#5670)
* refactor: Extract ssh logic from auth service

* Update site/src/i18n/en/userSettingsPage.json

Co-authored-by: Kira Pilot <kira@coder.com>

Co-authored-by: Kira Pilot <kira@coder.com>
2023-01-11 17:04:42 +00:00
Mathias Fredriksson 8e4af79cb2 ci: Do release tagging in CI and add --draft support (#5652)
* ci: Do release tagging in CI and add --draft support

* Add -h, --help to release.sh

* Add -h, --help to increment_version_tag.sh

* Limit release concurrency

* Add automatic release watching

* ci: Add git config, tag as "GitHub Actions Bot"

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-01-11 18:38:01 +02:00
Dean Sheather e72a2ad907 feat: add SIGQUIT/SIGTRAP handler for the CLI (#5665) 2023-01-11 16:22:20 +00:00
Steve Miller 69241d06e7 docs: Update WebIDE Section Headers (#5669)
* Update header indents

* Bump To Rerun CI
2023-01-11 15:48:29 +00:00
Marcin Tojek d9436fab69 docs: API enterprise (#5625)
* docs: audit, deploymentconfig, files, parameters

* Swagger comments in workspacebuilds.go

* structs in workspacebuilds.go

* workspaceagents: instance identity

* workspaceagents.go in progress

* workspaceagents.go in progress

* Agents

* workspacebuilds.go

* /workspaces

* templates.go, templateversions.go

* templateversion.go in progress

* cancel

* templateversions

* wip

* Merge

* x-apidocgen

* NullTime hack not needed anymore

* Fix: x-apidocgen

* Members

* Fixes

* Fix

* WIP

* WIP

* Users

* Logout

* User profile

* Status suspend activate

* User roles

* User tokens

* Keys

* SSH key

* All

* Typo

* Fix

* Entitlements

* Groups

* SCIM

* Fix

* Fix

* Clean templates

* Sort API pages

* Fix: HashedSecret

* General is first
2023-01-11 16:05:42 +01:00
Marcin Tojek 8e9cbdd71b docs: API users (#5620)
* docs: audit, deploymentconfig, files, parameters

* Swagger comments in workspacebuilds.go

* structs in workspacebuilds.go

* workspaceagents: instance identity

* workspaceagents.go in progress

* workspaceagents.go in progress

* Agents

* workspacebuilds.go

* /workspaces

* templates.go, templateversions.go

* templateversion.go in progress

* cancel

* templateversions

* wip

* Merge

* x-apidocgen

* NullTime hack not needed anymore

* Fix: x-apidocgen

* Members

* Fixes

* Fix

* WIP

* WIP

* Users

* Logout

* User profile

* Status suspend activate

* User roles

* User tokens

* Keys

* SSH key

* All

* Typo

* Fix

* Fix

* Fix: LoginWithPasswordRequest
2023-01-11 14:08:04 +01:00
Marcin Tojek 84120767a7 docs: API templateversions, templates, members, organizations (#5546)
* docs: audit, deploymentconfig, files, parameters

* Swagger comments in workspacebuilds.go

* structs in workspacebuilds.go

* workspaceagents: instance identity

* workspaceagents.go in progress

* workspaceagents.go in progress

* Agents

* workspacebuilds.go

* /workspaces

* templates.go, templateversions.go

* templateversion.go in progress

* cancel

* templateversions

* wip

* Merge

* x-apidocgen

* NullTime hack not needed anymore

* Fix: x-apidocgen

* Members

* Fixes

* Fix
2023-01-11 12:16:09 +01:00
Mathias Fredriksson 5a3985e6be test: Use global swagger handler to avoid data race in tests (#5668) 2023-01-11 12:42:49 +02:00
Ammar Bandukwala 41cefef95a docs: fix minor mistake about resource persistence 2023-01-11 02:12:51 +00:00
Muhammad Atif Ali 370934afdf ci: allow writing security events for CodeQL (#5514) 2023-01-10 19:40:32 -06:00
Joe Previte 2296432e8b docs: update space on prem link (#5628) 2023-01-10 19:37:35 -06:00
Kyle Carberry 01652e8afb fix: disable pointer events on app icons (#5664)
Ben accidentally clicked to open this in a new tab
which seemed kinda janky UX-wise on our part.
2023-01-10 21:42:33 +00:00
Bruno Quaresma f5d623ff3f refactor: User settings page (#5661) 2023-01-10 17:57:08 -03:00
Ammar Bandukwala d5ab06ed68 feat: improve copy in new template wizard (#5659) 2023-01-10 18:46:08 +00:00
Kira Pilot 0171ccbf62 chore: forbid direct react import (#5658) 2023-01-10 13:30:48 -05:00
Michel Racic efee03fdec fix(site): changing password no longer silently trims space chars in a password (#5640) 2023-01-10 11:34:58 -06:00
Presley Pizzo 56a69b7eea chore: add e2e tests for basic template and workspace flow (#5637)
* Fix type error in first user setup

* Save auth state

* Add template creation - wip

Remove saved auth state because it wasn't working

* Try adding the rest of the tests

Can't see if they work yet, waiting on a release

* Update playwright

* Update gitignore

* Write tests

* Format

* Update ignores

* Check that start worked

Co-authored-by: Ben Potter <ben@coder.com>

Co-authored-by: Ben Potter <ben@coder.com>
2023-01-10 12:30:44 -05:00
Cian Johnston 19ae42af53 chore: update lima example to use --with-terraform arg (#5655)
#5586 added the capability for install.sh to download and install Terraform automatically.
Using this now in the example Lima specification.
Also no longer hard-coding the instance name in favour of {{.Instance.Name}} in the output
that gets emitted upon successful instance provisioning.
2023-01-10 17:25:46 +00:00
Kira Pilot f96365a181 chore: remove redundant icon stories (#5656) 2023-01-10 11:53:51 -05:00
Muhammad Atif Ali dda8170427 fix(ci): fixed $vesrion being empty in packages.yaml (#5650) 2023-01-10 10:40:06 -06:00
Colin Adler 4f3ac95a39 fix(helm): use correct antiaffinity label (#5649) 2023-01-10 10:18:58 -06:00
Colin Adler 2effea5806 fix(helm): use correct prometheus port (#5644) 2023-01-10 10:16:56 -06:00
Colin Adler d34540ca30 fix: ignore EINVAL when fsyncing /dev/stdout (#5648) 2023-01-10 10:15:53 -06:00
Kyle Carberry d2ef727064 feat: add experimental button to open vscode locally (#5654)
* feat: add experimental button to open vscode locally

This uses the new Coder extension to open up any workspace
with a single click.

* Update site/src/components/VSCodeDesktopButton/VSCodeDesktopButton.stories.tsx

Co-authored-by: Kira Pilot <kira@coder.com>

Co-authored-by: Kira Pilot <kira@coder.com>
2023-01-10 16:07:40 +00:00
Marcin Tojek a23a471034 docs: update swaggo/swag v1.8.9 (#5590)
* docs: update swaggo/swag v1.8.9

* Fix: format

* swaggo: time.Duration

* swaggo: provisionertype

* Fix: AuthorizationObject

* Fix: enums

* Fix: netip.Addr

* Fix: clickable response properties
2023-01-10 15:47:08 +01:00
Mathias Fredriksson bbe33fef41 chore: Revert title case in release notes (#5653) 2023-01-10 16:04:33 +02:00
Kyle Carberry 52d7dfa253 docs: remove unfinished sentence in templates.md (#5647)
Fixes #5643.
2023-01-09 22:24:09 -06:00
Kyle Carberry 9f6edab53b feat: replace vscodeipc with vscodessh (#5645)
The VS Code extension has been refactored to use VS Code
Remote SSH instead of using the private API.

This changes the structure to continue using SSH, but
output network information periodically to a file.
2023-01-10 04:23:17 +00:00
Joe Previte fa7deaaa5c feat: add storybook for /deployment/security (#5610)
* refactor: move securitysettings to dir

* refactor: split page view SecuritySettingsPage

* feat: add storybook for security page

* fixup
2023-01-09 20:44:43 +00:00
Bruno Quaresma f70726b43c refactor: Extract security logic from auth service (#5635) 2023-01-09 13:18:32 -07:00
Bruno Quaresma fe16b2a06d refactor: Add spacing in the bottom of a page (#5633) 2023-01-09 13:17:48 -07:00
Colin Adler 7bcbf197c1 fix: print correct listen adress in coder server (#5634) 2023-01-09 13:59:23 -06:00
Mathias Fredriksson 68324c7263 chore: Add security section to release notes (#5636) 2023-01-09 19:57:42 +00:00
Muhammad Atif Ali eb8d5b4408 fix(ci): fix winget package submission (#5630)
* fix(ci): fix winget package submission

I removed the step to calculate the version, as somehow the $version was not populated with the version.
Also, GitHub actions suggest removing `:set-output:` as it is deprecated. 

This commit should probably fix the winget package submission using `wingetcreate` cli.

* fixed a typo
2023-01-09 19:46:10 +00:00
Mathias Fredriksson aec15905b5 chore: Add more categories and titles for release notes (#5632)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-01-09 21:19:07 +02:00
Bruno Quaresma 70d71bc7bc refactor: Do not display port forward button if it is disabled (#5604) 2023-01-09 13:38:31 -03:00
dependabot[bot] 34225b0380 chore: bump luxon from 3.1.1 to 3.2.1 in /site (#5624)
Bumps [luxon](https://github.com/moment/luxon) from 3.1.1 to 3.2.1.
- [Release notes](https://github.com/moment/luxon/releases)
- [Changelog](https://github.com/moment/luxon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moment/luxon/compare/3.1.1...3.2.1)

---
updated-dependencies:
- dependency-name: luxon
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-09 13:16:42 -03:00
Joe Previte 6807ad0d1b feat: add storybook for /deployment/userauth (#5609)
* refactor: move deploysettingspage to dir

* refactor: split page/view UserAuthSettings

* feat: add storybook for user auth

* Update site/src/components/DeploySettingsLayout/OptionsTable.tsx
2023-01-09 16:01:22 +00:00
Colin Adler a4ca8ffa65 fix: don't hang forever getting pg version (#5614) 2023-01-06 21:07:22 -06:00
Colin Adler 888766c10d fix: respect global --url flag in coder login (#5613) 2023-01-06 20:57:25 -06:00
Nathanial Spearing 9b602f55e0 feat: Added --with-terraform argument to install coder and terraform together (#5586)
* - Added a `--install-terraform` argument
- Added a unzip command check to the standalone function
	- Cleaner error and help redirect the user to a solution
- Added help info for `--install-terraform` argument
- Fixed standalone install typo (ard64 -> arm64)

* - Corrected formatting errors, and renamed functions

* - Fixed typos
- Added recommend changes for consistency

* Removed unzip check in standalone function

* Fixed styling

* Moved the TERRAFORM_VERSION Var up
2023-01-06 11:54:06 -06:00
Joe Previte 763147e5f2 feat: add storybook for /deployment/network (#5603)
* refactor: move NetworkSettingsPage to dir

* refactor: split page/view NetworkSettings

* feat: add storybook for NetworkSettingsPage
2023-01-06 17:14:01 +00:00
Joe Previte 242676bac3 feat: add storybook for /deployment/gitauth (#5596)
* refactor: move GitAuthSettingsPage to dir

* refactor: split page and view GitAuthSettingsPage

* fixup!: formatting

* refactor: narrow props in git auth view

* feat: add storybook for GitAuthSettingsPageView

* fixup: formatting
2023-01-06 16:58:20 +00:00
Bruno Quaresma aa68e0f8c9 fix: Too many requests during watching template version (#5602) 2023-01-06 13:31:49 -03:00
Dean Sheather f1fe2b5c06 feat: add GPG forwarding to coder ssh (#5482) 2023-01-06 07:52:19 +00:00
Joe Previte 59e919ab4a feat: add storybook for /deployments/general (#5595)
* refactor: split GeneralSettings page <> View

* feat: add story for generalsettingspageview

* Update site/src/pages/DeploySettingsPage/GeneralSettingsPage/GeneralSettingsPageView.tsx

Co-authored-by: Asher <ash@coder.com>

Co-authored-by: Asher <ash@coder.com>
2023-01-05 23:06:16 +00:00
dependabot[bot] 421e529763 chore: bump json5 from 1.0.1 to 1.0.2 in /site (#5553)
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-05 15:55:56 -07:00
Joe Previte bb03df8148 feat: add storybook for /deployment/appearance page (#5582)
* wip

* wip: move appearancesettingspage

* refactor: separate page and view ApperanceSettings

* refactor: create storybook from AppearanceSettingsView

* fixup: formatting and types
2023-01-05 16:16:54 -05:00
Bruno Quaresma 0d30a1eb72 fix: Display service banner after login (#5594) 2023-01-05 21:10:15 +00:00
dependabot[bot] 8ee3e2c541 chore: bump chartjs-adapter-date-fns from 2.0.0 to 3.0.0 in /site (#5528)
* chore: bump chartjs-adapter-date-fns from 2.0.0 to 3.0.0 in /site

Bumps [chartjs-adapter-date-fns](https://github.com/chartjs/chartjs-adapter-date-fns) from 2.0.0 to 3.0.0.
- [Release notes](https://github.com/chartjs/chartjs-adapter-date-fns/releases)
- [Commits](https://github.com/chartjs/chartjs-adapter-date-fns/compare/v2.0.0...v3.0.0)

---
updated-dependencies:
- dependency-name: chartjs-adapter-date-fns
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* added transformer for esm

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kira Pilot <kira.pilot23@gmail.com>
2023-01-05 15:58:04 -05:00
Dean Sheather 5a968e2f93 feat: add flag to disaable all rate limits (#5570) 2023-01-05 18:05:20 +00:00
Bruno Quaresma ab7e676b54 refactor: Refactor user menu (#5591) 2023-01-05 14:06:58 -03:00
Niklas Rosenstein dcf6c20132 feat: add coder.volumes parameter to Helm chart (#5551)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-01-06 01:53:29 +10:00
Marcin Tojek 66fa2a1a8c docs: API workspace agents and builds (#5538) 2023-01-05 15:27:10 +01:00
Cian Johnston e6b17b6ea7 chore: update Lima example (#5588)
* chore: lima: update ubuntu image version

* fix: lima: make docker socket usable by Lima user without sudo

* fix: lima: set access URL to host.lima.internal

* apply suggestion from PR
2023-01-05 11:47:33 +00:00
Muhammad Atif Ali 0124289f1a fix(ci): fix winget installer workflow (#5569)
* fix(ci): add GH_TOKEN env

* chore: fix windows installer build filename

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-01-05 04:56:00 +00:00
Ben Potter 04d45f3c1c fix!: remove AUTO_IMPORT_TEMPLATE for Kubernetes installs (#5401)
* fix!: remove AUTO_IMPORT_TEMPLATE

* chore: remove template auto importing

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-01-05 04:04:32 +00:00
dependabot[bot] 24592332e2 chore: bump github.com/gohugoio/hugo from 0.107.0 to 0.109.0 (#5541)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-05 10:34:53 +10:30
dependabot[bot] 2db9df4491 chore: bump github.com/prometheus/common from 0.37.0 to 0.39.0 (#5544)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-04 23:42:13 +00:00
dependabot[bot] c0dfbdf143 chore: bump emoji-mart from 5.3.3 to 5.4.0 in /site (#5527)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-05 10:00:56 +10:30
Ammar Bandukwala 0b63825a07 site: fix copy in users roles view (#5583) 2023-01-04 17:13:04 -06:00
Joe Previte a231c1a384 fix: styles for <AlertBanner /> (#5579)
* feat: add new story for LoginPageView

* fix: update <AlertBanner /> styles

- align text to the left
- add padding to the top of span inside

* fixup: formatting
2023-01-04 14:46:41 -07:00
Kyle Carberry c51b5a05db fix: add case for non-entitled logo url (#5580)
This was missing from my prior contribution, which
would lead any user to believe they could customize the logo.
2023-01-04 21:39:54 +00:00
Kyle Carberry 0dba2defd1 feat: enable enterprise users to specify a custom logo (#5566)
* feat: enable enterprise users to specify a custom logo

This adds a field in deployment settings that allows users to specify
the URL to a custom logo that will display in the dashboard.

This also groups service banner into a new appearance settings page.
It adds a Fieldset component to allow for modular fields moving forward.

* Fix tests
2023-01-04 15:31:45 -06:00
Bruno Quaresma 175be621cf refactor: Improve roles UI (#5576) 2023-01-04 18:30:35 -03:00
Jan Losinski de0601d611 feat: allow configurable username claim field in OIDC (#5507)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2023-01-04 15:16:31 -06:00
Kyle Carberry 8968a00035 fix: add spacing between the copyright and login box (#5578)
I forgot to commit this before merging my prior PR!
2023-01-04 16:00:25 -03:00
Mathias Fredriksson ebe1b56c08 chore: Switch from npm to yarn in scripts/apidocgen (#5575) 2023-01-04 19:38:48 +01:00
Kyle Carberry a36cd0bd7b refactor: move footer items into the user dropdown (#5562)
* refactor: move footer items into the user dropdown

The items at the bottom looked unprofessional. Users don't
always need to be prompted to join our Discord or see the
active version of Coder.

This moves the items in the user dropdown which looks better.

* Update site/src/components/UserDropdownContent/UserDropdownContent.tsx

Co-authored-by: Asher <ash@coder.com>

* Fix import order

Co-authored-by: Asher <ash@coder.com>
2023-01-04 12:36:25 -06:00
Marcin Tojek 925b29836c docs: improve authentication page (#5567)
* docs: improve authentication page

* Update docs/admin/automation.md

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update docs/admin/automation.md

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Fix

* Fix

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-01-04 10:14:47 -08:00
Dean Sheather 91a4c2dce1 chore: remove address from deployment page (#5565) 2023-01-04 23:50:55 +10:00
Steven Masley 5e540e3439 chore: Log out the failed audit log on failures (#5561) 2023-01-03 17:22:57 -06:00
Bruno Quaresma 4e14cc5207 refactor: Remove template UI from experimental (#5555) 2023-01-03 19:29:38 +00:00
Steven Masley c5128db484 docs: Add auditor role to roles table (#5557)
* docs: Add auditor role to roles table
* make fmt
2023-01-03 12:55:26 -06:00
dependabot[bot] 3e2477f255 chore: bump actions/stale from 6.0.0 to 7.0.0 (#5515)
Bumps [actions/stale](https://github.com/actions/stale) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v6.0.0...v7.0.0)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-03 12:51:26 -06:00
dependabot[bot] ed114ec341 chore: bump golang.org/x/tools from 0.3.0 to 0.4.0 (#5542)
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: golang.org/x/tools
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-03 12:44:37 -06:00
dependabot[bot] f1419bbc49 chore: bump golang.org/x/term from 0.2.0 to 0.3.0 (#5543)
Bumps [golang.org/x/term](https://github.com/golang/term) from 0.2.0 to 0.3.0.
- [Release notes](https://github.com/golang/term/releases)
- [Commits](https://github.com/golang/term/compare/v0.2.0...v0.3.0)

---
updated-dependencies:
- dependency-name: golang.org/x/term
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-03 12:44:31 -06:00
Marcin Tojek e67d131514 docs: audit, deploymentconfig, files, parameters (#5506)
* docs: audit, deploymentconfig, files, parameters

* Fix: mark as binary

* Fix: show format in docs

* Fix: use .swaggo

* Fix: swagger notice

* Swagger notice
2023-01-03 19:21:10 +01:00
Bruno Quaresma 829cfee29d refactor: Improve users table view for non admins (#5547) 2023-01-03 13:21:58 -03:00
dependabot[bot] 5e36fd522c chore: bump cronstrue from 2.14.0 to 2.21.0 in /site (#5545)
Bumps [cronstrue](https://github.com/bradymholt/cronstrue) from 2.14.0 to 2.21.0.
- [Release notes](https://github.com/bradymholt/cronstrue/releases)
- [Changelog](https://github.com/bradymholt/cRonstrue/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bradymholt/cronstrue/compare/v2.14.0...v2.21.0)

---
updated-dependencies:
- dependency-name: cronstrue
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-03 13:21:42 -03:00
dependabot[bot] 3969a8b58b chore: bump prettier from 2.7.1 to 2.8.1 in /site (#5526)
Bumps [prettier](https://github.com/prettier/prettier) from 2.7.1 to 2.8.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.7.1...2.8.1)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-03 10:00:14 -05:00
Mathias Fredriksson 856f0ab6f5 chore: Improve project-wide prettier formatting and ignored files (#5505)
* chore: Improve project-wide prettier formatting and ignored files

* chore: `Run make fmt/prettier`

* Fix gitignore for `.vscode` folder so that ! works

* Add comment in `.prettierrc.yaml` to explain `.editorconfig`

* Remove scripts/apidocgen/markdown-template/README.md

* Use `yq` for processing prettierrc, update lib.sh dependency check

* Add `yq` to Dockerfile and Nix
2023-01-03 15:11:13 +02:00
dependabot[bot] 5435bceaf0 chore: bump tj-actions/branch-names from 6.3 to 6.4 (#5518)
Bumps [tj-actions/branch-names](https://github.com/tj-actions/branch-names) from 6.3 to 6.4.
- [Release notes](https://github.com/tj-actions/branch-names/releases)
- [Changelog](https://github.com/tj-actions/branch-names/blob/main/HISTORY.md)
- [Commits](https://github.com/tj-actions/branch-names/compare/v6.3...v6.4)

---
updated-dependencies:
- dependency-name: tj-actions/branch-names
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:42:58 -06:00
Marcin Tojek 8bb7e17bf1 chore!: remove GET workspaceagents/me/report-stats (#5530)
* chore!: remove GET workspaceagents/me/report-stats

* Fix: tests
2023-01-02 21:38:51 +01:00
dependabot[bot] d124fab642 chore: bump jaxxstorm/action-install-gh-release from 1.7.1 to 1.9.0 (#5516)
Bumps [jaxxstorm/action-install-gh-release](https://github.com/jaxxstorm/action-install-gh-release) from 1.7.1 to 1.9.0.
- [Release notes](https://github.com/jaxxstorm/action-install-gh-release/releases)
- [Commits](https://github.com/jaxxstorm/action-install-gh-release/compare/v1.7.1...v1.9.0)

---
updated-dependencies:
- dependency-name: jaxxstorm/action-install-gh-release
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:37:17 -06:00
dependabot[bot] 4b093115e2 chore: bump google-github-actions/setup-gcloud from 0 to 1 (#5517)
Bumps [google-github-actions/setup-gcloud](https://github.com/google-github-actions/setup-gcloud) from 0 to 1.
- [Release notes](https://github.com/google-github-actions/setup-gcloud/releases)
- [Changelog](https://github.com/google-github-actions/setup-gcloud/blob/main/CHANGELOG.md)
- [Commits](https://github.com/google-github-actions/setup-gcloud/compare/v0...v1)

---
updated-dependencies:
- dependency-name: google-github-actions/setup-gcloud
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:37:06 -06:00
Ammar Bandukwala 05dc83e522 docs: add hero image to About (#5539)
A reddit comment recently linked to this page, so we want to
make it convert better.
2023-01-02 14:36:36 -06:00
dependabot[bot] b6dab5fbf7 chore: bump golang.org/x/text from 0.4.0 to 0.5.0 (#5521)
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.4.0...v0.5.0)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:34:25 -06:00
dependabot[bot] 54eb6a5b42 chore: bump github.com/valyala/fasthttp from 1.41.0 to 1.43.0 (#5522)
Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.41.0 to 1.43.0.
- [Release notes](https://github.com/valyala/fasthttp/releases)
- [Commits](https://github.com/valyala/fasthttp/compare/v1.41.0...v1.43.0)

---
updated-dependencies:
- dependency-name: github.com/valyala/fasthttp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:34:02 -06:00
dependabot[bot] 8d254bd94e chore: bump github.com/prometheus/client_model from 0.2.0 to 0.3.0 (#5523)
Bumps [github.com/prometheus/client_model](https://github.com/prometheus/client_model) from 0.2.0 to 0.3.0.
- [Release notes](https://github.com/prometheus/client_model/releases)
- [Commits](https://github.com/prometheus/client_model/compare/v0.2.0...v0.3.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_model
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:33:51 -06:00
dependabot[bot] f711abb236 chore: bump github.com/elastic/go-sysinfo from 1.8.1 to 1.9.0 (#5524)
Bumps [github.com/elastic/go-sysinfo](https://github.com/elastic/go-sysinfo) from 1.8.1 to 1.9.0.
- [Release notes](https://github.com/elastic/go-sysinfo/releases)
- [Changelog](https://github.com/elastic/go-sysinfo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/elastic/go-sysinfo/compare/v1.8.1...v1.9.0)

---
updated-dependencies:
- dependency-name: github.com/elastic/go-sysinfo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:33:41 -06:00
dependabot[bot] 86c1753e2b chore: bump react-i18next from 12.0.0 to 12.1.1 in /site (#5525)
Bumps [react-i18next](https://github.com/i18next/react-i18next) from 12.0.0 to 12.1.1.
- [Release notes](https://github.com/i18next/react-i18next/releases)
- [Changelog](https://github.com/i18next/react-i18next/blob/master/CHANGELOG.md)
- [Commits](https://github.com/i18next/react-i18next/compare/v12.0.0...v12.1.1)

---
updated-dependencies:
- dependency-name: react-i18next
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 10:35:39 -03:00
Geoffrey Huntley 26b54cd144 chore(autofix): upgrade-examples-terraform-provider-coder (#5498)
Automatically generated via https://github.com/coder/autofix
2022-12-23 12:25:56 +10:30
Dean Sheather 3e2e2ac49e fix: enforce unique agent names per workspace (#5497) 2022-12-22 15:20:35 -08:00
sharkymark 461c0d0d39 docs: v1 docs redirect (#5509)
* docs: v1 docs redirect

* fix link

Co-authored-by: Ben <me@bpmct.net>
2022-12-22 15:14:36 -08:00
Muhammad Atif Ali 341c4329f4 ci: enable CodeQL code scanning (#5279)
Co-authored-by: Dean Sheather <dean@deansheather.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Co-authored-by: Geoffrey Huntley <ghuntley@ghuntley.com>
2022-12-22 22:12:55 +02:00
Presley Pizzo c8f34bbad7 Test enabling deadline change buttons (#5508) 2022-12-22 13:47:07 -05:00
Presley Pizzo 418022943a fix: use template default ttl when enabling auto-stop (#5494)
* Fetch default ttl - wip

* Convert ms to hours

* Format

* Fix story

* Add test
2022-12-22 12:52:27 -05:00
Marcin Tojek cfd02d959c docs: api root, buildinfo, csp (#5493)
* docs: Applications

* WIP

* WIP

* WIP

* Fix: consume

* Fix: @Description

* Fix

* docs: apiroot, buildinfo, csp

* Fix: buildinfo

* docs: updatecheck

* docs: apiroot

* Fix: s/none//g

* Fix: godoc nice

* Fix: description

* Fix: It

* Fix: code sample trim empty line

* More fixes

* Fix: br

* Merge

* Fix: no-security on updatecheck

* Fix: code tags

* Fix: enumerated values in code tags

* Rephrased

* Address PR comments

* Fix: URL, id

* Fix: array items

* Fix: any property

* Fix: array item singular
2022-12-22 15:53:14 +01:00
Bruno Quaresma c505e8b207 feat: Add create template from the UI (#5427) 2022-12-21 18:07:00 -03:00
Dean Sheather 43b61ce33c chore: support underscores in agent bin filenames (#5496) 2022-12-21 21:06:38 +00:00
Mathias Fredriksson bae69df8f9 build: Fix site/bin tar/zstd build step in rare error cases (#5495) 2022-12-21 22:59:49 +02:00
Colin Adler ac27cf8c07 fix: properly apply metadata when multiple resources share the same id (#5443) 2022-12-21 13:48:49 -05:00
whitney-coder 308a0602b6 Update high-availability.md (#5473)
Capitalization corrections
2022-12-21 09:47:32 -08:00
Presley Pizzo 0eb25306ad fix: stop time incrementer on workspace page (#5406)
* Check template default ttl while setting max

* Lint

* Remove template default from max ttl consideration

* Finish removing template

* Fix disabling buttons

* Simplify, wip

* Handle NaN

* Format

* Add aria labels

* Explain NaN handling

* Use more realistic storybook args
2022-12-21 10:44:18 -05:00
Presley Pizzo 8d9528545a feat: offer to restart workspace when ttl is changed (#5391)
* Update xstate machine

* Fix autoStopChanged

* Add dialog

* Restart workspace

* Clearing location doesn't work and doesn't seem necessary

* Fix test

* Fix second test

* Format

* Lint

* Use i18n

* Switch to fire and forget restart

* Improve error handling

* Format

* Format

* Update site/src/pages/WorkspaceSchedulePage/WorkspaceSchedulePage.test.tsx

Co-authored-by: Kira Pilot <kira@coder.com>

* Fix name of guard

* Make done state final

* Format

Co-authored-by: Kira Pilot <kira@coder.com>
2022-12-21 10:11:54 -05:00
Marcin Tojek 2bbeff53f9 docs: applications and authorization (#5477)
* docs: Applications

* WIP

* WIP

* WIP

* Fix: consume

* Fix: @Description

* Fix

* Fix: s/none//g

* Fix: godoc nice

* Fix: description

* Fix: It

* Fix: code sample trim empty line

* More fixes

* Fix: br
2022-12-21 15:37:30 +01:00
Mathias Fredriksson 935bb99bed test: Merge env maps to simplify (#5481) 2022-12-20 20:40:41 +00:00
Dean Sheather 2ac31684f4 fix: use UIDs in Dockerfile (#5480) 2022-12-20 12:22:27 -08:00
Mathias Fredriksson c5cfefe3b2 test: Generate golden files for all (visible) CLI commands (#5479) 2022-12-20 22:17:51 +02:00
Mathias Fredriksson c7ce3e70da feat: Add --raw-url to coder server postgres-builtin-* commands (#5478) 2022-12-20 18:51:17 +00:00
Dean Sheather 50dfc2082b feat: endpoint to logout app subdomain URLs (#5428)
Co-authored-by: Bruno Quaresma <bruno@coder.com>
2022-12-20 18:45:13 +00:00
sharkymark 86257ce7fc docs: add contact us form for sales; improve enterprise page (#5459)
Co-authored-by: Geoffrey Huntley <ghuntley@ghuntley.com>
2022-12-20 13:01:28 +00:00
Mathias Fredriksson ca31f1b782 test: Update go-scp to fix data race (#5469) 2022-12-20 09:33:11 +00:00
Mathias Fredriksson a7e8f98e33 feat: Unhide workspace rename command (#5464) 2022-12-19 22:11:10 +02:00
Steven Masley e3cf759968 test: Unit tests creating fake audit logs require create permission (#5455) 2022-12-19 14:02:52 -06:00
Dean Sheather 1bc4eb5329 fix: fix security vulnerabilities reported by CodeQL (#5467) 2022-12-19 19:25:59 +00:00
Dean Sheather e359f3cd23 fix: change TLS client auth default to "none" (#5468) 2022-12-19 19:14:37 +00:00
Marcin Tojek dc6d271293 feat: Build framework for generating API docs (#5383)
* WIP

* Gen

* WIP

* chi swagger

* WIP

* WIP

* WIP

* GetWorkspaces

* GetWorkspaces

* Markdown

* Use widdershins

* WIP

* WIP

* WIP

* Markdown template

* Fix: makefile

* fmt

* Fix: comment

* Enable swagger conditionally

* fix: site

* Default false

* Flag tests

* fix

* fix

* template fixes

* Fix

* Fix

* Fix

* WIP

* Formatted

* Cleanup

* Templates

* BEGIN END SECTION

* subshell exit code

* Fix

* Fix merge

* WIP

* Fix

* Fix fmt

* Fix

* Generic api.md page

* Fix merge

* Link pages

* Fix

* Fix

* Fix: links

* Add icon

* Write manifest file

* Fix fmt

* Fix: enterprise

* Fix: Swagger.Enable

* Fix: rename apidocs to apidoc

* Fix: find -not -prune

* Fix: json not available

* Fix: rename Coderd API to Coder API

* Fix: npm exec

* Fix: api dir

* Fix: by ID

* Fix: string uuid

* Fix: include deleted

* Fix: indirect go.mod

* Fix: source lib.sh

* Fix: shellcheck

* Fix: pushd popd

* Fix: fmt

* Fix: improve workspaces

* Fix: swagger-enable

* Fix

* Fix: mention only HTTP 200

* Fix: IDs

* Fix: https

* Fix: icon

* More APis

* Fix: format swagger.json

* Fix: SwaggerEndpoint

* Fix: SCRIPT_DIR

* Fix: PROJECT_ROOT

* Fix: use code tags in schemas.md

* Fix: examples

* Fix: examples

* Fix: improve format

* Fix: date-time,enums

* Fix: include_deleted

* Fix: array of

* Fix: parameter, response

* Fix: string time or null

* Workspaces: more docs

* Workspaces: more docs

* Fix: renderDisplayName

* Fix: ActiveUserCount

* Fix

* Fix: typo

* Templates: docs

* Notice: incomplete
2022-12-19 18:43:46 +01:00
Kyle Carberry f239ca7ee3 fix: add the "workflow" scope for managing GitHub Actions with gitauth (#5461)
Seen in Discord: https://discord.com/channels/747933592273027093/1054155742871031858/1054155742871031858
2022-12-19 15:17:17 +02:00
Mathias Fredriksson 9983c07e13 build: Improve speed of find commands in Makefile (#5463) 2022-12-19 14:41:36 +02:00
Mathias Fredriksson 5a786edc3d test: Fix new name too long for cli/rename (#5462) 2022-12-19 11:58:22 +00:00
Kyle Carberry e61234f260 feat: Add vscodeipc subcommand for VS Code Extension (#5326)
* Add extio

* feat: Add `vscodeipc` subcommand for VS Code Extension

This enables the VS Code extension to communicate with a Coder client.
The extension will download the slim binary from `/bin/*` for the
respective client architecture and OS, then execute `coder vscodeipc`
for the connecting workspace.

* Add authentication header, improve comments, and add tests for the CLI

* Update cli/vscodeipc_test.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update cli/vscodeipc_test.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update cli/vscodeipc/vscodeipc_test.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Fix requested changes

* Fix IPC tests

* Fix shell execution

* Fix nix flake

* Silence usage

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-12-18 17:50:06 -06:00
Kyle Carberry d1f8fec1d3 fix: use static base date for timeline tests (#5460)
It was returning "yesterday" since today is Sunday ;p
2022-12-18 15:27:09 -06:00
Dean Sheather 88d3496a99 fix: fix helm prometheus block causing failures (#5458) 2022-12-19 04:48:08 +10:00
Joe Previte a19c6fc988 fix: update coder dotfiles in dogfood (#5451)
I wasn't calling the environment variable I set.
2022-12-16 12:08:13 -07:00
ElliotG e76f947da2 Added sessionAffinity to values.yaml (#5448) 2022-12-16 09:58:43 -07:00
Dean Sheather 0c0e3f0e4d fix: fix nested dirs in example tars (#5447) 2022-12-17 02:19:19 +10:00
Kyle Carberry fcd5511403 fix: add provisioner tags to template push (#5446)
This was previously only on template create!
2022-12-16 15:13:03 +00:00
Mathias Fredriksson ffb8df9655 test: Disable error on agent log in scaletest/reconnectingpty (#5445)
They way the reconnectingpty tests behave inherently will cause the
agent to occasionally log an error (e.g. due to test disconnecting at a
certain time), allowing these error logs to fail the test will cause
these tests to be flakey.

It's best for these tests to only rely on the observed behavior.
2022-12-16 16:13:31 +02:00
Mathias Fredriksson e2aec2709b test: Fix scaletest/reconnectingpty commands for use in powershell (#5439) 2022-12-16 12:18:14 +02:00
Steven Masley 79c71d2d2c chore: Upgrade to sqlc version 2 yaml configuration (#5442)
* chore: Upgrade to sqlc version 2 yaml configuration
2022-12-15 20:40:11 +00:00
Joe Previte fceac39143 refactor: pin code-server to 4.8.3 (#5440)
* chore(templates): pin code-server to 4.8.3

* docs: use code-server 4.8.3 in install snippets
2022-12-15 13:14:49 -07:00
Dean Sheather 31d38d4246 feat: allow http and https listening simultaneously (#5365) 2022-12-15 20:09:19 +00:00
Dean Sheather 787b8b2a51 fix: fix app hostname returning port number (#5441) 2022-12-16 04:43:00 +10:00
Mathias Fredriksson 44c10bbe3c build: Fix parallelism of make -j build (#5438) 2022-12-15 18:36:37 +02:00
Dean Sheather 6b6eac2518 feat: remove loadtest cmd, add new scaletest cmd (#5310) 2022-12-15 15:04:24 +00:00
Mathias Fredriksson 306fe4a91b ci: Fix release publish script (#5436) 2022-12-15 14:31:57 +00:00
Mathias Fredriksson e96fdbed26 feat: Add release.sh script and detect breaking changes (#5366)
This commit introduces three new scripts:

- `release.sh` To be run by a user on their local machine to preview and
  create a new release (tag + push)
- `check_commit_metadata.sh` For e.g. detecting breaking changes
- `genereate_release_notes.sh` To display the generated release notes,
  used for previews and in `publish_release.sh`

The `release.sh` script can be run without arguments, and it will
automatically determine if we're to do a patch or minor release. A minor
release can be forced via `--minor` flag.

Breaking changes can be annotated either via commit/merge title prefix
(`feat!:`, `feat(api)!:`), or by adding the `release/breaking` label to
the PR that was merged (on GitHub).

Related #5233
2022-12-15 15:41:30 +02:00
Mathias Fredriksson 4bc420dc48 test: Fix data race in loadtest/reconnectingpty (#5431) 2022-12-15 15:06:58 +02:00
Mathias Fredriksson 25ebebac5f ci: Improve gotestsum failure detection, prevent early exit (#5420) 2022-12-15 12:47:42 +02:00
Kyle Carberry d170d27e80 feat: add external property to coder_app (#5425)
* Add schema

* feat: add `external` property to `coder_app`

This allows exposing applications that open an external URL.
2022-12-14 15:54:18 -06:00
Kyle Carberry 8bc247d0c9 fix: use proper validate url for gitauth (#5426)
This was preventing custom validation URLs from being
used to verify git tokens.
2022-12-14 21:02:35 +00:00
Kyle Carberry 84995b7320 fix: preserve workspace resource metadata order (#5421)
Fixes #4511.
2022-12-14 19:08:22 +00:00
Kyle Carberry c0b251ac52 fix: improve error messages when the agent token is invalid (#5423)
I'm not sure why this issue is common, but it seems to be
based on: https://github.com/coder/coder/issues/4551.

This improves the error messages to be unique,
and also fixes a small edge-case bug a user ran into.
2022-12-14 12:24:22 -06:00
Mathias Fredriksson b39ba02bf0 ci: Increase Go mock db test timeout to 5m (#5413)
Our Windows test-runner often takes close to 3m to complete the test,
this was producing a few false failures due to us adding tests over time
and test times increasing.
2022-12-14 19:37:01 +02:00
Steven Masley 27386d49d0 fix: No org admins until organizations are in the UI (#5414)
* fix: No org admins until organizations are in the UI

Until organizations have management UI, we should not set any org
admins. This goes around the site wide perms transparently and
is confusing to users.

Default user is no longer an org admin, so the demotion test makes
no sense
2022-12-14 11:05:42 -06:00
Mathias Fredriksson 012a9e759e fix: Avoid deadlock in AgentReportStats Close during agent Close (#5415)
Since AgentReportStats takes a stats function which was doing mutex
locking on agent shutdown, it was possible for there to be a deadlock
depending on how the AgentReportsStats Close function is implemented.

This mostly seems to happen on Windows test runners as it's pretty hard
to hit this edge case. The bug currently only exists in the test
implementation of AgentReportStats, however, this was refactored to be
more robust in case of future changes.
2022-12-14 18:45:46 +02:00
Kyle Carberry 8e702d89bb fix: improve the warning mismatch to display the release assets on windows (#5418)
* fix: improve the warning mismatch to display the release assets on windows

Fixes #4226.

* Update cli/root.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update cli/root.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-12-14 16:36:28 +00:00
Marcin Tojek b103685170 chore: Collect gotests.xml files (#5398)
* chore: Use datadog-ci to collect gotests.xml

* WIP

* Fix: github ref

* fix

* just store gotests.xml
2022-12-14 16:23:31 +01:00
Arthur Normand ad0dd1be5d fix: Add client certs to OAuth HTTPClient context (#5126) 2022-12-14 16:44:29 +02:00
Mathias Fredriksson 663f7a3f12 ci: Output tail of gotestsum.json if test timed out (#5411)
This is to eternalize the log in case "re-run failed" is used, which
erases artifacts from previous run.
2022-12-14 15:04:39 +02:00
Mathias Fredriksson 2a4ef38a4f fix(site): Use correct UUID for web terminal when first opened (#5404) 2022-12-14 15:03:47 +02:00
Geoffrey Huntley 90b0adabc1 docs(readme): uppercase H in Self-Hosted (#5412) 2022-12-14 13:01:51 +00:00
Geoffrey Huntley ec2293a4e4 docs(readme): update comparison table (#5405) 2022-12-14 10:35:20 +01:00
Mathias Fredriksson 1a018c571b chore: Add PR Lint workflow (#5387)
Fixes #5381
2022-12-14 16:34:08 +10:00
Ricky Grassmuck f7baf45ae3 feat: support partial parameter files (#5392)
Fixes https://github.com/coder/coder/issues/5390
2022-12-13 19:58:57 -06:00
Joe Previte 5a568d8a9b refactor: conditionally use dotfiles in dogfood template (#5332)
* feat: add dotfiles_uri var to dogfood template

* refactor: use dotfiles if dotfiles var exists

This ensures the `coder dotfiles` command only runs if the dotfiles var
in the template is not empty.

* Update dogfood/main.tf

* refactor: assign variable to shell variable

* Update dogfood/main.tf

* fixup!: add default value
2022-12-13 21:15:25 +00:00
sharkymark 8df02f42c0 docs: make it clear the CLI must be downloaded to use templates (#5373) 2022-12-13 19:31:09 +00:00
Mathias Fredriksson 4fc4c01cea fix: Enable reconnectingpty loadtest and fix/improve logging (#5403)
* fix: Enable reconnectingpty loadtest and fix/improve logging

This commit re-enabled reconnectingpty loadtests after a logging
refactor of `(*agent).handleReconnectingPTY`. The reasons the tests were
flaking was that `logger.Error` was being called and `slogtest` failing
the test.

We could have set the option for `slogtest` to disable failing, but that
could hide real issues. The current approach improves reconnectingpty
logging overall and provides more insight into what's happening. It's
expected that reconnectingpty sessions fail after the agent is closed,
so calling `logger.Error` at that point is not wanted.

Ref: #5322
2022-12-13 21:28:07 +02:00
Garrett Delfosse 560c8ce0f6 fix: allow example files to be reused and not error (#5402) 2022-12-13 16:27:37 +00:00
Marcin Tojek 50d1c7191a fix: double quote in fake_cancel.sh (#5399) 2022-12-13 11:03:34 +01:00
Colin Adler 1c42a20865 chore: add debugging to agent stats report (#5395) 2022-12-13 01:03:03 -06:00
Geoffrey Huntley d72d312e1f docs(readme): update comparison table (#5394) 2022-12-13 00:55:23 +00:00
Kira Pilot a071bfa8aa fix: Store dismissedBanner key in localStorage (#5388)
* fix: Store dismissedBanner key in localStorage

* cleanup

* removed comment

* spelling

* fixed eslint

* wote test
2022-12-12 16:17:29 -05:00
Garrett Delfosse 40a5c0476f feat: add flag for token lifetime (#5385) 2022-12-12 15:39:31 -05:00
Mathias Fredriksson 760419a965 chore: Refactor agent tests to avoid t.Run when not needed (#5376)
It turns out that writing tests that contain subtests should probably be
limited to table-based tests and tests that share a common setup shared
between tests.

Writing tests with a subtest like this:

```
func TestSomething(t *testing.T) {
	t.Run("Subtest", func(t *testing.t) {})
}
```

Has the following disadvantages:

- It can lead to multiple tests failing with `(unknown)` status when
  only one of the subtests hang (never exit)
- In Go 1.20rc1, using `t.Setenv` is no longer allowed if the parent
  test is parallel
2022-12-12 22:20:46 +02:00
Geoffrey Huntley 08a6a18226 docs(comparisons): update comparison table (#5371) 2022-12-12 19:14:15 +00:00
Bruno Quaresma e7fc21e285 chore: Add react-syntax-highlight back (#5369) 2022-12-12 15:46:33 -03:00
Kyle Carberry 2b864cee9e fix: Remove @main tag from pkg.go.dev in docs links (#5384)
This seems to have broken, but removing the `main` tag makes
it resolve to the latest version.

See: https://github.com/coder/coder/actions/runs/3675316304/jobs/6215503383
2022-12-12 18:06:58 +00:00
Mathias Fredriksson 88bb901283 fix: Close tailnet if agent is closed during creation (#5375) 2022-12-12 11:26:49 +00:00
Mathias Fredriksson 1907f13c5f fix(site): Use relative date in Timeline test (#5377) 2022-12-12 13:15:28 +02:00
Garrett Delfosse ca0374b94f feat: add examples to api (#5331)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-12-09 14:29:50 -05:00
Bruno Quaresma 6cc864c048 chore: Add icons to templates (#5368) 2022-12-09 18:47:09 +00:00
Kira Pilot c6ae151f49 feat: amending audit string to show workspace owner (#5364)
* resolves #5269

* clean up

* fixed audit link
2022-12-09 12:19:30 -05:00
Joe Previte 66ec98f647 fix: pin code-server to 4.8.3 (#5363)
* fix: pin code-server to 4.8.3

We're having some terminal issues on macOS clients (i.e. iPad) with 4.9.0 so downgrading to 4.8.3 in the meantime.

* Update dogfood/main.tf
2022-12-09 17:07:27 +00:00
Marcin Tojek 971e36781b chore: improve logging in provisionerd_test (#5353) 2022-12-09 13:11:54 +01:00
Marcin Tojek cd04330ca6 fix: replace fireEvent with userEvent (#5361)
* fix: replace fireEvent with userEvent

* fmt
2022-12-09 13:11:36 +01:00
Marcin Tojek 935d2eb582 fix: fmt should check for unstaged files (#5362) 2022-12-09 12:00:39 +01:00
Mathias Fredriksson 05130db571 fix: Improve closing of services in agent tests (#5355) 2022-12-09 12:22:27 +02:00
Bruno Quaresma 92c5e97f85 fix: Fix CSP style directive for Monaco editor (#5360) 2022-12-08 16:53:50 -03:00
Bruno Quaresma 3c9dab34bf fix: Fix CSP for monaco editor (#5358) 2022-12-08 18:32:41 +00:00
Bruno Quaresma ce76d9d5a3 feat: Add diff and Dockerfile support for template version page (#5339) 2022-12-08 10:24:15 -05:00
Ben Potter f68a65697d fix: winget package releases (#5352)
* chore: fix winget package releases

* Update .github/workflows/packages.yaml

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-12-08 09:13:13 -06:00
dependabot[bot] 7eb3ab0498 chore: bump decode-uri-component from 0.2.0 to 0.2.2 in /site (#5251)
Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2.
- [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases)
- [Commits](https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.2)

---
updated-dependencies:
- dependency-name: decode-uri-component
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-08 09:52:30 -05:00
Mathias Fredriksson 687261c827 fix: Close coordinator in wsconncache test (#5348)
Possibly related to #5302
2022-12-08 11:44:03 +00:00
Marcin Tojek c063ac24a3 fix: use doWithRetries when making HTTP calls (#5344) 2022-12-08 10:24:50 +01:00
Eric Paulsen 59af8349c6 docs: add offical kubernetes provider runtime_class_name (#5157)
* add: offical kubernetes provider runtime_class_name

* fix: typos

* add: coder data source & vars
2022-12-07 23:30:57 -06:00
Eric Paulsen fd54512858 helm: add certs secret mount (#4641)
* helm: add certs secret mount

* fix: values ref

* fix: conditional brackets

* rm: comment

* refactor: cert secrets list

* fix: undefined var

* chore: remove deprecated value coder.tls.secretName

* chore: improve helm volumes logic

* feat: add support for multiple CA bundles to helm

* fix: grammar

* resolve: conflict

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-12-07 17:27:36 -06:00
Kyle Carberry 3d95c9256d chore: Add DatoCMS token to dogfood template (#5254)
* chore: Add DatoCMS token to dogfood template

This is used for developing coder.com!
2022-12-07 15:59:32 -06:00
dependabot[bot] 1ac1af7db8 chore: bump emoji-mart from 5.2.1 to 5.3.3 in /site (#5226)
Bumps [emoji-mart](https://github.com/missive/emoji-mart/tree/HEAD/packages/emoji-mart) from 5.2.1 to 5.3.3.
- [Release notes](https://github.com/missive/emoji-mart/releases)
- [Commits](https://github.com/missive/emoji-mart/commits/v5.3.3/packages/emoji-mart)

---
updated-dependencies:
- dependency-name: emoji-mart
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-08 02:55:38 +10:00
Marcin Tojek 534bff2ff5 fix: coderd/prometheusmetrics wait for all metrics in require.Eventually (#5338) 2022-12-07 17:50:17 +01:00
Presley Pizzo 8ea09235f9 fix: UX issues in template settings form's default auto-stop field (#5330)
* Fix helper text

- handles 0 ttl
- uses helper text typography
- pluralizes
- still doesn't override error (once considered touched)

* Show user friendly field name in error text

* Format

* Override label through Yup instead

* Switch to i18n - wip

* Fix i18n by thunking schema

* Fix template settings tests

* Replace third arg to getFieldHelpers -is used after all
2022-12-07 11:32:39 -05:00
Ammar Bandukwala ee605b34b6 fix: Don't show progress bar for new templates (#5298) 2022-12-07 16:22:20 +00:00
Mathias Fredriksson f7467cac50 fix: Improve ptytest closure on expect match timeout (#5337)
To ensure ptytest closure always happens the same way, we now define a
new `Close` function on `PTY` and always call the close function instead
of manually closing read/writers.

A few additional log messages have been added as well, to better
understand the shutdown process in case of errors.
2022-12-07 15:20:06 +00:00
Marcin Tojek a973c35a02 chore: collect gotestsum TestEvents as workflow artifacts (#5336) 2022-12-07 15:04:39 +01:00
Marcin Tojek 3cea5f96f0 fix: wait for creating template versions (#5335) 2022-12-07 14:19:18 +01:00
Marcin Tojek 2f3ff6ced8 fix: improve pty and ptytest (#5327)
* Fix: improve ptytest

* Disable skip

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* Fix

* WIP

* Fix

* fix: pty close on Windows

* Revert changes around workflow

* fix
2022-12-07 14:18:09 +01:00
Dean Sheather 161465db55 fix: do not canonicalize Sec-WebSocket-* headers in apps (#5334)
* fix: do not canonicalize Sec-WebSocket-* headers in apps

* chore: test for non-canonical header name subst
2022-12-07 22:55:02 +10:00
Kira Pilot 85945af55e fixed bug; wrote tests (#5329) 2022-12-06 16:58:32 -05:00
Ammar Bandukwala 1cfe5de1c5 Add Service Banners (#5272) 2022-12-06 18:38:38 +00:00
Kira Pilot df389d429c Add build number to workspace_build audit logs (#5267)
* got links working

* added translations

* fixed translation

* added translation for unavailable ip

* added support for group, template, user links

* cleaned up string

* added deleted label

* querying for workspace id

* remove prints

* fix/write tests

* added build number

* checking for existence of additional fields

* adjust documentation

* PR feedback
2022-12-06 13:33:21 -05:00
Dean Sheather 6651c1632d fix: avoid terraform state concurrent access, remove global mutex (#5273) 2022-12-06 17:05:14 +00:00
Marcin Tojek 85a6d14fbb skip: reconnectingpty tests (#5322) 2022-12-06 16:36:54 +01:00
Kyle Carberry c77c1b4bc2 fix: Retry if there is no git auth user yet (#5316)
Fixes part of #4900.
2022-12-06 16:06:41 +01:00
Marcin Tojek b2dc60c030 fix: markdown-link-check base-branch should not be set on main branch (#5311) 2022-12-06 15:41:06 +01:00
Bruno Quaresma e17fd0bb25 feat: Add GET previous template version endpoint (#5230) 2022-12-06 14:15:03 +00:00
Marcin Tojek 84872d970d fix: loadtest/reconnectingpty tweak timeout (#5300)
* flaky

* fix: load test increase timeout

* Remove flaky

* Improvement

* only Linux

* WaitSuperLong

* Fix

* Try longer

* Try: sleep 120
2022-12-06 14:40:38 +01:00
dependabot[bot] 03328d4f6d chore: bump eslint from 8.24.0 to 8.29.0 in /site (#5306)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-06 12:14:31 +00:00
dependabot[bot] 4a0ca4818f chore: bump @typescript-eslint/parser from 5.38.1 to 5.45.1 in /site (#5305)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-06 12:01:01 +00:00
dependabot[bot] 825480ae9b chore: bump crate-ci/typos from 1.12.12 to 1.13.3 (#5304)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Geoffrey Huntley <ghuntley@ghuntley.com>
2022-12-06 11:50:33 +00:00
Marcin Tojek 133b2de1ca chore: improve markdown-link-check workflow (#5303) 2022-12-06 21:46:17 +10:00
Joe Previte 9e4d213c2d feat: add lazygit, remove kubic, use dotfiles in dogfood image (#5271) 2022-12-06 20:11:44 +10:00
Presley Pizzo ee74df3d07 Fix scope of dbTTL (#5197) 2022-12-05 17:19:30 -05:00
Marcin Tojek d3200382f6 fix: agent panics on closed network (#5295)
* fix: agent panics on closed network

* Remove a.network = network

* Fix

* Fix

* Fix
2022-12-05 23:18:23 +01:00
Daniel Carrion 061635c36d feat: Allow multiple OIDC domains (#5210)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-12-05 20:20:53 +02:00
Bruno Quaresma 02bb052d09 Fix template Avatar (#5294) 2022-12-05 10:50:50 -07:00
Bruno Quaresma 02dcd0e20d fix: Fix resource avatar when icon is empty string (#5291) 2022-12-05 14:37:14 -03:00
Marcin Tojek e04877a638 fix: race conditions in replicasync (#5289) 2022-12-05 17:18:15 +01:00
Bruno Quaresma 9cfdbec2ef refactor: Remove login banner (#5239) 2022-12-05 11:24:53 -03:00
Marcin Tojek cec667d309 fix: prettier misses docs directory (#5285)
* chore: keep admin/prometheus.md if make target fails

* Address PR comments

* Formatted

* fix: prettier misses docs

* make fmt

* More md files
2022-12-05 12:21:09 +01:00
Muhammad Atif Ali b46035823e docs: add templates link to README.md (#5201) 2022-12-05 16:20:01 +10:00
Muhammad Atif Ali a3083f77c7 docs: fix community templates link on site. (#5278)
Fixes #5259
2022-12-05 04:59:53 +00:00
Colin Adler a02617b66b fix: remove unnecessary WHEREs from AcquireProvisionerJob (#5257) 2022-12-02 23:53:49 +00:00
Marcin Tojek 137a48c215 fix: workspaceapps: overloaded test server responds with 502s (#5255) 2022-12-02 23:16:07 +01:00
Ammar Bandukwala 91973e1e88 cli: remove redundant client creation requests (#5264) 2022-12-02 15:40:23 -06:00
Kira Pilot 65407462d1 Add audit links/kira pilot (#5156)
* got links working

* added translations

* fixed translation

* added translation for unavailable ip

* added support for group, template, user links

* cleaned up string

* added deleted label

* querying for workspace id

* remove prints

* fix/write tests

* PR feedback pt 1

* PR feedback part 2
2022-12-02 15:14:45 -05:00
Mathias Fredriksson fa641554e8 fix: Improve agent connection tracking when agent is closed (#5253) 2022-12-02 16:24:40 +02:00
Mathias Fredriksson 81c3948792 fix: Close tty first in ptytest cleanup (#5252) 2022-12-02 12:32:50 +00:00
Marcin Tojek ee4f0fc592 chore: enable debug logging for gotestsum (#5248) 2022-12-02 12:35:14 +01:00
Colin Adler 8469dbc045 fix: add index to provisioner_jobs.started_at (#5245) 2022-12-01 19:29:15 -06:00
Colin Adler 92c217bd85 fix: add index on workspace_agents.auth_token (#5244) 2022-12-02 01:29:05 +00:00
Dean Sheather 9e80322fe5 fix: do not truncate system PATH in win installer (#5243)
The path.nsh script in the NSIS installer provided methods for adding
paths to the PATH and removing them. It would do this by reading the
current PATH value from the registry, adding the new value (if it
doesn't exist) and then writing it to the registry.

Unfortunately, it would read from the user's PATH and write the updated
result to the system PATH, which would remove important PATH entries
like the following in the process:

- C:\Windows\System32
- C:\Windows
- C:\Windows\System32\wbem
- C:\Windows\System32\WindowsPowerShell\v1.0
- C:\Windows\System32\OpenSSH
- C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
- C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common

and would copy all user environment variables in their place. The
variables listed above were the ones missing from my machine when I
compared with a friend's machine.

Recommended course of action for affected users:
1. Add the paths listed above to your system PATH if they aren't there
   already and exist on your system.
2. Remove any paths that are in your user's PATH from your system PATH.

The existing installers for the last couple of versions of Coder have
been yanked from GitHub releases and this message will be included in
the release notes for the next patch.

Thanks to @cmor for finding and reporting this bug in #5240.
2022-12-02 09:56:49 +10:00
Colin Adler ab3b3d5fca feat: add debouncing to provisionerd rpc calls (#5198) 2022-12-01 16:54:53 -06:00
Tao Yang 5457dd0c65 feat: Let port-forwarding support custom http(s) port (#5084) 2022-12-02 06:39:19 +10:00
Mathias Fredriksson 2ec3b09ca7 fix: Fix nil-pointer deref on checkAuthorization (#5236)
Remove call to `err.Error()` on a `nil` error in `checkAuthorization`.
2022-12-01 18:42:10 +00:00
dependabot[bot] f77a445bfe chore: bump cron-parser from 4.6.0 to 4.7.0 in /site (#5221)
Bumps [cron-parser](https://github.com/harrisiirak/cron-parser) from 4.6.0 to 4.7.0.
- [Release notes](https://github.com/harrisiirak/cron-parser/releases)
- [Commits](https://github.com/harrisiirak/cron-parser/compare/4.6.0...4.7.0)

---
updated-dependencies:
- dependency-name: cron-parser
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 18:34:56 +00:00
dependabot[bot] 9724dbd36d chore: bump github.com/gohugoio/hugo from 0.105.0 to 0.107.0 (#5222)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 18:11:58 +00:00
dependabot[bot] 9675ea90e2 chore: bump google.golang.org/api from 0.100.0 to 0.103.0 (#5219)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 18:08:12 +00:00
dependabot[bot] 6c68126486 chore: bump github.com/spf13/viper from 1.13.0 to 1.14.0 (#5220)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 17:56:45 +00:00
Ammar Bandukwala 9a0a6b7002 .github: remove "never stale" 2022-12-01 11:47:01 -06:00
dependabot[bot] 7f94235419 chore: bump google.golang.org/grpc from 1.50.1 to 1.51.0 (#5223)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 11:43:36 -06:00
Mathias Fredriksson d9f2aaf3b4 feat: Add support for update checks and notifications (#4810)
Co-authored-by: Kira Pilot <kira@coder.com>
2022-12-01 19:43:28 +02:00
dependabot[bot] 4f1cf6c9d8 chore: bump golang.org/x/crypto from 0.1.0 to 0.3.0 (#5224)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 11:42:54 -06:00
dependabot[bot] 82d4aaea0b chore: bump tj-actions/branch-names from 6.2 to 6.3 (#5217)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 17:40:54 +00:00
dependabot[bot] 785d8750ce chore: bump hmarr/auto-approve-action from 2 to 3 (#5216)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 17:39:23 +00:00
dependabot[bot] e3103f3a5e chore: bump google-github-actions/auth from 0 to 1 (#5218)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 11:37:33 -06:00
dependabot[bot] 9a1ffe4121 chore: bump golangci/golangci-lint-action from 3.3.0 to 3.3.1 (#5214)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 17:11:03 +00:00
ElliotG 07560eefc0 Refactored Quota Docs (#5195) 2022-12-01 09:37:50 -07:00
Marcin Tojek 916ed284ce feat: Define Prometheus port in the pod spec (#5213)
* WIP

* portSpec

* Done

* Docs

* Fix: env
2022-12-01 15:43:32 +00:00
Mathias Fredriksson 9557d456e8 fix: Generate trial in scripts/develop.sh (#5231) 2022-12-01 17:12:16 +02:00
Marcin Tojek 883cf8afa9 chore: Add missing metrics description (#5212)
* chore: Add missing metrics description

* Update provisionerd/provisionerd.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Fix

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-12-01 12:50:57 +01:00
Muhammad Atif Ali 8cd8b6d858 docs: add community templates link to docs. (#5200) 2022-12-01 11:59:59 +10:00
Kyle Carberry af2c47b1a3 fix: Update install script text to separate run and use (#5203) 2022-11-30 13:38:25 -08:00
Marcin Tojek 38bdae7016 docs: Prometheus metrics + generator (#5179)
* docs: Prometheus metrics

* Fix

* Typo

* Typo

* Typo

* Fix: link

* Update docs/admin/prometheus.md

Co-authored-by: Dean Sheather <dean@deansheather.com>

* Update docs/admin/prometheus.md

Co-authored-by: Dean Sheather <dean@deansheather.com>

* Update docs/admin/prometheus.md

Co-authored-by: Dean Sheather <dean@deansheather.com>

* Update docs/admin/prometheus.md

Co-authored-by: Dean Sheather <dean@deansheather.com>

* Update docs/admin/prometheus.md

Co-authored-by: Dean Sheather <dean@deansheather.com>

* Rephrase

* notice

* use ```shell

* Generator

* gosec

* fix: lint

* PR comments

* not needed anymore

Co-authored-by: Dean Sheather <dean@deansheather.com>
Co-authored-by: Geoffrey Huntley <ghuntley@ghuntley.com>
2022-11-30 17:39:51 +01:00
Bruno Quaresma be79ae7d48 refactor: Add coder tip pill on sign in page (#5196) 2022-11-30 13:38:12 -03:00
Kyle Carberry 2a73362026 fix: add mutex to MockAuditor export to prevent race (#5189)
See: https://github.com/coder/coder/actions/runs/3575201153/jobs/6011435900.
2022-11-30 16:25:30 +00:00
Bruno Quaresma 41f10e7b69 refactor: Show template version in the workspace page (#5194) 2022-11-30 09:13:07 -05:00
Marcin Tojek 5817d2a301 skip: loadtest/reconnectingpty Test_Runner/Timeout (#5199) 2022-11-30 11:04:01 +01:00
Presley Pizzo 2e3db274f1 fix: send auto start/stop api calls only when changed (#5184)
* Send auto start/stop api calls only when changed

* Format

* Extract and test util function
2022-11-29 15:12:36 -05:00
Kyle Carberry 8b73844f69 feat: Validate Git tokens before consuming them (#5167)
* feat: Validate Git tokens before consuming them

This works the exact same way that the Git credential manager does. It ensures the user token is valid before returning it to the client.

It's been manually tested on GitHub, GitLab, and BitBucket.

* Fix requested changes
2022-11-29 12:08:27 -06:00
Marcin Tojek a8f5af1245 skip: loadtest/reconnectingpty Test_Runner/ExpectOutput (#5188) 2022-11-29 15:05:04 +00:00
Mathias Fredriksson 085f1917db fix: Fix develop script pid tracking, improve logging and interrupt (#5186) 2022-11-29 15:45:14 +02:00
Dean Sheather 15f8967a8a feat: tracing improvements (#4988) 2022-11-29 07:22:10 +10:00
Bruno Quaresma d402914eb7 refactor: Return template version name in the workspace build API (#5178) 2022-11-28 19:53:56 +00:00
Steven Masley ab9298f382 chore: Rewrite rbac rego -> SQL clause (#5138)
* chore: Rewrite rbac rego -> SQL clause

Previous code was challenging to read with edge cases
- bug: OrgAdmin could not make new groups
- Also refactor some function names
2022-11-28 12:12:34 -06:00
Presley Pizzo d5ab4fdeb8 fix: auto-stop bumper works and refreshes (#5162)
* Publish updates to workspace deadline

* Fix sync between machines
2022-11-28 10:59:43 -05:00
Muhammad Atif Ali 898ba11ef0 fix: packages.yaml action is not running on release trigger (#5173)
This commit is a workaround to run the `packages.yaml` action after the release action
Fixes #5137.
Check #5137 for context.
2022-11-27 07:06:34 -06:00
Muhammad Atif Ali 25c80566e7 docs: Add GitHub action to push template changes automatically (#5166)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-11-26 13:36:14 +00:00
Muhammad Atif Ali 5f31ea3ffb docs: add docs on how to allow public github signups (#5168) 2022-11-25 20:03:07 +02:00
Cian Johnston a4a319a76e feat: add CODER_OIDC_IGNORE_EMAIL_VERIFIED config knob (#5165)
* Adds a configuration knob CODER_OIDC_IGNORE_EMAIL_VERIFIED that allows
  ignoring the email_verified OIDC claim
* Adds warning message at startup if CODER_OIDC_IGNORE_EMAIL_VERIFIED=true
* Adds warning whenever an unverified OIDC email is let through
* Skips flaky test on non-linux platforms

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-11-25 10:10:09 +00:00
Mathias Fredriksson 6ed12ade54 fix: Improve debuggability of ptytest cleanup (#5170)
There are sporadic flakes in some tests on Windows related to the use of
`ptytest`. Since it's not clear why they fail, this commit adds some
more logging and timeouts to the cleanup methods.
2022-11-24 15:20:17 +00:00
Marcin Tojek 25da224513 Filter query: has-agent connecting, connected, disconnected, timeout (#5145)
* WIP

* has-agent:connecting, connected

* Fix

* Fix

* has-agent:disconnected, timeout

* Fix: typo

* Fix

* TODOs

* databasefake

* Fix: typo

* More TODOs

* databasefake

* Timeout tests

* Address PR comments

* Implement FIXMEs

* Renamings

* Address PR comments

* Fix: readability

* Fix: refactor CASE logic

* CASE logic

* Fix

* Use CTE

* Polishing

* Comment

* WIP

* IS NOT NULL

* Without CTE

* One more optimization

* 2nd optimization
2022-11-24 15:33:13 +01:00
Bruno Quaresma 511bb469c4 feat: Change workspace version using the UI (#5158) 2022-11-24 13:36:50 +00:00
Mathias Fredriksson eff99f78fa feat: Add support for MOTD file in coder agents (#5147) 2022-11-24 12:22:20 +00:00
Mathias Fredriksson 8ff89c4288 fix: Fix flakeyness of TestProvisionerd/ReconnectAndComplete (#5169) 2022-11-24 14:09:56 +02:00
Presley Pizzo 913e461f79 Don't override 0 ttl with template default (#5151) 2022-11-23 10:30:38 -05:00
Bruno Quaresma 59355431d0 refactor: Refactor login page (#5148) 2022-11-23 14:53:42 +00:00
Presley Pizzo 71bc48dda4 feat: tweak timeline design (#5144)
* Tweak timeline design

* Extract timeline style into component
2022-11-22 17:30:43 -05:00
Kira Pilot 6786ca2854 Audit build outcomes/kira pilot (#5143)
* auditing failed builds

* logging workspace build successes

* remove duplicate workspace build entry

* fixed workspacebuilds_test

* PR feedback

* lint and migrations

* fix nil auditors

* workspace_build test

* fixed workspaces_teest

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-11-22 13:22:56 -05:00
Colin Adler 1f20cab110 fix: don't use yamux for in-memory provisioner{,d} streams (#5136) 2022-11-22 12:19:32 -06:00
Mathias Fredriksson 2b6c229e4e fix: Trigger workspace event after agent timeout seconds (#5141)
Fixes #5116
2022-11-22 11:01:28 +00:00
Marcin Tojek e94b27bce4 fix: Adjust description for cancel in-progress workspace jobs (#5142)
* fix: Adjust description for cancel in-progress workspace jobs

* Update site/src/i18n/en/templatePage.json

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>
2022-11-21 17:00:18 +00:00
Presley Pizzo 67941b4f80 chore: refactor audit page to use window function for count (#5133)
* Move count query to window function

* Unpack count and update types

* Remove count endpoint

* Update tests, wip

* Fix tests

* Update frontend, wip

* Remove space

* Fix frontend test

* Don't hang on error

* Handle no results

* Don't omit count

* Fix frontend tests
2022-11-21 11:30:41 -05:00
Bruno Quaresma 7a369e0a30 refactor: Minor build bar UI improvement (#5132) 2022-11-21 10:04:24 -05:00
Marcin Tojek e86539db11 feat: Allow user to cancel workspace jobs (#5115)
* Add database column allow_user_cancel_workspace_jobs

* Adjust API

* site: typesGenerated.ts

* Expose template.allow_ in Workspaces API

* Fix: site tests

* Fix: make fmt/prettier

* Fix: enterprise

* Database tests

* Add CLI tests

* Add checkbox

* i18n

* Logic: block cancelling

* Unit tests for conditional cancel

* Fix: message

* Address PR comment

* Address PR comments

* Fix: make
2022-11-21 11:43:53 +01:00
Bruno Quaresma 5fa3fdeca0 refactor: Improve empty views (#5134) 2022-11-19 01:46:11 +00:00
Bruno Quaresma a477d901d6 refactor: Fix up to date color (#5131) 2022-11-19 01:18:40 +00:00
Colin Adler ae38bbeab6 chore: refactor agent stats streaming (#5112) 2022-11-18 16:46:53 -06:00
Bruno Quaresma 13a4cfa670 chore: Remove unused test files and code (#5130) 2022-11-18 18:03:15 +00:00
Presley Pizzo 4c24adb471 Fix filter bug (#5124) 2022-11-18 09:53:16 -05:00
Bruno Quaresma 5866ca48a9 refactor: Reemove mono font from empty title (#5125) 2022-11-18 10:09:13 -03:00
Ben Potter edad2d01da chore: fix typo in cvm docs (#5120) 2022-11-18 06:01:01 +00:00
Dean Sheather 69e8c9e7b4 feat: add reconnectingpty loadtest (#5083) 2022-11-17 16:57:15 +00:00
Ammar Bandukwala acf34d4295 site: support high build time variation in progress bar (#4941) 2022-11-17 16:56:56 +00:00
Kyle Carberry 60cec022eb fix: Parse boolean in slice for gitauth (#5113)
This was causing a panic for the new `no_refesh` option!
2022-11-17 07:52:11 -06:00
Ben Potter 8e468c49cb chore: default to generic troubleshooting link (#5007) 2022-11-17 11:10:49 +00:00
Kyle Carberry fb9ca7b830 feat: Add the option to generate a trial license during setup (#5110)
This allows users to generate a 30 day free license during setup to
test out Enterprise features.
2022-11-16 17:09:49 -06:00
Kyle Carberry b6703b11c6 feat: Add external provisioner daemons (#4935)
* Start to port over provisioner daemons PR

* Move to Enterprise

* Begin adding tests for external registration

* Move provisioner daemons query to enterprise

* Move around provisioner daemons schema

* Add tags to provisioner daemons

* make gen

* Add user local provisioner daemons

* Add provisioner daemons

* Add feature for external daemons

* Add command to start a provisioner daemon

* Add provisioner tags to template push and create

* Rename migration files

* Fix tests

* Fix entitlements test

* PR comments

* Update migration

* Fix FE types
2022-11-16 16:34:06 -06:00
Colin Adler 66d20cabac fix: index GetWorkspaceAgentsByResourceIDs query (#5021) 2022-11-16 14:40:57 -06:00
Colin Adler e7f1192614 fix: add index for GetProvisionerLogsByIDBetween (#5020) 2022-11-16 14:32:29 -06:00
Ammar Bandukwala da758ba712 site: fix quota_allowance == 0 bug (#5108) 2022-11-16 18:20:07 +00:00
Steven Masley 894953db3d fix: Workspace ls show only me by default (#5107) 2022-11-16 17:58:50 +00:00
Steven Masley 015a6f9e26 fix: RBAC should default deny missing variables. (#5105)
* fix: RBAC should default deny missing variables.

The default behavior was to use 'true' for missing variables. This
was an incorrect assumption. If the variable is missing, the new
default is to deny (fail secure).

* Assert 1 workspace is returned for the owners
2022-11-16 11:01:09 -06:00
Bruno Quaresma 1fcc7caf99 fix: Fix tab default (#5104) 2022-11-16 16:43:35 +00:00
Presley Pizzo e6ead7d915 chore: refactor workspaces query to use window function (#5079)
* Use window function in query

* Convert workspace rows and unpack count

* Update types

* Fix Scan bug

* Remove getCountError
2022-11-16 10:16:37 -05:00
Presley Pizzo 560d3c9fd0 fix: remove pagination widget when filter is invalid (#5095)
* Clear count along with user, remove count error

* Format
2022-11-16 09:55:41 -05:00
Marcin Tojek 32927b1a24 feat: show template.display_name on Workspace pages (#5082)
* feat: expose template.display_name via Workspaces endpoint

* Fix: MockWorkspace

* UI: Workspace stats and row

* Show template.display_name on pages

* Fix: address PR comments

* Add helper function: getDisplayWorkspaceTemplateName
2022-11-16 15:50:32 +01:00
Mathias Fredriksson c1ecc91aab feat: Add fallback troubleshooting URL for coder agents (#5005) 2022-11-16 12:53:02 +02:00
Geoffrey Huntley 1f4f0cee2a chore(branding): update branding (#5028) 2022-11-16 07:15:33 -03:00
Ben Potter 09ee844389 fix: git docs link (#5099) 2022-11-15 21:19:52 +00:00
Kyle Carberry fc0a493b72 feat: Add no_refresh option to Git auth configs (#5097)
This allows organizations to disable refreshing Git tokens
and instead prompt for authentication again.
2022-11-15 21:06:13 +00:00
Bruno Quaresma 2a46702fc5 fix: Syntax highlighting with long lines and untar content with emojis (#5098) 2022-11-15 20:09:54 +00:00
Ammar Bandukwala 44d3225932 .github: remove issue templates
Developers prefer no template based on Slack poll.
2022-11-15 20:02:50 +00:00
Mathias Fredriksson d9a83fc723 fix: Refactor tailnet conn AwaitReachable to allow for pings >1s RTT (#5096) 2022-11-15 20:59:22 +02:00
Marcin Tojek eda7c66896 chore: TemplatesPage tests failing on M1 (#5088) 2022-11-15 19:45:01 +01:00
Bruno Quaresma e68923fa36 fix: Worker security policy (#5093) 2022-11-15 17:02:24 +00:00
Mathias Fredriksson 9fb710a04f feat: Add allow everyone option to GitHub OAuth2 logins (#5086)
* feat: Add allow everyone option for GitHub OAuth

* fix: Detect team when multiple orgs are present

Co-authored-by: 李董睿煊 <dongruixuan@hotmail.com>
2022-11-15 18:56:46 +02:00
Bruno Quaresma f262fb4811 feat: Add template version page (#5071) 2022-11-15 16:24:13 +00:00
Kyle Carberry 773fc73280 fix: Add debug logging for connecting to psql (#5078)
If a database connection hung, the output was unclear.
2022-11-14 20:10:37 -06:00
Kyle Carberry 50b5becfb0 fix: Invert err nil check for opening Git URL (#5077)
Thanks @kconley-sq! 🥳
2022-11-14 20:10:23 -06:00
Geoffrey Huntley b5181aacd7 feat(i18n): adjust language when deleting a template (#5056) 2022-11-15 10:12:53 +10:00
Garrett Delfosse 88f3691dcc feat: add count to get users endpoint (#5016) 2022-11-14 17:22:57 -05:00
Marcin Tojek 49b340e039 Show template.display_name in the site UI (#5069)
* Show display_name field in the template settings

* Show template.display_name on pages: Templates, CreateWorkspace

* Fix: template.display_name pattern

* make fmt/prettier

* Fix tests

* Fix: make fmt/prettier

* Fix: merge

* Fix: autoFocus

* i18n: display_name
2022-11-14 21:11:50 +01:00
Mathias Fredriksson e872e18883 chore: Set initialism for DefaultTTL (from DefaultTtl) (#4996) 2022-11-14 20:14:08 +02:00
Ammar Bandukwala 97dbd4dc5d Implement Quotas v3 (#5012)
* provisioner/terraform: add cost to resource_metadata

* provisionerd/runner: use Options struct

* Complete provisionerd implementation

* Add quota_allowance to groups

* Combine Quota and RBAC licenses

* Add Opts to InTx
2022-11-14 17:57:33 +00:00
Kira Pilot 3fb7892c07 fix: template permissions page never loads (#5014)
* removed redundant permissions loader

* fixed tests
2022-11-14 12:33:17 -05:00
Kyle Carberry fefacc5bfd chore: Expose additional agent options to telemetry (#5070)
This also adds a few properties for deployments!
2022-11-14 10:11:08 -06:00
Geoffrey Huntley 9692cc2e22 housekeeping: structure GitHub issues via templates (#5025) 2022-11-14 09:32:54 -06:00
Marcin Tojek cf5d48bb5a fix: do not skip properties on creating templates (#5060)
* fix: do not skip properties while creating templates

* test: empty edit
2022-11-14 15:32:18 +01:00
Mathias Fredriksson 4b3d211e00 fix: Use UTC in cli/cliui table test to match expected output (#5063) 2022-11-14 15:08:51 +02:00
Muhammad Atif Ali 990be63c60 feat: create winget package workflow (#4761)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-11-14 12:59:08 +00:00
Marcin Tojek 1b6d0c39e1 docs: Rephrase Templates section (#5062)
* docs: Rephrase Templates section

* Update docs/templates.md

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update docs/templates.md

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update docs/templates.md

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update docs/templates.md

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-11-14 12:06:16 +00:00
Mathias Fredriksson e72927f3ab fix: Avoid running shell twice in coder agent (#5061)
The users login shell would be executed as:

	/bin/bash -c '/bin/bash -l'

This simplifies the command for login shells so that the executed
command is:

	/bin/bash -l
2022-11-14 14:01:22 +02:00
Mathias Fredriksson c515085450 fix: Unify context usage for agent cmd and logs (#5059) 2022-11-14 13:48:44 +02:00
Geoffrey Huntley cbb1e91372 feat(windows): default to PowerShell v7 over v6 and fallback to cmd.exe (#5053) 2022-11-14 15:43:40 +10:00
Mathias Fredriksson f017548a9c fix: Return correct exit code for SFTP sessions (#5044)
Fixes #5038
2022-11-13 23:22:50 +02:00
Kyle Carberry 2a6fff9227 fix: Set a default CODER_ACCESS_URL in Helm (#5041)
* fix: Set a default `CODER_ACCESS_URL` in Helm

This allows for a simple `helm apply` to create a full Coder
deployment that works for creating workspaces.

* Update docs
2022-11-13 14:49:57 -06:00
Ammar Bandukwala 73f91e4690 ci: use big runners (#4990)
* chore: Close idle connections on test cleanup

It's possible that this was the source of a leak on Windows...

* ci: use big runners

* fix: Improve tailnet connections by reducing timeouts

This awaits connection ping before running a dial. Before,
we were hitting the TCP retransmission and handshake timeouts,
which could intermittently add 1 or 5 seconds to a connection
being initialized.

* Add logging to Startupscript test

* Add better logging

* Write startup script logs to fs dir

* Fix startup script test

* Fix startup script test

* Reduce test timeout

* Use central tmp dir in agent

* Adjust output

* Skip startup script test on Windows

Co-authored-by: Kyle Carberry <kyle@carberry.com>
2022-11-13 14:23:23 -06:00
Arthur Normand 9578ce9f77 OAuth now uses client TLS certs (if configured) (#5042)
* OAuth now uses client TLS certs (if configured)

* Update docs

* Cleaning

* Fix lint errors and generate static files

* Fix lint error and regenerate more static files

* Suppress lint error
2022-11-13 14:15:06 -06:00
Kyle Carberry 49c7648af5 chore: Close idle connections on test cleanup (#4993)
It's possible that this was the source of a leak on Windows...
2022-11-13 14:06:03 -06:00
zhaozhiming 30e9ecbc96 docs: fix offline install docs some errors (#5039)
* docs: fix offline install docs some error

* retrigger checks
2022-11-13 14:05:19 -06:00
Kyle Carberry 82f494c99c fix: Improve tailnet connections by reducing timeouts (#5043)
* fix: Improve tailnet connections by reducing timeouts

This awaits connection ping before running a dial. Before,
we were hitting the TCP retransmission and handshake timeouts,
which could intermittently add 1 or 5 seconds to a connection
being initialized.

* Update Tailscale
2022-11-13 11:33:05 -06:00
Geoffrey Huntley 4646f58072 housekeeping(terraform): bump TerraformVersion (#4867) 2022-11-12 09:35:12 +10:00
Ammar Bandukwala 95fb59696e Refactor Provisioner to distinguish Plan and Apply (#5036) 2022-11-11 16:45:58 -06:00
Mathias Fredriksson 71601f4971 fix: Fix log wrapper for vite in scripts/develop.sh (#5030)
The pid tracking refactor resulted in the pipe while echo to block the
script from continuing and showing the banner at the end. This change
redirects the stdout for the `start_cmd` to a new fd which `while` is
reading from.
2022-11-11 12:39:33 +00:00
Eric Paulsen 823b02ac9c docs: deprecate name arg (#5026) 2022-11-11 06:16:14 +00:00
Kyle Carberry 4b7c710755 fix: Block creating workspaces with deleted templates (#5019)
@coadler and @deansheather bricked a Coder deployment with this...
2022-11-10 16:53:14 -06:00
Kyle Carberry 927c241995 fix: Debounce AcquireJob when no jobs are available (#5017)
This prevents constant database spam at scale to a maximum
of 60 queries/s per coderd instance.
2022-11-10 22:37:33 +00:00
Geoffrey Huntley f32748c929 housekeeping(stalebot): never close never stales (#4891) 2022-11-10 16:28:20 -06:00
Dean Sheather 8e5af82275 feat: add api-rate-limit flag (#5013) 2022-11-10 21:53:48 +00:00
Marcin Tojek 2042b575dc feat: Add template display name (backend) (#4966)
* Rename to nameValidator

* Refactor: NameValid

* Fix: comment

* Define new migration

* Include display_name

* Update typesGenerated.ts

* Update meta

* Adjust tests

* CLI tests

* Fix: audit

* Fix: omitempty

* site: display_name is optional

* unit: TestUsernameValid

* entities.ts: add display_name

* site: TemplateSettingsPage.test.tsx

* Fix: TemplateSettingsForm.tsx

* Adjust tests

* Add comment to display_name column

* Fix: rename

* Fix: make

* Loosen regexp

* Fix: err check

* Fix: template name length

* Allow for whitespaces

* Update migration number
2022-11-10 21:51:09 +01:00
Colin Adler f3eb662208 fix: add index for workspace_resource.job_id column (#5009) 2022-11-10 20:09:44 +00:00
Mathias Fredriksson 5e2253030f fix: Revert develop.sh timeout -> curl change (#5008)
It seems `--retry-all-errors` is not available on e.g. curl 7.68.0.
2022-11-10 19:49:11 +00:00
Colin Adler 8c8344ca13 fix: tolerate non-json lines in provisionerd logs (#5006)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-11-10 13:26:57 -06:00
Mathias Fredriksson a25deb939b fix: Misc improvements to scripts/develop.sh (#4995)
* Use new `/healthz` endpoint for checking API liveness
* Improved credential handling/retrying in failure scenarios
* Separate site (`vite`) logs with prefix and date, additionally this
  method also disables the `vite` clearing of the screen
* Show all interfaces coder API is listening on (due to `0.0.0.0`)
* Improved shutdown procedure / interrupt handling
2022-11-10 20:47:42 +02:00
Garrett Delfosse 766a2ad590 chore: refactor workspace count to single route (#4809)
Co-authored-by: Presley Pizzo <presley@coder.com>
2022-11-10 13:25:46 -05:00
Mathias Fredriksson 5fb9c33ecd fix: Fix ssh message/spinner in VSCode integrated terminal (#5000)
* fix: Fix ssh message/spinner in VSCode integrated terminal

The messages never show up in VSCode integrated terminal due to the
defer `fmt.Fprintf`. There could be a race in VSCode in handling the
terminal codes but ultimately, we can simplify our logic by just
stopping the spinner for the duration of the update.

* Avoid race in starting spinner after exit
2022-11-10 18:21:38 +00:00
Dean Sheather e847276d74 feat: add cleanup strategy to loadtest (#4991) 2022-11-11 04:14:50 +10:00
Kira Pilot 1c9677d37a Template delete button/kira pilot (#4992)
* removed button

* ripped out delete dialog

* fixed tests

* added error message back

* redirecting after success
2022-11-10 10:41:36 -05:00
Mathias Fredriksson 0eed533b17 fix: Improve agent waiting/timeout message behavior in ssh (#4999) 2022-11-10 15:41:23 +00:00
Kyle Carberry aa9fa2bdff chore: Disable load test for flakes (#4998) 2022-11-10 15:31:35 +00:00
Marcin Tojek d64c73dd74 chore: ignore .envrc (#4994) 2022-11-10 11:55:55 +01:00
Mathias Fredriksson 570a1ffc2b fix: Improve docker example first user experience (#4972)
The base ubuntu image lands the user as root, but the terraform tempalte
expected /home/coder to be used. This change adds a user with the same
name as the Coder users username and allows them to sudo.
2022-11-10 12:55:39 +02:00
Mathias Fredriksson 4885ecc3ad fix: Allow dumping db with pg_dump, utilize make cache (#4964) 2022-11-10 12:54:47 +02:00
Eric Paulsen 18a97c6f59 helm: add affinity, nodeSelectors, tolerations (#4763) 2022-11-09 22:08:44 +00:00
Bruno Quaresma d225f2c6ba feat: Display warning on agent connection timeout (#4983) 2022-11-09 20:40:34 +00:00
Kyle Carberry 16e9b1eb1a fix: Add timeouts to every tailnet ping (#4986)
A ping isn't guaranteed to deliver, so these need to have a
tight timeout for tests to not flake.
2022-11-09 20:12:51 +00:00
Dean Sheather 45f81a7cd5 fix: prevent terraform init races (#4985) 2022-11-09 19:40:52 +00:00
Garrett Delfosse d277e28427 feat: change template max_ttl to default_ttl (#4843) 2022-11-09 19:36:25 +00:00
Dean Sheather ffc24dcbe0 feat: create tracing.SlogSink for storing logs as span events (#4962) 2022-11-09 12:58:23 -06:00
Dean Sheather 0ae8d5eeec fix: prevent races from processing build logs after channel close (#4984) 2022-11-10 04:32:59 +10:00
Kyle Carberry 3c10c7f5f4 fix: Subscribe to template updates on the workspace page (#4979)
Fixes #4969.
2022-11-09 11:01:34 -06:00
Mathias Fredriksson 5592f85c11 chore: Find source files once in Makefile targets (#4968) 2022-11-09 18:39:42 +02:00
Kyle Carberry 089659ffb1 fix: Move SQL connection limits to initialization (#4981)
The connection limit wasn't being applied to pubsub, which would
overload the server if a ton of logs were being published at once.

This should fix it, and improve scale a lot!
2022-11-09 16:25:25 +00:00
Mathias Fredriksson 90c34b74de feat: Add connection_timeout and troubleshooting_url to agent (#4937)
* feat: Add connection_timeout and troubleshooting_url to agent

This commit adds the connection timeout and troubleshooting url fields
to coder agents.

If an initial connection cannot be established within connection timeout
seconds, then the agent status will be marked as `"timeout"`.

The troubleshooting URL will be present, if configured in the Terraform
template, it can be presented to the user when the agent state is either
`"timeout"` or `"disconnected"`.

Fixes #4678
2022-11-09 17:27:05 +02:00
Mathias Fredriksson ed7de90a55 fix: Use immutable names for volumes in example templates (#4954)
* fix: Use immutable names for volumes in example templates

This contributes towards #3000, #3386

Related #3409

* Add lifecycle and labels
2022-11-09 16:18:19 +02:00
Mathias Fredriksson 26ab0d37c1 fix: Protect codersdk.Client SessionToken so it can be updated (#4965)
This feature is used by the coder agent to exchange a new token. By
protecting the SessionToken via mutex we ensure there are no data races
when accessing it.
2022-11-09 15:31:24 +02:00
sharkymark 8cadb33396 chore: remove sample jetbrains projector code, only use 2 kubernetes example repos (#4819) 2022-11-09 10:30:38 +00:00
sharkymark b6f2a29b7e docs: update port forwarding to state it works without a wildcard with tunnel (#4887) 2022-11-09 20:25:32 +10:00
Dean Sheather d82364b9b5 feat: make trace provider in loadtest, add tracing to sdk (#4939) 2022-11-09 08:10:48 +10:00
Presley Pizzo fa844d0878 Feat: hide pagination widget when not needed (#4957)
* Hide pagination widget when not needed. Don't merge until count is in.

* Format

* Refactor

* Remove story

* Fix bug

* Format
2022-11-08 13:29:32 -05:00
Mathias Fredriksson e906d0dc54 feat: Add database fixtures for testing migrations (#4858) 2022-11-08 19:59:44 +02:00
Kyle Carberry b97043850b fix: Remove action from build cancelation names (#4930)
This looked weird in the UI and didn't conform to our other states.
2022-11-08 17:12:06 +00:00
Garrett Delfosse 2789fb7cac fix: move experimental flag to server (#4959) 2022-11-08 16:59:39 +00:00
Mathias Fredriksson b2a16d46c6 chore: Unify Docker terraform templates (#4952)
Changes to terraform templates:

* Remove DNS (this can interfere with users running their own DNS
  servers)
* Remove `lower()` restriction from hostnames so that it will show the
  name set by the user, as-is (there is no restriction on upper case
  letters in hostnames)
* Remove superfluous `trap` in entrypoints, this is already handled by
  the init script
* Switch from `command` to `entrypoint` as the latter can support more
  Docker images out-of-the-box
2022-11-08 18:52:19 +02:00
dependabot[bot] 6baaf205c8 chore: bump loader-utils from 1.4.0 to 1.4.1 in /site (#4956)
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 1.4.0 to 1.4.1.
- [Release notes](https://github.com/webpack/loader-utils/releases)
- [Changelog](https://github.com/webpack/loader-utils/blob/v1.4.1/CHANGELOG.md)
- [Commits](https://github.com/webpack/loader-utils/compare/v1.4.0...v1.4.1)

---
updated-dependencies:
- dependency-name: loader-utils
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-08 10:09:33 -06:00
Presley Pizzo 87b3fe1afb feat: add "on this page" to empty table message when you're past page 1 (#4886)
* Use empty page message on workspaces page

* Add prop for story

* AuditPage

* UsersPage

* Lint and format

* Fix tests

* Remove log

* Try to fix story

* Fix the right story
2022-11-08 11:08:51 -05:00
Presley Pizzo f496b149df feat: add count endpoint for users, enabling better pagination (#4848)
* Start on backend

* Hook up frontend

* Add to frontend test

* Add go test, wip

* Fix some test bugs

* Fix test

* Format

* Add to authorize.go

* copy user array into local variable

* Authorize route

* Log count error

* Authorize better

* Tweaks to authorization

* More authorization tweaks

* Make gen

* Fix test

Co-authored-by: Garrett <garrett@coder.com>
2022-11-08 10:58:44 -05:00
Kyle Carberry a4fbc74751 chore: Update gotestsum (#4955)
This was breaking CI!
2022-11-08 09:58:01 -06:00
Mathias Fredriksson d1c82f6c52 fix: Off-by-one created after notification for provisioner logs (#4949)
Fixes #4948
2022-11-08 17:56:16 +02:00
Bruno Quaresma e7bd04999f fix: Optimistically update the UI when a workspace action is triggered (#4929) 2022-11-08 09:35:19 -05:00
Marcin Tojek bf4a6fb5b5 feat: pprof is always on (#4951) 2022-11-08 15:02:07 +01:00
Marcin Tojek 16384f8594 feat: Add provisioner force-cancel flag (#4947)
* feat: Add provisionerd force cancel flag

* Golden files

* Fix: typesGenerated.ts

* Use single struct for Provisioner config
2022-11-08 14:19:40 +01:00
Bruno Quaresma f6130e25b2 refactor: Disable auto-complete for the new user form (#4933) 2022-11-08 13:10:25 +00:00
Bruno Quaresma 2af698c43d refactor: Remove workspace schedule banner (#4932) 2022-11-08 10:05:47 -03:00
Kyle Carberry da05bbbdf7 chore: Separate the provisionerd server into it's own package (#4940)
* chore: Separate the provisionerd server into it's own package

This code should be thoroughly tested now that we understand the abstraction.

I separated it to make our lives a bit easier for external provisioner daemons
as well!

* Add tests

* Add workspace builds

* Add test for workspace resources
2022-11-08 01:10:49 +00:00
Kyle Carberry bf2f7b575e chore: Disable docs.github.com for link checks (#4945)
This was causing CI to fail... maybe they have bot detection?
2022-11-07 18:39:46 -06:00
Kyle Carberry 165b6fbc6a fix: Use app slugs instead of the display name to report health (#4944)
All applications without display names were reporting broken health.
2022-11-07 23:35:01 +00:00
Colin Adler 50ad4a8535 fix: use backend for /healthz page (#4938) 2022-11-07 19:35:52 +00:00
Ben Potter bda76368bc docs: git auth (#4902) 2022-11-07 19:04:00 +00:00
sharkymark 1545979e6f docs: 1. fix closing ) on projector examples 2.update jupyter section for slug config and removal of owner and workspace baseURL (#4920) 2022-11-07 12:41:03 -06:00
Marcin Tojek 641aacf793 feat: show banner when workspace is outdated (#4926)
* feat: show banner when workspace is outdated

* Address PR comments

* Fix: writer
2022-11-07 19:12:39 +01:00
Bruno Quaresma f15854c179 fix: Fix long audit log string (#4931) 2022-11-07 14:39:37 -03:00
Dean Sheather 5f099ea488 feat: loadtest output formats (#4928) 2022-11-08 03:26:50 +10:00
Dean Sheather f9189772d7 feat: add new loadtest type agentconn (#4899) 2022-11-07 17:18:07 +00:00
Kyle Carberry 56b963a940 feat: Make workspace watching realtime instead of polling (#4922)
* feat: Make workspace watching realtime instead of polling

This was leading to performance issues on the frontend, where
the page should only be rendered if changes occur. While this
could be changed on the frontend, it was always the intention
to make this socket ~realtime anyways.

* Fix workspace tests waiting, erroring on workspace update, and add comments to workspace events
2022-11-07 15:25:18 +00:00
Muhammad Atif Ali a5cc1970cf bug: fixed prompt in .devcontainer/Dockerfile (#4820)
The user prompt was causing the GitHub codespaces build to fail.
2022-11-07 09:03:55 -03:00
Kyle Carberry 53f2449e4f chore: Fix changes from buffer provisioner logs (#4924)
Comments from #4918 were missed because of auto-merge.
2022-11-06 23:59:01 -06:00
Kyle Carberry 30281852d6 feat: Add buffering to provisioner job logs (#4918)
* feat: Add bufferring to provisioner job logs

This should improve overall build performance, and especially under load.

It removes the old `id` column on the `provisioner_job_logs` table
and replaces it with an auto-incrementing big integer to preserve order.

Funny enough, we never had to care about order before because inserts
would at minimum be 1ms different. Now they aren't, so the order needs
to be preserved.

* Fix log bufferring

* Fix frontend log streaming

* Fix JS test
2022-11-06 20:50:34 -06:00
sharkymark 531f7cd489 docs: adding sharkymark example templates to community page (#4911) 2022-11-06 17:03:37 -06:00
Colin Adler 65ffa20ba2 fix: use correct empty uuids (#4917) 2022-11-06 16:49:43 -06:00
Kyle Carberry 1898f67fe0 fix: Ensure the session token is properly passed to instance identity (#4923)
Fixes #4921.
2022-11-06 16:46:51 -06:00
Kyle Carberry 5be6c7071e feat: Associate connected workspace agents with replicas (#4914)
This will enable displaying a graph that associates agents
to running replicas.
2022-11-06 15:27:09 -06:00
Bruno Quaresma 267b81af83 Revert "fix: Optimistically update the UI when a workspace action is triggered (#4898)" (#4912)
This reverts commit 8f4ae5b6ac.
2022-11-06 10:22:01 -06:00
Colin Adler e740aebf26 feat: add provisionerd prometheus metrics (#4909) 2022-11-04 19:03:01 -05:00
Colin Adler 8dd567dd89 fix: use prometheus default registry (#4907) 2022-11-04 20:19:58 +00:00
Marcin Tojek dad89453d4 docs: Setup external PostgreSQL server (#4901)
* docs: Setup external PostgreSQL server

* Update docs/install/database.md

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Use user:password pattern

* Fix

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-11-04 21:15:03 +01:00
Bruno Quaresma 8f4ae5b6ac fix: Optimistically update the UI when a workspace action is triggered (#4898) 2022-11-04 19:09:45 +00:00
Jon Ayers 55fe26bdfa feat: publish helm chart to helm.coder.com (#4793) 2022-11-04 13:43:29 -05:00
Bruno Quaresma ab78f9c2c5 refactor: Improve long rows in audit log (#4904) 2022-11-04 15:24:49 -03:00
Mathias Fredriksson 587924fc42 feat: Add golden files to test cli help output (#4897) 2022-11-04 19:48:36 +02:00
Mathias Fredriksson 70048acd73 fix: Disable viper auto-env to avoid assigning to parent structs (#4893)
The viper automatic env mapping and BindEnv were both creating mappings
like `vip.BindEnv("telemetry", "CODER_TELEMETRY")` which we don't want
since `DeploymentConfig.Telemetry` is a struct housing fields.

For some reason, this was causing `DeploymentConfig.Telemetry.URL` to
**not** be assigned its default value when `CODER_TELEMETRY=false` was
set as an environment variable.

Potentially we would want `"telemetry.enable"` to be mapped to
`"CODER_TELEMETRY"` for simplicity. But that behavior is not changed by
this commit.

Arguably, we could remove `vip.SetEnvPrefix` and `vip.SetEnvKeyReplacer`
as well since we're manually controlling all environment variable names
via `formatEnv`.
2022-11-04 19:46:59 +02:00
Colin Adler 1bbe37a602 chore: update tailscale (#4903) 2022-11-04 12:32:55 -05:00
Kyle Carberry 8e743d28c8 fix: Use instance identity session token for git subcommands (#4884)
This broke using gitssh with instance identity!
2022-11-04 09:44:36 -07:00
Marcin Tojek 3f6c4486f7 Allow changing db schema from public (#4873)
* Remove public schema from enum defs

* Update queries

* Fix
2022-11-04 09:15:17 +01:00
Kyle Carberry 104d6608d9 feat: Add VSCODE_PROXY_URI to surface code-server ports (#4798)
* feat: Add `VSCODE_PROXY_URI` to surface code-server ports

Fixes #4776.

* Check if app host is provided
2022-11-04 04:45:43 +00:00
Geoffrey Huntley e83e6dc583 docs(cli): proxy-trusted-origins should be an ip (#4890) 2022-11-04 03:14:02 +00:00
Eric Paulsen c9a311331a docs: fix DB URL (#4888) 2022-11-04 02:32:59 +00:00
Ben Potter 75da08740c docs: consolidate docker quickstarts (#4882) 2022-11-04 04:30:10 +10:00
Mathias Fredriksson 04ae4c036b fix: Avoid parsing telemetry URL when telemetry is disabled (#4881) 2022-11-03 20:09:21 +02:00
Ben Potter 9b76b10206 chore: hide Coder message on code-server's "Getting Started" page (#4847) 2022-11-03 11:04:27 -05:00
sharkymark 1882edaa9a docs: change format from console to sh for psql URL and coder update repair sections (#4878) 2022-11-03 10:56:20 -05:00
sharkymark 9cd74f307c chore: update port forward dashboard docs for coder_app, sharing, and showing running processes (#4876)
* chore: update port forward dashboard docs for coder_app and sharing

* Update docs/networking/port-forwarding.md

Co-authored-by: Ben Potter <ben@coder.com>
2022-11-03 15:44:56 +00:00
dependabot[bot] 7f0f522b92 chore: bump chromatic from 6.10.1 to 6.11.4 in /site (#4833)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.10.1 to 6.11.4.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.10.1...v6.11.4)

---
updated-dependencies:
- dependency-name: chromatic
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-03 11:23:37 -04:00
Kira Pilot a73dd4f45d Audit date filter/kira pilot (#4845)
* sql query

* added time_to

* added validation error

* documentation

* attempt to add test

* removed whiitespace

* fix: ensure date_from and date_to are applied correct audit logs

* added more tests

* ran make gen

* PR feedback

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-11-03 11:04:36 -04:00
Joe Previte 6bfdccda2f refactor: rm eslint-disable CreateWorkspacePage (#4865) 2022-11-02 22:06:22 -03:00
sharkymark 3fc3b9f89f docs: add psql URL for built-in db and repair workspace CLI (#4864) 2022-11-02 23:56:24 +00:00
Bruno Quaresma f76e7b1dbd refactor: Refactor create workspace page (#4862) 2022-11-02 20:44:41 +00:00
Bruno Quaresma 86fc3e09a3 refactor: Better colocate suspense (#4863) 2022-11-02 13:17:14 -07:00
Dean Sheather e7dd3f9378 feat: add load testing harness, coder loadtest command (#4853) 2022-11-02 18:30:00 +00:00
sharkymark b1c400a7df chore: update web-ides section with revised docker examples and Airflow/RStudio using subdomain config (#4855)
* chore: update web-ides section with docker examples and subdomain rstudio and airflow examples

* Update docs/ides/web-ides.md

* Update docs/ides/web-ides.md

Co-authored-by: Ben Potter <ben@coder.com>
2022-11-02 15:09:42 +00:00
Colin Adler e26bc20723 fix: actually fix template version created by migration (#4850) 2022-11-01 22:19:58 +00:00
Kyle Carberry a672ae8c7d feat: Extract instance type when provisioning VMs (#4839)
This should help us identify what instances our users consume.
2022-11-01 21:51:57 +00:00
Presley Pizzo 26a920a740 chore: do less calculation on users page (#4801)
* Do less calculation on users page

* Handle missing usernames
2022-11-01 16:57:44 -04:00
Kyle Carberry 29dc5f66b8 experiment: Switch to BuildJet Linux Runners (#4846) 2022-11-01 20:56:33 +00:00
Kyle Carberry 288e7d1045 fix: Flake on TestReplica/TwentyConcurrent (#4842)
This could actually cause connections to intermittently fail too
when a CPU is absolutely pegged. It just so happens that only
our runners have been that slow!

Fixes #4607.
2022-11-01 20:28:34 +00:00
dependabot[bot] a390b73386 chore: bump cloud.google.com/go/compute/metadata from 0.1.0 to 0.2.1 (#4841)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 20:27:33 +00:00
dependabot[bot] 88fc37d015 chore: bump github.com/gohugoio/hugo from 0.104.2 to 0.105.0 (#4828)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 18:41:43 +00:00
dependabot[bot] 0b2296a843 chore: bump cloud.google.com/go/compute from 1.10.0 to 1.12.1 (#4826)
Bumps [cloud.google.com/go/compute](https://github.com/googleapis/google-cloud-go) from 1.10.0 to 1.12.1.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/pubsub/v1.10.0...pubsub/v1.12.1)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/compute
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 11:23:40 -07:00
Garrett Delfosse ddbae4da59 fix: error if protocol isn't specified in --access-url (#4835) 2022-11-01 12:59:37 -04:00
Colin Adler a930cf42b4 fix: templates created_by migration (#4838) 2022-11-01 16:35:14 +00:00
dependabot[bot] 9d1d0bce59 chore: bump cronstrue from 2.11.0 to 2.14.0 in /site (#4831)
Bumps [cronstrue](https://github.com/bradymholt/cronstrue) from 2.11.0 to 2.14.0.
- [Release notes](https://github.com/bradymholt/cronstrue/releases)
- [Changelog](https://github.com/bradymholt/cRonstrue/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bradymholt/cronstrue/compare/v2.11.0...v2.14.0)

---
updated-dependencies:
- dependency-name: cronstrue
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 11:18:07 -05:00
dependabot[bot] 261154869d chore: bump github.com/moby/moby from 20.10.18+incompatible to 20.10.21+incompatible (#4822)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 15:11:52 +00:00
dependabot[bot] a5fa54ff23 chore: bump crate-ci/typos from 1.12.8 to 1.12.12 (#4825)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 10:06:41 -05:00
dependabot[bot] d25f770488 chore: bump golangci/golangci-lint-action from 3.2.0 to 3.3.0 (#4824)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 10:02:08 -05:00
dependabot[bot] 88c18775d3 chore: bump tj-actions/branch-names from 6.1 to 6.2 (#4823)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 10:01:14 -05:00
Mathias Fredriksson e508057d1a fix: Avoid panic in ServerSentEventSender by keeping handler alive (#4821)
The goroutine launched by `ServerSentEventSender` can perform a write
and flush after the calling http handler has exited, at this point the
resources (e.g. `http.ResponseWriter`) are no longer safe to use.

To work around this issue, heartbeats and sending events are now handled
by the goroutine which signals its closure via a channel. This allows
the calling handler to ensure it is kept alive until it's safe to exit.

Fixes #4807
2022-11-01 16:57:38 +02:00
Bruno Quaresma a7e5588a65 refactor: Refactor build page (#4815)
* refactor: Improve build page

* Add build translation

* Add build avatar better props

* Get build number from build
2022-11-01 11:49:32 -03:00
dependabot[bot] cf794f1046 chore: bump react-i18next from 11.18.4 to 12.0.0 in /site (#4832)
Bumps [react-i18next](https://github.com/i18next/react-i18next) from 11.18.4 to 12.0.0.
- [Release notes](https://github.com/i18next/react-i18next/releases)
- [Changelog](https://github.com/i18next/react-i18next/blob/master/CHANGELOG.md)
- [Commits](https://github.com/i18next/react-i18next/compare/v11.18.4...v12.0.0)

---
updated-dependencies:
- dependency-name: react-i18next
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 11:21:45 -03:00
Colin Adler 4c5bf42355 feat: add option for exporting traces to a provided Honeycomb team (#4816) 2022-11-01 09:15:41 -05:00
Mathias Fredriksson 21e64943ac fix: Use immutable links for docker with intellij/pycharm (#4834) 2022-11-01 15:04:50 +02:00
Joe Previte 17f5e830c7 refactor: extend Overrides for MuiSkeleton (#4818)
* refactor: extend Overrides for MuiSkeleton

Looking at the types provided with `@material-ui/core`, it is indeed
missing `MuiSkeleton`. I'm not sure why. I found this issues upstream: https://github.com/mui/material-ui/issues/24959

I also tried upgrading the package to the latest - 4.12.4 I believe but
that didn't fix it either.

I resorted to extending the `Overrides` type based on what I saw in the
most recent version of the declaration file. This is a temporary fix but
opts back in to type safety instead of resorting to `@ts-ignore`.

* formatting
2022-10-31 16:33:01 -07:00
Joe Previte 34268e6dee refactor: remove eslint-disable (#4817) 2022-10-31 22:04:51 +00:00
Bruno Quaresma 97bcd441f3 refactor: Improve agent loading state (#4814) 2022-10-31 17:35:05 -03:00
Colin Adler dde9a43b7e chore: fix otel dependency versions (#4813) 2022-10-31 19:16:16 +00:00
Colin Adler 1bd67b8064 fix: use -no-color when calling terraform show state (#4812) 2022-10-31 13:03:59 -05:00
Colin Adler cffb723ecc fix: small typos in proxy-trusted-headers help (#4811) 2022-10-31 17:00:04 +00:00
Bruno Quaresma 46e0953876 refactor: Show template versions as timeline (#4800) 2022-10-31 16:38:07 +00:00
Bruno Quaresma cc655672eb refactor: Fix list styles in markdown (#4802) 2022-10-31 11:56:26 -04:00
Alexander Hansen ec4b397aa4 Add 8Bitz0/coder-rust-template (#4804)
Put `8Bitz0/coder-rust-template` in `community-templates.md`
2022-10-31 09:25:41 -05:00
Arthur Normand 7635736be6 Fix link to supported terraform versions (#4803)
* Fix link to supported terraform versions

* Update offline.md
2022-10-29 11:07:06 -07:00
Joe Previte ffe461ae58 chore(site): enable eslint-plugin-eslint-comments (#4799)
* chore(site): enable eslint-plugin-eslint-comments

* chore: add descriptions to eslint-disable comments

* chore: update eslint-disable comments in main.go
2022-10-28 17:46:51 -03:00
Presley Pizzo 506a81e3dc feat: paginating Users page (#4792)
* Extract PageButton

* Fix import

* Extract utils

* Format

* Separate pagination - wip

* Spawn pagination machine - buggy filter

* Make labels optional

* Layout, fix send reset bug

* Format

* Fix refresh data bug

* Remove debugging line

* Fix url updates

setSearchParams overwrites all search params, rather than merging

* Update Audit Page

* Simplify pagination widget

* Fix workspaces story

* Fix Audit story

* Fix pagination story and pagebutton highlight

* Fix pagination tests

* Add to utils tests

* Format

* Add tests

* Start adding pagination - type error

* Tweak machine

* Refactor paginated api calls

* Show pagination when count is undefined

* fix stories

* Fix api helper

* Add test

* Format

* Make widget show all the time to avoid blink
2022-10-28 15:43:10 -04:00
Bruno Quaresma 708abd37cf refactor: Improve template README section (#4794)
* refactor: Improve template README section

* Fix version

* Add darcula

* Fix typos
2022-10-28 19:40:41 +00:00
Bruno Quaresma 6add465365 fix: display None when there are no apps (#4797) 2022-10-28 19:37:45 +00:00
Bruno Quaresma d2fac850cb refactor: Align values when there are more than one row in agent preview (#4795) 2022-10-28 19:09:05 +00:00
Dean Sheather 10df2fd4fb feat: add new required slug property to coder_app, use in URLs (#4573) 2022-10-28 17:41:31 +00:00
Jon Ayers 90f77a3415 feat: add groups support to the CLI (#4755) 2022-10-27 16:49:35 -05:00
Bruno Quaresma ce2a7d49b1 refactor: Refactor template resources (#4789) 2022-10-27 17:27:15 -03:00
Kira Pilot 8282e46813 chore: add audit log tests (#4764)
* added test for stopping a workspace build

* formatted sfriendly string; added tests

* logging unmarshal error in auditLogDescription

* prettier

* got rid of extra workspace word

* PR feedback

* fixed mistake; wrote tests in penance

* fix be
2022-10-27 15:57:41 -04:00
Asher 01ec483ecc docs: fix base path for JupyterLab (#4790)
It seems the base path uses the app name (for now anyway).
2022-10-27 17:38:54 +00:00
Kyle Carberry b34a67e6cb fix: Allow custom Git OAuth URLs (#4758)
Fixes an issue reported in Discord where custom endpoints
weren't working.
2022-10-27 10:38:05 -07:00
Bruno Quaresma 3e15ee3ba0 fix: Fix audit log collapse (#4781) 2022-10-27 01:02:52 +00:00
Ben Potter 670d5adfd7 chore: fix install.sh typo (#4770) 2022-10-26 15:32:20 -04:00
Bruno Quaresma d88b824328 refactor: Inline workspace badge (#4774) 2022-10-26 12:30:02 -07:00
Eric Paulsen 896f628473 site: fix networking docs link (#4778) 2022-10-26 19:29:50 +00:00
Bruno Quaresma 00495568e4 refactor: Make the audit log looks like a timeline (#4765) 2022-10-26 19:20:26 +00:00
Joe Previte 9d8c3ca59c docs(templates): add edit templates section (#4754)
* docs(templates): add edit templates section

* minor changes

Co-authored-by: Ben <me@bpmct.net>
2022-10-26 11:18:47 -07:00
Shyim 820306a32c set correct case for env (#4713) 2022-10-26 12:09:05 -05:00
Presley Pizzo b0d5e0613e chore: refactor pagination (#4753)
* Extract PageButton

* Fix import

* Extract utils

* Format

* Separate pagination - wip

* Spawn pagination machine - buggy filter

* Make labels optional

* Layout, fix send reset bug

* Format

* Fix refresh data bug

* Remove debugging line

* Fix url updates

setSearchParams overwrites all search params, rather than merging

* Update Audit Page

* Simplify pagination widget

* Fix workspaces story

* Fix Audit story

* Fix pagination story and pagebutton highlight

* Fix pagination tests

* Add to utils tests

* Format

* Add tests
2022-10-26 13:08:22 -04:00
Mathias Fredriksson a0bdb4fca2 fix: Remove pkg/sftp fork, fix SFTP test (#4759) 2022-10-26 16:02:06 +03:00
Bruno Quaresma b217f2c210 refactor: Refactor resources colors and avatars (#4751) 2022-10-25 16:41:38 -03:00
Kira Pilot 3c5e292c5a feat: add workspace build start/stop to audit log (#4744)
* adding workspace_build resource

* added migration

* fix keyword

* got rid oof diffs for workspace builds

* adding workspace name to string

* renamed migrations

* fixed lint

* pass throough AdditionalFields and fix tests

* no need to pass through each handler

* cleaned up migrations

* generated types; fixed missing cases

* logging error
2022-10-25 15:34:48 -04:00
Bruno Quaresma 9070fcd5e7 refactor: Refactor page header spacing and stats (#4750) 2022-10-25 14:51:58 -03:00
Bruno Quaresma 2ffefc3bbd fix: Don't show pagination during workspaces load (#4743) 2022-10-25 17:41:18 +00:00
dependabot[bot] f622247b51 chore: bump github.com/spf13/cobra from 1.5.0 to 1.6.1 (#4746)
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.5.0 to 1.6.1.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.5.0...v1.6.1)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-25 15:51:37 +00:00
dependabot[bot] 8b199c00e5 chore: bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc (#4723)
Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc](https://github.com/open-telemetry/opentelemetry-go) from 1.10.0 to 1.11.1.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.10.0...v1.11.1)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-25 15:48:10 +00:00
sonnysasaka 7d831e31c6 fix: Line gets erased due to updateJob (#4740)
The first updateJob should be called after the first printStage to
guarantee that only stage prints can get erased and overwritten,
otherwise there could be an unrelated line that gets erased.

fixes #3967
2022-10-25 10:27:44 -05:00
Ben Potter df89e2c3b0 chore: Move deployment UI and HA out of experimental (#4722)
* Revert "chore: Move deployment UI and HA into experimental (#4595)"

This reverts commit 18c4368571.

* restore flag in coderdtest
2022-10-25 14:33:37 +00:00
Dean Sheather 067362cf31 feat: add windows amd64 installer (#4719) 2022-10-26 00:19:54 +10:00
Kyle Carberry 7d04bf2abe Revert "adding workspace_build resource (#4636)" (#4742)
This reverts commit 145faf4400.
2022-10-25 08:41:00 -05:00
Kira Pilot 145faf4400 adding workspace_build resource (#4636)
* adding workspace_build resource

* added migration

* added migration for audit_actions

* fix keyword

* got rid oof diffs for workspace builds

* adding workspace name to string

* renamed migrations

* fixed lint

* pass throough AdditionalFields and fix tests

* no need to pass through each handler

* cleaned up migrations
2022-10-25 09:27:50 -04:00
Bruno Quaresma 3e08bb4842 feat: Redesign build logs (#4734) 2022-10-25 00:44:13 -03:00
Kyle Carberry 6449443c1f dogfood: remove gitconfig to allow cloning with HTTPS (#4739)
This reflects a more natural environment that our customers might have,
and enables us to use the new git authentication!
2022-10-25 02:37:20 +00:00
Joe Previte 49b3ea02cc refactor: clean up WorkspaceBuildLogs types (#4738)
* refactor: clean up types in WorkspaceBuildLogs

* feat: add tests for groupLogsByStage

* fixup!: formatting
2022-10-24 21:57:12 -03:00
Joe Previte dea329705a chore: clean up eslint-disable lines (#4735)
* chore: drop eslint-disable rule

* refactor: add types for makeMockApiError
2022-10-24 21:55:44 -03:00
Kyle Carberry eec406b739 feat: Add Git auth for GitHub, GitLab, Azure DevOps, and BitBucket (#4670)
* Add scaffolding

* Move migration

* Add endpoints for gitauth

* Add configuration files and tests!

* Update typesgen

* Convert configuration format for git auth

* Fix unclosed database conn

* Add overriding VS Code configuration

* Fix Git screen

* Write VS Code special configuration if providers exist

* Enable automatic cloning from VS Code

* Add tests for gitaskpass

* Fix feature visibiliy

* Add banner for too many configurations

* Fix update loop for oauth token

* Jon comments

* Add deployment config page
2022-10-24 19:46:24 -05:00
Garrett Delfosse 585045b359 feat: support nested structs, structured arrays, and better secret value handling in config (#4727) 2022-10-25 00:11:00 +00:00
Joe Previte f9c6220263 refactor: clean up types in DAUChart (#4737)
This cleans up some types in `DAUChart.tsx`. Previously, we were
type-casting which can lead to errors in production.
2022-10-24 23:28:07 +00:00
Kira Pilot afb806f71a Added the Group resource in audit-logs.md (#4733) 2022-10-24 16:26:22 -04:00
Ben b43b721b1e chore: minor tweaks to architecture diagram 2022-10-24 20:07:48 +00:00
Ben Potter 9ea3e96447 docs: update architecture & diagram (#4721)
* docs: update architecture & diagram

* remove old diagrams

* fix typo
2022-10-24 20:00:46 +00:00
Ammar Bandukwala a0249bea61 docs: better explain persistent resources (#4703) 2022-10-24 19:59:27 +00:00
Eric Paulsen 54261b6e8b docs: add auto-start/stop (#4728)
* docs: add auto-start/stop

* feedback

Co-authored-by: Ben Potter <ben@coder.com>

Co-authored-by: Ben Potter <ben@coder.com>
2022-10-24 15:32:05 -04:00
Ammar Bandukwala a82f05a0a0 docs: move enterprise to root (#4720) 2022-10-24 18:10:06 +00:00
dependabot[bot] dc18b0e442 chore: bump go.opentelemetry.io/otel/exporters/otlp/otlptrace (#4591)
Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace](https://github.com/open-telemetry/opentelemetry-go) from 1.10.0 to 1.11.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.10.0...v1.11.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-24 13:07:32 -05:00
dependabot[bot] 65b4106eac chore: bump github.com/u-root/u-root from 0.9.0 to 0.10.0 (#4579)
Bumps [github.com/u-root/u-root](https://github.com/u-root/u-root) from 0.9.0 to 0.10.0.
- [Release notes](https://github.com/u-root/u-root/releases)
- [Changelog](https://github.com/u-root/u-root/blob/main/RELEASES)
- [Commits](https://github.com/u-root/u-root/compare/v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: github.com/u-root/u-root
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-24 13:07:06 -05:00
Ali Diamond 1c9c450399 docs: fix typo (#4520)
missing word
2022-10-24 13:06:37 -05:00
Eric Paulsen fba03aea6e helm: add imagePullSecret for air-gapped cust's (#4700)
* helm: add imagePullSecret for air-gapped cust's

* helm: pullSecrets array

* fix: tag

* indentation

Co-authored-by: Dean Sheather <dean@deansheather.com>

* array

Co-authored-by: Dean Sheather <dean@deansheather.com>

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-10-24 13:24:21 -04:00
John 0783ca3793 cli: version to the $ coder header in CLI (#4709) 2022-10-24 11:17:48 -05:00
Kyle Carberry 6e06cf10e8 fix: Loading template twice on page load (#4688)
The template page loaded the template twice immediately!
2022-10-24 11:10:50 -04:00
Kyle Carberry c41bdc21cb fix: Add names to config properties for the UI (#4718)
This was reverted in the configuration PR, which broke the UI.
2022-10-24 14:37:37 +00:00
Kyle Carberry bf3224e373 fix: Refactor agent to consume API client (#4715)
* fix: Refactor agent to consume API client

This simplifies a lot of code by creating an interface for
the codersdk client into the agent. It also moves agent
authentication code so instance identity will work between
restarts.

Fixes #3485 and #4082.

* Fix client reconnections
2022-10-23 22:35:08 -05:00
Ammar Bandukwala c9bf2a9099 ci: verify that all docs links work (#4710) 2022-10-23 17:09:58 -05:00
Shyim 05f38d6fe9 remove unused yarn file (#4711) 2022-10-23 21:10:16 +00:00
Shyim 2a47efc546 fix service name (#4712) 2022-10-23 21:08:06 +00:00
Kyle Carberry f75a54cd1e feat: Support x-forwarded-for headers for IPs (#4684)
* feat: Support x-forwarded-for headers for IPs

Fixes #4430.

* Fix realip accepting headers

* Fix unused headers
2022-10-23 13:21:49 -05:00
Ammar Bandukwala 795ed3dc97 provisioner: fix multi-dir installs (#4690)
In the previous implementation, tests would occasionally fail since the original install directory was deleted.
2022-10-22 20:44:05 +00:00
Dean Sheather d0fb054a55 fix: improve codersdk error messages when not JSON (#4495) 2022-10-21 23:36:31 +00:00
Kyle Carberry 7bc5b89f7a feat: Support config files with viper (#4696) 2022-10-21 17:08:23 -05:00
Kyle Carberry adc5c1a131 fix: Load template page chunks without blocking (#4689) 2022-10-21 16:56:52 -05:00
Garrett Delfosse e8537067ef Revert "Revert "Revert "feat: Support config files with viper"" (#4693)" (#4695)
This reverts commit 372fb1f345.
2022-10-21 16:07:38 -05:00
Garrett Delfosse 372fb1f345 Revert "Revert "feat: Support config files with viper"" (#4693) 2022-10-21 20:55:20 +00:00
Kyle Carberry d15b4159ef Add import for use translation 2022-10-21 20:35:21 +00:00
Garrett Delfosse a2fb444911 Revert "feat: Support config files with viper (#4558)" (#4692)
This reverts commit c8e299c8f1.
2022-10-21 20:04:27 +00:00
Kyle Carberry 0d27b59ebb feat: Add emoji picker to group settings (#4685)
Fixes #4413.
2022-10-21 19:42:38 +00:00
Garrett Delfosse c8e299c8f1 feat: Support config files with viper (#4558) 2022-10-21 19:26:39 +00:00
Kyle Carberry 2c47cda3d1 fix: Wrap applications if there are a bunch (#4686)
Fixes #4672.
2022-10-21 14:08:08 -05:00
Kyle Carberry 31b61d1bf8 fix: Remove license on Coder Docker image (#4683)
I didn't know what do change it to, but figured removing it
made the most sense. Fixes #3723.
2022-10-21 12:31:10 -05:00
Kyle Carberry 4d8cc7594d fix: Remove extra unicode char from some emojis (#4682)
Fixes #3689.
2022-10-21 17:28:01 +00:00
Eric Paulsen 72288c3685 fix: coder resource template (#4681) 2022-10-21 10:07:05 -05:00
Mathias Fredriksson 173b7a2c83 fix: Start SFTP sessions in user home (working directory) (#4549)
* fix: Start SFTP sessions in user home (working directory)

This commit switches to our fork of `pkg/sftp` which includes a Server
option for changing the current working directory.

Attempt to upstream: https://github.com/pkg/sftp/pull/528

Supercedes and closes #4420

Fixes #3620

* Update fork
2022-10-21 09:54:06 -05:00
Kira Pilot 940201313f chore: remove org_id from audit diffs (#4668)
* chore: remove org_id from audit diffs

* PR feedback

* fix tests
2022-10-21 10:34:24 -04:00
Dean Sheather 47cb9abfc2 feat: support wildcard apps over tunnel (#4602) 2022-10-21 08:09:44 +10:00
Kyle Carberry 43d1f724b1 chore: Implement database limits from v1 (#4669)
Under scale if there wasn't a PostgreSQL connection available,
an error was occurring instead of blocking for a new connection.

This fixes it!
2022-10-20 18:17:05 +00:00
Presley Pizzo 7c238f13e5 feat: paginate workspaces page (#4647)
* Start - still needs api call changes

* Some xservice changes

* Finish adding count to xservice

* Mock out api call on frontend

* Handle errors

* Doctor getWorkspaces

* Add types, start writing count function

* Hook up route

* Use empty page struct

* Write interface and database fake

* SQL query

* Fix params type

* Missed a spot

* Space after alert banner

* Fix model queries

* Unpack query correctly

* Fix filter-page interaction

* Make mobile friendly

* Format

* Test backend

* Fix key

* Delete unnecessary conditional

* Add test helpers

* Use limit constant

* Show widget with no count

* Add test

* Format

* make gen from garretts workspace idk why

* fix authorize test'

* Hide widget with 0 records

* Fix tests

* Format

* Fix types generated

* Fix story

* Add alert banner story

* Format

* Fix import

* Format

* Try removing story

* Revert "Fix story"

This reverts commit c06765b7fb.

* Add counts to page view story

* Revert "Try removing story"

This reverts commit 476019b041.

Co-authored-by: Garrett <garrett@coder.com>
2022-10-20 13:23:14 -04:00
Ammar Bandukwala 423ac04156 coderd: tighten /login rate limiting (#4432)
* coderd: tighten /login rate limit

* coderd: add Bypass rate limit header
2022-10-20 17:01:23 +00:00
Ben Potter 43f199a987 docs: small tweaks to "change management" (#4532) 2022-10-20 15:14:06 +00:00
Steven Masley 369b5d1c2d chore: Add generics to typescript generator (#4664)
* feat: Support generating generics in interfaces
* Switch struct to a template
* Support generics in apitypings
2022-10-20 08:15:24 -05:00
Jon Ayers d0b1c36d51 fix: prevent refreshing tokens that don't exist (#4661)
- When logging in with Google OIDC refresh tokens are not
  provided unless explicitly asked for. This PR updates
  the logic to avoid attempting to refresh the token if
  a refresh token does not exist.

  A session should only be dependent on a valid Coder API
  key, the state of its OAuth token (beyond initial authentication)
  should be irrelevant.
2022-10-20 00:25:57 -05:00
Ben Essex 49787a4924 docs: fix typo in dotfiles.md (#4663) 2022-10-20 04:57:37 +00:00
Ammar Bandukwala 63602bf568 dogfood: upgrade postgres to version 13 (#4657)
* Fix container updating
2022-10-20 03:06:57 +00:00
Ammar Bandukwala fa49ccd058 coderd/metricscache: fix test race (#4662) 2022-10-20 02:36:00 +00:00
Jon Ayers 7a5ae1e552 fix: delete all sessions on password change (#4659)
- Prevent users from reusing their old password
  as their new password.
2022-10-19 21:12:03 -05:00
Ammar Bandukwala ea156cce2e dogfood: upgrade postgres (#4642) 2022-10-19 19:33:26 +00:00
Ali Diamond eb04a7e7a5 feat: adding gcp quickstart (#4348)
* adding gcp tutorial

* refactor(seo): gcp to google cloud platform

* docs(quickstart): add next steps and title

* adding changes and gcp image

* adding ammar changes

Co-authored-by: Ali Diamond <user@ali.dev>
Co-authored-by: Geoffrey Huntley <ghuntley@ghuntley.com>
2022-10-19 13:52:56 -05:00
Ben Potter 75b058a475 chore: fix agent tooltips (#4654) 2022-10-19 11:40:01 -05:00
Eric Paulsen f9480ed576 add: helm binary download cmd (#4526) 2022-10-19 11:39:44 -05:00
Ben Potter df39920fcd fix: remove default namespace in k8s example (#4645) 2022-10-19 16:34:03 +00:00
Ben Potter 487cc0cd74 docker quickstart: mention tunnel + troubleshooting (#4653) 2022-10-19 11:30:27 -05:00
Eric Paulsen fbbecf0846 helm: add sa annotations (#4640)
* helm: add sa annotations

* rm: test annotation

* fix: labels bracket

Co-authored-by: Dean Sheather <dean@deansheather.com>

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-10-19 13:49:48 +00:00
Ammar Bandukwala d49d57ec4b provisioner: don't pass CODER_ variables (#4638) 2022-10-19 09:42:29 -04:00
Ben Potter 12cb4f1eb3 docs: add Caddy+LetsEncrypt TLS example (#4585)
* structure

* docs: add Caddy+LetsEncrypt TLS example
2022-10-19 07:20:11 -05:00
Ben Potter 0727c98313 docs: offline (air-gapped) installs (#4644)
* chore: add docs for offline (air-gapped) installs

* mention postgresql
2022-10-19 06:12:43 -05:00
Jon Ayers 0d1096da6c feat: add auditing for groups (#4527)
- Clean up `database.TemplateACL` implementation.
2022-10-19 02:00:45 -05:00
Ben Potter d4585fefb8 chore: remove bare template (#4629) 2022-10-19 03:47:08 +00:00
Colin Adler 0a5e5544b1 fix: time.NewTicker leaks (#4630) 2022-10-18 15:26:21 -05:00
Bruno Quaresma 5d7d8c3a9a refactor: Update resources to look as a stack (#4631) 2022-10-18 15:52:47 -04:00
Bruno Quaresma 906046c1cc feat: Add minor settings improvements (#4626) 2022-10-18 19:25:52 +00:00
Bruno Quaresma 0d67dfc215 fix: Agent version is only visible when connected (#4619) 2022-10-18 18:19:25 +00:00
Ammar Bandukwala 1984932dc9 coderd/metricscache: attempt to fix macOS race (#4622) 2022-10-18 17:28:40 +00:00
Ben Potter 39498b6531 fix: invalid docs links in "deployment settings" (#4617) 2022-10-18 17:12:06 +00:00
Bruno Quaresma 616fe7a3b1 feat: Redesign resources table (#4600) 2022-10-18 13:44:58 +00:00
Jon Ayers 61683f1961 fix: allow for alternate usernames on conflict (#4614) 2022-10-17 22:07:11 -05:00
Kyle Carberry 3c40698033 chore: Enforce PostgreSQL >=13 (#4612)
* chore: Enforce PostgreSQL >=13

Fixes #4608.

* Fix version string parsing
2022-10-17 20:02:25 -05:00
Eric Paulsen 614e40c0f5 add: postgres version requirement (#4611) 2022-10-18 00:24:49 +00:00
Eric Paulsen d1c537407d fix: install index 404 (#4610) 2022-10-17 19:22:56 -05:00
Colin Adler e95239cfcd fix: agent stats websocket blocking until next interval (#4609) 2022-10-18 00:15:07 +00:00
Kyle Carberry 7851fb1c99 Fix unlock of unlocked mutex in tailnet coordinator 2022-10-17 23:51:41 +00:00
Kyle Carberry 211ffabe39 Fix kill mode stopping the built-in PostgreSQL
This was preventing final cleanups from occurring!
2022-10-17 23:50:29 +00:00
Kyle Carberry c5afaffa7e fix: Tidy up closes for nicer output (#4605)
* fix: Tidy up closes for nicer output

There was a context canceled message that would appear
because of traces, and this was using the wrong close.

I don't think it was causing any specific problems, but
it could make a replica warning appear on restart.

* Fix migration and experimental
2022-10-17 18:36:23 -05:00
Jon Ayers e0a14f68fa feat: add avatar urls to groups (#4525) 2022-10-17 17:46:01 -05:00
Jon Ayers 9b4ab82044 fix: potential deadlock in coordinator (#4598) 2022-10-17 20:46:19 +00:00
Ben Potter 8ab4d26474 chore: add note that HA is experimental (#4601) 2022-10-17 20:14:27 +00:00
Ammar Bandukwala 8acba0ccff site: cleanup code in WorkspaceBuildProgress (#4584) 2022-10-17 16:45:06 -03:00
Kyle Carberry 6f5544e0e4 fix: Pass experimental to the FE through the API (#4597) 2022-10-17 19:44:04 +00:00
Kyle Carberry 4e44716b0c docs: add high availability (#4583)
- Rename `CODER_DERP_SERVER_RELAY_ADDRESS`

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>
2022-10-17 14:27:38 -05:00
Kyle Carberry fda71dadcb fix: Copy replicas to prevent race (#4596)
This was seen in https://github.com/coder/coder/actions/runs/3267638198/jobs/5373066836
2022-10-17 19:22:54 +00:00
Kyle Carberry 618c6dcaa4 fix: Allow OIDC with the username as email (#4594)
Fixes #4472.
2022-10-17 14:14:49 -05:00
Ammar Bandukwala ae9d7f6b4c coderd: fix race condition in template test 2022-10-17 19:12:21 +00:00
Kyle Carberry 18c4368571 chore: Move deployment UI and HA into experimental (#4595)
These are new, so they deserve a bit of gel-time!
2022-10-17 18:29:40 +00:00
Kyle Carberry 5325bec26c fix: Add timeout to selecting a dev tunnel (#4592)
For some reason this timed out for a prospect. Even if this
doesn't fix it, the problem will be revealed.
2022-10-17 18:03:17 +00:00
dependabot[bot] 4895e011df chore: bump go.opentelemetry.io/otel from 1.10.0 to 1.11.0 (#4582)
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.10.0 to 1.11.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.10.0...v1.11.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-17 12:23:26 -05:00
Kyle Carberry 6b1b3a2037 feat: Add deployment settings page (#4590)
* Add base components for the Settings Page

* WIP OIDC page

* Imrove layout

* Add table

* Abstract option

* Refactor badges

* Load settings from the API

* Update deployment page

* feat: Add deployment settings page

This allows deployment admins to view options
set on their deployments.

* Format

* Remove replicas table since it's not used

* Remove references to HA table

* Fix tests

* Improve language

Co-authored-by: Bruno Quaresma <bruno@coder.com>
2022-10-17 12:22:59 -05:00
Colin Adler 9b5d627a55 fix(tailnet): data race in coordinator.Close() (#4589) 2022-10-17 11:47:45 -05:00
Colin Adler 29acd25b4e fix: chrome requests hanging over port-forward (#4588) 2022-10-17 11:45:29 -05:00
Kyle Carberry d2ee18c14f fix: Don't check for existing replicas when starting up (#4587)
This was blocking startup, creating a chicken and egg problem where
if a replica died, a single one couldn't be bootstrapped again.
2022-10-17 15:27:28 +00:00
Kyle Carberry 2ba4a62a0d feat: Add high availability for multiple replicas (#4555)
* feat: HA tailnet coordinator

* fixup! feat: HA tailnet coordinator

* fixup! feat: HA tailnet coordinator

* remove printlns

* close all connections on coordinator

* impelement high availability feature

* fixup! impelement high availability feature

* fixup! impelement high availability feature

* fixup! impelement high availability feature

* fixup! impelement high availability feature

* Add replicas

* Add DERP meshing to arbitrary addresses

* Move packages to highavailability folder

* Move coordinator to high availability package

* Add flags for HA

* Rename to replicasync

* Denest packages for replicas

* Add test for multiple replicas

* Fix coordination test

* Add HA to the helm chart

* Rename function pointer

* Add warnings for HA

* Add the ability to block endpoints

* Add flag to disable P2P connections

* Wow, I made the tests pass

* Add replicas endpoint

* Ensure close kills replica

* Update sql

* Add database latency to high availability

* Pipe TLS to DERP mesh

* Fix DERP mesh with TLS

* Add tests for TLS

* Fix replica sync TLS

* Fix RootCA for replica meshing

* Remove ID from replicasync

* Fix getting certificates for meshing

* Remove excessive locking

* Fix linting

* Store mesh key in the database

* Fix replica key for tests

* Fix types gen

* Fix unlocking unlocked

* Fix race in tests

* Update enterprise/derpmesh/derpmesh.go

Co-authored-by: Colin Adler <colin1adler@gmail.com>

* Rename to syncReplicas

* Reuse http client

* Delete old replicas on a CRON

* Fix race condition in connection tests

* Fix linting

* Fix nil type

* Move pubsub to in-memory for twenty test

* Add comment for configuration tweaking

* Fix leak with transport

* Fix close leak in derpmesh

* Fix race when creating server

* Remove handler update

* Skip test on Windows

* Fix DERP mesh test

* Wrap HTTP handler replacement in mutex

* Fix error message for relay

* Fix API handler for normal tests

* Fix speedtest

* Fix replica resend

* Fix derpmesh send

* Ping async

* Increase wait time of template version jobd

* Fix race when closing replica sync

* Add name to client

* Log the derpmap being used

* Don't connect if DERP is empty

* Improve agent coordinator logging

* Fix lock in coordinator

* Fix relay addr

* Fix race when updating durations

* Fix client publish race

* Run pubsub loop in a queue

* Store agent nodes in order

* Fix coordinator locking

* Check for closed pipe

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-10-17 13:43:30 +00:00
Ammar Bandukwala dc3519e973 Support all transitions in build progress bar (#4575)
* Use null types instead of -1 for simplicity

* Fix pgcrypto bug in migration 59

* Add stories

* Fix visual stutter
2022-10-16 23:34:03 -05:00
Phorcys ee2c29d520 Rename the noVNC icon to match the other icons (#4574) 2022-10-16 19:37:02 -05:00
unknowndevQwQ efdd5d5a0c feat: add doas support (#4531)
* feat: add doas support

Some people may have some reason to drop sudo and switch to doas

* chore: doas at the end

Just because it is relatively cold :-(

Co-authored-by: Kyle Carberry <kyle@carberry.com>

* chore(CI): add doas to pass CI

* fix syntax error

Co-authored-by: Kyle Carberry <kyle@carberry.com>
Co-authored-by: Ben <me@bpmct.net>
2022-10-16 02:18:30 +00:00
Ammar Bandukwala de5ba47557 site: minor build stats fixes (#4569)
- Correct variable used in the template stats summary
- Don't use dayjs.humanize (it thinks 30 seconds is "a few seconds")
2022-10-15 21:30:51 +00:00
Ammar Bandukwala e456799f1a Add template build time stats (#4557)
- Expose time in Template pages
- Show progress bar when building a workspace
2022-10-15 20:36:50 +00:00
Ben Potter 5b7d204b9d chore: fix tooltip behavior (#4563) 2022-10-15 13:04:52 +00:00
Dean Sheather 1515d755e1 feat: add app sharing icon and tooltip (#4556)
Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-10-14 21:49:24 +00:00
Colin Adler 7ec88bf841 feat: audit git ssh key regeneration (#4544) 2022-10-14 16:25:46 -05:00
Kira Pilot dd8ebf10db fix: duplicate workspace update entries (#4513)
* fix: duplicate workspace update entries

* remove console log

* attempting to fix tests

* keep diffs with 0 changes

* cleaned up test
2022-10-14 14:39:20 -04:00
Dean Sheather a029817d3d feat: allow suffix after wildcard in wildcard access URL (#4524) 2022-10-14 18:25:11 +00:00
Presley Pizzo ccc008eb5e fix: redesign schedule bumper to handle multiple hours of change at once (#4535)
* Start sketching out new design

* Working but ugly

* Highlight chosen mode

* Format

* Set hours field width

* Alignment on desktop

* Use primary button color

* Make 1 the default change

* Add stepper max

* Fix storybook

* Handle undefined deadline

* Access deadline correctly

* Format

* Fix overflow on mobile
2022-10-14 13:23:00 -04:00
Dean Sheather d898737d6d feat: app sharing (now open source!) (#4378) 2022-10-15 02:46:38 +10:00
Mathias Fredriksson 19d7281daf fix: Fix template create with sub-folders on Windows (#4548)
On Windows, files in tar archives were stored with Windows
path-separators resulting in them being individual files as opposed to
contained in a folder.

This commit ensures Unix-based paths (slash) are being used inside tar
archives.

Exmple of previous output:

```
/tmp/provisionerd673501182/images:
/tmp/provisionerd673501182/:
README.md
images
images\base.Dockerfile
images\java.Dockerfile
images\node.Dockerfile
main.tf
```

Fixes #2815
2022-10-14 19:28:47 +03:00
Joe Previte 88f7505fdf feat: upgrade prettier and add --cache (#4543)
This uses the `--cache` flag with `prettier --check` to cache the
results and speed up subsequent runs.
2022-10-14 12:22:07 -04:00
Kira Pilot bf0aca35fa fix: ensure deleting workspace creates audit log (#4537)
* fix: ensure deleting workspace creates audit log

* getting rid of comments

* remove whitespace

* pushing failing test

* fixed test
2022-10-14 09:47:38 -04:00
Joe Previte b1409831a3 refactor: clean up api/error.ts (#4542)
This removes an eslint-disable lint and updates the `err` type to
`unknown` instead of `any` which is more correct.
2022-10-14 09:09:09 -03:00
Joe Previte 94db085b51 chore(site): remove some eslint-disables (#4265)
* fix: await promises in WorkspacePage.test.tsx

* chore: add eventsourcemock to cspell words

* fix: clean up UsersPage.test.tsx

* refactor: clean up eventsource mock

* revert: remove changes from WorkspacePage.test.tsx
2022-10-13 18:09:04 -05:00
Jon Ayers 4e57b9fbdc fix: allow regular users to push files (#4500)
- As part of merging support for Template RBAC
  and user groups a permission check on reading files
  was relaxed.

  With the addition of admin roles on individual templates, regular
  users are now able to push template versions if they have
  inherited the 'admin' role for a template. In order to do so
  they need to be able to create and read their own files. Since
  collisions on hash in the past were ignored, this means that a regular user
  who pushes a template version with a file hash that collides with
  an existing hash will not be able to read the file (since it belongs to
  another user).

  This commit fixes the underlying problem which was that
  the files table had a primary key on the 'hash' column.
  This was not a problem at the time because only template
  admins and other users with similar elevated roles were
  able to read all files regardless of ownership. To fix this
  a new column and primary key 'id' has been introduced to the files
  table. The unique constraint has been updated to be hash+created_by.
  Tables (provisioner_jobs) that referenced files.hash have been updated
  to reference files.id. Relevant API endpoints have also been updated.
2022-10-13 18:02:52 -05:00
Colin Adler a55186cd02 fix(database): remove usage of String() for comparing UUIDs (#4547) 2022-10-13 22:38:30 +00:00
Kira Pilot 9c0cc65973 fix: removing unsupported resources from audit log documentation (#4540) 2022-10-13 16:59:27 -04:00
Garrett Delfosse 459ee4e66a feat: add pagination to getWorkspaces (#4521) 2022-10-13 12:41:13 -04:00
Kyle Carberry 574e5d37c7 fix: Remove case sensitivity check in OIDC email domain (#4534)
Fixes #4533.
2022-10-13 15:51:54 +00:00
Kyle Carberry 0d0ea981da fix: Filter by deleted when querying workspaces (#4512)
Fixes #4508.
2022-10-12 14:53:03 -05:00
Jon Ayers 0fa8f528c2 chore: change view perm to use (#4496) 2022-10-12 14:33:21 -05:00
Jon Ayers 47805643f7 fix: allow user admins to manage groups (#4498) 2022-10-12 14:33:03 -05:00
Ben Potter 2a1bfb3e44 docs: API tokens & CI automation (#4510)
* reword: chore: add CI to dogfood template

* use hardcoded URL

* use consistent name for tokens

* chore: add docs for template change management

* add an example

* fix case
2022-10-12 15:43:59 +00:00
Dean Sheather abf14d976a chore: rename feature rbac to template_rbac (#4486)
* chore: rename feature rbac to template_rbac

* Fix feature visibility on FE

* fixup! Fix feature visibility on FE

Co-authored-by: Bruno Quaresma <bruno@coder.com>
2022-10-11 13:51:41 -05:00
Garrett Delfosse 0f3221f9d0 fix: use more descriptive login flags (#4493) 2022-10-11 18:45:30 +00:00
Bruno Quaresma c13e68248b docs: Add initial docs to groups and rbac (#4455)
* docs: Add initial docs to groups and rbac

* Update manifest

* Apply suggestions from code review

Co-authored-by: Joe Previte <jjprevite@gmail.com>

* use single user icon

* chore: add labels and standardize enterprise messaging

* clarify template role

* add groups role

* fix typo

* rename access to use

Co-authored-by: Joe Previte <jjprevite@gmail.com>
Co-authored-by: Ben <me@bpmct.net>
2022-10-11 13:34:41 -05:00
Kyle Carberry 9dcbe753f4 chore: Update docs for secretNames TLS change (#4469)
This was changed but the docs didn't reflect it.
2022-10-11 13:21:04 -05:00
Ben Potter cc1602ad78 fix: enterprise link for groups (#4491) 2022-10-11 18:19:19 +00:00
Bruno Quaresma c619138ece fix: Display Everyone group in the autocomplete (#4488) 2022-10-11 13:17:19 -05:00
Presley Pizzo 62357084ba feat: filter for running workspaces (#4157)
* Refactor workspaces xservice

* Remove layout comment

* Format

* Add comments

* Add running workspaces filter to frontend

* Start on backend - add status to filter

* Update sql and add test - wip

* Attempt to unconvert status for easier querying

* Fix syntax

* Join jobs table, untested

* sql

* Add Status to GetAuthorizedWorkspaces

* Update job tests to have canceled time

* fmt

* add status filter to database fake

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-10-11 13:50:41 -04:00
Bruno Quaresma aefb477e21 refactor: Add description to the roles options (#4480) 2022-10-11 14:08:13 -03:00
Ben Potter 443173c071 fix: delete random file (#4481) 2022-10-11 11:08:13 -05:00
Garrett Delfosse 3cb2d52a08 fix: issue with token auth (#4483) 2022-10-11 15:58:28 +00:00
Garrett Delfosse a70278e0e1 feat: make flags in one place (#4452) 2022-10-11 15:16:19 +00:00
Dean Sheather b1a095e486 feat: show listening ports in port forward popup (#4389)
* feat: show listening ports in port forward popup

* Move fetch logic to a machine

* feat: don't show  app ports and common non-HTTP ports

Co-authored-by: Bruno Quaresma <bruno@coder.com>
2022-10-12 01:10:02 +10:00
Bruno Quaresma a64731eea5 refactor: Add group badge to diff groups from users (#4478) 2022-10-11 14:39:03 +00:00
Bruno Quaresma 934777d9ca refactor: Add enterprise badge to paywalls (#4477) 2022-10-11 11:27:33 -03:00
Eric Paulsen 5411abb9c1 fix: PVC volume binding mode (#4471) 2022-10-10 22:05:54 -05:00
Kyle Carberry b402c6aba8 fix: Use lower function in default Kubernetes template (#4468)
Fixes #4467.
2022-10-10 21:16:06 -05:00
Joe Previte 8047a3ea61 refactor(site): remove eslint-disable in ResourceAvatar (#4463) 2022-10-10 18:23:23 -07:00
Geoffrey Huntley cf999f3e28 docs(contributing): styleguide for authoring docs (#4355) 2022-10-10 23:33:25 +00:00
Geoffrey Huntley 704840c04e chore(cla): implement coder.com/cla (#4354) 2022-10-10 17:49:03 -05:00
Ben Potter 5ca17c3f63 feat: add ingress to helm chart (#4446)
* feat: add ingress to helm chart

* chore: multiple hostname support in ingress

* fixup! chore: multiple hostname support in ingress

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-10-10 21:57:24 +00:00
Jon Ayers 3120c94c22 feat: add template RBAC/groups (#4235) 2022-10-10 15:37:06 -05:00
Garrett Delfosse 2687e3db49 fix: bug with CODER_OAUTH2_GITHUB_ALLOW_SIGNUPS (#4451) 2022-10-10 16:19:37 -04:00
Garrett Delfosse d22996ea20 fix: bug with TLS Client auth flag (#4450) 2022-10-11 05:26:27 +10:00
Ben Potter 6bc03907bd chore: add git token management to enterprise roadmap (#4447) 2022-10-10 14:06:36 -05:00
Garrett Delfosse b1faaef482 feat: deployment flags (#4426) 2022-10-10 15:04:15 -04:00
Kyle Carberry b50bb99fe7 fix: Check if the response body is nil before panicing (#4448)
If a WebSocket connection couldn't be established, a panic would occur.
2022-10-10 18:45:03 +00:00
Kyle Carberry daa34cf7b8 fix: Return deleted users when fetching workspace builds (#4441)
Fixes #4359.
2022-10-10 18:03:54 +00:00
Ammar Bandukwala 85c679597c site: reduce printWidth to 80 (#4437)
Resolves #4435
2022-10-10 10:33:35 -07:00
Ammar Bandukwala cb54986d3f docs: fix bullet points in kubernetes.md (#4445) 2022-10-10 17:21:32 +00:00
Bruno Quaresma 5e594adfba refactor: Display tooltip on cancel action (#4421) 2022-10-10 12:34:09 -03:00
Ammar Bandukwala eefc26c108 Hide build logs older than 30 days (#4436) 2022-10-09 20:01:18 +00:00
Andrei Kondratiev dd5173b45c fix: apply loadBalancerIP and externalTrafficPolicy values in helm chart (#4427) 2022-10-08 21:15:56 +00:00
Ammar Bandukwala c01910fb75 docs: use enterprise badges (#4428) 2022-10-07 23:44:41 -05:00
Colin Adler 0ad8e775a5 fix(ci): use correct retention-days in e2e (#4424) 2022-10-07 13:46:16 -05:00
Mathias Fredriksson 3ad27b547f chore: Rename context in cli/agent (#4422)
Rename context from common `ctx` to `retryCtx` to avoid later re-use.

Also kind of a bug-fix since client post was using `cmd.Context()`.
2022-10-07 18:06:20 +00:00
Bruno Quaresma 50966c4cf7 fix: Fix keyboard focus styles on buttons (#4418) 2022-10-07 14:39:39 -03:00
Bruno Quaresma 34f799257c refactor: Remove user roles from dropdown (#4419) 2022-10-07 14:17:56 -03:00
Kira Pilot 257df81667 chore: replace old ErrorSummary component (#4417)
* replaced error summary

* fixed tests

* positioning caret
2022-10-07 13:14:32 -04:00
Joe Previte 2b6586d542 chore: add ignoreRestSiblings to no-unused-vars ESLint rule (#4404)
* chore: add ignoreRestSiblings to eslint config

* fix(site): remove eslint warning in <Markdown />
2022-10-07 09:55:27 -07:00
Mathias Fredriksson adcf8838d2 fix: Ensure GitHub OAuth2 users are active in organization (#4416) 2022-10-07 19:53:58 +03:00
Kira Pilot e8e095e2f8 feat: redesign error alert (#4403)
* added a warning summary component

* added warning to workspace page

* consolidated warnings

* prettier

* updated design

* added color scheme

* updated expander component

* cleanup

* fixed tests

* fixed height issue

* prettier

* use theme constants

* increased icon margin
2022-10-07 10:39:27 -04:00
Kyle Carberry 3cc77d96eb feat: Add tunnel by default (#4399)
* feat: Add tunnel by default

If an access URL is not specified, we will always tunnel.

This is from community-member feedback who exclaimed that
it's confusing having the default for `coder server` display
a warning message, and I agree.

There is very little (maybe none) in running `coder server`
without tunnel and without an access URL, so this seems like
overall a much better UX.

* Update install.sh

Co-authored-by: Ben Potter <ben@coder.com>

* Update docs/install/packages.md

Co-authored-by: Ben Potter <ben@coder.com>

* Fix reset pass test

* Fix e2e test

Co-authored-by: Ben Potter <ben@coder.com>
2022-10-07 08:05:56 -05:00
Kyle Carberry 3049a56355 fix: Use the maximum number of users for a license warning (#4410)
This was causing a banner on dev.coder.com. But now we have a test!
2022-10-06 20:59:25 -05:00
Kyle Carberry 915bb41ea2 feat: Add trial property to licenses (#4372)
* feat: Add trial property to licenses

This allows the frontend to display whether the user is on
a trial license of Coder. This is useful for advertising
Enterprise functionality.

* Improve tests for license enablement code

* Add all features property
2022-10-06 19:28:22 -05:00
Timo 05670d133e fix: Spelling in audit log docs (#4384) 2022-10-06 22:13:25 +00:00
Garrett Delfosse 32bb1e7ce9 fix: add back missing postAPIKey route (#4406) 2022-10-06 17:56:43 -04:00
Garrett Delfosse a89d6909b2 fix: show help on wraper commands (#4402) 2022-10-06 20:15:28 +00:00
Garrett Delfosse f5df54831a feat: tokens (#4380) 2022-10-06 19:02:27 +00:00
Kyle Carberry fe7c9f8ec1 chore: Stop building images on tag pushes (#4397)
This was causing a red X on releases!
2022-10-06 15:39:53 +00:00
Kyle Carberry 9cf3e102ba chore: Pin typos to fix CI (#4396) 2022-10-06 10:27:23 -05:00
Dean Sheather 3b15f13ae4 fix: fix apps being unavailable until rebuild (#4395) 2022-10-06 10:23:55 -05:00
Kyle Carberry 9b1ff43e9f fix: Don't run CI for releases (#4393)
This was unnecessary and causing weird issues like double deploys and runs.
2022-10-06 10:02:37 -05:00
Ben Potter ea42212a2a chore: add icons to quickstarts (#4379) 2022-10-06 10:56:46 -04:00
Kyle Carberry 0ebcb7de55 fix: Remove reliance of relative_path on subdomains (#4390)
This broke all relative path applications.
2022-10-06 09:30:10 -05:00
Kyle Carberry d275331c13 fix: Remove audit warning if unlicensed (#4387)
Fixes #4383.
2022-10-06 08:48:44 -05:00
Dean Sheather 29a2fe46e8 fix: fix builds on windows_arm64 (#4388) 2022-10-06 23:42:58 +10:00
Mathias Fredriksson 93b8121c9b fix: Change use of 1337 to 13337 in example templates (#4386) 2022-10-06 13:25:18 +00:00
Dean Sheather 1386465631 feat: add endpoint to get listening ports in agent (#4260) 2022-10-06 22:38:22 +10:00
Kyle Carberry bbe2baf3f6 fix: Ignore all hidden files and folders in archive (#4382)
This also adds a suite of tests to ensure this cannot happen again!
2022-10-06 00:36:45 +00:00
Kira Pilot 3ad5e11d22 feat: add warning if workspace page becomes stale (#4375)
* added a warning summary component

* added warning to workspace page

* consolidated warnings

* prettier

* updated design
2022-10-05 18:46:46 -04:00
Presley Pizzo 9a670b90df chore: refactor frontend to use workspace status directly (#4361)
* Add/update copy

* Update mocks

* Handle disabled button labels separately

* Use workspace status directly, use i18n

* Update stories and tests

* Fix optimistic update in xservice to use status, pending

* Rename started to running in story

* Fix deletion banner conditional

* Send label to disabled button

* Refactor workspace actions
2022-10-05 16:20:29 -04:00
Dean Sheather 2a66395fb7 feat: use app wildcards for apps if configured (#4263)
* feat: use app wildcards for apps if configured

* feat: relative_path -> subdomain

- rename relative_path -> subdomain when referring to apps
    - migrate workspace_apps.relative_path to workspace_apps.subdomain
- upgrade coder/coder terraform module to 0.5.0
2022-10-05 19:23:01 +00:00
Ammar Bandukwala 4f3958c831 docs: link all enterprise features (#4368) 2022-10-05 15:05:28 -04:00
Garrett Delfosse b65c555dfc fix: warn user if not entitled feature is enabled (#4377) 2022-10-05 17:45:05 +00:00
Garrett Delfosse 8d14076a23 fix: move quotas above inputs (#4376) 2022-10-05 13:44:15 -04:00
Muhammad Atif Ali 3759bb2a9a docs: fixed a typo (#4374) 2022-10-05 09:50:56 -05:00
Kyle Carberry 504cd462a7 fix: Check for a response body when dialing the Tailnet WebSocket (#4327)
There was a panic in this code that caused it to fail on error!
2022-10-04 19:46:59 -05:00
Kyle Carberry 8940ea179e fix: Always set DisconnectedAt if the agent isn't connected (#4328)
Fixes #4315.
2022-10-05 00:28:47 +00:00
Steven Masley 587017665a feat: Also log out of apps if they are hosted on the same domain (#4334)
* feat: Also log out of apps if they are hosted on the same domain

* Update comment
2022-10-04 19:01:16 -04:00
Kyle Carberry 06d7e368ab fix: Ignore hidden folders when archiving (#4370)
Fixes #4369.
2022-10-04 22:27:14 +00:00
Kyle Carberry f2952000d9 fix: Ensure WebSockets routinely transfer data (#4367)
Fixes #4351.
2022-10-04 17:10:58 -05:00
Ammar Bandukwala a6bb3b29d0 docs: add quotas (#4366) 2022-10-04 20:55:43 +00:00
Ammar Bandukwala db7030716d docs: add minor quickstart fixups (#4363)
- And fix Telemetry in manifest.json
2022-10-04 14:57:06 -05:00
Kyle Carberry 45c05a0896 Fix additional .md on port-forwarding docs 2022-10-04 19:52:30 +00:00
Garrett Delfosse ffbaa93722 feat: add experimental flag (#4364) 2022-10-04 19:45:00 +00:00
Geoffrey Huntley 18b282cabb docs(quickstart): styling fixes (#4356) 2022-10-05 03:16:21 +10:00
Joe Previte 78283cf236 fix: add keys to createCtas elements (#4362) 2022-10-04 16:50:15 +00:00
Dean Sheather d165d76338 feat: static error page in applications handlers (#4299) 2022-10-05 02:30:55 +10:00
Joe Previte ce953441fb refactor: clean up types in jest.setup.ts (#4285) 2022-10-04 09:04:23 -07:00
Steven Masley cd4ab97efa feat: Convert rego queries into SQL clauses (#4225)
* feat: Convert rego queries into SQL clauses

* Fix postgres quotes to single quotes

* Ensure all test cases can compile into SQL clauses

* Do not export extra types

* Add custom query with rbac filter

* First draft of a custom authorized db call

* Add comments + tests

* Support better regex style matching for variables

* Handle jsonb arrays

* Remove auth call on workspaces

* Fix PG endpoints test

* Match psql implementation

* Add some comments

* Remove unused argument

* Add query name for tracking

* Handle nested types

This solves it without proper types in our AST.
Might bite the bullet and implement some better types

* Add comment

* Renaming function call to GetAuthorizedWorkspaces
2022-10-04 11:35:33 -04:00
Dean Sheather 6325a9ea91 feat: support multiple certificates in coder server and helm (#4150) 2022-10-04 21:45:21 +10:00
Ammar Bandukwala a1056bfa2a docs: describe our telemetry (#2641) 2022-10-04 04:03:46 +00:00
Bruno Quaresma bf63cc929a fix: Fix audit search query (#4352) 2022-10-03 20:56:54 -03:00
Ali Diamond 1d88b9c65c Add AWS and Azure quickstarts (#4176)
* Creating Azure QS and adding images

* adding AWS images and QS, plus fix on azure

* adding ben changes

* adding ammar changes

* adding ammar and ben edits

* pushing final changes to AWS

* removed troubleshooting

* fixing access word

* ammar pls

Co-authored-by: Ali Diamond <user@ali.dev>
2022-10-03 17:15:52 -04:00
Garrett Delfosse 738a38d71f chore: remove resources calls (#4344) 2022-10-03 21:01:13 +00:00
Kyle Carberry 9bc0d06aa0 fix: Install Terraform once and only log >=500 (#4339)
Fixes #4302.
2022-10-03 15:19:02 -05:00
Eric Paulsen aa3812ff4e add: deployment annotations (#4342) 2022-10-03 13:31:34 -05:00
Bruno Quaresma 15d7b78527 fix: Handle invalid resource types and actions (#4341)
* fix: Handle invalid resource types and actions

* Return all values if invalid

* Use types
2022-10-03 15:29:01 -03:00
dependabot[bot] cb62e16b41 chore: bump react-router-dom from 6.3.0 to 6.4.1 in /site (#4300)
Bumps [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) from 6.3.0 to 6.4.1.
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router-dom@6.4.1/packages/react-router-dom)

---
updated-dependencies:
- dependency-name: react-router-dom
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 12:30:28 -05:00
Kyle Carberry 46f194e7f1 fix: Output help on license subcommand (#4338)
Fixes #4314.
2022-10-03 12:30:18 -05:00
Steven Masley 0a95ba62b1 chore: Deprecate old cookie value (#4336)
Older clis will need to be updated.
Modern clis cannot communicate with <8.15 coderd
2022-10-03 13:04:22 -04:00
Kyle Carberry 4f6355506c fix: Remove "Starts at Manual" label (#4179)
Fixes #2798.
2022-10-03 17:03:11 +00:00
Kyle Carberry df2649ed2a fix: Test flake in TestWorkspaceStatus (#4333)
This also changes the status to be on the workspace build, since
that's where the true value is calculated. This exposed a bug where
jobs could never enter the canceled state unless fetched by a
provisioner daemon, which was nice to fix!

See: https://github.com/coder/coder/actions/runs/3175304200/jobs/5173479506
2022-10-03 11:43:11 -05:00
Steven Masley d11d83cc98 chore: Template-admin cannot create/update/delete workspaces (#4329)
This perm was changed to only be able to read workspaces
2022-10-03 11:20:13 -05:00
dependabot[bot] bbebc1a86a chore: bump @typescript-eslint/parser from 5.36.2 to 5.38.1 in /site (#4325)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.36.2 to 5.38.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.38.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 10:58:42 -04:00
Mathias Fredriksson 74cd31bdb1 Revert "refactor(ci): conditionally run jobs based on file changes (#4242)" (#4321)
This reverts commit f9b7588963.
2022-10-03 09:51:31 -05:00
Kyle Carberry 88d49dbcab fix: Add isFirst check before err check (#4326)
This was causing TestBlockNonBrowser to hang and fail.
2022-10-03 09:51:20 -05:00
Bruno Quaresma c7aea2fc42 feat: Add static error page (#4276) 2022-10-03 14:42:11 +00:00
dependabot[bot] 087a7defde chore: bump eslint-plugin-unicorn from 43.0.2 to 44.0.0 in /site (#4324)
Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 43.0.2 to 44.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v43.0.2...v44.0.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-unicorn
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 14:40:23 +00:00
dependabot[bot] 951343aa06 chore: bump cloud.google.com/go/compute from 1.9.0 to 1.10.0 (#4291)
Bumps [cloud.google.com/go/compute](https://github.com/googleapis/google-cloud-go) from 1.9.0 to 1.10.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/pubsub/v1.9.0...pubsub/v1.10.0)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/compute
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:25:28 -05:00
dependabot[bot] 2c74d974ca chore: bump github.com/jedib0t/go-pretty/v6 from 6.3.5 to 6.4.0 (#4323)
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.3.5 to 6.4.0.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.3.5...v6.4.0)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 14:21:04 +00:00
dependabot[bot] 132a788c54 chore: bump @typescript-eslint/eslint-plugin in /site (#4298)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.36.1 to 5.38.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.38.1/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:13:38 -05:00
dependabot[bot] f2051218ee chore: bump @playwright/test from 1.25.1 to 1.26.1 in /site (#4297)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.25.1 to 1.26.1.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.25.1...v1.26.1)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:13:31 -05:00
dependabot[bot] fc1536daab chore: bump actions/stale from 5.0.0 to 6.0.0 (#4289)
Bumps [actions/stale](https://github.com/actions/stale) from 5.0.0 to 6.0.0.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v5.0.0...v6.0.0)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:46 -05:00
dependabot[bot] bf0d530e78 chore: bump tj-actions/branch-names from 5.4 to 6.1 (#4290)
Bumps [tj-actions/branch-names](https://github.com/tj-actions/branch-names) from 5.4 to 6.1.
- [Release notes](https://github.com/tj-actions/branch-names/releases)
- [Changelog](https://github.com/tj-actions/branch-names/blob/main/HISTORY.md)
- [Commits](https://github.com/tj-actions/branch-names/compare/v5.4...v6.1)

---
updated-dependencies:
- dependency-name: tj-actions/branch-names
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:41 -05:00
dependabot[bot] 093e3bb3d7 chore: bump github.com/gohugoio/hugo from 0.101.0 to 0.104.2 (#4292)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.101.0 to 0.104.2.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/hugoreleaser.toml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.101.0...v0.104.2)

---
updated-dependencies:
- dependency-name: github.com/gohugoio/hugo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:23 -05:00
dependabot[bot] f077e14b38 chore: bump google.golang.org/api from 0.95.0 to 0.98.0 (#4293)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.95.0 to 0.98.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.95.0...v0.98.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:17 -05:00
dependabot[bot] 6c0552a5d4 chore: bump chart.js from 3.5.0 to 3.9.1 in /site (#4294)
Bumps [chart.js](https://github.com/chartjs/Chart.js) from 3.5.0 to 3.9.1.
- [Release notes](https://github.com/chartjs/Chart.js/releases)
- [Commits](https://github.com/chartjs/Chart.js/compare/v3.5.0...v3.9.1)

---
updated-dependencies:
- dependency-name: chart.js
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:11 -05:00
dependabot[bot] 9104a067d6 chore: bump eslint from 8.23.0 to 8.24.0 in /site (#4295)
Bumps [eslint](https://github.com/eslint/eslint) from 8.23.0 to 8.24.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.23.0...v8.24.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:04 -05:00
Mathias Fredriksson 00d0620679 fix: Fix err check in DialWorkspaceAgentTailnet (#4320) 2022-10-03 16:53:11 +03:00
Ammar Bandukwala 78a39a809d examples: support both localhost and 127.0.0.1 in Docker examples (#4306)
And some minor fixes
2022-10-03 08:31:12 -05:00
Mathias Fredriksson 092a22f242 feat: Support for comma-separation and ranges in port-forward (#4166)
Fixes #3766
2022-10-03 11:58:43 +03:00
Steven Masley 4919975f13 chore: Remove template-admin can create/update/delete workspaces (#4280)
Cannot crud someone else's workspace
2022-10-02 18:54:57 -04:00
dependabot[bot] 3ab8d57630 chore: bump chromatic from 6.9.0 to 6.10.1 in /site (#4296)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.9.0 to 6.10.1.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.9.0...v6.10.1)

---
updated-dependencies:
- dependency-name: chromatic
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-01 11:49:19 -03:00
Presley Pizzo d931b2c10d chore: refactor schedule banner (#4274)
* Start refactor

* Fix color of auto stop switch

* Format

* Use helper functions for min/max check

* Fix type

* Put new component in own file

* Fix decrease deadline bug

* Simplify functions

* Use ChooseOne

* Remove commented code
2022-09-30 17:39:14 -04:00
Garrett Delfosse 139bc6f58b chore: derive workspace status on backend (#4284) 2022-09-30 17:36:21 -04:00
Steven Masley d8008de77a chore: Optimize Filter() for small lists (#4282) 2022-09-30 15:55:08 -04:00
Garrett Delfosse 69c73b2d28 feat: workspace quotas (#4184) 2022-09-30 14:01:20 -04:00
Joe Previte f9b7588963 refactor(ci): conditionally run jobs based on file changes (#4242)
* refactor(ci): only run ts jobs on ts changes

This modifies the `style-lint-typescript` and `test-js` jobs to only run
when there are changes in `site`.

* refactor(ci): only run lint-shellcheck on sh changes

* refactor(ci): only run go jobs on go changes

* refactor(ci): only run style-fmt when needed

This adds a new item to `changes` for `**.tf` changes. Now it will only
run `style-fmt` if PR includes changes to `site/**`, `**.tf`, or
`**.ts`.

* refactor(ci): run e2e on go, ts or tf changes

* refactor(ci): run gen on gen changes

* refactor(ci): delete old comments

* fixup: try moving if step inside test-go job

* fixup: try if all steps

* fixup!: refactor(ci): run gen on gen changes

* Revert "refactor(ci): run gen on gen changes"

This reverts commit d0a5ba1c4b.
2022-09-30 09:34:55 -07:00
Kira Pilot c9bedc5e58 Feat: add showAvatar option to User Autocomplete (#4269)
* added avatar

* remove commented code
2022-09-30 09:50:36 -04:00
Bruno Quaresma 8c4de49359 chore: Remove unused deps (#4273) 2022-09-30 10:37:23 -03:00
Ammar Bandukwala 4b540b7c42 docs: simplify Docker quickstart (#4257) 2022-09-29 17:55:15 -05:00
Bruno Quaresma e49ef68ebc chore: Add XState inspector back (#4268) 2022-09-29 18:29:24 -03:00
Bruno Quaresma 1755e97748 chore: Remove webpack (#4270) 2022-09-29 18:28:44 -03:00
Kyle Carberry d9a61dd4c8 fix: Don't generate files for deploy (#4245)
This should fix a common race we've been seeing!
2022-09-29 13:54:04 -05:00
Kira Pilot 776f287685 feat: allow admins to create workspaces for other users in UI (#4247)
* added permission for creating a workspace on behalf of a user

* committing stashed files

* hooked up autocomplete for users

* added label

* added translations

* wrote test

* added inputMargin prop

* fixed permissions

* added inputSTyle prop

* ran prettier

* fix lint
2022-09-29 14:32:38 -04:00
Joe Previte 70d7dd9b2f docs: fix port forward link (#4252) 2022-09-29 11:04:13 -07:00
Cian Johnston e6f568fcac refactor: cli: address comments from #4240 (#4259) 2022-09-29 11:04:37 +01:00
Steven Masley 028a4edbd4 chore: Add flusher to make implement http.Flusher interface (#4255) 2022-09-29 01:16:11 +00:00
Colin Adler 6d2b7ea3ba fix(audit): only generate diff on request success (#4253) 2022-09-28 17:28:33 -05:00
Colin Adler 9339d597b9 fix(audit): properly set old workspace in putWorkspaceTTL (#4251) 2022-09-28 16:50:21 -05:00
Colin Adler 574635f43d chore: ignore db spans in workspace watch endpoint (#4250) 2022-09-28 16:17:24 -05:00
Ali Diamond 0c75ea6286 feat: coder ls should show possible columns to filter by (#4240)
* added showing columns in help call, need to format to make pretty

* finished formatting column  strings for print of list /ls command

Co-authored-by: Ali Diamond <user@ali.dev>
2022-09-28 16:39:44 -04:00
Bruno Quaresma df7c7393ad chore: Ignore dynamic message for chromatic (#4244) 2022-09-28 18:18:12 +00:00
Bruno Quaresma 2a7fe13397 chore: Remove extra typegen (#4243) 2022-09-28 16:58:50 +00:00
Bruno Quaresma af502a6a66 chore: Use Vite as build tool (#4239) 2022-09-28 13:11:00 -03:00
Kyle Carberry 6c83012082 chore: Add comments to indicate what each field on a network node means (#4241)
* chore: Add comments to indicate what each field on a network node means

* Update tailnet/coordinator.go

Co-authored-by: Colin Adler <colin1adler@gmail.com>

* Update tailnet/coordinator.go

Co-authored-by: Colin Adler <colin1adler@gmail.com>

* Update tailnet/coordinator.go

Co-authored-by: Colin Adler <colin1adler@gmail.com>

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-09-28 16:04:10 +00:00
Ammar Bandukwala 518f6960d0 docs: add missing icons to Administration section (#4233) 2022-09-28 10:12:31 -05:00
Bruno Quaresma d38cc75f31 fix: Port forward button (#4238) 2022-09-28 14:19:04 +00:00
Mathias Fredriksson 31aaa1ed59 docs: Update Docker docs and docker-compose, mention group-add (#4237) 2022-09-28 16:33:36 +03:00
Bruno Quaresma 59cc4a2586 chore: Use Vite as main dev runner for FE (#4230) 2022-09-27 21:09:16 -03:00
Joe Previte 9775228b00 fix: call testing lib cleanup afterEach test (#4232) 2022-09-27 16:27:42 -07:00
Kira Pilot 65ff604969 fix: update workspace button should properly update the workspace (#4228)
* resolves #4098

* PR comments
2022-09-27 19:23:28 -04:00
Presley Pizzo fedb180735 chore: Change usage of ChooseOne (no final condition) (#4158)
* Change contract of Cond: no condition on default case

* Handle no children case

* Format
2022-09-27 15:58:25 -04:00
Ben Potter 21e6bea792 docs: add health checks to docs & examples (#4223) 2022-09-27 12:58:39 -05:00
Steven Masley 27c8345ef2 chore: Add linter rule to prevent breaking of sse (#4144)
* chore: Add linter rule to prevent breaking of sse
2022-09-27 11:14:58 -04:00
Bruno Quaresma 5a449bf86f chore: Add user autocomplete (#4210)
* chore: Add user autocomplete

* Update value type

* fix initial load and option updates

* cleaned up styling

* PR comments

* prettier

Co-authored-by: Kira Pilot <kira.pilot23@gmail.com>
2022-09-27 10:23:38 -04:00
Ben Potter a7e08db16d docs: fix link 404 in port-forwarding (#4211) 2022-09-27 08:24:49 -05:00
Ben Potter b6426083b9 fix: inline code blocks in template README (#4141) 2022-09-27 07:54:29 -05:00
Kyle Carberry 4f453544d4 chore: Update hero image (#4216) 2022-09-27 07:38:18 -05:00
Ammar Bandukwala 47a53ce6c5 coderd: treat email case insensitively (#4215) 2022-09-27 03:51:58 +00:00
Garrett Delfosse 20bcb04e8a fix: use correct interval for healthcheck loop (#4212) 2022-09-26 21:00:58 +00:00
Ben Potter c86fc6e976 chore: examples/lima: bump terraform version (#4205)
Download terraform binary directly instead of using Hashicorp APT
repo.
Workaround for https://github.com/hashicorp/terraform/issues/31826

Signed-off-by: Cian Johnston <cian@coder.com>
Co-authored-by: Ben Potter <ben@coder.com>
2022-09-26 20:04:59 +00:00
Steven Masley 2f0d30d7b5 chore: Reduce the amount of bytes allocated for Filter (#4209)
Reuse parsed data structure for subsequent queries
2022-09-26 15:16:46 -04:00
Steven Masley 48c0b59447 fix: Log out of legacy cookie (#4202) 2022-09-26 14:20:38 -04:00
Kyle Carberry 39cf329404 fix: Replace access URL for built-in DERP servers (#4197)
Fixes #4195.
2022-09-26 12:56:04 -05:00
Ammar Bandukwala ee4b934601 Add Users Last Seen At (#4192) 2022-09-26 15:31:03 +00:00
Kyle Carberry b8ec5c786d fix: Ensure tailnet coordinations are sent orderly (#4198) 2022-09-26 10:16:04 -05:00
Bruno Quaresma c37ecdb9ff feat: Add port forward button (#4167) 2022-09-26 14:56:17 +00:00
Kyle Carberry 413bfb8d58 fix: Retry reporting agent version (#4190)
It's possible that an agent starts before a build is reported
as complete. This ensures the version is successfully sent
before the startup completes.

Fixes #4151.
2022-09-25 11:11:36 -05:00
Kyle Carberry 112eaf80d1 fix: Add logging to Terraform install (#4191)
Fixes #4129.
2022-09-24 14:55:17 -05:00
Kyle Carberry 4054a9c7cb Fix permissions for welcome message 2022-09-24 02:27:23 +00:00
Ryan Merolle 6571e52f17 Add coder binary to Dockerfile $PATH (#4189) 2022-09-24 02:25:15 +00:00
Kyle Carberry 28428d1294 feat: Add custom version names (#4186)
Fixes #4137.
2022-09-23 20:17:36 -05:00
Kyle Carberry 3c215a83b6 feat: Allow admins to create workspaces (#4183)
Fixes #3263.

This is now possible via the API, but still isn't possible via the UI.
2022-09-23 20:17:10 -05:00
Kyle Carberry 266a3b24e7 fix: Replace getFormHelpers (#4181)
Fixes #3209.
2022-09-23 16:37:44 -05:00
Kyle Carberry f9075cab0e fix: Hide agent status when a workspace is stopped (#4185)
Fixes #4033.
2022-09-23 21:36:33 +00:00
Kyle Carberry b64f624d17 fix: Remove unused scopes from parameter computation (#4171) 2022-09-23 16:09:45 -05:00
Kyle Carberry ea115c981d fix: Make entire row clickable in responsive navbar (#4182)
Fixes #3235.
2022-09-23 20:38:24 +00:00
Kyle Carberry 1c85799be5 fix: Update Terraform to v1.3.0 (#4180)
Contributes to #3202.
2022-09-23 15:31:26 -05:00
Colin Adler 15b9a59786 chore: only trace rbac.Filter (#4177) 2022-09-23 15:21:56 -05:00
Colin Adler 95aea104c7 chore: ignore traces from (*API).workspaceAgentCoordinate after accept (#4178) 2022-09-23 15:21:44 -05:00
Garrett Delfosse 4c8be34d81 feat: add health check monitoring to workspace apps (#4114) 2022-09-23 15:51:04 -04:00
Kyle Carberry f160830226 fix: Update default cache directory (#4175)
Fixes #2534.
2022-09-23 14:26:29 -05:00
Bruno Quaresma 38e2a28ada chore: Pin site deps (#4173) 2022-09-23 16:09:35 -03:00
Bruno Quaresma 189c562826 chore: Use Vite instead of Webpack for development (#4156) 2022-09-23 15:22:48 -03:00
Joe Previte ee00a1d886 chore(site): fix material ui warning (#4161)
* chore(deps): upgrade @material-ui/core to 4.12.4

This is the latest version which includes a fix for the warning we were
seeing while running our tests about `css` function being deprecated.

* refactor: use alpha() instead of fade

`fade()` was deprecated in favor of `alpha()` in a previous version of
`@material-ui/core/styles`.

* refactor: rows -> minRows

This was deprecated in a previous version of `@material-ui/core`.

* refactor: overlap circle -> circular

overlap="circle" was deprecated in favor of overlap="circular".

* refactor: createMuiTheme -> createTheme

This was deprecated and changed to `createTheme`.

* fixup!: chore(deps): upgrade @material-ui/core to 4.12.4

* fixup!: refactor: createMuiTheme -> createTheme

* fix: add SvgIconProps on icons

I couldn't find any release notes or breaking changes related to this
but it seems `props` can no longer be inferred on `SvgIcon`s so I had to
manually add the type.

* Revert "refactor: rows -> minRows"

This reverts commit 94dae6fea8.

* chore(deps): downgrade @material-ui/core to 4.12.0

* fixup!: fix: add SvgIconProps on icons

* fix: pass {} to useStyles

Looks like we may need to pass an empty object if some components in a
file use `props` in styles and some don't.

* fix: update types in Pill.tsx

We need to use generics so that `makeStyles` correctly infers the types
for the `Pill.tsx` styles.

I also updated the types to use `PillProps` directly to make sure they
stay in sync.
2022-09-23 18:14:02 +00:00
Kyle Carberry 99013b3aed chore: Close dials in tailnet conn on close (#4174)
Fixes a race seen in: https://github.com/coder/coder/actions/runs/3114263658/jobs/5049905647
2022-09-23 12:10:47 -05:00
Kira Pilot 8cd5aeaf25 cleanup workspace machine (#4160)
* removed dead build states

* removed dead code

* removed guards

* not calling events from actions

* simplified timeline

* simplify refresh template
2022-09-23 13:06:48 -04:00
Bruno Quaresma 1214022c5a Improve DAU chart view (#4172) 2022-09-23 13:58:00 -03:00
Kyle Carberry 8738755ffc chore: Compile rego once to save CPU cycles in testing (#4169)
Compiling rego isn't very fast, so this should speed up tests in CI!
2022-09-23 16:26:04 +00:00
Mathias Fredriksson 1e1967e0db fix: Avoid using hijacked http.ResponseWriter in workspaceAgentReportStats (#4165) 2022-09-23 19:08:56 +03:00
Bruno Quaresma 7898581e50 feat: Show a full screen loader while is loading a lazy loading page (#4168) 2022-09-23 10:32:28 -05:00
Mathias Fredriksson 6b365f46f5 fix: Ensure coordinator is closed and freed in agent (#4164)
* fix: Close coordinator on context cancellation

* fix: Refactor runCoordinator so that previous is closed/freed
2022-09-23 18:08:13 +03:00
Steven Masley 2e30d0512e chore: Move scope into the same auth call (#4162)
Scopes now are enforced in the same Authorize call as the roles. 
Vs 2 `Authorize()` calls
2022-09-23 11:07:30 -04:00
Kyle Carberry 4183c5e1d0 chore: Clean up unused and outdated dependencies from go.mod (#4163) 2022-09-23 00:58:19 +00:00
Dean Sheather 6deef06ad2 feat: secure and cross-domain subdomain-based proxying (#4136)
Co-authored-by: Kyle Carberry <kyle@carberry.com>
2022-09-22 22:30:32 +00:00
Kyle Carberry 80b45f1aa1 fix: Buffer tailnet nodes from connection initialization (#4159)
* fix: Don't use StatusAbnormalClosure

This is reserved for WASM use, and might be the cause of some weird leaks.

* Add close to provisioner logs
2022-09-22 20:22:49 +00:00
Kyle Carberry a7ee8b31e0 fix: Don't use StatusAbnormalClosure (#4155) 2022-09-22 18:26:05 +00:00
Ben Potter 9e099b543f chore: revert open in coder docs for now (#4154)
* chore: revert open in coder docs for now

* remove in dogfood
2022-09-22 18:02:11 +00:00
Kira Pilot 5fd90471fc Cleanup dead states in workspace machine
* removed dead build states

* removed dead code

* removed guards
2022-09-22 13:32:40 -04:00
Colin Adler 57c84d6446 chore: add option for specifically disabling Coder tracing (#4153) 2022-09-22 11:53:08 -05:00
Kyle Carberry b77d6bdd91 fix: Panic when loading coordination override (#4152)
This was broken because of browser-only. This should fix it!

Signed-off-by: Kyle Carberry <kyle@carberry.com>

Signed-off-by: Kyle Carberry <kyle@carberry.com>
2022-09-22 11:03:49 -05:00
Joe Previte 764600003b feat: add open in coder docs, fix missing templates (#4124)
* docs: add open in coder

This adds new documentation for the "Open in Coder" button that admins
can use to get their developers up and running faster.

* fix: display error if template not found

Previously, we weren't handling a case where we tried to get a template
that returned a 404 from the backend.

Now we handle that case in our state machine and display the error
message from the API on the frontend.

* feat: support template query param in index

This adds support to navigate directly to a template from the index by
using the `?template=<name>` query  param.

* Revert "feat: support template query param in index"

This reverts commit bad7ffb677.

We decided to use the `/template/path` route instead.

* fixup!: docs: add open in coder

* docs: add open in coder to dogfood readme

* Update docs/admin/open-in-coder.md

Co-authored-by: Ben Potter <ben@coder.com>

* Update docs/admin/open-in-coder.md

Co-authored-by: Ben Potter <ben@coder.com>

* Update docs/admin/open-in-coder.md

Co-authored-by: Ben Potter <ben@coder.com>
2022-09-22 08:48:03 -07:00
Kyle Carberry 7ad4276224 feat: Add browser-only connections to Enterprise (#4135)
* feat: Add browser-only connections to Enterprise

Fixes #4131.

* Fix formatting
2022-09-22 15:14:22 +00:00
Mohammed Agboola 656dcc0050 fix: typo (#4149) 2022-09-21 17:38:51 -05:00
Colin Adler 5de6f86959 feat: trace httpapi.{Read,Write} (#4134) 2022-09-21 17:07:00 -05:00
Joe Previte 1bf2dc0cc3 chore: add explicit-length-check eslint rule (#4147)
* chore: add eslint rule explicit-length-check

* fix: add explicit-length-check
2022-09-21 15:42:10 -04:00
Kira Pilot 5698b9d706 feat: use sse for workspace page (#4122)
* added error handling

* workspace machine cleanup

* renaming callback

* general cleanup

* fixed tests

* PR comments
2022-09-21 14:32:00 -04:00
Joe Previte 3db9ea9dd2 fix: disable inspect xstate in develop (#4145) 2022-09-21 11:08:54 -07:00
Ben Potter 93475453d8 chore: sync autostart helpers+values when toggled (#4143) 2022-09-21 12:59:06 -05:00
Ben Potter ceef283bfd chore: minor changes to SSH dialog (#4142) 2022-09-20 23:02:50 -05:00
Ammar Bandukwala d30945c5c5 feat: bump workspace deadline on user activity (#4119)
Resolves #2995
2022-09-20 21:17:24 +00:00
Presley Pizzo 0899548208 feat: have user type name of thing to delete for extra safety (#4080)
* Add info and text field to delete dialog

* Format

* Use DeleteDialog for Users, nix info except for Workspaces

* Format

* Update storybook

* Add and update tests

* Fix the worst of the UsersPage test bugs

* Fix users page tests

* Fix workspace tests

* Format
2022-09-20 17:13:48 -04:00
Colin Adler eb71053e56 chore: update wireguard-go (#4139) 2022-09-20 16:02:49 -05:00
Colin Adler 5e2efb68f1 feat: add SCIM provisioning via Okta (#4132)
Co-authored-by: Ben Potter <ben@coder.com>
2022-09-20 15:16:26 -05:00
Bruno Quaresma 50321ba2aa docs: Add missing audit logs filtering fields (#4133)
* docs: Add missing audit logs filtering fields

* Update docs/admin/audit-logs.md

Co-authored-by: Ben Potter <ben@coder.com>

Co-authored-by: Ben Potter <ben@coder.com>
2022-09-20 17:44:00 +00:00
Bruno Quaresma bc47d7ce69 feat: Add extra fields to the audit filter (#4123) 2022-09-20 13:07:21 -03:00
Kyle Carberry 3618b098cb fix: Return deprecation error when using WebRTC endpoint (#4130)
Fixes #4126.
2022-09-20 09:56:19 -05:00
Mathias Fredriksson 2ca7214259 fix: Produce unknown subcommand errors for bad command names (#4089)
Fixes #1616
2022-09-20 15:31:38 +03:00
Colin Adler 8d7954b015 fix: ignore context canceled error on server (#4128) 2022-09-19 23:56:51 -05:00
Colin Adler 67230babc0 fix: properly shutdown tracers (#4127) 2022-09-19 23:35:18 -05:00
Colin Adler 3993f66997 chore: bump github.com/open-policy-agent/opa from 0.41.0 to 0.44.0 (#4094) 2022-09-20 04:16:03 +00:00
Kyle Carberry db0ba8588e chore: Refactor Enterprise code to layer on top of AGPL (#4034)
* chore: Refactor Enterprise code to layer on top of AGPL

This is an experiment to invert the import order of the Enterprise
code to layer on top of AGPL.

* Fix Garrett's comments

* Add pointer.Handle to atomically obtain references

This uses a context to ensure the same value persists through
multiple executions to `Load()`.

* Remove entitlements API from AGPL coderd

* Remove AGPL Coder entitlements endpoint test

* Fix warnings output

* Add command-line flag to toggle audit logging

* Fix hasLicense being set

* Remove features interface

* Fix audit logging default

* Add bash as a dependency

* Add comment

* Add tests for resync and pubsub, and add back previous exp backoff retry

* Separate authz code again

* Add pointer loading example from comment

* Fix duplicate test, remove pointer.Handle

* Fix expired license

* Add entitlements struct

* Fix context passing
2022-09-19 23:11:01 -05:00
Kyle Carberry 714c366d16 chore: Remove WebRTC networking (#3881)
* chore: Remove WebRTC networking

* Fix race condition

* Fix WebSocket not closing
2022-09-19 19:46:29 -05:00
Bruno Quaresma 1186e643ec feat: Add audit logs filtering to the UI (#4120) 2022-09-19 21:28:23 -03:00
Garrett Delfosse 7fe7ffea6d chore: make fmt (#4121) 2022-09-19 20:22:46 +00:00
Kyle Carberry 72d6731924 fix: Only update workspace LastUsed when the connection payload has changed (#4115)
This was causing every workspace to update last used to time.Now() when
coderd was restarted!
2022-09-19 14:11:18 -05:00
Colin Adler 153e96f574 fix: use consistent tracer name (#4117) 2022-09-19 13:46:26 -05:00
Ammar Bandukwala 794b88fab4 Fix wireguard dependency (#4116)
The old commit disappeared(?).
2022-09-19 18:23:44 +00:00
Dean Sheather 29d804e692 feat: add API key scopes and application_connect scope (#4067) 2022-09-19 17:39:02 +00:00
Bruno Quaresma adad347902 refactor: Refactor audit logs count to support filtering (#4113) 2022-09-19 17:08:25 +00:00
Kyle Carberry 6f82ad09c8 fix: Improve consistency on CLI help (#4112)
This makes the english consistent on flags, and improves
the contrast for the placeholder color on dark themes.
2022-09-19 11:36:18 -05:00
Ben Potter 353fb8724a add docs: "docker in docker" and "systemd in docker" (#4051) 2022-09-19 16:33:31 +00:00
Bruno Quaresma 3e4b67893e fix: Workspace default filter on search bar (#4111) 2022-09-19 13:27:41 -03:00
James Ottaway 9196b3978d Fix kubectl get pods command in k8s install docs (#4053) 2022-09-19 15:55:32 +00:00
Ben Potter 732bc5910c fix: docs: remove reference to fixed issue (#4104) 2022-09-19 10:23:41 -05:00
Ben Potter 64e4ea73c0 fix: docs: use diff view in Docker docs (#4110) 2022-09-19 09:43:54 -05:00
Bruno Quaresma bf8d823ae3 feat: Add audit log filters in the API (#4078) 2022-09-19 10:37:33 -03:00
Geoffrey Huntley f314f30ebc housekeeping(gitignore): update gitignore/eslintignore/prettierignore (#4108) 2022-09-19 17:16:19 +10:00
Denbeigh Stevens 36a599ea9a docs: fix ephemeral resources link (#4101)
[This link](https://coder.com/docs/coder-oss/latest/templates#persistent-and-ephemeral-resources)
directs to the top of the Templates page, we should use
[this link](https://coder.com/docs/coder-oss/latest/templates#persistent-vs-ephemeral-resources) instead.
2022-09-19 02:23:17 +00:00
Kyle Carberry 68ee82437e fix: Remove hiding Tailscale flags (#4103)
Now that Tailscale is defualt, we shouldn't be hiding these!

Fixes #4083.
2022-09-18 20:24:26 -05:00
Geoffrey Huntley d499416024 housekeeping(branding): be consistent (#4075) 2022-09-19 09:57:18 +10:00
Kyle Carberry b3d07ffd87 fix: Test race for TestPostWorkspaceBuild (#4102) 2022-09-18 16:40:24 -05:00
Garrett Delfosse 63fd4945a2 chore: watch workspace endpoint (#4060) 2022-09-16 18:54:23 +00:00
Colin Adler b340634aaa feat: add rbac tracing (#4093) 2022-09-16 18:32:15 +00:00
Joe Previte 1bca269b90 refactor: add type safety in utils.test.ts (#4091)
This makes a few changes to the typings in
site/src/components/GlobalSnackbar/utils.test.ts to more accurately
represent the types we're using. It allows us to remove from type
assertion and one eslin-disable comment..
2022-09-16 10:11:37 -07:00
Colin Adler 77acf0c340 feat: provisionerd tracing, add public trace ingestion (#4070) 2022-09-16 11:43:22 -05:00
Dean Sheather fc841898cd fix: remove path-based port proxying (#4063) 2022-09-16 16:31:08 +00:00
Dean Sheather 6e9c05f859 chore: use zstd -6 in dev (#4092) 2022-09-16 16:03:16 +00:00
Mathias Fredriksson 21664c5c58 fix: Revert change from zstd level 22 to level 6 compression (#4086) 2022-09-16 18:36:11 +03:00
Mathias Fredriksson 9e12850f38 fix: Remove TestWorkspaceBuildResources/ListRunning (#4088) 2022-09-16 16:39:57 +03:00
Colin Adler 86fdafda23 fix: data races in databasefake (#4084) 2022-09-16 00:06:39 +00:00
Kyle Carberry b2bc74e3af chore: Skip TestPortForward due to flakes (#4081)
We'll have to fix this in a future PR... it's unfortunate but
these are *really* flakey.
2022-09-15 21:05:43 +00:00
Colin Adler 87ab6ae8a0 fix: incorrect templates list test assert (#4079) 2022-09-15 15:03:29 -05:00
Joe Previte b8bd3208ca chore: update cSpell and fix isNotificationTextPrefixed (#4076)
* chore: update cSpell words

* chore: add ignorePaths for cSpell

* fix: update isNotificationTextPrefixed

This removes an eslint-disable rule and adds two new tests to ensure
isNotificationTextPrefixed is working as expected.

* fix(e2e): remove filter in workspacesPage
2022-09-15 16:59:22 -03:00
Bruno Quaresma 9e9a9e0cd2 fix: Setup redirect (#4064) 2022-09-15 13:26:24 +00:00
Bruno Quaresma 40c0fc285c refactor: Remove users redirect to active filter (#4056) 2022-09-15 10:05:33 -03:00
Bruno Quaresma b78ab9e028 Fix form tab (#4066) 2022-09-15 09:59:13 -03:00
Andrei Kondratiev 938bd7341b helm: added service annotations (#4062) 2022-09-15 00:01:40 -05:00
Eric Paulsen 45f39ba488 chore: rename AWS ECS template & fix docker template var (#4068) 2022-09-14 20:59:31 -05:00
Kyle Carberry e847e7386a fix: Resolve flake in TestPortForward (#4069) 2022-09-14 20:21:53 -05:00
Kyle Carberry ec453f01e4 fix: Wait for connections before port-forwarding (#4057)
UDP packets were being dropped if a connection was started
before the Tailscale connection has been established.
2022-09-14 21:57:42 +00:00
Joe Previte 22e49c4316 feat(cli): add error message for bad login URL (#4042) 2022-09-14 20:15:47 +00:00
Bruno Quaresma 62d97b18f4 refactor: Typography, action hover and table head colors (#4046)
* Adjust primary text color

* refactor: Typography and table head colors
2022-09-14 15:09:06 -03:00
Geoffrey Huntley a01ab27751 docs(contributing): enable contribution via devcontainer (#3970) 2022-09-14 10:30:12 -07:00
Bruno Quaresma b20ecfdf37 refactor: Minor improvements and fixes for the page headers (#4045) 2022-09-14 11:04:01 -03:00
Presley Pizzo b6712ffbee chore: add wrapper components for conditional rendering (#4047)
* Add conditional wrappers

* Use wrappers in TemplatesPageView
2022-09-14 09:55:00 -04:00
Kyle Carberry 4f0417c6ad Revert "feat: Add portforward to the UI (#3812)" (#4048)
This reverts commit 0552c36e29.
2022-09-13 17:18:27 -05:00
Kyle Carberry 0f8c2f592e feat: Use Tailscale networking by default (#4003)
* feat: Use Tailscale networking by default

Removal of WebRTC code will happen in another PR, but it
felt dangerious to default and remove in a single commit.

Ideally, we can release this version and collect final
thoughts and  feedback before a full commitment.

* Remove UNIX forwarding

Tailscale doesn't support this, and adding support
for it shouldn't block our rollout. Customers can
always forward over SSH.

* Update cli/portforward_test.go

Co-authored-by: Dean Sheather <dean@deansheather.com>

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-09-13 15:55:56 -05:00
Bruno Quaresma 478d49c19c docs: Custom resource icon (#4041)
* Fix missed unresolved conflict

* docs: Custom resource icons

* Fix title

* Apply suggestions from code review

Co-authored-by: Ben Potter <ben@coder.com>

Co-authored-by: Ben Potter <ben@coder.com>
2022-09-13 20:45:17 +00:00
Bruno Quaresma 0552c36e29 feat: Add portforward to the UI (#3812)
* feat: Add portforward to the UI

* Update site/src/components/PortForwardButton/PortForwardButton.tsx

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>

* Add CODER_ENABLE_WILDCARD_APPS env var

* Fix portforward link

* Remove t file

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>
2022-09-13 17:41:40 -03:00
Steven Masley 9b5ee8f267 feat: Implement (but not enforce) CSRF for FE requests (#3786)
Future work is to enforce CSRF

Co-authored-by: Presley Pizzo <presley@coder.com>
2022-09-13 15:26:46 -04:00
Steven Masley 9ab437d6e2 feat: Add serving applications on subdomains and port-based proxying (#3753)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-09-14 03:31:33 +10:00
Presley Pizzo 99a7a8dd22 chore: Turn predictable action arguments on (#3964)
* Turn predictable action arguments on

* Remove layout strings
2022-09-13 12:54:04 -04:00
Ben Potter f16dd5acb4 docs: explain SSH key behavior (#3990) 2022-09-13 11:36:39 -05:00
Eric Paulsen d57c181aad Delete template docs (#4029)
* add: delete template docs

* add: RBAC context

* fix: caps

Co-authored-by: Ben Potter <ben@coder.com>

* add: deletion note

Co-authored-by: Ben Potter <ben@coder.com>
2022-09-13 10:51:50 -05:00
Ben Potter 3ded910cca Add support for coder tunnel in docker-compose (#4027) 2022-09-13 14:53:41 +00:00
Bruno Quaresma 214e59452f feat: Show custom resource icons in the UI (#4020) 2022-09-13 11:32:59 -03:00
Presley Pizzo 83c35bb916 feat: display specific errors if templates page fails (#4023)
* Surface templates page errors

* Format

* Separate error messages

* Fix story

* Format

* Format

* Fix imports

* Remove unnecessary check

* Format
2022-09-13 10:26:58 -04:00
Steven Masley 21e8fb243b fix: Allow develop.sh to host docker workspaces (#3802) 2022-09-13 09:21:05 -04:00
Kyle Carberry 57c7fcf27f fix: Ignore deleted users when signing up with OAuth (#4036)
This prevented a deleted user from signing up again when they
were already linked with a previous account.
2022-09-13 07:33:35 -05:00
Christian Feldkirchner 1ee1db9664 Update docker.md (#4004)
Added a more detailed description on how to create the initial user (via the web ui)
2022-09-13 05:17:01 +00:00
Kyle Carberry a4980446c5 fix: Update Tailscale to resolve race condition (#4032)
This is being fixed upstream here: https://github.com/tailscale/tailscale/pull/5611
2022-09-13 03:32:51 +00:00
Geoffrey Huntley 708bdbc134 docs(contributing): add macos homebrew commands (#3968) 2022-09-13 13:13:30 +10:00
Kyle Carberry 850a83097c feat: Allow deleting users (#4028)
* Add deleted column to the users table

* Fix user indexes

* Add frontend

* Add test
2022-09-12 23:24:20 +00:00
Kyle Carberry a2098254cd feat: Support --header for CLI commands to support proxies (#4008)
Fixes #3527.
2022-09-12 16:22:05 -05:00
Bruno Quaresma 846dd999b7 refactor: Remove cli example from the Audit page (#4031) 2022-09-12 17:17:59 -03:00
Ammar Bandukwala 7e54413d3b docs: add networking (#4030) 2022-09-12 19:07:03 +00:00
dependabot[bot] e9efb7e253 chore: bump github.com/go-chi/httprate from 0.6.0 to 0.7.0 (#4018)
Bumps [github.com/go-chi/httprate](https://github.com/go-chi/httprate) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/go-chi/httprate/releases)
- [Commits](https://github.com/go-chi/httprate/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: github.com/go-chi/httprate
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 18:51:44 +00:00
dependabot[bot] 34a2d40f27 chore: bump github.com/prometheus/client_golang from 1.12.2 to 1.13.0 (#4025)
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.12.2 to 1.13.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.12.2...v1.13.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 18:08:48 +00:00
Bruno Quaresma 184e7dbce0 docs: Add docs about coder_metadata hide attribute (#3985) 2022-09-12 14:57:53 -03:00
dependabot[bot] 0e59cb21ce chore: bump go.uber.org/atomic from 1.9.0 to 1.10.0 (#3793)
Bumps [go.uber.org/atomic](https://github.com/uber-go/atomic) from 1.9.0 to 1.10.0.
- [Release notes](https://github.com/uber-go/atomic/releases)
- [Changelog](https://github.com/uber-go/atomic/blob/master/CHANGELOG.md)
- [Commits](https://github.com/uber-go/atomic/compare/v1.9.0...v1.10.0)

---
updated-dependencies:
- dependency-name: go.uber.org/atomic
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 12:47:59 -05:00
Kyle Carberry 5c0d63d31f fix: Only hold tailnet.*Conn.Close() for a short duration (#4015)
* fix: Only hold `tailnet.*Conn.Close()` for a short duration

The long duration could be cause to a test deadlock.

* Add closed chan to listener struct
2022-09-12 17:46:45 +00:00
dependabot[bot] d4f0a6fecf chore: bump github.com/hashicorp/hcl/v2 from 2.13.0 to 2.14.0 (#4026)
Bumps [github.com/hashicorp/hcl/v2](https://github.com/hashicorp/hcl) from 2.13.0 to 2.14.0.
- [Release notes](https://github.com/hashicorp/hcl/releases)
- [Changelog](https://github.com/hashicorp/hcl/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/hcl/compare/v2.13.0...v2.14.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hcl/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 17:44:14 +00:00
dependabot[bot] 4db98b2b9f chore: bump cloud.google.com/go/compute from 1.7.0 to 1.9.0 (#4012)
Bumps [cloud.google.com/go/compute](https://github.com/googleapis/google-cloud-go) from 1.7.0 to 1.9.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/video/v1.7.0...pubsub/v1.9.0)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/compute
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 12:34:28 -05:00
dependabot[bot] cab6fe9482 chore: bump github.com/moby/moby (#4021)
Bumps [github.com/moby/moby](https://github.com/moby/moby) from 20.10.17+incompatible to 20.10.18+incompatible.
- [Release notes](https://github.com/moby/moby/releases)
- [Changelog](https://github.com/moby/moby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moby/moby/compare/v20.10.17...v20.10.18)

---
updated-dependencies:
- dependency-name: github.com/moby/moby
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 12:33:51 -05:00
dependabot[bot] edec39baef chore: bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc (#4016)
Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.9.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.9.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 12:10:55 -05:00
dependabot[bot] a7a56f9a26 chore: bump github.com/unrolled/secure from 1.12.0 to 1.13.0 (#4017)
Bumps [github.com/unrolled/secure](https://github.com/unrolled/secure) from 1.12.0 to 1.13.0.
- [Release notes](https://github.com/unrolled/secure/releases)
- [Commits](https://github.com/unrolled/secure/compare/v1.12.0...v1.13.0)

---
updated-dependencies:
- dependency-name: github.com/unrolled/secure
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 12:10:38 -05:00
Kyle Carberry 0551a6cba2 chore: Automatically approve dependabot PRs (#4014)
Dependabot is annoying but now it makes merging it's PRs a
little bit easier!
2022-09-12 16:56:38 +00:00
dependabot[bot] 42d1b5e4ba chore: bump go.uber.org/goleak from 1.1.12 to 1.2.0 (#4010)
Bumps [go.uber.org/goleak](https://github.com/uber-go/goleak) from 1.1.12 to 1.2.0.
- [Release notes](https://github.com/uber-go/goleak/releases)
- [Changelog](https://github.com/uber-go/goleak/blob/master/CHANGELOG.md)
- [Commits](https://github.com/uber-go/goleak/compare/v1.1.12...v1.2.0)

---
updated-dependencies:
- dependency-name: go.uber.org/goleak
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 11:55:46 -05:00
dependabot[bot] 4f78368403 chore: bump github.com/coreos/go-oidc/v3 from 3.2.0 to 3.4.0 (#4013)
Bumps [github.com/coreos/go-oidc/v3](https://github.com/coreos/go-oidc) from 3.2.0 to 3.4.0.
- [Release notes](https://github.com/coreos/go-oidc/releases)
- [Commits](https://github.com/coreos/go-oidc/compare/v3.2.0...v3.4.0)

---
updated-dependencies:
- dependency-name: github.com/coreos/go-oidc/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 11:55:34 -05:00
dependabot[bot] 31f25002a6 chore: bump github.com/charmbracelet/lipgloss from 0.5.0 to 0.6.0 (#4011)
Bumps [github.com/charmbracelet/lipgloss](https://github.com/charmbracelet/lipgloss) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/charmbracelet/lipgloss/releases)
- [Commits](https://github.com/charmbracelet/lipgloss/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: github.com/charmbracelet/lipgloss
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 11:55:04 -05:00
Kyle Carberry 2b8223bdd5 fix: Use command property when launching an application (#3998)
Fixes #3777.
2022-09-12 16:46:13 +00:00
dependabot[bot] 07e2565a4f chore: bump go.opentelemetry.io/otel/trace from 1.8.0 to 1.9.0 (#3794)
Bumps [go.opentelemetry.io/otel/trace](https://github.com/open-telemetry/opentelemetry-go) from 1.8.0 to 1.9.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.8.0...v1.9.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/trace
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 11:40:58 -05:00
dependabot[bot] 761f1e7c1a chore: bump google.golang.org/api from 0.94.0 to 0.95.0 (#3921)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.94.0 to 0.95.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.94.0...v0.95.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 11:38:07 -05:00
Mathias Fredriksson 09da3858ce fix: Terminal emulation used by SSH sessions (#3473)
Fixes #3371
2022-09-12 19:27:51 +03:00
Kyle Carberry b4c29f34c3 fix: Always use UTC time when inserting stats (#4009)
Fixes a flake reported by @mafredri
2022-09-12 16:01:42 +00:00
Mathias Fredriksson d0b02e581d feat: Improve experience with local SSH keys (#3835)
* feat: Improve experience with local SSH keys

This change means that users can place SSH keys in the default locations
for OpenSSH, like `~/.ssh/id_rsa` and it will be automatically picked
up (as per a default OpenSSH experience).

Fixes #3126

* fix: Ensure gitssh cleans up temporary file on interrupt

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-09-12 17:26:04 +03:00
Kyle Carberry 66ad86a755 fix: Update workspace wasn't using the latest build (#4001)
This was an oversight in a prior contribution. It broke the update
button, but fixed the other cases.
2022-09-12 08:22:29 -03:00
Bruno Quaresma 43f368dfc4 docs: Add audit logs docs (#3975)
* docs: Add audit logs docs

* Apply suggestions from code review

Co-authored-by: Joe Previte <jjprevite@gmail.com>

* Add contact link

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-09-12 01:04:56 +00:00
Ben Potter e5e1ed2f9c chore: minor clarifications to install docs (#3983) 2022-09-12 10:50:20 +10:00
Joe Previte 067069d2e2 docs: add jsjoeio/coder-templates to community (#3986) 2022-09-12 10:49:05 +10:00
Kyle Carberry 5b5bc1da56 feat: Add local configuration option for DERP mapping (#3996)
This allows entirely airgapped geodistributed deployments of Coder!
2022-09-11 16:45:49 -05:00
Kyle Carberry 6e20f9c729 fix: Recursively ignore hidden folders (#3997)
Fixes #3938.
2022-09-11 15:13:20 -05:00
Kyle Carberry 9e148a5cac fix: Update embedded DERP server default name (#3995)
* fix: Update embedded DERP server default name

This is still configurable, but exposing the name DERP
seemed awkward.

* Update relay name
2022-09-11 13:06:07 -05:00
Kyle Carberry f5bbbdf638 chore: Fix VSCode configuration to hide visual test overlay (#3994)
This made it impossible to code 😅
2022-09-11 10:50:50 -05:00
Denbeigh Stevens 522fde47dc docs: fix incorrect terraform providers docs link (#3991) 2022-09-10 16:20:28 -05:00
Colin Adler 29bac36816 feat: add workspace auditing (#3966) 2022-09-10 11:07:45 -05:00
J Bruni 442df9e132 Fix phrase at templates.md (#3987) 2022-09-10 16:07:51 +10:00
Kyle Carberry 849e389388 Update manifest.json 2022-09-09 15:53:00 -05:00
Presley Pizzo 20d950d1b3 feat: Update template page automatically (#3962)
* Update template page automatically

* Remove misleading test
2022-09-09 16:27:21 -04:00
Spike Curtis ba6a868a80 Licensed features docs (#3934)
* Licensed features docs

Signed-off-by: Spike Curtis <spike@coder.com>

* Licensed features -> Enterprise features

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-09-09 20:10:39 +00:00
Bruno Quaresma ce211fd8f5 fix: Do not update workspace on start (#3984) 2022-09-09 12:56:41 -07:00
Bruno Quaresma 8a94b72c7d feat: Allow hide resources (#3977) 2022-09-09 16:38:00 -03:00
Ammar Bandukwala f6aa025a01 feat: use active users instead of total users in Template views (#3900) 2022-09-09 19:30:31 +00:00
Bruno Quaresma 346583f13e fix: Audit log human parse message and nullable diffs (#3978)
* fix: Audit log human parse message and nullable diffs

* Fix diff values
2022-09-09 13:53:38 -03:00
Colin Adler abb804f2de feat: add template/template version auditing (#3965) 2022-09-09 11:34:23 -05:00
Ben Potter d380c9494d fix: broken docker-compose link (#3976) 2022-09-09 11:04:02 -05:00
Colin Adler 4e26e325a6 feat: add auditing to user routes (#3961) 2022-09-08 21:16:16 -05:00
sharkymark c026464375 chore: add uninstall steps to remove a Coder OSS deployment from docs (#3742)
Co-authored-by: Ben <ben@coder.com>
2022-09-09 00:31:29 +00:00
Ben Potter 3610f09c77 chore: separate install docs (#3859) 2022-09-08 14:41:00 -05:00
Geoffrey Huntley d38e645492 housekeeping(welcome): notify employees when it is someones first PR (#3884) 2022-09-08 14:35:51 -05:00
Eric Paulsen 9c5b879b16 add: ECS example template (#3915)
* add: ECS example template

* fix: empty main.tf

* cleanup

* rm: cluster & compute

* set CPU & memory vars

Co-authored-by: Ben Potter <ben@coder.com>

Co-authored-by: Ben Potter <ben@coder.com>
2022-09-08 15:27:27 +00:00
Kyle Carberry 2c41343ce5 fix: Show audit log in production if allowed (#3960) 2022-09-08 14:58:53 +00:00
Colin Adler 7dc73ed6c6 feat: add description to audit log responses (#3949) 2022-09-08 09:36:34 -05:00
Kyle Carberry 5e04a2f800 chore: Remove DataDog test reporting (#3958)
It was costing a lot of money, and it wasn't being used very much.
2022-09-08 14:29:30 +00:00
Kyle Carberry e1afec6db4 fix: Optionally consume email_verified if it's provided (#3957)
This reduces our OIDC requirement claims to only `email`. If `email_verified`
is provided and is `false`, we will block authentication.

Fixes #3954.
2022-09-08 14:06:00 +00:00
Dean Sheather bb4a681833 fix: don't check buildinfo or entitlements in agent (#3956) 2022-09-08 23:59:28 +10:00
Dean Sheather 6a3876d6df chore: hide template check 404 error from develop.sh (#3942) 2022-09-08 15:22:08 +10:00
Kyle Carberry 8596023e31 chore: Update PR template to mention checking for docs (#3913)
This arose from a conversation Presley and I had about developers
maintaining docs, and that this little reminder could be useful!
2022-09-07 22:20:02 -05:00
Kyle Carberry 7718fa53c9 fix: Use a channel for bufferring tailnet connection updates (#3940) 2022-09-07 22:18:35 -05:00
Kyle Carberry 519d724ca4 fix: Sort resources by name (#3941)
Fixes #3489.
2022-09-08 03:16:26 +00:00
Ben Potter 332056af29 dogfood: remove folder from code-server (#3944) 2022-09-07 17:37:30 -05:00
Kyle Carberry 2b0fcf3ece fix: Show the users workspaces by default on coder ls (#3947)
Fixes #3945.
2022-09-07 17:30:49 -05:00
Kyle Carberry c8d9c44aba fix: Sort workspaces by last used then name (#3943) 2022-09-07 21:16:53 +00:00
Kyle Carberry f510f01768 fix: Require an argument for speedtest (#3946) 2022-09-07 21:10:17 +00:00
Presley Pizzo 2a085d1936 chore: refactor dialogs (#3935)
* Move dialogs

* Repurpose WorkspaceDeleteDialog

* Rename to DeleteDialog

Pausing on the typing part for now, leaving this as a refactor

* Rename handlers
2022-09-07 17:04:42 -04:00
dependabot[bot] 47ee44e5ca chore: bump msw from 0.45.0 to 0.47.0 in /site (#3917)
Bumps [msw](https://github.com/mswjs/msw) from 0.45.0 to 0.47.0.
- [Release notes](https://github.com/mswjs/msw/releases)
- [Changelog](https://github.com/mswjs/msw/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mswjs/msw/compare/v0.45.0...v0.47.0)

---
updated-dependencies:
- dependency-name: msw
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 20:58:30 +00:00
dependabot[bot] 9a07d5de6e chore: bump eslint-plugin-jest from 26.7.0 to 27.0.1 in /site (#3828)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 26.7.0 to 27.0.1.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v26.7.0...v27.0.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-jest
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 13:51:12 -07:00
Kyle Carberry 11abb85df5 fix: Rename IncludeProvisionerD to IncludeProvisionerDaemon in test
This was an artifact from merging!
2022-09-07 20:29:26 +00:00
Bruno Quaresma a00fdd699f feat: Add Audit page in the UI (#3782) 2022-09-07 17:26:12 -03:00
Joe Previte 1359850715 feat(cli): validate name length on template create (#3823)
* feat(cli): add template create validation test

This adds a test to validate that `template create` prints an error
message if called with a template name exceeding the 32-char limit.

* fixup

* fixup test

* feat(cli): add name validation to templatecreate

This adds a validation step to ensure the template name is less than 32
characters.

* fixup!: use utf8.RuneCountInString

* fixup!: remove pty from test
2022-09-07 15:01:18 -05:00
Kyle Carberry 720c9dadcf fix: Remove name from workspace builds (#3937)
Fixes #1561.
2022-09-07 19:49:57 +00:00
Colin Adler 762063ed8f fix: add avatar_url to user object in audit log response (#3939) 2022-09-07 19:22:04 +00:00
dependabot[bot] 87379f413f chore: bump @typescript-eslint/parser from 5.31.0 to 5.36.2 in /site (#3912)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.31.0 to 5.36.2.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.36.2/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 15:59:18 -03:00
dependabot[bot] c880263926 chore: bump eslint from 8.21.0 to 8.23.0 in /site (#3920)
Bumps [eslint](https://github.com/eslint/eslint) from 8.21.0 to 8.23.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.21.0...v8.23.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 15:58:58 -03:00
Dean Sheather a79e34c0c7 chore: build releases on a single Linux runner (switch to rcodesign) (#3890)
* chore: build, sign and notarize darwin binaries on linux

* chore: download rcodesign during release

* chore: change nfpm install to be a download instead of compile

* chore: delete apple cert secrets after build

* fix: fix dependencies in archive.sh and build_go.sh

* chore: reduce output from rcodesign
2022-09-07 18:56:46 +00:00
Spike Curtis ac279b3483 Add periods to end of license warning text. (#3933)
* Add periods to end of license warning text.

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix tests

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-09-07 17:27:42 +00:00
Spike Curtis d46b04cb1e Add Enterprise License text (#3932)
Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-09-07 16:55:57 +00:00
Dean Sheather 819622182b chore: parallel makefile attempt 3 (#3926)
* Revert "chore: Revert parallel Makefile builds (#3918)"

This reverts commit b077f71015.

* fix: fix release workflow with parallel makefile

* fix: mark generated files as fresh during releases
2022-09-08 02:40:17 +10:00
Colin Adler 3d6d51fbd0 feat: audit log api (#3898) 2022-09-07 16:38:19 +00:00
Jon Ayers ad24404018 fix: fix creating users with wrong login type (#3929) 2022-09-07 10:37:15 -05:00
Presley Pizzo 69f430257c chore: remove unused sql-formatter (#3903) 2022-09-07 11:06:43 -04:00
dependabot[bot] cd85be52de chore: bump eslint-import-resolver-typescript in /site (#3925)
Bumps [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) from 3.3.0 to 3.5.0.
- [Release notes](https://github.com/import-js/eslint-import-resolver-typescript/releases)
- [Changelog](https://github.com/import-js/eslint-import-resolver-typescript/blob/master/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-import-resolver-typescript/compare/v3.3.0...v3.5.0)

---
updated-dependencies:
- dependency-name: eslint-import-resolver-typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 11:06:01 -04:00
Kyle Carberry 3db927bc09 fix: Add contents permission for release CI (#3927) 2022-09-07 14:53:31 +00:00
Kyle Carberry 00104096c2 fix: Resolve CI flakes for tailnet agent (#3924) 2022-09-07 09:24:58 -05:00
dependabot[bot] 73ec618aff chore: bump @testing-library/react from 13.3.0 to 13.4.0 in /site (#3905)
Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 13.3.0 to 13.4.0.
- [Release notes](https://github.com/testing-library/react-testing-library/releases)
- [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/react-testing-library/compare/v13.3.0...v13.4.0)

---
updated-dependencies:
- dependency-name: "@testing-library/react"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 10:12:42 -04:00
Kyle Carberry f9ef4b148b fix: Add package write permission to releases (#3923) 2022-09-07 13:58:22 +00:00
Kyle Carberry 80352656e9 fix: Improve speedtest by adding direct connection toggle (#3919)
It's weird to test connection speeds over DERP, because most
connections will eventually migrate to direct.
2022-09-07 03:21:08 +00:00
dependabot[bot] 0f0e3d1068 chore: bump uuid from 8.3.2 to 9.0.0 in /site (#3914)
Bumps [uuid](https://github.com/uuidjs/uuid) from 8.3.2 to 9.0.0.
- [Release notes](https://github.com/uuidjs/uuid/releases)
- [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uuidjs/uuid/compare/v8.3.2...v9.0.0)

---
updated-dependencies:
- dependency-name: uuid
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-06 21:57:32 -05:00
Kyle Carberry b077f71015 chore: Revert parallel Makefile builds (#3918)
This was breaking the release process. Namely it was running
the `gen` targets due to the dependency tree, which was failing
on macOS and Linux runners. This revert can be reverted once
we fix that up.
2022-09-07 01:56:51 +00:00
Kyle Carberry d2e6f305b1 Lower protoc version requirement for easy CI install 2022-09-06 20:35:52 -05:00
Kyle Carberry 502a7370c8 Pin to a static version of protoc 2022-09-06 20:32:24 -05:00
Kyle Carberry d970d2d3da Install protoc in release build 2022-09-06 20:13:08 -05:00
Kyle Carberry bb17fe5398 Use go run when executing goimports in gen 2022-09-06 19:59:14 -05:00
Kyle Carberry 65d63f9167 Use go run for executing goimports 2022-09-06 19:53:39 -05:00
Bruno Quaresma b1bdf10e38 feat: Add table support and syntax highlights for markdowns (#3910) 2022-09-06 22:20:23 +00:00
Kyle Carberry dca24bd15d fix: Don't clear out peers that haven't connected yet (#3916)
This was causing parallel connections to fail, because they wouldn't
be established yet.
2022-09-06 21:27:59 +00:00
Joe Previte 18af9426c0 chore: add no implicit coercion eslint rule (#3909)
* chore: add no-implicit-coercion ESLint rule

This adds a new ESLint rule to prevent us from using implicit coercion
in the codebase. See https://eslint.org/docs/latest/rules/no-implicit-coercion

* chore: fix implicit coercion errors

* fixup: formatting
2022-09-06 21:27:10 +00:00
dependabot[bot] bb0e79eb88 chore: bump prettier-plugin-organize-imports in /site (#3891)
Bumps [prettier-plugin-organize-imports](https://github.com/simonhaenisch/prettier-plugin-organize-imports) from 3.0.0 to 3.1.1.
- [Release notes](https://github.com/simonhaenisch/prettier-plugin-organize-imports/releases)
- [Commits](https://github.com/simonhaenisch/prettier-plugin-organize-imports/compare/v3.0.0...v3.1.1)

---
updated-dependencies:
- dependency-name: prettier-plugin-organize-imports
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-06 17:21:16 -04:00
dependabot[bot] 5301d36027 chore: bump canvas from 2.9.3 to 2.10.0 in /site (#3904)
Bumps [canvas](https://github.com/Automattic/node-canvas) from 2.9.3 to 2.10.0.
- [Release notes](https://github.com/Automattic/node-canvas/releases)
- [Changelog](https://github.com/Automattic/node-canvas/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Automattic/node-canvas/compare/v2.9.3...v2.10.0)

---
updated-dependencies:
- dependency-name: canvas
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-06 13:47:12 -07:00
Andrei Kondratiev f5ba90b963 Home folder can be empty, so copying default bash settings (#3897) 2022-09-06 15:11:53 -05:00
dependabot[bot] 30ce62b5b4 chore: bump @playwright/test from 1.24.1 to 1.25.1 in /site (#3843)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.24.1 to 1.25.1.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.24.1...v1.25.1)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-06 15:07:48 -04:00
Spike Curtis a7cdec5d39 Feature server implementation (#3899)
* Feature server implementation

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix imports

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-09-06 18:59:10 +00:00
Dean Sheather 1b6f9e54a3 fix: fix ERRPIPE in scripts/lib.sh (#3908) 2022-09-07 04:42:45 +10:00
Kyle Carberry 3264960fb3 Change the primary UI font, darken the background, and show template icons for workspaces (#3863)
* Use darker colors in the dashboard

I think this looks a bit nicer. It's pretty subjective, but right now
we sit in-between a light and a dark mode, but more on the dark side.

This essentially transforms us into a dark mode.

* Add icons to workspaces rows and apge

* Add narrowed navbar to tighten up design

* Swap gray[3] for gray[4]
2022-09-06 18:26:36 +00:00
Bruno Quaresma 3c94ca9cbe fix: Skip empty values so Terraform can use the default value (#3902) 2022-09-06 15:15:19 -03:00
dependabot[bot] 94eb503aac chore: bump chromatic from 6.7.1 to 6.9.0 in /site (#3837)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.7.1 to 6.9.0.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.7.1...v6.9.0)

---
updated-dependencies:
- dependency-name: chromatic
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-06 14:05:13 -04:00
Dean Sheather 419d701927 chore: parallel builds with Makefile (#3854)
* Revert "revert: Makefile buff-ification (#3700) (#3848)"

This reverts commit e490bdd531.

* fix: fix slim targets in makefile

* fix: don't clobber slim binaries, make sure they're in the correct location
2022-09-06 17:27:06 +00:00
Ammar Bandukwala 4f0105ef7e feat: add orphan support (#3849)
* feat: add resource orphanage

* feat: deny custom state in build for regular users

* Minor protoc improvements
2022-09-06 17:07:00 +00:00
Bruno Quaresma 209e011404 fix: Escape # character on appName (#3895) 2022-09-06 15:16:03 +00:00
Presley Pizzo 1f55135765 Make color usage more consistent (#3842)
* Tweak overrides - should not cause visual change

* Use closest color for avatar

* Change hover color of contained buttons

* Change nav item color (matches avatar now)

* Format

* Use lighter border for contained button hover

This looks more clickable than lightening the background

* Delete unused component

* Make dropdown arrow consistent

Same up as down. Contrast text everywhere except nav, where it matches links and avatar.

* No need to fade right arrows

* Add hover color

* Consistent box shadows

* Format

* Delete unused DialogSearch

* Deleting unused button types to avoid confusion

* Use disabled arrow on disabled action buttons
2022-09-06 10:58:12 -04:00
dependabot[bot] 8e1dfc2763 chore: bump typescript from 4.7.4 to 4.8.2 in /site (#3836)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.7.4 to 4.8.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.7.4...v4.8.2)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bruno Quaresma <bruno@coder.com>
2022-09-06 14:15:29 +00:00
Geoffrey Huntley 1b56a8cccb docs(readme): use /chat link in the README.md (#3868) 2022-09-06 08:58:27 +00:00
dependabot[bot] e3bbc77c35 chore: bump google.golang.org/api from 0.90.0 to 0.94.0 (#3882)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.90.0 to 0.94.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.90.0...v0.94.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-05 18:02:17 -05:00
Kyle Carberry 1254e7a902 feat: Add speedtest command for tailnet (#3874) 2022-09-05 17:15:49 -05:00
Ammar Bandukwala 38825b9ab4 dogfood: keep image locally (#3878)
Avoid delete conflicts
2022-09-05 19:23:52 +00:00
Geoffrey Huntley d6812e0be8 housekeeping(codeowners): migrate to teams (#3867) 2022-09-05 13:38:29 -05:00
Kyle Carberry 2fa77a9bbd fix: Run status callbacks async to solve tailnet race (#3866) 2022-09-05 10:43:24 -05:00
Mathias Fredriksson 3ca6f1fcd4 fix: Prevent nil pointer deref in reconnectingPTY (#3871)
Related #3870
2022-09-05 16:45:10 +03:00
Ammar Bandukwala 1a5d3eace4 dogfood: dynamically pull image (#3864)
Previously, the template would never pull new image updates.
2022-09-04 21:06:36 +00:00
Kyle Carberry 00f05e798b Fix avatar_url dump.sql 2022-09-04 16:56:09 +00:00
Kyle Carberry d8f9537880 Fix avatar_url database type 2022-09-04 16:55:25 +00:00
Kyle Carberry 05e2806ff3 feat: Add profile pictures to OAuth users (#3855)
This supports GitHub and OIDC login for profile pictures!
2022-09-04 11:44:27 -05:00
Kyle Carberry 67c4605370 chore: Reduce test times (#3856)
* chore: Reduce test times

* Rename IncludeProvisionerD to IncludeProvisionerDaemon

* Make  TestTemplateDAUs use Tailnet
2022-09-04 11:28:09 -05:00
J Bruni 271d075667 Update Coder contact at ADOPTERS.md (#3861) 2022-09-04 09:15:25 -05:00
Ammar Bandukwala 0a7fad674a dogfood: remove github apt source (#3860) 2022-09-03 20:44:40 -05:00
Ammar Bandukwala 1b3e75c3ab add watchexec to dogfood image (#3858)
* add watchexec to dogfood image

This comes in handy quite frequently.

* Fix dogfood image
2022-09-03 18:38:13 -05:00
Geoffrey Huntley aae57476f1 docs(adopters): add ADOPTERS.md (#3825) 2022-09-03 06:18:04 +00:00
Geoffrey Huntley 0372586382 housekeeping(discord): use /chat instead of the discord.gg link (#3826) 2022-09-03 06:16:57 +00:00
Kyle Carberry a24f26c137 fix: Allow disabling built-in DERP server (#3852) 2022-09-02 23:47:25 +00:00
Kyle Carberry 4f4d470c7c feat: Add wireguard to port-forward (#3851)
This allows replacement of the WebRTC networking!
2022-09-02 18:26:01 -05:00
Ammar Bandukwala a09ffd6c0d feat: show better error on invalid template upload (#3847)
* feat: show better error on invalid template upload

* Fix tests
2022-09-02 22:48:40 +00:00
Kyle Carberry ac50070713 fix: Add omitempty for proper latency type (#3850)
This was causing an error on the frontend, because this value can be nil!
2022-09-02 22:05:27 +00:00
Kyle Carberry 2e1db6cc63 feat: Add latency indicator to the UI (#3846)
With Tailscale, we now get latency of all regions.
2022-09-02 20:09:05 +00:00
Kyle Carberry e490bdd531 revert: Makefile buff-ification (#3700) (#3848)
This caused the following issues:
- Slim binaries weren't being updated.
- The coder.tar.ztd was misplaced.
- There is no coder.sha1 file with proper filenames.

This should be reintroduced in a future change with those fixes.
2022-09-02 14:46:58 -05:00
Bruno Quaresma d350d9033c refactor: Remove extra line from table bottom (#3831) 2022-09-02 19:32:28 +00:00
Colin Adler ff0aa8d742 feat: add unique ids to all HTTP requests (#3845) 2022-09-02 13:04:29 -05:00
Kyle Carberry de219d966d fix: Run Tailnet SSH connections in a goroutine (#3838)
This was causing SSH connections in parallel to fail 🤦!
2022-09-02 11:58:15 -05:00
dependabot[bot] 3be7bb58b4 chore: bump @storybook/addon-essentials from 6.4.22 to 6.5.10 in /site (#3827)
Bumps [@storybook/addon-essentials](https://github.com/storybookjs/storybook/tree/HEAD/addons/essentials) from 6.4.22 to 6.5.10.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.10/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.10/addons/essentials)

---
updated-dependencies:
- dependency-name: "@storybook/addon-essentials"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-02 16:58:04 +00:00
Bruno Quaresma 6fe63ed358 refactor: Keep focused style when input is hovered (#3832) 2022-09-02 09:53:46 -07:00
Bruno Quaresma 5618640227 refactor: Remove duplicated title (#3829) 2022-09-02 16:49:41 +00:00
Colin Adler 55c13c8ff9 chore: fully implement enterprise audit pkg (#3821) 2022-09-02 16:42:28 +00:00
Dean Sheather fefdff4946 fix: install goimports in deploy build (#3841) 2022-09-03 02:38:33 +10:00
Dean Sheather e6699d25ca fix: fix CI calling script/version.sh instead of scripts (#3839) 2022-09-03 02:16:19 +10:00
Bruno Quaresma 8c70b6c360 refactor: Update table cell colors to match the ones in the Workspace (#3830)
page
2022-09-02 13:04:08 -03:00
Bruno Quaresma 21ae411237 refactor: Fix README spacing (#3833) 2022-09-02 13:03:59 -03:00
Bruno Quaresma b9e5cc97a1 refactor: Make user columns consistent (#3834) 2022-09-02 13:03:36 -03:00
dependabot[bot] f1976a086f chore: bump webpack-bundle-analyzer from 4.5.0 to 4.6.1 in /site (#3818)
Bumps [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) from 4.5.0 to 4.6.1.
- [Release notes](https://github.com/webpack-contrib/webpack-bundle-analyzer/releases)
- [Changelog](https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack-contrib/webpack-bundle-analyzer/compare/v4.5.0...v4.6.1)

---
updated-dependencies:
- dependency-name: webpack-bundle-analyzer
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-02 10:25:26 -05:00
dependabot[bot] e20ff62c9f chore: bump xstate from 4.32.1 to 4.33.5 in /site (#3817)
Bumps [xstate](https://github.com/statelyai/xstate) from 4.32.1 to 4.33.5.
- [Release notes](https://github.com/statelyai/xstate/releases)
- [Commits](https://github.com/statelyai/xstate/compare/xstate@4.32.1...xstate@4.33.5)

---
updated-dependencies:
- dependency-name: xstate
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-02 13:11:20 +00:00
dependabot[bot] afd6834ff7 chore: bump @typescript-eslint/eslint-plugin in /site (#3804)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.31.0 to 5.36.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.36.1/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-02 10:08:26 -03:00
Dean Sheather e1a4f3a16b Makefile buff-ification (#3700)
Remove old go_build_matrix and go_build_slim scripts in favor of full makefile-ification.
2022-09-02 12:58:23 +00:00
Dean Sheather 46bf265e9b fix: prevent running helm chart without valid tag (#3770)
Co-authored-by: Eric Paulsen <ericpaulsen@coder.com>
2022-09-02 21:01:30 +10:00
Mathias Fredriksson 4c18034260 fix: Prevent autobuild executor from slowing down API requests (#3726)
With just a few workspaces, the autobuild executor can slow down API
requests every time it runs. This is because we started a long running
transaction and checked all eligible (for autostart) workspaces inside
that transaction. PostgreSQL doesn't know if we're modifying rows and as
such is locking the tables for read operations.

This commit changes the behavior so each workspace is checked in its own
transaction reducing the time the table/rows needs to stay locked.

For now concurrency has been arbitrarily limited to 10 workspaces at a
time, this could be made configurable or adjusted as the need arises.
2022-09-02 13:24:47 +03:00
Ammar Bandukwala 3f73243b37 feat: improve formatting of last used (#3824) 2022-09-01 23:03:02 -05:00
Ammar Bandukwala 2d347657dc site: correct documentation on gitsshkey (#3690)
* site: correct documentation on gitsshkey

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>
2022-09-02 02:29:57 +00:00
Joe Previte 3c91b92930 docs: add comment to ResourceAvatar (#3822) 2022-09-01 18:16:20 -07:00
Ammar Bandukwala 04b03792cb feat: add last used to Workspaces page (#3816) 2022-09-02 00:08:51 +00:00
Garrett Delfosse 80e9f24ac7 feat: add loaders to ssh and terminal buttons (#3820) 2022-09-01 19:58:43 -04:00
Kyle Carberry be273a20a7 fix: Update Tailscale to add HTTP(s) latency reporting (#3819)
This was broken in Tailscale, and I'll be sending an upstream PR
to resolve it. See: https://github.com/coder/tailscale/commit/2c5af585574d4e1432f0d5dc9d02c63db3f497b0
2022-09-01 22:02:05 +00:00
dependabot[bot] 081259314b chore: bump cron-parser from 4.5.0 to 4.6.0 in /site (#3809)
Bumps [cron-parser](https://github.com/harrisiirak/cron-parser) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/harrisiirak/cron-parser/releases)
- [Commits](https://github.com/harrisiirak/cron-parser/compare/4.5.0...4.6.0)

---
updated-dependencies:
- dependency-name: cron-parser
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 21:25:53 +00:00
dependabot[bot] ff026d4890 chore: bump eslint-plugin-react from 7.30.1 to 7.31.1 in /site (#3806)
Bumps [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) from 7.30.1 to 7.31.1.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-react/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jsx-eslint/eslint-plugin-react/compare/v7.30.1...v7.31.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-react
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 14:20:08 -07:00
Kyle Carberry cde036c1ab fix: Update to Go 1.19 for releases (#3814) 2022-09-01 20:10:53 +00:00
Ammar Bandukwala 30f8fd9b95 Daily Active User Metrics (#3735)
* agent: add StatsReporter

* Stabilize protoc
2022-09-01 14:58:23 -05:00
Kyle Carberry e0cb52ceea fix: Use an unnamed region instead of erroring for DERP (#3810) 2022-09-01 18:43:52 +00:00
Presley Pizzo 5f0b13795a feat: make scrollbars match color scheme (#3807) 2022-09-01 14:28:18 -04:00
dependabot[bot] 1efcd33d63 chore: bump jest-runner-eslint from 1.0.0 to 1.1.0 in /site (#3799)
Bumps [jest-runner-eslint](https://github.com/jest-community/jest-runner-eslint) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/jest-community/jest-runner-eslint/releases)
- [Changelog](https://github.com/jest-community/jest-runner-eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/jest-runner-eslint/compare/v1.0.0...v1.1.0)

---
updated-dependencies:
- dependency-name: jest-runner-eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 14:26:45 -04:00
Presley Pizzo 6d95145d3b Feat: delete template button (#3781)
* Add api call

* Extract DropDownButton

* Start adding DropdownButton to Template page

* Move stories to dropdown button

* Format

* Update xservice to delete

* Deletion flow

* Format

* Move ErrorSummary for consistency

* RBAC (unfinished) and style tweak

* Format

* Test rbac

* Format

* Move ErrorSummary under PageHeader in workspace and template

* Format

* Replace hook with onBlur

* Make style arg optional

* Format
2022-09-01 14:24:14 -04:00
Kyle Carberry 6826b976d7 fix: Add latency-check for DERP over HTTP(s) (#3788)
* fix: Add latency-check for DERP over HTTP(s)

This fixes scenarios where latency wasn't being reported if
a connection had UDP entirely blocked.

* Add inactivity ping

* Improve coordinator error reporting consistency
2022-09-01 16:41:47 +00:00
dependabot[bot] f4c8bfdc18 chore: bump webpack-dev-server from 4.9.3 to 4.10.1 in /site (#3801)
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.9.3 to 4.10.1.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.9.3...v4.10.1)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 16:26:50 +00:00
dependabot[bot] 5b9573d7c1 chore: bump just-debounce-it from 3.0.1 to 3.1.1 in /site (#3800)
Bumps [just-debounce-it](https://github.com/angus-c/just) from 3.0.1 to 3.1.1.
- [Release notes](https://github.com/angus-c/just/releases)
- [Commits](https://github.com/angus-c/just/compare/just-debounce-it@3.0.1...just-pick@3.1.1)

---
updated-dependencies:
- dependency-name: just-debounce-it
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 09:15:42 -07:00
dependabot[bot] b57b8b887d chore: bump jest-websocket-mock from 2.3.0 to 2.4.0 in /site (#3797)
Bumps [jest-websocket-mock](https://github.com/romgain/jest-websocket-mock) from 2.3.0 to 2.4.0.
- [Release notes](https://github.com/romgain/jest-websocket-mock/releases)
- [Commits](https://github.com/romgain/jest-websocket-mock/compare/v2.3.0...v2.4.0)

---
updated-dependencies:
- dependency-name: jest-websocket-mock
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 09:14:57 -07:00
Mathias Fredriksson f4a78c976f docs: Update direnv docs for Nix and remove .envrc (#3790) 2022-09-01 20:24:08 +10:00
Kyle Carberry 567e750659 fix: Prepend STUN nodes for DERP (#3787)
This makes Tailscale prefer STUN over DERP when possible.
2022-09-01 02:21:21 +00:00
Kyle Carberry 9bd83e5ec7 feat: Add Tailscale networking (#3505)
* fix: Add coder user to docker group on installation

This makes for a simpler setup, and reduces the likelihood
a user runs into a strange issue.

* Add wgnet

* Add ping

* Add listening

* Finish refactor to make this work

* Add interface for swapping

* Fix conncache with interface

* chore: update gvisor

* fix tailscale types

* linting

* more linting

* Add coordinator

* Add coordinator tests

* Fix coordination

* It compiles!

* Move all connection negotiation in-memory

* Migrate coordinator to use net.conn

* Add closed func

* Fix close listener func

* Make reconnecting PTY work

* Fix reconnecting PTY

* Update CI to Go 1.19

* Add CLI flags for DERP mapping

* Fix Tailnet test

* Rename ConnCoordinator to TailnetCoordinator

* Remove print statement from workspace agent test

* Refactor wsconncache to use tailnet

* Remove STUN from unit tests

* Add migrate back to dump

* chore: Upgrade to Go 1.19

This is required as part of #3505.

* Fix reconnecting PTY tests

* fix: update wireguard-go to fix devtunnel

* fix migration numbers

* linting

* Return early for status if endpoints are empty

* Update cli/server.go

Co-authored-by: Colin Adler <colin1adler@gmail.com>

* Update cli/server.go

Co-authored-by: Colin Adler <colin1adler@gmail.com>

* Fix frontend entites

* Fix agent bicopy

* Fix race condition for the last node

* Fix down migration

* Fix connection RBAC

* Fix migration numbers

* Fix forwarding TCP to a local port

* Implement ping for tailnet

* Rename to ForceHTTP

* Add external derpmapping

* Expose DERP region names to the API

* Add global option to enable Tailscale networking for web

* Mark DERP flags hidden while testing

* Update DERP map on reconnect

* Add close func to workspace agents

* Fix race condition in upstream dependency

* Fix feature columns race condition

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-08-31 20:09:44 -05:00
Colin Adler 00da01fdf7 chore: rearrange audit logging code into enterprise folder (#3741) 2022-08-31 21:12:54 +00:00
Mickael 9583e16a05 Update community-templates.md (#3785)
added kubernetes dind template
2022-08-31 15:40:41 -05:00
Cian Johnston 5362f4636e feat: show agent version in UI and CLI (#3709)
This commit adds the ability for agents to set their version upon start.
This is then reported in the UI and CLI.
2022-08-31 16:33:50 +01:00
Steven Masley aa9a1c3f56 fix: Prevent suspending owners (#3757) 2022-08-31 15:26:36 +00:00
Joe Previte e6802f0a56 refactor: use WidgetsIcon for null resources (#3754)
* refactor: replace HelpIcon w/WidgetsIcon

Based on user feedback, we believe the `WidgetsIcon` will cause less
confusion.

* fixup

* refactor: clean up types in ResourceAvatar.tsx

Before, we were using `string` for `type` in `ResourceAvatar`. This
meant it wasn't tied to the types generated from the backend.

Now it imports `WorkspaceResource` so that there is a single source of
truth and they always stay in sync.
2022-08-31 07:44:20 -07:00
Muhammad Atif Ali 774d7588dd docs: Update community-templates.md (#3778)
Added docker based deep learning and matlab coder-templates
2022-08-31 12:04:16 +00:00
Michael Eanes 126d71f41d Remove alpha warning from about (#3774)
The doc was outdated; I don't think the software is alpha anymore.
2022-08-31 03:23:56 +00:00
Kyle Carberry 6644e951d8 fix: Scope error to test functions to fix TestFeaturesService race (#3765)
Fixes #3747.
2022-08-30 19:17:57 -05:00
Bruno Quaresma 02c0100d4d fix: Use a select when parameter input has many options (#3762) 2022-08-30 15:56:36 -07:00
Garrett Delfosse 01a06e1213 feat: Add dedicated labels to agent status and OS (#3759) 2022-08-30 19:18:10 +00:00
Kyle Carberry a410ac42f5 fix: Use first user for telemetry email (#3761)
This was causing other users email to be sent, which isn't desired.
2022-08-30 19:00:23 +00:00
Bruno Quaresma f037aad456 fix: Accepts empty string for the icon prop to remove it (#3760) 2022-08-30 18:48:03 +00:00
Mathias Fredriksson 1dc0485027 fix: Use smarter quoting for ProxyCommand in config-ssh (#3755)
* fix: Use smarter quoting for ProxyCommand in config-ssh

This change takes better into account how OpenSSH executes
`ProxyCommand`s and applies quoting accordingly.

This supercedes #3664, which was reverted.

Fixes #2853

* fix: Ensure `~/.ssh` directory exists
2022-08-30 21:08:20 +03:00
Bruno Quaresma 0708e37a38 feat: Sort templates by workspaces count (#3734) 2022-08-30 17:27:33 +00:00
Muhammad Atif Ali 190310464d Update username in connecting to a workspace documenation (using JetBrains Gateway) (#3746)
if someone is not using coder-provided templates, they might not have coder as a user name.
2022-08-30 16:18:04 +00:00
Eric Paulsen 8a60ee0391 add: code-server to template examples (#3739)
* add: code-server to template examples

* add: code-server to gcp templates

* add: code-server to gcp-linux template

* update: READMEs

* update: boot disk version

* update: google provider version
2022-08-30 10:55:40 -05:00
Geoffrey Huntley 20086c1e77 feat(devenv): use direnv to invoke nix-shell (#3745) 2022-08-30 02:33:11 +00:00
Eric Paulsen c4a9be9c41 update: google provider to latest (#3743)
* update: google provider to latest

* rm: code-server
2022-08-29 19:12:26 -05:00
Spike Curtis cc346afce6 Use licenses to populate the Entitlements API (#3715)
* Use licenses for entitlements API

Signed-off-by: Spike Curtis <spike@coder.com>

* Tests for entitlements API

Signed-off-by: Spike Curtis <spike@coder.com>

* Add commentary about FeatureService

Signed-off-by: Spike Curtis <spike@coder.com>

* Lint

Signed-off-by: Spike Curtis <spike@coder.com>

* Quiet down the logs

Signed-off-by: Spike Curtis <spike@coder.com>

* Tell revive it's ok

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-29 16:45:40 -07:00
Joe Previte 05f932b37e refactor(scripts): remove -P from ln calls (#3740) 2022-08-29 15:05:08 -07:00
Jon Ayers 053fe6ff61 feat: add panic recovery middleware (#3687) 2022-08-29 17:00:52 -05:00
Bruno Quaresma 3cf17d34e7 refactor: Redesign auth cli page and add workspaces link (#3737) 2022-08-29 16:57:54 -03:00
Spike Curtis 779c446a6e cli prints license warnings (#3716)
* cli prints license warnings

Signed-off-by: Spike Curtis <spike@coder.com>

* Satisfy the linter

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-29 11:30:06 -07:00
Bruno Quaresma 62f686c003 fix: Templates table columns width (#3731) 2022-08-29 14:49:04 -03:00
Colin Adler 6285d65b6a fix: remove (http.Server).ReadHeaderTimeout (#3730)
* fix: remove `(http.Server).ReadHeaderTimeout`

Fixes https://github.com/coder/coder/issues/3710. It caused some race
condition for websockets where the server sent the first message.

* comment why disabled
2022-08-29 12:07:49 -05:00
Kyle Carberry 611ca55458 fix: Use "data" scheme when creating parameters from the site (#3732)
Fixes #3691.
2022-08-29 16:32:57 +00:00
Steven Masley 34d902ebf1 fix: Fix properly selecting workspace apps by agent (#3684) 2022-08-29 08:56:52 -04:00
Mathias Fredriksson dc9b4155e0 feat: Generate DB unique constraints as enums (#3701)
* feat: Generate DB unique constraints as enums

This fixes a TODO from #3409.
2022-08-29 14:56:51 +03:00
Mathias Fredriksson f4c5020f63 fix: Print postgres-builtin-url to stdout without formatting (#3727)
This allows use-cases like `eval $(coder server postgres-builtin-url)`.
2022-08-29 11:37:18 +00:00
Dean Sheather b9b9c2fb9f fix: mount TLS secret in helm chart (#3717) 2022-08-27 15:03:10 +00:00
Garrett Delfosse ccabec6dd1 fi stop tracing 4xx http status codes as errors (#3707) 2022-08-26 15:18:42 +00:00
Spike Curtis 23f61fce2a CLI: coder licensese delete (#3699)
Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-26 08:15:46 -07:00
Mathias Fredriksson 98a6958f10 Revert "fix: Avoid double escaping of ProxyCommand on Windows (#3664)" (#3704)
This reverts commit 123fe0131e.
2022-08-26 17:52:25 +03:00
Mathias Fredriksson 6a00baf235 fix: Transform branch name to valid Docker tag for dogfood (#3703) 2022-08-26 17:38:40 +03:00
Mathias Fredriksson c8f8c95f6a feat: Add support for renaming workspaces (#3409)
* feat: Implement workspace renaming

* feat: Add hidden rename command (and data loss warning)

* feat: Implement database.IsUniqueViolation
2022-08-26 12:28:38 +03:00
Presley Pizzo 623fc5baac feat: condition Audit log on licensing (#3685)
* Update XService

* Add simple wrapper

* Add selector

* Condition page

* Condition link

* Format and lint

* Integration test

* Add username to api call

* Format

* Format

* Fix link name

* Upgrade xstate/react to fix crashing tests

* Fix tests

* Format

* Abstract strings

* Debug test

* Increase timeout

* Add comments and try shorter timeout

* Use PropsWithChildren

* Undo PropsWithChildren, try lower timeout

* Format, lower timeout
2022-08-25 19:20:31 -04:00
Spike Curtis ca3811499e DELETE license API endpoint (#3697)
* DELETE license API endpoint

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix new lint stuff

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-25 14:04:31 -07:00
Dean Sheather 14a9576b77 Auto import kubernetes template in Helm charts (#3550) 2022-08-26 05:32:35 +10:00
Joe Previte 94e96fa40b chore: enable react/no-array-index-key eslint (#3696)
* chore: enable react/no-array-index-key eslint

* fix: add missing key to ResourcesTable
2022-08-25 11:20:24 -07:00
Dean Sheather 8a446837d4 chore: remove exa -> ls and bat -> cat replacements from dogfood img (#3695) 2022-08-26 04:03:27 +10:00
Garrett Delfosse 7a77e55bd4 fix: match term color (#3694) 2022-08-25 16:34:37 +00:00
Garrett Delfosse b412cc1a4b fix: use correct response writer for tracing middle (#3693) 2022-08-25 11:24:43 -05:00
Mathias Fredriksson 78a24941fe feat: Add codersdk.NullTime, change workspace build deadline (#3552)
Fixes #2015

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-08-25 19:10:42 +03:00
Roman Zubov a21a6d2f4a docs: replaced manual up next blocks with doc tag in workspaces.md (#3023)
* docs: replaced manual up next blocks with doc tag in workspaces.md

* replaced up next blocks with <doc page=""> tags

* revert back to markdown

now that we updated how these links work, we can have them as markdown on github and as cards on the docs website.

Co-authored-by: Anton Korzhuk <antonkorzhuk@gmail.com>
2022-08-25 08:26:04 -07:00
Spike Curtis 4de1fc8339 CLI: coder licenses list (#3686)
* Check GET license calls authz

Signed-off-by: Spike Curtis <spike@coder.com>

* CLI: coder licenses list

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-25 08:24:39 -07:00
Garrett Delfosse a05fad4efd fix: stop tracing static file server (#3683) 2022-08-25 09:37:59 -04:00
Steven Masley 6e496077ae feat: Support search query and --me in workspace list (#3667) 2022-08-24 17:43:41 -04:00
Kira Pilot cf0d2c9bbc added react-i18next to FE (#3682)
* added react-i18next

* fixing typo

* snake case to camel case

* typo

* clearer error in catch block
2022-08-24 17:28:02 -04:00
Joe Previte e6b6b7f610 chore: upload playwright videos on failure (#3677) 2022-08-24 13:45:03 -07:00
Steven Masley 0b53b06fc6 chore: Make member role struct match site roles (#3671) 2022-08-24 15:58:57 -04:00
Spike Curtis 076c4a0aa8 Fix authz test for GET licenses (#3681)
Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-24 12:25:37 -07:00
Spike Curtis 9e35793b43 Enterprise rbac testing (#3653)
* WIP refactor Auth tests to allow enterprise

Signed-off-by: Spike Curtis <spike@coder.com>

* enterprise RBAC testing

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix import ordering

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-24 12:05:46 -07:00
Joe Previte 254e91a08f Update stale.yaml (#3674)
- remove close-issue-reason (only valid in 5.1.0)
- add days-before-issue-stale 30
2022-08-24 12:02:12 -07:00
Garrett Delfosse 5d7c4092ac fix: end long lived connection traces (#3679) 2022-08-24 14:57:31 -04:00
Spike Curtis c9bce19d88 GET license endpoint (#3651)
* GET license endpoint

Signed-off-by: Spike Curtis <spike@coder.com>

* SDK GetLicenses -> Licenses

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-24 18:44:22 +00:00
Kira Pilot da54874958 fixed users test (#3676) 2022-08-24 14:10:41 -04:00
Kira Pilot 57c202d112 Template settings fixes/kira pilot (#3668)
* using hours instead of seconds

* checking out

* added ttl tests

* added description validation  and tests

* added some helper text

* fix typing

* Update site/src/pages/TemplateSettingsPage/TemplateSettingsForm.tsx

Co-authored-by: Cian Johnston <cian@coder.com>

* ran prettier

* added ttl of 0 test

* typo

* PR feedback

Co-authored-by: Cian Johnston <cian@coder.com>
2022-08-24 14:07:56 -04:00
Garrett Delfosse 4e3b212707 make agent 'connecting' visually different from 'connected' (#3675) 2022-08-24 17:54:45 +00:00
Kyle Carberry 4f8270d95b fix: Exclude time column when selecting build log (#3673)
Closes #2962.
2022-08-24 12:04:33 -05:00
Garrett Delfosse 1400d7cd84 fix: correctly link agent name in app urls (#3672) 2022-08-24 16:49:03 +00:00
Eric Paulsen ca3c0490e0 chore: k8s example persistence & coder images (#3619)
* add: persistence & coder images

* add: code-server

* chore: README updates

* chore: README example
2022-08-24 11:23:02 -05:00
Mathias Fredriksson 123fe0131e fix: Avoid double escaping of ProxyCommand on Windows (#3664)
Fixes #2853
2022-08-24 19:12:40 +03:00
Kyle Carberry 09142255e6 fix: Add consistent use of coder templates init (#3665)
Closes #2303.
2022-08-24 11:40:36 -04:00
Kyle Carberry 706bceb7e7 fix: Remove reference to coder rebuild command (#3670)
Closes #2464.
2022-08-24 15:35:46 +00:00
Cian Johnston eba753ba87 fix: template: enforce bounds of template max_ttl (#3662)
This PR makes the following changes:

- enforces lower and upper limits on template `max_ttl_ms`
- adds a migration to enforce 7-day cap on `max_ttl`
- allows setting template `max_ttl` to 0
- updates template edit CLI help to be clearer
2022-08-24 15:45:14 +01:00
Mathias Fredriksson 343d1184b2 fix: Clean up coder config-ssh dry-run behavior (#3660)
This commit also drops old deprecated code.

Fixes #2982
2022-08-24 16:58:46 +03:00
Mathias Fredriksson 7a71180ae6 chore: Enable comments for database dump / models (#3661) 2022-08-24 12:44:30 +00:00
Ammar Bandukwala 253e6cbffa web: fix template permission check (#3652)
Resolves #3582
2022-08-23 23:44:32 +00:00
Spike Curtis 184f0625e1 coder licenses add CLI command (#3632)
* coder licenses add CLI command

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix up lint

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix t.parallel call

Signed-off-by: Spike Curtis <spike@coder.com>

* Code review improvements

Signed-off-by: Spike Curtis <spike@coder.com>

* Lint

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-23 13:55:39 -07:00
Cian Johnston 6dacf70898 fix: disable AccountForm when user is not allowed edit users (#3649)
* RED: add unit tests for AccountForm username field
* GREEN: disable username field and button on account form when user edits are not allowed

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-08-23 20:19:26 +00:00
Garrett Delfosse b9dd566804 fix scrollbar on ssh key view (#3647) 2022-08-23 15:22:42 -04:00
Mathias Fredriksson e44f7adb7e feat: Set SSH env vars: SSH_CLIENT, SSH_CONNECTION and SSH_TTY (#3622)
Fixes #2339
2022-08-23 21:19:57 +03:00
Garrett Delfosse 9c0cd5287c fix: clarify we download templates on template select (#3296)
Co-authored-by: Joe Previte <jjprevite@gmail.com>
Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
2022-08-23 17:30:46 +00:00
Mathias Fredriksson 5025fe2fa0 fix: Protect circular buffer during close in reconnectingPTY (#3646) 2022-08-23 16:07:31 +00:00
Presley Pizzo 49de44c76d feat: Add LicenseBanner (#3568)
* Extract reusable Pill component

* Make icon optional

* Get pills in place

* Rough styling

* Extract Expander component

* Fix alignment

* Put it in action - type error

* Hide banner by default

* Use generated type

* Move PaletteIndex type

* Tweak colors

* Format, another color tweak

* Add stories

* Add tests

* Update site/src/components/Pill/Pill.tsx

Co-authored-by: Kira Pilot <kira@coder.com>

* Update site/src/components/Pill/Pill.tsx

Co-authored-by: Kira Pilot <kira@coder.com>

* Comments

* Remove empty story, improve empty test

* Lint

Co-authored-by: Kira Pilot <kira@coder.com>
2022-08-23 11:26:22 -04:00
Mathias Fredriksson f7ccfa2ab9 feat: Set CODER=true in workspaces (#3637)
Fixes #2340
2022-08-23 14:29:01 +03:00
Colin Adler 8343a4f199 chore: cleanup go.mod (#3636) 2022-08-22 22:40:11 -05:00
Jon Ayers a7b49788f5 chore: deduplicate OAuth login code (#3575) 2022-08-22 18:13:46 -05:00
Ammar Bandukwala a07ca946c3 Increase default auto-stop to 12h (#3631)
Resolves #3462.

And, clarify language to resolve #3509.
2022-08-22 17:24:15 -05:00
Ben Potter 8ca3fa9712 fix: use hardcoded "coder" user for AWS and Azure (#3625) 2022-08-22 22:19:30 +00:00
Spike Curtis b101a6f3f4 POST license API endpoint (#3570)
* POST license API

Signed-off-by: Spike Curtis <spike@coder.com>

* Support interface{} types in generated Typescript

Signed-off-by: Spike Curtis <spike@coder.com>

* Disable linting on empty interface any

Signed-off-by: Spike Curtis <spike@coder.com>

* Code review updates

Signed-off-by: Spike Curtis <spike@coder.com>

* Enforce unique licenses

Signed-off-by: Spike Curtis <spike@coder.com>

* Renames from code review

Signed-off-by: Spike Curtis <spike@coder.com>

* Code review renames and comments

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-22 15:02:50 -07:00
dependabot[bot] 85acfdf0dc chore: bump msw from 0.44.2 to 0.45.0 in /site (#3629)
Bumps [msw](https://github.com/mswjs/msw) from 0.44.2 to 0.45.0.
- [Release notes](https://github.com/mswjs/msw/releases)
- [Changelog](https://github.com/mswjs/msw/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mswjs/msw/compare/v0.44.2...v0.45.0)

---
updated-dependencies:
- dependency-name: msw
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-22 16:56:39 -04:00
Ammar Bandukwala 2ee6acb2ad Upgrade frontend to React 18 (#3353)
Co-authored-by: Kira Pilot <kira.pilot23@gmail.com>
2022-08-22 15:42:06 -05:00
Ammar Bandukwala 6fde537f9c web: use seconds in max TTL input (#3576)
Milliseconds are more difficult to deal with due to
all of the zeros.

Also, describe this feature as "auto-stop" to be
consistent with our Workspace page UI and CLI. "ttl"
is our backend lingo which should eventually be updated.
2022-08-22 20:35:17 +00:00
Ammar Bandukwala 5e36be8cbb docs: remove architecture diagram (#3615)
The diagram was more confusion than helpful.
2022-08-22 10:56:10 -05:00
Kyle Carberry 58d29264aa feat: Add template icon to the workspaces page (#3612)
This removes the last built by column from the page. It seemed
cluttered to have both on the page, and is simple enough to
click on the workspace to see additional info.
2022-08-22 09:42:11 -05:00
Dean Sheather 369a9fb535 fix: add writeable home dir to docker image (#3603) 2022-08-22 19:43:13 +10:00
Eric Paulsen 68e17921f0 fix: tooltip 404 (#3618) 2022-08-21 18:50:36 -05:00
Kyle Carberry b0fe9bcdd1 chore: Upgrade to Go 1.19 (#3617)
This is required as part of #3505.
2022-08-21 22:32:53 +00:00
Ammar Bandukwala d37fb054c8 docs: outdent remote desktop docs (#3614)
Resolves #3590
2022-08-21 01:59:40 +00:00
Bruno Quaresma 54b8e794ce feat: Add emoji picker for template icons (#3601) 2022-08-19 16:42:05 -04:00
Bruno Quaresma a4c90c591d feat: Add icon to the template page (#3604) 2022-08-19 15:37:16 -03:00
Spike Curtis 690e6c6585 Check AGPL code doesn't import enterprise (#3602)
* Check AGPL code doesn't import enterprise

Signed-off-by: Spike Curtis <spike@coder.com>

* use error/log instead of echo/exit

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-19 17:49:08 +00:00
Joe Previte 91bfcca287 fix(ui): decrease WorkspaceActions popover padding (#3555)
There was too much padding on the WorkspaceActions dropdown. This fixes
that.
2022-08-19 09:58:31 -07:00
Bruno Quaresma c14a4b92ed feat: Display and edit template icons in the UI (#3598) 2022-08-19 13:09:07 -03:00
Joe Previte e938e8577f fix: add missing && \ in Dockerfile (#3594)
* fix: add missing && \ in Dockerfile

* fixup: add goboring after PATH goboring
2022-08-19 15:41:17 +00:00
Kyle Carberry 985eea6099 fix: Update icon when metadata is changed (#3587)
This was causing names to become empty! Fixes #3586.
2022-08-19 10:11:54 -05:00
Joe Previte c417115eb1 feat: add cmake, nfpm to dogfood dockerfile (#3558)
* feat: add cmake, nfpm to dogfood dockerfile

* fixup: formatting

* Update dogfood/Dockerfile

Co-authored-by: Cian Johnston <cian@coder.com>

Co-authored-by: Cian Johnston <cian@coder.com>
2022-08-19 15:10:56 +00:00
Mathias Fredriksson 544bf01fbb chore: Update coder/coder provider in example templates (#3581)
Additionally, a convenience script was added to
`examples/update_template_versions.sh` to keep the templates up-to-date.

Fixes #2966
2022-08-19 17:18:11 +03:00
Bruno Quaresma 80f042f01b feat: Add icon to templates (#3561) 2022-08-19 13:17:35 +00:00
Cian Johnston 57f3410009 cli: remove confirm prompt when starting a workspace (#3580) 2022-08-19 11:08:56 +01:00
Mathias Fredriksson 3fdae47b87 fix: Shadow err in TestProvision_Cancel to fix test race (#3579)
Fixes #3574
2022-08-19 11:56:28 +03:00
Eric Paulsen 4ba3573632 fix: quickstart 404 (#3564) 2022-08-18 18:47:12 -05:00
Jon Ayers f6b0835982 fix: avoid processing updates to usernames (#3571)
- With the support of OIDC we began processing updates to a user's
  email and username to stay in sync with the upstream provider. This
  can cause issues in templates that use the user's username as a stable
  identifier, potentially causing the deletion of user's home volumes.
- Fix some faulty error wrapping.
2022-08-18 17:56:17 -05:00
Cian Johnston 04c5f924d7 fix: ui: workspace bumpers now honour template max_ttl (#3532)
- chore: WorkspacePage: invert workspace schedule bumper logic for readibility
- fix: make workspace bumpers honour template max_ttl
- chore: refactor workspace schedule bumper logic to util/schedule.ts and unit test separately
2022-08-18 23:32:23 +01:00
Bruno Quaresma 7599ad4bf6 feat: Add template settings page (#3557) 2022-08-18 16:58:01 -03:00
Joe Previte aabb72783c docs: update CONTRIBUTING requirements (#3541)
* docs: update CONTRIBUTING requirements

* Update docs/CONTRIBUTING.md

* refactor: remove dev from Makefile

* fixup: add linux section
2022-08-18 17:11:58 +00:00
Dean Sheather 55890df6f1 feat: add helm README, install guide, linters (#3268) 2022-08-19 02:41:23 +10:00
Dean Sheather 3610402cd8 Use new table formatter everywhere (#3544) 2022-08-19 02:41:00 +10:00
Kyle Carberry c43297937b feat: Add Kubernetes and resource metadata telemetry (#3548)
Fixes #3524.
2022-08-18 15:57:46 +00:00
Mathias Fredriksson f1423450bd fix: Allow terraform provisions to be gracefully cancelled (#3526)
* fix: Allow terraform provisions to be gracefully cancelled

This change allows terraform commands to be gracefully cancelled on
Unix-like platforms by signaling interrupt on provision cancellation.

One implementation detail to note is that we do not necessarily kill a
running terraform command immediately even if the stream is closed. The
reason for this is to allow for graceful cancellation even in such an
event. Currently the timeout is set to 5 minutes by default.

Related: #2683

The above issue may be partially or fully fixed by this change.

* fix: Remove incorrect minimumTerraformVersion variable

* Allow init to return provision complete response
2022-08-18 17:03:55 +03:00
Mathias Fredriksson 6a0f8ae9cc fix: Add SIGHUP and SIGTERM handling to coder server (#3543)
* fix: Add `SIGHUP` and `SIGTERM` handling to `coder server`

To prevent additional signals from aborting program execution, signal
handling was moved to the beginning of the main function, this ensures
that signals stays registered for the entire shutdown procedure.

Fixes #1529
2022-08-18 16:25:32 +03:00
Jon Ayers 380022fe63 fix: update oauth token on each login (#3542) 2022-08-17 23:06:03 -05:00
Jon Ayers c3eea98db0 fix: use unique ID for linked accounts (#3441)
- move OAuth-related fields off of api_keys into a new user_links table
- restrict users to single form of login
- process updates to user email/usernames for OIDC
- added a login_type column to users
2022-08-17 18:00:53 -05:00
Cian Johnston 53d1fb36db update-alternatives to ensure gofmt is goboring gofmt (#3540) 2022-08-17 20:03:44 +00:00
whitney-coder d6351a6b9f Update README.md (#3539)
Minor grammatical change on line 14
2022-08-17 14:48:41 -05:00
Bruno Quaresma 546157b63e feat: Make template name editable (#3538) 2022-08-17 19:04:00 +00:00
Kira Pilot 4b646cc4fa fix: hiding agent status on stopped workspaces (#3512)
* hiding agent status on a stopped workspaace

resolves #3484

* run prettier and lint

* Update site/src/components/Resources/Resources.tsx

Co-authored-by: Joe Previte <jjprevite@gmail.com>

* running prettier

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-08-17 14:37:54 -04:00
Spike Curtis acd0cd66f6 coder features list CLI command (#3533)
* AGPL Entitlements API

Signed-off-by: Spike Curtis <spike@coder.com>

* Generate typesGenerated.ts

Signed-off-by: Spike Curtis <spike@coder.com>

* AllFeatures -> FeatureNames

Signed-off-by: Spike Curtis <spike@coder.com>

* Features CLI command

Signed-off-by: Spike Curtis <spike@coder.com>

* Validate columns

Signed-off-by: Spike Curtis <spike@coder.com>

* Tests for features list CLI command

Signed-off-by: Spike Curtis <spike@coder.com>

* Drop empty EntitlementsRequest

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix dump.sql generation

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-17 11:26:16 -07:00
Spike Curtis 5c898d0c83 Fix archive.sh for LICENSE files (#3535)
Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-17 10:27:52 -07:00
Kyle Carberry c3f946737c fix: Strip session_token cookie from app proxy requests (#3528)
Fixes coder/security#1.
2022-08-17 17:09:45 +00:00
Noah Huppert 000e1a5ef2 Fixed env block in Emacs IDE docs (#3534) 2022-08-17 16:30:45 +00:00
Dean Sheather a872330a8d feat: add generic table formatter (#3415) 2022-08-18 02:28:22 +10:00
Spike Curtis b1b2d1b2b2 AGPL Entitlements API (#3523)
* AGPL Entitlements API

Signed-off-by: Spike Curtis <spike@coder.com>

* Generate typesGenerated.ts

Signed-off-by: Spike Curtis <spike@coder.com>

* AllFeatures -> FeatureNames

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-17 09:02:36 -07:00
Spike Curtis 5817c6ac7f Build enterprise coder binary by default (#3517)
* Build enterprise coder binary by default

Signed-off-by: Spike Curtis <spike@coder.com>

* Add --agpl to develop.sh

Signed-off-by: Spike Curtis <spike@coder.com>

* Add --agpl flag to archive.sh

Signed-off-by: Spike Curtis <spike@coder.com>

* shell format

Signed-off-by: Spike Curtis <spike@coder.com>

* Move AGPL back to LICENSE, explain enterprise license is forthcoming

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-17 09:02:25 -07:00
Steven Masley 4be61d9250 fix: Role assign ui fixes (#3521)
Co-authored-by: Kira Pilot <kira@coder.com>
2022-08-16 10:39:42 -05:00
Ben Potter 4b6a82f92a chore: rename to "template push" in docs (#3525) 2022-08-16 14:52:31 +00:00
Steven Masley 01dd35f1ba chore: Rename 'admin' to 'owner' (#3498)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-08-15 14:40:19 -05:00
Steven Masley 2306d2c709 chore: Fix misspelled "referrer" in site.go (#3507) 2022-08-15 14:12:34 +00:00
Mathias Fredriksson e749070193 chore: Update readme with note about embedded database (#3488) 2022-08-15 12:32:22 +03:00
Jon Ayers 301727d1fc chore: improve dump error output (#3499)
* chore: improve dump error output

- Properly report the error that occurs during the DB connection retry
  loop.
- Fail fatally if migration is unsuccessful.
2022-08-12 22:15:13 -05:00
Ammar Bandukwala 8cf82112ad docs: document additional roles (#3496)
Co-authored-by: Steven Masley <stevenmasley@coder.com>
2022-08-12 22:42:16 +00:00
Steven Masley 40e68cb80b feat: Add template-admin + user-admin role for managing templates + users (#3490)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-08-12 17:27:48 -05:00
Bruno Quaresma c41261cf6e fix: Remove unexpected break lines when copy logs (#3492) 2022-08-12 19:18:41 +00:00
Bruno Quaresma 351d55e1f4 chore: Minor table design changes (#3494) 2022-08-12 16:18:03 -03:00
Kyle Carberry 3b951f77fb fix: Unskip SuspendAnotherUser test (#3430)
It wasn't clear why this was skipped, it seems accidental.
2022-08-12 19:12:44 +00:00
Oxylibrium 0a46b1e59d chore: remove swr and dead code (#3495) 2022-08-12 15:06:40 -04:00
Mathias Fredriksson 010f64e8e9 fix: Enable goleak for cli tests (#3370) 2022-08-12 21:02:10 +03:00
Bruno Quaresma 0e8c68ebc5 chore: Increase border radius (#3493) 2022-08-12 14:58:14 -03:00
Muhammad Atif Ali c3fcf7c953 chore: renamed coder template edit flags in coder CLI (#3471)
Use `-` over `_` for cli flags
2022-08-12 10:21:42 -05:00
Kyle Carberry b3d3b8ba0f fix: Stop multiple buttons from compounding in the workspace action dropdown (#3482)
The variadic function on an object doesn't clone the inner array.

This was causing the `secondary` property to accumulate more and
more button types as time went on!

Fixes #3154.
2022-08-12 13:19:52 +00:00
Kyle Carberry 16c12e976e chore: Improve agent logging (#3483) 2022-08-12 07:01:00 -05:00
Kyle Carberry ca342067b3 fix: Remove typo in policy.rego 2022-08-11 23:33:50 -05:00
Ammar Bandukwala d7b96f7d58 Correct spelling of macOS (#3478)
* Correct spelling of macOS

* fixup! Correct spelling of macOS

* fixup! Correct spelling of macOS
2022-08-11 21:22:06 -04:00
Jon Ayers 923c212960 chore: add zstd to dogfood image (#3479) 2022-08-11 17:48:49 -05:00
Steven Masley 3ae42f4de9 chore: Update rego to be partial execution friendly (#3449)
- Improves performance of batch authorization calls
- Enables possibility to convert rego auth calls into SQL WHERE clauses
2022-08-11 22:07:48 +00:00
Bruno Quaresma 4a17e0d91f feat: Add setup page (#3476) 2022-08-11 17:22:46 +00:00
Sagar Vora 604f211674 fix: replace broken link with Github contributors graph (#3472) 2022-08-11 14:35:51 +00:00
Kira Pilot 6122df6f1f feature: gate audit log by permissions (#3464)
* pairing

* restricting audit route

resolvees #3460

* updated tests

* fixing lint

* useSelector instead of useActor
2022-08-11 09:34:45 -04:00
Ammar Bandukwala 4e6645af50 docs: outdent generic quickstart (#3467) 2022-08-10 21:53:35 -05:00
Jon Ayers 426b30ed16 fix: add missing dependencies to dogfood image (#3470) 2022-08-11 01:24:56 +00:00
Eric Paulsen 272962cfae docs: add upgrade page & update getting started (#3439) 2022-08-10 17:56:21 -05:00
Presley Pizzo 5d40b1f0f4 feat: Add switches for auto-start and auto-stop (#3358)
* Add elements

* Add Loading story

* Make form show empty values when manual

* Make form depend on switches

* Fix style

* Format

* Update unit tests

* Tweaks

* Update storybook

* Move util files

* Pull out more util functions

* Pull out strings

* Add border to section

* Make min ttl 1

* Format

* Fix import

* Fix validation for falsey values

* Format and fix tests

* Put switches in form, persist form state

* Fix bug

* Remove helper text when disabled

* Fix storybook

* Revert "Remove helper text when disabled"

This reverts commit a6271ca6c4.

* Format

* Use nicer function to set values

* Format
2022-08-10 22:03:15 +00:00
Ben Potter cee0d1f848 chore: add metadata to example templates (#3451) 2022-08-10 16:34:17 -05:00
Mathias Fredriksson 95f26f74b6 fix: Close response body in cli server test (#3459) 2022-08-10 16:30:46 +00:00
Kyle Carberry d6d9cf9b30 fix: Downgrade embedded PostgreSQL (#3453)
This was causing a new data path to occur, which broke existing installs.
It needs to use the same path and upgrade instead.
2022-08-10 10:08:24 -05:00
Kyle Carberry fd73d6dd0d fix: Reduce variables needed for Docker template (#3442)
* fix: Reduce variables needed for Docker template

This should make initial setup a bit simpler!

* Fix for M2 Macbooks

PostgreSQL 13 doesn't support the M series architecture.

* Fix name <-> id swap

* Update Docker provider to remove host requirement

Co-authored-by: Kyle Carberry <kyle@air.local>
2022-08-10 14:45:05 +00:00
Bruno Quaresma 758eb21b36 feat: Support booleans for parameters input (#3437) 2022-08-10 10:41:26 -03:00
Ammar Bandukwala f28cd15706 docs: remove incorrect SSH key info (#3448) 2022-08-09 22:15:18 -05:00
Ammar Bandukwala 3ceee76784 docs: explain resource metadata (#3447) 2022-08-09 20:21:26 -05:00
Ammar Bandukwala c73f708678 docs: remove configuring prefix from IDEs (#3446) 2022-08-09 20:10:09 -05:00
Ammar Bandukwala 815bf1b668 docs: fix IDE icon (#3445) 2022-08-09 20:07:51 -05:00
Ammar Bandukwala 88c9f31007 docs: explain how to display secrets (#3443) 2022-08-09 23:45:30 +00:00
Ammar Bandukwala fd59e2e812 add metadata to dogfood template (#3444) 2022-08-09 23:40:12 +00:00
Steven Masley db665e7261 chore: Drop resource_id support in rbac system (#3426) 2022-08-09 18:16:53 +00:00
Mathias Fredriksson ccf6f4e7ed chore: Use contexts with timeout in coderd tests (#3381) 2022-08-09 20:17:00 +03:00
Bruno Quaresma 690ba661a7 feat: Add metadata support to the UI (#3431) 2022-08-09 16:49:06 +00:00
Kyle Carberry 53400c6205 fix: Check if an API error has data before checking the message (#3427)
This was causing the app to crash with an error. I found this manually
by looking through the obfuscated sources in DevTools. It's a
data-point for #3425 though!
2022-08-09 14:26:18 +00:00
Kyle Carberry e1da2b6467 fix: Don't fetch resources when a workspace is building (#3424)
Fixes #3423.
2022-08-09 14:07:01 +00:00
Mathias Fredriksson c0cc8b9935 fix: Improve friendly validation error messages (#3390)
* fix: Add validations to `(*codersdk.Error).Friendly`

* fix: Add named validators for template and workspace name
2022-08-09 14:25:23 +03:00
Kyle Carberry f62e1ede77 feat: Add support for GitHub Enterprise authentication (#3422)
This was manually tested with GitHub Enterprise v3.6.0-rc1.
2022-08-08 20:49:51 -05:00
Kyle Carberry 7bdb8ff9cf feat: Add workspace metrics export to Prometheus (#3421)
This adds workspace totals indexed by status. It could be any
codersdk.ProvisionerJobStatus.
2022-08-09 01:08:42 +00:00
Kira Pilot e62677efab feat: add audit page title, subtitle, and CLI snippet (#3419)
* resolves #3356

* scaffolded out new audit page header

resolves #3357

* added tests and stories

* run prettier
2022-08-08 21:08:36 -04:00
Spike Curtis 049e7cb5df azure-linux example template (#3348)
* azure-linux example template

Signed-off-by: Spike Curtis <spike@coder.com>

* Use azurerm_linux_virtual_machine and wait for attachment

Signed-off-by: Spike Curtis <spike@coder.com>

* Use azure-instance-identity

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-08 15:25:20 -07:00
Kyle Carberry a848e71f58 fix: Make the twitter handle lowercase in README (#3413)
The uppercase was bothering...
2022-08-08 13:17:38 -05:00
Kyle Carberry 42bac09c1a fix: Sort workspace agents by name (#3407)
Fixes #2778.
2022-08-08 12:25:29 -05:00
Kyle Carberry d275e52a41 fix: Add godoc badge to README (#3412)
This helps allude to the idea that Coder provides an API as
seen in #3411.

This also fixes the codecov badge from always being red ;p
2022-08-08 12:16:40 -05:00
Kira Pilot eb7d947d10 resolves #3356 (#3408) 2022-08-08 12:23:01 -04:00
Kyle Carberry 9c12b4ed8e chore: Add nix shell for simple development setup (#3399)
* chore: Add nix shell for simple development setup

This enables contributors using Nix to set up their environment with ease.

* improve nix style, flake output schema

* fix error message

* Update scripts/build_go_slim.sh

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update scripts/build_go_slim.sh

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Add UTC default for timezone and remove unnecessary goreleaser dependency

* Skip TZ test if localtime does not exist

Co-authored-by: Charlie Moog <moogcharlie@gmail.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-08-08 15:49:12 +00:00
Kyle Carberry 3279504cbe feat: Add active users prometheus metric (#3406)
This  allows deployments using our Prometheus export t determine
the number of active users in the past hour.

The interval is an hour to align with API key last used refresh times.

SSH connections poll to check shutdown time, so this will be accurate
even on long-running connections without dashboard requests.
2022-08-08 10:09:46 -05:00
Ammar Bandukwala 13a2014d7f docs: fix up port-forwarding (#3403)
- Improve English
- Make new page live in manifest.json
- Add icon
- Outdent page to root
2022-08-07 22:22:47 +00:00
mark-theshark 8d4b6086f6 chore: docs: add port-forwarding options (CLI & ssh) (#3394)
* chore: docs: add port-forwarding options

* fix: code type

Co-authored-by: Eric Paulsen <eric@Erics-MacBook-Air.local>
2022-08-07 17:30:15 -04:00
mark-theshark 44a826dc06 docs: fix address specification in Docker quickstart (#3396) 2022-08-07 14:52:55 -05:00
Mathias Fredriksson 1fb274cbda fix: Disallow args for config-ssh subcommand in cli (#3393) 2022-08-06 20:56:42 +03:00
Mathias Fredriksson b10a1b84e5 fix: Fix close in pty and ptytest (#3392) 2022-08-05 21:31:54 +03:00
Ben Potter f14efd1a2b chore: alphabetize template list (#3363) 2022-08-05 13:03:22 -05:00
Cian Johnston 854bb5dbeb fix: post-hoc testutil fix (#3391) 2022-08-05 16:09:20 +00:00
Abhineet Jain e7bc01383c fix: handle workspace errors (#3341) 2022-08-05 10:38:07 -05:00
Cian Johnston 01fe5e668e chore: add testutil.Eventually and friends (#3389)
This PR adds a `testutil` function aimed to replace `require.Eventually`.

Before:
```go
require.Eventually(t, func() bool { ... }, testutil.WaitShort, testutil.IntervalFast)
```

After:
```go
require.True(t, testutil.EventuallyShort(t, func(ctx context.Context) bool { ... }))

// or the full incantation if you need more control
ctx, cancel := context.WithTimeout(ctx.Background(), testutil.WaitLong)
require.True(t, testutil.Eventually(t, ctx, func(ctx context.Context) bool { ... }, testutil.IntervalSlow))
```

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-08-05 16:34:44 +01:00
Mathias Fredriksson 46d64c624a fix: Add ps.Kill/Wait to test cleanup in ptytest.Start (#3387) 2022-08-05 13:35:33 +03:00
Mathias Fredriksson fb9fca8bc9 fix: Ensure terraform tests have a cache path and logger (#3161)
* fix: Ensure terraform tests have a cache path and logger

* fix: Protect against concurrent `terraform init`
2022-08-04 20:37:07 +03:00
Kyle Carberry ad20b23178 fix: Move state pull output to stdout (#3382)
* fix: Move state pull output to stdout

Fixes #1645.

* Update cli/state.go

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>
2022-08-04 15:33:59 +00:00
Kyle Carberry 303b280e0e fix: Associate spot instances with their instance IDs for auth (#3383)
Fixes #2162.
2022-08-04 10:20:56 -05:00
Ben Potter 075454cce8 chore: use consistent button type for settings (#3362) 2022-08-04 10:15:35 -05:00
David Wahler 9f54fa8e52 Make gcp-linux example template use a non-root user (#2480)
* make gcp-linux example template use a non-root user

* don't try to create user account if it already exists

* upgrade to debian-10 image since debian-9 is no longer available
2022-08-03 18:07:10 -05:00
Ben Potter fd4e2cc331 chore: improve contrast for terminal overlay (#3375) 2022-08-03 15:39:38 -05:00
Ammar Bandukwala 8a4438895b Add fish to dogfood (#3373) 2022-08-03 18:21:34 +00:00
dependabot[bot] b6774ead2c chore: bump eslint-plugin-jest from 26.6.0 to 26.7.0 in /site (#3334)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 26.6.0 to 26.7.0.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v26.6.0...v26.7.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-jest
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-03 14:15:47 -04:00
Ben Potter 7e1caa7086 chore: add helper text to help admins create new templates (#3364) 2022-08-03 17:27:39 +00:00
Kyle Carberry 69664ed168 fix: Use "virtual_machine_id" for instance identity with Azure (#3355)
This was using the wrong property, causing automatic auth to break.
2022-08-03 12:19:13 -05:00
Ben Potter 420fae886a chore: link to the hosted docs site instead of GitHub (#3365) 2022-08-03 17:04:45 +00:00
Mathias Fredriksson 6e426cf47d fix: Fix goleak in cli TestSSH/ForwardAgent test (#3369) 2022-08-03 16:06:40 +03:00
Mathias Fredriksson 9a023dd63b fix: Skip waiting for exit output in SSH test (#3368)
This seems to have caused flakes on Windows, the reason could be that
the input is lost due to writing to stdin before the shell is ready, or
simply that the command wasn't echoed (for the same reason).

We no longer need to consume the output since #2122 has been fixed, so
this might remove the flake in the latter case.

Ideally we would wait for the prompt to be present, but since we are
spawning the users shell, we have no control of what the prompt looks
like. In CI we can make assumption but even then it could change in the
future.
2022-08-03 13:37:12 +03:00
Mathias Fredriksson 1d6283bdac fix: Improve debuggability of ptytest failures (#3367)
Since we were not failing tests with `require` the error output was
somewhat hidden in the stream of log messages. This change standardizes
`ptytest` logging and failing to improve visibility.
2022-08-03 13:27:20 +03:00
Ammar Bandukwala 8f338782db Make minor improvements to Dogfood README (#3361) 2022-08-02 21:14:12 +00:00
Ammar Bandukwala 81e292be44 Add dogfood image (#3350) 2022-08-02 20:20:54 +00:00
Abhineet Jain 8bcf23e60a fix: handle create workspace errors (#3346) 2022-08-02 13:19:00 -04:00
Mathias Fredriksson 83c63d4a63 fix: Improve shutdown procedure of ssh, portforward, wgtunnel cmds (#3354)
* fix: Improve shutdown procedure of ssh, portforward, wgtunnel cmds

We could turn it into a practice to wrap `cmd.Context()` so that we have
more fine-grained control of cancellation. Sometimes in tests we may be
running commands with a context that is never canceled.

Related to #3221

* fix: Set ssh session stderr to stderr
2022-08-02 17:44:59 +03:00
Abhineet Jain 5ae19f097e fix: chromatic workflow filter (#3352) 2022-08-02 04:23:32 -04:00
Ammar Bandukwala bd785ddd87 Fix docs links (#3351) 2022-08-02 01:22:14 -04:00
Jon Ayers c1885dab27 fix: NPE when no arg provided to 'coder update' (#3347)
- Add test suite for 'coder update'.
2022-08-01 19:46:50 -05:00
David Wahler 8a2811210a feat: Add backend API support for resource metadata (#3242)
* Initial support for metadata in provisioner API and Terraform provisioner

* add support for nullable metadata fields

* handle metadata fields in provisionerd and API
2022-08-01 16:53:05 -05:00
Noah Huppert 877519232c Added Emacs Tips Documentation (#3247) 2022-08-01 16:47:22 -05:00
Dean Sheather 66a5b0f7bc fix: don't use adduser and addgroup for docker images (#3344)
* fix: don't use adduser and addgroup for docker images

* Revert "fix: Remove alternative image architectures until we virtualize (#3336)"

This reverts commit 00c5116a2e.
2022-08-01 19:28:38 +00:00
Kyle Carberry 8f3727d05d fix: Update issue reporting link with body (#3339) 2022-08-01 17:03:02 +00:00
Anton Korzhuk 80223a5e41 replace inline svgs with svg icon_path (#3332) 2022-08-01 16:57:51 +00:00
Ben Potter 56ee105a2a chore: add Discord link to footer (#3239) 2022-08-01 10:03:52 -05:00
Kyle Carberry 00c5116a2e fix: Remove alternative image architectures until we virtualize (#3336)
With the addition of a command being executed inside the Docker build,
we could no longer build non-amd64 images on amd64. They will be added
back, but to allow for releases this temporarily removes them.
2022-08-01 08:37:37 -05:00
Ammar Bandukwala 0d93e9bde1 ci: move chromatic to coder workflow (#3330) 2022-08-01 09:36:00 -04:00
Ammar Bandukwala 19fcf60864 ci: add typo detection (#3327)
And fix them.
2022-08-01 09:29:52 -04:00
dependabot[bot] eb514357bb chore: bump eslint from 8.20.0 to 8.21.0 in /site (#3335)
Bumps [eslint](https://github.com/eslint/eslint) from 8.20.0 to 8.21.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.20.0...v8.21.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-01 08:22:53 -05:00
Mathias Fredriksson 4730c589fe chore: Use standardized test timeouts and delays (#3291) 2022-08-01 15:45:05 +03:00
Kyle Carberry 3d0febdd90 feat: Add OIDC authentication (#3314)
* feat: Add OIDC authentication

* Extract username into a separate package and add OIDC tests

* Add test case for invalid tokens

* Add test case for username as email

* Add OIDC to the frontend

* Improve comments from self-review

* Add authentication docs

* Add telemetry

* Update docs/install/auth.md

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>

* Update docs/install/auth.md

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>

* Remove username package

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>
2022-07-31 23:05:35 -05:00
Jon Ayers 8b17bf98ea fix: prepend scheme to access url (#3317)
- Problems can arise spawning workspaces if a schemeless URL is passed
  as the access URL.

  If an access url is detected to not have an "http" or "https" scheme
  then it is prepended with "https". If the hostname is detected
  to be a loopback device then "http" is preferred.
2022-07-31 17:49:25 -05:00
Ammar Bandukwala f82df1bd78 docs: clean up English (#3324)
Fix issues from #3319 and #3320
2022-07-31 20:06:05 +00:00
dependabot[bot] 70bf66e030 chore: bump github.com/go-chi/httprate from 0.5.3 to 0.6.0 (#3311)
Bumps [github.com/go-chi/httprate](https://github.com/go-chi/httprate) from 0.5.3 to 0.6.0.
- [Release notes](https://github.com/go-chi/httprate/releases)
- [Commits](https://github.com/go-chi/httprate/compare/v0.5.3...v0.6.0)

---
updated-dependencies:
- dependency-name: github.com/go-chi/httprate
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-31 13:44:38 -05:00
dependabot[bot] 921de16d98 chore: bump google.golang.org/api from 0.88.0 to 0.90.0 (#3310)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.88.0 to 0.90.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.88.0...v0.90.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-31 13:44:25 -05:00
Noah Huppert 16f0f1a2db 3293, cli: Updated Placeholder color to have a dark theme alt (#3294)
Co-authored-by: Ubuntu <ubuntu@ip-172-31-1-230.us-east-2.compute.internal>
2022-07-31 13:44:05 -05:00
mark-theshark c553829fbf chore: document startup_script and agent log location (#3319) 2022-07-30 17:57:16 -05:00
Ben Potter 52041becf7 Revert "chore: relax template name validation"
This reverts commit 7806f3bebe.
2022-07-30 22:34:59 +00:00
mark-theshark beed6c7222 chore: updated web ide screenshots to be current, and fix minor spelling errors. (#3153) 2022-07-30 22:31:22 +00:00
Ben Potter c8d7b38418 Merge branch 'main' of github.com:coder/coder into main 2022-07-30 22:31:08 +00:00
Ben Potter 7806f3bebe chore: relax template name validation 2022-07-30 22:31:06 +00:00
mark-theshark 7367253097 chore: update jetbrains gateway docs with screenshots (#3320)
* chore: update jetbrains gateway with screenshots

* organize & add to manifest

Co-authored-by: Ben <ben@coder.com>
2022-07-30 17:29:05 -05:00
whitney-coder d764b3d0c3 Update oauth.md 2 (#3312)
I messed up the order of the brackets/parenthesis on the first commit.  This time, it should be correct and in line with Markdown syntax which states: Markdown syntax for a hyperlink is square brackets followed by parentheses. The square brackets hold the text, the parentheses hold the link.
2022-07-29 16:34:49 -05:00
Ammar Bandukwala 09776f33dd docs: rm postgres (#3313)
This is not our job.
2022-07-29 19:55:40 +00:00
Spike Curtis 6ea9298656 Update Gateway 2022.2 RC docs (#3256)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-29 14:36:43 -05:00
Ammar Bandukwala 6e63487b27 Rename template update to template push (#3307)
Before, there was a `template edit` AND a `template update`. The
distinction between both commands was easy to forget. `push` more
clearly indicates that the template's source code is being updated.

It is also complimentary to existing `template pull`.
2022-07-29 19:21:48 +00:00
whitney-coder 4b9daf5777 Update oauth.md (#3308)
Markdown syntax on line 9 caused a funky looking link on the website
2022-07-29 14:18:53 -05:00
Kira Pilot f49328bee5 chore: fix yaml file config error (#3306) 2022-07-29 15:18:22 -04:00
dependabot[bot] 9614bfea6b chore: bump @xstate/cli from 0.2.1 to 0.3.0 in /site (#3262)
Bumps @xstate/cli from 0.2.1 to 0.3.0.

---
updated-dependencies:
- dependency-name: "@xstate/cli"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-29 14:59:00 -04:00
Ammar Bandukwala 29eccbe4da ci: revert skips of required checks (#3303)
These were putting certain PRs in an unmergeable state.
2022-07-29 18:49:51 +00:00
dependabot[bot] d12e6b394f chore: bump typescript from 4.6.4 to 4.7.4 in /site (#2941)
* chore: bump typescript from 4.6.4 to 4.7.4 in /site

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.6.4 to 4.7.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.6.4...v4.7.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Remove unnecessary React imports

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Presley Pizzo <presley@coder.com>
2022-07-29 14:48:58 -04:00
mark-theshark 1f2ead80c6 chore: remove duplicative kube config info in projector section (#3290) 2022-07-29 13:40:14 -05:00
Kyle Carberry 183b2e80b9 fix: Increase zoom of hero for README (#3300)
This was pretty small before which made it difficult to see
what was going on.
2022-07-29 13:39:30 -05:00
Kira Pilot aaa2db6f8b feat: add pagination component to components directory (#3295)
* proof of concept

* added tests

* fixed tests

* wrote unit tests

* preettier
2022-07-29 14:37:53 -04:00
Kira Pilot b9936d2310 updated dependabot (#3297) 2022-07-29 13:31:49 -04:00
Abhineet Jain e94fe20b6b fix: handle getUser error (#3285) 2022-07-29 13:10:22 -04:00
Cian Johnston 4658b3f0d2 fix: coderd: putExtendWorkspace: move error from validation to message (#3289)
* refactor: coderd: extract error messages to variables
* fix: putExtendWorkspace: return validation error in message field
2022-07-29 15:01:17 +01:00
Abhineet Jain 74c87664c1 fix: handle more auth API errors (#3241) 2022-07-28 17:14:05 -04:00
Presley Pizzo 6b82fdd0c0 Surface backend error when extending schedule (#3275) 2022-07-28 17:13:46 -04:00
Spike Curtis d6faf8f524 remove character limit on instance ids (#3274)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-28 13:52:03 -07:00
dependabot[bot] 6d14dcb1ee chore: bump eslint-plugin-jest from 26.5.3 to 26.6.0 in /site (#3204)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 26.5.3 to 26.6.0.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v26.5.3...v26.6.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-jest
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-28 15:24:59 -04:00
dependabot[bot] 7ba69739f6 chore: bump ts-node from 10.8.2 to 10.9.1 in /site (#3213)
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.8.2 to 10.9.1.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v10.8.2...v10.9.1)

---
updated-dependencies:
- dependency-name: ts-node
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-28 15:11:44 -04:00
dependabot[bot] 736084ca5d chore: bump @typescript-eslint/eslint-plugin in /site (#3214)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.30.6 to 5.31.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.31.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-28 15:09:51 -04:00
Mathias Fredriksson 29d44b6283 fix: Guard pty window resize after close (#3270)
Could help alleviate #3236.
2022-07-28 19:07:11 +00:00
Denbeigh Stevens 43b8cf04f0 fix: remove pipefail from standard shell options (#3269)
This isn't well-supported by every POSIX shell anyways.
2022-07-28 18:50:04 +00:00
Presley Pizzo 73f145e45f fix: error messages from workspaceScheduleXService (#3255)
* Update color palette

* Edit dialog error colors

* Format

* Lighten links

* Lighten link just in ErrorSummary

* Format

* Fix errors in schedule xservice

* Add error summary to form for generic message

* Format

* Extend getFormHelpers to remap field name

* Add mock error and use in storybook

* Format
2022-07-28 13:18:51 -04:00
Bruno Quaresma 1a8cce27ae fix: Workspace schedule button on responsive (#3264) 2022-07-28 16:17:50 +00:00
Bruno Quaresma 2805d86ba9 chore: Replace stop icon to use pause icon (#3261) 2022-07-28 11:02:14 -03:00
dependabot[bot] 663d0475b9 chore: bump @typescript-eslint/parser from 5.30.6 to 5.31.0 in /site (#3212)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.30.6 to 5.31.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.31.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-28 09:48:58 -04:00
Spike Curtis 043768076f Explain pty Process abstraction (#3254)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-27 17:03:55 -07:00
Steven Masley 6230d5512e chore: Remove line numbers from auto-gen typescript (#3258)
* chore: Remove line numbers from auto-gen typescript

The line numbers are just extra noise that change when things shift
around. They are not required and usually make CI fail when you
forget to run 'make gen'.
2022-07-27 21:36:15 +00:00
Cian Johnston 27ea415b6c fix: remove string TTL from workspace error responses (#3257)
- Rewrites some error messages to better integrate with the frontend (ttl_ms -> time until shutdown)
- Makes codersdk.ValidationError implement the error interface
- Only return validations if the error was a validation error, return detail otherwise (e.g. database error)
2022-07-27 21:20:02 +00:00
Spike Curtis 36ffdce065 Return proper exit code on ssh with TTY (#3192)
* Return proper exit code on ssh with TTY

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix revive lint

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix Windows exit code for missing command

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix close error handling on agent TTY

Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-27 14:23:28 -05:00
Presley Pizzo a37e61a099 fix: make text colors legible (#3250)
* Update color palette

* Edit dialog error colors

* Format

* Lighten links

* Lighten link just in ErrorSummary

* Format
2022-07-27 13:49:03 -04:00
Mathias Fredriksson 46564fb470 fix: Fix goleak in cli TestSSH tests (#3253)
Commands are now also run with contexts that time out.

Work towards #3221.
2022-07-27 17:33:00 +00:00
Mathias Fredriksson a0320f455a fix: Close notifier Poll goroutine on stop (#3252)
Fix towards #3221.
2022-07-27 20:26:13 +03:00
Cian Johnston 6377f17fda chore: update terraform to 1.2.1 (#3243)
* chore: update terraform to 1.2.1

* allow terraform version equal to max
2022-07-27 17:11:38 +01:00
Mathias Fredriksson d27076cac7 fix: Improve coder server shutdown procedure (#3246)
* fix: Improve `coder server` shutdown procedure

This commit improves the `coder server` shutdown procedure so that all
triggers for shutdown do so in a graceful way without skipping any
steps.

We also improve cancellation and shutdown of services by ensuring
resources are cleaned up at the end.

Notable changes:
- We wrap `cmd.Context()` to allow us to control cancellation better
- We attempt graceful shutdown of the http server (`server.Shutdown`)
  because it's less abrupt (compared to `shutdownConns`)
- All exit paths share the same shutdown procedure (except for early
  exit)
- `provisionerd`s are now shutdown concurrently instead of one at a
  time, the also now get a new context for shutdown because
  `cmd.Context()` may be cancelled
- Resources created by `newProvisionerDaemon` are cleaned up
- Lifecycle `Executor` exits its goroutine on context cancellation

Fixes #3245
2022-07-27 18:21:21 +03:00
Mathias Fredriksson bb05b1f749 fix: Use slog for devtunnel logging (#3248)
Ensures standardized logging for server.
2022-07-27 18:05:47 +03:00
Mathias Fredriksson cef622d77c fix: Order database queries for templates (#3249)
* fix: Order database queries for templates

Fixes a race in a test where the order of templates varies.

* fix: Add sorting to databasefake as well
2022-07-27 15:04:29 +00:00
Ammar Bandukwala 5802c29c38 docs: add versions (#3147)
Resolves #3111
2022-07-27 10:52:18 -04:00
Spike Curtis f310aeb4cb Disable skipping job acquire log (#3240)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-26 16:36:45 -07:00
Abhineet Jain b1e0d69789 Implement basic templates versions CLI (#3145) 2022-07-26 18:31:17 -04:00
Dean Sheather df20dd7374 feat: improve coder users show output, add json format (#3176) 2022-07-26 15:47:12 -05:00
Bruno Quaresma aaf0da27ef chore: Update viewport to support responsive (#3233) 2022-07-26 17:33:46 -03:00
Abhineet Jain 6f93acd964 feat: make template pages responsive (#3232) 2022-07-26 16:31:58 -04:00
Bruno Quaresma 991b4f7480 feat: Make settings page responsive (#3228) 2022-07-26 19:48:41 +00:00
Bruno Quaresma 509a601efe feat: Make users page responsive (#3229) 2022-07-26 16:46:43 -03:00
Abhineet Jain 0128ca6bd1 fix: manage backend authXService errors (#3190) 2022-07-26 15:39:45 -04:00
Dean Sheather b19cf701c5 feat: change docker to use "coder" user and add basic Helm chart (#2746) 2022-07-26 13:19:29 -05:00
Bruno Quaresma d2aa75dd0d fix: Responsive for workspaces and workspace page (#3189) 2022-07-26 15:05:00 -03:00
David Wahler fbd1a272fe fix: Fix dangling references in provisioner/terraform/testdata (#3193) 2022-07-26 12:04:21 -05:00
dependabot[bot] 8115a11e58 chore: bump webpack from 5.73.0 to 5.74.0 in /site (#3208)
Bumps [webpack](https://github.com/webpack/webpack) from 5.73.0 to 5.74.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.73.0...v5.74.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 10:53:45 -04:00
dependabot[bot] c8d2254028 chore: bump chromatic from 6.7.0 to 6.7.1 in /site (#3206)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.7.0 to 6.7.1.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/commits)

---
updated-dependencies:
- dependency-name: chromatic
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 10:53:21 -04:00
dependabot[bot] f49b015fc7 chore: bump cronstrue from 2.5.0 to 2.11.0 in /site (#2943)
Bumps [cronstrue](https://github.com/bradymholt/cronstrue) from 2.5.0 to 2.11.0.
- [Release notes](https://github.com/bradymholt/cronstrue/releases)
- [Changelog](https://github.com/bradymholt/cRonstrue/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bradymholt/cronstrue/compare/v2.5.0...v2.11.0)

---
updated-dependencies:
- dependency-name: cronstrue
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 14:52:17 +00:00
Kira Pilot ef260faf27 fix: remove flaking test (#3207) 2022-07-26 10:35:13 -04:00
Mathias Fredriksson 159137dc10 fix: Use stdin/out defined in command (#3199) 2022-07-26 17:23:32 +03:00
dependabot[bot] 9fe260d5ea chore: bump eslint from 8.15.0 to 8.20.0 in /site (#3205)
Bumps [eslint](https://github.com/eslint/eslint) from 8.15.0 to 8.20.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.15.0...v8.20.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 10:22:52 -04:00
dependabot[bot] 8d6949a0b1 chore: bump @fontsource/ibm-plex-mono from 4.5.9 to 4.5.10 in /site (#2944)
Bumps [@fontsource/ibm-plex-mono](https://github.com/fontsource/fontsource/tree/HEAD/fonts/google/ibm-plex-mono) from 4.5.9 to 4.5.10.
- [Release notes](https://github.com/fontsource/fontsource/releases)
- [Changelog](https://github.com/fontsource/fontsource/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fontsource/fontsource/commits/HEAD/fonts/google/ibm-plex-mono)

---
updated-dependencies:
- dependency-name: "@fontsource/ibm-plex-mono"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 10:12:18 -04:00
dependabot[bot] 3f2cbc9b85 chore: bump @playwright/test from 1.23.2 to 1.24.1 in /site (#3203)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.23.2 to 1.24.1.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.23.2...v1.24.1)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 10:11:04 -04:00
dependabot[bot] 9a3baffe43 chore: bump @pmmmwh/react-refresh-webpack-plugin in /site (#3184)
Bumps [@pmmmwh/react-refresh-webpack-plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) from 0.5.6 to 0.5.7.
- [Release notes](https://github.com/pmmmwh/react-refresh-webpack-plugin/releases)
- [Changelog](https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pmmmwh/react-refresh-webpack-plugin/compare/v0.5.6...v0.5.7)

---
updated-dependencies:
- dependency-name: "@pmmmwh/react-refresh-webpack-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 09:54:28 -04:00
dependabot[bot] 100584d95c chore: bump github.com/klauspost/compress from 1.15.8 to 1.15.9 (#3162)
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.15.8 to 1.15.9.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Changelog](https://github.com/klauspost/compress/blob/master/.goreleaser.yml)
- [Commits](https://github.com/klauspost/compress/compare/v1.15.8...v1.15.9)

---
updated-dependencies:
- dependency-name: github.com/klauspost/compress
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 16:46:30 +03:00
Mathias Fredriksson d1d89210b8 fix: Disable telemetry by default in tests (#3200)
I also noticed we don't have `goleak` enabled for CLI tests, this commit
adds it, but commented out. The reason being that we're nowhere near
being able to enable it yet.

Co-authored-by: Cian Johnston <cian@coder.com>
2022-07-26 16:27:48 +03:00
dependabot[bot] 122c6f06d8 chore: bump github.com/unrolled/secure from 1.11.0 to 1.12.0 (#3017)
Bumps [github.com/unrolled/secure](https://github.com/unrolled/secure) from 1.11.0 to 1.12.0.
- [Release notes](https://github.com/unrolled/secure/releases)
- [Commits](https://github.com/unrolled/secure/compare/v1.11.0...v1.12.0)

---
updated-dependencies:
- dependency-name: github.com/unrolled/secure
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 16:26:07 +03:00
Cian Johnston 2c0d57e8c0 fix: update reference to agent.dev in examples and docs (#3198)
* fix: update agent ID in example templates
* fix: update agent ID in dogfood template
* chore: update default agent ID in documentation
* fix: develop.sh: start FE after template is created; leave template dir around if template creation fails
2022-07-26 14:09:09 +01:00
Mathias Fredriksson 9a9912c8ce fix: Add go.mod to prcontext and use build vs go run (#3197) 2022-07-26 16:04:00 +03:00
Mathias Fredriksson 0b86c8047c fix: Close connections in agent tests (#3196) 2022-07-26 13:24:54 +03:00
Mathias Fredriksson f34b5000cb fix: Avoid logging to stdout in devtunnel test (#3194)
The device keeps logging to the logger even after `dev.Close()` but
doing that with `t.Log` is unsafe (test has ended). This is why
`slogtest` was used.

`dev.Close()` has a wait on encryption and decryption routines, however,
these are left running even after the wait. The implementation uses the
WaitGroups in a weird way.
2022-07-26 12:20:21 +03:00
Kira Pilot 9bf5537b0f feat: showcase workspace state in actions dropdown (#3133)
* show progress indicator within workspace dropdown

resolves #2020

* wrote tests

* fix loading button

* PR feedback

* added stories for dropdown content

* PR feedbac
2022-07-25 18:12:59 -04:00
Bruno Quaresma b0957f32e3 feat: Add mobile navbar (#3186) 2022-07-25 17:54:11 +00:00
Mathias Fredriksson 173ab297be chore: Increase style/gen CI test timeout (#3187) 2022-07-25 17:10:53 +00:00
Mathias Fredriksson 92a95fbd5f fix: Rewrite ptytest to buffer stdout (#3170)
Fixes #2122
2022-07-25 20:02:34 +03:00
Mathias Fredriksson d7dee2c069 fix: Improve code coverage reporting in codecov (#2715)
* fix: Remove explicit coverpkg github.com/coder/coder/codersdk

This package is already covered by ./...

* fix: Ignore test utils in coverage (clitest, coderdtest, ptytest)
2022-07-25 19:55:19 +03:00
dependabot[bot] 6c5a142674 chore: bump dayjs from 1.11.3 to 1.11.4 in /site (#3180)
Bumps [dayjs](https://github.com/iamkun/dayjs) from 1.11.3 to 1.11.4.
- [Release notes](https://github.com/iamkun/dayjs/releases)
- [Changelog](https://github.com/iamkun/dayjs/blob/v1.11.4/CHANGELOG.md)
- [Commits](https://github.com/iamkun/dayjs/compare/v1.11.3...v1.11.4)

---
updated-dependencies:
- dependency-name: dayjs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 12:35:42 -04:00
dependabot[bot] 1859ca568d chore: bump eslint-plugin-jsx-a11y from 6.6.0 to 6.6.1 in /site (#3179)
Bumps [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y) from 6.6.0 to 6.6.1.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/compare/v6.6.0...v6.6.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-jsx-a11y
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 12:35:17 -04:00
Mathias Fredriksson 1c04b20fde fix: Set cache dir for coderd tests (#3160)
* fix: Set cache dir for coderd in codedtest

* fix: Ensure server cli tests have a cache path

To avoid sharing default path.
2022-07-25 19:24:32 +03:00
Mathias Fredriksson 6916d34458 fix: Fix cleanup in test helpers, prefer defer in tests (#3113)
* fix: Change uses of t.Cleanup -> defer in test bodies

Mixing t.Cleanup and defer can lead to unexpected order of execution.

* fix: Ensure t.Cleanup is not aborted by require

* chore: Add helper annotations
2022-07-25 19:22:02 +03:00
dependabot[bot] c2cd51d8b8 chore: bump sql-formatter from 8.0.2 to 8.2.0 in /site (#3178)
Bumps [sql-formatter](https://github.com/sql-formatter-org/sql-formatter) from 8.0.2 to 8.2.0.
- [Release notes](https://github.com/sql-formatter-org/sql-formatter/releases)
- [Changelog](https://github.com/sql-formatter-org/sql-formatter/blob/master/.release-it.json)
- [Commits](https://github.com/sql-formatter-org/sql-formatter/compare/v8.0.2...v8.2.0)

---
updated-dependencies:
- dependency-name: sql-formatter
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 12:12:58 -04:00
dependabot[bot] 456318cbd8 chore: bump eslint-import-resolver-typescript in /site (#3177)
Bumps [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) from 3.2.5 to 3.3.0.
- [Release notes](https://github.com/import-js/eslint-import-resolver-typescript/releases)
- [Changelog](https://github.com/import-js/eslint-import-resolver-typescript/blob/master/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-import-resolver-typescript/compare/v3.2.5...v3.3.0)

---
updated-dependencies:
- dependency-name: eslint-import-resolver-typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 12:09:30 -04:00
dependabot[bot] 4a0b8440bc chore: bump @types/node from 14.18.21 to 14.18.22 in /site (#3174)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.18.21 to 14.18.22.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 12:04:51 -04:00
dependabot[bot] 3c38a23e27 chore: bump eslint-plugin-react from 7.30.0 to 7.30.1 in /site (#3172)
Bumps [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) from 7.30.0 to 7.30.1.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-react/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jsx-eslint/eslint-plugin-react/compare/v7.30.0...v7.30.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-react
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 11:55:48 -04:00
Bruno Quaresma 821ae5dbd7 chore: Add colors object with the Coder color palette (#3173) 2022-07-25 12:49:00 -03:00
Mathias Fredriksson 4d53934eb0 fix: (Re-)enable TestPasswordTerminalState test (#3169) 2022-07-25 18:42:20 +03:00
David Wahler 5312296283 fix: Add a slightly better error message for dropped SSH connection (#3131) 2022-07-25 10:25:34 -05:00
dependabot[bot] f0f0aebdbb chore: bump @testing-library/user-event from 14.2.0 to 14.3.0 in /site (#3163)
Bumps [@testing-library/user-event](https://github.com/testing-library/user-event) from 14.2.0 to 14.3.0.
- [Release notes](https://github.com/testing-library/user-event/releases)
- [Changelog](https://github.com/testing-library/user-event/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/user-event/compare/v14.2...v14.3)

---
updated-dependencies:
- dependency-name: "@testing-library/user-event"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 10:35:21 -04:00
Mathias Fredriksson d7ec407a7c fix: Improve coder list and show CLI help (#3167) 2022-07-25 16:56:20 +03:00
Mathias Fredriksson 233aa17848 fix: Avoid dirtying stdout/stderr in test (#3165)
* fix: Default all clitest commands to io.Discard stdout/err

* fix: Never write to stdout or stderr in tests
2022-07-25 16:55:53 +03:00
Mathias Fredriksson ad2b29a571 fix: Remove hardcoded /tmp path in test (#3168) 2022-07-25 16:55:06 +03:00
Mathias Fredriksson 2c67a2f30b fix: Close bug in pty (#3166) 2022-07-25 16:31:30 +03:00
Mathias Fredriksson 592340c6ce fix: Data race in cliui.Styles without clone (#3164) 2022-07-25 16:30:52 +03:00
Ammar Bandukwala 54547a4e9a ci: fix postgres skipper (#3157) 2022-07-24 19:58:20 +00:00
Ammar Bandukwala 60de8d0279 ci: add skip directives for long tests (#3151)
This PR introduces many CI optimizations:

1. The `[ci-skip]` PR body directive to skip the Postgres and end to end tests
2. Improved caching that cuts the Go test matrix in half
3. Increasing Go test parallelism for ~20% gains
4. Enable caching in webpack (4x frontend build)
2022-07-24 14:33:58 -05:00
Ammar Bandukwala 5578facf8f Fix stalebot (#3156) 2022-07-24 19:32:41 +00:00
Ammar Bandukwala ecb6301cab docs: make small style improvements (#3065) 2022-07-23 16:37:54 -05:00
Ammar Bandukwala e4251af8f3 ci: configure stale bot some more (#3148) 2022-07-23 16:37:19 -05:00
Ammar Bandukwala 3eb6f28d81 ci: fix master build 2022-07-23 21:36:15 +00:00
Ammar Bandukwala d10513f43a ci: optimize jobs with path filtering (#3074) 2022-07-23 21:33:25 +00:00
mark-theshark 1ddff0abcd chore: docs to create admin user and workspace creation from UI screenshot (#3149) 2022-07-23 20:44:28 +00:00
Ammar Bandukwala f28d14197a Rename default agent to "main" instead of "dev" (#3150)
Resolves #3143
2022-07-23 20:26:56 +00:00
Ammar Bandukwala 257e52e014 ci: aggressively close stale PRs (#3146) 2022-07-23 14:57:35 -05:00
Spike Curtis 5e32468a73 Add JetBrains Gateway doc (#3104)
* Add JetBrains Gateway doc

Signed-off-by: Spike Curtis <spike@coder.com>

* Added GitHub issue to track Gateway failure

Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-22 15:32:16 -07:00
Kyle Carberry c6016d247d docs: Update hero image to the dashboard (#3132) 2022-07-22 21:00:21 +00:00
Bruno Quaresma ca93614c3f refactor: Make workspace status more visible (#3130) 2022-07-22 19:18:52 +00:00
Abhineet Jain 1b19a09a37 feat: New static error summary component (#3107) 2022-07-22 19:10:40 +00:00
Kyle Carberry fd4954b4e5 fix: Use membership endpoint to ensure user exists in team (#3129)
This was using the incorrect GitHub endpoint prior, which fetched a team
by slug. Any user in a GitHub organization can view all teams, so this
didn't block signups like intended.

I've verified this API returns an error when the calling user is not a
member  of the team requested.

Fixes #3105.
2022-07-22 13:54:08 -05:00
Kira Pilot 471564df7d feat: improve update button visibility (#3115)
* feat: give update button primary focus when applicable

resolves #3024

* added update tooltip

* cleanup

* prettier

* PR feedback
2022-07-22 14:28:52 -04:00
Joe Previte 2dd98c7ec8 docs: add dogfooding guide (#3099) 2022-07-22 18:22:11 +00:00
Mathias Fredriksson 51dd1fde3b fix: Remove use of require in require.Eventually in tests (#3110)
* fix: Remove use of `require` in `require.Eventually` in tests

Because require uses `t.FailNow()` and `require.Eventually` runs the
function in a goroutine, which is not allowed.

* feat: Add ruleguard for require.Eventually

Co-authored-by: Cian Johnston <cian@coder.com>
2022-07-22 20:02:49 +03:00
Bruno Quaresma 3bb760576b fix: Add resource icons into template page (#3124) 2022-07-22 11:46:51 -05:00
Spike Curtis fa4361db76 restore devtunnel test (#3050)
* Dev tunnel test uses local fake server; fixed port

Signed-off-by: Spike Curtis <spike@coder.com>

* Remove parallel for test

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix segfault
2022-07-22 08:26:39 -07:00
Kira Pilot 882ee55fd0 fix: storybook should use absolute paths (#3119) 2022-07-22 11:02:54 -04:00
Ben Potter f43eb0e77c fix: minor fixes to templates docs (#3117) 2022-07-22 09:59:19 -05:00
Cian Johnston 1140e29a17 chore: autobuild/executor: refactor big switch statement for legibility (#3116) 2022-07-22 15:45:12 +01:00
Mathias Fredriksson ef7d357e19 fix: Move timeout ctx closer to use in tests, increase timeout (#3109)
Some contexts were moved closer to use so that test setup doesn't affect
timeout. And timeout was increased for some others to avoid flakyness
due to slow test runners.
2022-07-22 17:42:09 +03:00
Bruno Quaresma e874d538fb feat: Add resource icons (#3118) 2022-07-22 11:38:38 -03:00
Mathias Fredriksson 7d07e670ca chore: Improve test cleanup (#3112) 2022-07-22 15:14:45 +03:00
Mathias Fredriksson 75ff579051 fix: Decrease postgres test timeout (make test-postgres) (#3108)
This commit lowers the postgres test timeout from 30m to 20m, currently
our postgres tests seem to take 8-10m, a 2x factor should suffice.
Comments were updated in both places to reflect the reasoning and
necessity of keeping these values in sync.

They used to take longer but the `count` was lowered in
3d40cb85b7.

The actual timeout value of `make test-postgres` got overlooked in
https://github.com/coder/coder/pull/3079.
2022-07-22 12:47:03 +03:00
Kira Pilot 0aa8c2efeb fix: set a failed canceled job status correctly (#3101)
* set a failed canceled job status correctly

resolves #1374

* added unit test for convertProvisionerJob

* Update coderd/provisionerjobs_internal_test.go

Co-authored-by: Cian Johnston <cian@coder.com>

* PR feedback

Co-authored-by: Cian Johnston <cian@coder.com>
2022-07-21 16:47:06 -04:00
mark-theshark 77f4ab16a4 feat: update IDE docs with advanced examples with pods and custom images (#3002) 2022-07-21 20:03:03 +00:00
David Wahler 7f54628848 config-ssh: always support agent name in host alias (#3036) 2022-07-21 14:49:32 -05:00
dependabot[bot] c9d7cbca48 chore: bump github.com/nhatthm/otelsql from 0.3.4 to 0.4.0 (#3069)
Bumps [github.com/nhatthm/otelsql](https://github.com/nhatthm/otelsql) from 0.3.4 to 0.4.0.
- [Release notes](https://github.com/nhatthm/otelsql/releases)
- [Commits](https://github.com/nhatthm/otelsql/compare/v0.3.4...v0.4.0)

---
updated-dependencies:
- dependency-name: github.com/nhatthm/otelsql
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-21 14:39:15 -05:00
dependabot[bot] 06e0a5b1e4 chore: bump google.golang.org/api from 0.86.0 to 0.88.0 (#3070)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.86.0 to 0.88.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.86.0...v0.88.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-21 14:38:56 -05:00
Cian Johnston 59b04c154e fix: coderdtest: increase ForceCancelInterval (#3085)
Two coderd unit tests (TestPatchCancelTemplateVersion/Success and TestPatchCancelWorkspaceBuild) implied erroneously that the job was canceled successfully.

This is not the case, as these unit tests do not include a Provision_Complete response in the input to the
echo provisioner. Now explicitly checking the job error and bumping the force cancel interval to be longer.

Fixes #3083.
2022-07-21 19:29:45 +00:00
Jon Ayers e01905821f fix: avoid emitting version warning when connection error encountered (#3082) 2022-07-21 14:28:24 -05:00
Bruno Quaresma 5b78251592 refactor: Initial color palette changes (#3087) 2022-07-21 17:56:16 +00:00
Mathias Fredriksson e33a74975e fix: Deadlock and race in peer, test improvements (#3086)
* fix: Potential deadlock in peer.Channel dc.OnOpen

* fix: Potential send on closed channel

* fix: Improve robustness of waitOpened during close

* chore: Simplify statements

* fix: Improve teardown and timeout of peer tests

* fix: Improve robustness of TestConn/Buffering test

* Update peer/channel.go

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
2022-07-21 18:47:17 +03:00
Jon Ayers 62e685669f feat: add verbose error messaging (#3053) 2022-07-20 15:17:51 -05:00
Mathias Fredriksson 4a7d067c6c fix: Increase CI timeout for postgres test (#3079)
The Go test timeout uses 20m, if we want to get a stack trace, we must
allow the actions worker to run longer than that.
2022-07-20 19:09:26 +00:00
Mathias Fredriksson 96edc8af9a fix: Add continue-on-error to codecov action step (#3081)
Avoid relying on codecov to manage action step failure, hopefully works
around:
https://github.com/codecov/codecov-action/issues/788
2022-07-20 19:04:40 +00:00
Mathias Fredriksson 3e5affd28a fix: Increase test timeout for TestCreate/CreateFromListWithSkip (#3077)
Considering database load and CI performance during testing, we should
avoid failing too early.
2022-07-20 17:51:33 +00:00
Ammar Bandukwala b0c26745fb ci: fix stale issue workflow (#3073) 2022-07-20 17:24:30 +00:00
Bruno Quaresma 916c388d8d fix: Statuses breaking line in the UI (#3071)
* fix: Fix statuses breaking line in the UI

* fix: AppLink stories
2022-07-20 17:11:20 +00:00
dependabot[bot] 82f159b8c3 chore: bump terser from 4.8.0 to 4.8.1 in /site (#3068)
Bumps [terser](https://github.com/terser/terser) from 4.8.0 to 4.8.1.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-20 12:58:43 -04:00
Ammar Bandukwala cf9bc71c03 ci: skip long jobs when only docs change (#3072) 2022-07-20 16:47:41 +00:00
Mathias Fredriksson 4fde5366be fix: Improve TestSSH reliability on macOS (#3067)
Related issue: https://github.com/coder/coder/issues/2122
2022-07-20 19:24:15 +03:00
dependabot[bot] 6199e6a060 chore: bump github.com/spf13/afero from 1.9.0 to 1.9.2 (#3046)
Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.9.0 to 1.9.2.
- [Release notes](https://github.com/spf13/afero/releases)
- [Commits](https://github.com/spf13/afero/compare/v1.9.0...v1.9.2)

---
updated-dependencies:
- dependency-name: github.com/spf13/afero
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-20 11:20:48 -05:00
Kira Pilot 0c18a2313f clarify start validation in schedule (#3052)
resolves #2792
2022-07-20 11:54:57 -04:00
Mathias Fredriksson 034416f141 chore: Speed up port-forward tests (#3062)
* chore: Speed up port-forward tests

* chore: Add t.Helper and ensure listener closure on error
2022-07-20 18:11:25 +03:00
Mathias Fredriksson cd74afcccc fix: Increase randomness for names used in tests (#3063)
We are starting to run into test flakes due to lack of randomness in CI,
this change simply bumps randomness by additional suffix numbers.

See: https://github.com/coder/coder/issues/3038#issuecomment-1190283608
2022-07-20 18:03:04 +03:00
Ammar Bandukwala 87b0b4b1ea docs: add secrets (#3057) 2022-07-20 07:31:33 -05:00
David Wahler f7ea016494 Pass git configuration variables via terraform (#3034)
* Pass workspace owner email address to provisioner

* Remove owner_email and owner_username fields from agent metadata

* Add Git environment variables to example templates

* Remove "owner_name" field from provisioner metadata, use username instead

* Remove Git configuration from most templates, add documentation

* Proofreading/typo fixes from @mafredri

* Update example templates to latest version of terraform-provider-coder
2022-07-19 13:24:06 -05:00
Alon David b9847c18f4 solves #2535. (#2557)
remove leading V in coder container image tag
2022-07-19 17:06:03 +00:00
dependabot[bot] a69bd47b3a chore: bump github.com/jedib0t/go-pretty/v6 from 6.3.3 to 6.3.5 (#3028)
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.3.3 to 6.3.5.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.3.3...v6.3.5)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-19 11:41:51 -05:00
dependabot[bot] caf2478cf6 chore: bump github.com/pion/webrtc/v3 from 3.1.42 to 3.1.43 (#3027)
Bumps [github.com/pion/webrtc/v3](https://github.com/pion/webrtc) from 3.1.42 to 3.1.43.
- [Release notes](https://github.com/pion/webrtc/releases)
- [Commits](https://github.com/pion/webrtc/compare/v3.1.42...v3.1.43)

---
updated-dependencies:
- dependency-name: github.com/pion/webrtc/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-19 11:27:41 -05:00
Ammar Bandukwala c86a623ff8 Remove Joe from docs CODEOWNERS (#3037) 2022-07-19 16:27:13 +00:00
Kira Pilot 1830a18565 feat: amend schedule form valiidation string (#3043)
resolves #2792
2022-07-19 12:04:06 -04:00
Ben Potter b6ad5623a3 example: add a bare/custom template (#2965) 2022-07-19 13:29:24 +00:00
Ammar Bandukwala a2f6b25110 Add new Dogfood template (#2959)
* Setup base template

* Add sysbox

* Run code-server in background

* Fix small typo
2022-07-18 22:44:09 +00:00
Ammar Bandukwala a66b852c81 ci: fix stale (#3030)
- Add necessary runs-on
- Use lowercase labels for consistency
2022-07-18 19:58:51 +00:00
Ammar Bandukwala 5919e96ac2 ci: add stale workflow (#3029) 2022-07-18 19:34:04 +00:00
Mathias Fredriksson 54cf677e80 chore: Switch back to upstream for hashicorp/yamux (#3026)
All our fixes have been upstreamed, so we are switching back.
2022-07-18 20:27:26 +03:00
dependabot[bot] 4f6b2cff83 chore: bump github.com/spf13/afero from 1.8.2 to 1.9.0 (#3014)
Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.8.2 to 1.9.0.
- [Release notes](https://github.com/spf13/afero/releases)
- [Commits](https://github.com/spf13/afero/compare/v1.8.2...v1.9.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/afero
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-18 12:12:10 -05:00
Mathias Fredriksson 3a692a6cdb fix: Sort ComputedValue according to parameter schema index (#3022)
This fixes a test-flake in TestTemplateVersionParameters/List and gives
us consistent sorting for parameters.
2022-07-18 19:39:24 +03:00
Kira Pilot c0d19ebea2 chore: configure absolute paths with webpack (#3011)
* coonfigure absolute paths with webpack

resolves #1855

* fixed jest config
2022-07-18 10:43:11 -04:00
dependabot[bot] 6d1ec409d0 chore: bump github.com/klauspost/compress from 1.15.7 to 1.15.8 (#3015)
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.15.7 to 1.15.8.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Changelog](https://github.com/klauspost/compress/blob/master/.goreleaser.yml)
- [Commits](https://github.com/klauspost/compress/compare/v1.15.7...v1.15.8)

---
updated-dependencies:
- dependency-name: github.com/klauspost/compress
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-18 10:08:43 -04:00
Abhineet Jain ccdf82dd7e feat: show template versions (#3003) 2022-07-15 15:25:47 -07:00
Kira Pilot 9a5fa3f050 fix: border fixes for workspace schedule button (#3010)
* border fixes for workspace schedule button

* fixing chromatic snapshots

* chromatic fix
2022-07-15 18:04:33 -04:00
Abhineet Jain d04ba2cc02 feat: add template version creator (#3001) 2022-07-15 14:12:39 -07:00
Bruno Quaresma d26b3b7ba1 refactor: Remove avatar from workspace name (#3006) 2022-07-15 15:49:18 +00:00
Colin Adler 680e24a14b Revert "feat: add template version creator (#2991)" (#2999)
This reverts commit aea3b3b83e.
2022-07-14 21:57:42 +00:00
Colin Adler 1033e02d79 feat: add coder server postgres-builtin-serve to run the built-in DB (#2997) 2022-07-14 21:51:44 +00:00
Kira Pilot eebf0dd736 feat: consolidate workspace buttons/kira pilot (#2996)
* added workspace cta dropdown

resolves #2748

* added tests

* fixed failing tests

* clean up snapshots
2022-07-14 16:47:10 -04:00
Abhineet Jain aea3b3b83e feat: add template version creator (#2991) 2022-07-14 20:44:33 +00:00
Ali Diamond 6ef8a625d5 Update workspaces.md (#2993)
adding missing command word
2022-07-14 18:31:01 +00:00
Bruno Quaresma adcd6f5cf1 refactor: Make the workspace panels more light (#2984) 2022-07-14 15:09:07 -03:00
Bruno Quaresma c8d04aff6b feat: Add status badge to the favicon (#2978) 2022-07-14 14:45:03 +00:00
Abhineet Jain bf1af216e1 fix: remove access column header (#2976) 2022-07-13 17:59:09 -07:00
Kyle Carberry 8e17254785 fix: Add test for wrapping init script with single quotes (#2979)
This ensures our initialization script works with single  uotes.
2022-07-13 17:43:48 -05:00
David Wahler b5f5e909bd Return template parameters in consistent order (#2975)
* return parameters from Terraform provisioner in sorted order

* persist parameter indices in database and return them in correct order from API

* don't re-sort parameters by name when creating templates
2022-07-13 15:29:34 -05:00
Abhineet Jain b692b7ea14 fix: remove system user highlighting (#2973) 2022-07-13 11:48:26 -07:00
Bruno Quaresma 000bc50258 refactor: Refactor last built by column (#2968) 2022-07-13 12:37:12 -03:00
Bruno Quaresma 02129332d7 fix: Loading state in the workspaces page (#2967) 2022-07-13 11:49:07 -03:00
Cian Johnston 0f5f30b6f6 fix: make agent scripts easier to troubleshoot (#2922)
- Adds distinct exit statuses to the bootstrap scripts
- Makes the bootstrap scripts loop forever trying to download the coder agent
- Surfaces and logs the status codes returned by the download tool
2022-07-13 10:17:40 +01:00
Kyle Carberry 6f34cbff1e fix: Use double quotes for trap signal (#2956)
Frequently callers will wrap our shell script in `sh -c ''`.
Having single quotes on our `trap` led to a syntax error when
doing this.
2022-07-13 01:09:59 +00:00
Kyle Carberry 8b76e40629 fix: Fetch GitHub teams by name for performance (#2955)
In large organizations with thousands of teams, looping took >5s.
This fetches organizations by team name, which should be very fast!
2022-07-13 00:45:43 +00:00
Jon Ayers 7e9819f2a8 ref: move httpapi.Reponse into codersdk (#2954) 2022-07-12 19:15:02 -05:00
Kyle Carberry dde51f1caa fix: Force trap to always succeed due to incompatibility (#2953)
There are some instances of Linux that don't support trap. We should
ignore the failure in those cases.
2022-07-12 23:31:25 +00:00
Kyle Carberry 5ee112bc00 fix: Fetch all GitHub teams on login (#2951)
This wasn't looping prior, so organizations with >100 teams
couldn't login. Contributes to #2848.
2022-07-12 23:06:27 +00:00
Mathias Fredriksson 59facdd8dc fix: Show schedule commands in help, improve template (#2923)
* fix: Show schedule commands in help, improve template

* chore: Remove schedule long help, fixed by listing missing commands

* chore: Clean up annotation usage with template function

* fix: Drive-by fix for trailing whitespace for flags

Introduced in c7681370b5.
2022-07-12 23:24:53 +03:00
Mathias Fredriksson 2d048803c8 chore: Switch drpc from fork to upstream (#2949)
The https://github.com/storj/drpc/pull/31 PR was not merged, but was
replaced by:

https://github.com/storj/drpc/commit/9206537a4db76809da6ec768a0c5e45ddb618ef5

This fixes the underlying issue fixed in the fork.
2022-07-12 22:20:22 +03:00
Mathias Fredriksson e035b642b8 chore: Update yamux fork (#2948) 2022-07-12 22:10:24 +03:00
Cian Johnston 5e6320163d change default aws linux instance type to t3.micro, reduce default template TTL (#2776)
- make default template max TTL 24 hours (still less than 168)
- make default workspace autostop 2 hours unless specified otherwise
- add instance type selector to aws templates
2022-07-12 19:37:59 +01:00
Steven Masley c07a45e610 fix: Fix workspace count to exclude deleted workspaces (#2916) 2022-07-12 12:52:28 -05:00
Abhineet Jain 61c52b3090 feat: default confirm to no for cli delete (#2919) 2022-07-12 10:36:07 -07:00
Abhineet Jain b0bab3e432 feat: show last build initiator for workspaces (#2921) 2022-07-12 10:14:36 -07:00
Bruno Quaresma e172a40a91 fix: Add links to the SSH popover (#2945) 2022-07-12 16:45:53 +00:00
Bruno Quaresma 166bc273b3 feature: Add SSH button in the agent access column (#2931) 2022-07-12 13:10:38 -03:00
dependabot[bot] 0645176e66 chore: bump webpack-dev-server from 4.9.0 to 4.9.3 in /site (#2939)
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.9.0 to 4.9.3.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.9.0...v4.9.3)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 12:07:47 -04:00
dependabot[bot] 8df4212bbb chore: bump ts-loader from 9.3.0 to 9.3.1 in /site (#2940)
Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 9.3.0 to 9.3.1.
- [Release notes](https://github.com/TypeStrong/ts-loader/releases)
- [Changelog](https://github.com/TypeStrong/ts-loader/blob/main/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/ts-loader/compare/v9.3.0...v9.3.1)

---
updated-dependencies:
- dependency-name: ts-loader
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 11:58:11 -04:00
dependabot[bot] 18a9d070af chore: bump @playwright/test from 1.22.1 to 1.23.2 in /site (#2934)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.22.1 to 1.23.2.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.22.1...v1.23.2)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kira Pilot <kira@coder.com>
2022-07-12 11:22:03 -04:00
dependabot[bot] 919e3a5fb5 chore: bump @testing-library/react-hooks from 8.0.0 to 8.0.1 in /site (#2936)
Bumps [@testing-library/react-hooks](https://github.com/testing-library/react-hooks-testing-library) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/testing-library/react-hooks-testing-library/releases)
- [Changelog](https://github.com/testing-library/react-hooks-testing-library/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/react-hooks-testing-library/compare/v8.0.0...v8.0.1)

---
updated-dependencies:
- dependency-name: "@testing-library/react-hooks"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kira Pilot <kira@coder.com>
2022-07-12 11:21:49 -04:00
dependabot[bot] 8acae4b5aa chore: bump chromatic from 6.5.4 to 6.7.0 in /site (#2935)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.5.4 to 6.7.0.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.5.4...v6.7.0)

---
updated-dependencies:
- dependency-name: chromatic
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kira Pilot <kira@coder.com>
2022-07-12 11:19:17 -04:00
dependabot[bot] 516dc190ad chore: bump @typescript-eslint/eslint-plugin in /site (#2933)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.27.0 to 5.30.6.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.30.6/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:50:45 -04:00
dependabot[bot] 4cfa240065 chore: bump eslint-plugin-jest from 26.2.2 to 26.5.3 in /site (#2926)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 26.2.2 to 26.5.3.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v26.2.2...v26.5.3)

---
updated-dependencies:
- dependency-name: eslint-plugin-jest
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kira Pilot <kira@coder.com>
2022-07-12 10:46:46 -04:00
dependabot[bot] 516d955219 chore: bump webpack from 5.72.0 to 5.73.0 in /site (#2932)
Bumps [webpack](https://github.com/webpack/webpack) from 5.72.0 to 5.73.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.72.0...v5.73.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:46:15 -04:00
dependabot[bot] 453d6ff75d chore: bump eslint-plugin-jsx-a11y from 6.5.1 to 6.6.0 in /site (#2930)
Bumps [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y) from 6.5.1 to 6.6.0.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/compare/v6.5.1...v6.6.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-jsx-a11y
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:31:35 -04:00
dependabot[bot] 701821ab28 chore: bump webpack-cli from 4.9.2 to 4.10.0 in /site (#2929)
Bumps [webpack-cli](https://github.com/webpack/webpack-cli) from 4.9.2 to 4.10.0.
- [Release notes](https://github.com/webpack/webpack-cli/releases)
- [Changelog](https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.9.2...webpack-cli@4.10.0)

---
updated-dependencies:
- dependency-name: webpack-cli
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:25:49 -04:00
dependabot[bot] b4bee421e9 chore: bump xterm from 4.18.0 to 4.19.0 in /site (#2927)
Bumps [xterm](https://github.com/xtermjs/xterm.js) from 4.18.0 to 4.19.0.
- [Release notes](https://github.com/xtermjs/xterm.js/releases)
- [Commits](https://github.com/xtermjs/xterm.js/compare/4.18.0...4.19.0)

---
updated-dependencies:
- dependency-name: xterm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:18:11 -04:00
dependabot[bot] c178f37a3e chore: bump eslint-import-resolver-typescript in /site (#2928)
Bumps [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) from 2.7.1 to 3.2.5.
- [Release notes](https://github.com/import-js/eslint-import-resolver-typescript/releases)
- [Changelog](https://github.com/import-js/eslint-import-resolver-typescript/blob/master/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-import-resolver-typescript/compare/v2.7.1...v3.2.5)

---
updated-dependencies:
- dependency-name: eslint-import-resolver-typescript
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:13:38 -04:00
dependabot[bot] 3070ef8903 chore: bump @xstate/cli from 0.1.7 to 0.2.1 in /site (#2908)
Bumps @xstate/cli from 0.1.7 to 0.2.1.

---
updated-dependencies:
- dependency-name: "@xstate/cli"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 09:49:07 -04:00
dependabot[bot] d497e1ce8d chore: bump cron-parser from 4.4.0 to 4.5.0 in /site (#2924)
Bumps [cron-parser](https://github.com/harrisiirak/cron-parser) from 4.4.0 to 4.5.0.
- [Release notes](https://github.com/harrisiirak/cron-parser/releases)
- [Commits](https://github.com/harrisiirak/cron-parser/compare/4.4.0...4.5.0)

---
updated-dependencies:
- dependency-name: cron-parser
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 09:45:22 -04:00
dependabot[bot] 146473cafd chore: bump prettier-plugin-organize-imports in /site (#2910)
Bumps [prettier-plugin-organize-imports](https://github.com/simonhaenisch/prettier-plugin-organize-imports) from 2.3.4 to 3.0.0.
- [Release notes](https://github.com/simonhaenisch/prettier-plugin-organize-imports/releases)
- [Commits](https://github.com/simonhaenisch/prettier-plugin-organize-imports/compare/v2.3.4...v3.0.0)

---
updated-dependencies:
- dependency-name: prettier-plugin-organize-imports
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 09:45:09 -04:00
dependabot[bot] dcf5d57357 chore: bump @typescript-eslint/parser from 5.25.0 to 5.30.6 in /site (#2911)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.25.0 to 5.30.6.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.30.6/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 09:26:53 -04:00
Colin Adler 92ebdaec5a feat: force legacy tunnels to new version (#2914) 2022-07-12 00:33:35 +00:00
Ammar Bandukwala 59de95b8bb Minor docs fixes (#2920)
* Fix image links in quickstart

* Add myself to CODEOWNERS for docs
2022-07-11 22:35:24 +00:00
Abhineet Jain df13b9dfea fix: open multiple app windows (#2912) 2022-07-11 12:24:28 -07:00
Kyle Carberry 2c89e07e12 fix: Redirect to login when unauthenticated and requesting a workspace app (#2903)
Fixes #2884.
2022-07-11 13:46:01 -05:00
dependabot[bot] 08d90f7b4f chore: bump mini-css-extract-plugin from 2.6.0 to 2.6.1 in /site (#2906)
Bumps [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/webpack-contrib/mini-css-extract-plugin/releases)
- [Changelog](https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack-contrib/mini-css-extract-plugin/compare/v2.6.0...v2.6.1)

---
updated-dependencies:
- dependency-name: mini-css-extract-plugin
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 14:45:16 -04:00
dependabot[bot] 00fee2e501 chore: bump jest-junit from 13.2.0 to 14.0.0 in /site (#2907)
Bumps [jest-junit](https://github.com/jest-community/jest-junit) from 13.2.0 to 14.0.0.
- [Release notes](https://github.com/jest-community/jest-junit/releases)
- [Commits](https://github.com/jest-community/jest-junit/compare/v13.2.0...v14.0.0)

---
updated-dependencies:
- dependency-name: jest-junit
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 14:45:05 -04:00
Ketan Gangatirkar 536c77af5d fix: confirm when deleting template (#2866)
* prompt for confirmation before deleting templates (#2830)

* populate templateNames from the interactive picker too

* allow skipping delete confirmation prompt with --yes flag

* eliminate unnecessary newline

* test both confirmation of delete and `--yes` with no confirmation

* fix failing test that needed --yes

* remove unnecessary empty line the linter disliked

* make the tests correct
2022-07-11 13:13:56 -05:00
dependabot[bot] fa7dcf615a chore: bump prettier from 2.6.2 to 2.7.1 in /site (#2896)
Bumps [prettier](https://github.com/prettier/prettier) from 2.6.2 to 2.7.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.6.2...2.7.1)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 14:13:42 -04:00
dependabot[bot] 7d8b092af9 chore: bump @types/node from 14.18.16 to 14.18.21 in /site (#2905)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.18.16 to 14.18.21.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 14:12:26 -04:00
dependabot[bot] 312a19c270 chore: bump github.com/hashicorp/go-version from 1.5.0 to 1.6.0 (#2818)
Bumps [github.com/hashicorp/go-version](https://github.com/hashicorp/go-version) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/hashicorp/go-version/releases)
- [Changelog](https://github.com/hashicorp/go-version/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/go-version/compare/v1.5.0...v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-version
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 18:06:28 +00:00
dependabot[bot] a585a986d8 chore: bump eslint-plugin-react-hooks from 4.5.0 to 4.6.0 in /site (#2864)
Bumps [eslint-plugin-react-hooks](https://github.com/facebook/react/tree/HEAD/packages/eslint-plugin-react-hooks) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/HEAD/packages/eslint-plugin-react-hooks)

---
updated-dependencies:
- dependency-name: eslint-plugin-react-hooks
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 13:01:50 -05:00
dependabot[bot] 420a07762a chore: bump go.opentelemetry.io/otel/exporters/otlp/otlptrace (#2895)
Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 13:01:30 -05:00
dependabot[bot] ef691f297a chore: bump @storybook/addon-actions from 6.4.22 to 6.5.9 in /site (#2519)
Bumps [@storybook/addon-actions](https://github.com/storybookjs/storybook/tree/HEAD/addons/actions) from 6.4.22 to 6.5.9.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.9/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.9/addons/actions)

---
updated-dependencies:
- dependency-name: "@storybook/addon-actions"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 13:54:11 -04:00
Ammar Bandukwala 13d7466ebc docs: add Docker quickstart (#2875)
* Fix docker-compose file

* Add docker quickstart
2022-07-11 12:05:05 -05:00
Ketan Gangatirkar 5eecbaa534 fix: trim leading and trailing spaces from template parameters (#2829) (#2879) 2022-07-11 11:46:03 -05:00
Mathias Fredriksson 749694b7de fix: Standardize and wrap example descriptions at 80 chars (#2894) 2022-07-11 19:08:09 +03:00
Kira Pilot 50e8a27d04 fix: removing noisy shutdown snapshots (#2899)
* fix: removing noisy shutdown snapshots

resolves #2685

* removing workspaceSchedule stories
2022-07-11 11:34:58 -04:00
Nicholas Pease 74d484eacf Update docs in reference to command change in #2530 (#2902) 2022-07-11 15:30:54 +00:00
dependabot[bot] 6d0aab4d2c chore: bump go.opentelemetry.io/otel/sdk from 1.7.0 to 1.8.0 (#2900)
Bumps [go.opentelemetry.io/otel/sdk](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/sdk
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 10:22:59 -05:00
Ben Potter 71cb223564 chore: add matlab icon (#2891) 2022-07-11 17:19:35 +02:00
dependabot[bot] daadb9a532 chore: bump github.com/nhatthm/otelsql from 0.3.3 to 0.3.4 (#2898)
Bumps [github.com/nhatthm/otelsql](https://github.com/nhatthm/otelsql) from 0.3.3 to 0.3.4.
- [Release notes](https://github.com/nhatthm/otelsql/releases)
- [Commits](https://github.com/nhatthm/otelsql/compare/v0.3.3...v0.3.4)

---
updated-dependencies:
- dependency-name: github.com/nhatthm/otelsql
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 09:36:05 -05:00
dependabot[bot] 8f55254167 chore: bump github.com/elastic/go-sysinfo from 1.8.0 to 1.8.1 (#2889)
Bumps [github.com/elastic/go-sysinfo](https://github.com/elastic/go-sysinfo) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/elastic/go-sysinfo/releases)
- [Changelog](https://github.com/elastic/go-sysinfo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/elastic/go-sysinfo/compare/v1.8.0...v1.8.1)

---
updated-dependencies:
- dependency-name: github.com/elastic/go-sysinfo
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 09:11:11 -05:00
Kyle Carberry 1973786335 fix: Add trap to agent startup script to sleep on failure (#2873)
* fix: Add `trap` to agent startup script to sleep on failure

The Docker Terraform provider removes containers immediately on exit, making
it difficult to debug a failed container start with Coder. This will sleep on
exit and output a friendly log, which should assist with debugging failures.

* Update provisionersdk/agent.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update provisionersdk/agent.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-07-11 14:10:06 +00:00
dependabot[bot] 3e279b6d23 chore: bump tailscale.com from 1.26.1 to 1.26.2 (#2890)
Bumps [tailscale.com](https://github.com/tailscale/tailscale) from 1.26.1 to 1.26.2.
- [Release notes](https://github.com/tailscale/tailscale/releases)
- [Commits](https://github.com/tailscale/tailscale/compare/v1.26.1...v1.26.2)

---
updated-dependencies:
- dependency-name: tailscale.com
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 09:09:17 -05:00
Mathias Fredriksson c7681370b5 fix: Wrap help flags at 100 chars (#2893)
Because the actual flags take quite a bit of space, wrapping at 80
characters creates a very cramped output for e.g. `coder server`, for
this reasons, flags are wrapped at 100 chars (vs. standard 80).

The `Consumes $ENV_FLAG` message was put on a newline for consistency,
this should allow users to learn where to look for the informations.

Side note: we should perhaps stop adding period (`.`) at the end of flag
descriptions to be consistent, for instance, command helps usually don't
have one.

This change fixes the biggest issue in #2363, but not all `--help`
output is guaranteed (yet) to wrap at 80-100 chars.

Fixes #2363
2022-07-11 17:07:25 +03:00
dependabot[bot] 2bf78aa548 chore: bump go.opentelemetry.io/otel/trace from 1.7.0 to 1.8.0 (#2887)
Bumps [go.opentelemetry.io/otel/trace](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/trace
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 08:54:26 -05:00
Mathias Fredriksson 41de2d8b67 fix: Replace github.com/hashicorp/yamux with our fork (#2883) 2022-07-11 16:51:03 +03:00
dependabot[bot] c99c15232c chore: bump xterm-addon-web-links from 0.5.1 to 0.6.0 in /site (#2892)
Bumps [xterm-addon-web-links](https://github.com/xtermjs/xterm.js) from 0.5.1 to 0.6.0.
- [Release notes](https://github.com/xtermjs/xterm.js/releases)
- [Commits](https://github.com/xtermjs/xterm.js/commits/0.6)

---
updated-dependencies:
- dependency-name: xterm-addon-web-links
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 08:48:22 -05:00
dependabot[bot] 70d394f6a1 chore: bump @storybook/addon-links from 6.4.22 to 6.5.9 in /site (#2861)
Bumps [@storybook/addon-links](https://github.com/storybookjs/storybook/tree/HEAD/addons/links) from 6.4.22 to 6.5.9.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.9/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.9/addons/links)

---
updated-dependencies:
- dependency-name: "@storybook/addon-links"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 08:56:33 -04:00
Cian Johnston 8a59178e7e provisionersdk: extract and embed agent bootstrap scripts (#2886)
This commit extracts the existing hard-coded agent scripts to their own files and embeds them using go:embed.
We can more easily use e.g. shellcheck to validate our agent scripts.
2022-07-11 12:43:14 +01:00
Cian Johnston 8d8c1a1927 develop.sh: add missing embed tag (#2885) 2022-07-11 12:20:54 +01:00
Kyle Carberry 4f1df88529 fix: Always output job failure reason in provisioner daemon tests (#2850)
This flake can be seen here: https://github.com/coder/coder/runs/7186604615?check_suite_focus=true
2022-07-10 14:52:33 -05:00
mark-theshark 08a781f401 docs: expand web IDE documentation
* docker group for coder user and code-server xterm issue and port-forward web IDEs

* add screenshots of jupyterlab, rstudio and airflow in Coder

* Clean up English in install and minor edits

* Integrate Jupyter

Co-authored-by: ammario <ammar@ammar.io>
2022-07-09 02:40:05 +00:00
Kyle Carberry dff6e97f83 feat: Add allowlist of GitHub teams for OAuth (#2849)
Fixes #2848.
2022-07-08 21:37:18 -05:00
Kyle Carberry c801da45f3 fix: Add https: to image CSP to allow external images (#2870)
This broke external application icons.
2022-07-08 21:35:59 -05:00
Kyle Carberry 411caa20df fix: Refactor preinstall script to use useradd if adduser is not available (#2858)
Fixes #2800 preventing installation on Alpine.
2022-07-08 16:09:19 -05:00
Kyle Carberry 52fa1f2464 fix: Handle all method types for app proxying (#2868)
All methods need to be accepted on app routes. Some apps
may POST (like Jupyter).
2022-07-08 15:45:28 -05:00
dependabot[bot] 8589eb693a chore: bump sql-formatter from 6.1.1 to 8.0.2 in /site (#2862)
Bumps [sql-formatter](https://github.com/sql-formatter-org/sql-formatter) from 6.1.1 to 8.0.2.
- [Release notes](https://github.com/sql-formatter-org/sql-formatter/releases)
- [Changelog](https://github.com/sql-formatter-org/sql-formatter/blob/master/.release-it.json)
- [Commits](https://github.com/sql-formatter-org/sql-formatter/compare/v6.1.1...v8.0.2)

---
updated-dependencies:
- dependency-name: sql-formatter
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 14:54:43 -05:00
dependabot[bot] ff5930c7fe chore: bump ts-node from 10.7.0 to 10.8.2 in /site (#2823)
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.7.0 to 10.8.2.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v10.7.0...v10.8.2)

---
updated-dependencies:
- dependency-name: ts-node
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 14:29:15 -05:00
Ketan Gangatirkar 2609be767d feat: add timestamps to output at end of some workspace and template subcommands (#2831) 2022-07-08 14:27:56 -05:00
Kyle Carberry 584448e089 fix: worksapces -> workspaces in template create CLI (#2857)
Fixes #2846.
2022-07-08 14:22:30 -05:00
Ketan Gangatirkar ca90189a9b fix: Upload the Windows .exe in CI (#2833)
Co-authored-by: kylecarbs <kyle@carberry.com>
2022-07-08 18:32:16 +00:00
dependabot[bot] c2bb5ee2b1 chore: bump github.com/klauspost/compress from 1.15.6 to 1.15.7 (#2816)
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.15.6 to 1.15.7.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Changelog](https://github.com/klauspost/compress/blob/master/.goreleaser.yml)
- [Commits](https://github.com/klauspost/compress/compare/v1.15.6...v1.15.7)

---
updated-dependencies:
- dependency-name: github.com/klauspost/compress
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 13:13:50 -05:00
dependabot[bot] 5df5507cf3 chore: bump github.com/stretchr/testify from 1.7.5 to 1.8.0 (#2817)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.5 to 1.8.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.5...v1.8.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 13:13:18 -05:00
dependabot[bot] a7b73fe001 chore: bump google.golang.org/api from 0.85.0 to 0.86.0 (#2819)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.85.0 to 0.86.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.85.0...v0.86.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 13:13:07 -05:00
dependabot[bot] 7ae1878c51 chore: bump github.com/unrolled/secure from 1.10.0 to 1.11.0 (#2820)
Bumps [github.com/unrolled/secure](https://github.com/unrolled/secure) from 1.10.0 to 1.11.0.
- [Release notes](https://github.com/unrolled/secure/releases)
- [Commits](https://github.com/unrolled/secure/compare/v1.10.0...v1.11.0)

---
updated-dependencies:
- dependency-name: github.com/unrolled/secure
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 13:12:56 -05:00
Kyle Carberry bacfd630fb fix: Disable random workspace filter tests due to flakes (#2855)
Contributes towards #2854.
2022-07-08 13:01:00 -05:00
Kyle Carberry 3d40cb85b7 fix: Reduce count to 1 for PostgreSQL tests (#2852)
It's unnecessary for these to run twice. It increases CI times  without
providing much additional assurance tests don't have race conditions.
This already runs with `-race` too.
2022-07-07 23:14:35 -05:00
Kyle Carberry dc58d1b734 fix: Update text in logout tests (#2851)
This fixes CI!
2022-07-07 21:46:31 -05:00
Ketan Gangatirkar 4f1e9dae27 Ketan/cli help tweak (#2803)
* fix CLI help text for logout

"log out" is verb, "logout" is a noun

* add CLI help for port-forward command (#2802)

* found another noun where a verb should be
2022-07-04 15:48:08 -05:00
Ketan Gangatirkar 88f852b42f restore windows builds to CI (#2827)
restore windows builds to CI
2022-07-04 15:37:48 -05:00
Spike Curtis b1e4cfe6c8 fix pubsub/poll race on provisioner job logs (#2783)
* fix pubsub/poll race on provisioner job logs

Signed-off-by: Spike Curtis <spike@coder.com>

* only cancel on non-error

Signed-off-by: Spike Curtis <spike@coder.com>

* Improve logging & comments

Signed-off-by: spikecurtis <spike@spikecurtis.com>
2022-07-01 14:07:18 -07:00
Abhineet Jain c1b3080162 fix: restrict edit schedule access (#2698) 2022-07-01 20:43:51 +00:00
Bruno Quaresma ea5c2cd09b refactor: Downsize the search bar a bit (#2789) 2022-07-01 17:37:08 -03:00
Kira Pilot ead3516fb5 fixing searchBar style type (#2785) 2022-07-01 15:09:44 -04:00
Bruno Quaresma 2d0ea00ffd refactor: Move schedule to the header (#2775) 2022-07-01 18:26:27 +00:00
Spike Curtis 22febc749a provisionerd sends failed or complete last (#2732)
* provisionerd sends failed or complete last

Signed-off-by: Spike Curtis <spike@coder.com>

* Move runner into package

Signed-off-by: Spike Curtis <spike@coder.com>

* Remove jobRunner interface

Signed-off-by: Spike Curtis <spike@coder.com>

* renames and slight reworking from code review

Signed-off-by: Spike Curtis <spike@coder.com>

* Reword comment about okToSend

Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-01 09:55:46 -07:00
Jon Ayers e5d5fa7706 fix: reprompt for matching passwords on mismatch (#2758)
- Previously we only re-prompted for the password confirmation.
2022-07-01 11:49:39 -05:00
Jon Ayers 554d9917c0 feat: make 'templates update [name]' optional (#2761)
- If the name is not specified the current working directory
  name is used or the name specified by "--directory". This
  reflects 'templates create" behavior.
2022-07-01 11:49:29 -05:00
David Wahler 0dbfd265fb chore: clean up scripts for internal godoc site that's no longer used (#2770) 2022-07-01 10:55:05 -05:00
Abhineet Jain de1fc40000 fix: consistent workspace status b/w CLI and UI (#2743) 2022-07-01 14:40:03 +00:00
Bruno Quaresma 9776e66ff9 refactor: Make the applications more notable in the resources table (#2774) 2022-07-01 10:48:48 -03:00
Cian Johnston e14953461c fix: develop.sh: do not clobber existing login, pre-build coder binary for speed (#2750) 2022-07-01 11:09:19 +01:00
Colin Adler 482feef373 feat(devtunnel): support geodistributed tunnels (#2711) 2022-06-30 19:11:13 -05:00
Kira Pilot ae59f166fd chore: cleaning up workspaces table code (#2765)
* cleaning up workspace table code

* Update site/src/components/WorkspacesTable/WorkspacesTableBody.tsx

Co-authored-by: Joe Previte <jjprevite@gmail.com>

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-06-30 16:50:15 -04:00
David Wahler 29be359f3d Clarify wording of install.sh --dry-run output (#2751) 2022-06-30 13:01:54 -05:00
Jon Ayers 6ad0f31687 fix: don't check version on gitssh cmds (#2757) 2022-06-30 12:03:41 -05:00
Kira Pilot 64997705ab feat: adding active and hover states to search input (#2741)
* feat: adding active and hover states to search input

* adding error state

* cleaning up error state

* adding input value
2022-06-30 11:57:38 -04:00
Cian Johnston 8ad35c7353 feature: allow editing workspace deadline in UI (#2721)
This PR adds two buttons to edit the workspace deadline.

- These buttons only appear when a workspace is running and has a non-zero deadline
- Clicking the  button increases the deadline by one hour, to a max of 24 hours in the future
- Clicking the  button decreases the deadline by one hour, to a minimum of 30 minutes in the future (when the warning banner appears)
2022-06-30 16:45:14 +01:00
Abhineet Jain 9df6bc7ba1 fix: update template updated_at value (#2729)
* fix: update template updated_at value

* use Go time for all updated_at updates
2022-06-30 12:14:51 +00:00
Jon Ayers 7df5827767 feat: add version checking to CLI (#2725) 2022-06-29 17:49:40 -05:00
dependabot[bot] 45328ec0f1 chore: bump github.com/AlecAivazis/survey/v2 from 2.3.4 to 2.3.5 (#2277)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-29 16:49:24 -05:00
Steven Masley 38fb6cb4b4 test: Try again in unit test if user already exists (#2730) 2022-06-29 14:17:32 -05:00
Kira Pilot 03fd063d20 chore: adding some quality of life Playwright comments (#2726) 2022-06-29 14:25:56 -04:00
Kira Pilot d9668f7a4e add debounced search on type to the search bar (#2703)
* debounced search on type

* loading workspaces on page entry

* fixing e2e test

* removing boilerplate
2022-06-29 13:43:41 -04:00
Colin Adler 6a55889362 fix: disable wireguard in portforward and gitssh tests (#2728) 2022-06-29 17:37:26 +00:00
Steven Masley baa36182c0 fix: Allow spaces in searches (#2723) 2022-06-29 11:59:38 -05:00
Steven Masley 889e2e68ea security: Tighten csp connect-src to prevent external websockets (#2705) 2022-06-29 16:42:17 +00:00
Steven Masley ea7f9e2d47 chore: Parameter listing cmd default adding scope column (#2718) 2022-06-29 11:29:21 -05:00
Ammar Bandukwala a06bea7a3f docs: improve providers illustration (#2713)
* Remove unused providers.png

* Add beautiful providers-compute
2022-06-28 22:11:43 -05:00
Colin Adler 2b6dcb842d Revert "feat: add version checking to CLI" (#2712) 2022-06-29 02:42:23 +00:00
Jon Ayers 7ee7be3391 feat: add version checking to CLI (#2643)
* feat: add version checking to CLI
2022-06-28 20:55:34 -05:00
Jon Ayers 4b6189c9e9 fix: fix panic in template pull (#2710) 2022-06-28 19:54:28 -05:00
Abhineet Jain 0d25e1752f feat: Add filter on Users page (#2653)
This commit adds a new filter feature to the Users page.

- adds a filter to the getUsers API call and users state machine.
- adds filter UI to Users page view.
- addresses error handling in the filter component, users page and machine.
- refactors user table code.
- refactors common code for workspace filter.
- adds and updates unit tests and stories.
2022-06-28 19:12:15 -04:00
Spike Curtis cb2d1f488a fix: ci uses a migrated DB template (#2696)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-28 14:42:19 -07:00
Steven Masley 576aef40f2 chore: Add linter rule to catch missing return after http writes (#2702) 2022-06-28 14:13:37 -05:00
Katie Horne 09cb778620 chore: add info re: always updating images (#2635) 2022-06-28 14:06:54 -05:00
Abhineet Jain 37f9dffc02 fix: remove gotests.xml from .gitignore (#2704) 2022-06-28 15:20:30 +00:00
Cian Johnston 0052e6a21b add CAP_NET_BIND_SERVICE to coder.service (#2699)
* add CAP_NET_BIND_SERVICE to systemd unit

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-06-28 16:02:42 +01:00
Colin Adler a494489ffa fix: use valid ip mask in api keys when remote address is ipv6 (#2695) 2022-06-27 20:31:18 +00:00
Kyle Carberry 69f27efead fix: Close parameter file before test exit (#2694)
Flake seen here:
https://github.com/coder/coder/runs/7079404499?check_suite_focus=true
2022-06-27 14:42:26 -05:00
Kyle Carberry abfae1b4aa fix: Add coder user to docker group on installation (#2693)
This makes for a simpler setup, and reduces the likelihood
a user runs into a strange issue.
2022-06-27 14:12:43 -05:00
Timo 752d6096a1 example: Added docker volume to docker-code-server (#2592) 2022-06-27 14:07:30 -05:00
Jon Ayers 2353687610 feat: unexpose coderdtest.NewWithAPI (#2613)
* feat: unexpose coderdtest.NewWithAPI
2022-06-27 13:50:52 -05:00
Timo 7dfec821f5 example: Added code-server icon (#2591) 2022-06-27 14:46:41 -04:00
dependabot[bot] 2d3d822273 chore: bump tailscale.com from 1.26.0 to 1.26.1 (#2677)
Bumps [tailscale.com](https://github.com/tailscale/tailscale) from 1.26.0 to 1.26.1.
- [Release notes](https://github.com/tailscale/tailscale/releases)
- [Commits](https://github.com/tailscale/tailscale/compare/v1.26.0...v1.26.1)

---
updated-dependencies:
- dependency-name: tailscale.com
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 12:29:16 -05:00
Jon Ayers 3a3aa493f1 fix: use absolute path for config-ssh coder binary (#2647) 2022-06-27 12:15:55 -05:00
Kyle Carberry 6429dfee1f test: Use a template to prevent migrations from running for every test (#2462)
* test: Use a template to prevent migrations from running for every test

* Create a single makefile target

* Fix built-in race

* Extend timeout of built-in PostgreSQL fetch
2022-06-27 17:07:39 +00:00
Kyle Carberry d9da96cad0 fix: Add test for SCP (#2692)
* fix: Elongate agent disconnect timeout in tests

This will fix the flake seen here:
https://github.com/coder/coder/runs/7071719863?check_suite_focus=true

* fix: Add test for SCP

This was hanging due to the stdin pipe never being closed.
A test has been added to make sure it works!
2022-06-27 17:41:53 +01:00
dependabot[bot] a805565cd4 chore: bump github.com/hashicorp/hcl/v2 from 2.12.0 to 2.13.0 (#2680)
Bumps [github.com/hashicorp/hcl/v2](https://github.com/hashicorp/hcl) from 2.12.0 to 2.13.0.
- [Release notes](https://github.com/hashicorp/hcl/releases)
- [Changelog](https://github.com/hashicorp/hcl/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/hcl/compare/v2.12.0...v2.13.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hcl/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 11:36:32 -05:00
Steven Masley f41b50a253 feat: Updating workspace prompts new parameters (#2598) 2022-06-27 16:19:10 +00:00
Katie Horne 407c47fd65 chore: change Coder v2 to Coder OSS in docs (#2630) 2022-06-27 11:07:17 -05:00
dependabot[bot] 68b5f0a35a chore: bump github.com/jedib0t/go-pretty/v6 from 6.3.2 to 6.3.3 (#2689)
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.3.2 to 6.3.3.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.3.2...v6.3.3)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 15:54:30 +00:00
dependabot[bot] 998e75feb3 chore: bump github.com/hashicorp/hc-install from 0.3.2 to 0.4.0 (#2691)
Bumps [github.com/hashicorp/hc-install](https://github.com/hashicorp/hc-install) from 0.3.2 to 0.4.0.
- [Release notes](https://github.com/hashicorp/hc-install/releases)
- [Changelog](https://github.com/hashicorp/hc-install/blob/main/.goreleaser.yml)
- [Commits](https://github.com/hashicorp/hc-install/compare/v0.3.2...v0.4.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hc-install
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 15:48:41 +00:00
dependabot[bot] 5c8b09fee7 chore: bump github.com/stretchr/testify from 1.7.3 to 1.7.5 (#2690)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.3 to 1.7.5.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.3...v1.7.5)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 10:37:43 -05:00
dependabot[bot] 975b4f6df2 chore: bump github.com/pion/webrtc/v3 from 3.1.41 to 3.1.42 (#2688)
Bumps [github.com/pion/webrtc/v3](https://github.com/pion/webrtc) from 3.1.41 to 3.1.42.
- [Release notes](https://github.com/pion/webrtc/releases)
- [Commits](https://github.com/pion/webrtc/compare/v3.1.41...v3.1.42)

---
updated-dependencies:
- dependency-name: github.com/pion/webrtc/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 15:12:22 +00:00
Kyle Carberry 08f4b193e1 fix: Elongate agent disconnect timeout in tests (#2687)
This will fix the flake seen here:
https://github.com/coder/coder/runs/7071719863?check_suite_focus=true
2022-06-27 15:06:51 +00:00
dependabot[bot] 4a2d29948e chore: bump github.com/spf13/cobra from 1.4.0 to 1.5.0 (#2679)
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.4.0...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 09:58:02 -05:00
Kyle Carberry 33a04f661f fix: Check if start is nil before consuming in echo provisioner (#2686)
This caused a race seen here:
https://github.com/coder/coder/runs/7074123929?check_suite_focus=true#step:10:217
2022-06-27 09:57:37 -05:00
Abhineet Jain 82938944e7 refactor: update Prettier printWidth to 100 (#2684) 2022-06-27 10:53:44 -04:00
Camdon 09722ae1ef Bump version number for coder terraform provider (#2673) 2022-06-27 08:49:26 -05:00
Cian Johnston bbbd5241c3 develop.sh: attempt to create a Docker template automatically (#2627)
This commit makes the following changes:

- Adds two variables docker_host and docker_arch to the example docker-code-server template
- Adds an example params.yaml to docker-code-server and updates the README.md to reference these parameters
- scripts/develop.sh will now attempt to create a template using docker-code-server with the appropriate parameters for the environment
- Updated Lima example to make use of the template parameters for docker-code-server


Additional drive-bys:

- webpack.dev.ts references CODER_HOST and not CODERV2_HOST; updated develop.sh accordingly
- develop.sh should now terminate child processes upon error.
2022-06-27 09:59:08 +01:00
dependabot[bot] f9d830a2b6 chore: bump google.golang.org/api from 0.82.0 to 0.85.0 (#2632)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.82.0 to 0.85.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.82.0...v0.85.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-26 18:43:21 -05:00
Kyle Carberry 16ac54cbd9 fix: Wait for workspace build to complete before running SSH tests (#2671)
This was causing a race shown here:
https://github.com/coder/coder/runs/7063713786?check_suite_focus=true
2022-06-26 23:10:52 +00:00
Kyle Carberry dac6838fc3 fix: Await workspace build job before waiting for CLI output (#2670)
This was causing occasional flakes seen here:
https://github.com/coder/coder/runs/7063142245?check_suite_focus=true
2022-06-26 22:05:37 +00:00
Kyle Carberry 4851d932c4 fix: Split host and port before storing IP (#2594)
The IP was always nil prior, and this fixes the test to
check for that as well!
2022-06-26 21:22:03 +00:00
Kyle Carberry 545a9f3435 fix: Increase wait time for agent connection tests (#2667)
This was causing a test flake seen here:
https://github.com/coder/coder/runs/7063032150?check_suite_focus=true
2022-06-26 21:15:59 +00:00
Kyle Carberry 01c31b47a3 fix: Adjust pagination limit to be zero-based (#2663)
There isn't a use-case for querying a limit of zero. Using
-1 led to issues when using default parameters for querying.
2022-06-26 20:23:25 +00:00
Kyle Carberry 95e854d144 fix: Update database fake to check for nil time when streaming logs (#2664)
This caused a test flake seen here: https://github.com/coder/coder/runs/7056544834?check_suite_focus=true
2022-06-26 19:52:15 +00:00
Steven Masley 47796211d7 fix: Properly remove non matched workspaces (#2649) 2022-06-25 16:37:21 -05:00
Steven Masley 3312c814bd feat: Workspace filters case insensitive (#2646) 2022-06-25 06:22:59 -05:00
Abhineet Jain 90815e5119 feat: improve Users filter API (#2645) 2022-06-24 23:55:28 +00:00
Jon Ayers d1c69866e8 fix: provide environment variable for CLI session token (#2648) 2022-06-24 18:50:35 -05:00
Colin Adler 6aed58f486 feat: add ssh support over wireguard (#2642) 2022-06-24 16:21:46 -05:00
Colin Adler 26e85b0bbc fix: use typed wireguard public keys in database structs (#2639) 2022-06-24 15:45:28 -05:00
Oxylibrium 115730341e fix: ensure gcp resource names are lowercase (#2619) 2022-06-24 15:11:24 -04:00
Colin Adler 46c6b9ee27 fix: use correct default wireguard public key (#2638) 2022-06-24 17:16:36 +00:00
Abhineet Jain bd07284a68 feat: Add success messages for CLI commands (#2634) 2022-06-24 16:30:22 +00:00
Colin Adler 05b67ab1cf feat: peer wireguard (#2445) 2022-06-24 10:25:01 -05:00
Steven Masley d21ab2115d feat: Backend api for filtering users using filter query string (#2553)
* User search query string
2022-06-24 10:02:23 -05:00
Oxylibrium 981fb2764f fix: add copy fallback for insecure contexts (#2044) 2022-06-23 16:35:12 -04:00
Oxylibrium 885e7fd03e chore: update tsconfig target to es2018 (#2616) 2022-06-23 15:52:42 -04:00
Garrett Delfosse 0bcdfd584f fix: order apps by name (#2614) 2022-06-23 19:18:03 +00:00
Ben Potter a39a8563cc docs: use simplified path for dotfiles (#2615) 2022-06-23 14:12:35 -05:00
Abhineet Jain 9c8079b25e refactor: Extract workspace filter into a separate component (#2601) 2022-06-23 11:30:53 -04:00
Kira Pilot 929227d0f8 bug: fix chromatic schedule bug (#2481) 2022-06-23 11:25:07 -04:00
Presley Pizzo 65870e65ce feat: Move agent status (#2593)
* Move agent status

* Format
2022-06-23 10:18:56 -04:00
Cian Johnston ac557e02b8 clean site/out and enforce make bin (#2604) 2022-06-23 15:16:27 +01:00
Katie Horne 4eda7034ee chore: fix broken links to use full path (#2606) 2022-06-23 09:04:31 -05:00
Kyle Carberry b55fca4904 fix: Increase timeout for streaming logs (#2596)
One second wasn't long enough, and was causing flakes in CI.
2022-06-23 09:00:00 -05:00
Abhineet Jain c6b1daabc5 feat: Download default terraform version when minor version mismatches (#1775) 2022-06-22 23:11:52 +00:00
Garrett Delfosse 6a2a145545 fix: simplify terminal link (#2597) 2022-06-22 17:10:58 -05:00
Kira Pilot 97d1d2f4f0 added a default app icon (#2595)
resolves #2268
2022-06-22 17:05:21 -04:00
Eric Paulsen 7dc3f5f92b init: oauth docs (#2565)
* init: oauth docs

* chore: update directories

* update: feedback
2022-06-22 15:25:06 -05:00
Mathias Fredriksson 69b7eed7ed feat: Check decompressed coder-slim binaries via SHA1 (#2556) 2022-06-22 21:33:23 +03:00
Cian Johnston a0c8e70d1b scripts/develop.sh: remove nc dependency (#2590) 2022-06-22 18:04:12 +00:00
Kyle Carberry 3f9776784c fix: Subtract a second when listening in TestWorkspaceBuildLogs (#2588)
This allowed a test flake seen here:
https://github.com/coder/coder/runs/7009119403?check_suite_focus=true#step:9:151
2022-06-22 17:48:03 +00:00
Abhineet Jain cfbda57990 fix: Parse 24h time format from schedule cron in CLI (#2586)
* fix: parse 24h time format from schedule cron in cli

* add unit test
2022-06-22 17:45:00 +00:00
Kyle Carberry b7eeb436ad feat: Add ip_address to API keys (#2580)
Fixes #2561.
2022-06-22 17:32:21 +00:00
Kyle Carberry caf9c41a9e fix: Stop sending before logs when after is specified (#2585)
This fixes duplicate logs appearing in completed jos!
2022-06-22 17:09:28 +00:00
Kyle Carberry 437066ce20 fix: Stop sending additional signals in Shutdown test (#2582)
Coder was exiting before the additional signals were handled,
which caused occasional CI failures.
2022-06-22 11:32:34 -05:00
Abhineet Jain f72a6d09fc fix: Open new windows for terminals (#2568) 2022-06-22 12:29:08 -04:00
David Wahler c366725472 Revert changes to scripts/build_go_matrix.sh from 1778db2 (#2581) 2022-06-22 15:59:20 +00:00
Mathias Fredriksson 11c47e0d3b feat: Rename config-ssh --diff to --dry-run (#2575)
* feat: Rename config-ssh `--diff` to `--dry-run`

Since the intent between diff and dry-run are different, this change
allows for interactive prompts to be shown during `--dry-run`,
previously prompts were disabled. Dry-run can also be chanied with
`--yes` and `--use-previous-options` for non-interactive modes.

Dry-run is like a normal run with changes replaced by diff.

Fixes #2530

Co-authored-by: Cian Johnston <cian@coder.com>
2022-06-22 18:33:08 +03:00
Abhineet Jain bd19fcbae1 Wrap code text in template readme files (#2562) 2022-06-22 11:01:43 -04:00
Cian Johnston 92bcacebde cli/templateinit: add links to template READMEs (#2576)
- template init: add links to template docs
- examples: add URL field to examples, ensure that example fields are always non-empty
- cliui: bump wrap width to 80 from 58
2022-06-22 14:15:04 +00:00
Katie Horne 34222b2260 chore: add doc on roles, user management (#2548) 2022-06-22 13:36:48 +00:00
Kyle Carberry 1778db23cb fix: Use WebSockets to stream workspace build logs (#2569)
* fix: Use WebSockets to stream workspace build logs

This was using a streaming HTTP request before, which didn't work
on my version of Chrome. This method seemed less reliable and standard
than a WebSocket, so figured switching would be best.

* Update site/src/xServices/workspaceBuild/workspaceBuildXService.ts

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>

* Update site/src/pages/WorkspaceBuildPage/WorkspaceBuildPage.test.tsx

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>

* Update site/src/api/api.ts

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>

* Remove unused prop

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>
2022-06-22 13:23:14 +00:00
Cian Johnston dc7d6def8e improve develop.sh (#2572)
- Running make dev now prompts you to run ./scripts/develop.sh manually, as GNU make does not appear to pass SIGINT to subprocesses.
- Added checks to develop.sh to ensure that coderd is listening before running our initial setup steps
- Add some more troubleshooting/debugging output to develop.sh
2022-06-22 14:02:31 +01:00
Kyle Carberry 7f778316ac fix: Remove duplicate logs from WorkspaceBuildPage (#2564) 2022-06-21 18:30:40 -05:00
Ketan Gangatirkar 5d2368cb1e remove incorrect coder open invocation from README.md screenshot (#2566) 2022-06-21 23:22:32 +00:00
Jon Ayers ee5918217b fix: cleanup reaper implementation (#2563)
- Clean up the agent/reaper API to be a more isolated and reusable package.
2022-06-21 18:01:34 -05:00
Ben Potter 0585372170 add enhanced docs for creating & troubleshooting templates (#2546)
Co-authored-by: Katie Horne <katie@coder.com>
2022-06-21 15:17:07 -05:00
Ammar Bandukwala 9d02a37ba9 Condense footer (#2555)
Since the footer is included in every page, we should try extra
hard to use little vertical space.

Also, I add an icon to the version text for balance.
2022-06-21 19:46:43 +00:00
Kyle Carberry 06ea7c8388 test: Remove max processes on Windows runner (#2457)
This was added because the runner was running out of memory.
It has potential to reduce our CI time significantly, so we'll
see if it still happens.
2022-06-21 12:04:27 -05:00
Mathias Fredriksson e2785ada5e feat: Compress and extract slim binaries with zstd (#2533)
Fixes #2202

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-06-21 19:53:36 +03:00
Mathias Fredriksson 64f0473499 chore: Prefer [[ over [ in bash build scripts (#2543) 2022-06-21 19:51:32 +03:00
Kyle Carberry fe81b0b859 fix: Wait for TestServer/Telemetry to close before exit (#2554)
This was causing occasional test failures due to leakage!
2022-06-21 19:50:29 +03:00
Kyle Carberry a48a838c9e fix: Wrap TableCell with Link for native browser routing (#2532)
Tables were previously using an onClick handler which replicated some
Link behavior, but not natively through the browser.

Fixes #2525.
2022-06-21 16:31:16 +00:00
dependabot[bot] 1ce28836d1 chore: bump github.com/stretchr/testify from 1.7.2 to 1.7.3 (#2518)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.2 to 1.7.3.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.2...v1.7.3)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-21 10:32:32 -05:00
Kira Pilot 5d2579fcda fix: adjusting language and icon for feedback link (#2483)
* fix: adjusting language and icon for feedback link

* adjust classname
2022-06-21 09:56:08 -04:00
Abhineet Jain a40089c22a Update template users language (#2523) 2022-06-21 09:38:03 -04:00
Katie Horne f476a4ad37 chore: fix broken links and formatting issues (#2547) 2022-06-21 13:13:38 +00:00
Ketan Gangatirkar 93b78755a6 change Docker main.tf to be multiline and make the README.md wrap more nicely (#2537)
see issue #2385
2022-06-21 05:34:14 -05:00
Abhineet Jain 7a4fd12911 Alias users CLI subcommand as user (#2522) 2022-06-20 10:40:08 -04:00
Abhineet Jain 8a853a64a5 Show build initiator on Workspace Build page (#2446)
* show build initiator in ui

* update autostop story
2022-06-20 10:38:57 -04:00
Katie Horne 6d0579d6b6 chore: sync readme and install (#2442) 2022-06-19 15:49:42 -05:00
Ben Potter a19493bd53 add docs for web IDEs (code-server, JetBrains Projector, VNC) (#2448)
* add "configuring web IDEs" doc

* no jupyterhub for now

* change location of web IDE page

* add Dockerfile example

* add run instructions
2022-06-19 20:45:14 +00:00
Dean Sheather 9bdaec6a21 fix: use armhf architecture in linux packages (#2514) 2022-06-20 06:12:38 +10:00
Dean Sheather 153ffc0ee9 fix: include architecture and version information in linux packages (#2511) 2022-06-19 18:56:07 +00:00
Dean Sheather 97348b1c9d fix: replace underscores with hyphens in slim binary name (#2509) 2022-06-19 18:15:20 +00:00
Dean Sheather 8d6faa3c1a fix: login before pushing docker images in release pipeline (#2496) 2022-06-19 13:12:09 +10:00
Dean Sheather 4b3608b628 fix: run git fetch --tags --force during release (#2495) 2022-06-19 10:39:01 +10:00
Dean Sheather dc115688b8 fix: checkout tags in deploy job (#2493) 2022-06-18 22:16:14 +00:00
Dean Sheather 167ab281e4 fix: fix ERRPIPE in build scripts, fix deploy (#2492) 2022-06-18 21:47:37 +00:00
Dean Sheather 075e891f28 Remove goreleaser in favor of build scripts (#2143) 2022-06-19 05:47:10 +10:00
Dean Sheather a9c166491d fix: synchronize terraform log output, fix init coloring (#2482) 2022-06-19 05:26:43 +10:00
Spike Curtis 54a585dbf6 Log provisioner outputs from TestProvision_ExtraEnv (#2427)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-17 14:47:05 -07:00
Spike Curtis 0aa66b4296 Lock the fake database during transactions (#2478)
* Lock the fake database during transactions

Signed-off-by: Spike Curtis <spike@coder.com>

* Add ut for fake database transactions

Signed-off-by: Spike Curtis <spike@coder.com>

* fix lint

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix lint macOS

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-17 13:50:11 -07:00
Cian Johnston 1455603505 fix: cli: create: use new autostart format, opt-in by default (#2472) 2022-06-17 20:38:10 +00:00
Steven Masley edd1083176 fix: Fix test flake based on same update time (#2484) 2022-06-17 15:20:21 -05:00
Steven Masley 4616499030 chore: Reuse ComputedParmeter, remove duplicated codersdk type (#2477)
* chore: Reuse ComputedParmeter instead of custom type
2022-06-17 15:20:13 -05:00
Cian Johnston 0b6efce466 add lima template for coder (#2452)
This commit adds a lima example for Coder.
You can now run limactl start --name=coder ./examples/lima/coder.yaml and have a "prod-like" Coder instance up and running within a minute or so.

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-06-17 20:12:42 +00:00
Steven Masley a9d62cc992 fix: Fix nested transactions should function correctly (#2470)
* fix: Fix nested transactions should function correctly

Inner tx should reuse outer tx
2022-06-17 15:10:44 -05:00
Cian Johnston 0d2f0d7f8c chore: apply non-durability settings to test postgres container (#2479)
This commit applies some recommended settings to sacrifice durability
for speed for our testing database:
  - Mount PGDATA dir on a tmpfs (--tmpfs /tmp)
  - Turn off fsync
  - Turn off synchronous_commit
  - Turn off full_page_writes

  Ref: https://www.postgresql.org/docs/current/non-durability.html
2022-06-17 20:57:38 +01:00
Mathias Fredriksson 17ba4c8e88 fix: Allow template names to be re-used after deletion (#2454)
Fixes #2152
2022-06-17 19:18:07 +00:00
Abhineet Jain 289b98978f Add reason field for workspace builds (#2438)
* add reason field for workspace build

* add the reason field to FE via API

* update BuildReasonMember to BuildReasonInitiator

* add unit tests

* add more unit tests

* add error for unknown transition

* fix lint

* add documentation

* fix unit tests

* fix generated types

* remove nested transaction

* rename migration file
2022-06-17 13:41:11 -04:00
Kira Pilot 7dcfea10dc feat: add feedback link to footer (#2447)
* add ability to activate users

resolves #2254

* added test

* PR feedback

* guarding against null validation_contains field

* fixing type for ParameterSchema

resolves #2161

* added report link to footer

resolves #1885

* added test

* Footer story

* fix broken test
2022-06-17 13:26:13 -04:00
Steven Masley 64b92eea67 feat: Allow inheriting parameters from previous template_versions when updating a template (#2397)
* WIP: feat: Update templates also updates parameters
* Insert params for template version update
* Working implementation of inherited params
* Add "--always-prompt" flag and logging info
2022-06-17 12:22:28 -05:00
Jon Ayers 18973a65c1 fix: Add reaper to coder agent (#2441)
* fix: Add reaper to coder agent

- The coder agent runs as PID 1 in some of our Docker workspaces.
  In such cases it is the responsibility of the init process to
  reap dead processes. Failing to do so can result in an inability
  to create new processes by running out of PIDs.

  This PR adds a reaper to our agent that is only spawned if it
  detects that it is PID1.
2022-06-17 11:51:46 -05:00
Mathias Fredriksson 6c1208e3db feat: Clean up coder agent path in ps listing (#2453)
This commit changes the `coder agent` path in `ps` listing from
`/tmp/tmp.coderwWs87Y/coder agent` to `./coder agent`.

The path is also updated to `/tmp/coder.wWs87Y`.

There were two options considered for turning `./coder agent` into
`coder agent`:

1. Run `exec -a coder /path/to/coder agent`
2. Run `PATH=/path/to:$PATH exec coder agent`

Option 1 is not supported by `dash`, and thus discarded.

Option 2 duplicates functionality in `coder agent` which _appends_ the
path, here we would want to _prepend_ it to ensure we're starting the
downloaded `coder` binary in case there is a binary with a conflicting
name on the system.

Fixes #2407
2022-06-17 19:37:47 +03:00
Mathias Fredriksson 18b0effa83 fix: Add --yes and --use-previous-options to config-ssh (#2458) 2022-06-17 18:03:15 +03:00
Kyle Carberry 7cce7a9c69 test: Write URL after signal listen to fix flake (#2456)
The URL could be read before the signal was listening, causing
this test to flake: https://github.com/coder/coder/runs/6936820170?check_suite_focus=true
2022-06-17 14:16:45 +00:00
Kyle Carberry f09ab03baf fix: Add flag to toggle telemetry (#2455)
* fix: Add flag to toggle telemetry

This allows users to entirely disable tracking from Coder!
Telemetry is enabled by default, so this is opt-out.

* Update cli/server.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-06-17 14:02:44 +00:00
Bruno Quaresma d0aca86657 feat: Show help tooltip on hover (#2423) 2022-06-17 12:50:54 +00:00
Bruno Quaresma 3415b9daef feat: Pop out all apps (#2346) 2022-06-17 12:36:48 +00:00
Bruno Quaresma 9fdee5d391 fix: Storybook error on complex args (#2424) 2022-06-17 09:19:41 -03:00
Kyle Carberry b9f3fe49cb fix: Start login shells on macOS and Linux (#2437)
This appends `-l` to the shell command on macOS and Linux.
It also adds environment variable expansion to allow for
chaining from `coder_agent.env`.
2022-06-17 05:54:45 +00:00
kylecarbs be02d87f22 fix: Swap migration numbers to fix deployment 2022-06-17 05:47:13 +00:00
Kyle Carberry 4cce969018 feat: Add anonymized telemetry to report product usage (#2273)
* feat: Add anonymized telemetry to report product usage

This adds a background service to report telemetry to a Coder
server for usage data. There will be realtime event data sent
in the future, but for now usage will report on a CRON.

* Fix flake and requested changes

* Add reporting options for setup

* Add reporting for workspaces

* Add resources as they are reported

* Track API key usage

* Ensure telemetry is tracked prior to exit
2022-06-17 00:26:40 -05:00
Ben Potter af8a1e3fea package app icons (#2449) 2022-06-17 05:13:37 +00:00
Ammar Bandukwala 40ef1546e1 docs: add architecture page (#2450) 2022-06-16 23:46:02 -05:00
Ammar Bandukwala de213934d1 docs: expand dotfiles section (#2444) 2022-06-16 18:48:18 -05:00
Katie Horne 535481139a chore: add IDEs page to sidebar (#2443) 2022-06-16 18:09:40 -05:00
Katie Horne a09d2af977 chore: add basic postgres instructions for byo databases (#2430) 2022-06-16 17:54:15 -05:00
Katie Horne 0c9ff3a2ac chore: change git link so that it uses https instead of ssh (#2431) 2022-06-16 16:21:52 -05:00
Katie Horne da9009bd3e chore: add link from install.md to Docker example README (#2435) 2022-06-16 16:06:10 -05:00
Spike Curtis 93b1425d85 Stop showing persistent vs ephemeral for resources (#2333)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-16 18:36:11 +00:00
Spike Curtis 552dad6919 Remove tfexec, allow TF_ environment vars and log them (#2264)
* Remove tfexec, allow TF_ environment vars and log them

Signed-off-by: Spike Curtis <spike@coder.com>

* fixup: commented code, long lines

Signed-off-by: Spike Curtis <spike@coder.com>

* rename executor methods to remove get

Signed-off-by: Spike Curtis <spike@coder.com>

* don't log terraform environment variables we don't know are safe

Signed-off-by: Spike Curtis <spike@coder.com>

* Disable linting of fake secret

Signed-off-by: Spike Curtis <spike@coder.com>

* drop parse support and move logger into terraform package

Signed-off-by: Spike Curtis <spike@coder.com>

* disable testpackage linter on internal package test

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-16 17:50:39 +00:00
Ammar Bandukwala 82c4b80c67 Docs touchups (#2421)
* Make secrets docs louder

* docs: a bunch of small touchups
2022-06-16 17:47:10 +00:00
Cian Johnston c9691eafcb feat: cli: consolidate schedule-related commands (#2402)
* feat: cli: consolidate schedule-related commands

This commit makes the following changes:
- renames autostart -> schedule starat
- renames ttl -> schedule stop
- renames bump -> schedule override
- adds schedule show command
- moves some cli-related stuff to util.go
2022-06-16 18:24:10 +01:00
Colin Adler c36b0d892b fix(devtunnel): use 1280 mtu (#2420)
This should be more compatible with cloud VMs and VPNs.
2022-06-16 12:12:04 -05:00
dependabot[bot] ba451b569a chore: bump github.com/gohugoio/hugo from 0.100.2 to 0.101.0 (#2416)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.100.2 to 0.101.0.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/goreleaser.yml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.100.2...v0.101.0)

---
updated-dependencies:
- dependency-name: github.com/gohugoio/hugo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-16 17:06:41 +00:00
dependabot[bot] c570501662 chore: bump github.com/nhatthm/otelsql from 0.3.0 to 0.3.3 (#2415)
Bumps [github.com/nhatthm/otelsql](https://github.com/nhatthm/otelsql) from 0.3.0 to 0.3.3.
- [Release notes](https://github.com/nhatthm/otelsql/releases)
- [Commits](https://github.com/nhatthm/otelsql/compare/v0.3.0...v0.3.3)

---
updated-dependencies:
- dependency-name: github.com/nhatthm/otelsql
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-16 11:51:16 -05:00
Mathias Fredriksson b3f2b7c80a feat: Add section for community templates (#2401)
* feat: Add section for community templates

* Add ntimo/coder-hetzner-cloud-template
2022-06-16 19:48:44 +03:00
dependabot[bot] edaa3f5fc3 chore: bump github.com/pkg/sftp from 1.13.4 to 1.13.5 (#2276)
Bumps [github.com/pkg/sftp](https://github.com/pkg/sftp) from 1.13.4 to 1.13.5.
- [Release notes](https://github.com/pkg/sftp/releases)
- [Commits](https://github.com/pkg/sftp/compare/v1.13.4...v1.13.5)

---
updated-dependencies:
- dependency-name: github.com/pkg/sftp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-16 11:30:34 -05:00
dependabot[bot] fda856d293 chore: bump github.com/jedib0t/go-pretty/v6 from 6.3.1 to 6.3.2 (#2314)
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.3.1 to 6.3.2.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.3.1...v6.3.2)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-16 11:29:54 -05:00
Katie Horne 6c1a111fa9 chore: add IDEs page (#2388) 2022-06-16 11:22:14 -05:00
Spike Curtis a82c0eb560 Fix socket leak, clean up single use postgres databases (#2413)
* Fix socket leak, clean up single use postgres databases

Signed-off-by: Spike Curtis <spike@coder.com>

* Move migrate close defer until after we know it is not nil

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-16 09:01:33 -07:00
Katie Horne eab5c15062 chore: edit CLI/UI copy (#2247) 2022-06-16 10:28:41 -05:00
David Wahler 2d7e6d6530 disable TestPasswordTerminalState until we can make it run reliably (#2409) 2022-06-16 10:18:07 -05:00
Kyle Carberry 024ab6df57 fix: Use in-memory filesystem for echo provisioner tests (#2408)
* fix: Use in-memory filesystem for echo provisioner tests

This should reduce IO in CI to shave some time off tests!

* test: Increase timeouts to reduce flakes

It's difficult to understand what's timing out due to a lock
vs. taking a long time. This should help resolve! 🕵️
2022-06-16 15:09:22 +00:00
Kyle Carberry 5e673cc544 test: Increase timeouts to reduce flakes (#2406)
It's difficult to understand what's timing out due to a lock
vs. taking a long time. This should help resolve! 🕵️
2022-06-16 14:52:45 +00:00
Katie Horne a95d9b17f6 chore: remove index.md (#2403)
* chore: fix broken link

* chore: remove index.md
2022-06-16 14:46:01 +00:00
Ammar Bandukwala 29c9c1d928 docs: small improvements to install (#2400)
* Simplify install docs

* docs: clarify security policy
2022-06-16 12:30:56 +00:00
Kyle Carberry 10dc9e3876 fix: Force keeping old files to prevent dpkg failure on update (#2399)
Updating a release if system files failed would result in failure from
the install script. This fixes it!
2022-06-15 20:04:20 -05:00
Steven Masley 75205f5978 feat: Implement parameters list + more template list columns (#2359)
* feat: Implement parameters list

- Allow more columns on template list

* Hide param list by default for now
2022-06-15 18:21:01 -05:00
Katie Horne f5e558c4ec chore: convert citations to hyperlinks (#2392) 2022-06-15 16:11:44 -05:00
Kyle Carberry ccd061652b feat: Add built-in PostgreSQL for simple production setup (#2345)
* feat: Add built-in PostgreSQL for simple production setup

Fixes #2321.

* Use fork of embedded-postgres for cache path
2022-06-15 16:02:18 -05:00
Katie Horne bb4ecd72c5 chore: update quickstart (docs) (#2381) 2022-06-15 14:52:48 -05:00
Kira Pilot 0f44048fcc fix: adjust ParameterSchema type for workspace creation (#2384)
* add ability to activate users

resolves #2254

* added test

* PR feedback

* guarding against null validation_contains field

* fixing type for ParameterSchema

resolves #2161
2022-06-15 15:12:57 -04:00
Ammar Bandukwala 2e625c1d9b docs: use about as home page (#2382)
* docs: use About as home page

* docs: format install.md
2022-06-15 14:03:13 -05:00
Jon Ayers 961f5110ca fix: fix deleted workspace banner 404 (#2386)
- When a workspace is deleted the user is nudged
  to create a new workspace. The page to which they
  are routed 404s. This PR simply routes them to the
  /templates page where they can pick a template for their
  new workspace.
2022-06-15 13:34:26 -05:00
Dean Sheather 45eb1b4980 feat: improve terraform template parsing errors (#2331) 2022-06-16 04:12:17 +10:00
Jon Ayers 6cf483bf37 fix: allow server startup without tunnel (#2380)
- Previously, specifying 'no' to the tunnel prompt just killed
  the process. It should be possible to start the server without
  a tunnel and not have the process killed.
2022-06-15 12:54:01 -05:00
Jon Ayers 9b3b6418a2 feat: Add template pull cmd (#2329) 2022-06-15 12:42:43 -05:00
Kira Pilot a6a06d4e9c feat: ability to activate suspended users (#2344)
* add ability to activate users

resolves #2254

* added test

* PR feedback
2022-06-15 13:29:38 -04:00
Kira Pilot d48ab96511 trying to resolve Chromatic CI failures (#2350) 2022-06-15 13:04:47 -04:00
Ben Potter 8f7dbee813 fix: flaky install.sh upgrade on OSX (zsh killed) (#2309)
* remove binary exists

* fix lint and format errors

Co-authored-by: ben@coder.com <benpotter@bens-mbp.lan>
2022-06-15 11:09:52 -05:00
Abhineet Jain 55e538e854 fix: break word to wrap long strings in stats, add media query (#2310)
* break word to wrap long strings, add media query

* add stories for smaller screens
2022-06-15 11:16:03 -04:00
Cian Johnston 12a664fa9a fix: coderd: fix flaky test (#2343) 2022-06-15 14:32:02 +00:00
Katie Horne afa5443180 chore: update docs manifest to reflect current Coder version number (#2342) 2022-06-15 14:25:12 +00:00
Mathias Fredriksson 7808593a25 fix: Revert to old SSH config section management in config-ssh (#2341) 2022-06-15 17:22:30 +03:00
Katie Horne d0794910d9 chore: update link to go to Coder docs instead of GitHub (#2330) 2022-06-15 09:16:43 -05:00
Bruno Quaresma b225953f68 feat: Add "Outdated" tooltip and "Update version" button in the Workspaces page (#2322) 2022-06-15 13:52:05 +00:00
Colin Adler e9f87f12ec chore: skip devtunnel test (#2336) 2022-06-14 20:32:40 -05:00
Cian Johnston 02ad60fd75 fix: allow setting workspace deadline as early as now plus 30 minutes (#2328)
This PR makes the following changes:

- coderd: /api/v2/workspaces/:workspace/extend now accepts any time at least 30 minutes in the future.
- coder bump command also allows the above. Some small copy changes to command.
- coder bump now actually enforces template-level maxima.
2022-06-14 22:39:15 +01:00
Steven Masley 4734636b17 fix: compilation error on merge with Authorize call (#2319)
Merge caused compilation errors.
- Authorize call having too many arguments
- `workspaces_test.go` missing "fmt" import
2022-06-14 16:21:30 +00:00
Cian Johnston c28b7ecdf2 fix: coderd: decouple ttl and deadline (#2282)
This commit makes the following changes:

- Partially reverts the changes of feat: update workspace deadline when workspace ttl updated #2165, making the deadline of a running workspace build independant of TTL, once started.
- CLI: updating a workspace TTL no longer updates the deadline of the workspace.
- UI: updating a workspace TTL no longer updates the deadline of the workspace.
- Drive-by: API: When creating a workspace, default TTL to min(12 hours, template max_ttl) if not instructed otherwise.
- Drive-by: CLI: list: measure workspace extension correctly (+X in last column) from the time the provisioner job was completed
- Drive-by: WorkspaceSchedule: show timezone of schedule if it is set, defaulting to dayjs guess otherwise.
- Drive-by: WorkspaceScheduleForm: fixed an issue where deleting the "TTL" value in the form would show the text "Your workspace will shut down a few seconds after start".
2022-06-14 17:09:24 +01:00
Steven Masley 251316751e feat: Return more 404s vs 403s (#2194)
* feat: Return more 404s vs 403s
* Return vague 404 in all cases
2022-06-14 10:14:05 -05:00
Steven Masley dc1de58857 feat: workspace filter query supported in backend (#2232)
* feat: add support for template in workspace filter
* feat: Implement workspace search filter to support names
* Use new query param parser for pagination fields
* Remove excessive calls, use filters on a single query

Co-authored-by: Garrett <garrett@coder.com>
2022-06-14 08:46:33 -05:00
dependabot[bot] 5be52de593 chore: bump github.com/gohugoio/hugo from 0.100.1 to 0.100.2 (#2274)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.100.1 to 0.100.2.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/goreleaser.yml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.100.1...v0.100.2)

---
updated-dependencies:
- dependency-name: github.com/gohugoio/hugo
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-13 21:39:16 -05:00
Colin Adler 961ddad925 fix: use command -v instead of which in agent bootstrap (#2307)
Certain distros don't ship with `which` (arch) and `command -v` is
built-in to the shell, so this is much more compatible.
2022-06-13 21:20:15 -05:00
Cian Johnston 0a949aaff2 cli: streamline autostart ux (#2251)
This commit adds the following changes:

- autostart enable|disable => autostart set|unset
- autostart enable now accepts a more natual schedule format: <time> <days-of-week> <location>
- autostart show now shows configured timezone
- 🎉 automatic timezone detection across mac, windows, linux 🎉

Fixes #1647
2022-06-13 22:09:36 +01:00
Bruno Quaresma 9d155843dd refactor: Replace PageHeaderText by PageHeaderSubtitle (#2287) 2022-06-13 17:12:47 -03:00
Steven Masley 1863da4ff4 chore: Add some more error context in cli (#2301) 2022-06-13 14:39:35 -05:00
Colin Adler dad42fe712 feat: gzip static http server assets (#2272) 2022-06-13 13:14:22 -05:00
Ben Potter d057e8cc03 docs: fix: use absolute link for examples (#2288)
* docs: fix: use absolute link for examples

* fix ugh
2022-06-13 12:50:05 -05:00
Abhineet Jain a91482cb25 fix: populate default created_by and add not-null constraint in templates (#2290) 2022-06-13 17:25:06 +00:00
Steven Masley 49f857806f fix: Do not write 2 errors to api on template fetch error (#2285) 2022-06-13 15:42:14 +00:00
Katie Horne cbde8e8b91 chore: add hero image to OSS docs homepage (#2241) 2022-06-13 09:16:26 -05:00
Colin Adler e3a1cd34b7 fix: ensure agentResource is non-nil (#2261) 2022-06-11 00:02:49 +00:00
Colin Adler 8415022bf9 fix(devtunnel): close http.Server before wireguard interface (#2263) 2022-06-10 23:40:33 +00:00
Colin Adler de6f86bf7a fix: ensure config dir exists before reading tunnel config (#2259) 2022-06-10 21:42:55 +00:00
Kira Pilot ec0bb7b330 feat: update language on workspace page (#2220) 2022-06-10 16:42:21 -04:00
Abhineet Jain 02d2aea7f2 feat: store and display template creator (#2228)
* design commit

* add owner_id to templates table

* add owner information in apis and ui

* update minWidth for statItem

* rename owner to created_by

* missing refactor to created_by

* handle errors in fetching created_by names
2022-06-10 19:24:21 +00:00
Garrett Delfosse 46da59a6b5 fix: use correct link in create from template button (#2253) 2022-06-10 13:38:43 -05:00
Colin Adler f562b74fa1 feat: use custom wireguard reverse proxy for dev tunnel (#1975) 2022-06-10 13:38:11 -05:00
David Wahler 71fd19631a feat: Warn on coderd startup if access URL is localhost (#2248) 2022-06-10 13:35:51 -05:00
Kyle Carberry f79ab7f87e fix: Remove easter egg mentioning competitor (#2250)
This is more confusing than helpful!
2022-06-10 18:14:06 +00:00
G r e y 928958c94c fix: workspace schedule time displays (#2249)
Summary:

Various time displays weren't quite right.

Details:

- Display date (not just time) of upcoming workspace stop in workspace
page
- Fix ttlShutdownAt for various cases + tests
  - manual to non-manual
  - unchanged/unmodified
  - isBefore --> isSameOrBefore
  - use the delta (off by _ error)
- pluralize units in dayjs.add
2022-06-10 17:26:20 +00:00
Mathias Fredriksson 1a9e57296c feat: Show template description in coder template init (#2238) 2022-06-10 19:54:28 +03:00
Joe Previte fcc52846da fix: update icon (#2216) 2022-06-10 11:23:20 -05:00
Abhineet Jain b2833c694b feat: update build url to @username/workspace/builds/buildnumber (#2234)
* update build url to @username/workspace/builds/buildnumber

* update errors thrown from the API

* add unit tests for the new API

* add t.parallel

* get username and workspace name from params
2022-06-10 12:08:50 -04:00
Kyle Carberry f9290b016e fix: Use explicit resource order when assocating agents (#2219)
This cleans up agent association code to explicitly map a single
agent to a single resource. This will fix #1884, and unblock
a prospect from beginning a POC.
2022-06-10 15:47:36 +00:00
Steven Masley 6bee180bb3 fix: Sort workspace by name by created_at (#2214)
* fix: Sort workspace by name by created_at

Fix bug where deleting workspaces with the same name returns the
oldest deleted workspace
2022-06-10 09:58:42 -05:00
Abhineet Jain 953e8c8fe6 feat: Allow admins to access member workspace terminals (#2114)
* allow workspace update permissions to access agents

* do not show app links to users without workspace update access

* address CR comments

* initialize machine context in the hook

* revert scoped connected status check
2022-06-10 10:46:48 -04:00
Mathias Fredriksson 0260e39d11 fix: Accept CODER_CACHE_DIRECTORY with CACHE_DIRECTORY fallback (#2236)
Fixes #2199
2022-06-10 17:00:00 +03:00
Ammar Bandukwala 06021bdc92 Make coder bump idempotent (#2230)
Resolves #2223

In addition to solving what's outlined in the issue,
I remove the client-side minute check because it had no
clear purpose when the API already returns an error.
2022-06-10 09:31:47 +01:00
ammario 6ea86c831b Revert "Make coder bump idempotent (#2225)"
This reverts commit 0df75f9176.

I merged on accident.
2022-06-10 03:31:13 +00:00
Ammar Bandukwala 0df75f9176 Make coder bump idempotent (#2225)
Resolves #2223

In addition to solving what's outlined in the issue,
I remove the client-side minute check because it had no
clear purpose when the API already returns an error.
2022-06-09 22:30:43 -05:00
Garrett Delfosse 92bda0d2c1 fix: allow admins to reset their own pass without old_password (#2222) 2022-06-10 11:43:54 +10:00
Garrett Delfosse b7234a6ce1 fix: push create workspace UX to templates page (#2142) 2022-06-09 18:43:49 -05:00
Cian Johnston 119db78bff feat: update workspace deadline when workspace ttl updated (#2165)
This commit adds the following changes to workspace scheduling behaviour:

* CLI: updating a workspace TTL updates the deadline of the workspace.
  * If the TTL is being un-set, the workspace deadline is set to zero.
  * If the TTL is being set, the workspace deadline is updated to be the last updated time of the workspace build plus the requested TTL. Additionally, the user is prompted to confirm interactively (can be bypassed with -y).
* UI: updating the workspace schedule behaves similarly to the CLI, showing a message to the user if the updated TTL/time to shutdown would effect changes to the lifetime of the running workspace.
2022-06-09 22:10:24 +01:00
G r e y 411d7da661 fix: ws schedule as 12-hour format (#2209)
This does not finish all tasks in #2175 but is one of the asks.
2022-06-09 16:20:29 -04:00
G r e y 377f17c292 fix: initialValues for ws schedule (#2213)
Summary:

When a schedule is not set, we default to M-F, 5 hours ttl
2022-06-09 15:20:53 -04:00
Bruno Quaresma d04d527f2c chore: Update docs manifest home page and icons (#2133)
* chore: Update docs manifest home page and icons

* RRemove contributors

* Update template icon

* fixup: manifest.json changes

* fix: add missing readme to root

* fix: add readme to /docs with toc

* fix: add quickstart to manifest

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-06-09 18:46:16 +00:00
Ben Potter 0ec1e8f89b example: aws-linux: resize and use non-root user (#2186) 2022-06-09 18:10:01 +00:00
G r e y 92db80cadc fix: sort time zones (#2210)
Summary:

The list of time zones in the edit workspace schedule form is not sorted
alphabetically.
2022-06-09 18:42:27 +01:00
Kira Pilot 518495a6c5 feat: show deleted workspace after delete action (#2208)
* added deleted workspace banner

* x state pass

* added include_deleted param

* clean up x state

* added teests

* cleaning up unneeded xstate service
2022-06-09 11:43:49 -04:00
dependabot[bot] d0ac4d9e74 chore: bump eslint-plugin-react from 7.29.4 to 7.30.0 in /site (#2076)
Bumps [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) from 7.29.4 to 7.30.0.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-react/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jsx-eslint/eslint-plugin-react/compare/v7.29.4...v7.30.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-react
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-09 11:17:52 -04:00
G r e y 857d83750a ci: storybook flake for auto-stop display (#2184)
Summary:

Uncaught from the change in https://github.com/coder/coder/pull/2171
2022-06-09 15:03:28 +00:00
Kyle Carberry fff59ef6ad fix: Add tests for instance and app association (#2198)
This was regressed in #2187. There was bad testing around this
before, and this should prevent a similiar situation from happening
again!
2022-06-09 13:34:24 +00:00
Mathias Fredriksson 567e4afdfc example: Re-enable Digital Ocean project assignment (#2196)
The issue tracked in #1750 was fixed by #2187, we can now re-enable the
project resource.
2022-06-09 12:17:44 +03:00
Mathias Fredriksson 2621093452 fix: Stop showing resources after coder create (#2155)
Fixes #1036
2022-06-09 10:44:41 +03:00
Steven Masley 74fe38eb3d feat: Add initiator_username to workspace builds in apis (#2174)
* feat: Add initiator_username to workspace builds in apis
2022-06-08 20:23:35 -05:00
Kyle Carberry 14701498c9 fix: Improve Terraform agent<->resource association testing (#2187) 2022-06-08 17:40:34 -05:00
Ben Potter 42c6b0849d example: add and document dotfiles usage (#2046) 2022-06-08 21:23:54 +00:00
dependabot[bot] c33113786e chore: bump dayjs from 1.11.2 to 1.11.3 in /site (#2088)
Bumps [dayjs](https://github.com/iamkun/dayjs) from 1.11.2 to 1.11.3.
- [Release notes](https://github.com/iamkun/dayjs/releases)
- [Changelog](https://github.com/iamkun/dayjs/blob/v1.11.3/CHANGELOG.md)
- [Commits](https://github.com/iamkun/dayjs/compare/v1.11.2...v1.11.3)

---
updated-dependencies:
- dependency-name: dayjs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-08 20:05:43 +00:00
Spike Curtis a86c957871 feat: set /Users/spike for coder agent in gcp-linux template (#2147)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-08 11:22:18 -07:00
Kira Pilot 3bc122b7d5 feat: added include_deleted to getWorkspaceByOwnerAndName (#2164)
* feat: added include_deleted

relates to #1955

* Update coderd/workspaces.go

defining vars in the scope of conditional

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update coderd/workspaces.go

avoid newline

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* Update coderd/workspaces.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

* PR feedback

* wrote test, added type

* Update coderd/workspaces_test.go

shortening test name

Co-authored-by: Cian Johnston <cian@coder.com>

* taking out api.ts change for now

* casing

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Co-authored-by: Cian Johnston <cian@coder.com>
2022-06-08 14:04:05 -04:00
Spike Curtis 85821568a9 feat: set $HOME for coder agent in aws-linux template (#2150)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-08 09:51:33 -07:00
G r e y 9cc6d7b3b2 fix: show explicit schedule stop time (#2171)
This does not fully resolve all requests in #2141, but just the piece of
when the workspace is actually stopping.

Next, we will adjust the default extension from 90 minutes to 4 hours.
Lastly, we can look at customizing the extension time in the extension
flow or with a pre-emptive prompt next to the stop time.
2022-06-08 12:00:22 -04:00
G r e y b390250e2e fix: increase default extension time (#2172)
This does not fully close #2141, but builds upon #2171 to fulfill each
of the UX requests.

A next step (probably as a separate ticket) is to allow customizing
extension time pre-emptively.
2022-06-08 12:00:09 -04:00
Joe Previte b6899e2c18 docs: slim down readme (#2140)
* docs: move docs table of contents to docs/index.md

* docs: move how it works and IDE support to about.md

* docs: move readme steps to walkthrough

* docs: slim down readme

* refactor: walkthrough -> quickstart

* docs: minor edits
2022-06-08 08:37:03 -07:00
Cian Johnston 8cfe223192 feat: cli: allow editing template metadata (#2159)
This PR adds a CLI command template edit which allows updating the following metadata fields of a template:
- Description
- Max TTL
- Min Autostart Interval
2022-06-08 15:14:57 +01:00
Mathias Fredriksson b65259f95e feat: Refactor CLI config-ssh to improve UX (#1900)
- Magic block is replaced by Include statement
- Writes are only done on changes
- Inform user of changes via prompt
- Allow displaying changes via `--diff`
- Remove magic block if present
- Safer config writing via tmp-file + rename
- Parse previous `config-ssh` options, compare to new options and ask to use new (otherwise old ones are used)
- Tests the new functionality

Fixes #1326
2022-06-08 11:45:29 +03:00
Garrett Delfosse 945fa9dacf fix: bug where all workspaces filter defaulted to 'me' (#2145)
* fix: bug where all workspaces filter defaulted to 'me'
2022-06-07 22:15:50 +00:00
Dean Sheather 7b76afb069 Revert split release (#2139)
* Revert "chore: ignore artifacts dir (#2132)"

This reverts commit 27acb98571.

* Revert "chore: split release workflow so the majority happens on Linux (#2092)"

This reverts commit b87096b500.
2022-06-07 20:57:32 +00:00
Abhineet Jain 4b82509922 feat: Make workspaces, timeline, templates rows obviously clickable (#2047)
* add right arrow to build table rows

* Add clickable rows to template and workspace list

* Specify 1% width for chevron right
2022-06-07 19:11:56 +00:00
Garrett Delfosse 7258d6acc8 fix: Show correct 'no results' message on workspace filters (#2103) 2022-06-07 13:54:59 -05:00
Dean Sheather 27acb98571 chore: ignore artifacts dir (#2132) 2022-06-07 16:41:38 +00:00
Bruno Quaresma 3a79759405 fix: Docs paths (#2131) 2022-06-07 16:29:18 +00:00
Bruno Quaresma 2b0662bf48 fix: Add .md extension to the docs routes (#2128) 2022-06-07 15:56:05 +00:00
Steven Masley a391572690 test: Pagination api query param parsing (#2127)
* test: Pagination api query param parsing
2022-06-07 10:48:08 -05:00
Dean Sheather b87096b500 chore: split release workflow so the majority happens on Linux (#2092) 2022-06-07 15:24:46 +00:00
Presley Pizzo b4645b2d11 Clear error on cancel (#2107) 2022-06-07 11:02:20 -04:00
Steven Masley cc30d42473 chore: Fix some 'Message' linting errors on main (#2129) 2022-06-07 14:52:44 +00:00
Steven Masley af401e3fe1 chore: Linter rule for properly formatted api errors (#2123)
* chore: Linter rule for properly formatted api errors
* Add omitempty to 'Detail' field
2022-06-07 14:33:06 +00:00
Katie Horne 3f1e885d21 chore: add manifest.json (#2100) 2022-06-07 09:30:34 -05:00
Kyle Carberry 7e8692b0fd fix: Update routing for workspace schedule (#2113)
* fix: Update routing for workspace schedule

This was broken as part of #2101. It was a silly mistake,
but unfortunate our tests didn't catch it.

This is a rare change so unlikely to occur again, so I won't
make an issue adding tests.

* Update site/src/pages/WorkspaceSchedulePage/WorkspaceSchedulePage.tsx

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>
2022-06-07 14:28:47 +00:00
Bruno Quaresma a4e259e14b fix: Page header width in the workspace page (#2125) 2022-06-07 14:24:01 +00:00
Bruno Quaresma 3752f4c401 fix: Update tooltip messages for workspaces and resources (#2126) 2022-06-07 14:20:44 +00:00
Mathias Fredriksson 6da4810a5e chore: Add (skipped) ptytest test that hangs on Intel Mac (and Windows) (#1629)
Co-authored-by: Steven Masley <stevenmasley@coder.com>
2022-06-07 17:08:11 +03:00
Bruno Quaresma eedd293ad5 feat: Add helpful tooltips for the key features (#2097) 2022-06-07 13:43:46 +00:00
Presley Pizzo 6d966963da refactor: rename errors to validations (#2105)
* Update validation error unpacking

* Rename validations on backend

* Format
2022-06-07 09:31:15 -04:00
Bruno Quaresma 3616c629c7 refactor: Update status for build logs (#2087) 2022-06-07 08:24:27 -05:00
Cian Johnston 3e419ddb3d feat: enforce template-level constraints for TTL and autostart (#2018)
This PR adds fields to templates that constrain values for workspaces derived from that template.

- Autostop: Adds a field max_ttl on the template which limits the maximum value of ttl on all workspaces derived from that template. Defaulting to 168 hours, enforced on edits to workspace metadata. New workspaces will default to the templates's `max_ttl` if not specified.
- Autostart: Adds a field min_autostart_duration which limits the minimum duration between successive autostarts of a template, measured from a single reference time. Defaulting to 1 hour, enforced on edits to workspace metadata.
2022-06-07 13:37:45 +01:00
dependabot[bot] 3878e6434a chore: bump github.com/moby/moby (#2112)
Bumps [github.com/moby/moby](https://github.com/moby/moby) from 20.10.16+incompatible to 20.10.17+incompatible.
- [Release notes](https://github.com/moby/moby/releases)
- [Changelog](https://github.com/moby/moby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moby/moby/compare/v20.10.16...v20.10.17)

---
updated-dependencies:
- dependency-name: github.com/moby/moby
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-07 01:53:04 +00:00
Kyle Carberry 94ed081a77 fix: Dependabot uses arrays for labels (#2111) 2022-06-07 01:35:44 +00:00
Kyle Carberry 16e66c61d9 fix: Remove dependabot labels (#2110)
This kept adding unnecessary labels to our tracker.
Once we need to filter for specific dependabot PRs,
we can add this back.
2022-06-07 01:17:56 +00:00
Ammar Bandukwala 8f1380774a Remove issue templates (#2109)
Per our product management conversation, we want to make
giving feedback as easy as possible initially.
2022-06-07 01:14:24 +00:00
Kyle Carberry 74d9fee444 fix: Make the workspace URL pretty (#2101)
This adds the `@username/workspacename` format to the
workspace page!
2022-06-06 17:53:39 -05:00
Steven Masley e2b2580196 chore: version sub command remove --version and -v flag (#2090)
* test: Add unit test for version cmd
2022-06-06 17:38:51 -05:00
Spike Curtis a7a7e7561d K8s template uses an authenticated environment (#2104)
* feat: K8s template uses authenticated environment

Signed-off-by: Spike Curtis <spike@coder.com>

* fmt

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-06 14:39:23 -07:00
Garrett Delfosse a860b86256 fix: support substring search on workspace name (#2096) 2022-06-06 19:43:16 +00:00
Kyle Carberry 66cf59bbe1 fix: Apply environment variables to startup script (#2099)
This was stopping `coder` from being in the path, and allowed
applications started in the script to bypass injected environmnet
variables like `GIT_SSH_COMMAND`.
2022-06-06 14:20:25 -05:00
Garrett Delfosse 1a39931d56 fix: correct localhost url in dev webpack (#2098) 2022-06-06 18:38:39 +00:00
Katie Horne 318e9792ad expand README files for examples (#1946) 2022-06-06 13:03:07 -05:00
Garrett Delfosse 37b0aaa018 fix: add workspace option 'deleted' to options type (#2095)
* fix: add workspace option 'deleted' to options type

* dead code
2022-06-06 17:23:02 +00:00
Garrett Delfosse 367897ef6b Specify number of builds before reporting status on codecov (#2094) 2022-06-06 11:25:51 -05:00
Steven Masley cf477ffbf0 chore: bump github.com/open-policy-agent/opa from 0.40.0 to 0.41.0 (#2093) 2022-06-06 11:16:46 -05:00
dependabot[bot] d7be7a840a chore: bump msw from 0.39.2 to 0.42.0 in /site (#2075)
Bumps [msw](https://github.com/mswjs/msw) from 0.39.2 to 0.42.0.
- [Release notes](https://github.com/mswjs/msw/releases)
- [Changelog](https://github.com/mswjs/msw/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mswjs/msw/compare/v0.39.2...v0.42.0)

---
updated-dependencies:
- dependency-name: msw
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 10:11:50 -05:00
dependabot[bot] 9f496435da chore: bump @fontsource/inter from 4.5.10 to 4.5.11 in /site (#2084)
Bumps [@fontsource/inter](https://github.com/fontsource/fontsource/tree/HEAD/fonts/google/inter) from 4.5.10 to 4.5.11.
- [Release notes](https://github.com/fontsource/fontsource/releases)
- [Changelog](https://github.com/fontsource/fontsource/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fontsource/fontsource/commits/HEAD/fonts/google/inter)

---
updated-dependencies:
- dependency-name: "@fontsource/inter"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 10:11:28 -05:00
Kyle Carberry ab8235f53e feat: Add links to the resource card for workspace applications (#2067)
* fix: Use proper webpack config for dev mode

This was broken when improving the build times. The typechecker
unfortunately missed it!

* feat: Add links to the resource card for workspace applications

Fixes #1907 and #805.

I'll make this pretty in another PR!

* Improve style
2022-06-06 09:50:07 -05:00
dependabot[bot] 722dbab337 chore: bump @typescript-eslint/eslint-plugin in /site (#2079)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.23.0 to 5.27.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.27.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 14:46:38 +00:00
Garrett Delfosse 3be3bc261e fix: handle owner but no name syntax (#2045) 2022-06-06 10:38:38 -04:00
dependabot[bot] 77d068215a chore: bump github.com/stretchr/testify from 1.7.1 to 1.7.2 (#2073)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.1 to 1.7.2.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.1...v1.7.2)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 09:38:23 -05:00
dependabot[bot] 2824521d67 chore: bump google.golang.org/api from 0.81.0 to 0.82.0 (#2072)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.81.0 to 0.82.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.81.0...v0.82.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 09:38:13 -05:00
dependabot[bot] ffe25c3442 chore: bump github.com/gohugoio/hugo from 0.99.1 to 0.100.1 (#2071)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.99.1 to 0.100.1.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/goreleaser.yml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.99.1...v0.100.1)

---
updated-dependencies:
- dependency-name: github.com/gohugoio/hugo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 09:37:55 -05:00
Mathias Fredriksson 59a6826920 feat: Add support for pprof in coder agent (#1985)
* feat: Allow USR1 signal to start pprof
2022-06-06 16:38:33 +03:00
Kyle Carberry 0ac37b146d feat: Add page titles (#2070) 2022-06-06 08:34:10 -05:00
Spike Curtis 3f3ecbf8b3 feat: Authenticate Digital Ocean via environment variable (#2051)
* Digital Ocean example uses environment variable auth

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-06 07:05:16 -05:00
Kyle Carberry 1634f2cddd fix: Use proper webpack config for dev mode (#2061)
This was broken when improving the build times. The typechecker
unfortunately missed it!
2022-06-05 18:23:44 +00:00
Kyle Carberry 013f028e55 feat: Add workspace application support (#1773)
* feat: Add app support

This adds apps as a property to a workspace agent.

The resource is added to the Terraform provider here:
https://github.com/coder/terraform-provider-coder/pull/17

Apps will be opened in the dashboard or via the CLI
with `coder open <name>`. If `command` is specified, a
terminal will appear locally and in the web. If `target`
is specified, the browser will open to an exposed instance
of that target.

* Compare fields in apps test

* Update Terraform provider to use relative path

* Add some basic structure for routing

* chore: Remove interface from coderd and lift API surface

Abstracting coderd into an interface added misdirection because
the interface was never intended to be fulfilled outside of a single
implementation.

This lifts the abstraction, and attaches all handlers to a root struct
named `*coderd.API`.

* Add basic proxy logic

* Add proxying based on path

* Add app proxying for wildcards

* Add wsconncache

* fix: Race when writing to a closed pipe

This is such an intermittent race it's difficult to track,
but regardless this is an improvement to the code.

* fix: Race when writing to a closed pipe

This is such an intermittent race it's difficult to track,
but regardless this is an improvement to the code.

* fix: Race when writing to a closed pipe

This is such an intermittent race it's difficult to track,
but regardless this is an improvement to the code.

* fix: Race when writing to a closed pipe

This is such an intermittent race it's difficult to track,
but regardless this is an improvement to the code.

* Add workspace route proxying endpoint

- Makes the workspace conn cache concurrency-safe
- Reduces unnecessary open checks in `peer.Channel`
- Fixes the use of a temporary context when dialing a workspace agent

* Add embed errors

* chore: Refactor site to improve testing

It was difficult to develop this package due to the
embed build tag being mandatory on the tests. The logic
to test doesn't require any embedded files.

* Add test for error handler

* Remove unused access url

* Add RBAC tests

* Fix dial agent syntax

* Fix linting errors

* Fix gen

* Fix icon required

* Adjust migration number

* Fix proxy error status code

* Fix empty db lookup
2022-06-04 15:13:37 -05:00
dependabot[bot] 2c089d5a99 chore: bump github.com/ory/dockertest/v3 from 3.9.0 to 3.9.1 (#1892)
Bumps [github.com/ory/dockertest/v3](https://github.com/ory/dockertest) from 3.9.0 to 3.9.1.
- [Release notes](https://github.com/ory/dockertest/releases)
- [Commits](https://github.com/ory/dockertest/compare/v3.9.0...v3.9.1)

---
updated-dependencies:
- dependency-name: github.com/ory/dockertest/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-04 15:12:54 -05:00
Kyle Carberry 5edd086b69 chore: Reduce deployment times by excluding Docker images (#1945)
* chore: Reduce deployment times by excluding Docker images

Only the Windows and Linux binaries are build during deploy, so we
can save many minutes by excluding Docker images.

* Stop docker image builds on snapshot

* Fix artifact upload

* Skip typecheck for release

* Flag deploy
2022-06-04 19:56:45 +00:00
Steven Masley c9a4642a12 chore: Update BE http errors to be ui friendly (#1994)
* chore: More UI friendly errors

Mainly capitlization + messages prefix error
2022-06-03 21:48:09 +00:00
Spike Curtis 847e2b18da Don't use parameters to pass secrets to GCP or AWS (#2039)
* Don't use parameters to pass secrets to GCP or AWS

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix fmt

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-03 14:29:22 -07:00
Kyle Carberry 43f622a52d fix: Remove unused workspace routes in favor of list with filter (#2038)
* fix: Remove unused workspace routes in favor of list with filter

This consolidates the workspace routes into a single place.
It allows users to fetch a workspace by their username and
workspace name, which will be used by the frontend for routing.

* Fix RBAC

* Fix CLI usages
2022-06-03 14:36:08 -05:00
Spike Curtis d8c440188e feat: Remove organization and user scoped parameters (#2007)
* feat: Remove organization and user scoped parameters

Signed-off-by: Spike Curtis <spike@coder.com>

* Fixup dump.sql

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix dump.sql again

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix down migration

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-03 11:49:58 -07:00
David Wahler 582d636e54 feat: support fully-qualified workspace names in CLI (#2036) 2022-06-03 12:47:56 -05:00
Abhineet Jain fc38b61819 feat: use ConfirmDialog for ResetPasswordDialog (#2035)
* feat: use ConfirmDialog for ResetPasswordDialog

* fix lint

* make description typography a div

* use paragraph for string description, div otherwise

* fix lint
2022-06-03 17:35:09 +00:00
Colin Adler 60102cb22f chore: fix codecov ignore for queries.sql.go (#2037) 2022-06-03 12:26:59 -05:00
Garrett Delfosse 8b03e2b0e1 feat: Workspaces filtering (#1972)
Co-authored-by: G r e y <grey@coder.com>
Co-authored-by: Kira Pilot <kira@coder.com>
2022-06-03 17:20:28 +00:00
G r e y ac6cb269db feat: ws schedule timezone select (#2032)
Resolves: #1959

Summary:

The package tzdata is used to create a meaningful select-list for
timezone in the workspace schedule form.

Impact:

Improved UX. Furthermore, we guess your timezone if the form is being
initialized from scratch.
2022-06-03 12:52:02 -04:00
Abhineet Jain 2b12beef98 feat: Update success confirmation dialog and snackbar (#2005)
* feat: update success confirmation dialog and snackbar

* add success variants to confirm dialog and snackbar

* update story name

* use success variant for snackbar
2022-06-03 11:42:46 -04:00
G r e y 37aff0c8a9 fix: FE parsing of schedule with day strings (#2006)
Resolves: #1901

Summary:

We had a homegrown parser that only understood numbers, not strings like
MON or TUES. We replace the homegrown parser with cron-parser.

Details:

This was nearly a straight drop-in.

Impact:

Much less code/maintenance burden :D

What I learned:

Don't trust the README, sometimes you just gotta read the code or import
it and try it out. The `fields` representation of the parsed expression
was missing from their docs. I might open an issue or PR to update them!
2022-06-03 11:08:57 -04:00
Abhineet Jain 7e89d91ce3 feat: link to timezone database spells out timezone (#2026) 2022-06-03 14:57:09 +00:00
G r e y c2720577cb fix: ws schedule top-down restriction (#2008)
Resolves: #1958

Summary:

The workspace schedule form no longer disables certain fields based on
whether or not a start time is filled out. Instead, we validate that a
start time is provided if any of the days are checked.
2022-06-03 10:50:36 -04:00
Bruno Quaresma 88e8c96ddd feature: Load workspace build logs from streaming (#1997) 2022-06-03 09:23:45 -05:00
Abhineet Jain d6e9eab258 feat: Use consistent colors for links and highlighting (#1989)
* feat: consistent highlight colors

* update user dropdown menu border

* update borderedmenurow active color
2022-06-03 10:16:50 -04:00
Bruno Quaresma 6bb76782a6 feat: Open terminal in a new window (#2017) 2022-06-03 09:06:44 -05:00
Mathias Fredriksson b4f5920df5 fix: Avoid use of r.Context() after r.Hijack() (#1978) 2022-06-03 12:50:10 +03:00
Kyle Carberry 61aacff444 chore: Refactor site to improve testing (#2014)
It was difficult to develop this package due to the
embed build tag being mandatory on the tests. The logic
to test doesn't require any embedded files.
2022-06-03 04:27:21 +00:00
Colin Adler 89dde21837 fix: ensure listen websocket isn't opened for non-latest agents (#2002)
Exponential backoff is only enabled if the websocket fails to open. If
the websocket is opened but immediately killed, the agent will try to
immediately reconnect. This is desireable in cases where coderd is being
replaced or network conditions cause the connection to die, but not for
permanent errors.
2022-06-02 15:03:01 -05:00
Ketan Gangatirkar 0e1f868f5f tweak README.md headings around one liner 2022-06-02 14:48:22 -05:00
Ketan Gangatirkar 597994548d added one liner to run Coder at very top of README.md 2022-06-02 14:47:34 -05:00
G r e y 0b59ed30d0 feat: ui autostop extension (#1987)
Resolves: #1460

Summary:

An 'Extend' CTA on workspace schedule banner is added so that a user can
extend their workspace lease from the UI.

Details:

* feat: putWorkspaceExtension handler

* refactor: TypesGen dflt import in workspace.ts

* feat: defaultWorkspaceExtension util

Impact:

This completes the UI<-->CLI parity epic in an MVP way. Of course, a
future improvement to make is extending by times other than the default
90 minutes.
2022-06-02 15:44:11 -04:00
Oxylibrium 1a07d021fe ux: change colors for inflight workspace actions (#1986) 2022-06-02 12:52:20 -04:00
Abhineet Jain e09cd3e9cf feat: Update UI for error dialog and snackbar (#1971)
* feat: update ui for error dialog and snackbar

* update padding for buttons
2022-06-02 11:23:52 -04:00
Abhineet Jain 47c7eda670 feat: add a divider after Account menu item (#1927)
* add a divider after Account menu item

* test: improve Storybook tests

* add closed and open userdropdown tests

* add default isOpen

* extract UserDropdownContent into a single component

* remove the isOpen prop

* address nit comments

* update test name
2022-06-02 11:09:19 -04:00
Steven Masley e6ee7dd652 chore: Add linting rule to help catch InTx misuse (#1980)
* chore: Add linting rule to help catch InTx misuse

This isn't perfect, as if you nest your misuse in another code block
like an if statement, it won't catch it :/. It is better
than nothing
2022-06-02 14:50:15 +00:00
Abhineet Jain c463e7801c feat: Update TTL language to Time until shutdown (#1948)
* feat: update ttl language in frontend

* Update TTL Helper text

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>

* update TTL helper string

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>
2022-06-02 10:15:36 -04:00
G r e y ab69c22ddc fix: missing FE ttl constraint validation (#1952)
Resolves: #1908
2022-06-02 10:14:42 -04:00
Steven Masley b9983e417f feat: Handle pagination cases where after_id does not exist (#1947)
* feat: Handle pagination cases where after_id does not exist

Throw an error to the user in these cases
- Templateversions
- Workspacebuilds

User pagination does not need it as suspended users still
have rows in the database
2022-06-02 09:01:45 -05:00
Kira Pilot 419dc6b036 feat: flexbox updates on workspace page (#1963)
* feat: flexbox work on workspace page

resolves 1910

* fixing cancel text

* chromatic fixes

* resolves #1953

no overflox text on smaller screens
2022-06-02 09:57:36 -04:00
Bruno Quaresma 3fd4dcd9d5 fix: Display member role when user has no role (#1965) 2022-06-02 08:46:06 -05:00
Cian Johnston dcf03d8ba3 chore: refactor time.Duration -> int64 milliseconds for FE consumption (#1944)
* Changes all public-facing codersdk types to use a plain int64 (milliseconds) instead of time.Duration.
* Makes autostart_schedule a *string as it may not be present.
* Adds a utils/ptr package with some useful methods.
2022-06-02 11:23:34 +01:00
Mathias Fredriksson 51c420c90a feat: Add support for --identity-agent in coder ssh (#1954) 2022-06-02 11:13:38 +03:00
Spike Curtis 9e3a625898 Show workspace name in WorkspaceBuildStats component (#1933)
* Show workspace name in WorkspaceBuildStats component

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix WorkspaceBuildPage tests

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-01 16:49:43 -07:00
Cian Johnston b203d40123 fix: fix duplicate migrations (#1968) 2022-06-01 20:58:22 +00:00
Steven Masley 913c0f5e7f feat: Longer lived api keys for cli (#1935)
* feat: Longer lived api keys for cli
* feat: Refresh tokens based on their lifetime set in the db
* test: Add unit test for refreshing
2022-06-01 14:58:55 -05:00
Presley Pizzo bb400a4e82 fix: Show error message from backend on create existing user (#1964)
* Show error message from backend on create existing user

* Format
2022-06-01 15:52:54 -04:00
Ben Potter 46ffb67d60 feat: one-line install script (#1924)
* feat: one-line install script

* remove homebrew support

* remove arch linux

* use proper filename for packages

* fix variable format

* fix systemd instructions

* fixes to standalone script

* fix missing var bugs

* fix standalone install

* fix for MacOS

* format

* fix armv7 assets and zips

* remove windows

* update install docs

* support external sources with shellcheck

* shfmt

* add external sources to GitHub action & unfold

* change wording

* first template docs

* default to /usr/local instead

* add option for binary name
2022-06-01 14:15:09 -05:00
Bruno Quaresma f5a8d17aa8 feat: Add copy button to the SSH Page (#1962) 2022-06-01 19:01:36 +00:00
Bruno Quaresma b85de3ee79 feat: Improve empty states for workspaces and templates (#1950) 2022-06-01 17:32:55 +00:00
Dean Sheather 6be8a373e0 feat: run a terraform plan before creating workspaces with the given template parameters (#1732) 2022-06-02 00:44:53 +10:00
Steven Masley cc87a0cf6b feat: Implied 'member' roles for site and organization (#1917)
* feat: Member roles are implied and never exlpicitly added
* Rename "GetAllUserRoles" to "GetAuthorizationRoles"
* feat: Add migration to remove implied roles
* rename user auth role middleware
2022-06-01 09:07:50 -05:00
Presley Pizzo 2878346f19 Use backend error if possible (#1938) 2022-06-01 09:09:58 -04:00
Kyle Carberry 1fa50a9da1 fix: Race when writing to a closed pipe (#1916) 2022-06-01 07:59:03 -05:00
Cian Johnston 1c5d94ed5b fix: add all regions to aws examples (#1934) 2022-06-01 11:20:14 +01:00
Cian Johnston 7b40c692eb fix: coderd: dev mode should show verbose output by default (#1898)
* check buildinfo for devel prerelease tag and show verbose output if so
2022-06-01 11:00:42 +01:00
Steven Masley 7acb742218 feat: Prevent role changing on yourself. (#1931)
* feat: Prevent role changing on yourself.

Only allow changing roles on other users. Not much value in self changing
at the moment
2022-05-31 15:50:38 -05:00
Spike Curtis 4b0ed06a26 Remove set -u on yarn_install.sh to allow it to run on zsh (#1930)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-31 13:50:18 -07:00
G r e y 56ec53d04b fix: derive running ws stop time from deadline (#1920)
* refactor: isWorkspaceOn utility

Summary:

A utility is function is added that answers the question if a workspace
is on.

Impact:

This is a shared piece of logic in workspace scheduling presentations.
In particular it unblocks work in 1779, or at least allows an
implementation that shares details with the WorkspaceScheduleBanner.

Notes:

We could possibly instead return whether the workspace is "ON",
"UNKNOWN", or "OFF". Maybe a future improvement for that could be made
as the neds arrises.

* fix: derive running ws stop time from deadline

Summary:

When a workspace is on, the remaining time until shutdown needs to be
derived from the deadline timestamp, not implied from the TTL
2022-05-31 15:50:03 -04:00
G r e y c6167a94ef refactor: remove dangling comment (#1929) 2022-05-31 19:39:29 +00:00
Bruno Quaresma 65c17a04df feat: Add selected template link at the template select field (#1918) 2022-05-31 18:28:22 +00:00
Bruno Quaresma 75bcb739f9 refactor: Make login headline one line and add auth method section (#1922) 2022-05-31 16:40:56 +00:00
Kira Pilot 555bf2461a fix: change color of time icon for dark mode (#1923)
resolves #1791
2022-05-31 12:33:15 -04:00
G r e y bdacbd4989 refactor: mock provisioner job typings (#1919)
An unnecessary type assertion was being made on the status property;
instead we just type the object as a ProvisionerJob
2022-05-31 15:16:15 +00:00
Presley Pizzo 6f7b7f0248 feat: Delete workspace (#1822)
* Add delete button

* Add confirmation dialog

* Extract dialog, storybook it, and test it

* Fix cancel and redirect

* Remove fragment
2022-05-31 10:43:31 -04:00
Abhineet Jain 9b19dc9154 refactor: rename SettingsPages directory to UserSettingsPage (#1877) 2022-05-31 14:16:17 +00:00
Bruno Quaresma 83edbee2e1 fix: Replace yes by true and add set -x (#1914) 2022-05-31 14:14:14 +00:00
Kira Pilot dd55d4577d chore: remove react imports (#1867)
reolves #1856
2022-05-31 10:01:37 -04:00
Steven Masley 26a2a169df fix: Suspended users cannot authenticate (#1849)
* fix: Suspended users cannot authenticate

- Merge roles and apikey extract httpmw
- Add member account to make dev
- feat: UI Shows suspended error logging into suspended account
- change 'active' route to 'activate'
2022-05-31 08:06:42 -05:00
Cian Johnston e02ef6f228 chore: executor_test: reduce test execution time (#1876)
Removes 5-second wait in autobuild.executor unit tests:

- Adds a write-only channel to Executor and plumbs through to unit tests
- Modifies runOnce to return an executor.RunStats struct and write to statsCh if not nil
2022-05-30 20:23:36 +01:00
Ketan Gangatirkar ae4b2d88cd added links to our issues to reduce necessary thinking to report issues 2022-05-30 14:19:48 -05:00
Cian Johnston a8ae9b39b3 feat: enforce upper bounds on workspace TTL and Deadline (#1902)
* Enforces upper bound for workspace TTL
* Enforces upper bound for workspace deadline
2022-05-30 20:19:17 +01:00
Ketan Gangatirkar 17a57a44eb added community links 2022-05-30 14:16:02 -05:00
Ketan Gangatirkar 02692402d8 added #coder in the most prominent least awkward place 2022-05-30 14:12:33 -05:00
Ben Potter 6850db2a47 chore: fix additional typo in templates doc 2022-05-28 08:14:46 -05:00
Ben Potter 80ec67f3fd chore: fix typo in templates docs 2022-05-28 08:13:50 -05:00
Ben Potter 7ad68ca36b example: docker: support Windows hosts (#1880) 2022-05-28 01:09:29 +00:00
Kyle Carberry da7ed8b292 chore: Ignore scripts from code coverage (#1878)
Our CI scripts don't need to have thorough tests, and aren't
in the hot path of the product.
2022-05-27 22:25:24 +00:00
Garrett Delfosse 5598ac05dc fix: prevent email from being altered (#1863) 2022-05-27 22:25:04 +00:00
Asher cfa316be89 fix: incomplete message when intercepting console logger (#1875)
I was getting a message like "Warning: Failed type %s: %s%s".
2022-05-27 17:16:19 -05:00
Asher dd1484e24f fix: add missing key to resource row (#1874) 2022-05-27 17:16:04 -05:00
Garrett Delfosse 8222bdc3bc feat: add user password change page (#1866) 2022-05-27 18:08:28 -04:00
Ben 8cd7d4fa9c chore: update hero 2022-05-27 20:48:52 +00:00
Abhineet Jain d623eeb8d1 feat: delete API token in /logout API (#1770)
* delete API token in logout api

* add deleteapikeybyid to databasefake

* set blank cookie on logout always

* refactor logout flow, add unit tests

* update logout messsage

* use read-only file mode for windows

* fix file mode on windows for cleanup

* change file permissions on windows

* assert error is not nil

* refactor cli

* try different file mode on windows

* try different file mode on windows

* try keeping the files open on Windows

* fix the error message on Windows
2022-05-27 16:47:03 -04:00
Kyle Carberry d0ed107b08 fix: Add command to reconnecting PTY (#1860)
This fixes #1708 and opens the door for PTYs to execute
non-shell commands!
2022-05-27 14:51:20 -05:00
Kira Pilot 6052607936 feat: add user roles to menu (#1862)
* view user roles in menu

resolves #1524

* fix stories

* PR feedback
2022-05-27 15:27:51 -04:00
G r e y 8d7499feb7 feat: ui alert <= 30mins from deadline (#1825)
Summary:

When a workspace build is <= 30 minutes from auto-scheduled shutdown,
then an alert banner is displayed on the workspace page.
2022-05-27 15:23:56 -04:00
Cian Johnston ff542afe87 feat: allow bumping workspace deadline (#1828)
* Adds a `bump` command to extend workspace build deadline
 * Reduces WARN-level logging spam from autobuild executor
 * Modifies `cli/ssh` notifications to read from workspace build deadline and to notify relative time instead (sidestepping the problem of figuring out a user's timezone across multiple OSes)
 * Shows workspace extension time in `coder list` output e.g.
    ```
    WORKSPACE        TEMPLATE  STATUS   LAST BUILT  OUTDATED  AUTOSTART        TTL        
    developer/test1  docker    Running  4m          false     0 9 * * MON-FRI  15m (+5m)  
    ```
2022-05-27 20:04:33 +01:00
Ben Potter bde3779fec chore: clarify install options in README (#1844)
* chore: clarify install options in README

* clarify the path is an example, not a requirement

* Update README.md

Co-authored-by: Katie Horne <katie@coder.com>

* Update README.md

Co-authored-by: Katie Horne <katie@coder.com>

* Update README.md

Co-authored-by: Katie Horne <katie@coder.com>

* Update README.md

Co-authored-by: Katie Horne <katie@coder.com>

* Update README.md

Co-authored-by: Katie Horne <katie@coder.com>

Co-authored-by: Katie Horne <katie@coder.com>
2022-05-27 18:10:54 +00:00
Ben Potter 5000edbfe0 example: docker warning on Coder host (#1842) 2022-05-27 13:02:59 -05:00
Kyle Carberry 984dc2bffd fix: Close peer negotiate mutex if we haven't negotiated (#1774)
Closes #1706 and #1644.
2022-05-27 17:34:13 +00:00
Garrett Delfosse 24d1a6744a fix: Add route for user to change own password (#1812) 2022-05-27 17:29:55 +00:00
Mathias Fredriksson 608eb322a8 chore: Add .editorconfig, shfmt, shellcheck and subshell dir changes (#1649) 2022-05-27 20:15:19 +03:00
Mathias Fredriksson 1a70298b5c feat: Add examples/templates/do-linux for Digital Ocean Droplets (#1749)
Co-authored-by: Cian Johnston <cian@coder.com>
2022-05-27 20:04:43 +03:00
Oxylibrium 14cdd85b66 fix(site): username validation in forms (#1851)
* refactor(site): move name validation to utils
* fix(site): username validation in forms
2022-05-27 17:02:56 +00:00
Garrett Delfosse 8a5277e291 fix: restore previous session on coder server --dev (#1821) 2022-05-27 17:02:02 +00:00
Bruno Quaresma 7eacab82a2 refactor: Update users page to looks like others (#1850) 2022-05-27 16:47:11 +00:00
Ammar Bandukwala e2030bba38 Move competitive comparison to README
And rewrite a bit.

Resolves #1365.
2022-05-27 11:38:25 -05:00
Steven Masley ec1fe46138 feat: Move create organizations route (#1831)
* feat: last rbac routes
- move create organization to /organizations.
2022-05-27 11:19:13 -05:00
ketang d73a0f4f23 fixed grammar 2022-05-27 11:09:53 -05:00
Ben Potter 655f348812 chore: change README to fancy alpha note 2022-05-27 10:56:35 -05:00
Bruno Quaresma 2b2d0291c2 fix: Suspend user in the UI (#1841) 2022-05-27 15:23:56 +00:00
Bruno Quaresma 4125863226 fix: Fix template README when has front-matter notation (#1840) 2022-05-27 15:19:32 +00:00
Steven Masley a409a34819 fix: Open csp-images to allow external (#1835)
External images are required for the README parts of templates.
Only allowing https right now
2022-05-27 14:59:13 +00:00
Abhineet Jain 7a5c8734ee test: Fix unit test in 'TestWorkspaceExtend' (#1836) 2022-05-27 14:45:22 +00:00
Abhineet Jain 9929189c45 feat: add tag and value in validation error details (#1760)
* add tag and value in validation error details

* fix unit tests and linter

* add quotes around value

* fix unit tests
2022-05-27 10:13:13 -04:00
Ammar Bandukwala c5f06acb01 Add alpha disclaimer to README 2022-05-27 09:08:35 -05:00
Steven Masley ebaae75993 test: Unit test to assert role capabilities (#1781)
* test: Unit test to assert role permissions

This unit test allows for asserting which roles can perform
actions on various objects. This is much easier than making
unit tests to hit the api.
2022-05-27 08:48:19 -05:00
Mathias Fredriksson 12227874a8 fix: Detect changes to examples/templates in Makefile (#1829) 2022-05-27 16:34:32 +03:00
Garrett Delfosse 1361c1357a feat: inject USER into shells (#1818) 2022-05-26 18:01:47 -05:00
ketang 951dc2d8b0 update tagline 2022-05-26 17:00:09 -05:00
Joe Previte d01a687caa fix: typo in docker terraform template (#1811) 2022-05-26 21:28:17 +00:00
Joe Previte 4d79b806c0 docs: clarify installing Coder instructions (#1809) 2022-05-26 14:11:58 -07:00
G r e y b6d6276149 ci: disable chromatic on forks (#1806) 2022-05-26 20:27:32 +00:00
Colin Adler 5833e37354 fix: macos flake (#1804)
https://github.com/coder/coder/runs/6614638495?check_suite_focus=true#step:9:104
2022-05-26 15:21:48 -05:00
Colin Adler d135f85f69 fix: use correct devnull device on windows for proxy logs (#1803) 2022-05-26 15:21:36 -05:00
G r e y 7467bfe4ed chore: organize ws stats, schedule stories (#1790)
Resolves: #1681

Summary:

- Moves WorkspaceSchedule out of WorkspaceStats
- Adds WorkspaceScheduleForm directory

Impact:

Improves breadth of our chromatic visual regression tests since the
examples for WorkspaceStats were non-representative of the component
2022-05-26 16:14:08 -04:00
Kira Pilot d4c26d534c chore: remove admin dropdown (#1802)
resolves #1748
2022-05-26 16:04:51 -04:00
Presley Pizzo 07ebd59e94 fix: Remove workspace Settings button and page (#1807) 2022-05-26 20:02:37 +00:00
Garrett Delfosse 4d6e8526a8 chore: tolerate codecov failures in CI (#1798) 2022-05-26 14:48:34 -05:00
Kira Pilot b4c41d3904 chore: add users link to nav bar (#1797)
* chore: add users link to nav bar

resolves #1746

* fix test names
2022-05-26 15:25:13 -04:00
Garrett Delfosse 781f3d0641 fix: use dir over full path for coder bin (#1795) 2022-05-26 19:05:46 +00:00
Bruno Quaresma 7b393526c5 fix: Fix sensitive parameters being displayed in the new workspace form (#1796) 2022-05-26 13:42:25 -05:00
Presley Pizzo d2ff5904c0 fix: hide New user button if no permission (#1794) 2022-05-26 14:25:23 -04:00
Bruno Quaresma e1b0cb0bca Remove create template button from the UI (#1793) 2022-05-26 18:22:47 +00:00
Garrett Delfosse 3052a6d88e Add coder executable to PATH (#1771) 2022-05-26 12:59:41 -05:00
Presley Pizzo fc67c6efb1 fix: remove unused pages from Admin dropdown (org and settings) (#1788)
* Delete Orgs Page

* Delete Admin Settings page
2022-05-26 13:10:54 -04:00
Cian Johnston 8f0a5a81f1 feat: add API/SDK support for autostop extension (#1778)
* Adds deadline column to workspace_builds, associated DB/API plumbing
* database: Upon inserting a row into workspace_builds, deadline will 
  initially be zero.
* autobuild: Executor now checks the Deadline field of the workspace_build
  for the purpose of autostop logic.
* coderd: Adds a new route /api/v2/workspaces/:workspace/extend which allows
  updating the deadline of the currently active workspace build. The new
  deadline must be after the existing deadline, and not the zero time.
* provisionerd: updates workspace_build.deadline upon successful workspace 
  build completion (equal to now plus workspace TTL, if it exists).
2022-05-26 18:08:11 +01:00
Steven Masley c04d045279 feat: RBAC provisionerdaemons and parameters (#1755)
* chore: Remove org_id from provisionerdaemons
2022-05-26 11:20:54 -05:00
Bruno Quaresma 104d07f659 feat: Add the template page (#1754) 2022-05-26 16:19:11 +00:00
G r e y 7c59ec4a2b feat: edit workspace schedule page (#1701)
Resolves: #1455 
Resolves: #1456

Summary:

Adds a page (accessible from Workspace Schedule section on a workspace) to edit a schedule.

Impact:

General parity with CLI for autostart/autostop: that is you can update your schedule from the UI
2022-05-26 12:11:30 -04:00
Kira Pilot 9a70c345c7 fix: update workspace form fields when switching templates (#1761)
resolves #1716
2022-05-26 08:43:07 -04:00
Kyle Carberry 31b819e83f chore: Remove interface from coderd and lift API surface (#1772)
Abstracting coderd into an interface added misdirection because
the interface was never intended to be fulfilled outside of a single
implementation.

This lifts the abstraction, and attaches all handlers to a root struct
named `*coderd.API`.
2022-05-26 03:14:08 +00:00
Abhineet Jain c78f947e09 feat: Upgrade terraform version to 1.1.9 (#1745)
* upgrade terraform version to 1.1.9

* Fix docs typo

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-05-25 19:35:41 -04:00
Presley Pizzo 841d9f277c feat: UI for canceling workspace builds (#1735)
* Start hooking up cancel

* Update xservice

* Render cancel

Changes behavior of other buttons too

* Make outdated workspace story show max buttons

* Remove retry code

* Remove loading button state

* Fix type, extend tests

* Update story
2022-05-25 17:58:00 -04:00
Garrett Delfosse 35ccb88f60 feat: add dotfiles command (#1723) 2022-05-25 16:43:20 -05:00
Ben Potter 47ef03fea4 example: fix: properly tag aws-windows workspaces (#1744) 2022-05-25 22:11:29 +01:00
Colin Adler b5d615367e chore: update cdr.dev/slog (#1759)
Fixes #1626
2022-05-25 20:22:38 +00:00
Mathias Fredriksson 527f1f3bc3 feat: Add SSH agent forwarding support to coder agent (#1548)
* feat: Add SSH agent forwarding support to coder agent

* feat: Add forward agent flag to `coder ssh`

* refactor: Share setup between SSH tests, sync goroutines

* feat: Add test for `coder ssh --forward-agent`

* fix: Fix test flakes and implement Deans suggestion for helpers

* fix: Add example to config-ssh

* fix: Allow forwarding agent via -A

Co-authored-by: Cian Johnston <cian@coder.com>
2022-05-25 21:28:10 +03:00
dependabot[bot] 22ef456164 chore: bump github.com/gohugoio/hugo from 0.98.0 to 0.99.1 (#1699)
* chore: bump github.com/gohugoio/hugo from 0.98.0 to 0.99.1

Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.98.0 to 0.99.1.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/goreleaser.yml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.98.0...v0.99.1)

---
updated-dependencies:
- dependency-name: github.com/gohugoio/hugo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fixup! chore: bump github.com/gohugoio/hugo from 0.98.0 to 0.99.1

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-05-25 12:44:23 -05:00
dependabot[bot] 088f842e17 chore: bump github.com/hashicorp/terraform-json from 0.13.0 to 0.14.0 (#1736)
Bumps [github.com/hashicorp/terraform-json](https://github.com/hashicorp/terraform-json) from 0.13.0 to 0.14.0.
- [Release notes](https://github.com/hashicorp/terraform-json/releases)
- [Commits](https://github.com/hashicorp/terraform-json/compare/v0.13.0...v0.14.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-json
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-25 12:20:28 -05:00
dependabot[bot] 29175d3158 chore: bump github.com/ory/dockertest/v3 from 3.8.1 to 3.9.0 (#1738)
Bumps [github.com/ory/dockertest/v3](https://github.com/ory/dockertest) from 3.8.1 to 3.9.0.
- [Release notes](https://github.com/ory/dockertest/releases)
- [Commits](https://github.com/ory/dockertest/compare/v3.8.1...v3.9.0)

---
updated-dependencies:
- dependency-name: github.com/ory/dockertest/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-25 12:20:11 -05:00
dependabot[bot] cd6fdc7832 chore: bump google.golang.org/api from 0.79.0 to 0.81.0 (#1737)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.79.0 to 0.81.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.79.0...v0.81.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-25 11:51:21 -05:00
dependabot[bot] 3c21b070d7 chore: bump github.com/pion/webrtc/v3 from 3.1.39 to 3.1.41 (#1697)
Bumps [github.com/pion/webrtc/v3](https://github.com/pion/webrtc) from 3.1.39 to 3.1.41.
- [Release notes](https://github.com/pion/webrtc/releases)
- [Commits](https://github.com/pion/webrtc/compare/v3.1.39...v3.1.41)

---
updated-dependencies:
- dependency-name: github.com/pion/webrtc/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-25 16:35:02 +00:00
Steven Masley eea8dc6c16 feat: Add rbac to templateversion+orgmember endpoints (#1713) 2022-05-25 11:00:59 -05:00
David Wahler f8410dee3a fix: include subdirectories in example templates (#1715) 2022-05-25 10:34:28 -05:00
Bruno Quaresma 5492ab75c2 feat: Add resource type and restyle terminal link (#1722) 2022-05-25 13:32:01 +00:00
Ammar Bandukwala c5f4d80eda Shorten README before Install docs 2022-05-24 20:20:08 -05:00
Kyle Carberry 74329f479f fix: Use Terraform address to index resource + agent association (#1727)
Closes #1705.

There was an issue in the implementation brought by #1577 by not trimming
the array value when resources use counts. This should fix it, and adds
a test to be sure!
2022-05-24 20:00:34 -05:00
Ammar Bandukwala 95d7e39c80 Rewrite README for launch (#1731) 2022-05-25 00:40:57 +00:00
Kyle Carberry 4d9168c076 fix: Increase release timeout (#1729)
This is unfortunate, but with the containers it can take a while.
We should spend some time making these parallel in the future,
but for now this is fine!
2022-05-24 16:54:27 -05:00
Colin Adler 4543a3b277 fix: log after test exit in TestAgent/StartupScript (#1726)
```
$ go test ./agent/ -v -run TestAgent/StartupScript -count 1
=== RUN   TestAgent
=== PAUSE TestAgent
=== CONT  TestAgent
=== RUN   TestAgent/StartupScript
=== PAUSE TestAgent/StartupScript
=== CONT  TestAgent/StartupScript
    t.go:56: 2022-05-24 20:22:39.648 [INFO]	<agent.go:112>	connected
--- PASS: TestAgent (0.00s)
    --- PASS: TestAgent/StartupScript (0.17s)
PASS
panic: Log in goroutine after TestAgent/StartupScript has completed: 2022-05-24 20:22:39.651 [WARN]	<agent.go:130>	agent script failed ...
"error": run:
             github.com/coder/coder/agent.(*agent).runStartupScript
                 /home/colin/Projects/coder/coder/agent/agent.go:183
           - signal: killed
```
2022-05-24 16:03:42 -05:00
Oxylibrium 99c79c79db docs(README): fix links to subpages (#1724) 2022-05-24 19:26:25 +00:00
G r e y 104c76b8bc ci: limit chromatic to site (#1700) 2022-05-24 14:30:15 -04:00
Joe Previte 0ade49b758 docs: rephrase value statement in README (#1711) 2022-05-24 10:59:20 -07:00
Abhineet Jain 7ba6449054 Improve CLI logout flow (#1692)
* Improve CLI logout flow

* Fix lint error

* Make notLoggedInMessage a const

* successful logout with a msg when cfg files are absent

* use require, os.remove, show only one message, add prompt
2022-05-24 13:11:01 -04:00
Ammar Bandukwala 33e2e40942 Expand stalebot to issues (#1672)
Removing old, stale issues is essential to keeping a workable tracker.
2022-05-24 10:03:43 -07:00
Steven Masley d3a0578fe1 feat: Allow regen-ssh and fetching a single user from the cli (#1619)
* feat: Allow regen-ssh and fetching a single user from the cli
2022-05-24 16:53:04 +00:00
Steven Masley 363b16af38 fix: Add template read permission node to members (#1712) 2022-05-24 16:35:34 +00:00
Joe Previte 61ffd03aaf docs: update contribution guidelines (#1691)
* docs(contributing): add subheading backend under styling

* docs: add styling for frontend
2022-05-24 15:30:15 +00:00
G r e y b0d52039f9 refactor: resource strings in WorkspaceSchedule (#1702) 2022-05-24 09:55:30 -04:00
Steven Masley c7ca86d374 feat: Implement RBAC checks on /templates endpoints (#1678)
* feat: Generic Filter method for rbac objects
2022-05-24 08:43:34 -05:00
Bruno Quaresma fcd610ee7b refactor: Update create workspace flow to allow creation from the workspaces page (#1684) 2022-05-24 08:37:44 -05:00
Steven Masley 5f8d0e5dad feat: Add RBAC to /files endpoints (#1664)
* feat: Add RBAC to /files endpoints
2022-05-24 08:25:02 -05:00
Bruno Quaresma f763472609 fix: Fix template label (#1685) 2022-05-24 12:38:31 +00:00
Mathias Fredriksson 34b1e19338 fix: Try to fix cli portforward test flakes (#1650)
* fix: Try to fix cli portforward test flakes

* fix: Guard against agent exit outside test func

* fix: Improve test teardown in setupTestListener, cleanup
2022-05-24 11:15:06 +03:00
Cian Johnston c2f74f3cc2 chore: avoid concurrent usage of t.FailNow (#1683)
* chore: golangci: add linter rule to report usage of t.FailNow inside goroutines
* chore: avoid t.FailNow in goroutines to appease the race detector
2022-05-24 08:58:39 +01:00
Presley Pizzo 9b70a9b2eb Fix: fix Workspace storybook and remove unnecessary fetching from xService (#1682)
* Make workspace machine ephemeral to limit polling

* Fix Workspace storybook

* Lint

* Remove breadcrumb from workspaceXService
2022-05-23 20:04:38 -04:00
dependabot[bot] 4ba3eedb70 chore: bump github.com/lib/pq from 1.10.5 to 1.10.6 (#1653)
Bumps [github.com/lib/pq](https://github.com/lib/pq) from 1.10.5 to 1.10.6.
- [Release notes](https://github.com/lib/pq/releases)
- [Commits](https://github.com/lib/pq/compare/v1.10.5...v1.10.6)

---
updated-dependencies:
- dependency-name: github.com/lib/pq
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-23 18:02:12 -05:00
dependabot[bot] 62acfc9a07 chore: bump goreleaser/goreleaser-action from 2 to 3 (#1652)
Bumps [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) from 2 to 3.
- [Release notes](https://github.com/goreleaser/goreleaser-action/releases)
- [Commits](https://github.com/goreleaser/goreleaser-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: goreleaser/goreleaser-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-23 22:55:40 +00:00
dependabot[bot] 98345e3d24 chore: bump github.com/hashicorp/go-version from 1.4.0 to 1.5.0 (#1654)
Bumps [github.com/hashicorp/go-version](https://github.com/hashicorp/go-version) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/hashicorp/go-version/releases)
- [Changelog](https://github.com/hashicorp/go-version/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/go-version/compare/v1.4.0...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-version
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-23 17:49:21 -05:00
dependabot[bot] e9818d79da chore: bump jaxxstorm/action-install-gh-release from 1.6.0 to 1.7.1 (#1651)
Bumps [jaxxstorm/action-install-gh-release](https://github.com/jaxxstorm/action-install-gh-release) from 1.6.0 to 1.7.1.
- [Release notes](https://github.com/jaxxstorm/action-install-gh-release/releases)
- [Commits](https://github.com/jaxxstorm/action-install-gh-release/compare/v1.6.0...v1.7.1)

---
updated-dependencies:
- dependency-name: jaxxstorm/action-install-gh-release
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-23 17:47:38 -05:00
dependabot[bot] 2de47ef9f0 chore: bump github.com/quasilyte/go-ruleguard/dsl from 0.3.19 to 0.3.21 (#1655)
Bumps [github.com/quasilyte/go-ruleguard/dsl](https://github.com/quasilyte/go-ruleguard) from 0.3.19 to 0.3.21.
- [Release notes](https://github.com/quasilyte/go-ruleguard/releases)
- [Commits](https://github.com/quasilyte/go-ruleguard/compare/dsl/v0.3.19...dsl/v0.3.21)

---
updated-dependencies:
- dependency-name: github.com/quasilyte/go-ruleguard/dsl
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-23 22:45:40 +00:00
Cian Johnston b2020761d9 feat: add default autostart and ttl for new workspaces (#1632)
* database: add autostart_schedule and ttl to InsertWorkspace; make gen
* coderd: workspaces: consume additional fields of CreateWorkspaceRequest
* cli: update: add support for TTL and autostart_schedule
* cli: create: add unit tests
* coder: import  `time/tzdata` for embedded timezone database
* autobuild: fix unit test that only runs with a real db
2022-05-23 23:31:41 +01:00
G r e y c465f8a8a3 feat: add retry to ErrorSummary (#1690)
Summary:

The ErrorSummary accepts a retry callback and received improvements to
style and product copy

Impact:

This allows xstate-controlled pages to send re-fetch events
2022-05-23 21:07:52 +00:00
Asher dd4bb07193 feat: add terminal links (#1636) 2022-05-23 15:49:02 -05:00
Oxylibrium 80f8f605fd chore: Add self to CONTRIBUTORS.md (#1680) 2022-05-23 16:46:03 -04:00
Bruno Quaresma 57c6d887a1 chore: Ignore last built value on Chromatic (#1687) 2022-05-23 20:42:05 +00:00
Katie Horne 98c89f80b0 chore: add instructions for installation w/ Docker Compose (#1599)
Co-authored-by: Ben Potter <ben@coder.com>
2022-05-23 19:42:45 +00:00
ketang ba66052181 fix incorrect retention field on artifacts in coder.yaml 2022-05-23 14:13:05 -05:00
Abhineet Jain fc46818e31 chore: move contributor list to contributors.md (#1496) 2022-05-23 19:09:45 +00:00
ketang 7de4cd6231 replace .deb artifact with Windows .zip 2022-05-23 13:54:13 -05:00
Abhineet Jain 4a78bade6d bug: Cleaner error message for non logged-in users (#1670)
* add helper text to unauthorized error messages

* fix lint error, add unit tests

* fix test name

* fix test name

* fix lint errors in test

* add unauthorized test for templates create

* remove unnecessary variable

* remove Error struct, change error message

* change [url] to <url>
2022-05-23 14:51:49 -04:00
ketang c543fca92f add tar.gz to artifacts and a 7 day retention period to .deb 2022-05-23 13:35:25 -05:00
Katie Horne b0298a3157 chore: fix in-product copy casing (#1671) 2022-05-23 13:30:38 -05:00
Presley Pizzo 7ac3cbe772 Make workspace machine ephemeral to limit polling (#1674) 2022-05-23 13:25:46 -04:00
Steven Masley 873ae90f39 feat: cli configs should not be space sensitive (#1668) 2022-05-23 12:19:33 -05:00
Mathias Fredriksson c8ed213347 fix: Guard against CLI cmd running after test exit (#1658)
* fix: Guard against CLI cmd running after test exit

* fix: cli: avoid calling t.FailNow in non-test-main goroutine

* fix: cli: server_test: avoid calling t.FailNow outside main goroutine

* fix: cli: clitest_test: avoid calling t.FailNow outside main goroutine

* fix: cli: list_test: avoid calling t.FailNow outside main goroutine

* fix: TestGitSSH use-of-t-after-exit

* fix: TestGitSSH "too many authentication failures"

Due to local SSH keys being given

* chore: clitest: fix TestCli

* chore: Simplify TestTemplateInit

Co-authored-by: Cian Johnston <cian@coder.com>
2022-05-23 20:09:58 +03:00
Kira Pilot fa957d6d65 fix: omit url params on login (#1666)
resolves #1282
2022-05-23 11:01:32 -04:00
Bruno Quaresma 9f3a6d631c refactor: Move schedule info to the sidebar (#1665) 2022-05-23 09:41:04 -05:00
Bruno Quaresma 1f03277f1c refactor: Increase navbar height (#1662) 2022-05-23 10:22:48 -04:00
Cian Johnston a8a8f9dbf3 chore: skip some flaky tests (#1643)
* chore: skip some flaky tests

* Update peer/conn_test.go

* add makefile targets, reduce parallelism in go test
2022-05-21 00:39:51 +01:00
G r e y 4f75291446 feat: form for editing ws schedule (#1634)
* feat: ui for editing ws schedule

Summary:

This presents a form component and storybook. The UI will be a routed
page and added into the dashboard in a separate PR. It is likely a
XService will be used at the page level to supply errors and actions to
this form.

Impact of Change:

Further progress on #1455

Squashed Commits:

* refactor: add className prop to Stack

combine classes with internal classes and an optional external className
to better control the Stack.

* fix: getFormHelpers helperText

the helperText logic was incorrect, the helperText would only show if not touched.
2022-05-20 20:26:43 +00:00
Bruno Quaresma b29a2dfdde refactor: Minor design adjustments (#1637) 2022-05-20 19:37:03 +00:00
Joe Previte 3653fcf256 fix: remove outdated doc paths in goreleaser (#1633)
It appears we were manually moving the `README.md`. This should have been updated in https://github.com/coder/coder/pull/1630 but slipped through CI
2022-05-20 19:02:38 +00:00
Presley Pizzo e40c68399d feat: resources card (#1627)
* Set up table

* Format

* Hook up api and test - bug assigning resources

* Remove debugging code

* Format

* Remove unnecessary cards

* Fix test

* Fix assignment

* Fix tests

* Lint
2022-05-20 18:29:42 +00:00
Steven Masley c189fc52c1 fix: using a trailing slash on login url (#1622) 2022-05-20 12:42:01 -05:00
Bruno Quaresma ce7bf0b847 feat: Redesign the workspace page (#1620) 2022-05-20 17:05:00 +00:00
Joe Previte 0622603220 docs: move README to root (#1630)
We noticed that when you download the repo as a ZIP from GitHub, it
places the `README.md` in the root, which causes the relative links to
break.

By moving it to the root, this will fix that issue.
2022-05-20 09:56:50 -07:00
Steven Masley ad946c3902 feat: Add confirm prompts to some cli actions (#1591)
* feat: Add confirm prompts to some cli actions
- Add optional -y skip. Standardize -y flag across commands
2022-05-20 15:59:04 +00:00
G r e y 4f70f84635 feat: WorkspaceSection action, styles (#1623)
This PR is a squash of refactors and improvements in our Workspace and
WorkspaceSection components. An action prop is added to WorkspaceSection
and along the way, I refactored things that were not meeting conventions
or were hard to read. With this addition, I am further unblocked in
making auto-start/off editable in the UI, as I intend to use the Action
prop to trigger a modal (or routed page view) with the form.

Squashed commits:

* refactor: spaces for readability
It's hard to read HTMl markup without spaces on adjacent nodes

* refactor: props
Our components had unused props and arbitrary ordering.
2022-05-20 11:55:39 -04:00
Garrett Delfosse 0effb71f43 feat: add tracing for sql (#1610) 2022-05-20 10:51:06 -05:00
Abhineet Jain 7c3e1a5d97 feat: Read params from file for template/workspace creation (#1541)
* Read params from file for template/workspace creation

* Use os.ReadFile

* Refactor reading params into a separate module

* Add comments and unit tests

* Rename variable

* Uncomment and fix unit test

* Fix comment

* Refactor tests

* Fix unit tests for windows

* Fix unit tests for Windows

* Add comments for the hotfix
2022-05-20 11:29:10 -04:00
Kira Pilot d0fd0d7040 feat: added error boundary (#1602)
* added error boundary and error ui components

* add body txt and standardize btn size

* added story

* feat: added error boundary

closes #1013

* committing lockfile

* added email body to help link
2022-05-20 10:48:39 -04:00
Cian Johnston 52230fab56 feat: make default autobuild poll intervals configurable (#1618)
* feat: make default poll intervals for autobuild and ssh ttl polling configurable
2022-05-20 10:57:02 +00:00
Mathias Fredriksson 992b58389b fix: Use the cobra CommandPath for usage to avoid duplication (#1617) 2022-05-20 12:42:56 +03:00
Dean Sheather adb7d20c16 feat: skip terraform destroy if there is no state when deleting (#1594) 2022-05-20 14:07:23 +10:00
Spike Curtis a03615a01f feature: disable provisionerd listen endpoint (#1614)
* feature: disable provisionerd listen endpoint

Signed-off-by: Spike Curtis <spike@coder.com>

* Regenerate ts types

Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-19 23:52:17 +00:00
Spike Curtis d1817310a1 fix build and lint (#1613)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-19 23:28:29 +00:00
Spike Curtis 1871b09697 feat: in-process provisionerd connection (#1568)
* in-process provisionerd connection

Signed-off-by: Spike Curtis <spike@coder.com>

* disable lint for server.go/newProvisionerDaemon

Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-19 17:47:45 -05:00
Garrett Delfosse 376c6819e0 feat: Move from datadog to generic otel (#1567) 2022-05-19 17:43:07 -05:00
Colin Adler 2a85d3d083 chore: unconditionally run all make cmds in CI (#1608) 2022-05-19 17:42:49 -05:00
Garrett Delfosse 077f16ce2c feat: add coder logout command (#1609) 2022-05-19 22:42:32 +00:00
David Wahler 0c4a65b113 fix: manually fix coderd/database/dump.sql and make style/gen check run more reliably (#1607) 2022-05-19 22:37:22 +00:00
Joe Previte 6dae48a1a8 fix: show --help message for CLI errors, add tests for delete (#1403)
* feat(cli): add test for delete

This adds a new test for the `delete` command to ensure it works as
expected when provided the correct args.

* fix(cli): use ExecuteC() to match Cobra

This modifies the `cli.Root().Execute()` to `cli.Root).ExecuteC()` to
match the default behavior of Cobra. We do this so errors will always
print the "run --help" line.

* feat(cli): add WithoutParameters test for delete

This adds a new test to the `delete_test.go` suite to ensure the correct
behavior occurs when `delete` is called without an argument.

* fixup! feat(cli): add WithoutParameters test for delete

* refactor(cli): show --help error message on main

This adds an error message which shows when there is an error with any
commands called to improve the UX.

* fixup! refactor(cli): show --help error message on main

* refactor(cli): handle err with FormatCobraError

This adds a new helper function called `FormatCobraError` to `root.go`
so that we can colorize and add "--help" message to cobra command errors
like calling `delete`.

* refactor(cli): add root_test.go, move delete test
2022-05-19 22:35:59 +00:00
G r e y a64ab6538e chore: update CODEOWNERS (#1600)
Resolves: #1559
2022-05-19 16:26:39 -05:00
Bruno Quaresma 0ffcc47f32 fix: Fix log order in the workspace build page (#1604) 2022-05-19 21:19:28 +00:00
Kyle Carberry 3be356095f feat: Add create workspace page (#1589) 2022-05-19 20:51:10 +00:00
Ben Potter 4afc66faf5 chore: remove docker host from docker-compose (#1596) 2022-05-19 20:38:07 +00:00
Bruno Quaresma 0b1a35f7b8 feat: Add workspace build logs page (#1598) 2022-05-19 15:34:42 -05:00
Cian Johnston d72c45e483 refactor: workspace autostop_schedule -> ttl (#1578)
Co-authored-by: G r e y <grey@coder.com>
2022-05-19 15:09:27 -04:00
Steven Masley 6c1117094d chore: Force codersdk to not import anything from database (#1576)
* chore: Force codersdk to not import anything from database (linter rule)
* chore: Move all database types in codersdk out
2022-05-19 13:04:44 -05:00
G r e y a0834404f7 chore: rm dead code; add check:all (#1595) 2022-05-19 12:40:40 -05:00
Ben Potter c47b6f0381 chore: use docker host in docker-compose (#1592) 2022-05-19 11:49:22 -05:00
G r e y 67333b6186 feat: getWorkspaces filter site api (#1564) 2022-05-19 12:08:55 -04:00
LG 0438430c7c fix: missing spacing added; typo fix (#1586)
Co-authored-by: Ben <ben@coder.com>
2022-05-19 15:51:49 +00:00
G r e y e0165c5d89 fix: static data in mocks (#1574) 2022-05-19 11:36:14 -04:00
Bruno Quaresma 3f770e1111 fix: User permissions on UI (#1570) 2022-05-19 15:10:18 +00:00
Dean Sheather 4eb0bb6afd feat: don't return 200 for deleted workspaces (#1556) 2022-05-20 00:29:10 +10:00
Ben Potter eb8f371f34 chore: add container image to footer of releases (#1579)
* chore: add docker pull to footer
2022-05-19 13:38:05 +00:00
Kyle Carberry 38ee519f42 feat: Expose the values contained in an HCL validation string to the API (#1587)
* feat: Expose the values contained in an HCL validation string to the API

This allows the frontend to render inputs displaying these values!

* Update codersdk/parameters.go

Co-authored-by: Cian Johnston <cian@coder.com>

* Call a spade a space

* Fix linting errors with type conversion

Co-authored-by: Cian Johnston <cian@coder.com>
2022-05-19 13:29:36 +00:00
Mathias Fredriksson ad9bdb7bd1 fix: More robust provisionersdk agent init scripts (#1551)
Related #1544

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-05-19 13:02:42 +00:00
Katie Horne 6f969214d3 chore: validate docs (#1485) 2022-05-19 08:01:19 -05:00
Dean Sheather cabc164f74 feat: use and display default template values when creating wkspc. (#1584) 2022-05-19 22:49:40 +10:00
Cian Johnston 8814cb0722 Revert "fix: Use Terraform address to index resource + agent association (#1577)" (#1585)
This reverts commit f3fe2a08ce.
2022-05-19 12:18:40 +01:00
Steven Masley c034e8389e feat: Add RBAC to /workspace endpoints (#1566)
* feat: Add RBAC to /workspace endpoints
2022-05-18 18:15:19 -05:00
Kyle Carberry f3fe2a08ce fix: Use Terraform address to index resource + agent association (#1577)
This fixes resources created from Terraform modules not
properly being associated with an agent.

By not using the address, and resource identifiers prefixed
with `module.<name>` would be missed!
2022-05-18 16:26:08 -05:00
Garrett Delfosse 0706c60445 chore: Add watch workspace endpoint (#1493) 2022-05-18 16:16:26 -05:00
Ben Potter b8ee939e52 chore: change Slack to Discord link (#1573) 2022-05-18 21:14:31 +00:00
Ben Potter 37cf3bb491 example: add docker-image-builds + docker docs (#1526)
Co-authored-by: Katie Horne <katie@23spoons.com>
2022-05-18 16:03:20 -05:00
Kyle Carberry 97699e9704 fix: Rename NewMemoryCoderd to NewWithServer (#1571)
This name felt invalid, because `New` was also in memory.
2022-05-18 15:49:46 -05:00
Steven Masley 2638c274cb fix: User's should be able to read what roles available (#1575) 2022-05-18 20:47:43 +00:00
Steven Masley 8bd1abee33 fix: Use sdk type in coderd api response (#1569)
Was using the database type
2022-05-18 15:34:00 -05:00
Garrett Delfosse e2ed581708 Add stages to all proto.Logs (#1563) 2022-05-18 17:33:29 +00:00
David Wahler a50a6e8638 fix: Make TestAgent and TestWorkspaceAgentPTY less flaky (#1562) 2022-05-18 17:06:17 +00:00
Spike Curtis 9f402fa27f Spike/222 workspace build order (#1534)
* chore: refactor before_id/after_id to build_number

Signed-off-by: Spike Curtis <spike@coder.com>

* pagination of workspace_builds

Signed-off-by: Spike Curtis <spike@coder.com>

* Disable parallel on postgres tests

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix lint

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix workspace build postgres query

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix JS tests

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix workspace builds postgres query

Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-18 16:33:33 +00:00
Cian Johnston 13571b0393 examples/docker-local: add explanatory comment (#1545) 2022-05-18 17:10:23 +01:00
Garrett Delfosse 89fb59aa9a chore: remove make build dep from make dev (#1557) 2022-05-18 16:00:20 +00:00
Asher e4e7e10690 feat: add terminal link component (#1538)
* Fix not being able to specify agent when connecting to terminal

The `workspace.agent` syntax was only used when fetching the agent and
not the workspace so it would try to fetch a workspace called
`workspace.agent` instead of just `workspace`.

* Add terminal link component

Currently it does not show anywhere but we can drop it into the
resources card later.
2022-05-18 10:53:59 -05:00
David Wahler 5f21a145d1 bug: Don't try to handle SIGINT when prompting for passwords (#1498) 2022-05-18 15:26:38 +00:00
Steven Masley a3556b12da feat: Single query for all workspaces with optional filter (#1537)
* feat: Add single query for all workspaces using a filter
2022-05-18 10:09:07 -05:00
dependabot[bot] 894646cb7c chore: bump @testing-library/user-event from 14.1.1 to 14.2.0 in /site (#1521)
Bumps [@testing-library/user-event](https://github.com/testing-library/user-event) from 14.1.1 to 14.2.0.
- [Release notes](https://github.com/testing-library/user-event/releases)
- [Changelog](https://github.com/testing-library/user-event/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/user-event/compare/v14.1.1...v14.2)

---
updated-dependencies:
- dependency-name: "@testing-library/user-event"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-18 11:01:28 -04:00
Kira Pilot 85a932bfaf bug: fixed menu height diff (#1546)
resolves #1229
2022-05-18 10:34:56 -04:00
Dean Sheather 9141be3656 feat: add port-forward subcommand (#1350) 2022-05-19 00:10:40 +10:00
Kyle Carberry 76fc59aa79 feat: Add templates page (#1510)
* feat: Add template page

* Create xService

* Update column names

* Show create template conditionally

* Add template description

* Route to templates

* Add empty states

* Add tests

* Add loading indicator

* Requested changes
2022-05-18 09:05:18 -05:00
Bruno Quaresma b7481489b1 feat: Add timeline in the workspace page (#1533) 2022-05-18 13:54:06 +00:00
Ben Potter 6bed620d6c example: ec2: document "minimal" policy (#1536)
* example: ec2: document "minimal" policy

* move DescribeInstances

* move ModifyInstanceCreditSpecification
2022-05-18 08:17:05 -05:00
Steven Masley 4e28b2d9c5 test: Using local time in unit test fails in certain time zones (#1540)
* test: Using local time in unit test fails in certain time zones

This test was failing when running in CST (GMT-5) timezone.
My local timezone pushed the next to the upcoming monday

* fix: schedule: assert expected result of String() separately from input spec

Co-authored-by: Cian Johnston <cian@coder.com>
2022-05-18 13:09:36 +00:00
Kyle Carberry ba818b3a10 fix: Append Terraform module resources to list (#1539)
This was causing module resources to be skipped!
2022-05-17 19:07:20 -05:00
David Wahler 72c2bf80aa feat: "coder ssh --shuffle" easter egg (#1084) 2022-05-17 17:55:58 -05:00
Kyle Carberry 33701862de fix: Publish Linux releases in tar.gz archives (#1535)
This reduces download size by ~70%.
2022-05-17 21:11:13 +00:00
Colin Adler 98ccd0eb89 feat: add README parsing to template versions (#1500) 2022-05-17 15:00:48 -05:00
dependabot[bot] 0f9559a784 chore: bump cronstrue from 2.4.0 to 2.5.0 in /site (#1518)
Bumps [cronstrue](https://github.com/bradymholt/cronstrue) from 2.4.0 to 2.5.0.
- [Release notes](https://github.com/bradymholt/cronstrue/releases)
- [Commits](https://github.com/bradymholt/cronstrue/compare/v2.4.0...v2.5.0)

---
updated-dependencies:
- dependency-name: cronstrue
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 15:03:45 -04:00
Kira Pilot 65acfc9bef bug: using NavLink for menus (#1530)
* bug: using NavLink for menus

resolves #955

* lets fix our story
2022-05-17 15:01:53 -04:00
Steven Masley 4ad5ac2d4a feat: Rbac more coderd endpoints, unit test to confirm (#1437)
* feat: Enforce authorize call on all endpoints
- Make 'request()' exported for running custom requests
* Rbac users endpoints
* 401 -> 403
2022-05-17 13:43:19 -05:00
Garrett Delfosse 495c87b6c3 chore: add make dev (#1527) 2022-05-17 13:12:14 -05:00
dependabot[bot] 841b792e8e chore: bump @typescript-eslint/parser from 5.23.0 to 5.25.0 in /site (#1517)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.23.0 to 5.25.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.25.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:36:03 -04:00
dependabot[bot] c0b80ef899 chore: bump sql-formatter from 4.0.2 to 6.1.1 in /site (#1514)
Bumps [sql-formatter](https://github.com/zeroturnaround/sql-formatter) from 4.0.2 to 6.1.1.
- [Release notes](https://github.com/zeroturnaround/sql-formatter/releases)
- [Changelog](https://github.com/zeroturnaround/sql-formatter/blob/master/.release-it.json)
- [Commits](https://github.com/zeroturnaround/sql-formatter/compare/v4.0.2...v6.1.1)

---
updated-dependencies:
- dependency-name: sql-formatter
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:35:29 -04:00
dependabot[bot] 5227a74ae3 chore: bump webpack-dev-server from 4.8.1 to 4.9.0 in /site (#1511)
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.8.1 to 4.9.0.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.8.1...v4.9.0)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:35:04 -04:00
dependabot[bot] 3eaca0d436 chore: bump @pmmmwh/react-refresh-webpack-plugin in /site (#1484)
Bumps [@pmmmwh/react-refresh-webpack-plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) from 0.5.5 to 0.5.6.
- [Release notes](https://github.com/pmmmwh/react-refresh-webpack-plugin/releases)
- [Changelog](https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pmmmwh/react-refresh-webpack-plugin/compare/v0.5.5...v0.5.6)

---
updated-dependencies:
- dependency-name: "@pmmmwh/react-refresh-webpack-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:33:52 -04:00
Cian Johnston 190210b18d fix: set autostop notify to t minus 30 minutes (#1513) 2022-05-17 16:14:10 +01:00
dependabot[bot] bb2740e7c3 chore: bump @playwright/test from 1.21.1 to 1.22.1 in /site (#1512)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.21.1 to 1.22.1.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.21.1...v1.22.1)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:12:50 -04:00
dependabot[bot] 8dd32e2a0a chore: bump eslint from 8.14.0 to 8.15.0 in /site (#1344)
Bumps [eslint](https://github.com/eslint/eslint) from 8.14.0 to 8.15.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.14.0...v8.15.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:08:26 -04:00
dependabot[bot] d5a500a73f chore: bump @fontsource/inter from 4.5.7 to 4.5.10 in /site (#1251)
Bumps [@fontsource/inter](https://github.com/fontsource/fontsource/tree/HEAD/fonts/google/inter) from 4.5.7 to 4.5.10.
- [Release notes](https://github.com/fontsource/fontsource/releases)
- [Changelog](https://github.com/fontsource/fontsource/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fontsource/fontsource/commits/HEAD/fonts/google/inter)

---
updated-dependencies:
- dependency-name: "@fontsource/inter"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:05:28 -04:00
G r e y d177937e1c chore: clean site dependencies (#1509)
* delete package-lock.json
* pin dayjs
* pin uuid, @types/uuid
* pin xterm dependencies
* pin jest deps
2022-05-17 10:45:51 -04:00
Cian Johnston 75dc8f59f6 fix: example: update docker-local to use host-gateway (#1507)
* fix: example: update docker-local to use host-gateway
* docker-compose.yaml: Add POSTGRES_ environment variables to CODER_PG_CONNECTION_URL

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-05-17 14:40:13 +00:00
Kyle Carberry fc9efc2b79 fix: Allow setting STUN to an empty string (#1502)
This allows users to entirely disable STUN.
2022-05-18 00:12:48 +10:00
Kyle Carberry 668a6712e6 fix: Use relative timestamp for workspaces page Storybook (#1505) 2022-05-17 07:58:18 -05:00
Kyle Carberry 55bd7aa747 fix: Run "make gen" to regenerate queries (#1504)
This is broken in our CI, and should be fixed!
I'll likely tackle in a future PR.
2022-05-16 23:47:31 -05:00
Kyle Carberry f75d29e38e fix: Remove grouping for workspace owner counts (#1503)
This caused templates to show max ownership of one developer!
2022-05-17 04:10:52 +00:00
Kyle Carberry a2ba69dd28 fix: Parse resources from Terraform Modules (#1501)
Fixes when Terraform modules are used to primariy provision
infrastructure!
2022-05-16 20:56:50 -05:00
Kyle Carberry 9b1ef29694 fix: Allow fetching of non-personal workspaces (#1495)
RBAC should cover this anyways!
2022-05-16 22:47:31 +00:00
Ben Potter 1ed69b95fc example(k8s): clarify kubeconfig location (#1494) 2022-05-16 22:29:15 +00:00
6433 changed files with 356768 additions and 73449 deletions
+83
View File
@@ -0,0 +1,83 @@
FROM ubuntu
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV EDITOR=vim
RUN apt-get update && apt-get upgrade --yes
RUN apt-get install --yes \
ca-certificates \
bash-completion \
build-essential \
curl \
cmake \
direnv \
emacs-nox \
gnupg \
htop \
jq \
less \
lsb-release \
lsof \
man-db \
nano \
neovim \
ssl-cert \
sudo \
unzip \
xz-utils \
zip
# configure locales to UTF8
RUN apt-get install locales && locale-gen en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
# configure direnv
RUN direnv hook bash >> $HOME/.bashrc
# install nix
RUN sh <(curl -L https://nixos.org/nix/install) --daemon
RUN mkdir -p $HOME/.config/nix $HOME/.config/nixpkgs \
&& echo 'sandbox = false' >> $HOME/.config/nix/nix.conf \
&& echo '{ allowUnfree = true; }' >> $HOME/.config/nixpkgs/config.nix \
&& echo '. $HOME/.nix-profile/etc/profile.d/nix.sh' >> $HOME/.bashrc
# install docker and configure daemon to use vfs as GitHub codespaces requires vfs
# https://github.com/moby/moby/issues/13742#issuecomment-725197223
RUN mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
&& echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null \
&& apt-get update \
&& apt-get install --yes docker-ce docker-ce-cli containerd.io docker-compose-plugin \
&& mkdir -p /etc/docker \
&& echo '{"cgroup-parent":"/actions_job","storage-driver":"vfs"}' >> /etc/docker/daemon.json
# install golang and language tooling
ENV GO_VERSION=1.20
ENV GOPATH=$HOME/go-packages
ENV GOROOT=$HOME/go
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH
RUN curl -fsSL https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz | tar xzs
RUN echo 'export PATH=$GOPATH/bin:$PATH' >> $HOME/.bashrc
RUN bash -c ". $HOME/.bashrc \
go install -v golang.org/x/tools/gopls@latest \
&& go install -v mvdan.cc/sh/v3/cmd/shfmt@latest \
&& go install -v github.com/mikefarah/yq/v4@v4.30.6 \
"
# install nodejs
RUN bash -c "$(curl -fsSL https://deb.nodesource.com/setup_14.x)" \
&& apt-get install -y nodejs
# install zstd
RUN bash -c "$(curl -fsSL https://raw.githubusercontent.com/horta/zstd.install/main/install)"
# install nfpm
RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list \
&& apt update \
&& apt install nfpm
+24
View File
@@ -0,0 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json
{
"name": "Development environments on your infrastructure",
// Sets the run context to one level up instead of the .devcontainer folder.
"context": ".",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "Dockerfile",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
"postStartCommand": "dockerd",
// privileged is required by GitHub codespaces - https://github.com/microsoft/vscode-dev-containers/issues/727
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--privileged",
"--init"
]
}
+16
View File
@@ -0,0 +1,16 @@
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
[*.{md,json,yaml,yml,tf,tfvars,nix}]
indent_style = space
indent_size = 2
[coderd/database/dump.sql]
indent_style = space
indent_size = 4
+6
View File
@@ -1,5 +1,11 @@
# Generated files
coderd/apidoc/docs.go linguist-generated=true
coderd/apidoc/swagger.json linguist-generated=true
coderd/database/dump.sql linguist-generated=true
peerbroker/proto/*.go linguist-generated=true
provisionerd/proto/*.go linguist-generated=true
provisionersdk/proto/*.go linguist-generated=true
*.tfplan.json linguist-generated=true
*.tfstate.json linguist-generated=true
*.tfstate.dot linguist-generated=true
*.tfplan.dot linguist-generated=true
-2
View File
@@ -1,2 +0,0 @@
site/ @coder/frontend
site/src/xServices @presleyp
-37
View File
@@ -1,37 +0,0 @@
---
name: Bug report
about: Report a bug
title: "Bug: "
labels: ["bug :bug:", "needs grooming :razor:"]
---
## OS Information
- OS:
- Browser (if applicable):
- Architecture:
- `coder --version`:
## Steps to Reproduce
<!-- 1. -->
<!-- 2. -->
<!-- 3. -->
## Expected
<!-- What should happen? -->
## Actual
<!-- What actually happens? -->
## Logs
## Screenshot
<!-- Ideally provide a screenshot, gif, video or screen recording. -->
## Notes
<!-- Anything else you want to share -->
-5
View File
@@ -1,5 +0,0 @@
blank_issues_enabled: true
contact_links:
- name: Question?
url: https://github.com/coder/coder/discussions/new?category=q-a
about: Ask for help on our GitHub Discussions board
-12
View File
@@ -1,12 +0,0 @@
---
name: Documentation improvement
about: Suggest a documentation improvement
title: "Docs: "
labels: ["documentation :memo:", "needs grooming :razor:"]
---
## What is your suggestion?
## How will this improve the docs?
## Are you interested in submitting a PR for this?
-14
View File
@@ -1,14 +0,0 @@
---
name: Feature request
about: Suggest an idea to improve coder
title: "Feat: "
labels: ["new feature :sparkles:", "needs grooming :razor:"]
---
## What is your suggestion?
## Why do you want this feature?
## Are there any workarounds to get this functionality today?
## Are you interested in submitting a PR for this?
+68
View File
@@ -0,0 +1,68 @@
name: "Setup Go"
description: |
Sets up the Go environment for tests, builds, etc.
inputs:
version:
description: "The Go version to use."
default: "1.20.5"
runs:
using: "composite"
steps:
- name: Cache go toolchain
uses: buildjet/cache@v3
with:
path: |
${{ runner.tool_cache }}/go/${{ inputs.version }}
key: gotoolchain-${{ runner.os }}-${{ inputs.version }}
restore-keys: |
gotoolchain-${{ runner.os }}-
- uses: buildjet/setup-go@v4
with:
# We do our own caching for implementation clarity.
cache: false
go-version: ${{ inputs.version }}
- name: Get cache dirs
shell: bash
run: |
set -x
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
# We split up GOMODCACHE from GOCACHE because the latter must be invalidated
# on code change, but the former can be kept.
- name: Cache $GOMODCACHE
uses: buildjet/cache@v3
with:
path: |
${{ env.GOMODCACHE }}
key: gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-${{ github.job }}
restore-keys: |
gomodcache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-
gomodcache-${{ runner.os }}-
- name: Cache $GOCACHE
uses: buildjet/cache@v3
with:
path: |
${{ env.GOCACHE }}
# Job name must be included in the key for effective
# test cache reuse.
# The key format is intentionally different than GOMODCACHE, because any
# time a Go file changes we invalidate this cache, whereas GOMODCACHE
# is only invalidated when go.sum changes.
key: gocache-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }}
restore-keys: |
gocache-${{ runner.os }}-${{ github.job }}-
gocache-${{ runner.os }}-
- name: Install gotestsum
shell: bash
run: go install gotest.tools/gotestsum@latest
# It isn't necessary that we ever do this, but it helps
# separate the "setup" from the "run" times.
- name: go mod download
shell: bash
run: go mod download -x
+15
View File
@@ -0,0 +1,15 @@
name: "Setup Node"
description: |
Sets up the node environment for tests, builds, etc.
runs:
using: "composite"
steps:
- uses: buildjet/setup-node@v3
with:
node-version: 16.16.0
# See https://github.com/actions/setup-node#caching-global-packages-data
cache: "yarn"
cache-dependency-path: "site/yarn.lock"
- name: Install node_modules
shell: bash
run: ./scripts/yarn_install.sh
+11
View File
@@ -0,0 +1,11 @@
name: "Setup Terraform"
description: |
Sets up Terraform for tests, builds, etc.
runs:
using: "composite"
steps:
- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.5.2
terraform_wrapper: false
@@ -0,0 +1,27 @@
name: Upload tests to datadog
if: always()
inputs:
api-key:
description: "Datadog API key"
required: true
runs:
using: "composite"
steps:
- shell: bash
run: |
owner=${{ github.repository_owner }}
echo "owner: $owner"
if [[ $owner != "coder" ]]; then
echo "Not a pull request from the main repo, skipping..."
exit 0
fi
if [[ -z "${{ inputs.api-key }}" ]]; then
# This can happen for dependabot.
echo "No API key provided, skipping..."
exit 0
fi
npm install -g @datadog/datadog-ci@2.10.0
datadog-ci junit upload --service coder ./gotests.xml \
--tags os:${{runner.os}} --tags runner_name:${{runner.name}}
env:
DATADOG_API_KEY: ${{ inputs.api-key }}
+13 -4
View File
@@ -1,5 +1,7 @@
codecov:
require_ci_to_pass: false
notify:
after_n_builds: 5
comment: false
@@ -7,19 +9,22 @@ github_checks:
annotations: false
coverage:
range: 50..75
round: down
precision: 2
status:
patch:
default:
informational: yes
project:
default:
target: 70%
informational: yes
target: 65%
informational: true
ignore:
# This is generated code.
- coderd/database/models.go
- coderd/database/query.sql.go
- coderd/database/queries.sql.go
- coderd/database/databasefake
# These are generated or don't require tests.
- cmd
@@ -29,6 +34,10 @@ ignore:
- peerbroker/proto
- provisionerd/proto
- provisionersdk/proto
- scripts/datadog-cireport
- scripts
- site/.storybook
- rules.go
# Packages used for writing tests.
- cli/clitest
- coderd/coderdtest
- pty/ptytest
+57 -13
View File
@@ -6,6 +6,7 @@ updates:
interval: "weekly"
time: "06:00"
timezone: "America/Chicago"
labels: []
commit-message:
prefix: "chore"
ignore:
@@ -32,22 +33,44 @@ updates:
timezone: "America/Chicago"
commit-message:
prefix: "chore"
labels:
- "dependencies"
- "go"
labels: []
ignore:
# Ignore patch updates for all dependencies
- dependency-name: "*"
update-types:
- version-update:semver-patch
- package-ecosystem: "npm"
directory: "/site/"
# Update our Dockerfile.
- package-ecosystem: "docker"
directory: "/scripts/"
schedule:
interval: "weekly"
time: "06:00"
timezone: "America/Chicago"
commit-message:
prefix: "chore"
labels:
- "dependencies"
- "typescript/js"
labels: []
ignore:
# We need to coordinate terraform updates with the version hardcoded in
# our Go code.
- dependency-name: "terraform"
- package-ecosystem: "npm"
directory: "/site/"
schedule:
interval: "monthly"
time: "06:00"
timezone: "America/Chicago"
reviewers:
- "coder/ts"
commit-message:
prefix: "chore"
labels: []
ignore:
# Ignore patch updates for all dependencies
- dependency-name: "*"
update-types:
- version-update:semver-patch
# Ignore major updates to Node.js types, because they need to
# correspond to the Node.js engine version
- dependency-name: "@types/node"
@@ -55,16 +78,37 @@ updates:
- version-update:semver-major
- package-ecosystem: "terraform"
directory: "/examples"
directory: "/examples/templates"
schedule:
interval: "monthly"
time: "06:00"
timezone: "America/Chicago"
commit-message:
prefix: "chore"
labels: []
ignore:
# We likely want to update this ourselves.
- dependency-name: "coder/coder"
# Update dogfood.
- package-ecosystem: "docker"
directory: "/dogfood/"
schedule:
interval: "weekly"
time: "06:00"
timezone: "America/Chicago"
commit-message:
prefix: "chore"
labels:
- "dependencies"
- "terraform"
labels: []
- package-ecosystem: "terraform"
directory: "/dogfood/"
schedule:
interval: "weekly"
time: "06:00"
timezone: "America/Chicago"
commit-message:
prefix: "chore"
labels: []
ignore:
# We likely want to update this ourselves.
- dependency-name: "coder/coder"
-13
View File
@@ -1,13 +0,0 @@
<!-- Help reviewers by listing the subtasks in this PR
Here's an example:
This PR adds a new feature to the CLI.
## Subtasks
- [x] added a test for feature
Fixes #345
-->
-56
View File
@@ -1,56 +0,0 @@
###############################################################################
# This file configures "Semantic Pull Requests", which is documented here:
# https://github.com/zeke/semantic-pull-requests
#
# This action/spec implements the "Conventional Commits" RFC which is
# available here:
# https://www.notion.so/coderhq/Conventional-commits-1d51287f58b64026bb29393f277734ed
###############################################################################
# We have no valid scopes right now.
# A scope should be added when commits aren't aligning with associated change anymore.
scopes:
# We only check that the PR title is semantic. The PR title is automatically
# applied to the "Squash & Merge" flow as the suggested commit message, so this
# should suffice unless someone drastically alters the message in that flow.
titleOnly: true
# Types are the 'tag' types in a commit or PR title. For example, in
#
# chore: fix thing
#
# 'chore' is the type.
types:
# A build of any kind.
- build
# Any code task that operates outside of CI, docs, or the product. Examples
# include configurations, linters etc.
- chore
# Any work performed on CI.
- ci
- example
# Work that directly implements or supports the implementation of a feature.
- feat
# A fix for either a released or unrelesed bug.
- fix
# A fix for a released bug (regression fix) that is intended for patch-release
# purposes.
- hotfix
# A refactor changes code structure without any behavioral change.
- refactor
# A git revert for any style of commit.
- revert
# Adding tests of any kind. Should be separate from feature or fix
# implementations. For example, if a commit adds a fix + test, it's a fix
# commit. If a commit is simply bumping coverage, it's a test commit.
- test
-14
View File
@@ -1,14 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 14
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 5
# Only apply the stale logic to pulls, since we are using issues to manage work
only: pulls
# Label to apply when stale.
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no activity occurs in the next 5 days.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
-60
View File
@@ -1,60 +0,0 @@
# Note: Chromatic is a separate workflow for coder.yaml as suggested by the
# chromatic docs. Explicitly, Chromatic works best on 'push' instead of other
# event types (like pull request), keep in mind that it works build-over-build
# by storing snapshots.
#
# SEE: https://www.chromatic.com/docs/ci
name: chromatic
on:
push:
branches:
- main
tags:
- "*"
pull_request:
jobs:
deploy:
# REMARK: this is only used to build storybook and deploy it to Chromatic.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Required by Chromatic for build-over-build history, otherwise we
# only get 1 commit on shallow checkout.
fetch-depth: 0
- name: Install dependencies
run: cd site && yarn
# This step is not meant for mainline because any detected changes to
# storybook snapshots will require manual approval/review in order for
# 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'
uses: chromaui/action@v1
with:
buildScriptName: "storybook:build"
exitOnceUploaded: true
# Chromatic states its fine to make this token public. See:
# https://www.chromatic.com/docs/github-actions#forked-repositories
projectToken: 695c25b6cb65
workingDir: "./site"
# This is a separate step for mainline only that auto accepts and changes
# instead of holding CI up. Since we squash/merge, this is defensive to
# avoid the same changeset from requiring review once squashed into
# main. Chromatic is supposed to be able to detect that we use squash
# commits, but it's good to be defensive in case, otherwise CI remains
# infinitely "in progress" in mainline unless we re-review each build.
- name: Publish to Chromatic (mainline)
if: github.ref == 'refs/heads/main'
uses: chromaui/action@v1
with:
autoAcceptChanges: true
buildScriptName: "storybook:build"
projectToken: 695c25b6cb65
workingDir: "./site"
+576
View File
@@ -0,0 +1,576 @@
name: ci
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
permissions:
actions: none
checks: none
contents: read
deployments: none
issues: none
packages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none
# Cancel in-progress runs for pull requests when developers push
# additional changes
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
changes:
runs-on: ubuntu-latest
outputs:
docs-only: ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }}
go: ${{ steps.filter.outputs.go }}
ts: ${{ steps.filter.outputs.ts }}
k8s: ${{ steps.filter.outputs.k8s }}
ci: ${{ steps.filter.outputs.ci }}
steps:
- uses: actions/checkout@v3
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
all:
- "**"
docs:
- "docs/**"
- "README.md"
- "examples/templates/**"
- "examples/web-server/**"
- "examples/monitoring/**"
- "examples/lima/**"
go:
- "**.sql"
- "**.go"
- "**.golden"
- "go.mod"
- "go.sum"
# Other non-Go files that may affect Go code:
- "**.rego"
- "**.sh"
- "**.tpl"
- "**.gotmpl"
- "**.gotpl"
- "Makefile"
- "site/static/error.html"
# Main repo directories for completeness in case other files are
# touched:
- "agent/**"
- "cli/**"
- "cmd/**"
- "coderd/**"
- "enterprise/**"
- "examples/*"
- "provisioner/**"
- "provisionerd/**"
- "provisionersdk/**"
- "pty/**"
- "scaletest/**"
- "tailnet/**"
- "testutil/**"
ts:
- "site/**"
- "Makefile"
k8s:
- "helm/**"
- "scripts/Dockerfile"
- "scripts/Dockerfile.base"
- "scripts/helm.sh"
ci:
- ".github/actions/**"
- ".github/workflows/ci.yaml"
- id: debug
run: |
echo "${{ toJSON(steps.filter )}}"
lint:
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-go
- uses: ./.github/actions/setup-node
- name: Get golangci-lint cache dir
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2
dir=$(golangci-lint cache status | awk '/Dir/ { print $2 }')
echo "LINT_CACHE_DIR=$dir" >> $GITHUB_ENV
- name: golangci-lint cache
uses: buildjet/cache@v3
with:
path: |
${{ env.LINT_CACHE_DIR }}
key: golangci-lint-${{ runner.os }}-${{ hashFiles('**/*.go') }}
restore-keys: |
golangci-lint-${{ runner.os }}-
# Check for any typos
- name: Check for typos
uses: crate-ci/typos@v1.14.12
with:
config: .github/workflows/typos.toml
- name: Fix the typos
if: ${{ failure() }}
run: |
echo "::notice:: you can automatically fix typos from your CLI:
cargo install typos-cli
typos -c .github/workflows/typos.toml -w"
# Needed for helm chart linting
- name: Install helm
uses: azure/setup-helm@v3
with:
version: v3.9.2
- name: make lint
run: |
make --output-sync=line -j lint
gen:
timeout-minutes: 8
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
needs: changes
if: needs.changes.outputs.docs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node
- uses: ./.github/actions/setup-go
- name: Install sqlc
run: |
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc
- name: go install tools
run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30
go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/mikefarah/yq/v4@v4.30.6
go install github.com/golang/mock/mockgen@v1.6.0
- name: Install Protoc
run: |
# protoc must be in lockstep with our dogfood Dockerfile or the
# version in the comments will differ. This is also defined in
# security.yaml
set -x
cd dogfood
DOCKER_BUILDKIT=1 docker build . --target proto -t protoc
protoc_path=/usr/local/bin/protoc
docker run --rm --entrypoint cat protoc /tmp/bin/protoc > $protoc_path
chmod +x $protoc_path
protoc --version
- name: make gen
run: "make --output-sync -j -B gen"
- name: Check for unstaged files
run: ./scripts/check_unstaged.sh
fmt:
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: buildjet/setup-node@v3
with:
node-version: 16.16.0
- uses: buildjet/setup-go@v4
with:
# This doesn't need caching. It's super fast anyways!
cache: false
go-version: 1.20.5
- name: Install prettier
# We only need prettier for fmt, so do not install all dependencies.
# There is no way to install a single package with yarn, so we have to
# make a new package.json with only prettier listed as a dependency.
# Then running `yarn` will only install prettier.
run: |
cd site
mv package.json package.json.bak
jq '{dependencies: {prettier: .devDependencies.prettier}}' < package.json.bak > package.json
yarn --frozen-lockfile
mv package.json.bak package.json
- name: Install shfmt
run: go install mvdan.cc/sh/v3/cmd/shfmt@v3.5.0
- name: make fmt
run: |
export PATH=${PATH}:$(go env GOPATH)/bin
make --output-sync -j -B fmt
- name: Check for unstaged files
run: ./scripts/check_unstaged.sh
test-go:
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'buildjet-4vcpu-ubuntu-2204' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xl' || matrix.os == 'windows-2019' && github.repository_owner == 'coder' && 'windows-latest-8-cores' || matrix.os }}
needs: changes
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
timeout-minutes: 20
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-2019
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-go
- uses: ./.github/actions/setup-tf
- name: Test with Mock Database
id: test
shell: bash
run: |
# Code coverage is more computationally expensive and also
# prevents test caching, so we disable it on alternate operating
# systems.
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
echo "cover=true" >> $GITHUB_OUTPUT
export COVERAGE_FLAGS='-covermode=atomic -coverprofile="gotests.coverage" -coverpkg=./...'
else
echo "cover=false" >> $GITHUB_OUTPUT
fi
# By default Go will use the number of logical CPUs, which
# is a fine default.
PARALLEL_FLAG=""
export TS_DEBUG_DISCO=true
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \
--packages="./..." -- $PARALLEL_FLAG -short -failfast $COVERAGE_FLAGS
- name: Print test stats
if: success() || failure()
run: |
# Artifacts are not available after rerunning a job,
# so we need to print the test stats to the log.
go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json
- uses: ./.github/actions/upload-datadog
if: success() || failure()
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
- uses: codecov/codecov-action@v3
# This action has a tendency to error out unexpectedly, it has
# the `fail_ci_if_error` option that defaults to `false`, but
# that is no guarantee, see:
# https://github.com/codecov/codecov-action/issues/788
continue-on-error: true
if: steps.test.outputs.cover && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./gotests.coverage
flags: unittest-go-${{ matrix.os }}
test-go-pg:
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
needs: changes
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
# 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
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-go
- uses: ./.github/actions/setup-tf
- name: Test with PostgreSQL Database
run: |
export TS_DEBUG_DISCO=true
make test-postgres
- name: Print test stats
if: success() || failure()
run: |
# Artifacts are not available after rerunning a job,
# so we need to print the test stats to the log.
go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json
- uses: ./.github/actions/upload-datadog
if: success() || failure()
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
- uses: codecov/codecov-action@v3
# This action has a tendency to error out unexpectedly, it has
# the `fail_ci_if_error` option that defaults to `false`, but
# that is no guarantee, see:
# https://github.com/codecov/codecov-action/issues/788
continue-on-error: true
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./gotests.coverage
flags: unittest-go-postgres-linux
test-go-race:
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
needs: changes
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
timeout-minutes: 25
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-go
- uses: ./.github/actions/setup-tf
- name: Run Tests
run: |
gotestsum --junitfile="gotests.xml" -- -race ./...
- uses: ./.github/actions/upload-datadog
if: always()
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
deploy:
name: "deploy"
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
timeout-minutes: 30
needs: changes
if: |
github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
&& needs.changes.outputs.docs-only == 'false'
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
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@v1
- uses: ./.github/actions/setup-go
- uses: ./.github/actions/setup-node
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
- name: Install zstd
run: sudo apt-get install -y zstd
- name: Build Release
run: |
set -euo pipefail
go mod download
version="$(./scripts/version.sh)"
make gen/mark-fresh
make -j \
build/coder_"$version"_windows_amd64.zip \
build/coder_"$version"_linux_amd64.{tar.gz,deb}
- name: Install Release
run: |
set -euo pipefail
regions=(
# gcp-region-id instance-name systemd-service-name
"us-central1-a coder coder"
"australia-southeast1-b coder-sydney coder-workspace-proxy"
"europe-west3-c coder-europe coder-workspace-proxy"
"southamerica-east1-b coder-brazil coder-workspace-proxy"
)
deb_pkg="./build/coder_$(./scripts/version.sh)_linux_amd64.deb"
if [ ! -f "$deb_pkg" ]; then
echo "deb package not found: $deb_pkg"
ls -l ./build
exit 1
fi
gcloud config set project coder-dogfood
for region in "${regions[@]}"; do
echo "::group::$region"
set -- $region
set -x
gcloud config set compute/zone "$1"
gcloud compute scp "$deb_pkg" "${2}:/tmp/coder.deb"
gcloud compute ssh "$2" -- /bin/sh -c "set -eux; sudo dpkg -i --force-confdef /tmp/coder.deb; sudo systemctl daemon-reload; sudo service '$3' restart"
set +x
echo "::endgroup::"
done
- uses: actions/upload-artifact@v3
with:
name: coder
path: |
./build/*.zip
./build/*.tar.gz
./build/*.deb
retention-days: 7
test-js:
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
needs: changes
if: needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node
- run: yarn test:ci --max-workers $(nproc)
working-directory: site
- uses: codecov/codecov-action@v3
# This action has a tendency to error out unexpectedly, it has
# the `fail_ci_if_error` option that defaults to `false`, but
# that is no guarantee, see:
# https://github.com/codecov/codecov-action/issues/788
continue-on-error: true
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./site/coverage/lcov.info
flags: unittest-js
test-e2e:
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
needs: changes
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node
- uses: ./.github/actions/setup-go
- uses: ./.github/actions/setup-tf
- name: Build
run: |
sudo npm install -g prettier
make -B site/out/index.html
- run: yarn playwright:install
working-directory: site
- run: yarn playwright:test
env:
DEBUG: pw:api
working-directory: site
- name: Upload Playwright Failed Tests
if: always() && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && !github.event.pull_request.head.repo.fork
uses: actions/upload-artifact@v3
with:
name: failed-test-videos
path: ./site/test-results/**/*.webm
retention-days: 7
chromatic:
# REMARK: this is only used to build storybook and deploy it to Chromatic.
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
with:
# Required by Chromatic for build-over-build history, otherwise we
# only get 1 commit on shallow checkout.
fetch-depth: 0
- uses: ./.github/actions/setup-node
# This step is not meant for mainline because any detected changes to
# storybook snapshots will require manual approval/review in order for
# 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@v1
env:
NODE_OPTIONS: "--max_old_space_size=4096"
STORYBOOK: true
with:
buildScriptName: "storybook:build"
exitOnceUploaded: true
# Chromatic states its fine to make this token public. See:
# https://www.chromatic.com/docs/github-actions#forked-repositories
projectToken: 695c25b6cb65
workingDir: "./site"
# This is a separate step for mainline only that auto accepts and changes
# instead of holding CI up. Since we squash/merge, this is defensive to
# avoid the same changeset from requiring review once squashed into
# main. Chromatic is supposed to be able to detect that we use squash
# commits, but it's good to be defensive in case, otherwise CI remains
# 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@v1
env:
NODE_OPTIONS: "--max_old_space_size=4096"
STORYBOOK: true
with:
autoAcceptChanges: true
buildScriptName: "storybook:build"
projectToken: 695c25b6cb65
workingDir: "./site"
required:
runs-on: ubuntu-latest
needs: [fmt, lint, gen, test-go, test-go-pg, test-go-race, test-js]
# Allow this job to run even if the needed jobs fail, are skipped or
# cancelled.
if: always()
steps:
- name: Ensure required checks
run: |
echo "Checking required checks"
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-js: ${{ needs.test-js.result }}"
echo
# We allow skipped jobs to pass, but not failed or cancelled jobs.
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "One of the required checks has failed or has been cancelled"
exit 1
fi
echo "Required checks have passed"
-510
View File
@@ -1,510 +0,0 @@
name: coder
on:
push:
branches:
- main
tags:
- "*"
pull_request:
workflow_dispatch:
permissions:
actions: none
checks: none
contents: read
deployments: none
issues: none
packages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none
# Cancel in-progress runs for pull requests when developers push
# additional changes
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
style-lint-golangci:
name: style/lint/golangci
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.2.0
with:
version: v1.46.0
style-lint-typescript:
name: "style/lint/typescript"
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache Node
id: cache-node
uses: actions/cache@v3
with:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
- name: Install node_modules
run: ./scripts/yarn_install.sh
- name: "yarn lint"
run: yarn lint
working-directory: site
gen:
name: "style/gen"
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache Node
id: cache-node
uses: actions/cache@v3
with:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
- name: Install node_modules
run: ./scripts/yarn_install.sh
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: "3.20.0"
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
- run: curl -sSL
https://github.com/kyleconroy/sqlc/releases/download/v1.13.0/sqlc_1.13.0_linux_amd64.tar.gz
| sudo tar -C /usr/bin -xz sqlc
- run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
- run: go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.26
- run: go install golang.org/x/tools/cmd/goimports@latest
- run: "make --output-sync -j gen"
- run: ./scripts/check_unstaged.sh
style-fmt:
name: "style/fmt"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Cache Node
id: cache-node
uses: actions/cache@v3
with:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
- name: Install node_modules
run: ./scripts/yarn_install.sh
- name: "make fmt"
run: "make --output-sync -j fmt"
test-go:
name: "test/go"
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-2022
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
- name: Echo Go Cache Paths
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Install goreleaser
uses: jaxxstorm/action-install-gh-release@v1.6.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repo: gotestyourself/gotestsum
tag: v1.7.0
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.2
terraform_wrapper: false
- name: Test with Mock Database
shell: bash
env:
GOCOUNT: ${{ runner.os == 'Windows' && 1 || 2 }}
GOMAXPROCS: ${{ runner.os == 'Windows' && 1 || 2 }}
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage"
-coverpkg=./...,github.com/coder/coder/codersdk
-timeout=3m -count=$GOCOUNT -short -failfast
- name: Upload DataDog Trace
if: always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: fake
DD_CATEGORY: unit
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go gotests.xml
- uses: codecov/codecov-action@v3
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./gotests.coverage
flags: unittest-go-${{ matrix.os }}
fail_ci_if_error: true
test-go-postgres:
name: "test/go/postgres"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
- name: Echo Go Cache Paths
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Install goreleaser
uses: jaxxstorm/action-install-gh-release@v1.6.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repo: gotestyourself/gotestsum
tag: v1.7.0
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.2
terraform_wrapper: false
- name: Start PostgreSQL Database
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
PGDATA: /tmp
run: |
docker run \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_DB=postgres \
-e PGDATA=/tmp \
-p 5432:5432 \
-d postgres:11 \
-c shared_buffers=1GB \
-c max_connections=1000
while ! pg_isready -h 127.0.0.1
do
echo "$(date) - waiting for database to start"
sleep 0.5
done
- name: Test with PostgreSQL Database
run: DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
-coverpkg=./...,github.com/coder/coder/codersdk
-count=1 -parallel=2 -race -failfast
- name: Upload DataDog Trace
if: always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: postgresql
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go gotests.xml
- uses: codecov/codecov-action@v3
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./gotests.coverage
flags: unittest-go-postgres-${{ matrix.os }}
fail_ci_if_error: true
deploy:
name: "deploy"
runs-on: ubuntu-latest
timeout-minutes: 20
if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v0
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@v0
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
- name: Echo Go Cache Paths
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-release-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
- uses: goreleaser/goreleaser-action@v2
with:
install-only: true
- name: Cache Node
id: cache-node
uses: actions/cache@v3
with:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
- name: Build site
run: make site/out/index.html
- name: Build Release
uses: goreleaser/goreleaser-action@v2.9.1
with:
version: latest
args: release --snapshot --rm-dist --skip-sign
- uses: actions/upload-artifact@v3
with:
name: coder_linux_amd64.deb
path: ./dist/coder_*_linux_amd64.deb
- name: Install Release
run: |
gcloud config set project coder-dogfood
gcloud config set compute/zone us-central1-a
gcloud compute scp ./dist/coder_*_linux_amd64.deb coder:/tmp/coder.deb
gcloud compute ssh coder -- sudo dpkg -i --force-confdef /tmp/coder.deb
gcloud compute ssh coder -- sudo systemctl daemon-reload
- name: Start
run: gcloud compute ssh coder -- sudo service coder restart
test-js:
name: "test/js"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- name: Cache Node
id: cache-node
uses: actions/cache@v3
with:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
# Go is required for uploading the test results to datadog
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
- uses: actions/setup-node@v3
with:
node-version: "14"
- name: Install node_modules
run: ./scripts/yarn_install.sh
- run: yarn test:coverage
working-directory: site
- uses: codecov/codecov-action@v3
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./site/coverage/lcov.info
flags: unittest-js
fail_ci_if_error: true
- name: Upload DataDog Trace
if: always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_CATEGORY: unit
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go site/test-results/junit.xml
test-e2e:
name: "test/e2e/${{ matrix.os }}"
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
matrix:
os:
- ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache Node
id: cache-node
uses: actions/cache@v3
with:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
# Go is required for uploading the test results to datadog
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.2
terraform_wrapper: false
- uses: actions/setup-node@v3
with:
node-version: "14"
- uses: goreleaser/goreleaser-action@v2
with:
install-only: true
- name: Echo Go Cache Paths
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Build
run: |
make site/out/index.html
- run: yarn playwright:install
working-directory: site
- run: yarn playwright:install-deps
working-directory: site
- run: yarn playwright:test
env:
DEBUG: pw:api
working-directory: site
- name: Upload DataDog Trace
if: always() && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && !github.event.pull_request.head.repo.fork
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_CATEGORY: e2e
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go site/test-results/junit.xml
+156
View File
@@ -0,0 +1,156 @@
name: contrib
on:
issue_comment:
types: [created]
pull_request_target:
types:
- opened
- closed
- synchronize
- labeled
- unlabeled
- opened
- reopened
- edited
# Only run one instance per PR to ensure in-order execution.
concurrency: pr-${{ github.ref }}
jobs:
# Dependabot is annoying, but this makes it a bit less so.
auto-approve-dependabot:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target'
permissions:
pull-requests: write
steps:
- uses: hmarr/auto-approve-action@v3
if: github.actor == 'dependabot[bot]'
cla:
runs-on: ubuntu-latest
steps:
- name: cla
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
uses: contributor-assistant/github-action@v2.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
PERSONAL_ACCESS_TOKEN: ${{ secrets.CDRCOMMUNITY_GITHUB_TOKEN }}
with:
remote-organization-name: "coder"
remote-repository-name: "cla"
path-to-signatures: "v2022-09-04/signatures.json"
path-to-document: "https://github.com/coder/cla/blob/main/README.md"
# branch should not be protected
branch: "main"
allowlist: dependabot*
release-labels:
runs-on: ubuntu-latest
# Skip tagging for draft PRs.
if: ${{ github.event_name == 'pull_request_target' && success() && !github.event.pull_request.draft }}
steps:
- uses: actions/github-script@v6
with:
# This script ensures PR title and labels are in sync:
#
# When release/breaking label is:
# - Added, rename PR title to include ! (e.g. feat!:)
# - Removed, rename PR title to strip ! (e.g. feat:)
#
# When title is:
# - Renamed (+!), add the release/breaking label
# - Renamed (-!), remove the release/breaking label
script: |
const releaseLabels = {
breaking: "release/breaking",
}
const { action, changes, label, pull_request } = context.payload
const { title } = pull_request
const labels = pull_request.labels.map((label) => label.name)
const isBreakingTitle = isBreaking(title)
// Debug information.
console.log("Action: %s", action)
console.log("Title: %s", title)
console.log("Labels: %s", labels.join(", "))
const params = {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
}
if (action === "opened" || action === "reopened") {
if (isBreakingTitle && !labels.includes(releaseLabels.breaking)) {
console.log('Add "%s" label', releaseLabels.breaking)
await github.rest.issues.addLabels({
...params,
labels: [releaseLabels.breaking],
})
}
}
if (action === "edited" && changes.title) {
if (isBreakingTitle && !labels.includes(releaseLabels.breaking)) {
console.log('Add "%s" label', releaseLabels.breaking)
await github.rest.issues.addLabels({
...params,
labels: [releaseLabels.breaking],
})
}
if (!isBreakingTitle && labels.includes(releaseLabels.breaking)) {
const wasBreakingTitle = isBreaking(changes.title.from)
if (wasBreakingTitle) {
console.log('Remove "%s" label', releaseLabels.breaking)
await github.rest.issues.removeLabel({
...params,
name: releaseLabels.breaking,
})
} else {
console.log('Rename title from "%s" to "%s"', title, toBreaking(title))
await github.rest.issues.update({
...params,
title: toBreaking(title),
})
}
}
}
if (action === "labeled") {
if (label.name === releaseLabels.breaking && !isBreakingTitle) {
console.log('Rename title from "%s" to "%s"', title, toBreaking(title))
await github.rest.issues.update({
...params,
title: toBreaking(title),
})
}
}
if (action === "unlabeled") {
if (label.name === releaseLabels.breaking && isBreakingTitle) {
console.log('Rename title from "%s" to "%s"', title, fromBreaking(title))
await github.rest.issues.update({
...params,
title: fromBreaking(title),
})
}
}
function isBreaking(t) {
return t.split(" ")[0].endsWith("!:")
}
function toBreaking(t) {
const parts = t.split(" ")
return [parts[0].replace(/:$/, "!:"), ...parts.slice(1)].join(" ")
}
function fromBreaking(t) {
const parts = t.split(" ")
return [parts[0].replace(/!:$/, ":"), ...parts.slice(1)].join(" ")
}
+90
View File
@@ -0,0 +1,90 @@
name: docker-base
on:
push:
branches:
- main
paths:
- scripts/Dockerfile.base
- scripts/Dockerfile
schedule:
# Run every week at 09:43 on Monday, Wednesday and Friday. We build this
# frequently to ensure that packages are up-to-date.
- cron: "43 9 * * 1,3,5"
workflow_dispatch:
permissions:
contents: read
# Necessary to push docker images to ghcr.io.
packages: write
# Necessary for depot.dev authentication.
id-token: write
# Avoid running multiple jobs for the same commit.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-docker-base
jobs:
build:
runs-on: ubuntu-latest
if: github.repository_owner == 'coder'
steps:
- uses: actions/checkout@v3
- name: Docker login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create empty base-build-context directory
run: mkdir base-build-context
- name: Install depot.dev CLI
uses: depot/setup-action@v1
# This uses OIDC authentication, so no auth variables are required.
- name: Build base Docker image via depot.dev
uses: depot/build-push-action@v1
with:
project: wl5hnrrkns
context: base-build-context
file: scripts/Dockerfile.base
platforms: linux/amd64,linux/arm64,linux/arm/v7
pull: true
no-cache: true
push: true
tags: |
ghcr.io/coder/coder-base:latest
- name: Verify that images are pushed properly
run: |
# retry 10 times with a 5 second delay as the images may not be
# available immediately
for i in {1..10}; do
rc=0
raw_manifests=$(docker buildx imagetools inspect --raw ghcr.io/coder/coder-base:latest) || rc=$?
if [[ "$rc" -eq 0 ]]; then
break
fi
if [[ "$i" -eq 10 ]]; then
echo "Failed to pull manifests after 10 retries"
exit 1
fi
echo "Failed to pull manifests, retrying in 5 seconds"
sleep 5
done
manifests=$(
echo "$raw_manifests" | \
jq -r '.manifests[].platform | .os + "/" + .architecture + (if .variant then "/" + .variant else "" end)'
)
# Verify all 3 platforms are present.
set -euxo pipefail
echo "$manifests" | grep -q linux/amd64
echo "$manifests" | grep -q linux/arm64
echo "$manifests" | grep -q linux/arm/v7
+76
View File
@@ -0,0 +1,76 @@
name: dogfood
on:
push:
branches:
- main
paths:
- "dogfood/**"
- ".github/workflows/dogfood.yaml"
# Uncomment these lines when testing with CI.
# pull_request:
# paths:
# - "dogfood/**"
# - ".github/workflows/dogfood.yaml"
workflow_dispatch:
jobs:
deploy_image:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6.5
- name: "Branch name to Docker tag name"
id: docker-tag-name
run: |
tag=${{ steps.branch-name.outputs.current_branch }}
# Replace / with --, e.g. user/feature => user--feature.
tag=${tag//\//--}
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: "{{defaultContext}}:dogfood"
push: true
tags: "codercom/oss-dogfood:${{ steps.docker-tag-name.outputs.tag }},codercom/oss-dogfood:latest"
cache-from: type=registry,ref=codercom/oss-dogfood:latest
cache-to: type=inline
deploy_template:
needs: deploy_image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get short commit SHA
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: "Get latest Coder binary from the server"
run: |
curl -fsSL "https://dev.coder.com/bin/coder-linux-amd64" -o "./coder"
chmod +x "./coder"
- name: "Push template"
run: |
./coder templates push $CODER_TEMPLATE_NAME --directory $CODER_TEMPLATE_DIR --yes --name=$CODER_TEMPLATE_VERSION
env:
# Consumed by Coder CLI
CODER_URL: https://dev.coder.com
CODER_SESSION_TOKEN: ${{ secrets.CODER_SESSION_TOKEN }}
# Template source & details
CODER_TEMPLATE_NAME: ${{ secrets.CODER_TEMPLATE_NAME }}
CODER_TEMPLATE_VERSION: ${{ steps.vars.outputs.sha_short }}
CODER_TEMPLATE_DIR: ./dogfood
+23
View File
@@ -0,0 +1,23 @@
{
"ignorePatterns": [
{
"pattern": "://localhost"
},
{
"pattern": "://.*.?example\\.com"
},
{
"pattern": "developer.github.com"
},
{
"pattern": "docs.github.com"
},
{
"pattern": "support.google.com"
},
{
"pattern": "tailscale.com"
}
],
"aliveStatusCodes": [200, 0]
}
+51
View File
@@ -0,0 +1,51 @@
# 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 midnight
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
go-race:
# While GitHub's toaster runners are likelier to flake, we want consistency
# between this environment and the regular test environment for DataDog
# statistics and to only show real workflow threats.
runs-on: "buildjet-8vcpu-ubuntu-2204"
# This runner costs 0.016 USD per minute,
# so 0.016 * 240 = 3.84 USD per run.
timeout-minutes: 240
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-go
- uses: ./.github/actions/setup-tf
- name: Run Tests
run: |
# -race is likeliest to catch flaky tests
# due to correctness detection and its performance
# impact.
gotestsum --junitfile="gotests.xml" -- -timeout=240m -count=10 -race ./...
- uses: ./.github/actions/upload-datadog
if: always()
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
go-timing:
# We run these tests with p=1 so we don't need a lot of compute.
runs-on: "buildjet-2vcpu-ubuntu-2204"
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-go
- name: Run Tests
run: |
gotestsum --junitfile="gotests.xml" -- --tags="timing" -p=1 -run='_Timing/' ./...
- uses: ./.github/actions/upload-datadog
if: always()
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
+16
View File
@@ -0,0 +1,16 @@
# Filtering pull requests is much easier when we can reliably guarantee
# that the "Assignee" field is populated.
name: PR Auto Assign
on:
pull_request_target:
types: [opened]
permissions:
pull-requests: write
jobs:
assign-author:
runs-on: ubuntu-latest
steps:
- uses: toshimaru/auto-author-assign@v1.6.2
+50
View File
@@ -0,0 +1,50 @@
name: Cleanup PR
on:
pull_request:
types: [closed]
workflow_dispatch:
inputs:
pr_number:
description: "PR number"
required: true
permissions:
packages: write
jobs:
cleanup:
runs-on: "ubuntu-latest"
steps:
- name: Get PR number
id: pr_number
run: |
if [ -n "${{ github.event.pull_request.number }}" ]; then
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
else
echo "PR_NUMBER=${{ github.event.inputs.pr_number }}" >> $GITHUB_OUTPUT
fi
- name: Delete image
continue-on-error: true
uses: bots-house/ghcr-delete-image-action@v1.1.0
with:
owner: coder
name: coder-preview
token: ${{ secrets.GITHUB_TOKEN }}
tag: pr${{ steps.pr_number.outputs.PR_NUMBER }}
- name: Set up kubeconfig
run: |
set -euxo pipefail
mkdir -p ~/.kube
echo "${{ secrets.DELIVERYBOT_KUBECONFIG }}" > ~/.kube/config
export KUBECONFIG=~/.kube/config
- name: Delete helm release
run: |
set -euxo pipefail
helm delete --namespace "pr${{ steps.pr_number.outputs.PR_NUMBER }}" "pr${{ steps.pr_number.outputs.PR_NUMBER }}" || echo "helm release not found"
- name: "Remove PR namespace"
run: |
kubectl delete namespace "pr${{ steps.pr_number.outputs.PR_NUMBER }}" || echo "namespace not found"
+207
View File
@@ -0,0 +1,207 @@
# This action will trigger when a PR is commentted containing /review-pr by a member of the org.
name: Deploy PR
on:
issue_comment:
workflow_dispatch:
inputs:
pr_number:
description: "PR number"
required: true
env:
REPO: ghcr.io/coder/coder-preview
permissions:
contents: read
packages: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pr_commented:
if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '/deploy-pr') && github.event.comment.author_association == 'MEMBER' || github.event_name == 'workflow_dispatch'
outputs:
PR_NUMBER: ${{ steps.pr_number.outputs.PR_NUMBER }}
PR_TITLE: ${{ steps.pr_number.outputs.PR_TITLE }}
PR_URL: ${{ steps.pr_number.outputs.PR_URL }}
COMMENT_ID: ${{ steps.comment_id.outputs.comment-id }}
CODER_BASE_IMAGE_TAG: ${{ steps.set_tags.outputs.CODER_BASE_IMAGE_TAG }}
CODER_IMAGE_TAG: ${{ steps.set_tags.outputs.CODER_IMAGE_TAG }}
runs-on: "ubuntu-latest"
steps:
- name: Get PR number and title
id: pr_number
run: |
set -euxo pipefail
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
PR_NUMBER=${{ github.event.inputs.pr_number }}
PR_TITLE=$(curl -sSL -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/coder/coder/pulls/$PR_NUMBER" | jq -r '.title')
else
PR_NUMBER=${{ github.event.issue.number }}
PR_TITLE='${{ github.event.issue.title }}'
fi
echo "PR_URL=https://github.com/coder/coder/pull/$PR_NUMBER" >> $GITHUB_OUTPUT
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_OUTPUT
- name: Set required tags
id: set_tags
run: |
set -euxo pipefail
echo "CODER_BASE_IMAGE_TAG=$CODER_BASE_IMAGE_TAG" >> $GITHUB_OUTPUT
echo "CODER_IMAGE_TAG=$CODER_IMAGE_TAG" >> $GITHUB_OUTPUT
env:
CODER_BASE_IMAGE_TAG: ghcr.io/coder/coder-preview-base:pr${{ steps.pr_number.outputs.PR_NUMBER }}
CODER_IMAGE_TAG: ghcr.io/coder/coder-preview:pr${{ steps.pr_number.outputs.PR_NUMBER }}
- name: Find Deploy Comment
if: github.event_name == 'issue_comment'
uses: peter-evans/find-comment@v2
id: fco
with:
issue-number: ${{ steps.pr_number.outputs.PR_NUMBER }}
comment-author: "github-actions[bot]"
body-includes: /deploy-pr
- name: React with Rocket
if: github.event_name == 'issue_comment'
id: comment_ido
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fco.outputs.comment-id }}
reactions: rocket
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ steps.pr_number.outputs.PR_NUMBER }}
comment-author: "github-actions[bot]"
body-includes: This deployment will be deleted when the PR is closed
- name: Comment on PR
id: comment_id
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ steps.pr_number.outputs.PR_NUMBER }}
edit-mode: replace
body: |
:rocket: Deploying PR ${{ steps.pr_number.outputs.PR_NUMBER }} ...
:warning: This deployment will be deleted when the PR is closed.
build:
needs: pr_commented
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
CODER_IMAGE_TAG: ${{ needs.pr_commented.outputs.coder_image_tag }}
PR_NUMBER: ${{ needs.pr_commented.outputs.pr_number }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/setup-go
- uses: ./.github/actions/setup-node
- name: Install sqlc
run: |
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc
- name: GHCR Login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Linux amd64 Docker image
run: |
set -euxo pipefail
go mod download
make gen/mark-fresh
export DOCKER_IMAGE_NO_PREREQUISITES=true
version="$(./scripts/version.sh)"
export CODER_IMAGE_BUILD_BASE_TAG="$(CODER_IMAGE_BASE=coder-base ./scripts/image_tag.sh --version "$version")"
make -j build/coder_linux_amd64
./scripts/build_docker.sh \
--arch amd64 \
--target ${{ env.CODER_IMAGE_TAG }} \
--version $version \
--push \
build/coder_linux_amd64
deploy:
needs: [build, pr_commented]
if: needs.build.result == 'success'
runs-on: "ubuntu-latest"
env:
CODER_IMAGE_TAG: ${{ needs.pr_commented.outputs.CODER_IMAGE_TAG }}
PR_NUMBER: ${{ needs.pr_commented.outputs.PR_NUMBER }}
PR_TITLE: ${{ needs.pr_commented.outputs.PR_TITLE }}
PR_URL: ${{ needs.pr_commented.outputs.PR_URL }}
steps:
- uses: actions/checkout@v3
- name: "Set up kubeconfig"
run: |
set -euxo pipefail
mkdir -p ~/.kube
echo "${{ secrets.DELIVERYBOT_KUBECONFIG }}" > ~/.kube/config
export KUBECONFIG=~/.kube/config
- name: "Create PR namespace"
run: |
set -euxo pipefail
# try to delete the namespace, but don't fail if it doesn't exist
kubectl delete namespace "pr${{ env.PR_NUMBER }}" || true
kubectl create namespace "pr${{ env.PR_NUMBER }}"
- name: "Install Helm chart"
run: |
helm upgrade --install pr${{ env.PR_NUMBER }} ./helm \
--namespace "pr${{ env.PR_NUMBER }}" \
--set coder.image.repo=${{ env.REPO }} \
--set coder.image.tag=pr${{ env.PR_NUMBER }} \
--set coder.service.type=ClusterIP \
--set coder.env[0].name=CODER_ACCESS_URL \
--set coder.env[0].value="" \
--force
- name: "Get deployment URL"
id: deployment_url
run: |
set -euo pipefail
kubectl rollout status deployment/coder --namespace "pr${{ env.PR_NUMBER }}"
POD_NAME=$(kubectl get pods -n "pr${{ env.PR_NUMBER }}" | awk 'NR==2{print $1}')
CODER_ACCESS_URL=$(kubectl logs $POD_NAME -n "pr${{ env.PR_NUMBER }}" | grep "Web UI:" | awk -F ':' '{print $2":"$3}' | awk '{$1=$1};1')
echo "::add-mask::$CODER_ACCESS_URL"
echo "CODER_ACCESS_URL=$CODER_ACCESS_URL" >> $GITHUB_OUTPUT
- name: Send Slack notification
run: |
curl -s -o /dev/null -X POST -H 'Content-type: application/json' \
-d '{
"pr_number": "'"${{ env.PR_NUMBER }}"'",
"pr_url": "'"${{ env.PR_URL }}"'",
"pr_title": "'"${{ env.PR_TITLE }}"'",
"pr_access_url": "'"${{ steps.deployment_url.outputs.CODER_ACCESS_URL }}"'" }' ${{ secrets.PR_DEPLOYMENTS_SLACK_WEBHOOK }}
echo "Slack notification sent"
- name: Comment on PR
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ env.PR_NUMBER }}
edit-mode: replace
comment-id: ${{ needs.pr_commented.outputs.COMMENT_ID }}
body: |
:heavy_check_mark: Deployed PR ${{ env.PR_NUMBER }} successfully.
:rocket: Access the deployment link [here](https://codercom.slack.com/archives/C05DNE982E8).
:warning: This deployment will be deleted when the PR is closed.
reactions: "+1"
+375 -52
View File
@@ -1,70 +1,104 @@
name: release
# GitHub release workflow.
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
dry_run:
description: Perform a dry-run release (devel). Note that ref must be an annotated tag when run without dry-run.
type: boolean
required: true
default: false
permissions:
# Required to publish a release
contents: write
# Necessary to push docker images to ghcr.io.
packages: write
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
id-token: write
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
# Use `inputs` (vs `github.event.inputs`) to ensure that booleans are actual
# booleans, not strings.
# https://github.blog/changelog/2022-06-10-github-actions-inputs-unified-across-manual-and-reusable-workflows/
CODER_RELEASE: ${{ !inputs.dry_run }}
CODER_DRY_RUN: ${{ inputs.dry_run }}
# For some reason, setup-go won't actually pick up a new patch version if
# it has an old one cached. We need to manually specify the versions so we
# can get the latest release. Never use "~1.xx" here!
CODER_GO_VERSION: "1.20.5"
jobs:
goreleaser:
runs-on: macos-latest
release:
name: Build and publish
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
env:
# Necessary for Docker manifest
DOCKER_CLI_EXPERIMENTAL: "enabled"
outputs:
version: ${{ steps.version.outputs.version }}
steps:
# Docker is not included on macos-latest
- uses: docker-practice/actions-setup-docker@1.0.10
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
# If the event that triggered the build was an annotated tag (which our
# tags are supposed to be), actions/checkout has a bug where the tag in
# question is only a lightweight tag and not a full annotated tag. This
# command seems to fix it.
# https://github.com/actions/checkout/issues/290
- name: Fetch git tags
run: git fetch --tags --force
- name: Print version
id: version
run: |
set -euo pipefail
version="$(./scripts/version.sh)"
echo "version=$version" >> $GITHUB_OUTPUT
# Speed up future version.sh calls.
echo "CODER_FORCE_VERSION=$version" >> $GITHUB_ENV
echo "$version"
- name: Create release notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# We always have to set this since there might be commits on
# main that didn't have a PR.
CODER_IGNORE_MISSING_COMMIT_METADATA: "1"
run: |
set -euo pipefail
ref=HEAD
old_version="$(git describe --abbrev=0 "$ref^1")"
version="$(./scripts/version.sh)"
# Generate notes.
release_notes_file="$(mktemp -t release_notes.XXXXXX)"
./scripts/release/generate_release_notes.sh --old-version "$old_version" --new-version "$version" --ref "$ref" >> "$release_notes_file"
echo CODER_RELEASE_NOTES_FILE="$release_notes_file" >> $GITHUB_ENV
- name: Show release notes
run: |
set -euo pipefail
cat "$CODER_RELEASE_NOTES_FILE"
- name: Docker Login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
- name: Install Gon
run: |
brew tap mitchellh/gon
brew install mitchellh/gon/gon
- name: Import Signing Certificates
uses: Apple-Actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.AC_CERTIFICATE_P12_BASE64 }}
p12-password: ${{ secrets.AC_CERTIFICATE_PASSWORD }}
- name: Echo Go Cache Paths
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-release-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
- uses: ./.github/actions/setup-go
- name: Cache Node
id: cache-node
uses: actions/cache@v3
uses: buildjet/cache@v3
with:
path: |
**/node_modules
@@ -73,18 +107,307 @@ jobs:
restore-keys: |
js-${{ runner.os }}-
- name: Install make
run: brew install make
- name: Install nsis and zstd
run: sudo apt-get install -y nsis zstd
- name: Build Site
run: make site/out/index.html
- name: Install nfpm
run: |
set -euo pipefail
wget -O /tmp/nfpm.deb https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.deb
sudo dpkg -i /tmp/nfpm.deb
rm /tmp/nfpm.deb
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2.9.1
- 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 and API key
run: |
set -euo pipefail
touch /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8}
chmod 600 /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8}
echo "$AC_CERTIFICATE_P12_BASE64" | base64 -d > /tmp/apple_cert.p12
echo "$AC_CERTIFICATE_PASSWORD" > /tmp/apple_cert_password.txt
echo "$AC_APIKEY_P8_BASE64" | base64 -d > /tmp/apple_apikey.p8
env:
AC_CERTIFICATE_P12_BASE64: ${{ secrets.AC_CERTIFICATE_P12_BASE64 }}
AC_CERTIFICATE_PASSWORD: ${{ secrets.AC_CERTIFICATE_PASSWORD }}
AC_APIKEY_P8_BASE64: ${{ secrets.AC_APIKEY_P8_BASE64 }}
- name: Build binaries
run: |
set -euo pipefail
go mod download
version="$(./scripts/version.sh)"
make gen/mark-fresh
make -j \
build/coder_"$version"_linux_{amd64,armv7,arm64}.{tar.gz,apk,deb,rpm} \
build/coder_"$version"_{darwin,windows}_{amd64,arm64}.zip \
build/coder_"$version"_windows_amd64_installer.exe \
build/coder_helm_"$version".tgz
env:
CODER_SIGN_DARWIN: "1"
AC_CERTIFICATE_FILE: /tmp/apple_cert.p12
AC_CERTIFICATE_PASSWORD_FILE: /tmp/apple_cert_password.txt
AC_APIKEY_ISSUER_ID: ${{ secrets.AC_APIKEY_ISSUER_ID }}
AC_APIKEY_ID: ${{ secrets.AC_APIKEY_ID }}
AC_APIKEY_FILE: /tmp/apple_apikey.p8
- name: Delete Apple Developer certificate and API key
run: rm -f /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8}
- name: Determine base image tag
id: image-base-tag
run: |
set -euo pipefail
if [[ "${CODER_RELEASE:-}" != *t* ]] || [[ "${CODER_DRY_RUN:-}" == *t* ]]; then
# Empty value means use the default and avoid building a fresh one.
echo "tag=" >> $GITHUB_OUTPUT
else
echo "tag=$(CODER_IMAGE_BASE=ghcr.io/coder/coder-base ./scripts/image_tag.sh)" >> $GITHUB_OUTPUT
fi
- name: Create empty base-build-context directory
if: steps.image-base-tag.outputs.tag != ''
run: mkdir base-build-context
- name: Install depot.dev CLI
if: steps.image-base-tag.outputs.tag != ''
uses: depot/setup-action@v1
# This uses OIDC authentication, so no auth variables are required.
- name: Build base Docker image via depot.dev
if: steps.image-base-tag.outputs.tag != ''
uses: depot/build-push-action@v1
with:
version: latest
args: release --rm-dist
project: wl5hnrrkns
context: base-build-context
file: scripts/Dockerfile.base
platforms: linux/amd64,linux/arm64,linux/arm/v7
pull: true
no-cache: true
push: true
tags: |
${{ steps.image-base-tag.outputs.tag }}
- name: Verify that images are pushed properly
run: |
# retry 10 times with a 5 second delay as the images may not be
# available immediately
for i in {1..10}; do
rc=0
raw_manifests=$(docker buildx imagetools inspect --raw "${{ steps.image-base-tag.outputs.tag }}") || rc=$?
if [[ "$rc" -eq 0 ]]; then
break
fi
if [[ "$i" -eq 10 ]]; then
echo "Failed to pull manifests after 10 retries"
exit 1
fi
echo "Failed to pull manifests, retrying in 5 seconds"
sleep 5
done
manifests=$(
echo "$raw_manifests" | \
jq -r '.manifests[].platform | .os + "/" + .architecture + (if .variant then "/" + .variant else "" end)'
)
# Verify all 3 platforms are present.
set -euxo pipefail
echo "$manifests" | grep -q linux/amd64
echo "$manifests" | grep -q linux/arm64
echo "$manifests" | grep -q linux/arm/v7
- name: Build Linux Docker images
run: |
set -euxo pipefail
# build Docker images for each architecture
version="$(./scripts/version.sh)"
make -j build/coder_"$version"_linux_{amd64,arm64,armv7}.tag
# we can't build multi-arch if the images aren't pushed, so quit now
# if dry-running
if [[ "$CODER_RELEASE" != *t* ]]; then
echo Skipping multi-arch docker builds due to dry-run.
exit 0
fi
# build and push multi-arch manifest, this depends on the other images
# being pushed so will automatically push them.
make -j push/build/coder_"$version"_linux.tag
# if the current version is equal to the highest (according to semver)
# version in the repo, also create a multi-arch image as ":latest" and
# push it
if [[ "$(git tag | grep '^v' | grep -vE '(rc|dev|-|\+|\/)' | sort -r --version-sort | head -n1)" == "v$(./scripts/version.sh)" ]]; then
./scripts/build_docker_multiarch.sh \
--push \
--target "$(./scripts/image_tag.sh --version latest)" \
$(cat build/coder_"$version"_linux_{amd64,arm64,armv7}.tag)
fi
env:
CODER_BASE_IMAGE_TAG: ${{ steps.image-base-tag.outputs.tag }}
- name: ls build
run: ls -lh build
- name: Publish release
run: |
set -euo pipefail
publish_args=()
if [[ $CODER_DRY_RUN == *t* ]]; then
publish_args+=(--dry-run)
fi
declare -p publish_args
./scripts/release/publish.sh \
"${publish_args[@]}" \
--release-notes-file "$CODER_RELEASE_NOTES_FILE" \
./build/*_installer.exe \
./build/*.zip \
./build/*.tar.gz \
./build/*.tgz \
./build/*.apk \
./build/*.deb \
./build/*.rpm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AC_USERNAME: ${{ secrets.AC_USERNAME }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
CODER_GPG_RELEASE_KEY_BASE64: ${{ secrets.GPG_RELEASE_KEY_BASE64 }}
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
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@v1"
- name: Publish Helm Chart
if: ${{ !inputs.dry_run }}
run: |
set -euo pipefail
version="$(./scripts/version.sh)"
mkdir -p build/helm
cp "build/coder_helm_${version}.tgz" build/helm
gsutil cp gs://helm.coder.com/v2/index.yaml build/helm/index.yaml
helm repo index build/helm --url https://helm.coder.com/v2 --merge build/helm/index.yaml
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/coder_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
- name: Upload artifacts to actions (if dry-run)
if: ${{ inputs.dry_run }}
uses: actions/upload-artifact@v3
with:
name: release-artifacts
path: |
./build/*_installer.exe
./build/*.zip
./build/*.tar.gz
./build/*.tgz
./build/*.apk
./build/*.deb
./build/*.rpm
retention-days: 7
- name: Start Packer builds
if: ${{ !inputs.dry_run }}
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.CDRCI_GITHUB_TOKEN }}
repository: coder/packages
event-type: coder-release
client-payload: '{"coder_version": "${{ steps.version.outputs.version }}"}'
publish-winget:
name: Publish to winget-pkgs
runs-on: windows-latest
needs: release
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# If the event that triggered the build was an annotated tag (which our
# tags are supposed to be), actions/checkout has a bug where the tag in
# question is only a lightweight tag and not a full annotated tag. This
# command seems to fix it.
# https://github.com/actions/checkout/issues/290
- name: Fetch git tags
run: git fetch --tags --force
- name: Install wingetcreate
run: |
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
- name: Submit updated manifest to winget-pkgs
run: |
# The package version is the same as the tag minus the leading "v".
# The version in this output already has the leading "v" removed but
# we do it again to be safe.
$version = "${{ needs.release.outputs.version }}".Trim('v')
$release_assets = gh release view --repo coder/coder "v${version}" --json assets | `
ConvertFrom-Json
# Get the installer URL from the release assets.
$installer_url = $release_assets.assets | `
Where-Object name -Match ".*_windows_amd64_installer.exe$" | `
Select -ExpandProperty url
echo "Installer URL: ${installer_url}"
echo "Package version: ${version}"
# Bail if dry-run.
if ($env:CODER_DRY_RUN -match "t") {
echo "Skipping submission due to dry-run."
exit 0
}
# The URL "|X64" suffix forces the architecture as it cannot be
# sniffed properly from the URL. wingetcreate checks both the URL and
# binary magic bytes for the architecture and they need to both match,
# but they only check for `x64`, `win64` and `_64` in the URL. Our URL
# contains `amd64` which doesn't match sadly.
#
# wingetcreate will still do the binary magic bytes check, so if we
# accidentally change the architecture of the installer, it will fail
# submission.
.\wingetcreate.exe update Coder.Coder `
--submit `
--version "${version}" `
--urls "${installer_url}|X64" `
--token "$env:WINGET_GH_TOKEN"
env:
# For gh CLI:
GH_TOKEN: ${{ github.token }}
# For wingetcreate. We need a real token since we're pushing a commit
# to GitHub and then making a PR in a different repo.
WINGET_GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
- name: Comment on PR
if: ${{ !inputs.dry_run }}
run: |
# Find the PR that wingetcreate just made.
$version = "${{ needs.release.outputs.version }}".Trim('v')
$pr_list = gh pr list --repo microsoft/winget-pkgs --search "author:cdrci Coder.Coder version ${version}" --limit 1 --json number | `
ConvertFrom-Json
$pr_number = $pr_list[0].number
gh pr comment --repo microsoft/winget-pkgs "${pr_number}" --body "🤖 cc: @deansheather @matifali"
env:
# For gh CLI. We need a real token since we're commenting on a PR in a
# different repo.
GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
+167
View File
@@ -0,0 +1,167 @@
name: "security"
permissions:
actions: read
contents: read
security-events: write
on:
workflow_dispatch:
schedule:
# Run every 6 hours Monday-Friday!
- cron: "0 0/6 * * 1-5"
# Cancel in-progress runs for pull requests when developers push
# additional changes
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-security
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CODER_GO_VERSION: "1.20.5"
jobs:
codeql:
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go, javascript
- uses: ./.github/actions/setup-go
# Workaround to prevent CodeQL from building the dashboard.
- name: Remove Makefile
run: |
rm Makefile
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Send Slack notification on failure
if: ${{ failure() }}
run: |
msg="❌ CodeQL Failed\n\nhttps://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
curl \
-qfsSL \
-X POST \
-H "Content-Type: application/json" \
--data "{\"content\": \"$msg\"}" \
"${{ secrets.SLACK_SECURITY_FAILURE_WEBHOOK_URL }}"
trivy:
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/setup-go
- name: Cache Node
id: cache-node
uses: buildjet/cache@v3
with:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
- name: Install sqlc
run: |
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc
- name: Install yq
run: go run github.com/mikefarah/yq/v4@v4.30.6
- name: Install mockgen
run: go install github.com/golang/mock/mockgen@v1.6.0
- name: Install protoc-gen-go
run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30
- name: Install protoc-gen-go-drpc
run: go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.33
- name: Install Protoc
run: |
# protoc must be in lockstep with our dogfood Dockerfile or the
# version in the comments will differ. This is also defined in
# ci.yaml.
set -x
cd dogfood
DOCKER_BUILDKIT=1 docker build . --target proto -t protoc
protoc_path=/usr/local/bin/protoc
docker run --rm --entrypoint cat protoc /tmp/bin/protoc > $protoc_path
chmod +x $protoc_path
protoc --version
- name: Build Coder linux amd64 Docker image
id: build
run: |
set -euo pipefail
version="$(./scripts/version.sh)"
image_job="build/coder_${version}_linux_amd64.tag"
# This environment variable force make to not build packages and
# archives (which the Docker image depends on due to technical reasons
# related to concurrent FS writes).
export DOCKER_IMAGE_NO_PREREQUISITES=true
# This environment variables forces scripts/build_docker.sh to build
# the base image tag locally instead of using the cached version from
# the registry.
export CODER_IMAGE_BUILD_BASE_TAG="$(CODER_IMAGE_BASE=coder-base ./scripts/image_tag.sh --version "$version")"
make -j "$image_job"
echo "image=$(cat "$image_job")" >> $GITHUB_OUTPUT
- name: Run Prisma Cloud image scan
uses: PaloAltoNetworks/prisma-cloud-scan@v1
with:
pcc_console_url: ${{ secrets.PRISMA_CLOUD_URL }}
pcc_user: ${{ secrets.PRISMA_CLOUD_ACCESS_KEY }}
pcc_pass: ${{ secrets.PRISMA_CLOUD_SECRET_KEY }}
image_name: ${{ steps.build.outputs.image }}
- name: Scan image
id: sysdig-scan
uses: sysdiglabs/scan-action@v3
with:
image-tag: ${{ steps.build.outputs.image }}
sysdig-secure-token: ${{ secrets.SYSDIG_API_TOKEN }}
input-type: docker-daemon
sysdig-secure-url: https://app.us4.sysdig.com
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@41f05d9ecffa2ed3f1580af306000f734b733e54
with:
image-ref: ${{ steps.build.outputs.image }}
format: sarif
output: trivy-results.sarif
severity: "CRITICAL,HIGH"
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: trivy-results.sarif
category: "Trivy"
- name: Upload Trivy scan results as an artifact
uses: actions/upload-artifact@v3
with:
name: trivy
path: trivy-results.sarif
retention-days: 7
- name: Send Slack notification on failure
if: ${{ failure() }}
run: |
msg="❌ Trivy Failed\n\nhttps://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
curl \
-qfsSL \
-X POST \
-H "Content-Type: application/json" \
--data "{\"content\": \"$msg\"}" \
"${{ secrets.SLACK_SECURITY_FAILURE_WEBHOOK_URL }}"
+66
View File
@@ -0,0 +1,66 @@
name: Stale Issue, Banch and Old Workflows Cleanup
on:
schedule:
# Every day at midnight
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
actions: write
steps:
- uses: actions/stale@v8.0.0
with:
stale-issue-label: "stale"
stale-pr-label: "stale"
days-before-stale: 90
# Pull Requests become stale more quickly due to merge conflicts.
# Also, we promote minimizing WIP.
days-before-pr-stale: 7
days-before-pr-close: 3
# We rarely take action in response to the message, so avoid
# cluttering the issue and just close the oldies.
stale-pr-message: ""
stale-issue-message: ""
# Upped from 30 since we have a big tracker and was hitting the limit.
operations-per-run: 60
# Start with the oldest issues, always.
ascending: true
branches:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run delete-old-branches-action
uses: beatlabs/delete-old-branches-action@v0.0.10
with:
repo_token: ${{ github.token }}
date: "6 months ago"
dry_run: false
delete_tags: false
# extra_protected_branch_regex: ^(foo|bar)$
exclude_open_pr_branches: true
del_runs:
runs-on: ubuntu-latest
steps:
- name: Delete PR Cleanup workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 1
keep_minimum_runs: 1
delete_workflow_pattern: pr-cleanup.yaml
- name: Delete PR Deploy workflow skipped runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 0
keep_minimum_runs: 0
delete_run_by_conclusion_pattern: skipped
delete_workflow_pattern: pr-deploy.yaml
+28
View File
@@ -0,0 +1,28 @@
[default.extend-identifiers]
alog = "alog"
Jetbrains = "JetBrains"
IST = "IST"
MacOS = "macOS"
AKS = "AKS"
[default.extend-words]
AKS = "AKS"
# do as sudo replacement
doas = "doas"
darcula = "darcula"
Hashi = "Hashi"
trialer = "trialer"
encrypter = "encrypter"
[files]
extend-exclude = [
"**.svg",
"**.png",
"**.lock",
"go.sum",
"go.mod",
# These files contain base64 strings that confuse the detector
"**XService**.ts",
"**identity.go",
"scripts/ci-report/testdata/**",
]
+32
View File
@@ -0,0 +1,32 @@
name: weekly-docs
# runs every monday at 9 am
on:
schedule:
- cron: "0 9 * * 1"
workflow_dispatch: # allows to run manually for testing
jobs:
check-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Check Markdown links
uses: gaurav-nelson/github-action-markdown-link-check@v1
id: markdown-link-check
# checks all markdown files from /docs including all subfolders
with:
use-quiet-mode: "yes"
use-verbose-mode: "yes"
config-file: ".github/workflows/mlc_config.json"
folder-path: "docs/"
file-path: "./README.md"
- name: Send Slack notification
if: failure()
run: |
curl -X POST -H 'Content-type: application/json' -d '{"msg":"Broken links found in the documentation. Please check the logs at ${{ env.LOGS_URL }}"}' ${{ secrets.DOCS_LINK_SLACK_WEBHOOK }}
echo "Sent Slack notification"
env:
LOGS_URL: https://github.com/coder/coder/actions/runs/${{ github.run_id }}
+48 -25
View File
@@ -1,40 +1,63 @@
###############################################################################
# NOTICE #
# If you change this file, kindly copy-pasta your change into .prettierignore #
# and .eslintignore as well. See the following discussions to understand why #
# we have to resort to this duplication (at least for now): #
# #
# https://github.com/prettier/prettier/issues/8048 #
# https://github.com/prettier/prettier/issues/8506 #
# https://github.com/prettier/prettier/issues/8679 #
###############################################################################
node_modules
vendor
# Common ignore patterns, these rules applies in both root and subdirectories.
.DS_Store
.eslintcache
yarn-error.log
.gitpod.yml
.idea
**/*.swp
gotests.coverage
gotests.xml
gotests_stats.json
gotests.json
node_modules/
vendor/
yarn-error.log
# Front-end ignore
# VSCode settings.
**/.vscode/*
# Allow VSCode recommendations and default settings in project root.
!/.vscode/extensions.json
!/.vscode/settings.json
# Front-end ignore patterns.
.next/
site/.eslintcache
site/.next/
site/node_modules/
site/storybook-static/
site/test-results/
site/yarn-error.log
coverage/
site/**/*.typegen.ts
site/build-storybook.log
site/coverage/
site/storybook-static/
site/test-results/*
site/e2e/test-results/*
site/e2e/states/*.json
site/e2e/.auth.json
site/playwright-report/*
site/.swc
site/dist/
# Make target for updating golden files (any dir).
.gen-golden
# Build
dist/
/build/
/dist/
site/out/
# Bundle analysis
site/stats/
*.tfstate
*.tfstate.backup
*.tfplan
*.lock.hcl
.terraform/
.vscode/*.log
**/*.swp
**/.coderv2/*
**/__debug_bin
# direnv
.envrc
*.test
# Loadtesting
./scaletest/terraform/.terraform
./scaletest/terraform/.terraform.lock.hcl
scaletest/terraform/secrets.tfvars
.terraform.tfstate.*
+15 -10
View File
@@ -54,7 +54,6 @@ linters-settings:
# - importShadow
- indexAlloc
- initClause
- ioutilDeprecated
- mapKey
- methodExprCall
# - nestingReduce
@@ -103,7 +102,7 @@ linters-settings:
settings:
ruleguard:
failOn: all
rules: rules.go
rules: "${configDir}/scripts/rules.go"
staticcheck:
# https://staticcheck.io/docs/options#checks
@@ -123,6 +122,8 @@ linters-settings:
misspell:
locale: US
ignore-words:
- trialer
nestif:
min-complexity: 4 # Min complexity of if statements (def 5, goal 4)
@@ -192,16 +193,18 @@ issues:
linters:
# We use assertions rather than explicitly checking errors in tests
- errcheck
- forcetypeassert
fix: true
max-issues-per-linter: 0
max-same-issues: 0
run:
concurrency: 4
skip-dirs:
- node_modules
timeout: 5m
skip-files:
- scripts/rules.go
timeout: 10m
# Over time, add more and more linters from
# https://golangci-lint.run/usage/linters/ as the code improves.
@@ -211,7 +214,6 @@ linters:
- asciicheck
- bidichk
- bodyclose
- deadcode
- dogsled
- errcheck
- errname
@@ -233,10 +235,15 @@ linters:
- noctx
- paralleltest
- revive
- rowserrcheck
- sqlclosecheck
# These don't work until the following issue is solved.
# https://github.com/golangci/golangci-lint/issues/2649
# - rowserrcheck
# - sqlclosecheck
# - structcheck
# - wastedassign
- staticcheck
- structcheck
- tenv
# In Go, it's possible for a package to test it's internal functionality
# without testing any exported functions. This is enabled to promote
@@ -250,5 +257,3 @@ linters:
- typecheck
- unconvert
- unused
- varcheck
- wastedassign
-165
View File
@@ -1,165 +0,0 @@
archives:
- id: coder-linux
builds: [coder-linux]
format: tar
files:
- src: docs/README.md
dst: README.md
- id: coder-darwin
builds: [coder-darwin]
format: zip
files:
- src: docs/README.md
dst: README.md
- id: coder-windows
builds: [coder-windows]
format: zip
files:
- src: docs/README.md
dst: README.md
before:
hooks:
- go mod tidy
- rm -f site/out/bin/coder*
builds:
- id: coder-slim
dir: cmd/coder
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
env: [CGO_ENABLED=0]
goos: [darwin, linux, windows]
goarch: [amd64, arm, arm64]
goarm: ["7"]
# Only build arm 7 for Linux
ignore:
- goos: windows
goarm: "7"
- goos: darwin
goarm: "7"
hooks:
# The "trimprefix" appends ".exe" on Windows.
post: |
cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ trimprefix .Name "coder" }}
- id: coder-linux
dir: cmd/coder
flags: [-tags=embed]
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
env: [CGO_ENABLED=0]
goos: [linux]
goarch: [amd64, arm, arm64]
goarm: ["7"]
- id: coder-windows
dir: cmd/coder
flags: [-tags=embed]
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
env: [CGO_ENABLED=0]
goos: [windows]
goarch: [amd64, arm64]
- id: coder-darwin
dir: cmd/coder
flags: [-tags=embed]
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
env: [CGO_ENABLED=0]
goos: [darwin]
goarch: [amd64, arm64]
hooks:
# This signs the binary that will be located inside the zip.
# MacOS requires the binary to be signed for notarization.
#
# If it doesn't successfully sign, the zip sign step will error.
post: |
sh -c 'codesign -s {{.Env.AC_APPLICATION_IDENTITY}} -f -v --timestamp --options runtime {{.Path}} || true'
env:
# Apple identity for signing!
- AC_APPLICATION_IDENTITY=BDB050EB749EDD6A80C6F119BF1382ECA119CCCC
nfpms:
- id: packages
vendor: Coder
homepage: https://coder.com
maintainer: Coder <support@coder.com>
description: |
Provision development environments with infrastructure with code
formats:
- apk
- deb
- rpm
suggests:
- postgresql
builds:
- coder-linux
bindir: /usr/bin
contents:
- src: coder.env
dst: /etc/coder.d/coder.env
type: "config|noreplace"
- src: coder.service
dst: /usr/lib/systemd/system/coder.service
dockers:
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-amd64"]
id: coder-linux
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title=Coder
- --label=org.opencontainers.image.description=A tool for provisioning self-hosted development environments with Terraform.
- --label=org.opencontainers.image.url=https://github.com/coder/coder
- --label=org.opencontainers.image.source=https://github.com/coder/coder
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=AGPL-3.0
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-arm64"]
goarch: arm64
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.title=coder
- --label=org.opencontainers.image.description=A tool for provisioning self-hosted development environments with Terraform.
- --label=org.opencontainers.image.url=https://github.com/coder/coder
- --label=org.opencontainers.image.source=https://github.com/coder/coder
- --label=org.opencontainers.image.version={{ .Tag }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=AGPL-3.0
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-armv7"]
goarch: arm
goarm: "7"
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/arm/v7
- --label=org.opencontainers.image.title=Coder
- --label=org.opencontainers.image.description=A tool for provisioning self-hosted development environments with Terraform.
- --label=org.opencontainers.image.url=https://github.com/coder/coder
- --label=org.opencontainers.image.source=https://github.com/coder/coder
- --label=org.opencontainers.image.version={{ .Tag }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=AGPL-3.0
docker_manifests:
- name_template: ghcr.io/coder/coder:{{ .Tag }}
image_templates:
- ghcr.io/coder/coder:{{ .Tag }}-amd64
- ghcr.io/coder/coder:{{ .Tag }}-arm64
- ghcr.io/coder/coder:{{ .Tag }}-armv7
release:
ids: [coder-linux, coder-darwin, coder-windows, packages]
signs:
- ids: [coder-darwin]
artifacts: archive
cmd: ./scripts/sign_macos.sh
args: ["${artifact}"]
output: true
snapshot:
name_template: "{{ .Version }}-devel+{{ .ShortCommit }}"
+80
View File
@@ -0,0 +1,80 @@
# Code generated by Makefile (.gitignore .prettierignore.include). DO NOT EDIT.
# .gitignore:
# Common ignore patterns, these rules applies in both root and subdirectories.
.DS_Store
.eslintcache
.gitpod.yml
.idea
**/*.swp
gotests.coverage
gotests.xml
gotests_stats.json
gotests.json
node_modules/
vendor/
yarn-error.log
# VSCode settings.
**/.vscode/*
# Allow VSCode recommendations and default settings in project root.
!/.vscode/extensions.json
!/.vscode/settings.json
# Front-end ignore patterns.
.next/
site/**/*.typegen.ts
site/build-storybook.log
site/coverage/
site/storybook-static/
site/test-results/*
site/e2e/test-results/*
site/e2e/states/*.json
site/e2e/.auth.json
site/playwright-report/*
site/.swc
site/dist/
# Make target for updating golden files (any dir).
.gen-golden
# Build
/build/
/dist/
site/out/
# Bundle analysis
site/stats/
*.tfstate
*.tfstate.backup
*.tfplan
*.lock.hcl
.terraform/
**/.coderv2/*
**/__debug_bin
# direnv
.envrc
*.test
# Loadtesting
./scaletest/terraform/.terraform
./scaletest/terraform/.terraform.lock.hcl
scaletest/terraform/secrets.tfvars
.terraform.tfstate.*
# .prettierignore.include:
# Helm templates contain variables that are invalid YAML and can't be formatted
# by Prettier.
helm/templates/*.yaml
# Terraform state files used in tests, these are automatically generated.
# Example: provisioner/terraform/testdata/instance-id/instance-id.tfstate.json
**/testdata/**/*.tf*.json
# Testdata shouldn't be formatted.
scripts/apitypings/testdata/**/*.ts
# Generated files shouldn't be formatted.
site/e2e/provisionerGenerated.ts
+13
View File
@@ -0,0 +1,13 @@
# Helm templates contain variables that are invalid YAML and can't be formatted
# by Prettier.
helm/templates/*.yaml
# Terraform state files used in tests, these are automatically generated.
# Example: provisioner/terraform/testdata/instance-id/instance-id.tfstate.json
**/testdata/**/*.tf*.json
# Testdata shouldn't be formatted.
scripts/apitypings/testdata/**/*.ts
# Generated files shouldn't be formatted.
site/e2e/provisionerGenerated.ts
+16
View File
@@ -0,0 +1,16 @@
# This config file is used in conjunction with `.editorconfig` to specify
# formatting for prettier-supported files. See `.editorconfig` and
# `site/.editorconfig`for whitespace formatting options.
printWidth: 80
semi: false
trailingComma: all
overrides:
- files:
- README.md
options:
proseWrap: preserve
- files:
- "site/**/*.yaml"
- "site/**/*.yml"
options:
proseWrap: always
+8
View File
@@ -0,0 +1,8 @@
// Replace all NullTime with string
replace github.com/coder/coder/codersdk.NullTime string
// Prevent swaggo from rendering enums for time.Duration
replace time.Duration int64
// Do not expose "echo" provider
replace github.com/coder/coder/codersdk.ProvisionerType string
// Do not render netip.Addr
replace netip.Addr string
+3 -1
View File
@@ -1,5 +1,6 @@
{
"recommendations": [
"github.vscode-codeql",
"golang.go",
"hashicorp.terraform",
"esbenp.prettier-vscode",
@@ -8,6 +9,7 @@
"zxh404.vscode-proto3",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker",
"dbaeumer.vscode-eslint"
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig"
]
}
+120 -9
View File
@@ -1,78 +1,187 @@
{
"cSpell.words": [
"afero",
"agentsdk",
"apps",
"ASKPASS",
"authcheck",
"autostop",
"awsidentity",
"bodyclose",
"buildinfo",
"buildname",
"circbuf",
"cliflag",
"cliui",
"codecov",
"coderd",
"coderdenttest",
"coderdtest",
"codersdk",
"cronstrue",
"databasefake",
"dbfake",
"dbgen",
"dbtype",
"DERP",
"derphttp",
"derpmap",
"devel",
"devtunnel",
"dflags",
"drpc",
"drpcconn",
"drpcmux",
"drpcserver",
"Dsts",
"embeddedpostgres",
"enablements",
"enterprisemeta",
"errgroup",
"eventsourcemock",
"Failf",
"fatih",
"Formik",
"gitauth",
"gitsshkey",
"goarch",
"gographviz",
"goleak",
"gonet",
"gossh",
"gsyslog",
"GTTY",
"hashicorp",
"hclsyntax",
"httpapi",
"httpmw",
"idtoken",
"Iflag",
"incpatch",
"ipnstate",
"isatty",
"Jobf",
"Keygen",
"kirsle",
"Kubernetes",
"ldflags",
"magicsock",
"manifoldco",
"mapstructure",
"mattn",
"mitchellh",
"moby",
"namesgenerator",
"namespacing",
"netaddr",
"netip",
"netmap",
"netns",
"netstack",
"nettype",
"nfpms",
"nhooyr",
"nmcfg",
"nolint",
"nosec",
"ntqry",
"OIDC",
"oneof",
"opty",
"paralleltest",
"parameterscopeid",
"pqtype",
"promptui",
"prometheusmetrics",
"promhttp",
"protobuf",
"provisionerd",
"provisionerdserver",
"provisionersdk",
"ptty",
"ptys",
"ptytest",
"quickstart",
"reconfig",
"replicasync",
"retrier",
"rpty",
"SCIM",
"sdkproto",
"sdktrace",
"Signup",
"slogtest",
"sourcemapped",
"Srcs",
"stdbuf",
"stretchr",
"STTY",
"stuntest",
"tanstack",
"tailbroker",
"tailcfg",
"tailexchange",
"tailnet",
"tailnettest",
"Tailscale",
"tbody",
"TCGETS",
"tcpip",
"TCSETS",
"templateversions",
"testdata",
"testid",
"testutil",
"tfexec",
"tfjson",
"tfplan",
"tfstate",
"thead",
"tios",
"tmpdir",
"tokenconfig",
"tparallel",
"trialer",
"trimprefix",
"tsdial",
"tslogger",
"tstun",
"turnconn",
"typegen",
"typesafe",
"unconvert",
"Untar",
"Userspace",
"VMID",
"walkthrough",
"weblinks",
"webrtc",
"wgcfg",
"wgconfig",
"wgengine",
"wgmonitor",
"wgnet",
"workspaceagent",
"workspaceagents",
"workspaceapp",
"workspaceapps",
"workspacebuilds",
"workspacename",
"wsconncache",
"wsjson",
"xerrors",
"xstate",
"yamux"
],
"cSpell.ignorePaths": ["site/package.json", ".vscode/settings.json"],
"emeraldwalk.runonsave": {
"commands": [
{
"match": "database/queries/*.sql",
"cmd": "make gen"
},
{
"match": "provisionerd/proto/provisionerd.proto",
"cmd": "make provisionerd/proto/provisionerd.pb.go"
}
]
},
@@ -80,25 +189,27 @@
"files.exclude": {
"**/node_modules": true
},
"search.exclude": {
"scripts/metricsdocgen/metrics": true,
"docs/api/*.md": true
},
// Ensure files always have a newline.
"files.insertFinalNewline": true,
"go.lintTool": "golangci-lint",
"go.lintFlags": ["--fast"],
"go.lintOnSave": "package",
"go.coverOnSave": true,
// The codersdk is used by coderd another other packages extensively.
// To reduce redundancy in tests, it's covered by other packages.
"go.testFlags": ["-short", "-coverpkg=./.,github.com/coder/coder/codersdk"],
"go.coverageDecorator": {
"type": "gutter",
"coveredHighlightColor": "rgba(64,128,128,0.5)",
"uncoveredHighlightColor": "rgba(128,64,64,0.25)",
"coveredBorderColor": "rgba(64,128,128,0.5)",
"uncoveredBorderColor": "rgba(128,64,64,0.25)",
"coveredGutterStyle": "blockgreen",
"uncoveredGutterStyle": "blockred"
},
// The codersdk is used by coderd another other packages extensively.
// To reduce redundancy in tests, it's covered by other packages.
// Since package coverage pairing can't be defined, all packages cover
// all other packages.
"go.testFlags": ["-short", "-coverpkg=./..."],
// We often use a version of TypeScript that's ahead of the version shipped
// with VS Code.
"typescript.tsdk": "./site/node_modules/typescript/lib",
"typescript.tsdk": "./site/node_modules/typescript/lib"
}
-6
View File
@@ -1,6 +0,0 @@
FROM alpine
# Generated by goreleaser on `goreleaser release`
ADD coder /opt/coder
ENTRYPOINT [ "/opt/coder", "server" ]
+31
View File
@@ -0,0 +1,31 @@
## Acceptance
By using any software and associated documentation files under Coder
Technologies Inc.s ("Coder") directory named "enterprise" ("Enterprise
Software"), you agree to all of the terms and conditions below.
## Copyright License
The licensor grants you a non-exclusive, royalty-free, worldwide,
non-sublicensable, non-transferable license to use, copy, distribute, make
available, modify and prepare derivative works of the Enterprise Software, in
each case subject to the limitations and conditions below.
## Limitations
You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software.
You agree that Coder and/or its licensors (as applicable) retain all right,
title and interest in and to all such modifications and/or patches.
## Additional Terms
This Enterprise Software may only be used in production, if you (and any entity
that you represent) have agreed to, and are in compliance with, the Coders
Terms of Service, available at https://coder.com/legal/terms-of-service, or
other agreement governing the use of the Software, as agreed by you and Coder.
+632 -57
View File
@@ -1,35 +1,390 @@
.DEFAULT_GOAL := build
# This is the Coder Makefile. The build directory for most tasks is `build/`.
#
# These are the targets you're probably looking for:
# - clean
# - build-fat: builds all "fat" binaries for all architectures
# - build-slim: builds all "slim" binaries (no frontend or slim binaries
# embedded) for all architectures
# - release: simulate a release (mostly, does not push images)
# - build/coder(-slim)?_${os}_${arch}(.exe)?: build a single fat binary
# - build/coder_${os}_${arch}.(zip|tar.gz): build a release archive
# - build/coder_linux_${arch}.(apk|deb|rpm): build a release Linux package
# - build/coder_${version}_linux_${arch}.tag: build a release Linux Docker image
# - build/coder_helm.tgz: build a release Helm chart
INSTALL_DIR=$(shell go env GOPATH)/bin
GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH)
.DEFAULT_GOAL := build-fat
bin: $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum
@echo "== This builds binaries for command-line usage."
@echo "== Use \"make build\" to embed the site."
goreleaser build --snapshot --rm-dist --single-target
# Use a single bash shell for each job, and immediately exit on failure
SHELL := bash
.SHELLFLAGS := -ceu
.ONESHELL:
build: dist/artifacts.json
.PHONY: build
# This doesn't work on directories.
# See https://stackoverflow.com/questions/25752543/make-delete-on-error-for-directory-targets
.DELETE_ON_ERROR:
# Runs migrations to output a dump of the database.
coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql)
go run coderd/database/dump/main.go
# Don't print the commands in the file unless you specify VERBOSE. This is
# essentially the same as putting "@" at the start of each line.
ifndef VERBOSE
.SILENT:
endif
# Generates Go code for querying the database.
coderd/database/querier.go: coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql)
coderd/database/generate.sh
# Create the output directories if they do not exist.
$(shell mkdir -p build site/out/bin)
dist/artifacts.json: site/out/index.html $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum
goreleaser release --snapshot --rm-dist --skip-sign
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
GOOS_BIN_EXT := $(if $(filter windows, $(GOOS)),.exe,)
VERSION := $(shell ./scripts/version.sh)
# Use the highest ZSTD compression level in CI.
ifdef CI
ZSTDFLAGS := -22 --ultra
else
ZSTDFLAGS := -6
endif
# Common paths to exclude from find commands, this rule is written so
# that it can be it can be used in a chain of AND statements (meaning
# you can simply write `find . $(FIND_EXCLUSIONS) -name thing-i-want`).
# Note, all find statements should be written with `.` or `./path` as
# the search path so that these exclusions match.
FIND_EXCLUSIONS= \
-not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path '*/node_modules/*' -o -path './site/out/*' -o -path './coderd/apidoc/*' \) -prune \)
# Source files used for make targets, evaluated on use.
GO_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go')
# All the shell files in the repo, excluding ignored files.
SHELL_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.sh')
# All ${OS}_${ARCH} combos we build for. Windows binaries have the .exe suffix.
OS_ARCHES := \
linux_amd64 linux_arm64 linux_armv7 \
darwin_amd64 darwin_arm64 \
windows_amd64.exe windows_arm64.exe
# Archive formats and their corresponding ${OS}_${ARCH} combos.
ARCHIVE_TAR_GZ := linux_amd64 linux_arm64 linux_armv7
ARCHIVE_ZIP := \
darwin_amd64 darwin_arm64 \
windows_amd64 windows_arm64
# All package formats we build and the ${OS}_${ARCH} combos we build them for.
PACKAGE_FORMATS := apk deb rpm
PACKAGE_OS_ARCHES := linux_amd64 linux_armv7 linux_arm64
# All architectures we build Docker images for (Linux only).
DOCKER_ARCHES := amd64 arm64 armv7
# Computed variables based on the above.
CODER_SLIM_BINARIES := $(addprefix build/coder-slim_$(VERSION)_,$(OS_ARCHES))
CODER_FAT_BINARIES := $(addprefix build/coder_$(VERSION)_,$(OS_ARCHES))
CODER_ALL_BINARIES := $(CODER_SLIM_BINARIES) $(CODER_FAT_BINARIES)
CODER_TAR_GZ_ARCHIVES := $(foreach os_arch, $(ARCHIVE_TAR_GZ), build/coder_$(VERSION)_$(os_arch).tar.gz)
CODER_ZIP_ARCHIVES := $(foreach os_arch, $(ARCHIVE_ZIP), build/coder_$(VERSION)_$(os_arch).zip)
CODER_ALL_ARCHIVES := $(CODER_TAR_GZ_ARCHIVES) $(CODER_ZIP_ARCHIVES)
CODER_ALL_PACKAGES := $(foreach os_arch, $(PACKAGE_OS_ARCHES), $(addprefix build/coder_$(VERSION)_$(os_arch).,$(PACKAGE_FORMATS)))
CODER_ARCH_IMAGES := $(foreach arch, $(DOCKER_ARCHES), build/coder_$(VERSION)_linux_$(arch).tag)
CODER_ARCH_IMAGES_PUSHED := $(addprefix push/, $(CODER_ARCH_IMAGES))
CODER_MAIN_IMAGE := build/coder_$(VERSION)_linux.tag
CODER_SLIM_NOVERSION_BINARIES := $(addprefix build/coder-slim_,$(OS_ARCHES))
CODER_FAT_NOVERSION_BINARIES := $(addprefix build/coder_,$(OS_ARCHES))
CODER_ALL_NOVERSION_IMAGES := $(foreach arch, $(DOCKER_ARCHES), build/coder_linux_$(arch).tag) build/coder_linux.tag
CODER_ALL_NOVERSION_IMAGES_PUSHED := $(addprefix push/, $(CODER_ALL_NOVERSION_IMAGES))
# If callers are only building Docker images and not the packages and archives,
# we can skip those prerequisites as they are not actually required and only
# specified to avoid concurrent write failures.
ifdef DOCKER_IMAGE_NO_PREREQUISITES
CODER_ARCH_IMAGE_PREREQUISITES :=
else
CODER_ARCH_IMAGE_PREREQUISITES := \
build/coder_$(VERSION)_%.apk \
build/coder_$(VERSION)_%.deb \
build/coder_$(VERSION)_%.rpm \
build/coder_$(VERSION)_%.tar.gz
endif
clean:
rm -rf build site/out
mkdir -p build site/out/bin
git restore site/out
.PHONY: clean
build-slim: $(CODER_SLIM_BINARIES)
.PHONY: build-slim
build-fat build-full build: $(CODER_FAT_BINARIES)
.PHONY: build-fat build-full build
release: $(CODER_FAT_BINARIES) $(CODER_ALL_ARCHIVES) $(CODER_ALL_PACKAGES) $(CODER_ARCH_IMAGES) build/coder_helm_$(VERSION).tgz
.PHONY: release
build/coder-slim_$(VERSION)_checksums.sha1: site/out/bin/coder.sha1
cp "$<" "$@"
site/out/bin/coder.sha1: $(CODER_SLIM_BINARIES)
pushd ./site/out/bin
openssl dgst -r -sha1 coder-* | tee coder.sha1
popd
build/coder-slim_$(VERSION).tar: build/coder-slim_$(VERSION)_checksums.sha1 $(CODER_SLIM_BINARIES)
pushd ./site/out/bin
tar cf "../../../build/$(@F)" coder-*
popd
# delete the uncompressed binaries from the embedded dir
rm -f site/out/bin/coder-*
site/out/bin/coder.tar.zst: build/coder-slim_$(VERSION).tar.zst
cp "$<" "$@"
build/coder-slim_$(VERSION).tar.zst: build/coder-slim_$(VERSION).tar
zstd $(ZSTDFLAGS) \
--force \
--long \
--no-progress \
-o "build/coder-slim_$(VERSION).tar.zst" \
"build/coder-slim_$(VERSION).tar"
# Redirect from version-less targets to the versioned ones. There is a similar
# target for slim binaries below.
#
# Called like this:
# make build/coder_linux_amd64
# make build/coder_windows_amd64.exe
$(CODER_FAT_NOVERSION_BINARIES): build/coder_%: build/coder_$(VERSION)_%
rm -f "$@"
ln "$<" "$@"
# Same as above, but for slim binaries.
#
# Called like this:
# make build/coder-slim_linux_amd64
# make build/coder-slim_windows_amd64.exe
$(CODER_SLIM_NOVERSION_BINARIES): build/coder-slim_%: build/coder-slim_$(VERSION)_%
rm -f "$@"
ln "$<" "$@"
# "fat" binaries always depend on the site and the compressed slim binaries.
$(CODER_FAT_BINARIES): \
site/out/index.html \
site/out/bin/coder.sha1 \
site/out/bin/coder.tar.zst
# This is a handy block that parses the target to determine whether it's "slim"
# or "fat", which OS was specified and which architecture was specified.
#
# It populates the following variables: mode, os, arch_ext, arch, ext (without
# dot).
define get-mode-os-arch-ext =
mode="$$([[ "$@" = build/coder-slim* ]] && echo "slim" || echo "fat")"
os="$$(echo $@ | cut -d_ -f3)"
arch_ext="$$(echo $@ | cut -d_ -f4)"
if [[ "$$arch_ext" == *.* ]]; then
arch="$$(echo $$arch_ext | cut -d. -f1)"
ext="$${arch_ext#*.}"
else
arch="$$arch_ext"
ext=""
fi
endef
# This task handles all builds, for both "fat" and "slim" binaries. It parses
# the target name to get the metadata for the build, so it must be specified in
# this format:
# build/coder(-slim)?_${version}_${os}_${arch}(.exe)?
#
# You should probably use the non-version targets above instead if you're
# calling this manually.
$(CODER_ALL_BINARIES): go.mod go.sum \
$(GO_SRC_FILES) \
$(shell find ./examples/templates)
$(get-mode-os-arch-ext)
if [[ "$$os" != "windows" ]] && [[ "$$ext" != "" ]]; then
echo "ERROR: Invalid build binary extension" 1>&2
exit 1
fi
if [[ "$$os" == "windows" ]] && [[ "$$ext" != exe ]]; then
echo "ERROR: Windows binaries must have an .exe extension." 1>&2
exit 1
fi
build_args=( \
--os "$$os" \
--arch "$$arch" \
--version "$(VERSION)" \
--output "$@" \
)
if [ "$$mode" == "slim" ]; then
build_args+=(--slim)
fi
./scripts/build_go.sh "$${build_args[@]}"
if [[ "$$mode" == "slim" ]]; then
dot_ext=""
if [[ "$$ext" != "" ]]; then
dot_ext=".$$ext"
fi
cp "$@" "./site/out/bin/coder-$$os-$$arch$$dot_ext"
fi
# This task builds all archives. It parses the target name to get the metadata
# for the build, so it must be specified in this format:
# build/coder_${version}_${os}_${arch}.${format}
#
# The following OS/arch/format combinations are supported:
# .tar.gz: linux_amd64, linux_arm64, linux_armv7
# .zip: darwin_amd64, darwin_arm64, windows_amd64, windows_arm64
#
# This depends on all fat binaries because it's difficult to do dynamic
# dependencies due to the .exe requirement on Windows. These targets are
# typically only used during release anyways.
$(CODER_ALL_ARCHIVES): $(CODER_FAT_BINARIES)
$(get-mode-os-arch-ext)
bin_ext=""
if [[ "$$os" == "windows" ]]; then
bin_ext=".exe"
fi
./scripts/archive.sh \
--format "$$ext" \
--os "$$os" \
--output "$@" \
"build/coder_$(VERSION)_$${os}_$${arch}$${bin_ext}"
# This task builds all packages. It parses the target name to get the metadata
# for the build, so it must be specified in this format:
# build/coder_${version}_linux_${arch}.${format}
#
# Supports apk, deb, rpm for all linux targets.
#
# This depends on all Linux fat binaries and archives because it's difficult to
# do dynamic dependencies due to the extensions in the filenames. These targets
# are typically only used during release anyways.
#
# Packages need to run after the archives are built, otherwise they cause tar
# errors like "file changed as we read it".
CODER_PACKAGE_DEPS := $(foreach os_arch, $(PACKAGE_OS_ARCHES), build/coder_$(VERSION)_$(os_arch) build/coder_$(VERSION)_$(os_arch).tar.gz)
$(CODER_ALL_PACKAGES): $(CODER_PACKAGE_DEPS)
$(get-mode-os-arch-ext)
./scripts/package.sh \
--arch "$$arch" \
--format "$$ext" \
--version "$(VERSION)" \
--output "$@" \
"build/coder_$(VERSION)_$${os}_$${arch}"
# This task builds a Windows amd64 installer. Depends on makensis.
build/coder_$(VERSION)_windows_amd64_installer.exe: build/coder_$(VERSION)_windows_amd64.exe
./scripts/build_windows_installer.sh \
--version "$(VERSION)" \
--output "$@" \
"$<"
# Redirect from version-less Docker image targets to the versioned ones.
#
# Called like this:
# make build/coder_linux_amd64.tag
$(CODER_ALL_NOVERSION_IMAGES): build/coder_%: build/coder_$(VERSION)_%
.PHONY: $(CODER_ALL_NOVERSION_IMAGES)
# Redirect from version-less push Docker image targets to the versioned ones.
#
# Called like this:
# make push/build/coder_linux_amd64.tag
$(CODER_ALL_NOVERSION_IMAGES_PUSHED): push/build/coder_%: push/build/coder_$(VERSION)_%
.PHONY: $(CODER_ALL_NOVERSION_IMAGES_PUSHED)
# This task builds all Docker images. It parses the target name to get the
# metadata for the build, so it must be specified in this format:
# build/coder_${version}_${os}_${arch}.tag
#
# Supports linux_amd64, linux_arm64, linux_armv7.
#
# Images need to run after the archives and packages are built, otherwise they
# cause errors like "file changed as we read it".
$(CODER_ARCH_IMAGES): build/coder_$(VERSION)_%.tag: build/coder_$(VERSION)_% $(CODER_ARCH_IMAGE_PREREQUISITES)
$(get-mode-os-arch-ext)
image_tag="$$(./scripts/image_tag.sh --arch "$$arch" --version "$(VERSION)")"
./scripts/build_docker.sh \
--arch "$$arch" \
--target "$$image_tag" \
--version "$(VERSION)" \
"build/coder_$(VERSION)_$${os}_$${arch}"
echo "$$image_tag" > "$@"
# Multi-arch Docker image. This requires all architecture-specific images to be
# built AND pushed.
$(CODER_MAIN_IMAGE): $(CODER_ARCH_IMAGES_PUSHED)
image_tag="$$(./scripts/image_tag.sh --version "$(VERSION)")"
./scripts/build_docker_multiarch.sh \
--target "$$image_tag" \
--version "$(VERSION)" \
$(foreach img, $^, "$$(cat "$(img:push/%=%)")")
echo "$$image_tag" > "$@"
# Push a Docker image.
$(CODER_ARCH_IMAGES_PUSHED): push/%: %
image_tag="$$(cat "$<")"
docker push "$$image_tag"
.PHONY: $(CODER_ARCH_IMAGES_PUSHED)
# Push the multi-arch Docker manifest.
push/$(CODER_MAIN_IMAGE): $(CODER_MAIN_IMAGE)
image_tag="$$(cat "$<")"
docker manifest push "$$image_tag"
.PHONY: push/$(CODER_MAIN_IMAGE)
# Shortcut for Helm chart package.
build/coder_helm.tgz: build/coder_helm_$(VERSION).tgz
rm -f "$@"
ln "$<" "$@"
# Helm chart package.
build/coder_helm_$(VERSION).tgz:
./scripts/helm.sh \
--version "$(VERSION)" \
--output "$@"
site/out/index.html: site/package.json $(shell find ./site $(FIND_EXCLUSIONS) -type f \( -name '*.ts' -o -name '*.tsx' \))
./scripts/yarn_install.sh
cd site
yarn build
install: build/coder_$(VERSION)_$(GOOS)_$(GOARCH)$(GOOS_BIN_EXT)
install_dir="$$(go env GOPATH)/bin"
output_file="$${install_dir}/coder$(GOOS_BIN_EXT)"
mkdir -p "$$install_dir"
cp "$<" "$$output_file"
.PHONY: install
fmt: fmt/prettier fmt/terraform fmt/shfmt fmt/go
.PHONY: fmt
fmt/go:
# VS Code users should check out
# https://github.com/mvdan/gofumpt#visual-studio-code
go run mvdan.cc/gofumpt@v0.4.0 -w -l .
.PHONY: fmt/go
fmt/prettier:
@echo "--- prettier"
echo "--- prettier"
cd site
# Avoid writing files in CI to reduce file write activity
ifdef CI
cd site && yarn run format:check
yarn run format:check
else
cd site && yarn run format:write
yarn run format:write
endif
.PHONY: fmt/prettier
@@ -37,36 +392,106 @@ fmt/terraform: $(wildcard *.tf)
terraform fmt -recursive
.PHONY: fmt/terraform
fmt: fmt/prettier fmt/terraform
.PHONY: fmt
fmt/shfmt: $(SHELL_SRC_FILES)
echo "--- shfmt"
# Only do diff check in CI, errors on diff.
ifdef CI
shfmt -d $(SHELL_SRC_FILES)
else
shfmt -w $(SHELL_SRC_FILES)
endif
.PHONY: fmt/shfmt
gen: coderd/database/querier.go peerbroker/proto/peerbroker.pb.go provisionersdk/proto/provisioner.pb.go provisionerd/proto/provisionerd.pb.go site/src/api/typesGenerated.ts
install: build
@echo "--- Copying from bin to $(INSTALL_DIR)"
cp -r ./dist/coder-$(GOOS)_$(GOOS)_$(GOARCH)*/* $(INSTALL_DIR)
@echo "-- CLI available at $(shell ls $(INSTALL_DIR)/coder*)"
.PHONY: install
lint:
golangci-lint run
lint: lint/shellcheck lint/go lint/ts lint/helm
.PHONY: lint
peerbroker/proto/peerbroker.pb.go: peerbroker/proto/peerbroker.proto
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./peerbroker/proto/peerbroker.proto
lint/ts:
cd site
yarn && yarn lint
.PHONY: lint/ts
provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./provisionerd/proto/provisionerd.proto
lint/go:
./scripts/check_enterprise_imports.sh
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2
golangci-lint run
.PHONY: lint/go
# Use shfmt to determine the shell files, takes editorconfig into consideration.
lint/shellcheck: $(SHELL_SRC_FILES)
echo "--- shellcheck"
shellcheck --external-sources $(SHELL_SRC_FILES)
.PHONY: lint/shellcheck
lint/helm:
cd helm
make lint
.PHONY: lint/helm
# all gen targets should be added here and to gen/mark-fresh
gen: \
coderd/database/dump.sql \
coderd/database/querier.go \
coderd/database/dbmock/dbmock.go \
provisionersdk/proto/provisioner.pb.go \
provisionerd/proto/provisionerd.pb.go \
site/src/api/typesGenerated.ts \
coderd/rbac/object_gen.go \
docs/admin/prometheus.md \
docs/cli.md \
docs/admin/audit-logs.md \
coderd/apidoc/swagger.json \
.prettierignore.include \
.prettierignore \
site/.prettierrc.yaml \
site/.prettierignore \
site/.eslintignore
.PHONY: gen
# Mark all generated files as fresh so make thinks they're up-to-date. This is
# used during releases so we don't run generation scripts.
gen/mark-fresh:
files="\
coderd/database/dump.sql \
coderd/database/querier.go \
coderd/database/dbmock/dbmock.go \
provisionersdk/proto/provisioner.pb.go \
provisionerd/proto/provisionerd.pb.go \
site/src/api/typesGenerated.ts \
coderd/rbac/object_gen.go \
docs/admin/prometheus.md \
docs/cli.md \
docs/admin/audit-logs.md \
coderd/apidoc/swagger.json \
.prettierignore.include \
.prettierignore \
site/.prettierrc.yaml \
site/.prettierignore \
site/.eslintignore \
"
for file in $$files; do
echo "$$file"
if [ ! -f "$$file" ]; then
echo "File '$$file' does not exist"
exit 1
fi
# touch sets the mtime of the file to the current time
touch $$file
done
.PHONY: gen/mark-fresh
# Runs migrations to output a dump of the database schema after migrations are
# applied.
coderd/database/dump.sql: coderd/database/gen/dump/main.go $(wildcard coderd/database/migrations/*.sql)
go run ./coderd/database/gen/dump/main.go
# Generates Go code for querying the database.
coderd/database/querier.go: coderd/database/sqlc.yaml coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql)
./coderd/database/generate.sh
coderd/database/dbmock/dbmock.go: coderd/database/db.go coderd/database/querier.go
go generate ./coderd/database/dbmock/
provisionersdk/proto/provisioner.pb.go: provisionersdk/proto/provisioner.proto
protoc \
@@ -76,16 +501,166 @@ provisionersdk/proto/provisioner.pb.go: provisionersdk/proto/provisioner.proto
--go-drpc_opt=paths=source_relative \
./provisionersdk/proto/provisioner.proto
site/out/index.html: $(shell find ./site -not -path './site/node_modules/*' -type f -name '*.tsx') $(shell find ./site -not -path './site/node_modules/*' -type f -name '*.ts') site/package.json
./scripts/yarn_install.sh
cd site && yarn typegen
cd site && yarn build
# Restores GITKEEP files!
git checkout HEAD site/out
provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./provisionerd/proto/provisionerd.proto
site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk -type f -name '*.go')
site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
cd site && yarn run format:types
cd site
yarn run format:types
test:
gotestsum -- -v -short ./...
coderd/rbac/object_gen.go: scripts/rbacgen/main.go coderd/rbac/object.go
go run scripts/rbacgen/main.go ./coderd/rbac > coderd/rbac/object_gen.go
docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics
go run scripts/metricsdocgen/main.go
cd site
yarn run format:write:only ../docs/admin/prometheus.md
docs/cli.md: scripts/clidocgen/main.go $(GO_SRC_FILES)
BASE_PATH="." go run ./scripts/clidocgen
cd site
yarn run format:write:only ../docs/cli.md ../docs/cli/*.md ../docs/manifest.json
docs/admin/audit-logs.md: scripts/auditdocgen/main.go enterprise/audit/table.go coderd/rbac/object_gen.go
go run scripts/auditdocgen/main.go
cd site
yarn run format:write:only ../docs/admin/audit-logs.md
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) $(wildcard enterprise/wsproxy/wsproxysdk/*.go) coderd/database/querier.go .swaggo docs/manifest.json coderd/rbac/object_gen.go
./scripts/apidocgen/generate.sh
yarn run --cwd=site format:write:only ../docs/api ../docs/manifest.json ../coderd/apidoc/swagger.json
update-golden-files: cli/testdata/.gen-golden helm/tests/testdata/.gen-golden scripts/ci-report/testdata/.gen-golden enterprise/cli/testdata/.gen-golden
.PHONY: update-golden-files
cli/testdata/.gen-golden: $(wildcard cli/testdata/*.golden) $(wildcard cli/*.tpl) $(GO_SRC_FILES)
go test ./cli -run="Test(CommandHelp|ServerYAML)" -update
touch "$@"
enterprise/cli/testdata/.gen-golden: $(wildcard enterprise/cli/testdata/*.golden) $(wildcard cli/*.tpl) $(GO_SRC_FILES)
go test ./enterprise/cli -run="TestEnterpriseCommandHelp" -update
touch "$@"
helm/tests/testdata/.gen-golden: $(wildcard helm/tests/testdata/*.yaml) $(wildcard helm/tests/testdata/*.golden) $(GO_SRC_FILES)
go test ./helm/tests -run=TestUpdateGoldenFiles -update
touch "$@"
scripts/ci-report/testdata/.gen-golden: $(wildcard scripts/ci-report/testdata/*) $(wildcard scripts/ci-report/*.go)
go test ./scripts/ci-report -run=TestOutputMatchesGoldenFile -update
touch "$@"
# Generate a prettierrc for the site package that uses relative paths for
# overrides. This allows us to share the same prettier config between the
# site and the root of the repo.
site/.prettierrc.yaml: .prettierrc.yaml
. ./scripts/lib.sh
dependencies yq
echo "# Code generated by Makefile (../$<). DO NOT EDIT." > "$@"
echo "" >> "$@"
# Replace all listed override files with relative paths inside site/.
# - ./ -> ../
# - ./site -> ./
yq \
'.overrides[].files |= map(. | sub("^./"; "") | sub("^"; "../") | sub("../site/"; "./"))' \
"$<" >> "$@"
# Combine .gitignore with .prettierignore.include to generate .prettierignore.
.prettierignore: .gitignore .prettierignore.include
echo "# Code generated by Makefile ($^). DO NOT EDIT." > "$@"
echo "" >> "$@"
for f in $^; do
echo "# $${f}:" >> "$@"
cat "$$f" >> "$@"
done
# Generate ignore files based on gitignore into the site directory. We turn all
# rules into relative paths for the `site/` directory (where applicable),
# following the pattern format defined by git:
# https://git-scm.com/docs/gitignore#_pattern_format
#
# This is done for compatibility reasons, see:
# https://github.com/prettier/prettier/issues/8048
# https://github.com/prettier/prettier/issues/8506
# https://github.com/prettier/prettier/issues/8679
site/.eslintignore site/.prettierignore: .prettierignore Makefile
rm -f "$@"
touch "$@"
# Skip generated by header, inherit `.prettierignore` header as-is.
while read -r rule; do
# Remove leading ! if present to simplify rule, added back at the end.
tmp="$${rule#!}"
ignore="$${rule%"$$tmp"}"
rule="$$tmp"
case "$$rule" in
# Comments or empty lines (include).
\#*|'') ;;
# Generic rules (include).
\*\**) ;;
# Site prefixed rules (include).
site/*) rule="$${rule#site/}";;
./site/*) rule="$${rule#./site/}";;
# Rules that are non-generic and don't start with site (rewrite).
/*) rule=.."$$rule";;
*/?*) rule=../"$$rule";;
*) ;;
esac
echo "$${ignore}$${rule}" >> "$@"
done < "$<"
test: test-clean
gotestsum --format standard-quiet -- -v -short ./...
.PHONY: test
# When updating -timeout for this test, keep in sync with
# test-go-postgres (.github/workflows/coder.yaml).
# Do add coverage flags so that test caching works.
test-postgres: test-clean test-postgres-docker
# The postgres test is prone to failure, so we limit parallelism for
# more consistent execution.
DB=ci DB_FROM=$(shell go run scripts/migrate-ci/main.go) gotestsum \
--junitfile="gotests.xml" \
--jsonfile="gotests.json" \
--packages="./..." -- \
-timeout=20m \
-failfast
.PHONY: test-postgres
test-postgres-docker:
docker rm -f test-postgres-docker || true
docker run \
--env POSTGRES_PASSWORD=postgres \
--env POSTGRES_USER=postgres \
--env POSTGRES_DB=postgres \
--env PGDATA=/tmp \
--tmpfs /tmp \
--publish 5432:5432 \
--name test-postgres-docker \
--restart no \
--detach \
gcr.io/coder-dev-1/postgres:13 \
-c shared_buffers=1GB \
-c work_mem=1GB \
-c effective_cache_size=1GB \
-c max_connections=1000 \
-c fsync=off \
-c synchronous_commit=off \
-c full_page_writes=off \
-c log_statement=all
while ! pg_isready -h 127.0.0.1
do
echo "$(date) - waiting for database to start"
sleep 0.5
done
.PHONY: test-postgres-docker
test-clean:
go clean -testcache
.PHONY: test-clean
+125
View File
@@ -0,0 +1,125 @@
<div align="center">
<a href="https://coder.com#gh-light-mode-only">
<img src="./docs/images/logo-black.png" style="width: 128px">
</a>
<a href="https://coder.com#gh-dark-mode-only">
<img src="./docs/images/logo-white.png" style="width: 128px">
</a>
<h1>
Self-Hosted Remote Development Environments
</h1>
<a href="https://coder.com#gh-light-mode-only">
<img src="./docs/images/banner-black.png" style="width: 650px">
</a>
<a href="https://coder.com#gh-dark-mode-only">
<img src="./docs/images/banner-white.png" style="width: 650px">
</a>
<br>
<br>
[Quickstart](#quickstart) | [Docs](https://coder.com/docs) | [Why Coder](https://coder.com/why) | [Enterprise](https://coder.com/docs/v2/latest/enterprise)
[![discord](https://img.shields.io/discord/747933592273027093?label=discord)](https://discord.gg/coder)
[![codecov](https://codecov.io/gh/coder/coder/branch/main/graph/badge.svg?token=TNLW3OAP6G)](https://codecov.io/gh/coder/coder)
[![release](https://img.shields.io/github/v/release/coder/coder)](https://github.com/coder/coder/releases/latest)
[![godoc](https://pkg.go.dev/badge/github.com/coder/coder.svg)](https://pkg.go.dev/github.com/coder/coder)
[![Go Report Card](https://goreportcard.com/badge/github.com/coder/coder)](https://goreportcard.com/report/github.com/coder/coder)
[![license](https://img.shields.io/github/license/coder/coder)](./LICENSE)
</div>
[Coder](https://coder.com) enables organizations to set up development environments in the cloud. Environments are defined with Terraform, connected through a secure high-speed Wireguard® tunnel, and are automatically shut down when not in use to save on costs. Coder gives engineering teams the flexibility to use the cloud for workloads that are most beneficial to them.
- Define development environments in Terraform
- EC2 VMs, Kubernetes Pods, Docker Containers, etc.
- Automatically shutdown idle resources to save on costs
- Onboard developers in seconds instead of days
<p align="center">
<img src="./docs/images/hero-image.png">
</p>
## Quickstart
The most convenient way to try Coder is to install it on your local machine and experiment with provisioning development environments using Docker (works on Linux, macOS, and Windows).
```
# First, install Coder
curl -L https://coder.com/install.sh | sh
# Start the Coder server (caches data in ~/.cache/coder)
coder server
# Navigate to http://localhost:3000 to create your initial user
# Create a Docker template, and provision a workspace
```
## Install
The easiest way to install Coder is to use our
[install script](https://github.com/coder/coder/blob/main/install.sh) for Linux
and macOS. For Windows, use the latest `..._installer.exe` file from GitHub
Releases.
```bash
curl -L https://coder.com/install.sh | sh
```
You can run the install script with `--dry-run` to see the commands that will be used to install without executing them. You can modify the installation process by including flags. Run the install script with `--help` for reference.
> See [install](docs/install) for additional methods.
Once installed, you can start a production deployment<sup>1</sup> with a single command:
```console
# Automatically sets up an external access URL on *.try.coder.app
coder server
# Requires a PostgreSQL instance (version 13 or higher) and external access URL
coder server --postgres-url <url> --access-url <url>
```
> <sup>1</sup> For production deployments, set up an external PostgreSQL instance for reliability.
Use `coder --help` to get a list of flags and environment variables. Use our [install guides](https://coder.com/docs/v2/latest/install) for a full walkthrough.
## Documentation
Browse our docs [here](https://coder.com/docs/v2) or visit a specific section below:
- [**Templates**](https://coder.com/docs/v2/latest/templates): Templates are written in Terraform and describe the infrastructure for workspaces
- [**Workspaces**](https://coder.com/docs/v2/latest/workspaces): Workspaces contain the IDEs, dependencies, and configuration information needed for software development
- [**IDEs**](https://coder.com/docs/v2/latest/ides): Connect your existing editor to a workspace
- [**Administration**](https://coder.com/docs/v2/latest/admin): Learn how to operate Coder
- [**Enterprise**](https://coder.com/docs/v2/latest/enterprise): Learn about our paid features built for large teams
## Community and Support
Feel free to [open an issue](https://github.com/coder/coder/issues/new) if you have questions, run into bugs, or have a feature request.
[Join our Discord](https://discord.gg/coder) to provide feedback on in-progress features, and chat with the community using Coder!
## Contributing
Contributions are welcome! Read the [contributing docs](https://coder.com/docs/v2/latest/CONTRIBUTING) to get started.
Find our list of contributors [here](https://github.com/coder/coder/graphs/contributors).
## Related
We are always working on new integrations. Feel free to open an issue to request an integration. Contributions are welcome in any official or community repositories.
### Official
- [**VS Code Extension**](https://marketplace.visualstudio.com/items?itemName=coder.coder-remote): Open any Coder workspace in VS Code with a single click
- [**JetBrains Gateway Extension**](https://plugins.jetbrains.com/plugin/19620-coder): Open any Coder workspace in JetBrains Gateway with a single click
- [**Self-Hosted VS Code Extension Marketplace**](https://github.com/coder/code-marketplace): A private extension marketplace that works in restricted or airgapped networks integrating with [code-server](https://github.com/coder/code-server).
### Community
- [**Provision Coder with Terraform**](https://github.com/ElliotG/coder-oss-tf): Provision Coder on Google GKE, Azure AKS, AWS EKS, DigitalOcean DOKS, IBMCloud K8s, OVHCloud K8s, and Scaleway K8s Kapsule with Terraform
- [**Coder GitHub Action**](https://github.com/marketplace/actions/update-coder-template): A GitHub Action that updates Coder templates
- [**Various Templates**](./examples/templates/community-templates.md): Hetzner Cloud, Docker in Docker, and other templates the community has built.
+73
View File
@@ -0,0 +1,73 @@
# Coder Security
Coder welcomes feedback from security researchers and the general public
to help improve our security. If you believe you have discovered a vulnerability,
privacy issue, exposed data, or other security issues in any of our assets, we
want to hear from you. This policy outlines steps for reporting vulnerabilities
to us, what we expect, what you can expect from us.
You can see the pretty version [here](https://coder.com/security/policy)
# Why Coder's security matters
If an attacker could fully compromise a Coder installation, they could spin
up expensive workstations, steal valuable credentials, or steal proprietary
source code. We take this risk very seriously and employ routine pen testing,
vulnerability scanning, and code reviews. We also welcome the contributions
from the community that helped make this product possible.
# Where should I report security issues?
Please report security issues to security@coder.com, providing
all relevant information. The more details you provide, the easier it will be
for us to triage and fix the issue.
# Out of Scope
Our primary concern is around an abuse of the Coder application that allows
an attacker to gain access to another users workspace, or spin up unwanted
workspaces.
- DOS/DDOS attacks affecting availability --> While we do support rate limiting
of requests, we primarily leave this to the owner of the Coder installation. Our
rationale is that a DOS attack only affecting availability is not a valuable
target for attackers.
- Abuse of a compromised user credential --> If a user credential is compromised
outside of the Coder ecosystem, then we consider it beyond the scope of our application.
However, if an unprivileged user could escalate their permissions or gain access
to another workspace, that is a cause for concern.
- Vulnerabilities in third party systems --> Vulnerabilities discovered in
out-of-scope systems should be reported to the appropriate vendor or applicable authority.
# Our Commitments
When working with us, according to this policy, you can expect us to:
- Respond to your report promptly, and work with you to understand and validate your report;
- Strive to keep you informed about the progress of a vulnerability as it is processed;
- Work to remediate discovered vulnerabilities in a timely manner, within our operational constraints; and
- Extend Safe Harbor for your vulnerability research that is related to this policy.
# Our Expectations
In participating in our vulnerability disclosure program in good faith, we ask that you:
- Play by the rules, including following this policy and any other relevant agreements.
If there is any inconsistency between this policy and any other applicable terms, the
terms of this policy will prevail;
- Report any vulnerability youve discovered promptly;
- Avoid violating the privacy of others, disrupting our systems, destroying data, and/or
harming user experience;
- Use only the Official Channels to discuss vulnerability information with us;
- Provide us a reasonable amount of time (at least 90 days from the initial report) to
resolve the issue before you disclose it publicly;
- Perform testing only on in-scope systems, and respect systems and activities which
are out-of-scope;
- If a vulnerability provides unintended access to data: Limit the amount of data you
access to the minimum required for effectively demonstrating a Proof of Concept; and
cease testing and submit a report immediately if you encounter any user data during testing,
such as Personally Identifiable Information (PII), Personal Healthcare Information (PHI),
credit card data, or proprietary information;
- You should only interact with test accounts you own or with explicit permission from
- the account holder; and
- Do not engage in extortion.
+1197 -392
View File
File diff suppressed because it is too large Load Diff
+2200 -197
View File
File diff suppressed because it is too large Load Diff
+848
View File
@@ -0,0 +1,848 @@
package agentssh
import (
"bufio"
"context"
"crypto/rand"
"crypto/rsa"
"errors"
"fmt"
"io"
"net"
"os"
"os/exec"
"os/user"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
"github.com/gliderlabs/ssh"
"github.com/pkg/sftp"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/afero"
"go.uber.org/atomic"
gossh "golang.org/x/crypto/ssh"
"golang.org/x/xerrors"
"cdr.dev/slog"
"github.com/coder/coder/agent/usershell"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/codersdk/agentsdk"
"github.com/coder/coder/pty"
)
const (
// MagicSessionErrorCode indicates that something went wrong with the session, rather than the
// command just returning a nonzero exit code, and is chosen as an arbitrary, high number
// unlikely to shadow other exit codes, which are typically 1, 2, 3, etc.
MagicSessionErrorCode = 229
// MagicSessionTypeEnvironmentVariable is used to track the purpose behind an SSH connection.
// This is stripped from any commands being executed, and is counted towards connection stats.
MagicSessionTypeEnvironmentVariable = "CODER_SSH_SESSION_TYPE"
// MagicSessionTypeVSCode is set in the SSH config by the VS Code extension to identify itself.
MagicSessionTypeVSCode = "vscode"
// MagicSessionTypeJetBrains is set in the SSH config by the JetBrains extension to identify itself.
MagicSessionTypeJetBrains = "jetbrains"
)
type Server struct {
mu sync.RWMutex // Protects following.
fs afero.Fs
listeners map[net.Listener]struct{}
conns map[net.Conn]struct{}
sessions map[ssh.Session]struct{}
closing chan struct{}
// Wait for goroutines to exit, waited without
// a lock on mu but protected by closing.
wg sync.WaitGroup
logger slog.Logger
srv *ssh.Server
x11SocketDir string
Env map[string]string
AgentToken func() string
Manifest *atomic.Pointer[agentsdk.Manifest]
ServiceBanner *atomic.Pointer[codersdk.ServiceBannerConfig]
connCountVSCode atomic.Int64
connCountJetBrains atomic.Int64
connCountSSHSession atomic.Int64
metrics *sshServerMetrics
}
func NewServer(ctx context.Context, logger slog.Logger, prometheusRegistry *prometheus.Registry, fs afero.Fs, maxTimeout time.Duration, x11SocketDir string) (*Server, error) {
// Clients' should ignore the host key when connecting.
// The agent needs to authenticate with coderd to SSH,
// so SSH authentication doesn't improve security.
randomHostKey, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
return nil, err
}
randomSigner, err := gossh.NewSignerFromKey(randomHostKey)
if err != nil {
return nil, err
}
if x11SocketDir == "" {
x11SocketDir = filepath.Join(os.TempDir(), ".X11-unix")
}
forwardHandler := &ssh.ForwardedTCPHandler{}
unixForwardHandler := &forwardedUnixHandler{log: logger}
metrics := newSSHServerMetrics(prometheusRegistry)
s := &Server{
listeners: make(map[net.Listener]struct{}),
fs: fs,
conns: make(map[net.Conn]struct{}),
sessions: make(map[ssh.Session]struct{}),
logger: logger,
x11SocketDir: x11SocketDir,
metrics: metrics,
}
srv := &ssh.Server{
ChannelHandlers: map[string]ssh.ChannelHandler{
"direct-tcpip": ssh.DirectTCPIPHandler,
"direct-streamlocal@openssh.com": directStreamLocalHandler,
"session": ssh.DefaultSessionHandler,
},
ConnectionFailedCallback: func(conn net.Conn, err error) {
s.logger.Warn(ctx, "ssh connection failed",
slog.F("remote_addr", conn.RemoteAddr()),
slog.F("local_addr", conn.LocalAddr()),
slog.Error(err))
metrics.failedConnectionsTotal.Add(1)
},
ConnectionCompleteCallback: func(conn *gossh.ServerConn, err error) {
s.logger.Info(ctx, "ssh connection complete",
slog.F("remote_addr", conn.RemoteAddr()),
slog.F("local_addr", conn.LocalAddr()),
slog.Error(err))
},
Handler: s.sessionHandler,
HostSigners: []ssh.Signer{randomSigner},
LocalPortForwardingCallback: func(ctx ssh.Context, destinationHost string, destinationPort uint32) bool {
// Allow local port forwarding all!
s.logger.Debug(ctx, "local port forward",
slog.F("destination_host", destinationHost),
slog.F("destination_port", destinationPort))
return true
},
PtyCallback: func(ctx ssh.Context, pty ssh.Pty) bool {
return true
},
ReversePortForwardingCallback: func(ctx ssh.Context, bindHost string, bindPort uint32) bool {
// Allow reverse port forwarding all!
s.logger.Debug(ctx, "local port forward",
slog.F("bind_host", bindHost),
slog.F("bind_port", bindPort))
return true
},
RequestHandlers: map[string]ssh.RequestHandler{
"tcpip-forward": forwardHandler.HandleSSHRequest,
"cancel-tcpip-forward": forwardHandler.HandleSSHRequest,
"streamlocal-forward@openssh.com": unixForwardHandler.HandleSSHRequest,
"cancel-streamlocal-forward@openssh.com": unixForwardHandler.HandleSSHRequest,
},
X11Callback: s.x11Callback,
ServerConfigCallback: func(ctx ssh.Context) *gossh.ServerConfig {
return &gossh.ServerConfig{
NoClientAuth: true,
}
},
SubsystemHandlers: map[string]ssh.SubsystemHandler{
"sftp": s.sessionHandler,
},
}
// The MaxTimeout functionality has been substituted with the introduction of the KeepAlive feature.
// In cases where very short timeouts are set, the SSH server will automatically switch to the connection timeout for both read and write operations.
if maxTimeout >= 3*time.Second {
srv.ClientAliveCountMax = 3
srv.ClientAliveInterval = maxTimeout / time.Duration(srv.ClientAliveCountMax)
srv.MaxTimeout = 0
} else {
srv.MaxTimeout = maxTimeout
}
s.srv = srv
return s, nil
}
type ConnStats struct {
Sessions int64
VSCode int64
JetBrains int64
}
func (s *Server) ConnStats() ConnStats {
return ConnStats{
Sessions: s.connCountSSHSession.Load(),
VSCode: s.connCountVSCode.Load(),
JetBrains: s.connCountJetBrains.Load(),
}
}
func (s *Server) sessionHandler(session ssh.Session) {
logger := s.logger.With(slog.F("remote_addr", session.RemoteAddr()), slog.F("local_addr", session.LocalAddr()))
logger.Info(session.Context(), "handling ssh session")
ctx := session.Context()
if !s.trackSession(session, true) {
// See (*Server).Close() for why we call Close instead of Exit.
_ = session.Close()
logger.Info(ctx, "unable to accept new session, server is closing")
return
}
defer s.trackSession(session, false)
extraEnv := make([]string, 0)
x11, hasX11 := session.X11()
if hasX11 {
handled := s.x11Handler(session.Context(), x11)
if !handled {
_ = session.Exit(1)
logger.Error(ctx, "x11 handler failed")
return
}
extraEnv = append(extraEnv, fmt.Sprintf("DISPLAY=:%d.0", x11.ScreenNumber))
}
switch ss := session.Subsystem(); ss {
case "":
case "sftp":
s.sftpHandler(session)
return
default:
logger.Warn(ctx, "unsupported subsystem", slog.F("subsystem", ss))
_ = session.Exit(1)
return
}
err := s.sessionStart(session, extraEnv)
var exitError *exec.ExitError
if xerrors.As(err, &exitError) {
logger.Info(ctx, "ssh session returned", slog.Error(exitError))
_ = session.Exit(exitError.ExitCode())
return
}
if err != nil {
logger.Warn(ctx, "ssh session failed", slog.Error(err))
// This exit code is designed to be unlikely to be confused for a legit exit code
// from the process.
_ = session.Exit(MagicSessionErrorCode)
return
}
logger.Info(ctx, "normal ssh session exit")
_ = session.Exit(0)
}
func (s *Server) sessionStart(session ssh.Session, extraEnv []string) (retErr error) {
ctx := session.Context()
env := append(session.Environ(), extraEnv...)
var magicType string
for index, kv := range env {
if !strings.HasPrefix(kv, MagicSessionTypeEnvironmentVariable) {
continue
}
magicType = strings.TrimPrefix(kv, MagicSessionTypeEnvironmentVariable+"=")
env = append(env[:index], env[index+1:]...)
}
switch magicType {
case MagicSessionTypeVSCode:
s.connCountVSCode.Add(1)
defer s.connCountVSCode.Add(-1)
case MagicSessionTypeJetBrains:
s.connCountJetBrains.Add(1)
defer s.connCountJetBrains.Add(-1)
case "":
s.connCountSSHSession.Add(1)
defer s.connCountSSHSession.Add(-1)
default:
s.logger.Warn(ctx, "invalid magic ssh session type specified", slog.F("type", magicType))
}
magicTypeLabel := magicTypeMetricLabel(magicType)
sshPty, windowSize, isPty := session.Pty()
cmd, err := s.CreateCommand(ctx, session.RawCommand(), env)
if err != nil {
ptyLabel := "no"
if isPty {
ptyLabel = "yes"
}
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, ptyLabel, "create_command").Add(1)
return err
}
if ssh.AgentRequested(session) {
l, err := ssh.NewAgentListener()
if err != nil {
ptyLabel := "no"
if isPty {
ptyLabel = "yes"
}
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, ptyLabel, "listener").Add(1)
return xerrors.Errorf("new agent listener: %w", err)
}
defer l.Close()
go ssh.ForwardAgentConnections(l, session)
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", "SSH_AUTH_SOCK", l.Addr().String()))
}
if isPty {
return s.startPTYSession(session, magicTypeLabel, cmd, sshPty, windowSize)
}
return s.startNonPTYSession(session, magicTypeLabel, cmd.AsExec())
}
func (s *Server) startNonPTYSession(session ssh.Session, magicTypeLabel string, cmd *exec.Cmd) error {
s.metrics.sessionsTotal.WithLabelValues(magicTypeLabel, "no").Add(1)
cmd.Stdout = session
cmd.Stderr = session.Stderr()
// This blocks forever until stdin is received if we don't
// use StdinPipe. It's unknown what causes this.
stdinPipe, err := cmd.StdinPipe()
if err != nil {
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, "no", "stdin_pipe").Add(1)
return xerrors.Errorf("create stdin pipe: %w", err)
}
go func() {
_, err := io.Copy(stdinPipe, session)
if err != nil {
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, "no", "stdin_io_copy").Add(1)
}
_ = stdinPipe.Close()
}()
err = cmd.Start()
if err != nil {
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, "no", "start_command").Add(1)
return xerrors.Errorf("start: %w", err)
}
return cmd.Wait()
}
// ptySession is the interface to the ssh.Session that startPTYSession uses
// we use an interface here so that we can fake it in tests.
type ptySession interface {
io.ReadWriter
Context() ssh.Context
DisablePTYEmulation()
RawCommand() string
}
func (s *Server) startPTYSession(session ptySession, magicTypeLabel string, cmd *pty.Cmd, sshPty ssh.Pty, windowSize <-chan ssh.Window) (retErr error) {
s.metrics.sessionsTotal.WithLabelValues(magicTypeLabel, "yes").Add(1)
ctx := session.Context()
// Disable minimal PTY emulation set by gliderlabs/ssh (NL-to-CRNL).
// See https://github.com/coder/coder/issues/3371.
session.DisablePTYEmulation()
if isLoginShell(session.RawCommand()) {
serviceBanner := s.ServiceBanner.Load()
if serviceBanner != nil {
err := showServiceBanner(session, serviceBanner)
if err != nil {
s.logger.Error(ctx, "agent failed to show service banner", slog.Error(err))
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, "yes", "service_banner").Add(1)
}
}
}
if !isQuietLogin(session.RawCommand()) {
manifest := s.Manifest.Load()
if manifest != nil {
err := showMOTD(session, manifest.MOTDFile)
if err != nil {
s.logger.Error(ctx, "agent failed to show MOTD", slog.Error(err))
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, "yes", "motd").Add(1)
}
} else {
s.logger.Warn(ctx, "metadata lookup failed, unable to show MOTD")
}
}
cmd.Env = append(cmd.Env, fmt.Sprintf("TERM=%s", sshPty.Term))
// The pty package sets `SSH_TTY` on supported platforms.
ptty, process, err := pty.Start(cmd, pty.WithPTYOption(
pty.WithSSHRequest(sshPty),
pty.WithLogger(slog.Stdlib(ctx, s.logger, slog.LevelInfo)),
))
if err != nil {
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, "yes", "start_command").Add(1)
return xerrors.Errorf("start command: %w", err)
}
defer func() {
closeErr := ptty.Close()
if closeErr != nil {
s.logger.Warn(ctx, "failed to close tty", slog.Error(closeErr))
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, "yes", "close").Add(1)
if retErr == nil {
retErr = closeErr
}
}
}()
go func() {
for win := range windowSize {
resizeErr := ptty.Resize(uint16(win.Height), uint16(win.Width))
// If the pty is closed, then command has exited, no need to log.
if resizeErr != nil && !errors.Is(resizeErr, pty.ErrClosed) {
s.logger.Warn(ctx, "failed to resize tty", slog.Error(resizeErr))
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, "yes", "resize").Add(1)
}
}
}()
go func() {
_, err := io.Copy(ptty.InputWriter(), session)
if err != nil {
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, "yes", "input_io_copy").Add(1)
}
}()
// We need to wait for the command output to finish copying. It's safe to
// just do this copy on the main handler goroutine because one of two things
// will happen:
//
// 1. The command completes & closes the TTY, which then triggers an error
// after we've Read() all the buffered data from the PTY.
// 2. The client hangs up, which cancels the command's Context, and go will
// kill the command's process. This then has the same effect as (1).
n, err := io.Copy(session, ptty.OutputReader())
s.logger.Debug(ctx, "copy output done", slog.F("bytes", n), slog.Error(err))
if err != nil {
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, "yes", "output_io_copy").Add(1)
return xerrors.Errorf("copy error: %w", err)
}
// We've gotten all the output, but we need to wait for the process to
// complete so that we can get the exit code. This returns
// immediately if the TTY was closed as part of the command exiting.
err = process.Wait()
var exitErr *exec.ExitError
// ExitErrors just mean the command we run returned a non-zero exit code, which is normal
// and not something to be concerned about. But, if it's something else, we should log it.
if err != nil && !xerrors.As(err, &exitErr) {
s.logger.Warn(ctx, "process wait exited with error", slog.Error(err))
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel, "yes", "wait").Add(1)
}
if err != nil {
return xerrors.Errorf("process wait: %w", err)
}
return nil
}
func (s *Server) sftpHandler(session ssh.Session) {
s.metrics.sftpConnectionsTotal.Add(1)
ctx := session.Context()
// Typically sftp sessions don't request a TTY, but if they do,
// we must ensure the gliderlabs/ssh CRLF emulation is disabled.
// Otherwise sftp will be broken. This can happen if a user sets
// `RequestTTY force` in their SSH config.
session.DisablePTYEmulation()
var opts []sftp.ServerOption
// Change current working directory to the users home
// directory so that SFTP connections land there.
homedir, err := userHomeDir()
if err != nil {
s.logger.Warn(ctx, "get sftp working directory failed, unable to get home dir", slog.Error(err))
} else {
opts = append(opts, sftp.WithServerWorkingDirectory(homedir))
}
server, err := sftp.NewServer(session, opts...)
if err != nil {
s.logger.Debug(ctx, "initialize sftp server", slog.Error(err))
return
}
defer server.Close()
err = server.Serve()
if errors.Is(err, io.EOF) {
// Unless we call `session.Exit(0)` here, the client won't
// receive `exit-status` because `(*sftp.Server).Close()`
// calls `Close()` on the underlying connection (session),
// which actually calls `channel.Close()` because it isn't
// wrapped. This causes sftp clients to receive a non-zero
// exit code. Typically sftp clients don't echo this exit
// code but `scp` on macOS does (when using the default
// SFTP backend).
_ = session.Exit(0)
return
}
s.logger.Warn(ctx, "sftp server closed with error", slog.Error(err))
s.metrics.sftpServerErrors.Add(1)
_ = session.Exit(1)
}
// CreateCommand processes raw command input with OpenSSH-like behavior.
// If the script provided is empty, it will default to the users shell.
// This injects environment variables specified by the user at launch too.
func (s *Server) CreateCommand(ctx context.Context, script string, env []string) (*pty.Cmd, error) {
currentUser, err := user.Current()
if err != nil {
return nil, xerrors.Errorf("get current user: %w", err)
}
username := currentUser.Username
shell, err := usershell.Get(username)
if err != nil {
return nil, xerrors.Errorf("get user shell: %w", err)
}
manifest := s.Manifest.Load()
if manifest == nil {
return nil, xerrors.Errorf("no metadata was provided")
}
// OpenSSH executes all commands with the users current shell.
// We replicate that behavior for IDE support.
caller := "-c"
if runtime.GOOS == "windows" {
caller = "/c"
}
args := []string{caller, script}
// gliderlabs/ssh returns a command slice of zero
// when a shell is requested.
if len(script) == 0 {
args = []string{}
if runtime.GOOS != "windows" {
// On Linux and macOS, we should start a login
// shell to consume juicy environment variables!
args = append(args, "-l")
}
}
cmd := pty.CommandContext(ctx, shell, args...)
cmd.Dir = manifest.Directory
// If the metadata directory doesn't exist, we run the command
// in the users home directory.
_, err = os.Stat(cmd.Dir)
if cmd.Dir == "" || err != nil {
// Default to user home if a directory is not set.
homedir, err := userHomeDir()
if err != nil {
return nil, xerrors.Errorf("get home dir: %w", err)
}
cmd.Dir = homedir
}
cmd.Env = append(os.Environ(), env...)
executablePath, err := os.Executable()
if err != nil {
return nil, xerrors.Errorf("getting os executable: %w", err)
}
// Set environment variables reliable detection of being inside a
// Coder workspace.
cmd.Env = append(cmd.Env, "CODER=true")
cmd.Env = append(cmd.Env, fmt.Sprintf("USER=%s", username))
// Git on Windows resolves with UNIX-style paths.
// If using backslashes, it's unable to find the executable.
unixExecutablePath := strings.ReplaceAll(executablePath, "\\", "/")
cmd.Env = append(cmd.Env, fmt.Sprintf(`GIT_SSH_COMMAND=%s gitssh --`, unixExecutablePath))
// Specific Coder subcommands require the agent token exposed!
cmd.Env = append(cmd.Env, fmt.Sprintf("CODER_AGENT_TOKEN=%s", s.AgentToken()))
// Set SSH connection environment variables (these are also set by OpenSSH
// and thus expected to be present by SSH clients). Since the agent does
// networking in-memory, trying to provide accurate values here would be
// nonsensical. For now, we hard code these values so that they're present.
srcAddr, srcPort := "0.0.0.0", "0"
dstAddr, dstPort := "0.0.0.0", "0"
cmd.Env = append(cmd.Env, fmt.Sprintf("SSH_CLIENT=%s %s %s", srcAddr, srcPort, dstPort))
cmd.Env = append(cmd.Env, fmt.Sprintf("SSH_CONNECTION=%s %s %s %s", srcAddr, srcPort, dstAddr, dstPort))
// This adds the ports dialog to code-server that enables
// proxying a port dynamically.
cmd.Env = append(cmd.Env, fmt.Sprintf("VSCODE_PROXY_URI=%s", manifest.VSCodePortProxyURI))
// Hide Coder message on code-server's "Getting Started" page
cmd.Env = append(cmd.Env, "CS_DISABLE_GETTING_STARTED_OVERRIDE=true")
// Load environment variables passed via the agent.
// These should override all variables we manually specify.
for envKey, value := range manifest.EnvironmentVariables {
// Expanding environment variables allows for customization
// of the $PATH, among other variables. Customers can prepend
// or append to the $PATH, so allowing expand is required!
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", envKey, os.ExpandEnv(value)))
}
// Agent-level environment variables should take over all!
// This is used for setting agent-specific variables like "CODER_AGENT_TOKEN".
for envKey, value := range s.Env {
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", envKey, value))
}
return cmd, nil
}
func (s *Server) Serve(l net.Listener) (retErr error) {
s.logger.Info(context.Background(), "started serving listener", slog.F("listen_addr", l.Addr()))
defer func() {
s.logger.Info(context.Background(), "stopped serving listener",
slog.F("listen_addr", l.Addr()), slog.Error(retErr))
}()
defer l.Close()
s.trackListener(l, true)
defer s.trackListener(l, false)
for {
conn, err := l.Accept()
if err != nil {
return err
}
go s.handleConn(l, conn)
}
}
func (s *Server) handleConn(l net.Listener, c net.Conn) {
logger := s.logger.With(
slog.F("remote_addr", c.RemoteAddr()),
slog.F("local_addr", c.LocalAddr()),
slog.F("listen_addr", l.Addr()))
defer c.Close()
if !s.trackConn(l, c, true) {
// Server is closed or we no longer want
// connections from this listener.
logger.Info(context.Background(), "received connection after server closed")
return
}
defer s.trackConn(l, c, false)
logger.Info(context.Background(), "started serving connection")
// note: srv.ConnectionCompleteCallback logs completion of the connection
s.srv.HandleConn(c)
}
// trackListener registers the listener with the server. If the server is
// closing, the function will block until the server is closed.
//
//nolint:revive
func (s *Server) trackListener(l net.Listener, add bool) {
s.mu.Lock()
defer s.mu.Unlock()
if add {
for s.closing != nil {
closing := s.closing
// Wait until close is complete before
// serving a new listener.
s.mu.Unlock()
<-closing
s.mu.Lock()
}
s.wg.Add(1)
s.listeners[l] = struct{}{}
return
}
s.wg.Done()
delete(s.listeners, l)
}
// trackConn registers the connection with the server. If the server is
// closed or the listener is closed, the connection is not registered
// and should be closed.
//
//nolint:revive
func (s *Server) trackConn(l net.Listener, c net.Conn, add bool) (ok bool) {
s.mu.Lock()
defer s.mu.Unlock()
if add {
found := false
for ll := range s.listeners {
if l == ll {
found = true
break
}
}
if s.closing != nil || !found {
// Server or listener closed.
return false
}
s.wg.Add(1)
s.conns[c] = struct{}{}
return true
}
s.wg.Done()
delete(s.conns, c)
return true
}
// trackSession registers the session with the server. If the server is
// closing, the session is not registered and should be closed.
//
//nolint:revive
func (s *Server) trackSession(ss ssh.Session, add bool) (ok bool) {
s.mu.Lock()
defer s.mu.Unlock()
if add {
if s.closing != nil {
// Server closed.
return false
}
s.wg.Add(1)
s.sessions[ss] = struct{}{}
return true
}
s.wg.Done()
delete(s.sessions, ss)
return true
}
// Close the server and all active connections. Server can be re-used
// after Close is done.
func (s *Server) Close() error {
s.mu.Lock()
// Guard against multiple calls to Close and
// accepting new connections during close.
if s.closing != nil {
s.mu.Unlock()
return xerrors.New("server is closing")
}
s.closing = make(chan struct{})
// Close all active sessions to gracefully
// terminate client connections.
for ss := range s.sessions {
// We call Close on the underlying channel here because we don't
// want to send an exit status to the client (via Exit()).
// Typically OpenSSH clients will return 255 as the exit status.
_ = ss.Close()
}
// Close all active listeners and connections.
for l := range s.listeners {
_ = l.Close()
}
for c := range s.conns {
_ = c.Close()
}
// Close the underlying SSH server.
err := s.srv.Close()
s.mu.Unlock()
s.wg.Wait() // Wait for all goroutines to exit.
s.mu.Lock()
close(s.closing)
s.closing = nil
s.mu.Unlock()
return err
}
// Shutdown gracefully closes all active SSH connections and stops
// accepting new connections.
//
// Shutdown is not implemented.
func (*Server) Shutdown(_ context.Context) error {
// TODO(mafredri): Implement shutdown, SIGHUP running commands, etc.
return nil
}
func isLoginShell(rawCommand string) bool {
return len(rawCommand) == 0
}
// isQuietLogin checks if the SSH server should perform a quiet login or not.
//
// https://github.com/openssh/openssh-portable/blob/25bd659cc72268f2858c5415740c442ee950049f/session.c#L816
func isQuietLogin(rawCommand string) bool {
// We are always quiet unless this is a login shell.
if !isLoginShell(rawCommand) {
return true
}
// Best effort, if we can't get the home directory,
// we can't lookup .hushlogin.
homedir, err := userHomeDir()
if err != nil {
return false
}
_, err = os.Stat(filepath.Join(homedir, ".hushlogin"))
return err == nil
}
// showServiceBanner will write the service banner if enabled and not blank
// along with a blank line for spacing.
func showServiceBanner(session io.Writer, banner *codersdk.ServiceBannerConfig) error {
if banner.Enabled && banner.Message != "" {
// The banner supports Markdown so we might want to parse it but Markdown is
// still fairly readable in its raw form.
message := strings.TrimSpace(banner.Message) + "\n\n"
return writeWithCarriageReturn(strings.NewReader(message), session)
}
return nil
}
// showMOTD will output the message of the day from
// the given filename to dest, if the file exists.
//
// https://github.com/openssh/openssh-portable/blob/25bd659cc72268f2858c5415740c442ee950049f/session.c#L784
func showMOTD(dest io.Writer, filename string) error {
if filename == "" {
return nil
}
f, err := os.Open(filename)
if err != nil {
if xerrors.Is(err, os.ErrNotExist) {
// This is not an error, there simply isn't a MOTD to show.
return nil
}
return xerrors.Errorf("open MOTD: %w", err)
}
defer f.Close()
return writeWithCarriageReturn(f, dest)
}
// writeWithCarriageReturn writes each line with a carriage return to ensure
// that each line starts at the beginning of the terminal.
func writeWithCarriageReturn(src io.Reader, dest io.Writer) error {
s := bufio.NewScanner(src)
for s.Scan() {
_, err := fmt.Fprint(dest, s.Text()+"\r\n")
if err != nil {
return xerrors.Errorf("write line: %w", err)
}
}
if err := s.Err(); err != nil {
return xerrors.Errorf("read line: %w", err)
}
return nil
}
// userHomeDir returns the home directory of the current user, giving
// priority to the $HOME environment variable.
func userHomeDir() (string, error) {
// First we check the environment.
homedir, err := os.UserHomeDir()
if err == nil {
return homedir, nil
}
// As a fallback, we try the user information.
u, err := user.Current()
if err != nil {
return "", xerrors.Errorf("current user: %w", err)
}
return u.HomeDir, nil
}
+197
View File
@@ -0,0 +1,197 @@
//go:build !windows
package agentssh
import (
"bufio"
"context"
"io"
"net"
"testing"
gliderssh "github.com/gliderlabs/ssh"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/pty"
"github.com/coder/coder/testutil"
"cdr.dev/slog/sloggers/slogtest"
)
const longScript = `
echo "started"
sleep 30
echo "done"
`
// Test_sessionStart_orphan tests running a command that takes a long time to
// exit normally, and terminate the SSH session context early to verify that we
// return quickly and don't leave the command running as an "orphan" with no
// active SSH session.
func Test_sessionStart_orphan(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
defer cancel()
logger := slogtest.Make(t, nil)
s, err := NewServer(ctx, logger, prometheus.NewRegistry(), afero.NewMemMapFs(), 0, "")
require.NoError(t, err)
defer s.Close()
// Here we're going to call the handler directly with a faked SSH session
// that just uses io.Pipes instead of a network socket. There is a large
// variation in the time between closing the socket from the client side and
// the SSH server canceling the session Context, which would lead to a flaky
// test if we did it that way. So instead, we directly cancel the context
// in this test.
sessionCtx, sessionCancel := context.WithCancel(ctx)
toClient, fromClient, sess := newTestSession(sessionCtx)
ptyInfo := gliderssh.Pty{}
windowSize := make(chan gliderssh.Window)
close(windowSize)
// the command gets the session context so that Go will terminate it when
// the session expires.
cmd := pty.CommandContext(sessionCtx, "sh", "-c", longScript)
done := make(chan struct{})
go func() {
defer close(done)
// we don't really care what the error is here. In the larger scenario,
// the client has disconnected, so we can't return any error information
// to them.
_ = s.startPTYSession(sess, "ssh", cmd, ptyInfo, windowSize)
}()
readDone := make(chan struct{})
go func() {
defer close(readDone)
s := bufio.NewScanner(toClient)
assert.True(t, s.Scan())
txt := s.Text()
assert.Equal(t, "started", txt, "output corrupted")
}()
waitForChan(ctx, t, readDone, "read timeout")
// process is started, and should be sleeping for ~30 seconds
sessionCancel()
// now, we wait for the handler to complete. If it does so before the
// main test timeout, we consider this a pass. If not, it indicates
// that the server isn't properly shutting down sessions when they are
// disconnected client side, which could lead to processes hanging around
// indefinitely.
waitForChan(ctx, t, done, "handler timeout")
err = fromClient.Close()
require.NoError(t, err)
}
func waitForChan(ctx context.Context, t *testing.T, c <-chan struct{}, msg string) {
t.Helper()
select {
case <-c:
// OK!
case <-ctx.Done():
t.Fatal(msg)
}
}
type testSession struct {
ctx testSSHContext
// c2p is the client -> pty buffer
toPty *io.PipeReader
// p2c is the pty -> client buffer
fromPty *io.PipeWriter
}
type testSSHContext struct {
context.Context
}
func newTestSession(ctx context.Context) (toClient *io.PipeReader, fromClient *io.PipeWriter, s ptySession) {
toClient, fromPty := io.Pipe()
toPty, fromClient := io.Pipe()
return toClient, fromClient, &testSession{
ctx: testSSHContext{ctx},
toPty: toPty,
fromPty: fromPty,
}
}
func (s *testSession) Context() gliderssh.Context {
return s.ctx
}
func (*testSession) DisablePTYEmulation() {}
// RawCommand returns "quiet logon" so that the PTY handler doesn't attempt to
// write the message of the day, which will interfere with our tests. It writes
// the message of the day if it's a shell login (zero length RawCommand()).
func (*testSession) RawCommand() string { return "quiet logon" }
func (s *testSession) Read(p []byte) (n int, err error) {
return s.toPty.Read(p)
}
func (s *testSession) Write(p []byte) (n int, err error) {
return s.fromPty.Write(p)
}
func (testSSHContext) Lock() {
panic("not implemented")
}
func (testSSHContext) Unlock() {
panic("not implemented")
}
// User returns the username used when establishing the SSH connection.
func (testSSHContext) User() string {
panic("not implemented")
}
// SessionID returns the session hash.
func (testSSHContext) SessionID() string {
panic("not implemented")
}
// ClientVersion returns the version reported by the client.
func (testSSHContext) ClientVersion() string {
panic("not implemented")
}
// ServerVersion returns the version reported by the server.
func (testSSHContext) ServerVersion() string {
panic("not implemented")
}
// RemoteAddr returns the remote address for this connection.
func (testSSHContext) RemoteAddr() net.Addr {
panic("not implemented")
}
// LocalAddr returns the local address for this connection.
func (testSSHContext) LocalAddr() net.Addr {
panic("not implemented")
}
// Permissions returns the Permissions object used for this connection.
func (testSSHContext) Permissions() *gliderssh.Permissions {
panic("not implemented")
}
// SetValue allows you to easily write new values into the underlying context.
func (testSSHContext) SetValue(_, _ interface{}) {
panic("not implemented")
}
func (testSSHContext) KeepAlive() *gliderssh.SessionKeepAlive {
panic("not implemented")
}
+144
View File
@@ -0,0 +1,144 @@
// Package agentssh_test provides tests for basic functinoality of the agentssh
// package, more test coverage can be found in the `agent` and `cli` package(s).
package agentssh_test
import (
"bytes"
"context"
"net"
"strings"
"sync"
"testing"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"
"go.uber.org/goleak"
"golang.org/x/crypto/ssh"
"cdr.dev/slog/sloggers/slogtest"
"github.com/coder/coder/agent/agentssh"
"github.com/coder/coder/codersdk/agentsdk"
"github.com/coder/coder/pty/ptytest"
)
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
func TestNewServer_ServeClient(t *testing.T) {
t.Parallel()
ctx := context.Background()
logger := slogtest.Make(t, nil)
s, err := agentssh.NewServer(ctx, logger, prometheus.NewRegistry(), afero.NewMemMapFs(), 0, "")
require.NoError(t, err)
defer s.Close()
// The assumption is that these are set before serving SSH connections.
s.AgentToken = func() string { return "" }
s.Manifest = atomic.NewPointer(&agentsdk.Manifest{})
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.
}()
c := sshClient(t, ln.Addr().String())
var b bytes.Buffer
sess, err := c.NewSession()
sess.Stdout = &b
require.NoError(t, err)
err = sess.Start("echo hello")
require.NoError(t, err)
err = sess.Wait()
require.NoError(t, err)
require.Equal(t, "hello", strings.TrimSpace(b.String()))
err = s.Close()
require.NoError(t, err)
<-done
}
func TestNewServer_CloseActiveConnections(t *testing.T) {
t.Parallel()
ctx := context.Background()
logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
s, err := agentssh.NewServer(ctx, logger, prometheus.NewRegistry(), afero.NewMemMapFs(), 0, "")
require.NoError(t, err)
defer s.Close()
// The assumption is that these are set before serving SSH connections.
s.AgentToken = func() string { return "" }
s.Manifest = atomic.NewPointer(&agentsdk.Manifest{})
ln, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()
err := s.Serve(ln)
assert.Error(t, err) // Server is closed.
}()
pty := ptytest.New(t)
doClose := make(chan struct{})
go func() {
defer wg.Done()
c := sshClient(t, ln.Addr().String())
sess, err := c.NewSession()
sess.Stdin = pty.Input()
sess.Stdout = pty.Output()
sess.Stderr = pty.Output()
assert.NoError(t, err)
err = sess.Start("")
assert.NoError(t, err)
close(doClose)
err = sess.Wait()
assert.Error(t, err)
}()
<-doClose
err = s.Close()
require.NoError(t, err)
wg.Wait()
}
func sshClient(t *testing.T, addr string) *ssh.Client {
conn, err := net.Dial("tcp", addr)
require.NoError(t, err)
t.Cleanup(func() {
_ = conn.Close()
})
sshConn, channels, requests, err := ssh.NewClientConn(conn, "localhost:22", &ssh.ClientConfig{
HostKeyCallback: ssh.InsecureIgnoreHostKey(), //nolint:gosec // This is a test.
})
require.NoError(t, err)
t.Cleanup(func() {
_ = sshConn.Close()
})
c := ssh.NewClient(sshConn, channels, requests)
t.Cleanup(func() {
_ = c.Close()
})
return c
}
+47
View File
@@ -0,0 +1,47 @@
package agentssh
import (
"context"
"io"
"sync"
)
// Bicopy copies all of the data between the two connections and will close them
// after one or both of them are done writing. If the context is canceled, both
// of the connections will be closed.
func Bicopy(ctx context.Context, c1, c2 io.ReadWriteCloser) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
defer func() {
_ = c1.Close()
_ = c2.Close()
}()
var wg sync.WaitGroup
copyFunc := func(dst io.WriteCloser, src io.Reader) {
defer func() {
wg.Done()
// If one side of the copy fails, ensure the other one exits as
// well.
cancel()
}()
_, _ = io.Copy(dst, src)
}
wg.Add(2)
go copyFunc(c1, c2)
go copyFunc(c2, c1)
// Convert waitgroup to a channel so we can also wait on the context.
done := make(chan struct{})
go func() {
defer close(done)
wg.Wait()
}()
select {
case <-ctx.Done():
case <-done:
}
}
+203
View File
@@ -0,0 +1,203 @@
package agentssh
import (
"context"
"fmt"
"net"
"os"
"path/filepath"
"sync"
"github.com/gliderlabs/ssh"
gossh "golang.org/x/crypto/ssh"
"golang.org/x/xerrors"
"cdr.dev/slog"
)
// streamLocalForwardPayload describes the extra data sent in a
// streamlocal-forward@openssh.com containing the socket path to bind to.
type streamLocalForwardPayload struct {
SocketPath string
}
// forwardedStreamLocalPayload describes the data sent as the payload in the new
// channel request when a Unix connection is accepted by the listener.
type forwardedStreamLocalPayload struct {
SocketPath string
Reserved uint32
}
// forwardedUnixHandler is a clone of ssh.ForwardedTCPHandler that does
// streamlocal forwarding (aka. unix forwarding) instead of TCP forwarding.
type forwardedUnixHandler struct {
sync.Mutex
log slog.Logger
forwards map[string]net.Listener
}
func (h *forwardedUnixHandler) HandleSSHRequest(ctx ssh.Context, _ *ssh.Server, req *gossh.Request) (bool, []byte) {
h.Lock()
if h.forwards == nil {
h.forwards = make(map[string]net.Listener)
}
h.Unlock()
conn, ok := ctx.Value(ssh.ContextKeyConn).(*gossh.ServerConn)
if !ok {
h.log.Warn(ctx, "SSH unix forward request from client with no gossh connection")
return false, nil
}
switch req.Type {
case "streamlocal-forward@openssh.com":
var reqPayload streamLocalForwardPayload
err := gossh.Unmarshal(req.Payload, &reqPayload)
if err != nil {
h.log.Warn(ctx, "parse streamlocal-forward@openssh.com request payload from client", slog.Error(err))
return false, nil
}
addr := reqPayload.SocketPath
h.Lock()
_, ok := h.forwards[addr]
h.Unlock()
if ok {
h.log.Warn(ctx, "SSH unix forward request for socket path that is already being forwarded (maybe to another client?)",
slog.F("socket_path", addr),
)
return false, nil
}
// Create socket parent dir if not exists.
parentDir := filepath.Dir(addr)
err = os.MkdirAll(parentDir, 0o700)
if err != nil {
h.log.Warn(ctx, "create parent dir for SSH unix forward request",
slog.F("parent_dir", parentDir),
slog.F("socket_path", addr),
slog.Error(err),
)
return false, nil
}
ln, err := net.Listen("unix", addr)
if err != nil {
h.log.Warn(ctx, "listen on Unix socket for SSH unix forward request",
slog.F("socket_path", addr),
slog.Error(err),
)
return false, nil
}
// The listener needs to successfully start before it can be added to
// the map, so we don't have to worry about checking for an existing
// listener.
//
// This is also what the upstream TCP version of this code does.
h.Lock()
h.forwards[addr] = ln
h.Unlock()
ctx, cancel := context.WithCancel(ctx)
go func() {
<-ctx.Done()
_ = ln.Close()
}()
go func() {
defer cancel()
for {
c, err := ln.Accept()
if err != nil {
if !xerrors.Is(err, net.ErrClosed) {
h.log.Warn(ctx, "accept on local Unix socket for SSH unix forward request",
slog.F("socket_path", addr),
slog.Error(err),
)
}
// closed below
break
}
payload := gossh.Marshal(&forwardedStreamLocalPayload{
SocketPath: addr,
})
go func() {
ch, reqs, err := conn.OpenChannel("forwarded-streamlocal@openssh.com", payload)
if err != nil {
h.log.Warn(ctx, "open SSH channel to forward Unix connection to client",
slog.F("socket_path", addr),
slog.Error(err),
)
_ = c.Close()
return
}
go gossh.DiscardRequests(reqs)
Bicopy(ctx, ch, c)
}()
}
h.Lock()
ln2, ok := h.forwards[addr]
if ok && ln2 == ln {
delete(h.forwards, addr)
}
h.Unlock()
_ = ln.Close()
}()
return true, nil
case "cancel-streamlocal-forward@openssh.com":
var reqPayload streamLocalForwardPayload
err := gossh.Unmarshal(req.Payload, &reqPayload)
if err != nil {
h.log.Warn(ctx, "parse cancel-streamlocal-forward@openssh.com request payload from client", slog.Error(err))
return false, nil
}
h.Lock()
ln, ok := h.forwards[reqPayload.SocketPath]
h.Unlock()
if ok {
_ = ln.Close()
}
return true, nil
default:
return false, nil
}
}
// directStreamLocalPayload describes the extra data sent in a
// direct-streamlocal@openssh.com channel request containing the socket path.
type directStreamLocalPayload struct {
SocketPath string
Reserved1 string
Reserved2 uint32
}
func directStreamLocalHandler(_ *ssh.Server, _ *gossh.ServerConn, newChan gossh.NewChannel, ctx ssh.Context) {
var reqPayload directStreamLocalPayload
err := gossh.Unmarshal(newChan.ExtraData(), &reqPayload)
if err != nil {
_ = newChan.Reject(gossh.ConnectionFailed, "could not parse direct-streamlocal@openssh.com channel payload")
return
}
var dialer net.Dialer
dconn, err := dialer.DialContext(ctx, "unix", reqPayload.SocketPath)
if err != nil {
_ = newChan.Reject(gossh.ConnectionFailed, fmt.Sprintf("dial unix socket %q: %+v", reqPayload.SocketPath, err.Error()))
return
}
ch, reqs, err := newChan.Accept()
if err != nil {
_ = dconn.Close()
return
}
go gossh.DiscardRequests(reqs)
Bicopy(ctx, ch, dconn)
}
+82
View File
@@ -0,0 +1,82 @@
package agentssh
import (
"github.com/prometheus/client_golang/prometheus"
)
type sshServerMetrics struct {
failedConnectionsTotal prometheus.Counter
sftpConnectionsTotal prometheus.Counter
sftpServerErrors prometheus.Counter
x11HandlerErrors *prometheus.CounterVec
sessionsTotal *prometheus.CounterVec
sessionErrors *prometheus.CounterVec
}
func newSSHServerMetrics(registerer prometheus.Registerer) *sshServerMetrics {
failedConnectionsTotal := prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "agent", Subsystem: "ssh_server", Name: "failed_connections_total",
})
registerer.MustRegister(failedConnectionsTotal)
sftpConnectionsTotal := prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "agent", Subsystem: "ssh_server", Name: "sftp_connections_total",
})
registerer.MustRegister(sftpConnectionsTotal)
sftpServerErrors := prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "agent", Subsystem: "ssh_server", Name: "sftp_server_errors_total",
})
registerer.MustRegister(sftpServerErrors)
x11HandlerErrors := prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "agent",
Subsystem: "x11_handler",
Name: "errors_total",
},
[]string{"error_type"},
)
registerer.MustRegister(x11HandlerErrors)
sessionsTotal := prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "agent",
Subsystem: "sessions",
Name: "total",
},
[]string{"magic_type", "pty"},
)
registerer.MustRegister(sessionsTotal)
sessionErrors := prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "agent",
Subsystem: "sessions",
Name: "errors_total",
},
[]string{"magic_type", "pty", "error_type"},
)
registerer.MustRegister(sessionErrors)
return &sshServerMetrics{
failedConnectionsTotal: failedConnectionsTotal,
sftpConnectionsTotal: sftpConnectionsTotal,
sftpServerErrors: sftpServerErrors,
x11HandlerErrors: x11HandlerErrors,
sessionsTotal: sessionsTotal,
sessionErrors: sessionErrors,
}
}
func magicTypeMetricLabel(magicType string) string {
switch magicType {
case MagicSessionTypeVSCode:
case MagicSessionTypeJetBrains:
case "":
magicType = "ssh"
default:
magicType = "unknown"
}
return magicType
}
+200
View File
@@ -0,0 +1,200 @@
package agentssh
import (
"context"
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
"net"
"os"
"path/filepath"
"strconv"
"time"
"github.com/gliderlabs/ssh"
"github.com/gofrs/flock"
"github.com/spf13/afero"
gossh "golang.org/x/crypto/ssh"
"golang.org/x/xerrors"
"cdr.dev/slog"
)
// x11Callback is called when the client requests X11 forwarding.
// It adds an Xauthority entry to the Xauthority file.
func (s *Server) x11Callback(ctx ssh.Context, x11 ssh.X11) bool {
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)
return false
}
err = s.fs.MkdirAll(s.x11SocketDir, 0o700)
if err != nil {
s.logger.Warn(ctx, "failed to make the x11 socket dir", slog.F("dir", s.x11SocketDir), slog.Error(err))
s.metrics.x11HandlerErrors.WithLabelValues("socker_dir").Add(1)
return false
}
err = addXauthEntry(ctx, s.fs, hostname, strconv.Itoa(int(x11.ScreenNumber)), 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)
return false
}
return true
}
// 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) bool {
serverConn, valid := ctx.Value(ssh.ContextKeyConn).(*gossh.ServerConn)
if !valid {
s.logger.Warn(ctx, "failed to get server connection")
return false
}
// We want to overwrite the socket so that subsequent connections will succeed.
socketPath := filepath.Join(s.x11SocketDir, fmt.Sprintf("X%d", x11.ScreenNumber))
err := os.Remove(socketPath)
if err != nil && !errors.Is(err, os.ErrNotExist) {
s.logger.Warn(ctx, "failed to remove existing X11 socket", slog.Error(err))
return false
}
listener, err := net.Listen("unix", socketPath)
if err != nil {
s.logger.Warn(ctx, "failed to listen for X11", slog.Error(err))
return false
}
s.trackListener(listener, true)
go func() {
defer listener.Close()
defer s.trackListener(listener, false)
handledFirstConnection := false
for {
conn, err := listener.Accept()
if err != nil {
if errors.Is(err, net.ErrClosed) {
return
}
s.logger.Warn(ctx, "failed to accept X11 connection", slog.Error(err))
return
}
if x11.SingleConnection && handledFirstConnection {
s.logger.Warn(ctx, "X11 connection rejected because single connection is enabled")
_ = conn.Close()
continue
}
handledFirstConnection = true
unixConn, ok := conn.(*net.UnixConn)
if !ok {
s.logger.Warn(ctx, fmt.Sprintf("failed to cast connection to UnixConn. got: %T", conn))
return
}
unixAddr, ok := unixConn.LocalAddr().(*net.UnixAddr)
if !ok {
s.logger.Warn(ctx, fmt.Sprintf("failed to cast local address to UnixAddr. got: %T", unixConn.LocalAddr()))
return
}
channel, reqs, err := serverConn.OpenChannel("x11", gossh.Marshal(struct {
OriginatorAddress string
OriginatorPort uint32
}{
OriginatorAddress: unixAddr.Name,
OriginatorPort: 0,
}))
if err != nil {
s.logger.Warn(ctx, "failed to open X11 channel", slog.Error(err))
return
}
go gossh.DiscardRequests(reqs)
go Bicopy(ctx, conn, channel)
}
}()
return true
}
// 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 {
// Get the Xauthority file path
homeDir, err := os.UserHomeDir()
if err != nil {
return xerrors.Errorf("failed to get user home directory: %w", err)
}
xauthPath := filepath.Join(homeDir, ".Xauthority")
lock := flock.New(xauthPath)
defer lock.Close()
ok, err := lock.TryLockContext(ctx, 100*time.Millisecond)
if !ok {
return xerrors.Errorf("failed to lock Xauthority file: %w", err)
}
if err != nil {
return xerrors.Errorf("failed to lock Xauthority file: %w", err)
}
// Open or create the Xauthority file
file, err := fs.OpenFile(xauthPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o600)
if err != nil {
return xerrors.Errorf("failed to open Xauthority file: %w", err)
}
defer file.Close()
// Convert the authCookie from hex string to byte slice
authCookieBytes, err := hex.DecodeString(authCookie)
if err != nil {
return xerrors.Errorf("failed to decode auth cookie: %w", err)
}
// Write Xauthority entry
family := uint16(0x0100) // FamilyLocal
err = binary.Write(file, binary.BigEndian, family)
if err != nil {
return xerrors.Errorf("failed to write family: %w", err)
}
err = binary.Write(file, binary.BigEndian, uint16(len(host)))
if err != nil {
return xerrors.Errorf("failed to write host length: %w", err)
}
_, err = file.WriteString(host)
if err != nil {
return xerrors.Errorf("failed to write host: %w", err)
}
err = binary.Write(file, binary.BigEndian, uint16(len(display)))
if err != nil {
return xerrors.Errorf("failed to write display length: %w", err)
}
_, err = file.WriteString(display)
if err != nil {
return xerrors.Errorf("failed to write display: %w", err)
}
err = binary.Write(file, binary.BigEndian, uint16(len(authProtocol)))
if err != nil {
return xerrors.Errorf("failed to write auth protocol length: %w", err)
}
_, err = file.WriteString(authProtocol)
if err != nil {
return xerrors.Errorf("failed to write auth protocol: %w", err)
}
err = binary.Write(file, binary.BigEndian, uint16(len(authCookieBytes)))
if err != nil {
return xerrors.Errorf("failed to write auth cookie length: %w", err)
}
_, err = file.Write(authCookieBytes)
if err != nil {
return xerrors.Errorf("failed to write auth cookie: %w", err)
}
return nil
}
+100
View File
@@ -0,0 +1,100 @@
package agentssh_test
import (
"context"
"encoding/hex"
"net"
"os"
"path/filepath"
"runtime"
"testing"
"github.com/gliderlabs/ssh"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"
gossh "golang.org/x/crypto/ssh"
"cdr.dev/slog"
"cdr.dev/slog/sloggers/slogtest"
"github.com/coder/coder/agent/agentssh"
"github.com/coder/coder/codersdk/agentsdk"
"github.com/coder/coder/testutil"
)
func TestServer_X11(t *testing.T) {
t.Parallel()
if runtime.GOOS != "linux" {
t.Skip("X11 forwarding is only supported on Linux")
}
ctx := context.Background()
logger := slogtest.Make(t, nil).Leveled(slog.LevelDebug)
fs := afero.NewOsFs()
dir := t.TempDir()
s, err := agentssh.NewServer(ctx, logger, prometheus.NewRegistry(), fs, 0, dir)
require.NoError(t, err)
defer s.Close()
// The assumption is that these are set before serving SSH connections.
s.AgentToken = func() string { return "" }
s.Manifest = atomic.NewPointer(&agentsdk.Manifest{})
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.
}()
c := sshClient(t, ln.Addr().String())
sess, err := c.NewSession()
require.NoError(t, err)
reply, err := sess.SendRequest("x11-req", true, gossh.Marshal(ssh.X11{
AuthProtocol: "MIT-MAGIC-COOKIE-1",
AuthCookie: hex.EncodeToString([]byte("cookie")),
ScreenNumber: 0,
}))
require.NoError(t, err)
assert.True(t, reply)
err = sess.Shell()
require.NoError(t, err)
x11Chans := c.HandleChannelOpen("x11")
payload := "hello world"
require.Eventually(t, func() bool {
conn, err := net.Dial("unix", filepath.Join(dir, "X0"))
if err == nil {
_, err = conn.Write([]byte(payload))
assert.NoError(t, err)
_ = conn.Close()
}
return err == nil
}, testutil.WaitShort, testutil.IntervalFast)
x11 := <-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()
_ = s.Close()
<-done
// Ensure the Xauthority file was written!
home, err := os.UserHomeDir()
require.NoError(t, err)
_, err = fs.Stat(filepath.Join(home, ".Xauthority"))
require.NoError(t, err)
}
+57
View File
@@ -0,0 +1,57 @@
package agent
import (
"net/http"
"sync"
"time"
"github.com/go-chi/chi"
"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/codersdk"
)
func (a *agent) apiHandler() http.Handler {
r := chi.NewRouter()
r.Get("/", func(rw http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.Response{
Message: "Hello from the agent!",
})
})
// Make a copy to ensure the map is not modified after the handler is
// created.
cpy := make(map[int]string)
for k, b := range a.ignorePorts {
cpy[k] = b
}
lp := &listeningPortsHandler{ignorePorts: cpy}
r.Get("/api/v0/listening-ports", lp.handler)
return r
}
type listeningPortsHandler struct {
mut sync.Mutex
ports []codersdk.WorkspaceAgentListeningPort
mtime time.Time
ignorePorts map[int]string
}
// handler returns a list of listening ports. This is tested by coderd's
// TestWorkspaceAgentListeningPorts test.
func (lp *listeningPortsHandler) handler(rw http.ResponseWriter, r *http.Request) {
ports, err := lp.getListeningPorts()
if err != nil {
httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
Message: "Could not scan for listening ports.",
Detail: err.Error(),
})
return
}
httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.WorkspaceAgentListeningPortsResponse{
Ports: ports,
})
}
+182
View File
@@ -0,0 +1,182 @@
package agent
import (
"context"
"net/http"
"sync"
"time"
"github.com/google/uuid"
"golang.org/x/xerrors"
"cdr.dev/slog"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/codersdk/agentsdk"
"github.com/coder/retry"
)
// WorkspaceAgentApps fetches the workspace apps.
type WorkspaceAgentApps func(context.Context) ([]codersdk.WorkspaceApp, error)
// PostWorkspaceAgentAppHealth updates the workspace app health.
type PostWorkspaceAgentAppHealth func(context.Context, agentsdk.PostAppHealthsRequest) error
// WorkspaceAppHealthReporter is a function that checks and reports the health of the workspace apps until the passed context is canceled.
type WorkspaceAppHealthReporter func(ctx context.Context)
// NewWorkspaceAppHealthReporter creates a WorkspaceAppHealthReporter that reports app health to coderd.
func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.WorkspaceApp, postWorkspaceAgentAppHealth PostWorkspaceAgentAppHealth) WorkspaceAppHealthReporter {
runHealthcheckLoop := func(ctx context.Context) error {
// no need to run this loop if no apps for this workspace.
if len(apps) == 0 {
return nil
}
hasHealthchecksEnabled := false
health := make(map[uuid.UUID]codersdk.WorkspaceAppHealth, 0)
for _, app := range apps {
if app.Health == codersdk.WorkspaceAppHealthDisabled {
continue
}
health[app.ID] = app.Health
hasHealthchecksEnabled = true
}
// no need to run this loop if no health checks are configured.
if !hasHealthchecksEnabled {
return nil
}
// run a ticker for each app health check.
var mu sync.RWMutex
failures := make(map[uuid.UUID]int, 0)
for _, nextApp := range apps {
if !shouldStartTicker(nextApp) {
continue
}
app := nextApp
go func() {
t := time.NewTicker(time.Duration(app.Healthcheck.Interval) * time.Second)
defer t.Stop()
for {
select {
case <-ctx.Done():
return
case <-t.C:
}
// we set the http timeout to the healthcheck interval to prevent getting too backed up.
client := &http.Client{
Timeout: time.Duration(app.Healthcheck.Interval) * time.Second,
}
err := func() error {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, app.Healthcheck.URL, nil)
if err != nil {
return err
}
res, err := client.Do(req)
if err != nil {
return err
}
// successful healthcheck is a non-5XX status code
_ = res.Body.Close()
if res.StatusCode >= http.StatusInternalServerError {
return xerrors.Errorf("error status code: %d", res.StatusCode)
}
return nil
}()
if err != nil {
mu.Lock()
if failures[app.ID] < int(app.Healthcheck.Threshold) {
// increment the failure count and keep status the same.
// we will change it when we hit the threshold.
failures[app.ID]++
} else {
// set to unhealthy if we hit the failure threshold.
// we stop incrementing at the threshold to prevent the failure value from increasing forever.
health[app.ID] = codersdk.WorkspaceAppHealthUnhealthy
}
mu.Unlock()
} else {
mu.Lock()
// we only need one successful health check to be considered healthy.
health[app.ID] = codersdk.WorkspaceAppHealthHealthy
failures[app.ID] = 0
mu.Unlock()
}
t.Reset(time.Duration(app.Healthcheck.Interval) * time.Second)
}
}()
}
mu.Lock()
lastHealth := copyHealth(health)
mu.Unlock()
reportTicker := time.NewTicker(time.Second)
defer reportTicker.Stop()
// every second we check if the health values of the apps have changed
// and if there is a change we will report the new values.
for {
select {
case <-ctx.Done():
return nil
case <-reportTicker.C:
mu.RLock()
changed := healthChanged(lastHealth, health)
mu.RUnlock()
if !changed {
continue
}
mu.Lock()
lastHealth = copyHealth(health)
mu.Unlock()
err := postWorkspaceAgentAppHealth(ctx, agentsdk.PostAppHealthsRequest{
Healths: lastHealth,
})
if err != nil {
logger.Error(ctx, "failed to report workspace app stat", slog.Error(err))
}
}
}
}
return func(ctx context.Context) {
for r := retry.New(time.Second, 30*time.Second); r.Wait(ctx); {
err := runHealthcheckLoop(ctx)
if err == nil || xerrors.Is(err, context.Canceled) || xerrors.Is(err, context.DeadlineExceeded) {
return
}
logger.Error(ctx, "failed running workspace app reporter", slog.Error(err))
}
}
}
func shouldStartTicker(app codersdk.WorkspaceApp) bool {
return app.Healthcheck.URL != "" && app.Healthcheck.Interval > 0 && app.Healthcheck.Threshold > 0
}
func healthChanged(old map[uuid.UUID]codersdk.WorkspaceAppHealth, new map[uuid.UUID]codersdk.WorkspaceAppHealth) bool {
for name, newValue := range new {
oldValue, found := old[name]
if !found {
return true
}
if newValue != oldValue {
return true
}
}
return false
}
func copyHealth(h1 map[uuid.UUID]codersdk.WorkspaceAppHealth) map[uuid.UUID]codersdk.WorkspaceAppHealth {
h2 := make(map[uuid.UUID]codersdk.WorkspaceAppHealth, 0)
for k, v := range h1 {
h2[k] = v
}
return h2
}
+207
View File
@@ -0,0 +1,207 @@
package agent_test
import (
"context"
"net/http"
"net/http/httptest"
"sync"
"sync/atomic"
"testing"
"time"
"github.com/stretchr/testify/require"
"cdr.dev/slog"
"cdr.dev/slog/sloggers/slogtest"
"github.com/coder/coder/agent"
"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/codersdk/agentsdk"
"github.com/coder/coder/testutil"
)
func TestAppHealth_Healthy(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
apps := []codersdk.WorkspaceApp{
{
Slug: "app1",
Healthcheck: codersdk.Healthcheck{},
Health: codersdk.WorkspaceAppHealthDisabled,
},
{
Slug: "app2",
Healthcheck: codersdk.Healthcheck{
// URL: We don't set the URL for this test because the setup will
// create a httptest server for us and set it for us.
Interval: 1,
Threshold: 1,
},
Health: codersdk.WorkspaceAppHealthInitializing,
},
}
handlers := []http.Handler{
nil,
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), w, http.StatusOK, nil)
}),
}
getApps, closeFn := setupAppReporter(ctx, t, apps, handlers)
defer closeFn()
apps, err := getApps(ctx)
require.NoError(t, err)
require.EqualValues(t, codersdk.WorkspaceAppHealthDisabled, apps[0].Health)
require.Eventually(t, func() bool {
apps, err := getApps(ctx)
if err != nil {
return false
}
return apps[1].Health == codersdk.WorkspaceAppHealthHealthy
}, testutil.WaitLong, testutil.IntervalSlow)
}
func TestAppHealth_500(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
apps := []codersdk.WorkspaceApp{
{
Slug: "app2",
Healthcheck: codersdk.Healthcheck{
// URL: We don't set the URL for this test because the setup will
// create a httptest server for us and set it for us.
Interval: 1,
Threshold: 1,
},
Health: codersdk.WorkspaceAppHealthInitializing,
},
}
handlers := []http.Handler{
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), w, http.StatusInternalServerError, nil)
}),
}
getApps, closeFn := setupAppReporter(ctx, t, apps, handlers)
defer closeFn()
require.Eventually(t, func() bool {
apps, err := getApps(ctx)
if err != nil {
return false
}
return apps[0].Health == codersdk.WorkspaceAppHealthUnhealthy
}, testutil.WaitLong, testutil.IntervalSlow)
}
func TestAppHealth_Timeout(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
apps := []codersdk.WorkspaceApp{
{
Slug: "app2",
Healthcheck: codersdk.Healthcheck{
// URL: We don't set the URL for this test because the setup will
// create a httptest server for us and set it for us.
Interval: 1,
Threshold: 1,
},
Health: codersdk.WorkspaceAppHealthInitializing,
},
}
handlers := []http.Handler{
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// sleep longer than the interval to cause the health check to time out
time.Sleep(2 * time.Second)
httpapi.Write(r.Context(), w, http.StatusOK, nil)
}),
}
getApps, closeFn := setupAppReporter(ctx, t, apps, handlers)
defer closeFn()
require.Eventually(t, func() bool {
apps, err := getApps(ctx)
if err != nil {
return false
}
return apps[0].Health == codersdk.WorkspaceAppHealthUnhealthy
}, testutil.WaitLong, testutil.IntervalSlow)
}
func TestAppHealth_NotSpamming(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
apps := []codersdk.WorkspaceApp{
{
Slug: "app2",
Healthcheck: codersdk.Healthcheck{
// URL: We don't set the URL for this test because the setup will
// create a httptest server for us and set it for us.
Interval: 1,
Threshold: 1,
},
Health: codersdk.WorkspaceAppHealthInitializing,
},
}
counter := new(int32)
handlers := []http.Handler{
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
atomic.AddInt32(counter, 1)
}),
}
_, closeFn := setupAppReporter(ctx, t, apps, handlers)
defer closeFn()
// Ensure we haven't made more than 2 (expected 1 + 1 for buffer) requests in the last second.
// if there is a bug where we are spamming the healthcheck route this will catch it.
time.Sleep(time.Second)
require.LessOrEqual(t, atomic.LoadInt32(counter), int32(2))
}
func setupAppReporter(ctx context.Context, t *testing.T, apps []codersdk.WorkspaceApp, handlers []http.Handler) (agent.WorkspaceAgentApps, func()) {
closers := []func(){}
for i, handler := range handlers {
if handler == nil {
continue
}
ts := httptest.NewServer(handler)
app := apps[i]
app.Healthcheck.URL = ts.URL
apps[i] = app
closers = append(closers, ts.Close)
}
var mu sync.Mutex
workspaceAgentApps := func(context.Context) ([]codersdk.WorkspaceApp, error) {
mu.Lock()
defer mu.Unlock()
var newApps []codersdk.WorkspaceApp
return append(newApps, apps...), nil
}
postWorkspaceAgentAppHealth := func(_ context.Context, req agentsdk.PostAppHealthsRequest) error {
mu.Lock()
for id, health := range req.Healths {
for i, app := range apps {
if app.ID != id {
continue
}
app.Health = health
apps[i] = app
}
}
mu.Unlock()
return nil
}
go agent.NewWorkspaceAppHealthReporter(slogtest.Make(t, nil).Leveled(slog.LevelDebug), apps, postWorkspaceAgentAppHealth)(ctx)
return workspaceAgentApps, func() {
for _, closeFn := range closers {
closeFn()
}
}
}
-77
View File
@@ -1,77 +0,0 @@
package agent
import (
"context"
"fmt"
"net"
"golang.org/x/crypto/ssh"
"golang.org/x/xerrors"
"github.com/coder/coder/peer"
"github.com/coder/coder/peerbroker/proto"
)
// ReconnectingPTYRequest is sent from the client to the server
// to pipe data to a PTY.
type ReconnectingPTYRequest struct {
Data string `json:"data"`
Height uint16 `json:"height"`
Width uint16 `json:"width"`
}
// Conn wraps a peer connection with helper functions to
// communicate with the agent.
type Conn struct {
// Negotiator is responsible for exchanging messages.
Negotiator proto.DRPCPeerBrokerClient
*peer.Conn
}
// ReconnectingPTY returns a connection serving a TTY that can
// be reconnected to via ID.
func (c *Conn) ReconnectingPTY(id string, height, width uint16) (net.Conn, error) {
channel, err := c.Dial(context.Background(), fmt.Sprintf("%s:%d:%d", id, height, width), &peer.ChannelOptions{
Protocol: "reconnecting-pty",
})
if err != nil {
return nil, xerrors.Errorf("pty: %w", err)
}
return channel.NetConn(), nil
}
// SSH dials the built-in SSH server.
func (c *Conn) SSH() (net.Conn, error) {
channel, err := c.Dial(context.Background(), "ssh", &peer.ChannelOptions{
Protocol: "ssh",
})
if err != nil {
return nil, xerrors.Errorf("dial: %w", err)
}
return channel.NetConn(), nil
}
// SSHClient calls SSH to create a client that uses a weak cipher
// for high throughput.
func (c *Conn) SSHClient() (*ssh.Client, error) {
netConn, err := c.SSH()
if err != nil {
return nil, xerrors.Errorf("ssh: %w", err)
}
sshConn, channels, requests, err := ssh.NewClientConn(netConn, "localhost:22", &ssh.ClientConfig{
// SSH host validation isn't helpful, because obtaining a peer
// connection already signifies user-intent to dial a workspace.
// #nosec
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
})
if err != nil {
return nil, xerrors.Errorf("ssh conn: %w", err)
}
return ssh.NewClient(sshConn, channels, requests), nil
}
func (c *Conn) Close() error {
_ = c.Negotiator.DRPCConn().Close()
return c.Conn.Close()
}
+130
View File
@@ -0,0 +1,130 @@
package agent
import (
"context"
"fmt"
"strings"
"github.com/prometheus/client_golang/prometheus"
prompb "github.com/prometheus/client_model/go"
"tailscale.com/util/clientmetric"
"cdr.dev/slog"
"github.com/coder/coder/codersdk/agentsdk"
)
type agentMetrics struct {
connectionsTotal prometheus.Counter
reconnectingPTYErrors *prometheus.CounterVec
}
func newAgentMetrics(registerer prometheus.Registerer) *agentMetrics {
connectionsTotal := prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "agent", Subsystem: "reconnecting_pty", Name: "connections_total",
})
registerer.MustRegister(connectionsTotal)
reconnectingPTYErrors := prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "agent",
Subsystem: "reconnecting_pty",
Name: "errors_total",
},
[]string{"error_type"},
)
registerer.MustRegister(reconnectingPTYErrors)
return &agentMetrics{
connectionsTotal: connectionsTotal,
reconnectingPTYErrors: reconnectingPTYErrors,
}
}
func (a *agent) collectMetrics(ctx context.Context) []agentsdk.AgentMetric {
var collected []agentsdk.AgentMetric
// Tailscale internal metrics
metrics := clientmetric.Metrics()
for _, m := range metrics {
if isIgnoredMetric(m.Name()) {
continue
}
collected = append(collected, agentsdk.AgentMetric{
Name: m.Name(),
Type: asMetricType(m.Type()),
Value: float64(m.Value()),
})
}
metricFamilies, err := a.prometheusRegistry.Gather()
if err != nil {
a.logger.Error(ctx, "can't gather agent metrics", slog.Error(err))
return collected
}
for _, metricFamily := range metricFamilies {
for _, metric := range metricFamily.GetMetric() {
labels := toAgentMetricLabels(metric.Label)
if metric.Counter != nil {
collected = append(collected, agentsdk.AgentMetric{
Name: metricFamily.GetName(),
Type: agentsdk.AgentMetricTypeCounter,
Value: metric.Counter.GetValue(),
Labels: labels,
})
} else if metric.Gauge != nil {
collected = append(collected, agentsdk.AgentMetric{
Name: metricFamily.GetName(),
Type: agentsdk.AgentMetricTypeGauge,
Value: metric.Gauge.GetValue(),
Labels: labels,
})
} else {
a.logger.Error(ctx, "unsupported metric type", slog.F("type", metricFamily.Type.String()))
}
}
}
return collected
}
func toAgentMetricLabels(metricLabels []*prompb.LabelPair) []agentsdk.AgentMetricLabel {
if len(metricLabels) == 0 {
return nil
}
labels := make([]agentsdk.AgentMetricLabel, 0, len(metricLabels))
for _, metricLabel := range metricLabels {
labels = append(labels, agentsdk.AgentMetricLabel{
Name: metricLabel.GetName(),
Value: metricLabel.GetValue(),
})
}
return labels
}
// isIgnoredMetric checks if the metric should be ignored, as Coder agent doesn't use related features.
// Expected metric families: magicsock_*, derp_*, tstun_*, netcheck_*, portmap_*, etc.
func isIgnoredMetric(metricName string) bool {
if strings.HasPrefix(metricName, "dns_") ||
strings.HasPrefix(metricName, "controlclient_") ||
strings.HasPrefix(metricName, "peerapi_") ||
strings.HasPrefix(metricName, "profiles_") ||
strings.HasPrefix(metricName, "tstun_") {
return true
}
return false
}
func asMetricType(typ clientmetric.Type) agentsdk.AgentMetricType {
switch typ {
case clientmetric.TypeGauge:
return agentsdk.AgentMetricTypeGauge
case clientmetric.TypeCounter:
return agentsdk.AgentMetricTypeCounter
default:
panic(fmt.Sprintf("unknown metric type: %d", typ))
}
}
+69
View File
@@ -0,0 +1,69 @@
//go:build linux || (windows && amd64)
package agent
import (
"time"
"github.com/cakturk/go-netstat/netstat"
"golang.org/x/xerrors"
"github.com/coder/coder/codersdk"
)
func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.WorkspaceAgentListeningPort, error) {
lp.mut.Lock()
defer lp.mut.Unlock()
if time.Since(lp.mtime) < time.Second {
// copy
ports := make([]codersdk.WorkspaceAgentListeningPort, len(lp.ports))
copy(ports, lp.ports)
return ports, nil
}
tabs, err := netstat.TCPSocks(func(s *netstat.SockTabEntry) bool {
return s.State == netstat.Listen
})
if err != nil {
return nil, xerrors.Errorf("scan listening ports: %w", err)
}
seen := make(map[uint16]struct{}, len(tabs))
ports := []codersdk.WorkspaceAgentListeningPort{}
for _, tab := range tabs {
if tab.LocalAddr == nil || tab.LocalAddr.Port < codersdk.WorkspaceAgentMinimumListeningPort {
continue
}
// Ignore ports that we've been told to ignore.
if _, ok := lp.ignorePorts[int(tab.LocalAddr.Port)]; ok {
continue
}
// Don't include ports that we've already seen. This can happen on
// Windows, and maybe on Linux if you're using a shared listener socket.
if _, ok := seen[tab.LocalAddr.Port]; ok {
continue
}
seen[tab.LocalAddr.Port] = struct{}{}
procName := ""
if tab.Process != nil {
procName = tab.Process.Name
}
ports = append(ports, codersdk.WorkspaceAgentListeningPort{
ProcessName: procName,
Network: "tcp",
Port: tab.LocalAddr.Port,
})
}
lp.ports = ports
lp.mtime = time.Now()
// copy
ports = make([]codersdk.WorkspaceAgentListeningPort, len(lp.ports))
copy(ports, lp.ports)
return ports, nil
}
+12
View File
@@ -0,0 +1,12 @@
//go:build !linux && !(windows && amd64)
package agent
import "github.com/coder/coder/codersdk"
func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.WorkspaceAgentListeningPort, error) {
// Can't scan for ports on non-linux or non-windows_amd64 systems at the
// moment. The UI will not show any "no ports found" message to the user, so
// the user won't suspect a thing.
return []codersdk.WorkspaceAgentListeningPort{}, nil
}
+4
View File
@@ -0,0 +1,4 @@
// Package reaper contains logic for reaping subprocesses. It is
// specifically used in the agent to avoid the accumulation of
// zombie processes.
package reaper
+41
View File
@@ -0,0 +1,41 @@
package reaper
import (
"os"
"github.com/hashicorp/go-reap"
)
type Option func(o *options)
// WithExecArgs specifies the exec arguments for the fork exec call.
// By default the same arguments as the parent are used as dictated by
// os.Args. Since ForkReap calls a fork-exec it is the responsibility of
// the caller to avoid fork-bombing oneself.
func WithExecArgs(args ...string) Option {
return func(o *options) {
o.ExecArgs = args
}
}
// WithPIDCallback sets the channel that reaped child process PIDs are pushed
// onto.
func WithPIDCallback(ch reap.PidCh) Option {
return func(o *options) {
o.PIDs = ch
}
}
// WithCatchSignals sets the signals that are caught and forwarded to the
// child process. By default no signals are forwarded.
func WithCatchSignals(sigs ...os.Signal) Option {
return func(o *options) {
o.CatchSignals = sigs
}
}
type options struct {
ExecArgs []string
PIDs reap.PidCh
CatchSignals []os.Signal
}
+12
View File
@@ -0,0 +1,12 @@
//go:build !linux
package reaper
// IsInitProcess returns true if the current process's PID is 1.
func IsInitProcess() bool {
return false
}
func ForkReap(_ ...Option) error {
return nil
}
+102
View File
@@ -0,0 +1,102 @@
//go:build linux
package reaper_test
import (
"fmt"
"os"
"os/exec"
"os/signal"
"syscall"
"testing"
"time"
"github.com/hashicorp/go-reap"
"github.com/stretchr/testify/require"
"github.com/coder/coder/agent/reaper"
"github.com/coder/coder/testutil"
)
// TestReap checks that's the reaper is successfully reaping
// exited processes and passing the PIDs through the shared
// channel.
//
//nolint:paralleltest
func TestReap(t *testing.T) {
// Don't run the reaper test in CI. It does weird
// things like forkexecing which may have unintended
// consequences in CI.
if testutil.InCI() {
t.Skip("Detected CI, skipping reaper tests")
}
pids := make(reap.PidCh, 1)
err := reaper.ForkReap(
reaper.WithPIDCallback(pids),
// Provide some argument that immediately exits.
reaper.WithExecArgs("/bin/sh", "-c", "exit 0"),
)
require.NoError(t, err)
cmd := exec.Command("tail", "-f", "/dev/null")
err = cmd.Start()
require.NoError(t, err)
cmd2 := exec.Command("tail", "-f", "/dev/null")
err = cmd2.Start()
require.NoError(t, err)
err = cmd.Process.Kill()
require.NoError(t, err)
err = cmd2.Process.Kill()
require.NoError(t, err)
expectedPIDs := []int{cmd.Process.Pid, cmd2.Process.Pid}
for i := 0; i < len(expectedPIDs); i++ {
select {
case <-time.After(testutil.WaitShort):
t.Fatalf("Timed out waiting for process")
case pid := <-pids:
require.Contains(t, expectedPIDs, pid)
}
}
}
//nolint:paralleltest // Signal handling.
func TestReapInterrupt(t *testing.T) {
// Don't run the reaper test in CI. It does weird
// things like forkexecing which may have unintended
// consequences in CI.
if testutil.InCI() {
t.Skip("Detected CI, skipping reaper tests")
}
errC := make(chan error, 1)
pids := make(reap.PidCh, 1)
// Use signals to notify when the child process is ready for the
// next step of our test.
usrSig := make(chan os.Signal, 1)
signal.Notify(usrSig, syscall.SIGUSR1, syscall.SIGUSR2)
defer signal.Stop(usrSig)
go func() {
errC <- reaper.ForkReap(
reaper.WithPIDCallback(pids),
reaper.WithCatchSignals(os.Interrupt),
// Signal propagation does not extend to children of children, so
// we create a little bash script to ensure sleep is interrupted.
reaper.WithExecArgs("/bin/sh", "-c", fmt.Sprintf("pid=0; trap 'kill -USR2 %d; kill -TERM $pid' INT; sleep 10 &\npid=$!; kill -USR1 %d; wait", os.Getpid(), os.Getpid())),
)
}()
require.Equal(t, <-usrSig, syscall.SIGUSR1)
err := syscall.Kill(os.Getpid(), syscall.SIGINT)
require.NoError(t, err)
require.Equal(t, <-usrSig, syscall.SIGUSR2)
require.NoError(t, <-errC)
}
+86
View File
@@ -0,0 +1,86 @@
//go:build linux
package reaper
import (
"os"
"os/signal"
"syscall"
"github.com/hashicorp/go-reap"
"golang.org/x/xerrors"
)
// IsInitProcess returns true if the current process's PID is 1.
func IsInitProcess() bool {
return os.Getpid() == 1
}
func catchSignals(pid int, sigs []os.Signal) {
if len(sigs) == 0 {
return
}
sc := make(chan os.Signal, 1)
signal.Notify(sc, sigs...)
defer signal.Stop(sc)
for {
s := <-sc
sig, ok := s.(syscall.Signal)
if ok {
_ = syscall.Kill(pid, sig)
}
}
}
// ForkReap spawns a goroutine that reaps children. In order to avoid
// complications with spawning `exec.Commands` in the same process that
// is reaping, we forkexec a child process. This prevents a race between
// the reaper and an exec.Command waiting for its process to complete.
// The provided 'pids' channel may be nil if the caller does not care about the
// reaped children PIDs.
func ForkReap(opt ...Option) error {
opts := &options{
ExecArgs: os.Args,
}
for _, o := range opt {
o(opts)
}
go reap.ReapChildren(opts.PIDs, nil, nil, nil)
pwd, err := os.Getwd()
if err != nil {
return xerrors.Errorf("get wd: %w", err)
}
pattrs := &syscall.ProcAttr{
Dir: pwd,
Env: os.Environ(),
Sys: &syscall.SysProcAttr{
Setsid: true,
},
Files: []uintptr{
uintptr(syscall.Stdin),
uintptr(syscall.Stdout),
uintptr(syscall.Stderr),
},
}
//#nosec G204
pid, err := syscall.ForkExec(opts.ExecArgs[0], opts.ExecArgs, pattrs)
if err != nil {
return xerrors.Errorf("fork exec: %w", err)
}
go catchSignals(pid, opts.CatchSignals)
var wstatus syscall.WaitStatus
_, err = syscall.Wait4(pid, &wstatus, 0, nil)
for xerrors.Is(err, syscall.EINTR) {
_, err = syscall.Wait4(pid, &wstatus, 0, nil)
}
return err
}
+1 -1
View File
@@ -3,6 +3,6 @@ package usershell
import "os"
// Get returns the $SHELL environment variable.
func Get(username string) (string, error) {
func Get(_ string) (string, error) {
return os.Getenv("SHELL"), nil
}
+5 -1
View File
@@ -4,7 +4,11 @@ import "os/exec"
// Get returns the command prompt binary name.
func Get(username string) (string, error) {
_, err := exec.LookPath("powershell.exe")
_, err := exec.LookPath("pwsh.exe")
if err == nil {
return "pwsh.exe", nil
}
_, err = exec.LookPath("powershell.exe")
if err == nil {
return "powershell.exe", nil
}
+42 -3
View File
@@ -3,6 +3,7 @@ package buildinfo
import (
"fmt"
"runtime/debug"
"strings"
"sync"
"time"
@@ -20,8 +21,17 @@ var (
version string
readVersion sync.Once
// Injected with ldflags at build!
tag string
// Updated by buildinfo_slim.go on start.
slim bool
// Injected with ldflags at build, see scripts/build_go.sh
tag string
agpl string // either "true" or "false", ldflags does not support bools
)
const (
// develPrefix is prefixed to developer versions of the application.
develPrefix = "v0.0.0-devel"
)
// Version returns the semantic version of the build.
@@ -35,7 +45,7 @@ func Version() string {
if tag == "" {
// This occurs when the tag hasn't been injected,
// like when using "go run".
version = "v0.0.0-devel" + revision
version = develPrefix + revision
return
}
version = "v" + tag
@@ -48,6 +58,35 @@ func Version() string {
return version
}
// VersionsMatch compares the two versions. It assumes the versions match if
// the major and the minor versions are equivalent. Patch versions are
// disregarded. If it detects that either version is a developer build it
// returns true.
func VersionsMatch(v1, v2 string) bool {
// Developer versions are disregarded...hopefully they know what they are
// doing.
if strings.HasPrefix(v1, develPrefix) || strings.HasPrefix(v2, develPrefix) {
return true
}
return semver.MajorMinor(v1) == semver.MajorMinor(v2)
}
// IsDev returns true if this is a development build.
func IsDev() bool {
return strings.HasPrefix(Version(), develPrefix)
}
// IsSlim returns true if this is a slim build.
func IsSlim() bool {
return slim
}
// IsAGPL returns true if this is an AGPL build.
func IsAGPL() bool {
return strings.Contains(agpl, "t")
}
// ExternalURL returns a URL referencing the current Coder version.
// For production builds, this will link directly to a release.
// For development builds, this will link to a commit.
+7
View File
@@ -0,0 +1,7 @@
//go:build slim
package buildinfo
func init() {
slim = true
}
+67
View File
@@ -1,6 +1,7 @@
package buildinfo_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
@@ -29,4 +30,70 @@ func TestBuildInfo(t *testing.T) {
_, valid := buildinfo.Time()
require.False(t, valid)
})
t.Run("VersionsMatch", func(t *testing.T) {
t.Parallel()
type testcase struct {
name string
v1 string
v2 string
expectMatch bool
}
cases := []testcase{
{
name: "OK",
v1: "v1.2.3",
v2: "v1.2.3",
expectMatch: true,
},
// Test that we return true if a developer version is detected.
// Developers do not need to be warned of mismatched versions.
{
name: "DevelIgnored",
v1: "v0.0.0-devel+123abac",
v2: "v1.2.3",
expectMatch: true,
},
// Our CI instance uses a "-devel" prerelease
// flag. This is not the same as a developer WIP build.
{
name: "DevelPreleaseNotIgnored",
v1: "v1.1.1-devel+123abac",
v2: "v1.2.3",
expectMatch: false,
},
{
name: "MajorMismatch",
v1: "v1.2.3",
v2: "v0.1.2",
expectMatch: false,
},
{
name: "MinorMismatch",
v1: "v1.2.3",
v2: "v1.3.2",
expectMatch: false,
},
// Different patches are ok, breaking changes are not allowed
// in patches.
{
name: "PatchMismatch",
v1: "v1.2.3+hash.whocares",
v2: "v1.2.4+somestuff.hm.ok",
expectMatch: true,
},
}
for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
t.Parallel()
require.Equal(t, c.expectMatch, buildinfo.VersionsMatch(c.v1, c.v2),
fmt.Sprintf("expected match=%v for version %s and %s", c.expectMatch, c.v1, c.v2),
)
})
}
})
}
+408 -67
View File
@@ -2,142 +2,483 @@ package cli
import (
"context"
"fmt"
"io"
"net/http"
"net/http/pprof"
"net/url"
"os"
"os/signal"
"path/filepath"
"runtime"
"strconv"
"sync"
"time"
"cloud.google.com/go/compute/metadata"
"github.com/spf13/cobra"
"golang.org/x/xerrors"
"gopkg.in/natefinch/lumberjack.v2"
"tailscale.com/util/clientmetric"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/expfmt"
"cdr.dev/slog"
"cdr.dev/slog/sloggers/sloghuman"
"cdr.dev/slog/sloggers/slogjson"
"cdr.dev/slog/sloggers/slogstackdriver"
"github.com/coder/coder/agent"
"github.com/coder/coder/cli/cliflag"
"github.com/coder/coder/agent/reaper"
"github.com/coder/coder/buildinfo"
"github.com/coder/coder/cli/clibase"
"github.com/coder/coder/codersdk"
"github.com/coder/retry"
"gopkg.in/natefinch/lumberjack.v2"
"github.com/coder/coder/codersdk/agentsdk"
)
func workspaceAgent() *cobra.Command {
func (r *RootCmd) workspaceAgent() *clibase.Cmd {
var (
auth string
auth string
logDir string
pprofAddress string
noReap bool
sshMaxTimeout time.Duration
tailnetListenPort int64
prometheusAddress string
debugAddress string
slogHumanPath string
slogJSONPath string
slogStackdriverPath string
)
cmd := &cobra.Command{
Use: "agent",
cmd := &clibase.Cmd{
Use: "agent",
Short: `Starts the Coder workspace agent.`,
// This command isn't useful to manually execute.
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
rawURL, err := cmd.Flags().GetString(varAgentURL)
if err != nil {
return xerrors.Errorf("CODER_AGENT_URL must be set: %w", err)
}
coderURL, err := url.Parse(rawURL)
if err != nil {
return xerrors.Errorf("parse %q: %w", rawURL, err)
Handler: func(inv *clibase.Invocation) error {
ctx, cancel := context.WithCancel(inv.Context())
defer cancel()
var (
ignorePorts = map[int]string{}
isLinux = runtime.GOOS == "linux"
sinks = []slog.Sink{}
logClosers = []func() error{}
)
defer func() {
for _, closer := range logClosers {
_ = closer()
}
}()
addSinkIfProvided := func(sinkFn func(io.Writer) slog.Sink, loc string) error {
switch loc {
case "":
// Do nothing.
case "/dev/stderr":
sinks = append(sinks, sinkFn(inv.Stderr))
case "/dev/stdout":
sinks = append(sinks, sinkFn(inv.Stdout))
default:
fi, err := os.OpenFile(loc, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o644)
if err != nil {
return xerrors.Errorf("open log file %q: %w", loc, err)
}
sinks = append(sinks, sinkFn(fi))
logClosers = append(logClosers, fi.Close)
}
return nil
}
logWriter := &lumberjack.Logger{
Filename: filepath.Join(os.TempDir(), "coder-agent.log"),
MaxSize: 5, // MB
if err := addSinkIfProvided(sloghuman.Sink, slogHumanPath); err != nil {
return xerrors.Errorf("add human sink: %w", err)
}
if err := addSinkIfProvided(slogjson.Sink, slogJSONPath); err != nil {
return xerrors.Errorf("add json sink: %w", err)
}
if err := addSinkIfProvided(slogstackdriver.Sink, slogStackdriverPath); err != nil {
return xerrors.Errorf("add stackdriver sink: %w", err)
}
// Spawn a reaper so that we don't accumulate a ton
// of zombie processes.
if reaper.IsInitProcess() && !noReap && isLinux {
logWriter := &lumberjackWriteCloseFixer{w: &lumberjack.Logger{
Filename: filepath.Join(logDir, "coder-agent-init.log"),
MaxSize: 5, // MB
// Without this, rotated logs will never be deleted.
MaxBackups: 1,
}}
defer logWriter.Close()
sinks = append(sinks, sloghuman.Sink(logWriter))
logger := slog.Make(sinks...).Leveled(slog.LevelDebug)
logger.Info(ctx, "spawning reaper process")
// Do not start a reaper on the child process. It's important
// to do this else we fork bomb ourselves.
args := append(os.Args, "--no-reap")
err := reaper.ForkReap(
reaper.WithExecArgs(args...),
reaper.WithCatchSignals(InterruptSignals...),
)
if err != nil {
logger.Error(ctx, "agent process reaper unable to fork", slog.Error(err))
return xerrors.Errorf("fork reap: %w", err)
}
logger.Info(ctx, "reaper process exiting")
return nil
}
// Handle interrupt signals to allow for graceful shutdown,
// note that calling stopNotify disables the signal handler
// and the next interrupt will terminate the program (you
// probably want cancel instead).
//
// Note that we don't want to handle these signals in the
// process that runs as PID 1, that's why we do this after
// the reaper forked.
ctx, stopNotify := signal.NotifyContext(ctx, InterruptSignals...)
defer stopNotify()
// DumpHandler does signal handling, so we call it after the
// reaper.
go DumpHandler(ctx)
logWriter := &lumberjackWriteCloseFixer{w: &lumberjack.Logger{
Filename: filepath.Join(logDir, "coder-agent.log"),
MaxSize: 5, // MB
// Without this, rotated logs will never be deleted.
MaxBackups: 1,
}}
defer logWriter.Close()
logger := slog.Make(sloghuman.Sink(cmd.ErrOrStderr()), sloghuman.Sink(logWriter)).Leveled(slog.LevelDebug)
client := codersdk.New(coderURL)
sinks = append(sinks, sloghuman.Sink(logWriter))
logger := slog.Make(sinks...).Leveled(slog.LevelDebug)
version := buildinfo.Version()
logger.Info(ctx, "agent is starting now",
slog.F("url", r.agentURL),
slog.F("auth", auth),
slog.F("version", version),
)
client := agentsdk.New(r.agentURL)
client.SDK.Logger = logger
// Set a reasonable timeout so requests can't hang forever!
// The timeout needs to be reasonably long, because requests
// with large payloads can take a bit. e.g. startup scripts
// may take a while to insert.
client.SDK.HTTPClient.Timeout = 30 * time.Second
// Enable pprof handler
// This prevents the pprof import from being accidentally deleted.
_ = pprof.Handler
pprofSrvClose := ServeHandler(ctx, logger, nil, pprofAddress, "pprof")
defer pprofSrvClose()
if port, err := extractPort(pprofAddress); err == nil {
ignorePorts[port] = "pprof"
}
if port, err := extractPort(prometheusAddress); err == nil {
ignorePorts[port] = "prometheus"
}
if port, err := extractPort(debugAddress); err == nil {
ignorePorts[port] = "debug"
}
// exchangeToken returns a session token.
// This is abstracted to allow for the same looping condition
// regardless of instance identity auth type.
var exchangeToken func(context.Context) (codersdk.WorkspaceAgentAuthenticateResponse, error)
var exchangeToken func(context.Context) (agentsdk.AuthenticateResponse, error)
switch auth {
case "token":
token, err := cmd.Flags().GetString(varAgentToken)
token, err := inv.ParsedFlags().GetString(varAgentToken)
if err != nil {
return xerrors.Errorf("CODER_AGENT_TOKEN must be set for token auth: %w", err)
}
client.SessionToken = token
client.SetSessionToken(token)
case "google-instance-identity":
// This is *only* done for testing to mock client authentication.
// This will never be set in a production scenario.
var gcpClient *metadata.Client
gcpClientRaw := cmd.Context().Value("gcp-client")
gcpClientRaw := ctx.Value("gcp-client")
if gcpClientRaw != nil {
gcpClient, _ = gcpClientRaw.(*metadata.Client)
}
exchangeToken = func(ctx context.Context) (codersdk.WorkspaceAgentAuthenticateResponse, error) {
return client.AuthWorkspaceGoogleInstanceIdentity(ctx, "", gcpClient)
exchangeToken = func(ctx context.Context) (agentsdk.AuthenticateResponse, error) {
return client.AuthGoogleInstanceIdentity(ctx, "", gcpClient)
}
case "aws-instance-identity":
// This is *only* done for testing to mock client authentication.
// This will never be set in a production scenario.
var awsClient *http.Client
awsClientRaw := cmd.Context().Value("aws-client")
awsClientRaw := ctx.Value("aws-client")
if awsClientRaw != nil {
awsClient, _ = awsClientRaw.(*http.Client)
if awsClient != nil {
client.HTTPClient = awsClient
client.SDK.HTTPClient = awsClient
}
}
exchangeToken = func(ctx context.Context) (codersdk.WorkspaceAgentAuthenticateResponse, error) {
return client.AuthWorkspaceAWSInstanceIdentity(ctx)
exchangeToken = func(ctx context.Context) (agentsdk.AuthenticateResponse, error) {
return client.AuthAWSInstanceIdentity(ctx)
}
case "azure-instance-identity":
// This is *only* done for testing to mock client authentication.
// This will never be set in a production scenario.
var azureClient *http.Client
azureClientRaw := cmd.Context().Value("azure-client")
azureClientRaw := ctx.Value("azure-client")
if azureClientRaw != nil {
azureClient, _ = azureClientRaw.(*http.Client)
if azureClient != nil {
client.HTTPClient = azureClient
client.SDK.HTTPClient = azureClient
}
}
exchangeToken = func(ctx context.Context) (codersdk.WorkspaceAgentAuthenticateResponse, error) {
return client.AuthWorkspaceAzureInstanceIdentity(ctx)
exchangeToken = func(ctx context.Context) (agentsdk.AuthenticateResponse, error) {
return client.AuthAzureInstanceIdentity(ctx)
}
}
if exchangeToken != nil {
// Agent's can start before resources are returned from the provisioner
// daemon. If there are many resources being provisioned, this time
// could be significant. This is arbitrarily set at an hour to prevent
// tons of idle agents from pinging coderd.
ctx, cancelFunc := context.WithTimeout(cmd.Context(), time.Hour)
defer cancelFunc()
for retry.New(100*time.Millisecond, 5*time.Second).Wait(ctx) {
var response codersdk.WorkspaceAgentAuthenticateResponse
executablePath, err := os.Executable()
if err != nil {
return xerrors.Errorf("getting os executable: %w", err)
}
err = os.Setenv("PATH", fmt.Sprintf("%s%c%s", os.Getenv("PATH"), filepath.ListSeparator, filepath.Dir(executablePath)))
if err != nil {
return xerrors.Errorf("add executable to $PATH: %w", err)
}
response, err = exchangeToken(ctx)
prometheusRegistry := prometheus.NewRegistry()
subsystem := inv.Environ.Get(agent.EnvAgentSubsystem)
agnt := agent.New(agent.Options{
Client: client,
Logger: logger,
LogDir: logDir,
TailnetListenPort: uint16(tailnetListenPort),
ExchangeToken: func(ctx context.Context) (string, error) {
if exchangeToken == nil {
return client.SDK.SessionToken(), nil
}
resp, err := exchangeToken(ctx)
if err != nil {
logger.Warn(ctx, "authenticate workspace", slog.F("method", auth), slog.Error(err))
continue
return "", err
}
client.SessionToken = response.SessionToken
logger.Info(ctx, "authenticated", slog.F("method", auth))
break
}
if err != nil {
return xerrors.Errorf("agent failed to authenticate in time: %w", err)
}
}
closer := agent.New(client.ListenWorkspaceAgent, &agent.Options{
Logger: logger,
EnvironmentVariables: map[string]string{
// Override the "CODER_AGENT_TOKEN" variable in all
// shells so "gitssh" works!
"CODER_AGENT_TOKEN": client.SessionToken,
client.SetSessionToken(resp.SessionToken)
return resp.SessionToken, nil
},
EnvironmentVariables: map[string]string{
"GIT_ASKPASS": executablePath,
},
IgnorePorts: ignorePorts,
SSHMaxTimeout: sshMaxTimeout,
Subsystem: codersdk.AgentSubsystem(subsystem),
PrometheusRegistry: prometheusRegistry,
})
<-cmd.Context().Done()
return closer.Close()
prometheusSrvClose := ServeHandler(ctx, logger, prometheusMetricsHandler(prometheusRegistry, logger), prometheusAddress, "prometheus")
defer prometheusSrvClose()
debugSrvClose := ServeHandler(ctx, logger, agnt.HTTPDebug(), debugAddress, "debug")
defer debugSrvClose()
<-ctx.Done()
return agnt.Close()
},
}
cmd.Options = clibase.OptionSet{
{
Flag: "auth",
Default: "token",
Description: "Specify the authentication type to use for the agent.",
Env: "CODER_AGENT_AUTH",
Value: clibase.StringOf(&auth),
},
{
Flag: "log-dir",
Default: os.TempDir(),
Description: "Specify the location for the agent log files.",
Env: "CODER_AGENT_LOG_DIR",
Value: clibase.StringOf(&logDir),
},
{
Flag: "pprof-address",
Default: "127.0.0.1:6060",
Env: "CODER_AGENT_PPROF_ADDRESS",
Value: clibase.StringOf(&pprofAddress),
Description: "The address to serve pprof.",
},
{
Flag: "no-reap",
Env: "",
Description: "Do not start a process reaper.",
Value: clibase.BoolOf(&noReap),
},
{
Flag: "ssh-max-timeout",
// tcpip.KeepaliveIdleOption = 72h + 1min (forwardTCPSockOpts() in tailnet/conn.go)
Default: "72h",
Env: "CODER_AGENT_SSH_MAX_TIMEOUT",
Description: "Specify the max timeout for a SSH connection, it is advisable to set it to a minimum of 60s, but no more than 72h.",
Value: clibase.DurationOf(&sshMaxTimeout),
},
{
Flag: "tailnet-listen-port",
Default: "0",
Env: "CODER_AGENT_TAILNET_LISTEN_PORT",
Description: "Specify a static port for Tailscale to use for listening.",
Value: clibase.Int64Of(&tailnetListenPort),
},
{
Flag: "prometheus-address",
Default: "127.0.0.1:2112",
Env: "CODER_AGENT_PROMETHEUS_ADDRESS",
Value: clibase.StringOf(&prometheusAddress),
Description: "The bind address to serve Prometheus metrics.",
},
{
Flag: "debug-address",
Default: "127.0.0.1:2113",
Env: "CODER_AGENT_DEBUG_ADDRESS",
Value: clibase.StringOf(&debugAddress),
Description: "The bind address to serve a debug HTTP server.",
},
{
Name: "Human Log Location",
Description: "Output human-readable logs to a given file.",
Flag: "log-human",
Env: "CODER_AGENT_LOGGING_HUMAN",
Default: "/dev/stderr",
Value: clibase.StringOf(&slogHumanPath),
},
{
Name: "JSON Log Location",
Description: "Output JSON logs to a given file.",
Flag: "log-json",
Env: "CODER_AGENT_LOGGING_JSON",
Default: "",
Value: clibase.StringOf(&slogJSONPath),
},
{
Name: "Stackdriver Log Location",
Description: "Output Stackdriver compatible logs to a given file.",
Flag: "log-stackdriver",
Env: "CODER_AGENT_LOGGING_STACKDRIVER",
Default: "",
Value: clibase.StringOf(&slogStackdriverPath),
},
}
cliflag.StringVarP(cmd.Flags(), &auth, "auth", "", "CODER_AGENT_AUTH", "token", "Specify the authentication type to use for the agent")
return cmd
}
func ServeHandler(ctx context.Context, logger slog.Logger, handler http.Handler, addr, name string) (closeFunc func()) {
logger.Debug(ctx, "http server listening", slog.F("addr", addr), slog.F("name", name))
// ReadHeaderTimeout is purposefully not enabled. It caused some issues with
// websockets over the dev tunnel.
// See: https://github.com/coder/coder/pull/3730
//nolint:gosec
srv := &http.Server{
Addr: addr,
Handler: handler,
}
go func() {
err := srv.ListenAndServe()
if err != nil && !xerrors.Is(err, http.ErrServerClosed) {
logger.Error(ctx, "http server listen", slog.F("name", name), slog.Error(err))
}
}()
return func() {
_ = srv.Close()
}
}
// lumberjackWriteCloseFixer is a wrapper around an io.WriteCloser that
// prevents writes after Close. This is necessary because lumberjack
// re-opens the file on Write.
type lumberjackWriteCloseFixer struct {
w io.WriteCloser
mu sync.Mutex // Protects following.
closed bool
}
func (c *lumberjackWriteCloseFixer) Close() error {
c.mu.Lock()
defer c.mu.Unlock()
c.closed = true
return c.w.Close()
}
func (c *lumberjackWriteCloseFixer) Write(p []byte) (int, error) {
c.mu.Lock()
defer c.mu.Unlock()
if c.closed {
return 0, io.ErrClosedPipe
}
return c.w.Write(p)
}
// extractPort handles different url strings.
// - localhost:6060
// - http://localhost:6060
func extractPort(u string) (int, error) {
port, firstError := urlPort(u)
if firstError == nil {
return port, nil
}
// Try with a scheme
port, err := urlPort("http://" + u)
if err == nil {
return port, nil
}
return -1, xerrors.Errorf("invalid url %q: %w", u, firstError)
}
// urlPort extracts the port from a valid URL.
func urlPort(u string) (int, error) {
parsed, err := url.Parse(u)
if err != nil {
return -1, xerrors.Errorf("invalid url %q: %w", u, err)
}
if parsed.Port() != "" {
port, err := strconv.ParseUint(parsed.Port(), 10, 16)
if err == nil && port > 0 && port < 1<<16 {
return int(port), nil
}
}
return -1, xerrors.Errorf("invalid port: %s", u)
}
func prometheusMetricsHandler(prometheusRegistry *prometheus.Registry, logger slog.Logger) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
// Based on: https://github.com/tailscale/tailscale/blob/280255acae604796a1113861f5a84e6fa2dc6121/ipn/localapi/localapi.go#L489
clientmetric.WritePrometheusExpositionFormat(w)
metricFamilies, err := prometheusRegistry.Gather()
if err != nil {
logger.Error(context.Background(), "Prometheus handler can't gather metric families", slog.Error(err))
return
}
for _, metricFamily := range metricFamilies {
_, err = expfmt.MetricFamilyToText(w, metricFamily)
if err != nil {
logger.Error(context.Background(), "expfmt.MetricFamilyToText failed", slog.Error(err))
return
}
}
})
}
+69
View File
@@ -0,0 +1,69 @@
package cli
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
func Test_extractPort(t *testing.T) {
t.Parallel()
tests := []struct {
name string
urlString string
want int
wantErr bool
}{
{
name: "Empty",
urlString: "",
wantErr: true,
},
{
name: "NoScheme",
urlString: "localhost:6060",
want: 6060,
},
{
name: "WithScheme",
urlString: "http://localhost:6060",
want: 6060,
},
{
name: "NoPort",
urlString: "http://localhost",
wantErr: true,
},
{
name: "NoPortNoScheme",
urlString: "localhost",
wantErr: true,
},
{
name: "OnlyPort",
urlString: "6060",
wantErr: true,
},
{
name: "127.0.0.1",
urlString: "127.0.0.1:2113",
want: 2113,
wantErr: false,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, err := extractPort(tt.urlString)
if tt.wantErr {
require.Error(t, err, fmt.Sprintf("extractPort(%v)", tt.urlString))
} else {
require.NoError(t, err, fmt.Sprintf("extractPort(%v)", tt.urlString))
require.Equal(t, tt.want, got, fmt.Sprintf("extractPort(%v)", tt.urlString))
}
})
}
}
+159 -57
View File
@@ -2,30 +2,79 @@ package cli_test
import (
"context"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/agent"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/provisioner/echo"
"github.com/coder/coder/provisionersdk/proto"
"github.com/coder/coder/pty/ptytest"
)
func TestWorkspaceAgent(t *testing.T) {
t.Parallel()
t.Run("LogDirectory", func(t *testing.T) {
t.Parallel()
authToken := uuid.NewString()
client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
})
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
ProvisionApply: echo.ProvisionApplyWithAgent(authToken),
})
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
logDir := t.TempDir()
inv, _ := clitest.New(t,
"agent",
"--auth", "token",
"--agent-token", authToken,
"--agent-url", client.URL.String(),
"--log-dir", logDir,
)
pty := ptytest.New(t).Attach(inv)
clitest.Start(t, inv)
ctx := inv.Context()
pty.ExpectMatchContext(ctx, "agent is starting now")
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
info, err := os.Stat(filepath.Join(logDir, "coder-agent.log"))
require.NoError(t, err)
require.Greater(t, info.Size(), int64(0))
})
t.Run("Azure", func(t *testing.T) {
t.Parallel()
instanceID := "instanceidentifier"
certificates, metadataClient := coderdtest.NewAzureInstanceIdentity(t, instanceID)
client := coderdtest.New(t, &coderdtest.Options{
AzureCertificates: certificates,
AzureCertificates: certificates,
IncludeProvisionerDaemon: true,
})
user := coderdtest.CreateFirstUser(t, client)
coderdtest.NewProvisionerDaemon(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
Provision: []*proto.Provision_Response{{
ProvisionApply: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
Resources: []*proto.Resource{{
@@ -46,26 +95,24 @@ func TestWorkspaceAgent(t *testing.T) {
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
cmd, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--agent-url", client.URL.String())
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
go func() {
// A linting error occurs for weakly typing the context value here,
// but it seems reasonable for a one-off test.
// nolint
ctx = context.WithValue(ctx, "azure-client", metadataClient)
err := cmd.ExecuteContext(ctx)
require.NoError(t, err)
}()
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
resources, err := client.WorkspaceResourcesByBuild(ctx, workspace.LatestBuild.ID)
inv, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--agent-url", client.URL.String())
inv = inv.WithContext(
//nolint:revive,staticcheck
context.WithValue(inv.Context(), "azure-client", metadataClient),
)
ctx := inv.Context()
clitest.Start(t, inv)
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
workspace, err := client.Workspace(ctx, workspace.ID)
require.NoError(t, err)
resources := workspace.LatestBuild.Resources
if assert.NotEmpty(t, workspace.LatestBuild.Resources) && assert.NotEmpty(t, resources[0].Agents) {
assert.NotEmpty(t, resources[0].Agents[0].Version)
}
dialer, err := client.DialWorkspaceAgent(ctx, resources[0].Agents[0].ID, nil)
require.NoError(t, err)
defer dialer.Close()
_, err = dialer.Ping()
require.NoError(t, err)
cancelFunc()
require.True(t, dialer.AwaitReachable(ctx))
})
t.Run("AWS", func(t *testing.T) {
@@ -73,13 +120,13 @@ func TestWorkspaceAgent(t *testing.T) {
instanceID := "instanceidentifier"
certificates, metadataClient := coderdtest.NewAWSInstanceIdentity(t, instanceID)
client := coderdtest.New(t, &coderdtest.Options{
AWSCertificates: certificates,
AWSCertificates: certificates,
IncludeProvisionerDaemon: true,
})
user := coderdtest.CreateFirstUser(t, client)
coderdtest.NewProvisionerDaemon(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
Provision: []*proto.Provision_Response{{
ProvisionApply: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
Resources: []*proto.Resource{{
@@ -100,40 +147,38 @@ func TestWorkspaceAgent(t *testing.T) {
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
cmd, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--agent-url", client.URL.String())
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
go func() {
// A linting error occurs for weakly typing the context value here,
// but it seems reasonable for a one-off test.
// nolint
ctx = context.WithValue(ctx, "aws-client", metadataClient)
err := cmd.ExecuteContext(ctx)
require.NoError(t, err)
}()
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
resources, err := client.WorkspaceResourcesByBuild(ctx, workspace.LatestBuild.ID)
inv, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--agent-url", client.URL.String())
inv = inv.WithContext(
//nolint:revive,staticcheck
context.WithValue(inv.Context(), "aws-client", metadataClient),
)
clitest.Start(t, inv)
ctx := inv.Context()
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
workspace, err := client.Workspace(ctx, workspace.ID)
require.NoError(t, err)
resources := workspace.LatestBuild.Resources
if assert.NotEmpty(t, resources) && assert.NotEmpty(t, resources[0].Agents) {
assert.NotEmpty(t, resources[0].Agents[0].Version)
}
dialer, err := client.DialWorkspaceAgent(ctx, resources[0].Agents[0].ID, nil)
require.NoError(t, err)
defer dialer.Close()
_, err = dialer.Ping()
require.NoError(t, err)
cancelFunc()
require.True(t, dialer.AwaitReachable(ctx))
})
t.Run("GoogleCloud", func(t *testing.T) {
t.Parallel()
instanceID := "instanceidentifier"
validator, metadata := coderdtest.NewGoogleInstanceIdentity(t, instanceID, false)
validator, metadataClient := coderdtest.NewGoogleInstanceIdentity(t, instanceID, false)
client := coderdtest.New(t, &coderdtest.Options{
GoogleTokenValidator: validator,
GoogleTokenValidator: validator,
IncludeProvisionerDaemon: true,
})
user := coderdtest.CreateFirstUser(t, client)
coderdtest.NewProvisionerDaemon(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
Provision: []*proto.Provision_Response{{
ProvisionApply: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
Resources: []*proto.Resource{{
@@ -154,25 +199,82 @@ func TestWorkspaceAgent(t *testing.T) {
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
cmd, _ := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String())
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
go func() {
// A linting error occurs for weakly typing the context value here,
// but it seems reasonable for a one-off test.
// nolint
ctx = context.WithValue(ctx, "gcp-client", metadata)
err := cmd.ExecuteContext(ctx)
require.NoError(t, err)
}()
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
resources, err := client.WorkspaceResourcesByBuild(ctx, workspace.LatestBuild.ID)
inv, cfg := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String())
ptytest.New(t).Attach(inv)
clitest.SetupConfig(t, client, cfg)
clitest.Start(t,
inv.WithContext(
//nolint:revive,staticcheck
context.WithValue(inv.Context(), "gcp-client", metadataClient),
),
)
ctx := inv.Context()
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
workspace, err := client.Workspace(ctx, workspace.ID)
require.NoError(t, err)
resources := workspace.LatestBuild.Resources
if assert.NotEmpty(t, resources) && assert.NotEmpty(t, resources[0].Agents) {
assert.NotEmpty(t, resources[0].Agents[0].Version)
}
dialer, err := client.DialWorkspaceAgent(ctx, resources[0].Agents[0].ID, nil)
require.NoError(t, err)
defer dialer.Close()
_, err = dialer.Ping()
require.True(t, dialer.AwaitReachable(ctx))
sshClient, err := dialer.SSHClient(ctx)
require.NoError(t, err)
cancelFunc()
defer sshClient.Close()
session, err := sshClient.NewSession()
require.NoError(t, err)
defer session.Close()
key := "CODER_AGENT_TOKEN"
command := "sh -c 'echo $" + key + "'"
if runtime.GOOS == "windows" {
command = "cmd.exe /c echo %" + key + "%"
}
token, err := session.CombinedOutput(command)
require.NoError(t, err)
_, err = uuid.Parse(strings.TrimSpace(string(token)))
require.NoError(t, err)
})
t.Run("PostStartup", func(t *testing.T) {
t.Parallel()
authToken := uuid.NewString()
client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
})
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
ProvisionApply: echo.ProvisionApplyWithAgent(authToken),
})
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
logDir := t.TempDir()
inv, _ := clitest.New(t,
"agent",
"--auth", "token",
"--agent-token", authToken,
"--agent-url", client.URL.String(),
"--log-dir", logDir,
)
// Set the subsystem for the agent.
inv.Environ.Set(agent.EnvAgentSubsystem, string(codersdk.AgentSubsystemEnvbox))
pty := ptytest.New(t).Attach(inv)
clitest.Start(t, inv)
pty.ExpectMatchContext(inv.Context(), "agent is starting now")
resources := coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
require.Len(t, resources, 1)
require.Len(t, resources[0].Agents, 1)
require.Equal(t, codersdk.AgentSubsystemEnvbox, resources[0].Agents[0].Subsystem)
})
}
-167
View File
@@ -1,167 +0,0 @@
package cli
import (
"fmt"
"os"
"time"
"github.com/spf13/cobra"
"github.com/coder/coder/coderd/autobuild/schedule"
"github.com/coder/coder/codersdk"
)
const autostartDescriptionLong = `To have your workspace build automatically at a regular time you can enable autostart.
When enabling autostart, provide the minute, hour, and day(s) of week.
The default schedule is at 09:00 in your local timezone (TZ env, UTC by default).
`
func autostart() *cobra.Command {
autostartCmd := &cobra.Command{
Annotations: workspaceCommand,
Use: "autostart enable <workspace>",
Short: "schedule a workspace to automatically start at a regular time",
Long: autostartDescriptionLong,
Example: "coder autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin",
}
autostartCmd.AddCommand(autostartShow())
autostartCmd.AddCommand(autostartEnable())
autostartCmd.AddCommand(autostartDisable())
return autostartCmd
}
func autostartShow() *cobra.Command {
cmd := &cobra.Command{
Use: "show <workspace_name>",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
return err
}
organization, err := currentOrganization(cmd, client)
if err != nil {
return err
}
workspace, err := client.WorkspaceByOwnerAndName(cmd.Context(), organization.ID, codersdk.Me, args[0])
if err != nil {
return err
}
if workspace.AutostartSchedule == "" {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "not enabled\n")
return nil
}
validSchedule, err := schedule.Weekly(workspace.AutostartSchedule)
if err != nil {
// This should never happen.
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "invalid autostart schedule %q for workspace %s: %s\n", workspace.AutostartSchedule, workspace.Name, err.Error())
return nil
}
next := validSchedule.Next(time.Now())
loc, _ := time.LoadLocation(validSchedule.Timezone())
_, _ = fmt.Fprintf(cmd.OutOrStdout(),
"schedule: %s\ntimezone: %s\nnext: %s\n",
validSchedule.Cron(),
validSchedule.Timezone(),
next.In(loc),
)
return nil
},
}
return cmd
}
func autostartEnable() *cobra.Command {
// yes some of these are technically numbers but the cron library will do that work
var autostartMinute string
var autostartHour string
var autostartDayOfWeek string
var autostartTimezone string
cmd := &cobra.Command{
Use: "enable <workspace_name> <schedule>",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
return err
}
organization, err := currentOrganization(cmd, client)
if err != nil {
return err
}
spec := fmt.Sprintf("CRON_TZ=%s %s %s * * %s", autostartTimezone, autostartMinute, autostartHour, autostartDayOfWeek)
validSchedule, err := schedule.Weekly(spec)
if err != nil {
return err
}
workspace, err := client.WorkspaceByOwnerAndName(cmd.Context(), organization.ID, codersdk.Me, args[0])
if err != nil {
return err
}
err = client.UpdateWorkspaceAutostart(cmd.Context(), workspace.ID, codersdk.UpdateWorkspaceAutostartRequest{
Schedule: validSchedule.String(),
})
if err != nil {
return err
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace will automatically start at %s.\n\n", workspace.Name, validSchedule.Next(time.Now()))
return nil
},
}
cmd.Flags().StringVar(&autostartMinute, "minute", "0", "autostart minute")
cmd.Flags().StringVar(&autostartHour, "hour", "9", "autostart hour")
cmd.Flags().StringVar(&autostartDayOfWeek, "days", "1-5", "autostart day(s) of week")
tzEnv := os.Getenv("TZ")
if tzEnv == "" {
tzEnv = "UTC"
}
cmd.Flags().StringVar(&autostartTimezone, "tz", tzEnv, "autostart timezone")
return cmd
}
func autostartDisable() *cobra.Command {
return &cobra.Command{
Use: "disable <workspace_name>",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
return err
}
organization, err := currentOrganization(cmd, client)
if err != nil {
return err
}
workspace, err := client.WorkspaceByOwnerAndName(cmd.Context(), organization.ID, codersdk.Me, args[0])
if err != nil {
return err
}
err = client.UpdateWorkspaceAutostart(cmd.Context(), workspace.ID, codersdk.UpdateWorkspaceAutostartRequest{
Schedule: "",
})
if err != nil {
return err
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace will no longer automatically start.\n\n", workspace.Name)
return nil
},
}
}
-165
View File
@@ -1,165 +0,0 @@
package cli_test
import (
"bytes"
"context"
"fmt"
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/codersdk"
)
func TestAutostart(t *testing.T) {
t.Parallel()
t.Run("ShowOK", func(t *testing.T) {
t.Parallel()
var (
ctx = context.Background()
client = coderdtest.New(t, nil)
_ = coderdtest.NewProvisionerDaemon(t, client)
user = coderdtest.CreateFirstUser(t, client)
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID)
cmdArgs = []string{"autostart", "show", workspace.Name}
sched = "CRON_TZ=Europe/Dublin 30 17 * * 1-5"
stdoutBuf = &bytes.Buffer{}
)
err := client.UpdateWorkspaceAutostart(ctx, workspace.ID, codersdk.UpdateWorkspaceAutostartRequest{
Schedule: sched,
})
require.NoError(t, err)
cmd, root := clitest.New(t, cmdArgs...)
clitest.SetupConfig(t, client, root)
cmd.SetOut(stdoutBuf)
err = cmd.Execute()
require.NoError(t, err, "unexpected error")
// CRON_TZ gets stripped
require.Contains(t, stdoutBuf.String(), "schedule: 30 17 * * 1-5")
})
t.Run("EnableDisableOK", func(t *testing.T) {
t.Parallel()
var (
ctx = context.Background()
client = coderdtest.New(t, nil)
_ = coderdtest.NewProvisionerDaemon(t, client)
user = coderdtest.CreateFirstUser(t, client)
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID)
tz = "Europe/Dublin"
cmdArgs = []string{"autostart", "enable", workspace.Name, "--minute", "30", "--hour", "9", "--days", "1-5", "--tz", tz}
sched = "CRON_TZ=Europe/Dublin 30 9 * * 1-5"
stdoutBuf = &bytes.Buffer{}
)
cmd, root := clitest.New(t, cmdArgs...)
clitest.SetupConfig(t, client, root)
cmd.SetOut(stdoutBuf)
err := cmd.Execute()
require.NoError(t, err, "unexpected error")
require.Contains(t, stdoutBuf.String(), "will automatically start at", "unexpected output")
// Ensure autostart schedule updated
updated, err := client.Workspace(ctx, workspace.ID)
require.NoError(t, err, "fetch updated workspace")
require.Equal(t, sched, updated.AutostartSchedule, "expected autostart schedule to be set")
// Disable schedule
cmd, root = clitest.New(t, "autostart", "disable", workspace.Name)
clitest.SetupConfig(t, client, root)
cmd.SetOut(stdoutBuf)
err = cmd.Execute()
require.NoError(t, err, "unexpected error")
require.Contains(t, stdoutBuf.String(), "will no longer automatically start", "unexpected output")
// Ensure autostart schedule updated
updated, err = client.Workspace(ctx, workspace.ID)
require.NoError(t, err, "fetch updated workspace")
require.Empty(t, updated.AutostartSchedule, "expected autostart schedule to not be set")
})
t.Run("Enable_NotFound", func(t *testing.T) {
t.Parallel()
var (
client = coderdtest.New(t, nil)
_ = coderdtest.NewProvisionerDaemon(t, client)
user = coderdtest.CreateFirstUser(t, client)
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
)
cmd, root := clitest.New(t, "autostart", "enable", "doesnotexist")
clitest.SetupConfig(t, client, root)
err := cmd.Execute()
require.ErrorContains(t, err, "status code 404: no workspace found by name", "unexpected error")
})
t.Run("Disable_NotFound", func(t *testing.T) {
t.Parallel()
var (
client = coderdtest.New(t, nil)
_ = coderdtest.NewProvisionerDaemon(t, client)
user = coderdtest.CreateFirstUser(t, client)
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
)
cmd, root := clitest.New(t, "autostart", "disable", "doesnotexist")
clitest.SetupConfig(t, client, root)
err := cmd.Execute()
require.ErrorContains(t, err, "status code 404: no workspace found by name", "unexpected error")
})
t.Run("Enable_DefaultSchedule", func(t *testing.T) {
t.Parallel()
var (
ctx = context.Background()
client = coderdtest.New(t, nil)
_ = coderdtest.NewProvisionerDaemon(t, client)
user = coderdtest.CreateFirstUser(t, client)
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID)
)
// check current TZ env var
currTz := os.Getenv("TZ")
if currTz == "" {
currTz = "UTC"
}
expectedSchedule := fmt.Sprintf("CRON_TZ=%s 0 9 * * 1-5", currTz)
cmd, root := clitest.New(t, "autostart", "enable", workspace.Name)
clitest.SetupConfig(t, client, root)
err := cmd.Execute()
require.NoError(t, err, "unexpected error")
// Ensure nothing happened
updated, err := client.Workspace(ctx, workspace.ID)
require.NoError(t, err, "fetch updated workspace")
require.Equal(t, expectedSchedule, updated.AutostartSchedule, "expected default autostart schedule")
})
}
-167
View File
@@ -1,167 +0,0 @@
package cli
import (
"fmt"
"os"
"time"
"github.com/spf13/cobra"
"github.com/coder/coder/coderd/autobuild/schedule"
"github.com/coder/coder/codersdk"
)
const autostopDescriptionLong = `To have your workspace stop automatically at a regular time you can enable autostop.
When enabling autostop, provide the minute, hour, and day(s) of week.
The default autostop schedule is at 18:00 in your local timezone (TZ env, UTC by default).
`
func autostop() *cobra.Command {
autostopCmd := &cobra.Command{
Annotations: workspaceCommand,
Use: "autostop enable <workspace>",
Short: "schedule a workspace to automatically stop at a regular time",
Long: autostopDescriptionLong,
Example: "coder autostop enable my-workspace --minute 0 --hour 18 --days 1-5 -tz Europe/Dublin",
}
autostopCmd.AddCommand(autostopShow())
autostopCmd.AddCommand(autostopEnable())
autostopCmd.AddCommand(autostopDisable())
return autostopCmd
}
func autostopShow() *cobra.Command {
cmd := &cobra.Command{
Use: "show <workspace_name>",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
return err
}
organization, err := currentOrganization(cmd, client)
if err != nil {
return err
}
workspace, err := client.WorkspaceByOwnerAndName(cmd.Context(), organization.ID, codersdk.Me, args[0])
if err != nil {
return err
}
if workspace.AutostopSchedule == "" {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "not enabled\n")
return nil
}
validSchedule, err := schedule.Weekly(workspace.AutostopSchedule)
if err != nil {
// This should never happen.
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "invalid autostop schedule %q for workspace %s: %s\n", workspace.AutostopSchedule, workspace.Name, err.Error())
return nil
}
next := validSchedule.Next(time.Now())
loc, _ := time.LoadLocation(validSchedule.Timezone())
_, _ = fmt.Fprintf(cmd.OutOrStdout(),
"schedule: %s\ntimezone: %s\nnext: %s\n",
validSchedule.Cron(),
validSchedule.Timezone(),
next.In(loc),
)
return nil
},
}
return cmd
}
func autostopEnable() *cobra.Command {
// yes some of these are technically numbers but the cron library will do that work
var autostopMinute string
var autostopHour string
var autostopDayOfWeek string
var autostopTimezone string
cmd := &cobra.Command{
Use: "enable <workspace_name> <schedule>",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
return err
}
organization, err := currentOrganization(cmd, client)
if err != nil {
return err
}
spec := fmt.Sprintf("CRON_TZ=%s %s %s * * %s", autostopTimezone, autostopMinute, autostopHour, autostopDayOfWeek)
validSchedule, err := schedule.Weekly(spec)
if err != nil {
return err
}
workspace, err := client.WorkspaceByOwnerAndName(cmd.Context(), organization.ID, codersdk.Me, args[0])
if err != nil {
return err
}
err = client.UpdateWorkspaceAutostop(cmd.Context(), workspace.ID, codersdk.UpdateWorkspaceAutostopRequest{
Schedule: validSchedule.String(),
})
if err != nil {
return err
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace will automatically stop at %s.\n\n", workspace.Name, validSchedule.Next(time.Now()))
return nil
},
}
cmd.Flags().StringVar(&autostopMinute, "minute", "0", "autostop minute")
cmd.Flags().StringVar(&autostopHour, "hour", "18", "autostop hour")
cmd.Flags().StringVar(&autostopDayOfWeek, "days", "1-5", "autostop day(s) of week")
tzEnv := os.Getenv("TZ")
if tzEnv == "" {
tzEnv = "UTC"
}
cmd.Flags().StringVar(&autostopTimezone, "tz", tzEnv, "autostop timezone")
return cmd
}
func autostopDisable() *cobra.Command {
return &cobra.Command{
Use: "disable <workspace_name>",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
if err != nil {
return err
}
organization, err := currentOrganization(cmd, client)
if err != nil {
return err
}
workspace, err := client.WorkspaceByOwnerAndName(cmd.Context(), organization.ID, codersdk.Me, args[0])
if err != nil {
return err
}
err = client.UpdateWorkspaceAutostop(cmd.Context(), workspace.ID, codersdk.UpdateWorkspaceAutostopRequest{
Schedule: "",
})
if err != nil {
return err
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace will no longer automatically stop.\n\n", workspace.Name)
return nil
},
}
}
-165
View File
@@ -1,165 +0,0 @@
package cli_test
import (
"bytes"
"context"
"fmt"
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/codersdk"
)
func TestAutostop(t *testing.T) {
t.Parallel()
t.Run("ShowOK", func(t *testing.T) {
t.Parallel()
var (
ctx = context.Background()
client = coderdtest.New(t, nil)
_ = coderdtest.NewProvisionerDaemon(t, client)
user = coderdtest.CreateFirstUser(t, client)
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID)
cmdArgs = []string{"autostop", "show", workspace.Name}
sched = "CRON_TZ=Europe/Dublin 30 17 * * 1-5"
stdoutBuf = &bytes.Buffer{}
)
err := client.UpdateWorkspaceAutostop(ctx, workspace.ID, codersdk.UpdateWorkspaceAutostopRequest{
Schedule: sched,
})
require.NoError(t, err)
cmd, root := clitest.New(t, cmdArgs...)
clitest.SetupConfig(t, client, root)
cmd.SetOut(stdoutBuf)
err = cmd.Execute()
require.NoError(t, err, "unexpected error")
// CRON_TZ gets stripped
require.Contains(t, stdoutBuf.String(), "schedule: 30 17 * * 1-5")
})
t.Run("EnableDisableOK", func(t *testing.T) {
t.Parallel()
var (
ctx = context.Background()
client = coderdtest.New(t, nil)
_ = coderdtest.NewProvisionerDaemon(t, client)
user = coderdtest.CreateFirstUser(t, client)
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID)
cmdArgs = []string{"autostop", "enable", workspace.Name, "--minute", "30", "--hour", "17", "--days", "1-5", "--tz", "Europe/Dublin"}
sched = "CRON_TZ=Europe/Dublin 30 17 * * 1-5"
stdoutBuf = &bytes.Buffer{}
)
cmd, root := clitest.New(t, cmdArgs...)
clitest.SetupConfig(t, client, root)
cmd.SetOut(stdoutBuf)
err := cmd.Execute()
require.NoError(t, err, "unexpected error")
require.Contains(t, stdoutBuf.String(), "will automatically stop at", "unexpected output")
// Ensure autostop schedule updated
updated, err := client.Workspace(ctx, workspace.ID)
require.NoError(t, err, "fetch updated workspace")
require.Equal(t, sched, updated.AutostopSchedule, "expected autostop schedule to be set")
// Disable schedule
cmd, root = clitest.New(t, "autostop", "disable", workspace.Name)
clitest.SetupConfig(t, client, root)
cmd.SetOut(stdoutBuf)
err = cmd.Execute()
require.NoError(t, err, "unexpected error")
require.Contains(t, stdoutBuf.String(), "will no longer automatically stop", "unexpected output")
// Ensure autostop schedule updated
updated, err = client.Workspace(ctx, workspace.ID)
require.NoError(t, err, "fetch updated workspace")
require.Empty(t, updated.AutostopSchedule, "expected autostop schedule to not be set")
})
t.Run("Enable_NotFound", func(t *testing.T) {
t.Parallel()
var (
client = coderdtest.New(t, nil)
_ = coderdtest.NewProvisionerDaemon(t, client)
user = coderdtest.CreateFirstUser(t, client)
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
)
cmd, root := clitest.New(t, "autostop", "enable", "doesnotexist")
clitest.SetupConfig(t, client, root)
err := cmd.Execute()
require.ErrorContains(t, err, "status code 404: no workspace found by name", "unexpected error")
})
t.Run("Disable_NotFound", func(t *testing.T) {
t.Parallel()
var (
client = coderdtest.New(t, nil)
_ = coderdtest.NewProvisionerDaemon(t, client)
user = coderdtest.CreateFirstUser(t, client)
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
)
cmd, root := clitest.New(t, "autostop", "disable", "doesnotexist")
clitest.SetupConfig(t, client, root)
err := cmd.Execute()
require.ErrorContains(t, err, "status code 404: no workspace found by name", "unexpected error")
})
t.Run("Enable_DefaultSchedule", func(t *testing.T) {
t.Parallel()
var (
ctx = context.Background()
client = coderdtest.New(t, nil)
_ = coderdtest.NewProvisionerDaemon(t, client)
user = coderdtest.CreateFirstUser(t, client)
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID)
)
// check current TZ env var
currTz := os.Getenv("TZ")
if currTz == "" {
currTz = "UTC"
}
expectedSchedule := fmt.Sprintf("CRON_TZ=%s 0 18 * * 1-5", currTz)
cmd, root := clitest.New(t, "autostop", "enable", workspace.Name)
clitest.SetupConfig(t, client, root)
err := cmd.Execute()
require.NoError(t, err, "unexpected error")
// Ensure nothing happened
updated, err := client.Workspace(ctx, workspace.ID)
require.NoError(t, err, "fetch updated workspace")
require.Equal(t, expectedSchedule, updated.AutostopSchedule, "expected default autostop schedule")
})
}
+80
View File
@@ -0,0 +1,80 @@
// Package clibase offers an all-in-one solution for a highly configurable CLI
// application. Within Coder, we use it for all of our subcommands, which
// demands more functionality than cobra/viber offers.
//
// The Command interface is loosely based on the chi middleware pattern and
// http.Handler/HandlerFunc.
package clibase
import (
"strings"
"golang.org/x/exp/maps"
)
// Group describes a hierarchy of groups that an option or command belongs to.
type Group struct {
Parent *Group `json:"parent,omitempty"`
Name string `json:"name,omitempty"`
YAML string `json:"yaml,omitempty"`
Description string `json:"description,omitempty"`
}
// Ancestry returns the group and all of its parents, in order.
func (g *Group) Ancestry() []Group {
if g == nil {
return nil
}
groups := []Group{*g}
for p := g.Parent; p != nil; p = p.Parent {
// Prepend to the slice so that the order is correct.
groups = append([]Group{*p}, groups...)
}
return groups
}
func (g *Group) FullName() string {
var names []string
for _, g := range g.Ancestry() {
names = append(names, g.Name)
}
return strings.Join(names, " / ")
}
// Annotations is an arbitrary key-mapping used to extend the Option and Command types.
// Its methods won't panic if the map is nil.
type Annotations map[string]string
// Mark sets a value on the annotations map, creating one
// if it doesn't exist. Mark does not mutate the original and
// returns a copy. It is suitable for chaining.
func (a Annotations) Mark(key string, value string) Annotations {
var aa Annotations
if a != nil {
aa = maps.Clone(a)
} else {
aa = make(Annotations)
}
aa[key] = value
return aa
}
// IsSet returns true if the key is set in the annotations map.
func (a Annotations) IsSet(key string) bool {
if a == nil {
return false
}
_, ok := a[key]
return ok
}
// Get retrieves a key from the map, returning false if the key is not found
// or the map is nil.
func (a Annotations) Get(key string) (string, bool) {
if a == nil {
return "", false
}
v, ok := a[key]
return v, ok
}
+567
View File
@@ -0,0 +1,567 @@
package clibase
import (
"context"
"errors"
"flag"
"fmt"
"io"
"os"
"strings"
"unicode"
"github.com/spf13/pflag"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"gopkg.in/yaml.v3"
)
// Cmd describes an executable command.
type Cmd struct {
// Parent is the direct parent of the command.
Parent *Cmd
// Children is a list of direct descendants.
Children []*Cmd
// Use is provided in form "command [flags] [args...]".
Use string
// Aliases is a list of alternative names for the command.
Aliases []string
// Short is a one-line description of the command.
Short string
// Hidden determines whether the command should be hidden from help.
Hidden bool
// RawArgs determines whether the command should receive unparsed arguments.
// No flags are parsed when set, and the command is responsible for parsing
// its own flags.
RawArgs bool
// Long is a detailed description of the command,
// presented on its help page. It may contain examples.
Long string
Options OptionSet
Annotations Annotations
// Middleware is called before the Handler.
// Use Chain() to combine multiple middlewares.
Middleware MiddlewareFunc
Handler HandlerFunc
HelpHandler HandlerFunc
}
// AddSubcommands adds the given subcommands, setting their
// Parent field automatically.
func (c *Cmd) AddSubcommands(cmds ...*Cmd) {
for _, cmd := range cmds {
cmd.Parent = c
c.Children = append(c.Children, cmd)
}
}
// Walk calls fn for the command and all its children.
func (c *Cmd) Walk(fn func(*Cmd)) {
fn(c)
for _, child := range c.Children {
child.Parent = c
child.Walk(fn)
}
}
// PrepareAll performs initialization and linting on the command and all its children.
func (c *Cmd) PrepareAll() error {
if c.Use == "" {
return xerrors.New("command must have a Use field so that it has a name")
}
var merr error
for i := range c.Options {
opt := &c.Options[i]
if opt.Name == "" {
switch {
case opt.Flag != "":
opt.Name = opt.Flag
case opt.Env != "":
opt.Name = opt.Env
case opt.YAML != "":
opt.Name = opt.YAML
default:
merr = errors.Join(merr, xerrors.Errorf("option must have a Name, Flag, Env or YAML field"))
}
}
if opt.Description != "" {
// Enforce that description uses sentence form.
if unicode.IsLower(rune(opt.Description[0])) {
merr = errors.Join(merr, xerrors.Errorf("option %q description should start with a capital letter", opt.Name))
}
if !strings.HasSuffix(opt.Description, ".") {
merr = errors.Join(merr, xerrors.Errorf("option %q description should end with a period", opt.Name))
}
}
}
slices.SortFunc(c.Options, func(a, b Option) bool {
return a.Name < b.Name
})
slices.SortFunc(c.Children, func(a, b *Cmd) bool {
return a.Name() < b.Name()
})
for _, child := range c.Children {
child.Parent = c
err := child.PrepareAll()
if err != nil {
merr = errors.Join(merr, xerrors.Errorf("command %v: %w", child.Name(), err))
}
}
return merr
}
// Name returns the first word in the Use string.
func (c *Cmd) Name() string {
return strings.Split(c.Use, " ")[0]
}
// FullName returns the full invocation name of the command,
// as seen on the command line.
func (c *Cmd) FullName() string {
var names []string
if c.Parent != nil {
names = append(names, c.Parent.FullName())
}
names = append(names, c.Name())
return strings.Join(names, " ")
}
// FullName returns usage of the command, preceded
// by the usage of its parents.
func (c *Cmd) FullUsage() string {
var uses []string
if c.Parent != nil {
uses = append(uses, c.Parent.FullName())
}
uses = append(uses, c.Use)
return strings.Join(uses, " ")
}
// FullOptions returns the options of the command and its parents.
func (c *Cmd) FullOptions() OptionSet {
var opts OptionSet
if c.Parent != nil {
opts = append(opts, c.Parent.FullOptions()...)
}
opts = append(opts, c.Options...)
return opts
}
// Invoke creates a new invocation of the command, with
// stdio discarded.
//
// The returned invocation is not live until Run() is called.
func (c *Cmd) Invoke(args ...string) *Invocation {
return &Invocation{
Command: c,
Args: args,
Stdout: io.Discard,
Stderr: io.Discard,
Stdin: strings.NewReader(""),
}
}
// Invocation represents an instance of a command being executed.
type Invocation struct {
ctx context.Context
Command *Cmd
parsedFlags *pflag.FlagSet
Args []string
// Environ is a list of environment variables. Use EnvsWithPrefix to parse
// os.Environ.
Environ Environ
Stdout io.Writer
Stderr io.Writer
Stdin io.Reader
}
// WithOS returns the invocation as a main package, filling in the invocation's unset
// fields with OS defaults.
func (inv *Invocation) WithOS() *Invocation {
return inv.with(func(i *Invocation) {
i.Stdout = os.Stdout
i.Stderr = os.Stderr
i.Stdin = os.Stdin
i.Args = os.Args[1:]
i.Environ = ParseEnviron(os.Environ(), "")
})
}
func (inv *Invocation) Context() context.Context {
if inv.ctx == nil {
return context.Background()
}
return inv.ctx
}
func (inv *Invocation) ParsedFlags() *pflag.FlagSet {
if inv.parsedFlags == nil {
panic("flags not parsed, has Run() been called?")
}
return inv.parsedFlags
}
type runState struct {
allArgs []string
commandDepth int
flagParseErr error
}
func copyFlagSetWithout(fs *pflag.FlagSet, without string) *pflag.FlagSet {
fs2 := pflag.NewFlagSet("", pflag.ContinueOnError)
fs2.Usage = func() {}
fs.VisitAll(func(f *pflag.Flag) {
if f.Name == without {
return
}
fs2.AddFlag(f)
})
return fs2
}
// run recursively executes the command and its children.
// allArgs is wired through the stack so that global flags can be accepted
// anywhere in the command invocation.
func (inv *Invocation) run(state *runState) error {
err := inv.Command.Options.ParseEnv(inv.Environ)
if err != nil {
return xerrors.Errorf("parsing env: %w", err)
}
// Now the fun part, argument parsing!
children := make(map[string]*Cmd)
for _, child := range inv.Command.Children {
child.Parent = inv.Command
for _, name := range append(child.Aliases, child.Name()) {
if _, ok := children[name]; ok {
return xerrors.Errorf("duplicate command name: %s", name)
}
children[name] = child
}
}
if inv.parsedFlags == nil {
inv.parsedFlags = pflag.NewFlagSet(inv.Command.Name(), pflag.ContinueOnError)
// We handle Usage ourselves.
inv.parsedFlags.Usage = func() {}
}
// If we find a duplicate flag, we want the deeper command's flag to override
// the shallow one. Unfortunately, pflag has no way to remove a flag, so we
// have to create a copy of the flagset without a value.
inv.Command.Options.FlagSet().VisitAll(func(f *pflag.Flag) {
if inv.parsedFlags.Lookup(f.Name) != nil {
inv.parsedFlags = copyFlagSetWithout(inv.parsedFlags, f.Name)
}
inv.parsedFlags.AddFlag(f)
})
var parsedArgs []string
if !inv.Command.RawArgs {
// Flag parsing will fail on intermediate commands in the command tree,
// so we check the error after looking for a child command.
state.flagParseErr = inv.parsedFlags.Parse(state.allArgs)
parsedArgs = inv.parsedFlags.Args()
}
// Set value sources for flags.
for i, opt := range inv.Command.Options {
if fl := inv.parsedFlags.Lookup(opt.Flag); fl != nil && fl.Changed {
inv.Command.Options[i].ValueSource = ValueSourceFlag
}
}
// Read YAML configs, if any.
for _, opt := range inv.Command.Options {
path, ok := opt.Value.(*YAMLConfigPath)
if !ok || path.String() == "" {
continue
}
byt, err := os.ReadFile(path.String())
if err != nil {
return xerrors.Errorf("reading yaml: %w", err)
}
var n yaml.Node
err = yaml.Unmarshal(byt, &n)
if err != nil {
return xerrors.Errorf("decoding yaml: %w", err)
}
err = inv.Command.Options.UnmarshalYAML(&n)
if err != nil {
return xerrors.Errorf("applying yaml: %w", err)
}
}
err = inv.Command.Options.SetDefaults()
if err != nil {
return xerrors.Errorf("setting defaults: %w", err)
}
// Run child command if found (next child only)
// We must do subcommand detection after flag parsing so we don't mistake flag
// values for subcommand names.
if len(parsedArgs) > state.commandDepth {
nextArg := parsedArgs[state.commandDepth]
if child, ok := children[nextArg]; ok {
child.Parent = inv.Command
inv.Command = child
state.commandDepth++
return inv.run(state)
}
}
// Flag parse errors are irrelevant for raw args commands.
if !inv.Command.RawArgs && state.flagParseErr != nil && !errors.Is(state.flagParseErr, pflag.ErrHelp) {
return xerrors.Errorf(
"parsing flags (%v) for %q: %w",
state.allArgs,
inv.Command.FullName(), state.flagParseErr,
)
}
if inv.Command.RawArgs {
// If we're at the root command, then the name is omitted
// from the arguments, so we can just use the entire slice.
if state.commandDepth == 0 {
inv.Args = state.allArgs
} else {
argPos, err := findArg(inv.Command.Name(), state.allArgs, inv.parsedFlags)
if err != nil {
panic(err)
}
inv.Args = state.allArgs[argPos+1:]
}
} else {
// In non-raw-arg mode, we want to skip over flags.
inv.Args = parsedArgs[state.commandDepth:]
}
mw := inv.Command.Middleware
if mw == nil {
mw = Chain()
}
ctx := inv.ctx
if ctx == nil {
ctx = context.Background()
}
ctx, cancel := context.WithCancel(ctx)
defer cancel()
inv = inv.WithContext(ctx)
if inv.Command.Handler == nil || errors.Is(state.flagParseErr, pflag.ErrHelp) {
if inv.Command.HelpHandler == nil {
return xerrors.Errorf("no handler or help for command %s", inv.Command.FullName())
}
return inv.Command.HelpHandler(inv)
}
err = mw(inv.Command.Handler)(inv)
if err != nil {
return &RunCommandError{
Cmd: inv.Command,
Err: err,
}
}
return nil
}
type RunCommandError struct {
Cmd *Cmd
Err error
}
func (e *RunCommandError) Unwrap() error {
return e.Err
}
func (e *RunCommandError) Error() string {
return fmt.Sprintf("running command %q: %+v", e.Cmd.FullName(), e.Err)
}
// findArg returns the index of the first occurrence of arg in args, skipping
// over all flags.
func findArg(want string, args []string, fs *pflag.FlagSet) (int, error) {
for i := 0; i < len(args); i++ {
arg := args[i]
if !strings.HasPrefix(arg, "-") {
if arg == want {
return i, nil
}
continue
}
// This is a flag!
if strings.Contains(arg, "=") {
// The flag contains the value in the same arg, just skip.
continue
}
// We need to check if NoOptValue is set, then we should not wait
// for the next arg to be the value.
f := fs.Lookup(strings.TrimLeft(arg, "-"))
if f == nil {
return -1, xerrors.Errorf("unknown flag: %s", arg)
}
if f.NoOptDefVal != "" {
continue
}
if i == len(args)-1 {
return -1, xerrors.Errorf("flag %s requires a value", arg)
}
// Skip the value.
i++
}
return -1, xerrors.Errorf("arg %s not found", want)
}
// Run executes the command.
// If two command share a flag name, the first command wins.
//
//nolint:revive
func (inv *Invocation) Run() (err error) {
defer func() {
// Pflag is panicky, so additional context is helpful in tests.
if flag.Lookup("test.v") == nil {
return
}
if r := recover(); r != nil {
err = xerrors.Errorf("panic recovered for %s: %v", inv.Command.FullName(), r)
panic(err)
}
}()
// We close Stdin to prevent deadlocks, e.g. when the command
// has ended but an io.Copy is still reading from Stdin.
defer func() {
if inv.Stdin == nil {
return
}
rc, ok := inv.Stdin.(io.ReadCloser)
if !ok {
return
}
e := rc.Close()
err = errors.Join(err, e)
}()
err = inv.run(&runState{
allArgs: inv.Args,
})
return err
}
// WithContext returns a copy of the Invocation with the given context.
func (inv *Invocation) WithContext(ctx context.Context) *Invocation {
return inv.with(func(i *Invocation) {
i.ctx = ctx
})
}
// with returns a copy of the Invocation with the given function applied.
func (inv *Invocation) with(fn func(*Invocation)) *Invocation {
i2 := *inv
fn(&i2)
return &i2
}
// MiddlewareFunc returns the next handler in the chain,
// or nil if there are no more.
type MiddlewareFunc func(next HandlerFunc) HandlerFunc
func chain(ms ...MiddlewareFunc) MiddlewareFunc {
return MiddlewareFunc(func(next HandlerFunc) HandlerFunc {
if len(ms) > 0 {
return chain(ms[1:]...)(ms[0](next))
}
return next
})
}
// Chain returns a Handler that first calls middleware in order.
//
//nolint:revive
func Chain(ms ...MiddlewareFunc) MiddlewareFunc {
// We need to reverse the array to provide top-to-bottom execution
// order when defining a command.
reversed := make([]MiddlewareFunc, len(ms))
for i := range ms {
reversed[len(ms)-1-i] = ms[i]
}
return chain(reversed...)
}
func RequireNArgs(want int) MiddlewareFunc {
return RequireRangeArgs(want, want)
}
// RequireRangeArgs returns a Middleware that requires the number of arguments
// to be between start and end (inclusive). If end is -1, then the number of
// arguments must be at least start.
func RequireRangeArgs(start, end int) MiddlewareFunc {
if start < 0 {
panic("start must be >= 0")
}
return func(next HandlerFunc) HandlerFunc {
return func(i *Invocation) error {
got := len(i.Args)
switch {
case start == end && got != start:
switch start {
case 0:
if len(i.Command.Children) > 0 {
return xerrors.Errorf("unrecognized subcommand %q", i.Args[0])
}
return xerrors.Errorf("wanted no args but got %v %v", got, i.Args)
default:
return xerrors.Errorf(
"wanted %v args but got %v %v",
start,
got,
i.Args,
)
}
case start > 0 && end == -1:
switch {
case got < start:
return xerrors.Errorf(
"wanted at least %v args but got %v",
start,
got,
)
default:
return next(i)
}
case start > end:
panic("start must be <= end")
case got < start || got > end:
return xerrors.Errorf(
"wanted between %v and %v args but got %v",
start, end,
got,
)
default:
return next(i)
}
}
}
}
// HandlerFunc handles an Invocation of a command.
type HandlerFunc func(i *Invocation) error
+635
View File
@@ -0,0 +1,635 @@
package clibase_test
import (
"bytes"
"context"
"fmt"
"os"
"strings"
"testing"
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"
"github.com/coder/coder/cli/clibase"
)
// ioBufs is the standard input, output, and error for a command.
type ioBufs struct {
Stdin bytes.Buffer
Stdout bytes.Buffer
Stderr bytes.Buffer
}
// fakeIO sets Stdin, Stdout, and Stderr to buffers.
func fakeIO(i *clibase.Invocation) *ioBufs {
var b ioBufs
i.Stdout = &b.Stdout
i.Stderr = &b.Stderr
i.Stdin = &b.Stdin
return &b
}
func TestCommand(t *testing.T) {
t.Parallel()
cmd := func() *clibase.Cmd {
var (
verbose bool
lower bool
prefix string
)
return &clibase.Cmd{
Use: "root [subcommand]",
Options: clibase.OptionSet{
clibase.Option{
Name: "verbose",
Flag: "verbose",
Value: clibase.BoolOf(&verbose),
},
clibase.Option{
Name: "prefix",
Flag: "prefix",
Value: clibase.StringOf(&prefix),
},
},
Children: []*clibase.Cmd{
{
Use: "toupper [word]",
Short: "Converts a word to upper case",
Middleware: clibase.Chain(
clibase.RequireNArgs(1),
),
Aliases: []string{"up"},
Options: clibase.OptionSet{
clibase.Option{
Name: "lower",
Flag: "lower",
Value: clibase.BoolOf(&lower),
},
},
Handler: (func(i *clibase.Invocation) error {
i.Stdout.Write([]byte(prefix))
w := i.Args[0]
if lower {
w = strings.ToLower(w)
} else {
w = strings.ToUpper(w)
}
_, _ = i.Stdout.Write(
[]byte(
w,
),
)
if verbose {
i.Stdout.Write([]byte("!!!"))
}
return nil
}),
},
},
}
}
t.Run("SimpleOK", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke("toupper", "hello")
io := fakeIO(i)
i.Run()
require.Equal(t, "HELLO", io.Stdout.String())
})
t.Run("Alias", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"up", "hello",
)
io := fakeIO(i)
i.Run()
require.Equal(t, "HELLO", io.Stdout.String())
})
t.Run("NoSubcommand", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"na",
)
io := fakeIO(i)
err := i.Run()
require.Empty(t, io.Stdout.String())
require.Error(t, err)
})
t.Run("BadArgs", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"toupper",
)
io := fakeIO(i)
err := i.Run()
require.Empty(t, io.Stdout.String())
require.Error(t, err)
})
t.Run("UnknownFlags", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"toupper", "--unknown",
)
io := fakeIO(i)
err := i.Run()
require.Empty(t, io.Stdout.String())
require.Error(t, err)
})
t.Run("Verbose", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"--verbose", "toupper", "hello",
)
io := fakeIO(i)
require.NoError(t, i.Run())
require.Equal(t, "HELLO!!!", io.Stdout.String())
})
t.Run("Verbose=", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"--verbose=true", "toupper", "hello",
)
io := fakeIO(i)
require.NoError(t, i.Run())
require.Equal(t, "HELLO!!!", io.Stdout.String())
})
t.Run("PrefixSpace", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"--prefix", "conv: ", "toupper", "hello",
)
io := fakeIO(i)
require.NoError(t, i.Run())
require.Equal(t, "conv: HELLO", io.Stdout.String())
})
t.Run("GlobalFlagsAnywhere", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"toupper", "--prefix", "conv: ", "hello", "--verbose",
)
io := fakeIO(i)
require.NoError(t, i.Run())
require.Equal(t, "conv: HELLO!!!", io.Stdout.String())
})
t.Run("LowerVerbose", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"toupper", "--verbose", "hello", "--lower",
)
io := fakeIO(i)
require.NoError(t, i.Run())
require.Equal(t, "hello!!!", io.Stdout.String())
})
t.Run("ParsedFlags", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"toupper", "--verbose", "hello", "--lower",
)
_ = fakeIO(i)
require.NoError(t, i.Run())
require.Equal(t,
"true",
i.ParsedFlags().Lookup("verbose").Value.String(),
)
})
t.Run("NoDeepChild", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"root", "level", "level", "toupper", "--verbose", "hello", "--lower",
)
fio := fakeIO(i)
require.Error(t, i.Run(), fio.Stdout.String())
})
}
func TestCommand_DeepNest(t *testing.T) {
t.Parallel()
cmd := &clibase.Cmd{
Use: "1",
Children: []*clibase.Cmd{
{
Use: "2",
Children: []*clibase.Cmd{
{
Use: "3",
Handler: func(i *clibase.Invocation) error {
i.Stdout.Write([]byte("3"))
return nil
},
},
},
},
},
}
inv := cmd.Invoke("2", "3")
stdio := fakeIO(inv)
err := inv.Run()
require.NoError(t, err)
require.Equal(t, "3", stdio.Stdout.String())
}
func TestCommand_FlagOverride(t *testing.T) {
t.Parallel()
var flag string
cmd := &clibase.Cmd{
Use: "1",
Options: clibase.OptionSet{
{
Name: "flag",
Flag: "f",
Value: clibase.DiscardValue,
},
},
Children: []*clibase.Cmd{
{
Use: "2",
Options: clibase.OptionSet{
{
Name: "flag",
Flag: "f",
Value: clibase.StringOf(&flag),
},
},
Handler: func(i *clibase.Invocation) error {
return nil
},
},
},
}
err := cmd.Invoke("2", "--f", "mhmm").Run()
require.NoError(t, err)
require.Equal(t, "mhmm", flag)
}
func TestCommand_MiddlewareOrder(t *testing.T) {
t.Parallel()
mw := func(letter string) clibase.MiddlewareFunc {
return func(next clibase.HandlerFunc) clibase.HandlerFunc {
return (func(i *clibase.Invocation) error {
_, _ = i.Stdout.Write([]byte(letter))
return next(i)
})
}
}
cmd := &clibase.Cmd{
Use: "toupper [word]",
Short: "Converts a word to upper case",
Middleware: clibase.Chain(
mw("A"),
mw("B"),
mw("C"),
),
Handler: (func(i *clibase.Invocation) error {
return nil
}),
}
i := cmd.Invoke(
"hello", "world",
)
io := fakeIO(i)
require.NoError(t, i.Run())
require.Equal(t, "ABC", io.Stdout.String())
}
func TestCommand_RawArgs(t *testing.T) {
t.Parallel()
cmd := func() *clibase.Cmd {
return &clibase.Cmd{
Use: "root",
Options: clibase.OptionSet{
{
Name: "password",
Flag: "password",
Value: clibase.StringOf(new(string)),
},
},
Children: []*clibase.Cmd{
{
Use: "sushi <args...>",
Short: "Throws back raw output",
RawArgs: true,
Handler: (func(i *clibase.Invocation) error {
if v := i.ParsedFlags().Lookup("password").Value.String(); v != "codershack" {
return xerrors.Errorf("password %q is wrong!", v)
}
i.Stdout.Write([]byte(strings.Join(i.Args, " ")))
return nil
}),
},
},
}
}
t.Run("OK", func(t *testing.T) {
// Flag parsed before the raw arg command should still work.
t.Parallel()
i := cmd().Invoke(
"--password", "codershack", "sushi", "hello", "--verbose", "world",
)
io := fakeIO(i)
require.NoError(t, i.Run())
require.Equal(t, "hello --verbose world", io.Stdout.String())
})
t.Run("BadFlag", func(t *testing.T) {
// Verbose before the raw arg command should fail.
t.Parallel()
i := cmd().Invoke(
"--password", "codershack", "--verbose", "sushi", "hello", "world",
)
io := fakeIO(i)
require.Error(t, i.Run())
require.Empty(t, io.Stdout.String())
})
t.Run("NoPassword", func(t *testing.T) {
// Flag parsed before the raw arg command should still work.
t.Parallel()
i := cmd().Invoke(
"sushi", "hello", "--verbose", "world",
)
_ = fakeIO(i)
require.Error(t, i.Run())
})
}
func TestCommand_RootRaw(t *testing.T) {
t.Parallel()
cmd := &clibase.Cmd{
RawArgs: true,
Handler: func(i *clibase.Invocation) error {
i.Stdout.Write([]byte(strings.Join(i.Args, " ")))
return nil
},
}
inv := cmd.Invoke("hello", "--verbose", "--friendly")
stdio := fakeIO(inv)
err := inv.Run()
require.NoError(t, err)
require.Equal(t, "hello --verbose --friendly", stdio.Stdout.String())
}
func TestCommand_HyphenHyphen(t *testing.T) {
t.Parallel()
cmd := &clibase.Cmd{
Handler: (func(i *clibase.Invocation) error {
i.Stdout.Write([]byte(strings.Join(i.Args, " ")))
return nil
}),
}
inv := cmd.Invoke("--", "--verbose", "--friendly")
stdio := fakeIO(inv)
err := inv.Run()
require.NoError(t, err)
require.Equal(t, "--verbose --friendly", stdio.Stdout.String())
}
func TestCommand_ContextCancels(t *testing.T) {
t.Parallel()
var gotCtx context.Context
cmd := &clibase.Cmd{
Handler: (func(i *clibase.Invocation) error {
gotCtx = i.Context()
if err := gotCtx.Err(); err != nil {
return xerrors.Errorf("unexpected context error: %w", i.Context().Err())
}
return nil
}),
}
err := cmd.Invoke().Run()
require.NoError(t, err)
require.Error(t, gotCtx.Err())
}
func TestCommand_Help(t *testing.T) {
t.Parallel()
cmd := func() *clibase.Cmd {
return &clibase.Cmd{
Use: "root",
HelpHandler: (func(i *clibase.Invocation) error {
i.Stdout.Write([]byte("abdracadabra"))
return nil
}),
Handler: (func(i *clibase.Invocation) error {
return xerrors.New("should not be called")
}),
}
}
t.Run("NoHandler", func(t *testing.T) {
t.Parallel()
c := cmd()
c.HelpHandler = nil
err := c.Invoke("--help").Run()
require.Error(t, err)
})
t.Run("Long", func(t *testing.T) {
t.Parallel()
inv := cmd().Invoke("--help")
stdio := fakeIO(inv)
err := inv.Run()
require.NoError(t, err)
require.Contains(t, stdio.Stdout.String(), "abdracadabra")
})
t.Run("Short", func(t *testing.T) {
t.Parallel()
inv := cmd().Invoke("-h")
stdio := fakeIO(inv)
err := inv.Run()
require.NoError(t, err)
require.Contains(t, stdio.Stdout.String(), "abdracadabra")
})
}
func TestCommand_SliceFlags(t *testing.T) {
t.Parallel()
cmd := func(want ...string) *clibase.Cmd {
var got []string
return &clibase.Cmd{
Use: "root",
Options: clibase.OptionSet{
{
Name: "arr",
Flag: "arr",
Default: "bad,bad,bad",
Value: clibase.StringArrayOf(&got),
},
},
Handler: (func(i *clibase.Invocation) error {
require.Equal(t, want, got)
return nil
}),
}
}
err := cmd("good", "good", "good").Invoke("--arr", "good", "--arr", "good", "--arr", "good").Run()
require.NoError(t, err)
err = cmd("bad", "bad", "bad").Invoke().Run()
require.NoError(t, err)
}
func TestCommand_EmptySlice(t *testing.T) {
t.Parallel()
cmd := func(want ...string) *clibase.Cmd {
var got []string
return &clibase.Cmd{
Use: "root",
Options: clibase.OptionSet{
{
Name: "arr",
Flag: "arr",
Default: "def,def,def",
Env: "ARR",
Value: clibase.StringArrayOf(&got),
},
},
Handler: (func(i *clibase.Invocation) error {
require.Equal(t, want, got)
return nil
}),
}
}
// Base-case, uses default.
err := cmd("def", "def", "def").Invoke().Run()
require.NoError(t, err)
// Empty-env uses default, too.
inv := cmd("def", "def", "def").Invoke()
inv.Environ.Set("ARR", "")
require.NoError(t, err)
// Reset to nothing at all via flag.
inv = cmd().Invoke("--arr", "")
inv.Environ.Set("ARR", "cant see")
err = inv.Run()
require.NoError(t, err)
// Reset to a specific value with flag.
inv = cmd("great").Invoke("--arr", "great")
inv.Environ.Set("ARR", "")
err = inv.Run()
require.NoError(t, err)
}
func TestCommand_DefaultsOverride(t *testing.T) {
t.Parallel()
test := func(name string, want string, fn func(t *testing.T, inv *clibase.Invocation)) {
t.Run(name, func(t *testing.T) {
t.Parallel()
var (
got string
config clibase.YAMLConfigPath
)
cmd := &clibase.Cmd{
Options: clibase.OptionSet{
{
Name: "url",
Flag: "url",
Default: "def.com",
Env: "URL",
Value: clibase.StringOf(&got),
YAML: "url",
},
{
Name: "config",
Flag: "config",
Default: "",
Value: &config,
},
},
Handler: (func(i *clibase.Invocation) error {
_, _ = fmt.Fprintf(i.Stdout, "%s", got)
return nil
}),
}
inv := cmd.Invoke()
stdio := fakeIO(inv)
fn(t, inv)
err := inv.Run()
require.NoError(t, err)
require.Equal(t, want, stdio.Stdout.String())
})
}
test("DefaultOverNothing", "def.com", func(t *testing.T, inv *clibase.Invocation) {})
test("FlagOverDefault", "good.com", func(t *testing.T, inv *clibase.Invocation) {
inv.Args = []string{"--url", "good.com"}
})
test("EnvOverDefault", "good.com", func(t *testing.T, inv *clibase.Invocation) {
inv.Environ.Set("URL", "good.com")
})
test("FlagOverEnv", "good.com", func(t *testing.T, inv *clibase.Invocation) {
inv.Environ.Set("URL", "bad.com")
inv.Args = []string{"--url", "good.com"}
})
test("FlagOverYAML", "good.com", func(t *testing.T, inv *clibase.Invocation) {
fi, err := os.CreateTemp(t.TempDir(), "config.yaml")
require.NoError(t, err)
defer fi.Close()
_, err = fi.WriteString("url: bad.com")
require.NoError(t, err)
inv.Args = []string{"--config", fi.Name(), "--url", "good.com"}
})
test("YAMLOverDefault", "good.com", func(t *testing.T, inv *clibase.Invocation) {
fi, err := os.CreateTemp(t.TempDir(), "config.yaml")
require.NoError(t, err)
defer fi.Close()
_, err = fi.WriteString("url: good.com")
require.NoError(t, err)
inv.Args = []string{"--config", fi.Name()}
})
}
+76
View File
@@ -0,0 +1,76 @@
package clibase
import "strings"
// name returns the name of the environment variable.
func envName(line string) string {
return strings.ToUpper(
strings.SplitN(line, "=", 2)[0],
)
}
// value returns the value of the environment variable.
func envValue(line string) string {
tokens := strings.SplitN(line, "=", 2)
if len(tokens) < 2 {
return ""
}
return tokens[1]
}
// Var represents a single environment variable of form
// NAME=VALUE.
type EnvVar struct {
Name string
Value string
}
type Environ []EnvVar
func (e Environ) ToOS() []string {
var env []string
for _, v := range e {
env = append(env, v.Name+"="+v.Value)
}
return env
}
func (e Environ) Lookup(name string) (string, bool) {
for _, v := range e {
if v.Name == name {
return v.Value, true
}
}
return "", false
}
func (e Environ) Get(name string) string {
v, _ := e.Lookup(name)
return v
}
func (e *Environ) Set(name, value string) {
for i, v := range *e {
if v.Name == name {
(*e)[i].Value = value
return
}
}
*e = append(*e, EnvVar{Name: name, Value: value})
}
// ParseEnviron returns all environment variables starting with
// prefix without said prefix.
func ParseEnviron(environ []string, prefix string) Environ {
var filtered []EnvVar
for _, line := range environ {
name := envName(line)
if strings.HasPrefix(name, prefix) {
filtered = append(filtered, EnvVar{
Name: strings.TrimPrefix(name, prefix),
Value: envValue(line),
})
}
}
return filtered
}
+44
View File
@@ -0,0 +1,44 @@
package clibase_test
import (
"reflect"
"testing"
"github.com/coder/coder/cli/clibase"
)
func TestFilterNamePrefix(t *testing.T) {
t.Parallel()
type args struct {
environ []string
prefix string
}
tests := []struct {
name string
args args
want clibase.Environ
}{
{"empty", args{[]string{}, "SHIRE"}, nil},
{
"ONE",
args{
[]string{
"SHIRE_BRANDYBUCK=hmm",
},
"SHIRE_",
},
[]clibase.EnvVar{
{Name: "BRANDYBUCK", Value: "hmm"},
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if got := clibase.ParseEnviron(tt.args.environ, tt.args.prefix); !reflect.DeepEqual(got, tt.want) {
t.Errorf("FilterNamePrefix() = %v, want %v", got, tt.want)
}
})
}
}
+231
View File
@@ -0,0 +1,231 @@
package clibase
import (
"os"
"strings"
"github.com/hashicorp/go-multierror"
"github.com/spf13/pflag"
"golang.org/x/xerrors"
)
type ValueSource string
const (
ValueSourceNone ValueSource = ""
ValueSourceFlag ValueSource = "flag"
ValueSourceEnv ValueSource = "env"
ValueSourceYAML ValueSource = "yaml"
ValueSourceDefault ValueSource = "default"
)
// Option is a configuration option for a CLI application.
type Option struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
// Flag is the long name of the flag used to configure this option. If unset,
// flag configuring is disabled.
Flag string `json:"flag,omitempty"`
// FlagShorthand is the one-character shorthand for the flag. If unset, no
// shorthand is used.
FlagShorthand string `json:"flag_shorthand,omitempty"`
// Env is the environment variable used to configure this option. If unset,
// environment configuring is disabled.
Env string `json:"env,omitempty"`
// YAML is the YAML key used to configure this option. If unset, YAML
// configuring is disabled.
YAML string `json:"yaml,omitempty"`
// Default is parsed into Value if set.
Default string `json:"default,omitempty"`
// Value includes the types listed in values.go.
Value pflag.Value `json:"value,omitempty"`
// Annotations enable extensions to clibase higher up in the stack. It's useful for
// help formatting and documentation generation.
Annotations Annotations `json:"annotations,omitempty"`
// Group is a group hierarchy that helps organize this option in help, configs
// and other documentation.
Group *Group `json:"group,omitempty"`
// UseInstead is a list of options that should be used instead of this one.
// The field is used to generate a deprecation warning.
UseInstead []Option `json:"use_instead,omitempty"`
Hidden bool `json:"hidden,omitempty"`
ValueSource ValueSource `json:"value_source,omitempty"`
}
func (o Option) YAMLPath() string {
if o.YAML == "" {
return ""
}
var gs []string
for _, g := range o.Group.Ancestry() {
gs = append(gs, g.YAML)
}
return strings.Join(append(gs, o.YAML), ".")
}
// OptionSet is a group of options that can be applied to a command.
type OptionSet []Option
// Add adds the given Options to the OptionSet.
func (s *OptionSet) Add(opts ...Option) {
*s = append(*s, opts...)
}
// Filter will only return options that match the given filter. (return true)
func (s OptionSet) Filter(filter func(opt Option) bool) OptionSet {
cpy := make(OptionSet, 0)
for _, opt := range s {
if filter(opt) {
cpy = append(cpy, opt)
}
}
return cpy
}
// FlagSet returns a pflag.FlagSet for the OptionSet.
func (s *OptionSet) FlagSet() *pflag.FlagSet {
if s == nil {
return &pflag.FlagSet{}
}
fs := pflag.NewFlagSet("", pflag.ContinueOnError)
for _, opt := range *s {
if opt.Flag == "" {
continue
}
var noOptDefValue string
{
no, ok := opt.Value.(NoOptDefValuer)
if ok {
noOptDefValue = no.NoOptDefValue()
}
}
val := opt.Value
if val == nil {
val = DiscardValue
}
fs.AddFlag(&pflag.Flag{
Name: opt.Flag,
Shorthand: opt.FlagShorthand,
Usage: opt.Description,
Value: val,
DefValue: "",
Changed: false,
Deprecated: "",
NoOptDefVal: noOptDefValue,
Hidden: opt.Hidden,
})
}
fs.Usage = func() {
_, _ = os.Stderr.WriteString("Override (*FlagSet).Usage() to print help text.\n")
}
return fs
}
// ParseEnv parses the given environment variables into the OptionSet.
// Use EnvsWithPrefix to filter out prefixes.
func (s *OptionSet) ParseEnv(vs []EnvVar) error {
if s == nil {
return nil
}
var merr *multierror.Error
// We parse environment variables first instead of using a nested loop to
// avoid N*M complexity when there are a lot of options and environment
// variables.
envs := make(map[string]string)
for _, v := range vs {
envs[v.Name] = v.Value
}
for i, opt := range *s {
if opt.Env == "" {
continue
}
envVal, ok := envs[opt.Env]
// Currently, empty values are treated as if the environment variable is
// unset. This behavior is technically not correct as there is now no
// way for a user to change a Default value to an empty string from
// the environment. Unfortunately, we have old configuration files
// that rely on the faulty behavior.
//
// TODO: We should remove this hack in May 2023, when deployments
// have had months to migrate to the new behavior.
if !ok || envVal == "" {
continue
}
(*s)[i].ValueSource = ValueSourceEnv
if err := opt.Value.Set(envVal); err != nil {
merr = multierror.Append(
merr, xerrors.Errorf("parse %q: %w", opt.Name, err),
)
}
}
return merr.ErrorOrNil()
}
// SetDefaults sets the default values for each Option, skipping values
// that already have a value source.
func (s *OptionSet) SetDefaults() error {
if s == nil {
return nil
}
var merr *multierror.Error
for i, opt := range *s {
// Skip values that may have already been set by the user.
if opt.ValueSource != ValueSourceNone {
continue
}
if opt.Default == "" {
continue
}
if opt.Value == nil {
merr = multierror.Append(
merr,
xerrors.Errorf(
"parse %q: no Value field set\nFull opt: %+v",
opt.Name, opt,
),
)
continue
}
(*s)[i].ValueSource = ValueSourceDefault
if err := opt.Value.Set(opt.Default); err != nil {
merr = multierror.Append(
merr, xerrors.Errorf("parse %q: %w", opt.Name, err),
)
}
}
return merr.ErrorOrNil()
}
// ByName returns the Option with the given name, or nil if no such option
// exists.
func (s *OptionSet) ByName(name string) *Option {
for i := range *s {
opt := &(*s)[i]
if opt.Name == name {
return opt
}
}
return nil
}
+169
View File
@@ -0,0 +1,169 @@
package clibase_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/clibase"
)
func TestOptionSet_ParseFlags(t *testing.T) {
t.Parallel()
t.Run("SimpleString", func(t *testing.T) {
t.Parallel()
var workspaceName clibase.String
os := clibase.OptionSet{
clibase.Option{
Name: "Workspace Name",
Value: &workspaceName,
Flag: "workspace-name",
FlagShorthand: "n",
},
}
var err error
err = os.FlagSet().Parse([]string{"--workspace-name", "foo"})
require.NoError(t, err)
require.EqualValues(t, "foo", workspaceName)
err = os.FlagSet().Parse([]string{"-n", "f"})
require.NoError(t, err)
require.EqualValues(t, "f", workspaceName)
})
t.Run("StringArray", func(t *testing.T) {
t.Parallel()
var names clibase.StringArray
os := clibase.OptionSet{
clibase.Option{
Name: "name",
Value: &names,
Flag: "name",
FlagShorthand: "n",
},
}
err := os.SetDefaults()
require.NoError(t, err)
err = os.FlagSet().Parse([]string{"--name", "foo", "--name", "bar"})
require.NoError(t, err)
require.EqualValues(t, []string{"foo", "bar"}, names)
})
t.Run("ExtraFlags", func(t *testing.T) {
t.Parallel()
var workspaceName clibase.String
os := clibase.OptionSet{
clibase.Option{
Name: "Workspace Name",
Value: &workspaceName,
},
}
err := os.FlagSet().Parse([]string{"--some-unknown", "foo"})
require.Error(t, err)
})
}
func TestOptionSet_ParseEnv(t *testing.T) {
t.Parallel()
t.Run("SimpleString", func(t *testing.T) {
t.Parallel()
var workspaceName clibase.String
os := clibase.OptionSet{
clibase.Option{
Name: "Workspace Name",
Value: &workspaceName,
Env: "WORKSPACE_NAME",
},
}
err := os.ParseEnv([]clibase.EnvVar{
{Name: "WORKSPACE_NAME", Value: "foo"},
})
require.NoError(t, err)
require.EqualValues(t, "foo", workspaceName)
})
t.Run("EmptyValue", func(t *testing.T) {
t.Parallel()
var workspaceName clibase.String
os := clibase.OptionSet{
clibase.Option{
Name: "Workspace Name",
Value: &workspaceName,
Default: "defname",
Env: "WORKSPACE_NAME",
},
}
err := os.SetDefaults()
require.NoError(t, err)
err = os.ParseEnv(clibase.ParseEnviron([]string{"CODER_WORKSPACE_NAME="}, "CODER_"))
require.NoError(t, err)
require.EqualValues(t, "defname", workspaceName)
})
t.Run("StringSlice", func(t *testing.T) {
t.Parallel()
var actual clibase.StringArray
expected := []string{"foo", "bar", "baz"}
os := clibase.OptionSet{
clibase.Option{
Name: "name",
Value: &actual,
Env: "NAMES",
},
}
err := os.SetDefaults()
require.NoError(t, err)
err = os.ParseEnv([]clibase.EnvVar{
{Name: "NAMES", Value: "foo,bar,baz"},
})
require.NoError(t, err)
require.EqualValues(t, expected, actual)
})
t.Run("StructMapStringString", func(t *testing.T) {
t.Parallel()
var actual clibase.Struct[map[string]string]
expected := map[string]string{"foo": "bar", "baz": "zap"}
os := clibase.OptionSet{
clibase.Option{
Name: "labels",
Value: &actual,
Env: "LABELS",
},
}
err := os.SetDefaults()
require.NoError(t, err)
err = os.ParseEnv([]clibase.EnvVar{
{Name: "LABELS", Value: `{"foo":"bar","baz":"zap"}`},
})
require.NoError(t, err)
require.EqualValues(t, expected, actual.Value)
})
}
+444
View File
@@ -0,0 +1,444 @@
package clibase
import (
"encoding/csv"
"encoding/json"
"fmt"
"net"
"net/url"
"reflect"
"strconv"
"strings"
"time"
"github.com/spf13/pflag"
"golang.org/x/xerrors"
"gopkg.in/yaml.v3"
)
// NoOptDefValuer describes behavior when no
// option is passed into the flag.
//
// This is useful for boolean or otherwise binary flags.
type NoOptDefValuer interface {
NoOptDefValue() string
}
// values.go contains a standard set of value types that can be used as
// Option Values.
type Int64 int64
func Int64Of(i *int64) *Int64 {
return (*Int64)(i)
}
func (i *Int64) Set(s string) error {
ii, err := strconv.ParseInt(s, 10, 64)
*i = Int64(ii)
return err
}
func (i Int64) Value() int64 {
return int64(i)
}
func (i Int64) String() string {
return strconv.Itoa(int(i))
}
func (Int64) Type() string {
return "int"
}
type Bool bool
func BoolOf(b *bool) *Bool {
return (*Bool)(b)
}
func (b *Bool) Set(s string) error {
if s == "" {
*b = Bool(false)
return nil
}
bb, err := strconv.ParseBool(s)
*b = Bool(bb)
return err
}
func (*Bool) NoOptDefValue() string {
return "true"
}
func (b Bool) String() string {
return strconv.FormatBool(bool(b))
}
func (b Bool) Value() bool {
return bool(b)
}
func (Bool) Type() string {
return "bool"
}
type String string
func StringOf(s *string) *String {
return (*String)(s)
}
func (*String) NoOptDefValue() string {
return ""
}
func (s *String) Set(v string) error {
*s = String(v)
return nil
}
func (s String) String() string {
return string(s)
}
func (s String) Value() string {
return string(s)
}
func (String) Type() string {
return "string"
}
var _ pflag.SliceValue = &StringArray{}
// StringArray is a slice of strings that implements pflag.Value and pflag.SliceValue.
type StringArray []string
func StringArrayOf(ss *[]string) *StringArray {
return (*StringArray)(ss)
}
func (s *StringArray) Append(v string) error {
*s = append(*s, v)
return nil
}
func (s *StringArray) Replace(vals []string) error {
*s = vals
return nil
}
func (s *StringArray) GetSlice() []string {
return *s
}
func readAsCSV(v string) ([]string, error) {
return csv.NewReader(strings.NewReader(v)).Read()
}
func writeAsCSV(vals []string) string {
var sb strings.Builder
err := csv.NewWriter(&sb).Write(vals)
if err != nil {
return fmt.Sprintf("error: %s", err)
}
return sb.String()
}
func (s *StringArray) Set(v string) error {
if v == "" {
*s = nil
return nil
}
ss, err := readAsCSV(v)
if err != nil {
return err
}
*s = append(*s, ss...)
return nil
}
func (s StringArray) String() string {
return writeAsCSV([]string(s))
}
func (s StringArray) Value() []string {
return []string(s)
}
func (StringArray) Type() string {
return "string-array"
}
type Duration time.Duration
func DurationOf(d *time.Duration) *Duration {
return (*Duration)(d)
}
func (d *Duration) Set(v string) error {
dd, err := time.ParseDuration(v)
*d = Duration(dd)
return err
}
func (d *Duration) Value() time.Duration {
return time.Duration(*d)
}
func (d *Duration) String() string {
return time.Duration(*d).String()
}
func (Duration) Type() string {
return "duration"
}
func (d *Duration) MarshalYAML() (interface{}, error) {
return yaml.Node{
Kind: yaml.ScalarNode,
Value: d.String(),
}, nil
}
func (d *Duration) UnmarshalYAML(n *yaml.Node) error {
return d.Set(n.Value)
}
type URL url.URL
func URLOf(u *url.URL) *URL {
return (*URL)(u)
}
func (u *URL) Set(v string) error {
uu, err := url.Parse(v)
if err != nil {
return err
}
*u = URL(*uu)
return nil
}
func (u *URL) String() string {
uu := url.URL(*u)
return uu.String()
}
func (u *URL) MarshalYAML() (interface{}, error) {
return yaml.Node{
Kind: yaml.ScalarNode,
Value: u.String(),
}, nil
}
func (u *URL) UnmarshalYAML(n *yaml.Node) error {
return u.Set(n.Value)
}
func (u *URL) MarshalJSON() ([]byte, error) {
return json.Marshal(u.String())
}
func (u *URL) UnmarshalJSON(b []byte) error {
var s string
err := json.Unmarshal(b, &s)
if err != nil {
return err
}
return u.Set(s)
}
func (*URL) Type() string {
return "url"
}
func (u *URL) Value() *url.URL {
return (*url.URL)(u)
}
// HostPort is a host:port pair.
type HostPort struct {
Host string
Port string
}
func (hp *HostPort) Set(v string) error {
if v == "" {
return xerrors.Errorf("must not be empty")
}
var err error
hp.Host, hp.Port, err = net.SplitHostPort(v)
return err
}
func (hp *HostPort) String() string {
if hp.Host == "" && hp.Port == "" {
return ""
}
// Warning: net.JoinHostPort must be used over concatenation to support
// IPv6 addresses.
return net.JoinHostPort(hp.Host, hp.Port)
}
func (hp *HostPort) MarshalJSON() ([]byte, error) {
return json.Marshal(hp.String())
}
func (hp *HostPort) UnmarshalJSON(b []byte) error {
var s string
err := json.Unmarshal(b, &s)
if err != nil {
return err
}
if s == "" {
hp.Host = ""
hp.Port = ""
return nil
}
return hp.Set(s)
}
func (hp *HostPort) MarshalYAML() (interface{}, error) {
return yaml.Node{
Kind: yaml.ScalarNode,
Value: hp.String(),
}, nil
}
func (hp *HostPort) UnmarshalYAML(n *yaml.Node) error {
return hp.Set(n.Value)
}
func (*HostPort) Type() string {
return "host:port"
}
var (
_ yaml.Marshaler = new(Struct[struct{}])
_ yaml.Unmarshaler = new(Struct[struct{}])
)
// Struct is a special value type that encodes an arbitrary struct.
// It implements the flag.Value interface, but in general these values should
// only be accepted via config for ergonomics.
//
// The string encoding type is YAML.
type Struct[T any] struct {
Value T
}
func (s *Struct[T]) Set(v string) error {
return yaml.Unmarshal([]byte(v), &s.Value)
}
func (s *Struct[T]) String() string {
byt, err := yaml.Marshal(s.Value)
if err != nil {
return "decode failed: " + err.Error()
}
return string(byt)
}
func (s *Struct[T]) MarshalYAML() (interface{}, error) {
var n yaml.Node
err := n.Encode(s.Value)
if err != nil {
return nil, err
}
return n, nil
}
func (s *Struct[T]) UnmarshalYAML(n *yaml.Node) error {
// HACK: for compatibility with flags, we use nil slices instead of empty
// slices. In most cases, nil slices and empty slices are treated
// the same, so this behavior may be removed at some point.
if typ := reflect.TypeOf(s.Value); typ.Kind() == reflect.Slice && len(n.Content) == 0 {
reflect.ValueOf(&s.Value).Elem().Set(reflect.Zero(typ))
return nil
}
return n.Decode(&s.Value)
}
func (s *Struct[T]) Type() string {
return fmt.Sprintf("struct[%T]", s.Value)
}
func (s *Struct[T]) MarshalJSON() ([]byte, error) {
return json.Marshal(s.Value)
}
func (s *Struct[T]) UnmarshalJSON(b []byte) error {
return json.Unmarshal(b, &s.Value)
}
// DiscardValue does nothing but implements the pflag.Value interface.
// It's useful in cases where you want to accept an option, but access the
// underlying value directly instead of through the Option methods.
var DiscardValue discardValue
type discardValue struct{}
func (discardValue) Set(string) error {
return nil
}
func (discardValue) String() string {
return ""
}
func (discardValue) Type() string {
return "discard"
}
var _ pflag.Value = (*Enum)(nil)
type Enum struct {
Choices []string
Value *string
}
func EnumOf(v *string, choices ...string) *Enum {
return &Enum{
Choices: choices,
Value: v,
}
}
func (e *Enum) Set(v string) error {
for _, c := range e.Choices {
if v == c {
*e.Value = v
return nil
}
}
return xerrors.Errorf("invalid choice: %s, should be one of %v", v, e.Choices)
}
func (e *Enum) Type() string {
return fmt.Sprintf("enum[%v]", strings.Join(e.Choices, "|"))
}
func (e *Enum) String() string {
return *e.Value
}
var _ pflag.Value = (*YAMLConfigPath)(nil)
// YAMLConfigPath is a special value type that encodes a path to a YAML
// configuration file where options are read from.
type YAMLConfigPath string
func (p *YAMLConfigPath) Set(v string) error {
*p = YAMLConfigPath(v)
return nil
}
func (p *YAMLConfigPath) String() string {
return string(*p)
}
func (*YAMLConfigPath) Type() string {
return "yaml-config-path"
}
+295
View File
@@ -0,0 +1,295 @@
package clibase
import (
"errors"
"fmt"
"strings"
"github.com/mitchellh/go-wordwrap"
"golang.org/x/xerrors"
"gopkg.in/yaml.v3"
)
var (
_ yaml.Marshaler = new(OptionSet)
_ yaml.Unmarshaler = new(OptionSet)
)
// deepMapNode returns the mapping node at the given path,
// creating it if it doesn't exist.
func deepMapNode(n *yaml.Node, path []string, headComment string) *yaml.Node {
if len(path) == 0 {
return n
}
// Name is every two nodes.
for i := 0; i < len(n.Content)-1; i += 2 {
if n.Content[i].Value == path[0] {
// Found matching name, recurse.
return deepMapNode(n.Content[i+1], path[1:], headComment)
}
}
// Not found, create it.
nameNode := yaml.Node{
Kind: yaml.ScalarNode,
Value: path[0],
HeadComment: headComment,
}
valueNode := yaml.Node{
Kind: yaml.MappingNode,
}
n.Content = append(n.Content, &nameNode)
n.Content = append(n.Content, &valueNode)
return deepMapNode(&valueNode, path[1:], headComment)
}
// MarshalYAML converts the option set to a YAML node, that can be
// converted into bytes via yaml.Marshal.
//
// The node is returned to enable post-processing higher up in
// the stack.
//
// It is isomorphic with FromYAML.
func (s *OptionSet) MarshalYAML() (any, error) {
root := yaml.Node{
Kind: yaml.MappingNode,
}
for _, opt := range *s {
if opt.YAML == "" {
continue
}
defValue := opt.Default
if defValue == "" {
defValue = "<unset>"
}
comment := wordwrap.WrapString(
fmt.Sprintf("%s\n(default: %s, type: %s)", opt.Description, defValue, opt.Value.Type()),
80,
)
nameNode := yaml.Node{
Kind: yaml.ScalarNode,
Value: opt.YAML,
HeadComment: comment,
}
var valueNode yaml.Node
if opt.Value == nil {
valueNode = yaml.Node{
Kind: yaml.ScalarNode,
Value: "null",
}
} else if m, ok := opt.Value.(yaml.Marshaler); ok {
v, err := m.MarshalYAML()
if err != nil {
return nil, xerrors.Errorf(
"marshal %q: %w", opt.Name, err,
)
}
valueNode, ok = v.(yaml.Node)
if !ok {
return nil, xerrors.Errorf(
"marshal %q: unexpected underlying type %T",
opt.Name, v,
)
}
} else {
// The all-other types case.
//
// A bit of a hack, we marshal and then unmarshal to get
// the underlying node.
byt, err := yaml.Marshal(opt.Value)
if err != nil {
return nil, xerrors.Errorf(
"marshal %q: %w", opt.Name, err,
)
}
var docNode yaml.Node
err = yaml.Unmarshal(byt, &docNode)
if err != nil {
return nil, xerrors.Errorf(
"unmarshal %q: %w", opt.Name, err,
)
}
if len(docNode.Content) != 1 {
return nil, xerrors.Errorf(
"unmarshal %q: expected one node, got %d",
opt.Name, len(docNode.Content),
)
}
valueNode = *docNode.Content[0]
}
var group []string
for _, g := range opt.Group.Ancestry() {
if g.YAML == "" {
return nil, xerrors.Errorf(
"group yaml name is empty for %q, groups: %+v",
opt.Name,
opt.Group,
)
}
group = append(group, g.YAML)
}
var groupDesc string
if opt.Group != nil {
groupDesc = wordwrap.WrapString(opt.Group.Description, 80)
}
parentValueNode := deepMapNode(
&root, group,
groupDesc,
)
parentValueNode.Content = append(
parentValueNode.Content,
&nameNode,
&valueNode,
)
}
return &root, nil
}
// mapYAMLNodes converts parent into a map with keys of form "group.subgroup.option"
// and values as the corresponding YAML nodes.
func mapYAMLNodes(parent *yaml.Node) (map[string]*yaml.Node, error) {
if parent.Kind != yaml.MappingNode {
return nil, xerrors.Errorf("expected mapping node, got type %v", parent.Kind)
}
if len(parent.Content)%2 != 0 {
return nil, xerrors.Errorf("expected an even number of k/v pairs, got %d", len(parent.Content))
}
var (
key string
m = make(map[string]*yaml.Node, len(parent.Content)/2)
merr error
)
for i, child := range parent.Content {
if i%2 == 0 {
if child.Kind != yaml.ScalarNode {
// We immediately because the rest of the code is bound to fail
// if we don't know to expect a key or a value.
return nil, xerrors.Errorf("expected scalar node for key, got type %v", child.Kind)
}
key = child.Value
continue
}
// We don't know if this is a grouped simple option or complex option,
// so we store both "key" and "group.key". Since we're storing pointers,
// the additional memory is of little concern.
m[key] = child
if child.Kind != yaml.MappingNode {
continue
}
sub, err := mapYAMLNodes(child)
if err != nil {
merr = errors.Join(merr, xerrors.Errorf("mapping node %q: %w", key, err))
continue
}
for k, v := range sub {
m[key+"."+k] = v
}
}
return m, nil
}
func (o *Option) setFromYAMLNode(n *yaml.Node) error {
o.ValueSource = ValueSourceYAML
if um, ok := o.Value.(yaml.Unmarshaler); ok {
return um.UnmarshalYAML(n)
}
switch n.Kind {
case yaml.ScalarNode:
return o.Value.Set(n.Value)
case yaml.SequenceNode:
// We treat empty values as nil for consistency with other option
// mechanisms.
if len(n.Content) == 0 {
o.Value = nil
return nil
}
return n.Decode(o.Value)
case yaml.MappingNode:
return xerrors.Errorf("mapping nodes must implement yaml.Unmarshaler")
default:
return xerrors.Errorf("unexpected node kind %v", n.Kind)
}
}
// UnmarshalYAML converts the given YAML node into the option set.
// It is isomorphic with ToYAML.
func (s *OptionSet) UnmarshalYAML(rootNode *yaml.Node) error {
// The rootNode will be a DocumentNode if it's read from a file. We do
// not support multiple documents in a single file.
if rootNode.Kind == yaml.DocumentNode {
if len(rootNode.Content) != 1 {
return xerrors.Errorf("expected one node in document, got %d", len(rootNode.Content))
}
rootNode = rootNode.Content[0]
}
yamlNodes, err := mapYAMLNodes(rootNode)
if err != nil {
return xerrors.Errorf("mapping nodes: %w", err)
}
matchedNodes := make(map[string]*yaml.Node, len(yamlNodes))
var merr error
for i := range *s {
opt := &(*s)[i]
if opt.YAML == "" {
continue
}
var group []string
for _, g := range opt.Group.Ancestry() {
if g.YAML == "" {
return xerrors.Errorf(
"group yaml name is empty for %q, groups: %+v",
opt.Name,
opt.Group,
)
}
group = append(group, g.YAML)
delete(yamlNodes, strings.Join(group, "."))
}
key := strings.Join(append(group, opt.YAML), ".")
node, ok := yamlNodes[key]
if !ok {
continue
}
matchedNodes[key] = node
if opt.ValueSource != ValueSourceNone {
continue
}
if err := opt.setFromYAMLNode(node); err != nil {
merr = errors.Join(merr, xerrors.Errorf("setting %q: %w", opt.YAML, err))
}
}
// Remove all matched nodes and their descendants from yamlNodes so we
// can accurately report unknown options.
for k := range yamlNodes {
var key string
for _, part := range strings.Split(k, ".") {
if key != "" {
key += "."
}
key += part
if _, ok := matchedNodes[key]; ok {
delete(yamlNodes, k)
}
}
}
for k := range yamlNodes {
merr = errors.Join(merr, xerrors.Errorf("unknown option %q", k))
}
return merr
}
+202
View File
@@ -0,0 +1,202 @@
package clibase_test
import (
"testing"
"github.com/spf13/pflag"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"gopkg.in/yaml.v3"
"github.com/coder/coder/cli/clibase"
)
func TestOptionSet_YAML(t *testing.T) {
t.Parallel()
t.Run("RequireKey", func(t *testing.T) {
t.Parallel()
var workspaceName clibase.String
os := clibase.OptionSet{
clibase.Option{
Name: "Workspace Name",
Value: &workspaceName,
Default: "billie",
},
}
node, err := os.MarshalYAML()
require.NoError(t, err)
require.Len(t, node.(*yaml.Node).Content, 0)
})
t.Run("SimpleString", func(t *testing.T) {
t.Parallel()
var workspaceName clibase.String
os := clibase.OptionSet{
clibase.Option{
Name: "Workspace Name",
Value: &workspaceName,
Default: "billie",
Description: "The workspace's name.",
Group: &clibase.Group{YAML: "names"},
YAML: "workspaceName",
},
}
err := os.SetDefaults()
require.NoError(t, err)
n, err := os.MarshalYAML()
require.NoError(t, err)
// Visually inspect for now.
byt, err := yaml.Marshal(n)
require.NoError(t, err)
t.Logf("Raw YAML:\n%s", string(byt))
})
}
func TestOptionSet_YAMLUnknownOptions(t *testing.T) {
t.Parallel()
os := clibase.OptionSet{
{
Name: "Workspace Name",
Default: "billie",
Description: "The workspace's name.",
YAML: "workspaceName",
Value: new(clibase.String),
},
}
const yamlDoc = `something: else`
err := yaml.Unmarshal([]byte(yamlDoc), &os)
require.Error(t, err)
require.Empty(t, os[0].Value.String())
os[0].YAML = "something"
err = yaml.Unmarshal([]byte(yamlDoc), &os)
require.NoError(t, err)
require.Equal(t, "else", os[0].Value.String())
}
// TestOptionSet_YAMLIsomorphism tests that the YAML representations of an
// OptionSet converts to the same OptionSet when read back in.
func TestOptionSet_YAMLIsomorphism(t *testing.T) {
t.Parallel()
// This is used to form a generic.
//nolint:unused
type kid struct {
Name string `yaml:"name"`
Age int `yaml:"age"`
}
for _, tc := range []struct {
name string
os clibase.OptionSet
zeroValue func() pflag.Value
}{
{
name: "SimpleString",
os: clibase.OptionSet{
{
Name: "Workspace Name",
Default: "billie",
Description: "The workspace's name.",
Group: &clibase.Group{YAML: "names"},
YAML: "workspaceName",
},
},
zeroValue: func() pflag.Value {
return clibase.StringOf(new(string))
},
},
{
name: "Array",
os: clibase.OptionSet{
{
YAML: "names",
Default: "jill,jack,joan",
},
},
zeroValue: func() pflag.Value {
return clibase.StringArrayOf(&[]string{})
},
},
{
name: "ComplexObject",
os: clibase.OptionSet{
{
YAML: "kids",
Default: `- name: jill
age: 12
- name: jack
age: 13`,
},
},
zeroValue: func() pflag.Value {
return &clibase.Struct[[]kid]{}
},
},
{
name: "DeepGroup",
os: clibase.OptionSet{
{
YAML: "names",
Default: "jill,jack,joan",
Group: &clibase.Group{YAML: "kids", Parent: &clibase.Group{YAML: "family"}},
},
},
zeroValue: func() pflag.Value {
return clibase.StringArrayOf(&[]string{})
},
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
// Set initial values.
for i := range tc.os {
tc.os[i].Value = tc.zeroValue()
}
err := tc.os.SetDefaults()
require.NoError(t, err)
y, err := tc.os.MarshalYAML()
require.NoError(t, err)
toByt, err := yaml.Marshal(y)
require.NoError(t, err)
t.Logf("Raw YAML:\n%s", string(toByt))
var y2 yaml.Node
err = yaml.Unmarshal(toByt, &y2)
require.NoError(t, err)
os2 := slices.Clone(tc.os)
for i := range os2 {
os2[i].Value = tc.zeroValue()
os2[i].ValueSource = clibase.ValueSourceNone
}
// os2 values should be zeroed whereas tc.os should be
// set to defaults.
// This check makes sure we aren't mixing pointers.
require.NotEqual(t, tc.os, os2)
err = os2.UnmarshalYAML(&y2)
require.NoError(t, err)
want := tc.os
for i := range want {
want[i].ValueSource = clibase.ValueSourceYAML
}
require.Equal(t, tc.os, os2)
})
}
}
-88
View File
@@ -1,88 +0,0 @@
// Package cliflag extends flagset with environment variable defaults.
//
// Usage:
//
// cliflag.String(root.Flags(), &address, "address", "a", "CODER_ADDRESS", "127.0.0.1:3000", "The address to serve the API and dashboard")
//
// Will produce the following usage docs:
//
// -a, --address string The address to serve the API and dashboard (uses $CODER_ADDRESS). (default "127.0.0.1:3000")
//
package cliflag
import (
"fmt"
"os"
"strconv"
"strings"
"github.com/spf13/pflag"
)
// String sets a string flag on the given flag set.
func String(flagset *pflag.FlagSet, name, shorthand, env, def, usage string) {
v, ok := os.LookupEnv(env)
if !ok || v == "" {
v = def
}
flagset.StringP(name, shorthand, v, fmtUsage(usage, env))
}
// StringVarP sets a string flag on the given flag set.
func StringVarP(flagset *pflag.FlagSet, p *string, name string, shorthand string, env string, def string, usage string) {
v, ok := os.LookupEnv(env)
if !ok || v == "" {
v = def
}
flagset.StringVarP(p, name, shorthand, v, fmtUsage(usage, env))
}
func StringArrayVarP(flagset *pflag.FlagSet, ptr *[]string, name string, shorthand string, env string, def []string, usage string) {
val, ok := os.LookupEnv(env)
if ok {
def = strings.Split(val, ",")
}
flagset.StringArrayVarP(ptr, name, shorthand, def, usage)
}
// Uint8VarP sets a uint8 flag on the given flag set.
func Uint8VarP(flagset *pflag.FlagSet, ptr *uint8, name string, shorthand string, env string, def uint8, usage string) {
val, ok := os.LookupEnv(env)
if !ok || val == "" {
flagset.Uint8VarP(ptr, name, shorthand, def, fmtUsage(usage, env))
return
}
vi64, err := strconv.ParseUint(val, 10, 8)
if err != nil {
flagset.Uint8VarP(ptr, name, shorthand, def, fmtUsage(usage, env))
return
}
flagset.Uint8VarP(ptr, name, shorthand, uint8(vi64), fmtUsage(usage, env))
}
// BoolVarP sets a bool flag on the given flag set.
func BoolVarP(flagset *pflag.FlagSet, ptr *bool, name string, shorthand string, env string, def bool, usage string) {
val, ok := os.LookupEnv(env)
if !ok || val == "" {
flagset.BoolVarP(ptr, name, shorthand, def, fmtUsage(usage, env))
return
}
valb, err := strconv.ParseBool(val)
if err != nil {
flagset.BoolVarP(ptr, name, shorthand, def, fmtUsage(usage, env))
return
}
flagset.BoolVarP(ptr, name, shorthand, valb, fmtUsage(usage, env))
}
func fmtUsage(u string, env string) string {
if env == "" {
return fmt.Sprintf("%s.", u)
}
return fmt.Sprintf("%s - consumes $%s.", u, env)
}
-187
View File
@@ -1,187 +0,0 @@
package cliflag_test
import (
"fmt"
"strconv"
"testing"
"github.com/spf13/pflag"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/cliflag"
"github.com/coder/coder/cryptorand"
)
// Testcliflag cannot run in parallel because it uses t.Setenv.
//nolint:paralleltest
func TestCliflag(t *testing.T) {
t.Run("StringDefault", func(t *testing.T) {
flagset, name, shorthand, env, usage := randomFlag()
def, _ := cryptorand.String(10)
cliflag.String(flagset, name, shorthand, env, def, usage)
got, err := flagset.GetString(name)
require.NoError(t, err)
require.Equal(t, def, got)
require.Contains(t, flagset.FlagUsages(), usage)
require.Contains(t, flagset.FlagUsages(), fmt.Sprintf(" - consumes $%s", env))
})
t.Run("StringEnvVar", func(t *testing.T) {
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.String(10)
t.Setenv(env, envValue)
def, _ := cryptorand.String(10)
cliflag.String(flagset, name, shorthand, env, def, usage)
got, err := flagset.GetString(name)
require.NoError(t, err)
require.Equal(t, envValue, got)
})
t.Run("StringVarPDefault", func(t *testing.T) {
var ptr string
flagset, name, shorthand, env, usage := randomFlag()
def, _ := cryptorand.String(10)
cliflag.StringVarP(flagset, &ptr, name, shorthand, env, def, usage)
got, err := flagset.GetString(name)
require.NoError(t, err)
require.Equal(t, def, got)
require.Contains(t, flagset.FlagUsages(), usage)
require.Contains(t, flagset.FlagUsages(), fmt.Sprintf(" - consumes $%s", env))
})
t.Run("StringVarPEnvVar", func(t *testing.T) {
var ptr string
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.String(10)
t.Setenv(env, envValue)
def, _ := cryptorand.String(10)
cliflag.StringVarP(flagset, &ptr, name, shorthand, env, def, usage)
got, err := flagset.GetString(name)
require.NoError(t, err)
require.Equal(t, envValue, got)
})
t.Run("EmptyEnvVar", func(t *testing.T) {
var ptr string
flagset, name, shorthand, _, usage := randomFlag()
def, _ := cryptorand.String(10)
cliflag.StringVarP(flagset, &ptr, name, shorthand, "", def, usage)
got, err := flagset.GetString(name)
require.NoError(t, err)
require.Equal(t, def, got)
require.Contains(t, flagset.FlagUsages(), usage)
require.NotContains(t, flagset.FlagUsages(), " - consumes")
})
t.Run("StringArrayDefault", func(t *testing.T) {
var ptr []string
flagset, name, shorthand, env, usage := randomFlag()
def := []string{"hello"}
cliflag.StringArrayVarP(flagset, &ptr, name, shorthand, env, def, usage)
got, err := flagset.GetStringArray(name)
require.NoError(t, err)
require.Equal(t, def, got)
})
t.Run("StringArrayEnvVar", func(t *testing.T) {
var ptr []string
flagset, name, shorthand, env, usage := randomFlag()
t.Setenv(env, "wow,test")
cliflag.StringArrayVarP(flagset, &ptr, name, shorthand, env, nil, usage)
got, err := flagset.GetStringArray(name)
require.NoError(t, err)
require.Equal(t, []string{"wow", "test"}, got)
})
t.Run("IntDefault", func(t *testing.T) {
var ptr uint8
flagset, name, shorthand, env, usage := randomFlag()
def, _ := cryptorand.Int63n(10)
cliflag.Uint8VarP(flagset, &ptr, name, shorthand, env, uint8(def), usage)
got, err := flagset.GetUint8(name)
require.NoError(t, err)
require.Equal(t, uint8(def), got)
require.Contains(t, flagset.FlagUsages(), usage)
require.Contains(t, flagset.FlagUsages(), fmt.Sprintf(" - consumes $%s", env))
})
t.Run("IntEnvVar", func(t *testing.T) {
var ptr uint8
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.Int63n(10)
t.Setenv(env, strconv.FormatUint(uint64(envValue), 10))
def, _ := cryptorand.Int()
cliflag.Uint8VarP(flagset, &ptr, name, shorthand, env, uint8(def), usage)
got, err := flagset.GetUint8(name)
require.NoError(t, err)
require.Equal(t, uint8(envValue), got)
})
t.Run("IntFailParse", func(t *testing.T) {
var ptr uint8
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.String(10)
t.Setenv(env, envValue)
def, _ := cryptorand.Int63n(10)
cliflag.Uint8VarP(flagset, &ptr, name, shorthand, env, uint8(def), usage)
got, err := flagset.GetUint8(name)
require.NoError(t, err)
require.Equal(t, uint8(def), got)
})
t.Run("BoolDefault", func(t *testing.T) {
var ptr bool
flagset, name, shorthand, env, usage := randomFlag()
def, _ := cryptorand.Bool()
cliflag.BoolVarP(flagset, &ptr, name, shorthand, env, def, usage)
got, err := flagset.GetBool(name)
require.NoError(t, err)
require.Equal(t, def, got)
require.Contains(t, flagset.FlagUsages(), usage)
require.Contains(t, flagset.FlagUsages(), fmt.Sprintf(" - consumes $%s", env))
})
t.Run("BoolEnvVar", func(t *testing.T) {
var ptr bool
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.Bool()
t.Setenv(env, strconv.FormatBool(envValue))
def, _ := cryptorand.Bool()
cliflag.BoolVarP(flagset, &ptr, name, shorthand, env, def, usage)
got, err := flagset.GetBool(name)
require.NoError(t, err)
require.Equal(t, envValue, got)
})
t.Run("BoolFailParse", func(t *testing.T) {
var ptr bool
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.String(10)
t.Setenv(env, envValue)
def, _ := cryptorand.Bool()
cliflag.BoolVarP(flagset, &ptr, name, shorthand, env, def, usage)
got, err := flagset.GetBool(name)
require.NoError(t, err)
require.Equal(t, def, got)
})
}
func randomFlag() (*pflag.FlagSet, string, string, string, string) {
fsname, _ := cryptorand.String(10)
flagset := pflag.NewFlagSet(fsname, pflag.PanicOnError)
name, _ := cryptorand.String(10)
shorthand, _ := cryptorand.String(1)
env, _ := cryptorand.String(10)
usage, _ := cryptorand.String(10)
return flagset, name, shorthand, env, usage
}
+314
View File
@@ -0,0 +1,314 @@
package clistat
import (
"bufio"
"bytes"
"strconv"
"strings"
"github.com/spf13/afero"
"golang.org/x/xerrors"
"tailscale.com/types/ptr"
)
// Paths for CGroupV1.
// Ref: https://www.kernel.org/doc/Documentation/cgroup-v1/cpuacct.txt
const (
// CPU usage of all tasks in cgroup in nanoseconds.
cgroupV1CPUAcctUsage = "/sys/fs/cgroup/cpu/cpuacct.usage"
// Alternate path
cgroupV1CPUAcctUsageAlt = "/sys/fs/cgroup/cpu,cpuacct/cpuacct.usage"
// CFS quota and period for cgroup in MICROseconds
cgroupV1CFSQuotaUs = "/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us"
cgroupV1CFSPeriodUs = "/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_period_us"
// Maximum memory usable by cgroup in bytes
cgroupV1MemoryMaxUsageBytes = "/sys/fs/cgroup/memory/memory.max_usage_in_bytes"
// Current memory usage of cgroup in bytes
cgroupV1MemoryUsageBytes = "/sys/fs/cgroup/memory/memory.usage_in_bytes"
// Other memory stats - we are interested in total_inactive_file
cgroupV1MemoryStat = "/sys/fs/cgroup/memory/memory.stat"
)
// Paths for CGroupV2.
// Ref: https://docs.kernel.org/admin-guide/cgroup-v2.html
const (
// Contains quota and period in microseconds separated by a space.
cgroupV2CPUMax = "/sys/fs/cgroup/cpu.max"
// Contains current CPU usage under usage_usec
cgroupV2CPUStat = "/sys/fs/cgroup/cpu.stat"
// Contains current cgroup memory usage in bytes.
cgroupV2MemoryUsageBytes = "/sys/fs/cgroup/memory.current"
// Contains max cgroup memory usage in bytes.
cgroupV2MemoryMaxBytes = "/sys/fs/cgroup/memory.max"
// Other memory stats - we are interested in total_inactive_file
cgroupV2MemoryStat = "/sys/fs/cgroup/memory.stat"
)
// ContainerCPU returns the CPU usage of the container cgroup.
// This is calculated as difference of two samples of the
// CPU usage of the container cgroup.
// The total is read from the relevant path in /sys/fs/cgroup.
// If there is no limit set, the total is assumed to be the
// number of host cores multiplied by the CFS period.
// If the system is not containerized, this always returns nil.
func (s *Statter) ContainerCPU() (*Result, error) {
// Firstly, check if we are containerized.
if ok, err := IsContainerized(s.fs); err != nil || !ok {
return nil, nil //nolint: nilnil
}
total, err := s.cGroupCPUTotal()
if err != nil {
return nil, xerrors.Errorf("get total cpu: %w", err)
}
used1, err := s.cGroupCPUUsed()
if err != nil {
return nil, xerrors.Errorf("get cgroup CPU usage: %w", err)
}
// The measurements in /sys/fs/cgroup are counters.
// We need to wait for a bit to get a difference.
// Note that someone could reset the counter in the meantime.
// We can't do anything about that.
s.wait(s.sampleInterval)
used2, err := s.cGroupCPUUsed()
if err != nil {
return nil, xerrors.Errorf("get cgroup CPU usage: %w", err)
}
if used2 < used1 {
// Someone reset the counter. Best we can do is count from zero.
used1 = 0
}
r := &Result{
Unit: "cores",
Used: used2 - used1,
Total: ptr.To(total),
Prefix: PrefixDefault,
}
return r, nil
}
func (s *Statter) cGroupCPUTotal() (used float64, err error) {
if s.isCGroupV2() {
return s.cGroupV2CPUTotal()
}
// Fall back to CGroupv1
return s.cGroupV1CPUTotal()
}
func (s *Statter) cGroupCPUUsed() (used float64, err error) {
if s.isCGroupV2() {
return s.cGroupV2CPUUsed()
}
return s.cGroupV1CPUUsed()
}
func (s *Statter) isCGroupV2() bool {
// Check for the presence of /sys/fs/cgroup/cpu.max
_, err := s.fs.Stat(cgroupV2CPUMax)
return err == nil
}
func (s *Statter) cGroupV2CPUUsed() (used float64, err error) {
usageUs, err := readInt64Prefix(s.fs, cgroupV2CPUStat, "usage_usec")
if err != nil {
return 0, xerrors.Errorf("get cgroupv2 cpu used: %w", err)
}
periodUs, err := readInt64SepIdx(s.fs, cgroupV2CPUMax, " ", 1)
if err != nil {
return 0, xerrors.Errorf("get cpu period: %w", err)
}
return float64(usageUs) / float64(periodUs), nil
}
func (s *Statter) cGroupV2CPUTotal() (total float64, err error) {
var quotaUs, periodUs int64
periodUs, err = readInt64SepIdx(s.fs, cgroupV2CPUMax, " ", 1)
if err != nil {
return 0, xerrors.Errorf("get cpu period: %w", err)
}
quotaUs, err = readInt64SepIdx(s.fs, cgroupV2CPUMax, " ", 0)
if err != nil {
// Fall back to number of cores
quotaUs = int64(s.nproc) * periodUs
}
return float64(quotaUs) / float64(periodUs), nil
}
func (s *Statter) cGroupV1CPUTotal() (float64, error) {
periodUs, err := readInt64(s.fs, cgroupV1CFSPeriodUs)
if err != nil {
return 0, xerrors.Errorf("read cpu period: %w", err)
}
quotaUs, err := readInt64(s.fs, cgroupV1CFSQuotaUs)
if err != nil {
return 0, xerrors.Errorf("read cpu quota: %w", err)
}
if quotaUs < 0 {
// Fall back to the number of cores
quotaUs = int64(s.nproc) * periodUs
}
return float64(quotaUs) / float64(periodUs), nil
}
func (s *Statter) cGroupV1CPUUsed() (float64, error) {
usageNs, err := readInt64(s.fs, cgroupV1CPUAcctUsage)
if err != nil {
// try alternate path
usageNs, err = readInt64(s.fs, cgroupV1CPUAcctUsageAlt)
if err != nil {
return 0, xerrors.Errorf("read cpu used: %w", err)
}
}
// usage is in ns, convert to us
usageNs /= 1000
periodUs, err := readInt64(s.fs, cgroupV1CFSPeriodUs)
if err != nil {
return 0, xerrors.Errorf("get cpu period: %w", err)
}
return float64(usageNs) / float64(periodUs), nil
}
// ContainerMemory returns the memory usage of the container cgroup.
// If the system is not containerized, this always returns nil.
func (s *Statter) ContainerMemory(p Prefix) (*Result, error) {
if ok, err := IsContainerized(s.fs); err != nil || !ok {
return nil, nil //nolint:nilnil
}
if s.isCGroupV2() {
return s.cGroupV2Memory(p)
}
// Fall back to CGroupv1
return s.cGroupV1Memory(p)
}
func (s *Statter) cGroupV2Memory(p Prefix) (*Result, error) {
maxUsageBytes, err := readInt64(s.fs, cgroupV2MemoryMaxBytes)
if err != nil {
return nil, xerrors.Errorf("read memory total: %w", err)
}
currUsageBytes, err := readInt64(s.fs, cgroupV2MemoryUsageBytes)
if err != nil {
return nil, xerrors.Errorf("read memory usage: %w", err)
}
inactiveFileBytes, err := readInt64Prefix(s.fs, cgroupV2MemoryStat, "inactive_file")
if err != nil {
return nil, xerrors.Errorf("read memory stats: %w", err)
}
return &Result{
Total: ptr.To(float64(maxUsageBytes)),
Used: float64(currUsageBytes - inactiveFileBytes),
Unit: "B",
Prefix: p,
}, nil
}
func (s *Statter) cGroupV1Memory(p Prefix) (*Result, error) {
maxUsageBytes, err := readInt64(s.fs, cgroupV1MemoryMaxUsageBytes)
if err != nil {
return nil, xerrors.Errorf("read memory total: %w", err)
}
// need a space after total_rss so we don't hit something else
usageBytes, err := readInt64(s.fs, cgroupV1MemoryUsageBytes)
if err != nil {
return nil, xerrors.Errorf("read memory usage: %w", err)
}
totalInactiveFileBytes, err := readInt64Prefix(s.fs, cgroupV1MemoryStat, "total_inactive_file")
if err != nil {
return nil, xerrors.Errorf("read memory stats: %w", err)
}
// Total memory used is usage - total_inactive_file
return &Result{
Total: ptr.To(float64(maxUsageBytes)),
Used: float64(usageBytes - totalInactiveFileBytes),
Unit: "B",
Prefix: p,
}, nil
}
// read an int64 value from path
func readInt64(fs afero.Fs, path string) (int64, error) {
data, err := afero.ReadFile(fs, path)
if err != nil {
return 0, xerrors.Errorf("read %s: %w", path, err)
}
val, err := strconv.ParseInt(string(bytes.TrimSpace(data)), 10, 64)
if err != nil {
return 0, xerrors.Errorf("parse %s: %w", path, err)
}
return val, nil
}
// read an int64 value from path at field idx separated by sep
func readInt64SepIdx(fs afero.Fs, path, sep string, idx int) (int64, error) {
data, err := afero.ReadFile(fs, path)
if err != nil {
return 0, xerrors.Errorf("read %s: %w", path, err)
}
parts := strings.Split(string(data), sep)
if len(parts) < idx {
return 0, xerrors.Errorf("expected line %q to have at least %d parts", string(data), idx+1)
}
val, err := strconv.ParseInt(strings.TrimSpace(parts[idx]), 10, 64)
if err != nil {
return 0, xerrors.Errorf("parse %s: %w", path, err)
}
return val, nil
}
// read the first int64 value from path prefixed with prefix
func readInt64Prefix(fs afero.Fs, path, prefix string) (int64, error) {
data, err := afero.ReadFile(fs, path)
if err != nil {
return 0, xerrors.Errorf("read %s: %w", path, err)
}
scn := bufio.NewScanner(bytes.NewReader(data))
for scn.Scan() {
line := scn.Text()
if !strings.HasPrefix(line, prefix) {
continue
}
parts := strings.Fields(line)
if len(parts) != 2 {
return 0, xerrors.Errorf("parse %s: expected two fields but got %s", path, line)
}
val, err := strconv.ParseInt(strings.TrimSpace(parts[1]), 10, 64)
if err != nil {
return 0, xerrors.Errorf("parse %s: %w", path, err)
}
return val, nil
}
return 0, xerrors.Errorf("parse %s: did not find line with prefix %s", path, prefix)
}
+61
View File
@@ -0,0 +1,61 @@
package clistat
import (
"bufio"
"bytes"
"os"
"github.com/spf13/afero"
"golang.org/x/xerrors"
)
const (
procMounts = "/proc/mounts"
procOneCgroup = "/proc/1/cgroup"
)
// IsContainerized returns whether the host is containerized.
// This is adapted from https://github.com/elastic/go-sysinfo/tree/main/providers/linux/container.go#L31
// with modifications to support Sysbox containers.
// On non-Linux platforms, it always returns false.
func IsContainerized(fs afero.Fs) (ok bool, err error) {
cgData, err := afero.ReadFile(fs, procOneCgroup)
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, xerrors.Errorf("read file %s: %w", procOneCgroup, err)
}
scn := bufio.NewScanner(bytes.NewReader(cgData))
for scn.Scan() {
line := scn.Bytes()
if bytes.Contains(line, []byte("docker")) ||
bytes.Contains(line, []byte(".slice")) ||
bytes.Contains(line, []byte("lxc")) ||
bytes.Contains(line, []byte("kubepods")) {
return true, nil
}
}
// Last-ditch effort to detect Sysbox containers.
// Check if we have anything mounted as type sysboxfs in /proc/mounts
mountsData, err := afero.ReadFile(fs, procMounts)
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, xerrors.Errorf("read file %s: %w", procMounts, err)
}
scn = bufio.NewScanner(bytes.NewReader(mountsData))
for scn.Scan() {
line := scn.Bytes()
if bytes.Contains(line, []byte("sysboxfs")) {
return true, nil
}
}
// If we get here, we are _probably_ not running in a container.
return false, nil
}
+27
View File
@@ -0,0 +1,27 @@
//go:build !windows
package clistat
import (
"syscall"
"tailscale.com/types/ptr"
)
// Disk returns the disk usage of the given path.
// If path is empty, it returns the usage of the root directory.
func (*Statter) Disk(p Prefix, path string) (*Result, error) {
if path == "" {
path = "/"
}
var stat syscall.Statfs_t
if err := syscall.Statfs(path, &stat); err != nil {
return nil, err
}
var r Result
r.Total = ptr.To(float64(stat.Blocks * uint64(stat.Bsize)))
r.Used = float64(stat.Blocks-stat.Bfree) * float64(stat.Bsize)
r.Unit = "B"
r.Prefix = p
return &r, nil
}
+36
View File
@@ -0,0 +1,36 @@
package clistat
import (
"golang.org/x/sys/windows"
"tailscale.com/types/ptr"
)
// Disk returns the disk usage of the given path.
// If path is empty, it defaults to C:\
func (*Statter) Disk(p Prefix, path string) (*Result, error) {
if path == "" {
path = `C:\`
}
pathPtr, err := windows.UTF16PtrFromString(path)
if err != nil {
return nil, err
}
var freeBytes, totalBytes, availBytes uint64
if err := windows.GetDiskFreeSpaceEx(
pathPtr,
&freeBytes,
&totalBytes,
&availBytes,
); err != nil {
return nil, err
}
var r Result
r.Total = ptr.To(float64(totalBytes))
r.Used = float64(totalBytes - freeBytes)
r.Unit = "B"
r.Prefix = p
return &r, nil
}
+236
View File
@@ -0,0 +1,236 @@
package clistat
import (
"math"
"runtime"
"strconv"
"strings"
"time"
"github.com/elastic/go-sysinfo"
"github.com/spf13/afero"
"golang.org/x/xerrors"
"tailscale.com/types/ptr"
sysinfotypes "github.com/elastic/go-sysinfo/types"
)
// Prefix is a scale multiplier for a result.
// Used when creating a human-readable representation.
type Prefix float64
const (
PrefixDefault = 1.0
PrefixKibi = 1024.0
PrefixMebi = PrefixKibi * 1024.0
PrefixGibi = PrefixMebi * 1024.0
PrefixTebi = PrefixGibi * 1024.0
)
var (
PrefixHumanKibi = "Ki"
PrefixHumanMebi = "Mi"
PrefixHumanGibi = "Gi"
PrefixHumanTebi = "Ti"
)
func (s *Prefix) String() string {
switch *s {
case PrefixKibi:
return "Ki"
case PrefixMebi:
return "Mi"
case PrefixGibi:
return "Gi"
case PrefixTebi:
return "Ti"
default:
return ""
}
}
func ParsePrefix(s string) Prefix {
switch s {
case PrefixHumanKibi:
return PrefixKibi
case PrefixHumanMebi:
return PrefixMebi
case PrefixHumanGibi:
return PrefixGibi
case PrefixHumanTebi:
return PrefixTebi
default:
return PrefixDefault
}
}
// Result is a generic result type for a statistic.
// Total is the total amount of the resource available.
// It is nil if the resource is not a finite quantity.
// Unit is the unit of the resource.
// Used is the amount of the resource used.
type Result struct {
Total *float64 `json:"total"`
Unit string `json:"unit"`
Used float64 `json:"used"`
Prefix Prefix `json:"-"`
}
// String returns a human-readable representation of the result.
func (r *Result) String() string {
if r == nil {
return "-"
}
scale := 1.0
if r.Prefix != 0.0 {
scale = float64(r.Prefix)
}
var sb strings.Builder
var usedScaled, totalScaled float64
usedScaled = r.Used / scale
_, _ = sb.WriteString(humanizeFloat(usedScaled))
if r.Total != (*float64)(nil) {
_, _ = sb.WriteString("/")
totalScaled = *r.Total / scale
_, _ = sb.WriteString(humanizeFloat(totalScaled))
}
_, _ = sb.WriteString(" ")
_, _ = sb.WriteString(r.Prefix.String())
_, _ = sb.WriteString(r.Unit)
if r.Total != (*float64)(nil) && *r.Total > 0 {
_, _ = sb.WriteString(" (")
pct := r.Used / *r.Total * 100.0
_, _ = sb.WriteString(strconv.FormatFloat(pct, 'f', 0, 64))
_, _ = sb.WriteString("%)")
}
return strings.TrimSpace(sb.String())
}
func humanizeFloat(f float64) string {
// humanize.FtoaWithDigits does not round correctly.
prec := precision(f)
rat := math.Pow(10, float64(prec))
rounded := math.Round(f*rat) / rat
return strconv.FormatFloat(rounded, 'f', -1, 64)
}
// limit precision to 3 digits at most to preserve space
func precision(f float64) int {
fabs := math.Abs(f)
if fabs == 0.0 {
return 0
}
if fabs < 1.0 {
return 3
}
if fabs < 10.0 {
return 2
}
if fabs < 100.0 {
return 1
}
return 0
}
// Statter is a system statistics collector.
// It is a thin wrapper around the elastic/go-sysinfo library.
type Statter struct {
hi sysinfotypes.Host
fs afero.Fs
sampleInterval time.Duration
nproc int
wait func(time.Duration)
}
type Option func(*Statter)
// WithSampleInterval sets the sample interval for the statter.
func WithSampleInterval(d time.Duration) Option {
return func(s *Statter) {
s.sampleInterval = d
}
}
// WithFS sets the fs for the statter.
func WithFS(fs afero.Fs) Option {
return func(s *Statter) {
s.fs = fs
}
}
func New(opts ...Option) (*Statter, error) {
hi, err := sysinfo.Host()
if err != nil {
return nil, xerrors.Errorf("get host info: %w", err)
}
s := &Statter{
hi: hi,
fs: afero.NewReadOnlyFs(afero.NewOsFs()),
sampleInterval: 100 * time.Millisecond,
nproc: runtime.NumCPU(),
wait: func(d time.Duration) {
<-time.After(d)
},
}
for _, opt := range opts {
opt(s)
}
return s, nil
}
// HostCPU returns the CPU usage of the host. This is calculated by
// taking two samples of CPU usage and calculating the difference.
// Total will always be equal to the number of cores.
// Used will be an estimate of the number of cores used during the sample interval.
// This is calculated by taking the difference between the total and idle HostCPU time
// and scaling it by the number of cores.
// Units are in "cores".
func (s *Statter) HostCPU() (*Result, error) {
r := &Result{
Unit: "cores",
Total: ptr.To(float64(s.nproc)),
Prefix: PrefixDefault,
}
c1, err := s.hi.CPUTime()
if err != nil {
return nil, xerrors.Errorf("get first cpu sample: %w", err)
}
s.wait(s.sampleInterval)
c2, err := s.hi.CPUTime()
if err != nil {
return nil, xerrors.Errorf("get second cpu sample: %w", err)
}
total := c2.Total() - c1.Total()
if total == 0 {
return r, nil // no change
}
idle := c2.Idle - c1.Idle
used := total - idle
scaleFactor := float64(s.nproc) / total.Seconds()
r.Used = used.Seconds() * scaleFactor
return r, nil
}
// HostMemory returns the memory usage of the host, in gigabytes.
func (s *Statter) HostMemory(p Prefix) (*Result, error) {
r := &Result{
Unit: "B",
Prefix: p,
}
hm, err := s.hi.Memory()
if err != nil {
return nil, xerrors.Errorf("get memory info: %w", err)
}
r.Total = ptr.To(float64(hm.Total))
// On Linux, hm.Used equates to MemTotal - MemFree in /proc/stat.
// This includes buffers and cache.
// So use MemAvailable instead, which only equates to physical memory.
// On Windows, this is also calculated as Total - Available.
r.Used = float64(hm.Total - hm.Available)
return r, nil
}
+345
View File
@@ -0,0 +1,345 @@
package clistat
import (
"testing"
"time"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"tailscale.com/types/ptr"
)
func TestResultString(t *testing.T) {
t.Parallel()
for _, tt := range []struct {
Expected string
Result Result
}{
{
Expected: "1.23/5.68 quatloos (22%)",
Result: Result{Used: 1.234, Total: ptr.To(5.678), Unit: "quatloos"},
},
{
Expected: "0/0 HP",
Result: Result{Used: 0.0, Total: ptr.To(0.0), Unit: "HP"},
},
{
Expected: "123 seconds",
Result: Result{Used: 123.01, Total: nil, Unit: "seconds"},
},
{
Expected: "12.3",
Result: Result{Used: 12.34, Total: nil, Unit: ""},
},
{
Expected: "1.5 KiB",
Result: Result{Used: 1536, Total: nil, Unit: "B", Prefix: PrefixKibi},
},
{
Expected: "1.23 things",
Result: Result{Used: 1.234, Total: nil, Unit: "things"},
},
{
Expected: "0/100 TiB (0%)",
Result: Result{Used: 1, Total: ptr.To(100.0 * float64(PrefixTebi)), Unit: "B", Prefix: PrefixTebi},
},
{
Expected: "0.5/8 cores (6%)",
Result: Result{Used: 0.5, Total: ptr.To(8.0), Unit: "cores"},
},
} {
assert.Equal(t, tt.Expected, tt.Result.String())
}
}
func TestStatter(t *testing.T) {
t.Parallel()
// We cannot make many assertions about the data we get back
// for host-specific measurements because these tests could
// and should run successfully on any OS.
// The best we can do is assert that it is non-zero.
t.Run("HostOnly", func(t *testing.T) {
t.Parallel()
fs := initFS(t, fsHostOnly)
s, err := New(WithFS(fs))
require.NoError(t, err)
t.Run("HostCPU", func(t *testing.T) {
t.Parallel()
cpu, err := s.HostCPU()
require.NoError(t, err)
// assert.NotZero(t, cpu.Used) // HostCPU can sometimes be zero.
assert.NotZero(t, cpu.Total)
assert.Equal(t, "cores", cpu.Unit)
})
t.Run("HostMemory", func(t *testing.T) {
t.Parallel()
mem, err := s.HostMemory(PrefixDefault)
require.NoError(t, err)
assert.NotZero(t, mem.Used)
assert.NotZero(t, mem.Total)
assert.Equal(t, "B", mem.Unit)
})
t.Run("HostDisk", func(t *testing.T) {
t.Parallel()
disk, err := s.Disk(PrefixDefault, "") // default to home dir
require.NoError(t, err)
assert.NotZero(t, disk.Used)
assert.NotZero(t, disk.Total)
assert.Equal(t, "B", disk.Unit)
})
})
// Sometimes we do need to "fake" some stuff
// that happens while we wait.
withWait := func(waitF func(time.Duration)) Option {
return func(s *Statter) {
s.wait = waitF
}
}
// Other times we just want things to run fast.
withNoWait := func(s *Statter) {
s.wait = func(time.Duration) {}
}
// We don't want to use the actual host CPU here.
withNproc := func(n int) Option {
return func(s *Statter) {
s.nproc = n
}
}
// For container-specific measurements, everything we need
// can be read from the filesystem. We control the FS, so
// we control the data.
t.Run("CGroupV1", func(t *testing.T) {
t.Parallel()
t.Run("ContainerCPU/Limit", func(t *testing.T) {
t.Parallel()
fs := initFS(t, fsContainerCgroupV1)
fakeWait := func(time.Duration) {
// Fake 1 second in ns of usage
mungeFS(t, fs, cgroupV1CPUAcctUsage, "100000000")
}
s, err := New(WithFS(fs), withWait(fakeWait))
require.NoError(t, err)
cpu, err := s.ContainerCPU()
require.NoError(t, err)
require.NotNil(t, cpu)
assert.Equal(t, 1.0, cpu.Used)
require.NotNil(t, cpu.Total)
assert.Equal(t, 2.5, *cpu.Total)
assert.Equal(t, "cores", cpu.Unit)
})
t.Run("ContainerCPU/NoLimit", func(t *testing.T) {
t.Parallel()
fs := initFS(t, fsContainerCgroupV1NoLimit)
fakeWait := func(time.Duration) {
// Fake 1 second in ns of usage
mungeFS(t, fs, cgroupV1CPUAcctUsage, "100000000")
}
s, err := New(WithFS(fs), withNproc(2), withWait(fakeWait))
require.NoError(t, err)
cpu, err := s.ContainerCPU()
require.NoError(t, err)
require.NotNil(t, cpu)
assert.Equal(t, 1.0, cpu.Used)
require.NotNil(t, cpu.Total)
assert.Equal(t, 2.0, *cpu.Total)
assert.Equal(t, "cores", cpu.Unit)
})
t.Run("ContainerMemory", func(t *testing.T) {
t.Parallel()
fs := initFS(t, fsContainerCgroupV1)
s, err := New(WithFS(fs), withNoWait)
require.NoError(t, err)
mem, err := s.ContainerMemory(PrefixDefault)
require.NoError(t, err)
require.NotNil(t, mem)
assert.Equal(t, 268435456.0, mem.Used)
assert.NotNil(t, mem.Total)
assert.Equal(t, 1073741824.0, *mem.Total)
assert.Equal(t, "B", mem.Unit)
})
})
t.Run("CGroupV2", func(t *testing.T) {
t.Parallel()
t.Run("ContainerCPU/Limit", func(t *testing.T) {
t.Parallel()
fs := initFS(t, fsContainerCgroupV2)
fakeWait := func(time.Duration) {
mungeFS(t, fs, cgroupV2CPUStat, "usage_usec 100000")
}
s, err := New(WithFS(fs), withWait(fakeWait))
require.NoError(t, err)
cpu, err := s.ContainerCPU()
require.NoError(t, err)
require.NotNil(t, cpu)
assert.Equal(t, 1.0, cpu.Used)
require.NotNil(t, cpu.Total)
assert.Equal(t, 2.5, *cpu.Total)
assert.Equal(t, "cores", cpu.Unit)
})
t.Run("ContainerCPU/NoLimit", func(t *testing.T) {
t.Parallel()
fs := initFS(t, fsContainerCgroupV2NoLimit)
fakeWait := func(time.Duration) {
mungeFS(t, fs, cgroupV2CPUStat, "usage_usec 100000")
}
s, err := New(WithFS(fs), withNproc(2), withWait(fakeWait))
require.NoError(t, err)
cpu, err := s.ContainerCPU()
require.NoError(t, err)
require.NotNil(t, cpu)
assert.Equal(t, 1.0, cpu.Used)
require.NotNil(t, cpu.Total)
assert.Equal(t, 2.0, *cpu.Total)
assert.Equal(t, "cores", cpu.Unit)
})
t.Run("ContainerMemory", func(t *testing.T) {
t.Parallel()
fs := initFS(t, fsContainerCgroupV2)
s, err := New(WithFS(fs), withNoWait)
require.NoError(t, err)
mem, err := s.ContainerMemory(PrefixDefault)
require.NoError(t, err)
require.NotNil(t, mem)
assert.Equal(t, 268435456.0, mem.Used)
assert.NotNil(t, mem.Total)
assert.Equal(t, 1073741824.0, *mem.Total)
assert.Equal(t, "B", mem.Unit)
})
})
}
func TestIsContainerized(t *testing.T) {
t.Parallel()
for _, tt := range []struct {
Name string
FS map[string]string
Expected bool
Error string
}{
{
Name: "Empty",
FS: map[string]string{},
Expected: false,
Error: "",
},
{
Name: "BareMetal",
FS: fsHostOnly,
Expected: false,
Error: "",
},
{
Name: "Docker",
FS: fsContainerCgroupV1,
Expected: true,
Error: "",
},
{
Name: "Sysbox",
FS: fsContainerSysbox,
Expected: true,
Error: "",
},
} {
tt := tt
t.Run(tt.Name, func(t *testing.T) {
t.Parallel()
fs := initFS(t, tt.FS)
actual, err := IsContainerized(fs)
if tt.Error == "" {
assert.NoError(t, err)
assert.Equal(t, tt.Expected, actual)
} else {
assert.ErrorContains(t, err, tt.Error)
assert.False(t, actual)
}
})
}
}
// helper function for initializing a fs
func initFS(t testing.TB, m map[string]string) afero.Fs {
t.Helper()
fs := afero.NewMemMapFs()
for k, v := range m {
mungeFS(t, fs, k, v)
}
return fs
}
// helper function for writing v to fs under path k
func mungeFS(t testing.TB, fs afero.Fs, k, v string) {
t.Helper()
require.NoError(t, afero.WriteFile(fs, k, []byte(v+"\n"), 0o600))
}
var (
fsHostOnly = map[string]string{
procOneCgroup: "0::/",
procMounts: "/dev/sda1 / ext4 rw,relatime 0 0",
}
fsContainerSysbox = map[string]string{
procOneCgroup: "0::/docker/aa86ac98959eeedeae0ecb6e0c9ddd8ae8b97a9d0fdccccf7ea7a474f4e0bb1f",
procMounts: `overlay / overlay rw,relatime,lowerdir=/some/path:/some/path,upperdir=/some/path:/some/path,workdir=/some/path:/some/path 0 0
sysboxfs /proc/sys proc ro,nosuid,nodev,noexec,relatime 0 0`,
cgroupV2CPUMax: "250000 100000",
cgroupV2CPUStat: "usage_usec 0",
}
fsContainerCgroupV2 = map[string]string{
procOneCgroup: "0::/docker/aa86ac98959eeedeae0ecb6e0c9ddd8ae8b97a9d0fdccccf7ea7a474f4e0bb1f",
procMounts: `overlay / overlay rw,relatime,lowerdir=/some/path:/some/path,upperdir=/some/path:/some/path,workdir=/some/path:/some/path 0 0
proc /proc/sys proc ro,nosuid,nodev,noexec,relatime 0 0`,
cgroupV2CPUMax: "250000 100000",
cgroupV2CPUStat: "usage_usec 0",
cgroupV2MemoryMaxBytes: "1073741824",
cgroupV2MemoryUsageBytes: "536870912",
cgroupV2MemoryStat: "inactive_file 268435456",
}
fsContainerCgroupV2NoLimit = map[string]string{
procOneCgroup: "0::/docker/aa86ac98959eeedeae0ecb6e0c9ddd8ae8b97a9d0fdccccf7ea7a474f4e0bb1f",
procMounts: `overlay / overlay rw,relatime,lowerdir=/some/path:/some/path,upperdir=/some/path:/some/path,workdir=/some/path:/some/path 0 0
proc /proc/sys proc ro,nosuid,nodev,noexec,relatime 0 0`,
cgroupV2CPUMax: "max 100000",
cgroupV2CPUStat: "usage_usec 0",
cgroupV2MemoryMaxBytes: "1073741824",
cgroupV2MemoryUsageBytes: "536870912",
cgroupV2MemoryStat: "inactive_file 268435456",
}
fsContainerCgroupV1 = map[string]string{
procOneCgroup: "0::/docker/aa86ac98959eeedeae0ecb6e0c9ddd8ae8b97a9d0fdccccf7ea7a474f4e0bb1f",
procMounts: `overlay / overlay rw,relatime,lowerdir=/some/path:/some/path,upperdir=/some/path:/some/path,workdir=/some/path:/some/path 0 0
proc /proc/sys proc ro,nosuid,nodev,noexec,relatime 0 0`,
cgroupV1CPUAcctUsage: "0",
cgroupV1CFSQuotaUs: "250000",
cgroupV1CFSPeriodUs: "100000",
cgroupV1MemoryMaxUsageBytes: "1073741824",
cgroupV1MemoryUsageBytes: "536870912",
cgroupV1MemoryStat: "total_inactive_file 268435456",
}
fsContainerCgroupV1NoLimit = map[string]string{
procOneCgroup: "0::/docker/aa86ac98959eeedeae0ecb6e0c9ddd8ae8b97a9d0fdccccf7ea7a474f4e0bb1f",
procMounts: `overlay / overlay rw,relatime,lowerdir=/some/path:/some/path,upperdir=/some/path:/some/path,workdir=/some/path:/some/path 0 0
proc /proc/sys proc ro,nosuid,nodev,noexec,relatime 0 0`,
cgroupV1CPUAcctUsage: "0",
cgroupV1CFSQuotaUs: "-1",
cgroupV1CFSPeriodUs: "100000",
cgroupV1MemoryMaxUsageBytes: "1073741824",
cgroupV1MemoryUsageBytes: "536870912",
cgroupV1MemoryStat: "total_inactive_file 268435456",
}
)

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