Compare commits

...

2316 Commits

Author SHA1 Message Date
Jon Ayers 1372bf82f5 chore: revert "chore: remove workspace_actions experiment (#10030)" (#10363) 2023-10-20 13:21:53 -05:00
Asher 57c9d88703 chore(site): remove terminal xservice (#10234)
* Remove terminalXService

This is a prelude to the change I actually want to make, which is to
send the size of the terminal on the web socket URL after we do a fit.
I have found xstate so confusing that it was easier to just rewrite it.

* Fix hanging tests

I am not really sure what ws.connected is doing but it seems to somehow
block updates.  Something to do with `act()` maybe?

Basically, the useEffect creating the terminal never updates once the
config query finishes, so the web socket is never created, and the test
hangs forever.

It might have been working before only because the web socket was
created using xstate rather than useEffect and once it connected it
would unblock and React could update again but this is just a guess.

* Ignore other config changes

The terminal only cares about the renderer specifically, no need to
recreate the terminal if something else changes.

* Break out port forward URL open to util

Felt like this could be broken out to reduce the component size.  Also
trying to figure out why it is causing the terminal to create multiple
times.

* Prevent handleWebLink change from recreating terminal

Depending on the timing, handleWebLink was causing the terminal to get
recreated.  We only need to create the terminal once unless the render
type changes.

Recreating the terminal was also recreating the web socket pointlessly.
2023-10-20 10:18:17 -08:00
Muhammad Atif Ali 5ebb702e00 chore: add OIDC provider logos (#10365)
* chore: add OIDC provider logos

* Add files via upload

* fmt
2023-10-20 19:30:05 +03:00
Eric Paulsen 9dbc913798 fix: additional cluster SA, role names (#10366) 2023-10-20 11:44:16 -04:00
Kira Pilot ed5567ba28 fix: show dormant and suspended users in groups (#10333)
* fix: show dormant and suspended users in groups

* added status column
2023-10-20 11:36:00 -04:00
Bruno Quaresma ac322724b0 chore(site): replace custom LoadingButton from the one in MUI (#10351) 2023-10-20 09:57:27 -03:00
Bruno Quaresma 3d9bfdd5dc chore(site): remove update check service (#10355) 2023-10-20 09:41:34 -03:00
Bruno Quaresma 1ba5169109 chore(site): remove search users and groups xservice (#10353) 2023-10-20 09:33:07 -03:00
Jon Ayers d33526108f feat: add frontend support for mandating active template version (#10338) 2023-10-19 18:21:52 -05:00
Jon Ayers f5f150d568 feat: add cli support for --require-active-version (#10337) 2023-10-19 17:16:15 -05:00
Ammar Bandukwala b799014832 docs: rework telemetry doc and add CLI warning (#10354) 2023-10-19 15:50:20 -05:00
Kira Pilot 9c9319f81e fix: resolve User is not unauthenticated error seen on logout (#10349)
* fix: do not cache getAuthenticatedUser call

* use initialQuery, add back meta tag for initial load of users

* lift initialUserData
2023-10-19 14:50:53 -04:00
Michael Smith ab2904a676 feat: add user groups column to users table (#10284)
* refactor: extract UserRoleCell into separate component

* wip: add placeholder Groups column

* fix: remove redundant css styles

* refactor: update EditRolesButton to use Sets to detect selections

* wip: commit progress for updated roles column

* wip: commit current role pill progress

* fix: update state sync logic

* chore: add groupsByUserId query options factory

* fix: update return value of select function

* chore: drill groups data down to cell component

* wip: commit current cell progress

* fix: remove redundant classes

* wip: commit current styling progress

* fix: update line height for CTA

* fix: update spacing

* chore: add tooltip for Groups column header

* fix: remove tsbuild file

* refactor: consolidate tooltip components

* fix: update font size defaults inside theme

* fix: expand hoverable/clickable area of groups cell

* fix: remove possible undefined cases from HelpTooltip

* chore: add popover functionality to groups

* wip: commit progress on groups tooltip

* fix: remove zero-height group name visual bug

* feat: get basic version of user group tooltips done

* perf: move sort order callback outside loop

* fix: update spacing for tooltip

* feat: make popovers entirely hover-based

* fix: disable scroll locking for popover

* docs: add comments explaining some pitfalls with Popover component

* refactor: simplify userRoleCell implementation

* feat: complete main feature

* fix: prevent scroll lock for role tooltips

* fix: change import to type import

* refactor: simplify how groups are clustered

* refactor: update UserRoleCell to use Popover

* refactor: remove unnecessary fragment

* chore: add id/aria support for Popover

* refactor: update UserGroupsCell to use Popover

* chore: redo visual design for UserGroupsCell

* fix: shrink UserGroupsCell text

* fix: update UsersTable test to include groups info
2023-10-19 14:31:48 -04:00
Bruno Quaresma 557adab224 chore(site): remove template ACL XService (#10332) 2023-10-19 14:59:08 -03:00
dependabot[bot] 21f87313bd chore: bump github.com/aws/smithy-go from 1.14.2 to 1.15.0 (#10282)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-19 16:08:56 +03:00
Muhammad Atif Ali 42c21d400f fix(docs): update external-auth docs to use coder_external_auth (#10347) 2023-10-19 12:30:48 +00:00
Bruno Quaresma f677c4470b chore(site): add custom popover component (#10319) 2023-10-19 09:13:21 -03:00
Bruno Quaresma b8c7b56fda fix(site): fix tabs in the template layout (#10334) 2023-10-19 09:12:41 -03:00
Marcin Tojek c4f590581e feat: expose template insights as Prometheus metrics (#10325) 2023-10-19 08:45:12 +00:00
Jon Ayers 997493d4ae feat: add template setting to require active template version (#10277) 2023-10-18 17:07:21 -05:00
Colin Adler 1ad998ee3a fix: add requester IP to workspace build audit logs (#10242) 2023-10-18 15:08:02 -05:00
Colin Adler 504cedf15a feat: add telemetry for external provisioners (#10322) 2023-10-18 14:20:30 -05:00
Mathias Fredriksson 9b73020f11 ci(.github): set DataDog upload timeout (#10328) 2023-10-18 20:07:52 +03:00
Bruno Quaresma c93fe8ddbe chore(site): remove template version machine (#10315) 2023-10-18 09:18:03 -03:00
Muhammad Atif Ali fe05fd1e6e docs: update vscode web docs (#10327) 2023-10-18 12:13:44 +00:00
Kayla Washburn 2b5e02f5b2 refactor: improve e2e test reporting (#10304) 2023-10-17 16:11:42 -06:00
Muhammad Atif Ali ab456276dc docs: add v2.3.1 changelog (#10313)
* add v2.3.1 changelog

* fmt

* explain

* simplify

* update

* simplify

* cleanup

* refresh

* update

* cleanup and fmt

* Update v2.3.1.md

cleanup

* add new commits

---------

Co-authored-by: Ben <me@bpmct.net>
2023-10-17 21:45:38 +00:00
Eric Paulsen 09d995c8dc fix: set K8s deployment strategy to Recreate (#10321) 2023-10-17 21:06:35 +00:00
Kayla Washburn 619df23ad1 chore: fix linting issues and generated files (#10317) 2023-10-17 14:41:35 -06:00
Muhammad Atif Ali 492da15890 chore: delete filebrowser.db (#10320) 2023-10-17 18:59:35 +00:00
Kira Pilot 1656249e07 feat: add all safe experiments to the deployment page (#10276)
* added new option table type for experiments

* added tests

* fixed go tests

* added go test for new param

* removing query change

* clearing ExperimentsAll

* dont mutate ExperimentsAll

* added new route for safe experiments

* added new route for safe experiments

* added test for new route

* PR feedback

* altered design

* alias children
2023-10-17 14:49:19 -04:00
Bruno Quaresma 35f9e2ef7f refactor(site): refactor create workspace button (#10303) 2023-10-17 13:31:51 -03:00
Michael Smith 0f2d4fdb6d fix: prevent metadata queries from short-circuiting (#10312)
* fix: prevent metadata queries from short-circuiting

* fix: use correct type definitions
2023-10-17 10:20:56 -06:00
Mathias Fredriksson 8f39ec5cc3 fix(scaletest/templates): fix bugs and improve debugging (#10316) 2023-10-17 15:18:49 +00:00
Kayla Washburn 2f4ca0f566 chore: use emotion for styling (pt. 6) (#10298) 2023-10-17 09:14:13 -06:00
Muhammad Atif Ali a49e6b88f9 docs: reorganize template docs (#10297)
* docs: rework our "templates" section

* wikistuff

* fix formatting

* add diagram

* reorganize some things

* docs: improve workspaces and templates doc (#9139)

* Reorg, updated/new screenshots, consistent terminology

* First pass

* Another pass

* Added integration section

* New outline for template pages, small updates

* Revised outline for templates, added tutorial

* First pass at tutorial

* Some feedback from Ben.

* Update docs/workspaces.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Update docs/workspaces.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Update docs/workspaces.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Fixed typos

* Expanded tutorial

I have read the CLA Document and I hereby sign the CLA

* New screenshots, improved tutorial, revised anatomy

* Improved tutorial. Anatomy is now a guided tour.

* First pass at guided tour

* Updated authentication info

* Reorganized the guided tour

* Edited more template pages

* Update docs/templates/tour.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Update docs/templates/tour.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Update docs/templates/tour.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Update docs/templates/tutorial.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Update docs/templates/tour.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Update docs/templates/tour.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Update docs/templates/tour.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Update docs/templates/tour.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Update docs/templates/tour.md

Co-authored-by: Muhammad Atif Ali <matifali@live.com>

* Revised devcontainers and docker-in-workspaces

* Edited and added screenshots

* Prepared first draft, except docs/templates/open-in-coder.md

* Fix typo

* remove legacy parameters and migration guide

* Use coder templates create

* Added screenshot for workspace template variables

* Made it prettier

* Fixed minor typos and markdown problems

* edits to repairing workspaces

* fix broken links in product

* Added troubleshooting, minor corrections.

* fix terminal links

* fmt

---------

Co-authored-by: Muhammad Atif Ali <matifali@live.com>
Co-authored-by: Ben Potter <me@bpmct.net>
Co-authored-by: Atif Ali <atif@coder.com>

* make fmt

* fix merge conflict

* make fmt

* make gen

* update

* lint

* Discard changes to coderd/database/queries.sql.go

* Discard changes to cli/templates.go

* Discard changes to cli/templateversionarchive.go

* Discard changes to cli/templateversions.go

* Update docker-in-workspaces.md

* replace ```sh with ```shell

* open-in-coder

* fmt

* mention coder_metadata in icons.md

* resource_metadata

* use shell

* modules.md

* mention coder registry module

* workspace.md

* resource_metadata

* remove duplication

* address comments

* cleanup

* fmt

* fix broken links

* fix numbering

* mention module registry

* add example

* demote heading

* remove top level entry from manifest

* fmt

---------

Co-authored-by: Ben <me@bpmct.net>
Co-authored-by: Marc Paquette <22124737+marcpaq@users.noreply.github.com>
2023-10-17 14:47:12 +00:00
dependabot[bot] b5e5b39de2 chore: bump @babel/traverse from 7.22.8 to 7.23.2 in /offlinedocs (#10294)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-16 23:39:04 +03:00
dependabot[bot] 2acf195b13 chore: bump @babel/traverse from 7.22.11 to 7.23.2 in /site (#10295)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-16 23:38:51 +03:00
Kayla Washburn eaea918a59 chore: use emotion for styling (pt. 5) (#10261) 2023-10-16 12:41:15 -06:00
Bruno Quaresma 4240200b5d fix(site): fix state used to check if creating was loading (#10296) 2023-10-16 15:53:50 +00:00
Mathias Fredriksson 43f26dfec5 feat(scaletest/templates): run all scenarios even on failure (#10290)
We now also end all failed phases and add the `error` tag in Grafana.
2023-10-16 18:18:05 +03:00
Ben Potter 9a0aac88e0 chore: fix broken links in docs (#10291)
https://github.com/coder/coder/actions/runs/6531396781/job/17732557812
2023-10-16 14:29:53 +00:00
Steven Masley 6ebe9b0402 feat: add UI for autostart workspace days (#10263)
* feat: add ui for selecting auto start days
2023-10-16 09:29:42 -05:00
Steven Masley 5a90228c60 feat: fix 404 on the first app loads when unauthenticated (#10262)
* feat: fix 404 on the first app loads when unauthenticated
* Update site/src/pages/LoginPage/LoginPage.tsx
2023-10-16 09:29:25 -05:00
Mathias Fredriksson 8ffe0e22b6 feat(scaletest/templates): gather pod logs at the end of a scale test (#10288) 2023-10-16 13:50:04 +00:00
Bruno Quaresma 8efa1239e7 fix(site): do not return next page if the current size is lower than the limit (#10287) 2023-10-16 13:39:48 +00:00
Mathias Fredriksson 3c49290dd7 feat(scaletest/templates): add comment parameter (#10285) 2023-10-16 13:28:23 +00:00
Cian Johnston 6875faf238 fix(coderd/provisionerdserver): pass through api ctx to provisionerdserver (#10259)
Passes through coderd API ctx to provisionerd server so we can cancel workspace updates when API is shutting down.
2023-10-16 13:50:07 +01:00
Bruno Quaresma 01792f064e fix(site): display empty component when workspace has no parameters (#10286) 2023-10-16 09:49:53 -03:00
Bruno Quaresma f64b9cab90 feat(site): decrease the number of statuses in the workspaces filter (#10283) 2023-10-16 12:46:06 +00:00
Mathias Fredriksson 493e2bd2ac feat(scaletest/templates): add repo branch parameter (#10279) 2023-10-16 12:25:32 +00:00
Cian Johnston dd86100f33 fix(scaletest): fix flake in Test_Runner/Cleanup (#10252)
* fix(scaletest/createworkspaces): address flake in Test_Runner/CleanupPendingBuild

* fix(scaletest): pass io.Writer to Cleanup()

* add some extra logs to workspacebuild cleanup

* fixup! fix(scaletest): pass io.Writer to Cleanup()

* remove race

* fmt

* address PR comments
2023-10-16 12:37:12 +01:00
Cian Johnston 1be24dcb5c feat(helm/provisioner): add extraTemplates (#10256)
Adds support for extraTemplates to the coder-provisioner chart to bring it in line with the coder chart.
2023-10-16 12:17:05 +01:00
Stephen Kirby 2029543eba chore(site): clarify autostop description (#10260)
* updated autostop description based on customer request

* edited for specificity

* make fmt
2023-10-13 12:24:37 -05:00
Steven Masley 39c0539d42 feat: add controls to template for determining startup days (#10226)
* feat: template controls which days can autostart
* Add unit test to test blocking autostart with DaysOfWeek
2023-10-13 11:57:18 -05:00
Ammar Bandukwala 98b6c8bcb0 chore(coderd): report full license in telemetry (#10258)
Will aid in cross-referencing deployments to sales accounts.
2023-10-13 11:43:06 -05:00
Kayla Washburn cbc0c39792 fix: display health alert in DeploymentBannerView (#10193) 2023-10-13 10:39:20 -06:00
Muhammad Atif Ali def980b973 chore(docs): fix syntax highlighting (#10247)
Due to some reason, our docs are not rendering syntax highlighting when the code block type is 'terraform'. Changing the type to `hcl` fixes this.
2023-10-13 18:50:24 +03:00
Mathias Fredriksson 76c65b1e1b fix(agent): send metadata in batches (#10225)
Fixes #9782

---

I recommend reviewing with ignore whitespace.
2023-10-13 17:48:25 +03:00
Mathias Fredriksson 4857d4bd55 feat(codersdk/agentsdk): use new agent metadata batch endpoint (#10224)
Part of #9782
2023-10-13 17:32:28 +03:00
Mathias Fredriksson 7eeba15d16 feat(coderd): add support for sending batched agent metadata (#10223)
Part of #9782
2023-10-13 16:37:55 +03:00
dependabot[bot] 1b1ab97c24 chore: bump github.com/google/go-cmp from 0.5.9 to 0.6.0 (#10248)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-13 13:27:22 +00:00
dependabot[bot] 13036dd088 chore: bump google.golang.org/api from 0.145.0 to 0.147.0 (#10249)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-13 16:17:35 +03:00
dependabot[bot] ab7dd24d97 ci: bump the github-actions group with 2 updates (#10250)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-13 16:17:21 +03:00
Cian Johnston d56f49f619 fix(coderd): make activitybump aware of default template ttl (#10253)
The refactored ActivityBump query did not take into account the
template-level TTL, resulting in potentially incorrect bump
amounts for workspaces that have both a user-defined and template-
defined TTL that differ.

This change is ported over from PR#10035 to reduce the overall
size of that PR.

Also includes a drive-by unit test in autobuild for checking template autostop/TTL.

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-10-13 13:53:02 +01:00
Marcin Tojek 2a4ac2a53c feat: expose user seat limits as Prometheus metrics (#10169) 2023-10-13 08:10:16 +00:00
Eric Paulsen 570f963aea clarify external auth regex (#10243)
* docs: clarify external auth regex

* cleanup
2023-10-13 04:27:12 +00:00
Kayla Washburn 5fc9ff29d1 docs: mention /icons in the template documentation (#10230)
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-10-12 15:32:23 -06:00
Steven Masley 88605b9d01 chore: add display name to member role (#10239)
* chore: add display name to member role
* Do not let member role be assignable
* Ignore org member role for assignability atm
2023-10-12 10:52:32 -05:00
Cian Johnston e5198a25a6 feat(scaletest): annotate scaletest pod when scaletest is in progress (#10235)
This PR modifies the scaletest-runner template to add a pod annotation to the scaletest runner pod.

The annotation key is set to com.coder.scaletest.phase and the annotation value is one of preparing, running, or complete.

This will allow checking if a scaletest is in progress, and preventing any operations that would interrupt a running scaletest.

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-10-12 14:36:15 +01:00
Mathias Fredriksson 782c22a293 test(coderd/database/dbtestutil): allow access to *sql.DB (#10238) 2023-10-12 15:07:16 +03:00
Mathias Fredriksson 7df40b85f2 chore(coderd/coderdtest): use testing.TB for use in benchmarks (#10237) 2023-10-12 15:03:16 +03:00
Cian Johnston 1e75762cb4 fix(cli): scaletest: create-worksapces: remove invalid character for kubernetes provider in implicit plan (#10228) 2023-10-12 09:21:40 +01:00
Muhammad Atif Ali 3adf86b608 chore(dogfood): use coder_extrenal_auth over deprecated coder_git_auth (#10208)
@kylecarbs does this need any changes on the Coder server?
For example adopting to the new `CODER_EXTERNAL_AUTH_X` variables?
2023-10-12 10:30:00 +03:00
dependabot[bot] 5f0457f160 chore: bump golang.org/x/net from 0.16.0 to 0.17.0 (#10232)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.16.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.16.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  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-10-11 21:43:59 -05:00
Michael Smith 9bf3b35bbf fix: update create workspace button to recognize template names+display names (#10233)
* fix: only used 'unnamed' as a last resort for templates

* fix: update filter logic to read from name field
2023-10-12 00:23:45 +00:00
Kayla Washburn 6ef1beec13 chore: recrop some icons for more consistent sizing (#10229) 2023-10-11 15:59:47 -06:00
Asher a9077812e2 fix: use UTF-8 encoding with screen (#10190)
This will make characters like ❯ and ⇣ work, for example.
2023-10-11 13:25:04 -08:00
Asher a67a5a8105 Prevent terminal being created twice (#10200)
I missed this in code review.
2023-10-11 12:47:32 -08:00
Bruno Quaresma 301c045aad chore(site): remove create workspace xservice (#10217)
* Move xstate transitions to provider

* Centrlize auth logic in the provider

* Remove actor

* Remove auth xservice

* Add loader while AuthProvider is loading

* Simplify and fix a few computed states

* Add a few replaces

* Fix logout

* Remove unused import

* Fix RequireAuth test

* Fix wait loader

* Fix tests

* Remove unecessary type

* Rename workspace queries module

* Remove auto create from workspace xservice

* Move external auth into its own hook

* Remove permissions fetching from templateByName query

* Remove form load from service

* Remove create workspace service entirely

* refactor: update workspace automation to use useEffectEvent

---------

Co-authored-by: Parkreiner <michaelsmith@coder.com>
Co-authored-by: Michael Smith <throwawayclover@gmail.com>
2023-10-11 20:42:25 +00:00
Bruno Quaresma 5be4b12378 chore(site): refactor AuthProvider to not use authXService (#10184)
* Move xstate transitions to provider

* Centrlize auth logic in the provider

* Remove actor

* Remove auth xservice

* Add loader while AuthProvider is loading

* Simplify and fix a few computed states

* Add a few replaces

* Fix logout

* Remove unused import

* Fix RequireAuth test

* Fix wait loader

* Fix tests

* Wrap signout with callback
2023-10-11 16:13:32 -04:00
Kira Pilot 7c6687813d fix(site): ensure empty string error shows default message (#10196)
* fix(site): ensure empty string error shows default message

* added test

* added logging

* asserting axios message

* cleanup and add test
2023-10-11 13:54:58 -04:00
Cian Johnston 59ae69b7f2 chore(enterprise/cli): fix test flake in TestServerDBCrypt (#10222)
* increase randomness in names generated by server dbcrypt

* more randomness

* close PTYs when we are done with them
2023-10-11 17:38:20 +01:00
Ben Potter 04e67836a5 docs: add v2.3.0 changelog (#10221)
* docs: add v2.3.0 changelog

* mention archive version
2023-10-11 11:05:53 -05:00
Cian Johnston 98a076fb46 chore(pty/ptytest): add sync.Once to close (#10220) 2023-10-11 16:47:02 +01:00
Steven Masley ac623b4717 feat: implement basic archive ui to make archiving failed versions easy (#10182)
* feat: implement basic archive ui to make archiving failed versions easy.
2023-10-11 15:06:10 +00:00
Steven Masley 1e950fa9a8 feat: archive template versions to hide them from the ui (#10179)
* api + cli implementation
2023-10-11 09:26:22 -05:00
Bruno Quaresma edbd51955c chore(site): fix inconsistent fetching results on tests (#10215) 2023-10-11 11:17:56 -03:00
Colin Adler 43fa4349d6 chore: move single_tailnet experiment to * (#10188) 2023-10-11 08:50:45 -05:00
Mathias Fredriksson a2cd6640f3 fix(codersdk/agentsdk): improve ctx cancel in agent logs flush, fix test (#10214)
Fixes #9719
Related #9865
2023-10-11 12:42:30 +00:00
Marcin Tojek a1ee4d44aa fix: test: TestSSH_RemoteForward wait for startup script (#10211) 2023-10-11 14:17:04 +02:00
Cian Johnston e829cbf2db fix(scaletest/dashboard): fix early exit due to validate (#10212) 2023-10-11 11:51:06 +00:00
Cian Johnston ed8092c83d fix(scaletest/createworkspaces): address race condition between agent closer and cleanup (#10210) 2023-10-11 12:10:51 +01:00
Cian Johnston b3471bd23a fix(scaletest/dashboard): increase viewport size and handle deadlines (#10197)
- Set viewport size to avoid responsive mode
- Added way more debug logging
- Added facility to write a screenshot on error in verbose mode.
- Added a deadline for each iteraction of clicking on and waiting for a thing.
2023-10-11 11:10:08 +01:00
Cian Johnston dc117051e6 chore(docs): update admin/scale.md (#10168) 2023-10-11 09:40:43 +01:00
Muhammad Atif Ali fafecbd9b3 fix(dogfood): fix slackme module source (#10207)
This was pinned to the branch ref and is no more needed after the branch has been merged.
2023-10-11 08:29:25 +00:00
Spike Curtis 3c43216e99 fix: remove Parallel() call after timeout context (#10203)
Fixes test flake seen here: https://github.com/coder/coder/runs/17562370632

It's inherently flaky to create a context with a timeout and then later call `t.Parallel()` since it causes the test to wait until all non-parallel tests have completed before resuming execution.  By the time execution has resumed, the context may 
have expired.  The amount of time before resuming is dependent on machine resources and number of test cases, which are inherently variable.
2023-10-11 11:39:15 +04:00
Jon Ayers 4452a1484d fix: fix log spam related to skipping custom nice scores (#10206) 2023-10-11 02:32:50 -05:00
Spike Curtis 7c71053eab fix: stop leaking User into API handlers unless authorized
Fixes an issue where we extracted the `{user}` parameter from the URL and added it to the API Handler context regardless of whether the caller had permission to read the User.
2023-10-11 09:41:14 +04:00
Spike Curtis fbabb43cbb fix: ignore spurious node updates while waiting for errors (#10175)
fixes #9921
2023-10-11 09:22:20 +04:00
Kyle Carberry b0d2828f9e fix: append external auth env vars (#10201) 2023-10-11 05:17:08 +00:00
Jon Ayers ec9b480ac0 fix: use is-dormant instead of dormant_at (#10191) 2023-10-10 19:00:09 -05:00
Kyle Carberry 652e1a7d43 feat: add slackme module to dogfood (#10198) 2023-10-10 22:46:47 +00:00
Dean Sheather e7d9b8d858 feat: allow prefixes at the beginning of subdomain app hostnames (#10150) 2023-10-10 20:02:39 +00:00
Dean Sheather f48bc33e00 chore: remove cron schedule from quiet hours schedule page (#10187) 2023-10-10 19:55:28 +00:00
Jon Ayers 91555c3a85 feat: support configurable web terminal rendering (#10095)
* feat: support configurable web terminal rendering

- Added a deployment option for configuring web terminal rendering.
  Valid values are 'webgl', 'canvas', and 'dom'.
2023-10-10 13:18:02 -05:00
Jon Ayers 05a393cd06 feat: only display license warnings to privileged users (#10096) 2023-10-10 12:48:51 -05:00
Colin Adler 7e6b549170 chore: upgrade Terraform to 1.5.7 (#10186) 2023-10-10 12:46:59 -05:00
Colin Adler 21e0d540dc chore: upgrade Go to 1.20.10
https://groups.google.com/g/golang-announce/c/iNNxDTCjZvo/m/UDd7VKQuAAAJ?utm_medium=email&utm_source=footer
2023-10-10 12:23:54 -05:00
Kayla Washburn 7ea58eac18 chore: use emotion for styling (pt. 4) (#10149) 2023-10-10 10:46:45 -06:00
Colin Adler 00589d6422 chore: fix lint failures 2023-10-10 11:26:53 -05:00
Steven Masley 69d13f1676 chore: add archive column to template versions (#10178)
* chore: add archive column to template versions
2023-10-10 10:52:42 -05:00
Colin Adler c11f241622 feat: add --version flag to coder templates pull, default to active version (#10153)
Fixes https://github.com/coder/coder/issues/9837
2023-10-10 10:20:31 -05:00
Cian Johnston 2506415def chore(scaletest/templates/scaletest-runner): fix dashboard command invocation, autoscale provisioners (#10177)
add --retries on kubectl cp
remove --count parameter to scaletest dashboard
scale provisioners up and down

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-10-10 15:33:55 +01:00
Spike Curtis db8592fa93 chore: refactor workspace conversion to accept ownerName (#10171)
Refactors workspace conversion to accept the ownerName, rather than a slice of users, since all it does is search the slice for the owner and use the username.

This is in preparation for a fix to `postWorkspacesByOrganization()` that will remove the need to pass the user object.

Also avoids panicing if the required user is not in the slice, since `findUser` could return nil in the old code, which would then get dereferenced for the username.
2023-10-10 16:55:28 +04:00
Bruno Quaresma 19400d6794 fix(site): fix week range for insights (#10173) 2023-10-10 09:33:46 -03:00
Spike Curtis b780bff429 chore: drop unused redirectToLoginOnMe parameter (#10164)
The parameter seems to be vestigial from an earlier use of the middleware, but is always set to `false` in the code.
2023-10-10 16:13:00 +04:00
Michael Smith 5ae6cda89f feat: add warning message when trying to delete active template (#10142)
* refactor: clean up TemplatePageHeader

* chore: add react query configs for workspace lists

* feat: add delete-intercept functionality

* refactor: improve readability

* refactor: rename entities for readability/accuracy

* refactor: clean up variable names again

* refactor: remove redudant function calls

* fix: update logic check for safe deletions

* fix: update workspaces query logic

* fix: update call site for workspaces key
2023-10-10 08:04:54 -04:00
Spike Curtis 78b9201b31 chore: move AsSystemRestricted to caller (#10163)
Moves escalation to SystemRestricted out of the function that queries the database for the User. This is in prepartion for a refactor such that we don't need SystemRestricted in `ExtractUserParam` middleware.
2023-10-10 15:57:51 +04:00
Spike Curtis 8a47262faf fix: ignore logged errors in TestWorkspaceAgent/Timeout
fixes #10167

Annoyingly, there isn't a good way to stop the publish from being sent on shutdown, and subscribing to them in the test is too fragile because empty messages are sent in a bunch of places, so we can't reliably tell it's regarding timeouts.
2023-10-10 15:45:47 +04:00
Spike Curtis a0485c00ac chore: refactor ExtractUserParam to call function
Refactors `ExtractUserParam` to separate the part that actually obtains the user from the database and the part that sets it on the middleware context.  This is in preparation for further refactor that removes `ExtractUserParam` middleware from 
`organizations/{organization}/members/{user}` paths.
2023-10-10 15:00:53 +04:00
Cian Johnston c83af5e627 chore(cli): add linter to detect potential spurious usage of owner user in cli tests (#10133)
* Detects the following pattern where the CLI is initialized with a client authenticated as the "first user":

    client := coderdtest.New(t, ...)
    [...]
    user := coderdtest.CreateFirstUser(t, client)
    [...]
    clitest.SetupConfig(t, client, root)

* Updates documentation regarding role permissions on workspaces.
2023-10-10 11:14:20 +01:00
dependabot[bot] 017d7e9dad chore: bump github.com/prometheus/client_model to 0.5.0 (#10129)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-10 12:33:32 +03:00
Spike Curtis 211718f95a fix: fix MaliciousTar test case (#10158)
fixes #9895

Problem was that provisionerd tries to acquire the next job, and races with shutdown, triggering the assert in the handler.  Switches this test case to use the more robust handler.
2023-10-10 13:24:43 +04:00
Marcin Tojek f36fba2486 fix: revert: use CRC32 to shorten app subdomain
This reverts commit 0e28397c82.
2023-10-10 18:12:46 +10:00
Spike Curtis b039dc6989 fix: correct escaping in test regex (#10138)
Fixes regex escaping.  Spotted during a code read.
2023-10-10 08:42:39 +04:00
Kyle Carberry 9c098b218f feat: allow external auth providers to expose extra metadata (#10157) 2023-10-09 23:02:16 -05:00
Kyle Carberry 3eb9a43190 fix: use query to get external-auth by id (#10156) 2023-10-09 22:25:50 -05:00
Kyle Carberry a61f8ee45c fix: apply default ExtraTokenKeys to oauth (#10155) 2023-10-09 22:11:05 -05:00
Kyle Carberry 863c2e7b64 feat: allow storing extra oauth token properties in the database (#10152) 2023-10-09 18:49:30 -05:00
Kyle Carberry 35538e1051 feat: add external-auth cli (#10052)
* feat: add `external-auth` cli

* Add subcommands

* Improve descriptions

* Add external-auth subcommand

* Fix docs

* Fix gen

* Fix comment

* Fix golden file
2023-10-09 23:04:35 +00:00
Colin Adler 20438ae6c2 chore: run go mod tidy 2023-10-09 15:10:46 -05:00
Kayla Washburn 42fb6cab12 chore: add icons for popular programming languages (#10141) 2023-10-09 13:52:06 -06:00
dependabot[bot] cb3b617ee9 ci: bump the github-actions group with 2 updates (#10131)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-09 22:39:40 +03:00
dependabot[bot] af63909134 chore: bump google.golang.org/api from 0.143.0 to 0.145.0 (#10130)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-09 22:39:29 +03:00
dependabot[bot] 583d44e60e chore: bump the golang-x group with 6 updates (#10128)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-09 22:39:13 +03:00
Kayla Washburn 1cdc62b332 chore: reorganize storybook (#10144) 2023-10-09 13:26:38 -06:00
Kyle Carberry 54648b90ca fix: properly trim spaces so multi-line shebang executes (#10146) 2023-10-09 19:19:57 +00:00
Colin Adler 3bbfcc593e feat: add request_id to HTTP trace spans (#10145) 2023-10-09 14:05:10 -05:00
Muhammad Atif Ali 2881b8b252 chore: add vault icon (#10125) 2023-10-09 18:25:07 +00:00
Spike Curtis b9c7bc4d3c fix: check for nil pointer in AwaitWorkspaceAgents
CompletedAt is a pointer and can be nil, need to check before calling IsZero() on it

c.f. https://github.com/coder/coder/runs/17534657301
2023-10-09 22:12:28 +04:00
Bruno Quaresma 584a2e87c9 chore(site): remove create template xservice (#10112) 2023-10-09 14:10:48 -03:00
Spike Curtis 54fd350913 feat: improve logging for speedtest connections
part of #7963

improve connection logging for speedtest connections
2023-10-09 20:48:28 +04:00
Colin Adler 9e622d00a6 feat(cli): add coder users delete command (#10115) 2023-10-09 11:47:57 -05:00
Spike Curtis 24c80bf532 fix: remove AwaitWorkspaceAgents in goroutines
AwaitWorkspaceAgent calls testify.require which isn't allowed from a goroutine and causes cascading failures in the test suite such as: https://github.com/coder/coder/actions/runs/6458768855/job/17533163316

I don't believe these functions serve a direct purpose since nothing else is "waiting" for the functions to return before doing other things.
2023-10-09 20:37:23 +04:00
Spike Curtis 17e889af16 feat: improve logging for reconnectingPTY connections
part of #7963

improves connection logging on reconnectingPTY
2023-10-09 20:35:50 +04:00
Kyle Carberry b402f2a816 feat: add shebang support to scripts (#10134)
This enables much greater portability!
2023-10-09 10:57:57 -05:00
Kayla Washburn 17869ecb74 feat: select icons from emoji picker (#10119) 2023-10-09 09:50:24 -06:00
Kayla Washburn bda68b143a feat: add /icons page (#10093) 2023-10-09 09:49:26 -06:00
Spike Curtis 236e84c4d6 feat: add logging for forwarded TCP connections
part of #7963

log TCP connections as they are forwarded by gVisor
2023-10-09 19:41:26 +04:00
Kira Pilot 791144ddfd feat(site): disable rich parameters when using open in coder (#10114)
* feat(site): disable rich parameters when using open in coder

* updated docs

* chore(site): increase refetch interval for deployment health

* Revert "chore(site): increase refetch interval for deployment health"

This reverts commit 8e642be3fb.
2023-10-09 09:47:22 -04:00
Cian Johnston 5673aca408 feat(cli): add --parameter flag to exp scaletest command (#10132) 2023-10-09 14:08:24 +01:00
Marcin Tojek c6cf719f6c feat: show user limit on active users chart (#10101) 2023-10-09 13:38:41 +02:00
Michael Smith 38bb854c8b fix: update ErrorDialog logic and tests (#10111)
* fix: make error text less naggy

* fix: make input colors sync with confirmation text state

* fix: more color sync fixes

* fix: remove flaky warning messages in test

* fix: remove needless braces

* refactor: clean up code

* refactor: clean up code more
2023-10-06 19:40:37 -04:00
Kayla Washburn ae113179b3 chore: alias react-query (#10118) 2023-10-06 17:15:03 -06:00
Kira Pilot da47ac87db chore(site): increase refetch interval for deployment health (#10117) 2023-10-06 16:26:46 -04:00
Colin Adler 19dbf19177 fix(coder): properly check for missing organization membership
Fixes a possible panic introduced in https://github.com/coder/coder/pull/9781.
2023-10-06 14:57:21 -05:00
Kayla Washburn 71ad5909f2 chore: add icons.json file (#10085) 2023-10-06 13:46:37 -06:00
Colin Adler 36f3151b71 fix(enterprise/tailnet): properly detect legacy agents (#10083) 2023-10-06 16:49:26 +00:00
Colin Adler 03a7d2f70b chore: fix servertailnet test flake (#10110)
https://github.com/coder/coder/actions/runs/6424100765/job/17444018788?pr=10083#step:5:771
2023-10-06 11:31:53 -05:00
Kyle Carberry 2d2bea79a7 fix: convert the new dashboard theme to be an experiment (#10108) 2023-10-06 09:46:52 -05:00
Kyle Carberry 69b65693c9 fix: make the dark mode a bit less dark (#10107)
We got feedback from our Discord that it was a bit too dark,
so this brightens it up a little!
2023-10-06 14:09:21 +00:00
Kyle Carberry 23425d36a1 fix: invert the favicon on dark mode (#10097) 2023-10-06 07:55:11 -05:00
Spike Curtis 983e8c3ae8 feat: add API support for workspace automatic updates (#10099)
* Added automatic_updates to workspaces table

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

* Queries and API updates

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

* Golden files

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

* Enable automatic updates on autostart

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

* db migration number

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

* fix imports and ts mock

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

* code review updates

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-10-06 13:27:12 +04:00
Kyle Carberry d24d2d2c8d fix: use proper react hook for favicon theme (#10094)
I was using `useState` before, which didn't re-render on load.
2023-10-05 18:23:56 -05:00
Bruno Quaresma 127f65c98b fix(site): fix logo width on sign in (#10091) 2023-10-05 17:44:53 -05:00
Kyle Carberry 4ad080c3b9 fix: apply the same border for button groups (#10092) 2023-10-05 17:44:45 -05:00
Kyle Carberry 14c8824c83 fix: use proper state in system theme (#10090) 2023-10-05 17:32:52 -05:00
Kyle Carberry fa0a597530 fix: add build status favicons based on system theme (#10089) 2023-10-05 22:23:11 +00:00
Kyle Carberry f270d9d351 feat: make the dashboard darker (#10084)
* feat: make the dashboard darker

Coder is a the internal software development platform. It is not
designed to be opinionated on colors, but it should look great.

Focusing on neutrality for our default dashboard theme is great
for our ICP. Some organizations may lean towards colors more or
less, and that shouldn't influence their decision when exploring
Coder.

* Make it a lil more dark

* Improve button outline

* Lower the red brightness

* Improve the divider contrast
2023-10-05 16:46:38 -05:00
Bruno Quaresma 04e7748a9b feat(site): load previous builds (#10076) 2023-10-05 18:30:11 -03:00
Kyle Carberry 1eb21d247b feat: adjust favicon based on system color-scheme (#10087)
This will still default to light-theme, but support showing
a white favicon when the system-theme is dark.
2023-10-05 16:11:15 -05:00
Bruno Quaresma a5f8300c76 refactor(site): do not block the screen when disconnected (#10057)
Close https://github.com/coder/coder/issues/9858

Demo:
https://github.com/coder/coder/assets/3165839/d6d4d2d7-487a-4739-86c9-042242d9820f
2023-10-05 18:06:26 -03:00
Michael Smith 2d6c4fe90a feat(site): add WorkspacesButton component (#10011)
* chore: Add OverflowY component

* chore: Add PopoverContainer component

* chore: Add SearchBox

* feat: add WorkspacesButton

* chore: Install MUI utils package

* chore: integrate WorkspacesButton

* chore: reorganize files

* fix: resolve hover state visual glitch

* chore: Add story for OverflowY

* fix: remove dynamic name from OverflowY story

* chore: update stories again

* fix: remove all references to icons (for now)

* refactor: move flex shrink to be OverflowY concern

* fix: remove needless render key

* fix: make sure popover closes before navigation

* refactor: clean up WorkspacesButton to use more native MUI

* fix: update integration into rest of view

* fix: remove JS security concern

* refactor: parameterize button language

* revert: undo sql/go file change

* fix: remove permissions dependency

* fix: simplify button prop types

* fix: lift data dependencies to page component

* refactor: clean up props

* fix: update dependencies again for Storybook
2023-10-05 20:46:42 +00:00
Kyle Carberry ad47ef17e8 feat: allow reading the agent token from a file (#10080)
Adds `CODER_AGENT_TOKEN_FILE` which will read the agent token from
a file if `CODER_AGENT_TOKEN` is not provided. Using a Kubernetes
Secret with a volume-mounted file is a more secure way to provide
the agent token instead of an environment variable.
2023-10-05 15:41:05 -05:00
Jon Ayers eb4826a11f chore: remove workspace_actions experiment (#10030) 2023-10-05 14:18:35 -05:00
Kayla Washburn 3c87c4df1b feat: show descriptions for parameter options (#10068) 2023-10-05 13:14:28 -06:00
Jon Ayers b32d79ef0b fix: fix failed workspaces continuously auto-deleting (#10069)
- Fixes an issue where workspaces that are eligible for auto-deletion
  are retried every tick (1 minute) even if the previous deletion
  transition failed.

  The updated logic only attempts to delete workspaces that previously
  failed once a day (24 hours since last attempt).
2023-10-05 14:11:39 -05:00
Jon Ayers 91265678ad chore: add auditing to workspace dormancy (#10070)
- Adds an audit log for workspaces automatically transitioned to the dormant
  state.
- Imposes a mininum of 1 minute on cleanup-related fields. This is to
  prevent accidental API misuse from resulting in catastrophe.
2023-10-05 13:41:07 -05:00
Kyle Carberry 888b97fd86 chore: use JobStatus computed from the db (#10079)
Fixes `main`
2023-10-05 18:25:06 +00:00
Kayla Washburn 246dae0e1a chore: use emotion for styling (pt. 3) (#10026) 2023-10-05 10:49:44 -06:00
Kayla Washburn f001a57614 fix: only allow promoting successful template versions (#9998) 2023-10-05 10:49:25 -06:00
Mathias Fredriksson 48ee80a559 fix(cli): prevent sqlDB leaks in ConnectToPostgres (#10072) 2023-10-05 17:57:48 +03:00
Mathias Fredriksson 5d5a7da67f fix(scaletest): output error and trace instead of {} for json output (#10075) 2023-10-05 13:31:54 +00:00
Marcin Tojek ab9276bd08 feat: modify workspace_agent_stats index (#10073) 2023-10-05 14:49:08 +02:00
Colin Adler 30440915bc chore: add mod replace wireguard-go to fix race condition (#10071)
Fixes https://github.com/coder/coder/issues/10045
2023-10-04 23:47:01 -05:00
Steven Masley 5021e23105 chore: compute job status as column (#10024)
* chore: provisioner job status as column
* use provisioner job status for workspace searching
2023-10-04 20:57:46 -05:00
Colin Adler d5040441aa fix(site): change utils/delay import path (#10065) 2023-10-04 17:15:20 -05:00
Kyle Carberry df8e10cc4c chore: increase ForceCancelInterval for test flakes (#10066)
See https://github.com/coder/coder/actions/runs/6411239320/job/17406394658
2023-10-04 21:16:39 +00:00
Kyle Carberry bca7416069 fix: add --version flag to the root to support migrating customers (#10063) 2023-10-04 15:37:15 -05:00
Jon Ayers 1cd4405caf fix: change alpha badge color to violet (#10029)
- Makes it less scary.
2023-10-04 15:20:13 -05:00
Bruno Quaresma 03c377b754 fix(site): fix users page for template admins (#10060)
Fix https://github.com/coder/coder/issues/10053
2023-10-04 17:05:49 -03:00
Bruno Quaresma a8ed88b22e fix(site): fix chart label depending on interval (#10059)
Close https://github.com/coder/coder/issues/10056
2023-10-04 17:05:29 -03:00
Eric Paulsen 1076d16456 docs: update offline tf provider config (#10062) 2023-10-04 15:40:09 -04:00
Kyle Carberry fd06b7f7a0 fix: allow all environment variables to fallback prefix to HOMEBREW_ (#10050)
See the customer use-case in the code docs.
2023-10-04 18:57:49 +00:00
Kyle Carberry 252ec14556 fix: update the validation url for github enterprise (#10061)
This was wrong... not sure why.
2023-10-04 18:49:40 +00:00
Kyle Carberry 7f9b4ad9a8 fix: allow auditors to query deployment stats and insights (#10058)
This is a customer request.
2023-10-04 18:37:25 +00:00
Bruno Quaresma 516b88dc25 fix(site): disable auto fields when they are disabled in the template settings (#10022)
- Disable form inputs 
- Add disable badge + tooltip with more info

<img width="1679" alt="Screen Shot 2023-10-03 at 14 20 26" src="https://github.com/coder/coder/assets/3165839/7555eb77-19d9-4a13-965e-6d40c3b852dd">

Fix https://github.com/coder/coder/issues/9820
2023-10-04 15:00:09 -03:00
Ben Potter 46551e619d docs: add v2.2.1 changelog (#10055)
* fix external auth link

* chore v2.2.1 changelog
2023-10-04 17:02:14 +00:00
Kyle Carberry 64692f0b69 chore: update docs for external-auth (#10046) 2023-10-04 11:38:41 -05:00
Kyle Carberry defef4671c fix: silence bash deprecation warning on macOS runners (#10051)
See https://github.com/coder/coder/actions/runs/6407839577/job/17395535790?pr=10050
2023-10-04 15:36:27 +00:00
Cian Johnston 2c2e98cc39 fix(coderd): fetch workspace agent scripts and log sources using system auth ctx (#10043)
* add failing unit test
* fetch log sources and agent scripts using system auth ctx
2023-10-04 15:50:51 +01:00
Kyle Carberry 8e44dce5b3 chore: fix external-auth.mp4 docs video (#10048) 2023-10-04 14:39:13 +00:00
Bruno Quaresma 6651aff57b feat(site): add user activity on template insights (#10013)
Close https://github.com/coder/coder/issues/9497


https://github.com/coder/coder/assets/3165839/941e268c-6c06-47ae-b57d-665e01e804b0
2023-10-04 11:37:47 -03:00
Kyle Carberry b468415a81 chore: revert docs for git-auth until release (#10044) 2023-10-04 14:33:28 +00:00
Bruno Quaresma 5e0cb372b4 fix(site): fix orphan values on insights (#10036) 2023-10-04 10:16:59 -03:00
Cian Johnston 2405bbe1b9 fix(coderd/database/dbtestutil): fix typo in pgDump (#10033) 2023-10-04 13:21:45 +01:00
Michael Smith c7218b40c9 docs: update frontend contribution docs (#10028)
* docs: update frontend contribution docs

* fix: update docs formatting
2023-10-04 08:11:07 -04:00
Colin Adler 4ab52766d2 feat: add --net-admin option to install script (#9953) 2023-10-03 23:01:46 +00:00
Colin Adler 39846d69d3 feat: modify agent install script to give CAP_NET_ADMIN if available (#9908) 2023-10-03 17:34:29 -05:00
timquinlan 2a19b46ab7 update to gateway offline install docs, 2 typos, 2 command additions (#10027) 2023-10-03 17:58:26 -04:00
dependabot[bot] 6322e13046 chore: bump postcss from 8.4.27 to 8.4.31 in /site (#10019)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.27 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.27...8.4.31)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-04 00:28:54 +03:00
Bruno Quaresma efdbb6f9e6 fix(site): remove 48 week option (#10025) 2023-10-03 18:25:03 -03:00
Kayla Washburn e6aeee2ba2 feat: warn users when renaming workspaces (#10023) 2023-10-03 15:04:34 -06:00
dependabot[bot] 4df5c1ddec chore: bump the alpine image from 3.18.3 to 3.18.4 in Dockerfile.base (#9993)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-03 14:09:50 -05:00
Bruno Quaresma bdb9954f87 feat(site): add support for weekly data on template insights (#9997)
Close https://github.com/coder/coder/issues/9495
2023-10-03 15:14:11 -03:00
Bruno Quaresma e7042e601c fix(site): fix navbar hover (#10021) 2023-10-03 14:10:51 -03:00
Kayla Washburn c194119689 chore: rename AwaitTemplateVersionJobCompleted and AwaitWorkspaceBuildJobCompleted (#10003) 2023-10-03 11:02:56 -06:00
Kayla Washburn 4b97ac269b chore: refactor Pill styles (#10004) 2023-10-03 10:47:28 -06:00
Kyle Carberry 5e3bf275da chore: check for valid regex in git auth configs (#10020) 2023-10-03 16:45:07 +00:00
Ammar Bandukwala 70a4e56c01 ci: switch to M1 runners
ci: switch to M1 runners
    
 Per
    https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/,
    we should see large performance improvements.
2023-10-03 10:54:20 -05:00
Kyle Carberry f16eb1331f chore: update multiple git providers docs (#10017)
* chore: update multiple git providers docs

* Improve var name

* Fix fmt
2023-10-03 15:27:02 +00:00
Kyle Carberry eeab33b1c3 fix: do not require client_secret for external auth providers (#10016)
Device-based auth does not need a client secret.
2023-10-03 14:29:34 +00:00
Cian Johnston 9aac15212b fix(cli): remove exp scaletest from slim binary (#9934)
- Removes the `exp scaletest` command from the slim binary 
- Updates scaletest-runner template to fetch the full binary from the running Coder instance
2023-10-03 15:13:04 +01:00
Kyle Carberry 45b53c285f feat: allow external services to be authable (#9996)
* feat: allow external services to be authable

* Refactor external auth config structure for defaults

* Add support for new config properties

* Change the name of external auth

* Move externalauth -> external-auth

* Run gen

* Fix tests

* Fix MW tests

* Fix git auth redirect

* Fix lint

* Fix name

* Allow any ID

* Fix invalid type test

* Fix e2e tests

* Fix comments

* Fix colors

* Allow accepting any type as string

* Run gen

* Fix href
2023-10-03 14:04:39 +00:00
Marcin Tojek f62f45a303 feat!: add sections parameter to template insights (#10010) 2023-10-03 15:44:50 +02:00
Marcin Tojek cb60409a8c feat: add index to workspace_agent_stats (#10009) 2023-10-03 11:13:44 +00:00
dependabot[bot] cc2772c646 chore: bump github.com/prometheus/client_golang from 1.16.0 to 1.17.0 (#9989)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-03 13:12:06 +03:00
Cian Johnston e55c25e037 chore: enable exhaustruct linter for database param structs (#9995) 2023-10-03 09:23:45 +01:00
Muhammad Atif Ali 352ec7bc4f chore(dogfood): rename project_directory to folder (#10008) 2023-10-03 07:11:58 +00:00
Monika Pawluczuk 4966ef02cf feat(cli): add reverse tunnelling SSH support for unix sockets (#9976) 2023-10-03 16:39:39 +10:00
Muhammad Atif Ali 465546eefd chore(dogfood): open vscode desktop in coder repo directory (#9999) 2023-10-03 08:55:25 +03:00
Eric Paulsen 3980dbd029 docs: add support to enterprise features (#10005) 2023-10-02 21:25:05 -05:00
Bruno Quaresma 9e1e365b32 chore(site): remove user search service (#9939) 2023-10-02 15:24:28 -03:00
Bruno Quaresma 42e25740eb chore(site): remove users and pagination services (#9932) 2023-10-02 15:10:51 -03:00
Kayla Washburn 885b2502ed chore: replace <ChooseOne> with alternatives when appropriate (#9907) 2023-10-02 10:51:35 -06:00
Kayla Washburn 148fa819ae chore: use emotion for styling (pt. 2) (#9951) 2023-10-02 10:48:11 -06:00
dependabot[bot] fabcc41a6b chore: bump @types/node from 18.17.0 to 18.18.1 in /offlinedocs (#9971)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.17.0 to 18.18.1.
- [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-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-02 10:06:59 -05:00
dependabot[bot] 6452008e32 chore: bump github.com/sqlc-dev/pqtype from 0.2.0 to 0.3.0 (#9991)
Bumps [github.com/sqlc-dev/pqtype](https://github.com/sqlc-dev/pqtype) from 0.2.0 to 0.3.0.
- [Release notes](https://github.com/sqlc-dev/pqtype/releases)
- [Commits](https://github.com/sqlc-dev/pqtype/compare/v0.2.0...v0.3.0)

---
updated-dependencies:
- dependency-name: github.com/sqlc-dev/pqtype
  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-10-02 10:06:50 -05:00
dependabot[bot] f694204773 chore: bump @types/node from 18.17.0 to 18.18.1 in /site (#9967)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.17.0 to 18.18.1.
- [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-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-02 10:38:26 -04:00
dependabot[bot] 0a54506940 chore: bump the otel group with 3 updates (#9988)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-02 14:27:21 +00:00
dependabot[bot] f802fba89e chore: bump github.com/open-policy-agent/opa from 0.56.0 to 0.57.0 (#9992)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-02 14:15:58 +00:00
dependabot[bot] 89c2938b20 chore: bump google.golang.org/api from 0.142.0 to 0.143.0 (#9990)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-02 17:02:51 +03:00
dependabot[bot] 06411b8b17 ci: bump the github-actions group with 2 updates (#9994)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-02 17:02:41 +03:00
Marcin Tojek 57909e0c72 site(e2e): wait for empty workspaces (#9987) 2023-10-02 11:53:44 +00:00
Mathias Fredriksson 4b0565c895 feat(scaletest): add service banner status for runner (#9945) 2023-10-02 14:37:38 +03:00
Mathias Fredriksson e6d2ddb54b feat(scaletest): add apps to scaletest template (#9944) 2023-10-02 14:37:16 +03:00
Muhammad Atif Ali 1a07ee0b16 chore(site): make name bold in delete dialog
This makes the name bold in delete dialog and makes it readable.
<img width="439" alt="Screenshot 2023-09-24 at 03 30 55" src="https://github.com/coder/coder/assets/10648092/b97e634b-c7c8-4300-b78c-8091b3f2c9f0">

Edit: Tests are passed. thanks @aslilac
2023-10-02 13:57:21 +03:00
Cian Johnston 1c48610d56 feat(scaletest/dashboard): integrate chromedp (#9927)
* Adds a set of actions to automatically interact with a Coder instance using chromedp
* Integrates the chromedp actions into the scaletest dashboard command,
* Re-enables the previously disabled unit tests for scaletest/dashboard
* Removes previous dashboard actions based around codersdk
2023-10-02 10:40:17 +01:00
Muhammad Atif Ali 1906cc4806 Revert "chore: bump remark-gfm from 3.0.1 to 4.0.0 in /site (#9965)" (#9981)
This reverts commit 81a046e0a9.
2023-10-02 09:56:35 +02:00
dependabot[bot] 81a046e0a9 chore: bump remark-gfm from 3.0.1 to 4.0.0 in /site (#9965)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-02 10:31:56 +03:00
dependabot[bot] 247eeab3c8 chore: bump next from 13.4.12 to 13.5.3 in /offlinedocs (#9972)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-02 09:22:15 +03:00
dependabot[bot] 52b16f0622 chore: bump the eslint group in /site with 1 update
Bumps the eslint group in /site with 1 update: [eslint](https://github.com/eslint/eslint).

<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/eslint/eslint/releases">eslint's releases</a>.</em></p>
<blockquote>
<h2>v8.50.0</h2>
<h2>Features</h2>
<ul>
<li><a href="https://github.com/eslint/eslint/commit/27d5a9e57ad347982a68fcd0e75eafee42d344f0"><code>27d5a9e</code></a> feat: add suggestions to array-callback-return (<a href="https://redirect.github.com/eslint/eslint/issues/17590">#17590</a>) (Tanuj Kanti)</li>
<li><a href="https://github.com/eslint/eslint/commit/f9082ff3f3956a0a5a7d7659de63640a21c4de0f"><code>f9082ff</code></a> feat: flat-rule-tester make sure default config always matches (<a href="https://redirect.github.com/eslint/eslint/issues/17585">#17585</a>) (fnx)</li>
<li><a href="https://github.com/eslint/eslint/commit/83914adbfd5fce7d11b33d095ba6d6a39be0dbbc"><code>83914ad</code></a> feat: Implement SourceCode#applyInlineConfig() (<a href="https://redirect.github.com/eslint/eslint/issues/17351">#17351</a>) (Nicholas C. Zakas)</li>
<li><a href="https://github.com/eslint/eslint/commit/22a558228ff98f478fa308c9ecde361acc4caf20"><code>22a5582</code></a> feat: add rule <code>no-object-constructor</code>, deprecate <code>no-new-object</code> (<a href="https://redirect.github.com/eslint/eslint/issues/17576">#17576</a>) (Francesco Trotta)</li>
<li><a href="https://github.com/eslint/eslint/commit/85a3d9e967b19cb4a0189746499d81ef2f93e14e"><code>85a3d9e</code></a> feat: allowVoid option in array-callback-return (<a href="https://redirect.github.com/eslint/eslint/issues/17564">#17564</a>) (Tanuj Kanti)</li>
</ul>
<h2>Bug Fixes</h2>
<ul>
<li><a href="https://github.com/eslint/eslint/commit/cc4d26b5a59d510f2c878e973fd245e8eff27c2a"><code>cc4d26b</code></a> fix: Ensure deprecated context.parserServices warns (<a href="https://redirect.github.com/eslint/eslint/issues/17593">#17593</a>) (Nicholas C. Zakas)</li>
<li><a href="https://github.com/eslint/eslint/commit/1ea4cfb585dcb52ac3cb1522a32f25cfe507121b"><code>1ea4cfb</code></a> fix: Ensure all RuleTester tests all deprecated context methods (<a href="https://redirect.github.com/eslint/eslint/issues/17587">#17587</a>) (Nicholas C. Zakas)</li>
<li><a href="https://github.com/eslint/eslint/commit/aa1b657a9febcd03e9298c03ae2888762795e322"><code>aa1b657</code></a> fix: wrong suggestion and message in <code>no-misleading-character-class</code> (<a href="https://redirect.github.com/eslint/eslint/issues/17571">#17571</a>) (Yosuke Ota)</li>
</ul>
<h2>Documentation</h2>
<ul>
<li><a href="https://github.com/eslint/eslint/commit/180053759c6cf05a326c710353b4717fbf289ee0"><code>1800537</code></a> docs: Fix and standardize JSX code examples (<a href="https://redirect.github.com/eslint/eslint/issues/17591">#17591</a>) (Francesco Trotta)</li>
<li><a href="https://github.com/eslint/eslint/commit/48a44a73ac456739bdee348bbaf1840d2b1e4830"><code>48a44a7</code></a> docs: Add correct/incorrect tags to <code>prefer-arrow-callback</code> (<a href="https://redirect.github.com/eslint/eslint/issues/17589">#17589</a>) (Francesco Trotta)</li>
<li><a href="https://github.com/eslint/eslint/commit/20893d48b9012f2b61bbbfeac8bee70d68d90e5e"><code>20893d4</code></a> docs: fix incorrect tag's place (<a href="https://redirect.github.com/eslint/eslint/issues/17575">#17575</a>) (Tanuj Kanti)</li>
<li><a href="https://github.com/eslint/eslint/commit/bd7a71fd6b7efb0445393304e2d48c5c06d46a45"><code>bd7a71f</code></a> docs: Update README (GitHub Actions Bot)</li>
</ul>
<h2>Chores</h2>
<ul>
<li><a href="https://github.com/eslint/eslint/commit/f8a8a2d6b45c82f94a574623759b6e3d2af193f3"><code>f8a8a2d</code></a> chore: upgrade <code>@​eslint/js</code><a href="https://github.com/8"><code>@​8</code></a>.50.0 (<a href="https://redirect.github.com/eslint/eslint/issues/17599">#17599</a>) (Milos Djermanovic)</li>
<li><a href="https://github.com/eslint/eslint/commit/38ada6df8f4a0313b7d0739b28f0af6b4897b8ce"><code>38ada6d</code></a> chore: package.json update for <code>@​eslint/js</code> release (ESLint Jenkins)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/eslint/eslint/blob/main/CHANGELOG.md">eslint's changelog</a>.</em></p>
<blockquote>
<p>v8.50.0 - September 22, 2023</p>
<ul>
<li><a href="https://github.com/eslint/eslint/commit/f8a8a2d6b45c82f94a574623759b6e3d2af193f3"><code>f8a8a2d</code></a> chore: upgrade <code>@​eslint/js</code><a href="https://github.com/8"><code>@​8</code></a>.50.0 (<a href="https://redirect.github.com/eslint/eslint/issues/17599">#17599</a>) (Milos Djermanovic)</li>
<li><a href="https://github.com/eslint/eslint/commit/38ada6df8f4a0313b7d0739b28f0af6b4897b8ce"><code>38ada6d</code></a> chore: package.json update for <code>@​eslint/js</code> release (ESLint Jenkins)</li>
<li><a href="https://github.com/eslint/eslint/commit/27d5a9e57ad347982a68fcd0e75eafee42d344f0"><code>27d5a9e</code></a> feat: add suggestions to array-callback-return (<a href="https://redirect.github.com/eslint/eslint/issues/17590">#17590</a>) (Tanuj Kanti)</li>
<li><a href="https://github.com/eslint/eslint/commit/f9082ff3f3956a0a5a7d7659de63640a21c4de0f"><code>f9082ff</code></a> feat: flat-rule-tester make sure default config always matches (<a href="https://redirect.github.com/eslint/eslint/issues/17585">#17585</a>) (fnx)</li>
<li><a href="https://github.com/eslint/eslint/commit/83914adbfd5fce7d11b33d095ba6d6a39be0dbbc"><code>83914ad</code></a> feat: Implement SourceCode#applyInlineConfig() (<a href="https://redirect.github.com/eslint/eslint/issues/17351">#17351</a>) (Nicholas C. Zakas)</li>
<li><a href="https://github.com/eslint/eslint/commit/cc4d26b5a59d510f2c878e973fd245e8eff27c2a"><code>cc4d26b</code></a> fix: Ensure deprecated context.parserServices warns (<a href="https://redirect.github.com/eslint/eslint/issues/17593">#17593</a>) (Nicholas C. Zakas)</li>
<li><a href="https://github.com/eslint/eslint/commit/1ea4cfb585dcb52ac3cb1522a32f25cfe507121b"><code>1ea4cfb</code></a> fix: Ensure all RuleTester tests all deprecated context methods (<a href="https://redirect.github.com/eslint/eslint/issues/17587">#17587</a>) (Nicholas C. Zakas)</li>
<li><a href="https://github.com/eslint/eslint/commit/180053759c6cf05a326c710353b4717fbf289ee0"><code>1800537</code></a> docs: Fix and standardize JSX code examples (<a href="https://redirect.github.com/eslint/eslint/issues/17591">#17591</a>) (Francesco Trotta)</li>
<li><a href="https://github.com/eslint/eslint/commit/22a558228ff98f478fa308c9ecde361acc4caf20"><code>22a5582</code></a> feat: add rule <code>no-object-constructor</code>, deprecate <code>no-new-object</code> (<a href="https://redirect.github.com/eslint/eslint/issues/17576">#17576</a>) (Francesco Trotta)</li>
<li><a href="https://github.com/eslint/eslint/commit/48a44a73ac456739bdee348bbaf1840d2b1e4830"><code>48a44a7</code></a> docs: Add correct/incorrect tags to <code>prefer-arrow-callback</code> (<a href="https://redirect.github.com/eslint/eslint/issues/17589">#17589</a>) (Francesco Trotta)</li>
<li><a href="https://github.com/eslint/eslint/commit/aa1b657a9febcd03e9298c03ae2888762795e322"><code>aa1b657</code></a> fix: wrong suggestion and message in <code>no-misleading-character-class</code> (<a href="https://redirect.github.com/eslint/eslint/issues/17571">#17571</a>) (Yosuke Ota)</li>
<li><a href="https://github.com/eslint/eslint/commit/20893d48b9012f2b61bbbfeac8bee70d68d90e5e"><code>20893d4</code></a> docs: fix incorrect tag's place (<a href="https://redirect.github.com/eslint/eslint/issues/17575">#17575</a>) (Tanuj Kanti)</li>
<li><a href="https://github.com/eslint/eslint/commit/85a3d9e967b19cb4a0189746499d81ef2f93e14e"><code>85a3d9e</code></a> feat: allowVoid option in array-callback-return (<a href="https://redirect.github.com/eslint/eslint/issues/17564">#17564</a>) (Tanuj Kanti)</li>
<li><a href="https://github.com/eslint/eslint/commit/bd7a71fd6b7efb0445393304e2d48c5c06d46a45"><code>bd7a71f</code></a> docs: Update README (GitHub Actions Bot)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/eslint/eslint/commit/299bfae1254f22bd4b3bccd897d6355f63e0d3b6"><code>299bfae</code></a> 8.50.0</li>
<li><a href="https://github.com/eslint/eslint/commit/212687c36a9e2682b84f5de2b683b025182d9777"><code>212687c</code></a> Build: changelog update for 8.50.0</li>
<li><a href="https://github.com/eslint/eslint/commit/f8a8a2d6b45c82f94a574623759b6e3d2af193f3"><code>f8a8a2d</code></a> chore: upgrade <code>@​eslint/js</code><a href="https://github.com/8"><code>@​8</code></a>.50.0 (<a href="https://redirect.github.com/eslint/eslint/issues/17599">#17599</a>)</li>
<li><a href="https://github.com/eslint/eslint/commit/38ada6df8f4a0313b7d0739b28f0af6b4897b8ce"><code>38ada6d</code></a> chore: package.json update for <code>@​eslint/js</code> release</li>
<li><a href="https://github.com/eslint/eslint/commit/27d5a9e57ad347982a68fcd0e75eafee42d344f0"><code>27d5a9e</code></a> feat: add suggestions to array-callback-return (<a href="https://redirect.github.com/eslint/eslint/issues/17590">#17590</a>)</li>
<li><a href="https://github.com/eslint/eslint/commit/f9082ff3f3956a0a5a7d7659de63640a21c4de0f"><code>f9082ff</code></a> feat: flat-rule-tester make sure default config always matches (<a href="https://redirect.github.com/eslint/eslint/issues/17585">#17585</a>)</li>
<li><a href="https://github.com/eslint/eslint/commit/83914adbfd5fce7d11b33d095ba6d6a39be0dbbc"><code>83914ad</code></a> feat: Implement SourceCode#applyInlineConfig() (<a href="https://redirect.github.com/eslint/eslint/issues/17351">#17351</a>)</li>
<li><a href="https://github.com/eslint/eslint/commit/cc4d26b5a59d510f2c878e973fd245e8eff27c2a"><code>cc4d26b</code></a> fix: Ensure deprecated context.parserServices warns (<a href="https://redirect.github.com/eslint/eslint/issues/17593">#17593</a>)</li>
<li><a href="https://github.com/eslint/eslint/commit/1ea4cfb585dcb52ac3cb1522a32f25cfe507121b"><code>1ea4cfb</code></a> fix: Ensure all RuleTester tests all deprecated context methods (<a href="https://redirect.github.com/eslint/eslint/issues/17587">#17587</a>)</li>
<li><a href="https://github.com/eslint/eslint/commit/180053759c6cf05a326c710353b4717fbf289ee0"><code>1800537</code></a> docs: Fix and standardize JSX code examples (<a href="https://redirect.github.com/eslint/eslint/issues/17591">#17591</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/eslint/eslint/compare/v8.49.0...v8.50.0">compare view</a></li>
</ul>
</details>
<br />


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

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

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

---

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

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


</details>
2023-10-02 08:53:55 +03:00
dependabot[bot] 8af28717a3 chore: bump eslint from 8.49.0 to 8.50.0 in /offlinedocs (#9970)
Bumps [eslint](https://github.com/eslint/eslint) from 8.49.0 to 8.50.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.49.0...v8.50.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-10-02 05:46:22 +00:00
dependabot[bot] d650cf9b8c chore: bump eslint-config-next from 13.4.10 to 13.5.3 in /offlinedocs (#9973)
Bumps [eslint-config-next](https://github.com/vercel/next.js/tree/HEAD/packages/eslint-config-next) from 13.4.10 to 13.5.3.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](https://github.com/vercel/next.js/commits/v13.5.3/packages/eslint-config-next)

---
updated-dependencies:
- dependency-name: eslint-config-next
  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-10-02 08:42:11 +03:00
dependabot[bot] cac677b4ba chore: bump @octokit/types from 11.1.0 to 12.0.0 in /site (#9963)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-01 11:50:36 +00:00
dependabot[bot] 3dc478ad6b chore: bump ts-proto from 1.158.0 to 1.159.1 in /site (#9964)
Bumps [ts-proto](https://github.com/stephenh/ts-proto) from 1.158.0 to 1.159.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/stephenh/ts-proto/releases">ts-proto's releases</a>.</em></p>
<blockquote>
<h2>v1.159.1</h2>
<h2><a href="https://github.com/stephenh/ts-proto/compare/v1.159.0...v1.159.1">1.159.1</a> (2023-09-30)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>Use a Map when map keys are boolean. (<a href="https://redirect.github.com/stephenh/ts-proto/issues/933">#933</a>) (<a href="https://github.com/stephenh/ts-proto/commit/c1253a3761405d7a2ffe4d15f4c3ffb364697a02">c1253a3</a>), closes <a href="https://redirect.github.com/stephenh/ts-proto/issues/926">#926</a></li>
</ul>
<h2>v1.159.0</h2>
<h1><a href="https://github.com/stephenh/ts-proto/compare/v1.158.1...v1.159.0">1.159.0</a> (2023-09-30)</h1>
<h3>Features</h3>
<ul>
<li>Add globalThisPolyfill, defaults false. (<a href="https://redirect.github.com/stephenh/ts-proto/issues/931">#931</a>) (<a href="https://github.com/stephenh/ts-proto/commit/085fa21603a74544af192f404289c2e62ecfd8f6">085fa21</a>)</li>
</ul>
<h2>v1.158.1</h2>
<h2><a href="https://github.com/stephenh/ts-proto/compare/v1.158.0...v1.158.1">1.158.1</a> (2023-09-30)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>Use globalThis for Array/String/Boolean (<a href="https://redirect.github.com/stephenh/ts-proto/issues/930">#930</a>) (<a href="https://github.com/stephenh/ts-proto/commit/9a252c3d4cf988496f6de17cc378dbb09a1baf92">9a252c3</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/stephenh/ts-proto/blob/main/CHANGELOG.md">ts-proto's changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/stephenh/ts-proto/compare/v1.159.0...v1.159.1">1.159.1</a> (2023-09-30)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>Use a Map when map keys are boolean. (<a href="https://redirect.github.com/stephenh/ts-proto/issues/933">#933</a>) (<a href="https://github.com/stephenh/ts-proto/commit/c1253a3761405d7a2ffe4d15f4c3ffb364697a02">c1253a3</a>), closes <a href="https://redirect.github.com/stephenh/ts-proto/issues/926">#926</a></li>
</ul>
<h1><a href="https://github.com/stephenh/ts-proto/compare/v1.158.1...v1.159.0">1.159.0</a> (2023-09-30)</h1>
<h3>Features</h3>
<ul>
<li>Add globalThisPolyfill, defaults false. (<a href="https://redirect.github.com/stephenh/ts-proto/issues/931">#931</a>) (<a href="https://github.com/stephenh/ts-proto/commit/085fa21603a74544af192f404289c2e62ecfd8f6">085fa21</a>)</li>
</ul>
<h2><a href="https://github.com/stephenh/ts-proto/compare/v1.158.0...v1.158.1">1.158.1</a> (2023-09-30)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>Use globalThis for Array/String/Boolean (<a href="https://redirect.github.com/stephenh/ts-proto/issues/930">#930</a>) (<a href="https://github.com/stephenh/ts-proto/commit/9a252c3d4cf988496f6de17cc378dbb09a1baf92">9a252c3</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/stephenh/ts-proto/commit/09e9fa2594431785253a2fc15e66d85e721003e9"><code>09e9fa2</code></a> chore(release): 1.159.1 [skip ci]</li>
<li><a href="https://github.com/stephenh/ts-proto/commit/c1253a3761405d7a2ffe4d15f4c3ffb364697a02"><code>c1253a3</code></a> fix: Use a Map when map keys are boolean. (<a href="https://redirect.github.com/stephenh/ts-proto/issues/933">#933</a>)</li>
<li><a href="https://github.com/stephenh/ts-proto/commit/ccf54be52d181c341ff310c68665a65fef3ed86d"><code>ccf54be</code></a> chore(release): 1.159.0 [skip ci]</li>
<li><a href="https://github.com/stephenh/ts-proto/commit/085fa21603a74544af192f404289c2e62ecfd8f6"><code>085fa21</code></a> feat: Add globalThisPolyfill, defaults false. (<a href="https://redirect.github.com/stephenh/ts-proto/issues/931">#931</a>)</li>
<li><a href="https://github.com/stephenh/ts-proto/commit/6f856376b103284e2694d3bb7d4471c6b43429f9"><code>6f85637</code></a> chore(release): 1.158.1 [skip ci]</li>
<li><a href="https://github.com/stephenh/ts-proto/commit/9a252c3d4cf988496f6de17cc378dbb09a1baf92"><code>9a252c3</code></a> fix: Use globalThis for Array/String/Boolean (<a href="https://redirect.github.com/stephenh/ts-proto/issues/930">#930</a>)</li>
<li>See full diff in <a href="https://github.com/stephenh/ts-proto/compare/v1.158.0...v1.159.1">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=ts-proto&package-manager=npm_and_yarn&previous-version=1.158.0&new-version=1.159.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

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

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

---

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

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


</details>
2023-10-01 14:49:04 +03:00
dependabot[bot] b035c4d88a chore: bump chromatic from 7.1.0 to 7.2.0 in /site (#9966)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 7.1.0 to 7.2.0.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/chromaui/chromatic-cli/commit/5366e6b8a73f606cdf48bec69176c090bdaf58c4"><code>5366e6b</code></a> 7.2.0</li>
<li><a href="https://github.com/chromaui/chromatic-cli/commit/0749afb68e1da025de47af3204e6ea5062c9c571"><code>0749afb</code></a> Step package.json back</li>
<li><a href="https://github.com/chromaui/chromatic-cli/commit/788d8e96f72a95fc69f831fbceab862fd404a6ce"><code>788d8e9</code></a> Merge pull request <a href="https://redirect.github.com/chromaui/chromatic-cli/issues/819">#819</a> from chromaui/tom/drop-loggly</li>
<li><a href="https://github.com/chromaui/chromatic-cli/commit/0967fa81cc4358e3709e4468c5599e1797922c58"><code>0967fa8</code></a> 7.2.1-canary.0</li>
<li><a href="https://github.com/chromaui/chromatic-cli/commit/2f9484e733bd09300de76707d24815e08adbaca7"><code>2f9484e</code></a> No longer log to loggly</li>
<li><a href="https://github.com/chromaui/chromatic-cli/commit/6f614e64036e02bbb0cec3d9252718de7277acb0"><code>6f614e6</code></a> 7.2.0-next.1</li>
<li><a href="https://github.com/chromaui/chromatic-cli/commit/10bc2a32a1db2e5039e117e233f3aba3c6cfe51b"><code>10bc2a3</code></a> 7.2.0-next.0</li>
<li><a href="https://github.com/chromaui/chromatic-cli/commit/a0b14d8c45f8fc2c50cbb7b944bcddee3a9cf294"><code>a0b14d8</code></a> Merge pull request <a href="https://redirect.github.com/chromaui/chromatic-cli/issues/814">#814</a> from chromaui/tom/ap-3623-add-cli-support-for-a-chrom...</li>
<li><a href="https://github.com/chromaui/chromatic-cli/commit/a8acc0e8d33180a35846feb8c314d0fe0edfae97"><code>a8acc0e</code></a> Trying <code>xlarge</code></li>
<li><a href="https://github.com/chromaui/chromatic-cli/commit/5af4e277207621d0b379bc272a60972cf1c29eeb"><code>5af4e27</code></a> Try medium resource class</li>
<li>Additional commits viewable in <a href="https://github.com/chromaui/chromatic-cli/compare/v7.1.0...v7.2.0">compare view</a></li>
</ul>
</details>
<br />


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

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

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

---

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

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


</details>
2023-10-01 14:42:35 +03:00
dependabot[bot] 3d71173e74 chore: bump yup from 1.2.0 to 1.3.2 in /site (#9968)
Bumps [yup](https://github.com/jquense/yup) from 1.2.0 to 1.3.2.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/jquense/yup/blob/master/CHANGELOG.md">yup's changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/jquense/yup/compare/v1.3.1...v1.3.2">1.3.2</a> (2023-09-29)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>pick and omit with excluded edges (<a href="https://github.com/jquense/yup/commit/6956ee788369dff00e5ecadb506726af3598a87e">6956ee7</a>), closes <a href="https://redirect.github.com/jquense/yup/issues/2097">#2097</a></li>
</ul>
<h2><a href="https://github.com/jquense/yup/compare/v1.3.0...v1.3.1">1.3.1</a> (2023-09-26)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>ValidationError extends Error (<a href="https://github.com/jquense/yup/commit/bc5121b92d8e16baf8fe9b83f0247a4e90e169b8">bc5121b</a>)</li>
</ul>
<h1><a href="https://github.com/jquense/yup/compare/v1.2.0...v1.3.0">1.3.0</a> (2023-09-23)</h1>
<h3>Bug Fixes</h3>
<ul>
<li>add tuple to locale object (<a href="https://redirect.github.com/jquense/yup/issues/2100">#2100</a>) (<a href="https://github.com/jquense/yup/commit/809b55a9c16e0cd567f4eced9b9ab02ad8b0bffa">809b55a</a>)</li>
<li>performance improvement (<a href="https://redirect.github.com/jquense/yup/issues/2043">#2043</a>) (<a href="https://redirect.github.com/jquense/yup/issues/2044">#2044</a>) (<a href="https://github.com/jquense/yup/commit/ee1b7317b0a9fc0e16a7d33064c3e5584bd7f2d5">ee1b731</a>)</li>
</ul>
<h3>Features</h3>
<ul>
<li>Allow schema metadata to be strongly typed (<a href="https://redirect.github.com/jquense/yup/issues/2021">#2021</a>) (<a href="https://github.com/jquense/yup/commit/e593f8f72e7195cf0ac48fa8e1cd82d95c1e6bb5">e593f8f</a>)</li>
</ul>
<h3>Reverts</h3>
<ul>
<li>Revert &quot;fix: performance improvement (<a href="https://redirect.github.com/jquense/yup/issues/2043">#2043</a>) (<a href="https://redirect.github.com/jquense/yup/issues/2044">#2044</a>)&quot; (<a href="https://redirect.github.com/jquense/yup/issues/2071">#2071</a>) (<a href="https://github.com/jquense/yup/commit/b940eef48eb7456622ae384d0ffa7363d4fbad25">b940eef</a>), closes <a href="https://redirect.github.com/jquense/yup/issues/2043">#2043</a> <a href="https://redirect.github.com/jquense/yup/issues/2044">#2044</a> <a href="https://redirect.github.com/jquense/yup/issues/2071">#2071</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/jquense/yup/commit/a58f02d2f6164c46a9757a818eebac582f7a441c"><code>a58f02d</code></a> Publish v1.3.2</li>
<li><a href="https://github.com/jquense/yup/commit/2f2c0aa9be6258b763f95e7de076c2dcfbe0cae3"><code>2f2c0aa</code></a> fix type</li>
<li><a href="https://github.com/jquense/yup/commit/020901fcf3cfb12a38afd90e4fe56e2e37c312a1"><code>020901f</code></a> Allow parent resolve before describe. (<a href="https://redirect.github.com/jquense/yup/issues/2051">#2051</a>)</li>
<li><a href="https://github.com/jquense/yup/commit/6956ee788369dff00e5ecadb506726af3598a87e"><code>6956ee7</code></a> fix: pick and omit with excluded edges</li>
<li><a href="https://github.com/jquense/yup/commit/e15297bb747552e4742bbaa2ecb95aad1c37f918"><code>e15297b</code></a> Publish v1.3.1</li>
<li><a href="https://github.com/jquense/yup/commit/bc5121b92d8e16baf8fe9b83f0247a4e90e169b8"><code>bc5121b</code></a> fix: ValidationError extends Error</li>
<li><a href="https://github.com/jquense/yup/commit/9c1208c0685a5a7571ef74c39a08d248100f793f"><code>9c1208c</code></a> Publish v1.3.0</li>
<li><a href="https://github.com/jquense/yup/commit/809b55a9c16e0cd567f4eced9b9ab02ad8b0bffa"><code>809b55a</code></a> fix: add tuple to locale object (<a href="https://redirect.github.com/jquense/yup/issues/2100">#2100</a>)</li>
<li><a href="https://github.com/jquense/yup/commit/13ce359c20be195794f22f16a64d633bc28db7f5"><code>13ce359</code></a> Update README.md (<a href="https://redirect.github.com/jquense/yup/issues/2101">#2101</a>)</li>
<li><a href="https://github.com/jquense/yup/commit/1ee9b21c994b4293f3ab338119dc17ab2f4e284c"><code>1ee9b21</code></a> Export Lazy and Reference types (<a href="https://redirect.github.com/jquense/yup/issues/2093">#2093</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/jquense/yup/compare/v1.2.0...v1.3.2">compare view</a></li>
</ul>
</details>
<br />


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

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

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

---

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

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


</details>
2023-10-01 14:41:38 +03:00
dependabot[bot] 5b18007311 chore: bump @vitejs/plugin-react from 4.0.1 to 4.1.0 in /site (#9969)
Bumps [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react) from 4.0.1 to 4.1.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/vitejs/vite-plugin-react/releases"><code>@​vitejs/plugin-react</code>'s releases</a>.</em></p>
<blockquote>
<h2>v4.1.0</h2>
<ul>
<li>Add <code>@types/babel__cores</code> to dependencies (fix <a href="https://redirect.github.com/vitejs/vite-plugin-react/issues/211">#211</a>)</li>
<li>Improve build perf when not using Babel plugins by lazy loading <code>@babel/core</code> <a href="https://redirect.github.com/vitejs/vite-plugin-react/pull/212">#212</a></li>
<li>Better invalidation message when an export is added &amp; fix HMR for export of nullish values <a href="https://redirect.github.com/vitejs/vite-plugin-react/pull/215">#215</a></li>
<li>Include non-dev jsx runtime in optimizeDeps &amp; support HMR for JS files using the non dev runtime <a href="https://redirect.github.com/vitejs/vite-plugin-react/pull/224">#224</a></li>
<li>The build output now contains a <code>index.d.cts</code> file so you don't get types errors when setting <code>moduleResolution</code> to <code>node16</code> or <code>nodenext</code> in your tsconfig (we recommend using <code>bundler</code> which is more close to how Vite works)</li>
</ul>
<h2>v4.0.4</h2>
<ul>
<li>Fix <a href="https://github.com/vitejs/vite-plugin-react/discussions/198">#198</a>: Enable Babel if presets list is not empty</li>
</ul>
<h2>v4.0.3</h2>
<ul>
<li>Revert <a href="https://redirect.github.com/vitejs/vite-plugin-react/pull/108">#108</a>: Remove throw when refresh runtime is loaded twice to enable usage in micro frontend apps. This was added to help fix setup usage, and this is not worth an annoying warning for others or a config parameter.</li>
</ul>
<h2>v4.0.2</h2>
<ul>
<li>Fix fast-refresh for files that are transformed into jsx (<a href="https://redirect.github.com/vitejs/vite-plugin-react/pull/188">#188</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/CHANGELOG.md"><code>@​vitejs/plugin-react</code>'s changelog</a>.</em></p>
<blockquote>
<h2>4.1.0 (2023-09-24)</h2>
<ul>
<li>Add <code>@types/babel__cores</code> to dependencies (fix <a href="https://redirect.github.com/vitejs/vite-plugin-react/issues/211">#211</a>)</li>
<li>Improve build perf when not using Babel plugins by lazy loading <code>@babel/core</code> <a href="https://redirect.github.com/vitejs/vite-plugin-react/pull/212">#212</a></li>
<li>Better invalidation message when an export is added &amp; fix HMR for export of nullish values <a href="https://redirect.github.com/vitejs/vite-plugin-react/pull/215">#215</a></li>
<li>Include non-dev jsx runtime in optimizeDeps &amp; support HMR for JS files using the non dev runtime <a href="https://redirect.github.com/vitejs/vite-plugin-react/pull/224">#224</a></li>
<li>The build output now contains a <code>index.d.cts</code> file so you don't get types errors when setting <code>moduleResolution</code> to <code>node16</code> or <code>nodenext</code> in your tsconfig (we recommend using <code>bundler</code> which is more close to how Vite works)</li>
</ul>
<h2>4.0.4 (2023-07-31)</h2>
<ul>
<li>Fix <a href="https://github.com/vitejs/vite-plugin-react/discussions/198">#198</a>: Enable Babel if presets list is not empty</li>
</ul>
<h2>4.0.3 (2023-07-10)</h2>
<ul>
<li>Revert <a href="https://redirect.github.com/vitejs/vite-plugin-react/pull/108">#108</a>: Remove throw when refresh runtime is loaded twice to enable usage in micro frontend apps. This was added to help fix setup usage, and this is not worth an annoying warning for others or a config parameter.</li>
</ul>
<h2>4.0.2 (2023-07-06)</h2>
<ul>
<li>Fix fast-refresh for files that are transformed into jsx (<a href="https://redirect.github.com/vitejs/vite-plugin-react/pull/188">#188</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/vitejs/vite-plugin-react/commit/bf1453edac2d21f7fc06680aa66d178082b770df"><code>bf1453e</code></a> release: plugin-react@4.1.0</li>
<li><a href="https://github.com/vitejs/vite-plugin-react/commit/25fe88a02d3a718b81a3b1290ff4e46bfab427f9"><code>25fe88a</code></a> feat: add support for non-dev jsx runtime (<a href="https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react/issues/224">#224</a>)</li>
<li><a href="https://github.com/vitejs/vite-plugin-react/commit/272c338a7c2927d6e673901bc52f25791d466a98"><code>272c338</code></a> fix(deps): update all non-major dependencies (<a href="https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react/issues/206">#206</a>)</li>
<li><a href="https://github.com/vitejs/vite-plugin-react/commit/286360281992c425bf75cb0a18846f65fcdc5ef3"><code>2863602</code></a> fix: better invalidation message when an export is added &amp; fix HMR for export...</li>
<li><a href="https://github.com/vitejs/vite-plugin-react/commit/ccd25ddf1fe9d70d9486e8f07da95bcf3fd0b5d6"><code>ccd25dd</code></a> perf: lazy load <code>@babel/core</code> (<a href="https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react/issues/212">#212</a>)</li>
<li><a href="https://github.com/vitejs/vite-plugin-react/commit/8413a1835e78a9d923bcc5a5723cb1e903c8fc0f"><code>8413a18</code></a> fix: add <code>@types/babel__cores</code> to dependencies (fix <a href="https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react/issues/211">#211</a>)</li>
<li><a href="https://github.com/vitejs/vite-plugin-react/commit/90328ce92ecfdc9797aa58af67e46f9872b29118"><code>90328ce</code></a> release: plugin-react@4.0.4</li>
<li><a href="https://github.com/vitejs/vite-plugin-react/commit/9f9e2f66d699c47e8bf7b88175fdd55908a2bf35"><code>9f9e2f6</code></a> fix(deps): update all non-major dependencies (<a href="https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react/issues/199">#199</a>)</li>
<li><a href="https://github.com/vitejs/vite-plugin-react/commit/6e2e0a406e8478002dc0ab4a5104d370d4afc7b3"><code>6e2e0a4</code></a> fix <a href="https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react/issues/198">#198</a>: enable Babel if presets list is not empty</li>
<li><a href="https://github.com/vitejs/vite-plugin-react/commit/cbdf19f8f973fe78495336ca14247ddfc276f998"><code>cbdf19f</code></a> release: plugin-react@4.0.3</li>
<li>Additional commits viewable in <a href="https://github.com/vitejs/vite-plugin-react/commits/v4.1.0/packages/plugin-react">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@vitejs/plugin-react&package-manager=npm_and_yarn&previous-version=4.0.1&new-version=4.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

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

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

---

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

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


</details>
2023-10-01 14:41:02 +03:00
Kyle Carberry 5596fb20b5 chore: move /gitauth to /externalauth on the frontend (#9954)
* chore: move `/gitauth` to `/externalauth` on the frontend

This actually took a lot more jank than anticipated,
so I wanted to split this up before adding the ability
to embed new providers.

* Rename FE

* Fix em' up

* Fix linting error

* Fix e2e tests

* chore: update helm golden files
2023-09-30 14:30:01 -05:00
Muhammad Atif Ali 16a2d4d733 chore(dogfood): use coder modules in dogfood (#9890)
updates dogfood to use coder modules

---

<details open="true"><summary>Generated summary (powered by <a href="https://app.graphite.dev">Graphite</a>)</summary>

> # TL;DR
> This pull request removes the `dotfiles_url` and `jetbrains_ide` parameters, and the related code from the `main.tf` file. It also adds several new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`. The `startup_script` has been updated to remove the installation and launch of `filebrowser` and the `dotfiles` related code. 
> 
> # What changed
> - Removed `dotfiles_url` and `jetbrains_ide` parameters.
> - Removed related code for `dotfiles_url` and `jetbrains_ide`.
> - Added new modules for `dotfiles`, `git-clone`, `personalize`, `code-server`, `jetbrains_gateway`, `vscode`, and `filebrowser`.
> - Updated `startup_script` to remove the installation and launch of `filebrowser` and the `dotfiles` related code.
> 
> # How to test
> 1. Go to https://dev.coder.com/templates/coder/versions/dazzling_hugle0 and create a new workspace or change your dogfood workspace version to `dazzling_hugle0` .
> 2. Verify that the new modules are working as expected.
> 
> # Why make this change
> The `dotfiles_url` and `jetbrains_ide` parameters and related code were removed to simplify the configuration and make it easier to manage. The new modules were added to provide additional functionality and improve the overall user experience. The `startup_script` was updated to reflect these changes.
</details>
2023-09-30 22:22:14 +03:00
Kyle Carberry c1cd93da30 chore: update helm golden files (#9959) 2023-09-30 18:36:34 +00:00
Ammar Bandukwala 3d21872230 chore: set sessionAffinity to None in helm chart (#9918) 2023-09-30 12:33:20 -05:00
Steven Masley e9ccb8dc78 chore: change cli error message handling (#9952)
* chore: add command to easily visualize different errors

* chore: add verbose error printing in cli
2023-09-29 16:50:23 -05:00
Stephen Kirby fa297e1096 feat(site): add white coder icon (#9955)
* Added a white coder svg

* renamed svg

* rename icon
2023-09-29 15:25:44 -05:00
Mathias Fredriksson e6cb2c5a8e chore(go.mod): update cdr.dev/slog to include additional stackdriver field (#9938) 2023-09-29 20:22:37 +00:00
Eric Paulsen 710b170adf site(fix): add space characters to group display name (#9950) 2023-09-29 15:25:59 -04:00
Kyle Carberry 8abca9bea7 chore: rename git_auth to external_auth in our schema (#9935)
* chore: rename `git_auth` to `external_auth` in our schema

We're changing Git auth to be external auth. It will support
any OAuth2 or OIDC provider.

To split up the larger change I want to contribute the schema
changes first, and I'll add the feature itself in another PR.

* Fix names

* Fix outdated view

* Rename some additional places

* Fix sort order

* Fix template versions auth route

* Fix types

* Fix dbauthz
2023-09-29 19:13:20 +00:00
Kayla Washburn 2b5428e95f refactor: start using emotion for styling (#9909) 2023-09-29 13:08:17 -06:00
Colin Adler 4da1223a80 fix: pass OnSubscribe to HA MultiAgent (#9947)
Fixes https://github.com/coder/coder/issues/9929
2023-09-29 13:37:17 -05:00
Kayla Washburn 61154a6bb5 chore: update datadog (#9925) 2023-09-29 12:06:24 -06:00
Steven Masley 92308bec3b chore: color value_source for deployment values (#9922)
* chore: Return populated options vs a blank
* Strip secret values
2023-09-29 12:04:28 -05:00
Marcin Tojek 87ebe6c2c2 test: fix flaky TestPostWorkspacesByOrganization/Create (#9931) 2023-09-29 13:06:21 +00:00
Marcin Tojek c0705ec40e fix: flaky TestCreateValidateRichParameters/ValidateString (#9928) 2023-09-29 12:54:51 +02:00
Marcin Tojek 2dd49cc0a7 fix(site): double input box for logo url (#9926) 2023-09-29 07:27:47 +00:00
Steven Masley beac36027f chore: generate any interface as Deployment Option in TypeScript (#9917)
* chore: handle interfaces as "any" in typescript

Use generated Deployment Option
2023-09-28 16:14:28 -05:00
Colin Adler 885041a65b revert: downgrade alpine to v3.18.3 (#9916) 2023-09-28 20:27:47 +00:00
Steven Masley 8cff6237ba chore: show yaml option in deployment page (#9912) 2023-09-28 15:10:06 -05:00
Colin Adler 92c0237899 chore: upgrade alpine to v3.18.4 2023-09-28 19:47:48 +00:00
Colin Adler ed8ae2f123 chore: upgrade go to 1.20.8 2023-09-28 14:17:15 -05:00
Steven Masley 9e845213f5 chore: include organization id in workspace build audit log (#9905)
* chore: include organization id in workspace build audit log
* rename 'BuildAudit' to 'WorkspaceBuildAudit'
2023-09-28 11:29:12 -05:00
Marcin Tojek 305556f655 feat(site): use custom application name (#9902) 2023-09-28 18:23:27 +02:00
Kayla Washburn 0f946669c1 chore: simplify imports (#9896) 2023-09-28 09:21:36 -06:00
Marcin Tojek dae528f5e7 feat: expose application name and logo url via meta properties (#9900) 2023-09-28 10:50:40 +02:00
Steven Masley 2d1b35390e chore: relax wsproxy version checking (#9796) 2023-09-27 19:34:55 +00:00
Michael Smith dcad8fdc2f fix: add checks for preventing HSL colors from entering React state (#9893)
* fix: remove hsl color from initial form state

* chore: add extra color helpers

* chore: add extra runtime validation for colors

* chore: clean up comments for clarity

* chore: add tests for colors
2023-09-27 19:27:11 +00:00
Ben Potter 20a681af8d chore: add v2.2.0 changelog (#9889)
* chore: add v2.2.0 changelog

* add actual changelog
2023-09-27 17:38:43 +00:00
Kayla Washburn 066b25f710 chore: remove Maybe (#9880) 2023-09-27 10:45:12 -06:00
Cian Johnston 72e8f88af3 feat(scaletest/terraform): add cert-manager, otel, and TLS (#9894) 2023-09-27 17:41:07 +01:00
Mathias Fredriksson 0878381d0b fix(cli/cliui): avoid nil pointer deref when agent disconnects (#9892)
Fixes #9884
2023-09-27 19:10:15 +03:00
Kyle Carberry de6d0b9a1a fix: only specify vscode proxy uri if app subdomains enabled (#9891)
Otherwise this generates an invalid URI that breaks code-server!
2023-09-27 15:13:47 +00:00
Marcin Tojek cb5f8df4c2 feat: expose application name via Appearance API (#9886) 2023-09-27 17:02:18 +02:00
Mathias Fredriksson 68738771b9 feat(scaletest): create automated pprof dumps during scaletest (#9887) 2023-09-27 15:58:43 +03:00
Cian Johnston fad02081fc fix: avoid logging env in unit tests (#9885) 2023-09-27 13:34:40 +01:00
Mathias Fredriksson d8515f02af feat(scaletest): add grafana annotations and slack reporting (#9852)
Fixes #9575
Fixes #9576
2023-09-27 11:44:11 +00:00
Mathias Fredriksson 4e442040f7 feat(coderd/httpmw): log start timestamp for http requests (#9776) 2023-09-27 14:39:22 +03:00
Spike Curtis c67db6efb0 fix: wait for bash prompt before commands (#9882)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-27 12:26:24 +04:00
Cian Johnston 399b428149 chore(scaletest): update scaletest terraform to match big.cdr.dev (#9860)
- Removes usage of null_resources as no longer required
- Updates terraform in both infra/ and k8s/ to match
- Updates provisionerd deployment to use helm chart
2023-09-27 09:02:35 +01:00
Kyle Carberry 726a4dadf2 feat: allow magic string to generate session token for external apps (#9878)
* fix: make non-http external app links open in the current window

* Allow magic string to be replaced with a session token for external apps

* Improve readibility
2023-09-26 16:04:24 -05:00
Kira Pilot 75366ec6b5 more renames (#9876) 2023-09-26 14:45:29 -04:00
Kayla Washburn 6f0e2a7968 refactor: poll for git auth updates when creating a workspace (#9804) 2023-09-26 11:39:07 -06:00
Marcin Tojek 4c3b579f58 feat: expose insights into user activity (#9807) 2023-09-26 18:42:16 +02:00
Cian Johnston 1f4335733c fix(coderd/workspaceapps/apptest): bump sleep in testReconnectingPTY to reduce test flakes (#9875) 2023-09-26 14:58:18 +01:00
Bruno Quaresma b0b9d32a2a chore(site): remove dead code (#9830) 2023-09-26 10:05:24 -03:00
Cian Johnston 93ef696b57 refactor(agent): add agenttest.New helper function (#9812)
* Adds agenttest.New() helper function
* Makes sure agent gets closed on test cleanup
* Makes sure you don't forget to set session token
* Sets the agent and client logger automatically
2023-09-26 12:05:19 +01:00
Cian Johnston 96c5076c69 fix(coderd): remove troublesome test case (#9874) 2023-09-26 11:33:21 +01:00
Kyle Carberry c4718fd747 fix: remove pinned version for dogfood (#9872) 2023-09-26 02:23:42 +00:00
Muhammad Atif Ali 04c85c3833 chore: add icons (#9871) 2023-09-26 00:46:07 +00:00
Kyle Carberry f7c89082d2 chore: swap dogfood to use modules (#9870) 2023-09-25 19:41:45 -05:00
Kyle Carberry 442fb105c9 chore: add git svg icon (#9869) 2023-09-26 00:15:55 +00:00
Kyle Carberry 20bfe6e9e5 fix: allow expansion from log_path for coder_script (#9868) 2023-09-25 23:45:55 +00:00
Colin Adler 89292264be feat(coderd): add simple healthcheck formatting option (#9864) 2023-09-25 22:55:50 +00:00
Kyle Carberry 6e6b808143 fix: add case for logs without a source (#9866)
This is to support legacy logs!
2023-09-25 22:19:51 +00:00
Kyle Carberry d3220c5db9 fix: resolve flake in log sender by checking context (#9865)
See: https://github.com/coder/coder/actions/runs/6305051172/job/17117693579
2023-09-25 22:19:27 +00:00
Kyle Carberry 1262eef2c0 feat: add support for coder_script (#9584)
* Add basic migrations

* Improve schema

* Refactor agent scripts into it's own package

* Support legacy start and stop script format

* Pipe the scripts!

* Finish the piping

* Fix context usage

* It works!

* Fix sql query

* Fix SQL query

* Rename `LogSourceID` -> `SourceID`

* Fix the FE

* fmt

* Rename migrations

* Fix log tests

* Fix lint err

* Fix gen

* Fix story type

* Rename source to script

* Fix schema jank

* Uncomment test

* Rename proto to TimeoutSeconds

* Fix comments

* Fix comments

* Fix legacy endpoint without specified log_source

* Fix non-blocking by default in agent

* Fix resources tests

* Fix dbfake

* Fix resources

* Fix linting I think

* Add fixtures

* fmt

* Fix startup script behavior

* Fix comments

* Fix context

* Fix cancel

* Fix SQL tests

* Fix e2e tests

* Interrupt on Windows

* Fix agent leaking script process

* Fix migrations

* Fix stories

* Fix duplicate logs appearing

* Gen

* Fix log location

* Fix tests

* Fix tests

* Fix log output

* Show display name in output

* Fix print

* Return timeout on start context

* Gen

* Fix fixture

* Fix the agent status

* Fix startup timeout msg

* Fix command using shared context

* Fix timeout draining

* Change signal type

* Add deterministic colors to startup script logs

---------

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-09-25 16:47:17 -05:00
Kayla Washburn dac1375880 feat: add &hellip; to actions that require confirmation (#9862) 2023-09-25 15:25:02 -06:00
Kayla Washburn ff3fc0971c feat: create a workspace from any template version (#9861) 2023-09-25 14:54:19 -06:00
Ammar Bandukwala 4adbf24a08 docs: fix typo (#9859) 2023-09-25 19:52:53 +00:00
Steven Masley b6c5e94ffa fix: consider all 'devel' builds as 'dev' builds (#9794)
* fix: all 'devel' builds should be considered 'dev' builds.

If CI needs to be distinguished from a dev build, we should add
a different pre-release tag for those builds.

* change CI version checking to be more strict
2023-09-25 13:59:49 -05:00
Kayla Washburn 47d3161b0b fix: give more room to lonely resource metadata items (#9832) 2023-09-25 09:40:51 -06:00
Michael Smith 3757005e82 feat: add middle click support for workspace rows (#9834)
* chore: add generic ref support for useClickable

* chore: update useClickable call sites to use type parameter

* chore: update useClickableTableRow implementation

* chore: update other components using useClickableTableRow

* feat: add middle-click and cmd-click support for rows

* refactor: rename variable for clarity

* docs: add comment for clarity

* chore: add more click logic and comments

* refactor: clean up useClickableTableRow

* docs: rewrite comments for clarity

* fix: update TimelineEntry to accept forwarded ref

* fix: fix keyboard event logic to respond to spaces properly
2023-09-25 11:32:33 -04:00
Marcin Tojek 415818035c test(site): e2e: use IPv4 address for web server (#9843) 2023-09-25 14:44:15 +02:00
Cian Johnston 4622ea2c10 chore: remove filebrowser.db (#9854)
* rm and gitignore filebrowser.db
2023-09-25 12:41:27 +00:00
Bruno Quaresma cb545bcc30 chore(site): move a few pages to lazy load (#9831) 2023-09-25 09:38:24 -03:00
Muhammad Atif Ali 63ea12e74c chore: remove terraform provider versions for pr-deployment template (#9853) 2023-09-25 12:33:01 +00:00
dependabot[bot] 7da3180036 chore: bump github.com/spf13/afero from 1.9.5 to 1.10.0 (#9850)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-25 15:32:21 +03:00
dependabot[bot] 9d5af5b483 chore: bump github.com/coder/terraform-provider-coder from 0.11.1 to 0.12.0 (#9849)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-25 15:23:19 +03:00
dependabot[bot] e649b7cefe chore: bump google.golang.org/api from 0.141.0 to 0.142.0 (#9848)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-25 15:22:54 +03:00
dependabot[bot] 5c1ee6990e chore: bump github.com/gohugoio/hugo from 0.118.2 to 0.119.0 (#9847)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-25 15:22:43 +03:00
dependabot[bot] 9358b3bd84 ci: bump the github-actions group with 2 updates (#9846)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-25 15:22:19 +03:00
Muhammad Atif Ali 26e0d7580c chore: avoid pushing .terraform.lock.hcl while creating the template (#9851) 2023-09-25 15:13:32 +03:00
Cian Johnston 382843dc5f chore(docs): add notice re enabling encryption (#9844) 2023-09-25 11:07:38 +01:00
Bruno Quaresma 85ab9c2d48 chore(site): replace agent log service (#9814) 2023-09-22 16:13:25 -03:00
Bruno Quaresma 7bb0061804 chore(site): remove workspace build machine (#9813) 2023-09-22 16:12:25 -03:00
Muhammad Atif Ali df0c597843 docs: update VS Code Web docs (#9811)
* docs: update VS Code Web docs

* add back folder
2023-09-22 18:49:20 +00:00
Colin Adler cc009fe121 ci: increase timeout for template build jobs (#9829) 2023-09-22 13:13:50 -05:00
Ammar Bandukwala 733171a93b revert: "ci: cache datadog-ci (#9702)" (#9828)
Original commit changeset: b104e0ec0c
2023-09-22 17:31:25 +00:00
Michael Smith c201fc2538 revert: remove localStorage sync for search params (#9827) 2023-09-22 12:43:08 -04:00
Bruno Quaresma f6ee08d100 chore(site): replace create user machine by react-query (#9810) 2023-09-22 13:28:56 -03:00
Jon Ayers 9216725698 chore: add alpha badges to workspace cleanup fields (#9802) 2023-09-22 10:41:17 -05:00
Cian Johnston 8d8402da00 fix(coderd/database): avoid clobbering workspace build state (#9826)
Fixes #9823.

- Decomposes UpdateWorkspaceBuildByID into UpdateWorkspaceBuildProvisionerStateByID and UpdateWorkspaceBuildDeadlineByID.
- Replaces existing invocations of UpdateWorkspaceBuildByID with the newer queries where applicable.
- Modifies GetActiveWorkspaceBuildsByTemplateID to not return incomplete workspace builds.
2023-09-22 16:22:07 +01:00
Cian Johnston a1f3a6b606 refactor(scaletest/terraform): break up infra creation and k8s resource provisioning (#9824)
Breaks up scaletest/terraform into {infra, k8s}.
2023-09-22 15:55:47 +01:00
Michael Smith 84999cb33d feat: add empty state for SSO auth methods (#9818)
* fix: remove needless undefined checks

* refactor: clean up button markup

* refactor: restrict access to full auth in oidc functions

* feat: add empty SSO state
2023-09-22 09:38:49 -04:00
Spike Curtis e9077f3bd2 fix: use AlwaysEnable for licenses with all features (#9808)
* fix: use AlwaysEnable for licenses with all features

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

* use dbtime.Now() intead of time.Now()

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-22 05:02:28 +00:00
Dean Sheather 94a0612cd2 chore: update tailscale (#9817) 2023-09-22 07:21:38 +10:00
Colin Adler c900b5f8df feat: add single tailnet support to pgcoord (#9351) 2023-09-21 14:30:48 -05:00
Colin Adler fbad06f406 chore: bump wgtunnel (#9805) 2023-09-21 13:33:13 -05:00
Michael Smith 91a04c0132 chore: enhance tests for TemplateSchedulePage (#9801)
* chore: Add benchmark logs to test

* chore: Remove benchmark logic

* chore: add hard cutoff for waitFor calls

* refactor: clean up waitFor cut-off logic

* chore: add assertion that submit button is not disabled

* chore: Remove disabled check at the start of the test

* fix: extend cutoff for waitFor config
2023-09-21 14:25:26 -04:00
Muhammad Atif Ali 201a6c0c79 chore: remove extra condition from pr-deploy.yaml (#9788) 2023-09-21 17:58:46 +03:00
Bruno Quaresma 801c6c994b chore(site): replace setup machine by react-query (#9809) 2023-09-21 11:21:49 -03:00
Spike Curtis 866ba8ede5 fix: call agent directly in cli tests (#9789)
* fix: call agent directly in cli tests

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

* log verbose in TestDERPHeaders

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-21 13:30:24 +04:00
Muhammad Atif Ali fa858531a8 feat: add nomad template (#9786) 2023-09-21 08:54:56 +00:00
Michael Smith b742661abd feat: make workspace search bar remember text (#9759)
* minor: Add useEffectEvent polyfill

* chore: update filter to have better callback support

* docs: Clean up comments

* fix: add localStorage to useWorkspacesFilter

* refactor: Centralize stable useSearchParams

* refactor: clean up filter to be fully pure on mount

* chore: add tests for useEffectEvent

* wip: commit progress for searchbar fix

* chore: clean up WorkspacesPage

* fix: add logic for syncing queries with search params

* chore: Rename initialValue to fallbackFilter

* chore: Remove todo comment

* refactor: update code to use useEffectEvent

* docs: clean up comments for clarity

* fix: update url check to use regex
2023-09-20 16:44:19 -04:00
Bruno Quaresma 92a90eb9ae test(site): fix terminal page test flakiness (#9798) 2023-09-20 15:19:27 -03:00
Bruno Quaresma 1cd0bea86e chore: make workspace batch actions enabled by default (#9797) 2023-09-20 14:10:01 -03:00
Eric Paulsen fae8a470df fix(cli): display pasted session token (#9710) 2023-09-20 12:41:59 -04:00
Steven Masley f89b68056d chore: add debug information to wsproxy errors (#9683)
* chore: add debug information to wsproxy errors
* Use codersdk.ReadBodyAsError
2023-09-20 10:05:14 -05:00
Cian Johnston ae1896f2dc chore(docs): replace numbering with bullets in admin/encryption.md (#9792) 2023-09-20 15:15:39 +01:00
Marcin Tojek 8e012e4e1a test(site): workaround for reattached xterm-rows (#9790) 2023-09-20 14:25:30 +02:00
Steven Masley a18bf73131 chore: display warnings on app share failure (#9783)
* chore: add warnings to app share failure
Warnings only appear if the app is misconfigured to the deployment
2023-09-19 21:54:51 +00:00
Kayla Washburn 1fd1c654a9 fix: hide empty update message box (#9784) 2023-09-19 13:11:22 -06:00
Dean Sheather eda32659a8 chore: fix flake in tunnel (#9746) 2023-09-19 18:54:56 +00:00
Spike Curtis 70e481e7a5 fix: use terminal emulator that keeps state in ReconnectingPTY tests (#9765)
* Add more pty diagnostics for terminal parsing

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

* print escaped strings

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

* Only log on failure - heisenbug?

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

* use the terminal across matches to keep cursor & contents state

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

* Only log bytes if we're not expecting EOF

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-19 17:57:30 +00:00
Kayla Washburn 269b1c59f1 refactor: get rid of templateVariablesXService (#9763) 2023-09-19 11:54:14 -06:00
Mathias Fredriksson 530dd9d247 fix(coderd): subscribe to workspace when streaming agent logs to detect outdated build (#9729)
Fixes #9721
2023-09-19 20:02:27 +03:00
Bruno Quaresma 87d50f17a2 chore(site): refactor groups to use react-query (#9701) 2023-09-19 13:37:17 -03:00
Mathias Fredriksson 161a3cfa26 fix(coderd/batchstats): use debug log on query cancellation in flush (#9778)
Fixes #9772
2023-09-19 18:16:07 +03:00
Marcin Tojek ceb52ac24a fix: user should always belong to an organization (#9781) 2023-09-19 16:22:37 +02:00
Mathias Fredriksson d6089ae0ad fix(coderd/batchstats): use debug log on context cancellation in flush (#9777) 2023-09-19 13:19:39 +00:00
Bruno Quaresma 7bc98c296b refactor(site): do not display error details as message (#9755) 2023-09-19 09:54:59 -03:00
Bruno Quaresma e26bb2d91b chore(site): rollback remark-gfm version (#9774) 2023-09-19 09:43:11 -03:00
Bruno Quaresma ffa77ba6ff feat(site): show CLI flags and env variables for the options (#9757) 2023-09-19 09:34:04 -03:00
Dr. Pi3cH 94cccd0a01 fix: make sure fly_app name is lower case (#9771)
fly_app does not support uppercase. Coder allows uppercase for username/owner.
2023-09-19 12:30:52 +00:00
Eric Paulsen e9c183d0dc feat: add envFrom value to Helm chart (#9587)
* feat: add envFrom value to Helm chart

* add envUseClusterAccessURL

* add tests

---------

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-09-19 16:03:13 +04:00
Marcin Tojek ceeb9987a5 test(cli): ensure first option selected with is expected (#9770) 2023-09-19 13:55:51 +02:00
Marcin Tojek b0e3daa120 feat(coderd): support weekly aggregated insights (#9684) 2023-09-19 13:06:19 +02:00
Muhammad Atif Ali b358e3d558 chore: fix permission for kubeconfig (#9768) 2023-09-19 08:36:00 +00:00
Spike Curtis 375c70d141 feat: integrate Acquirer for provisioner jobs (#9717)
* chore: add Acquirer to provisionerdserver pkg

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

* code review improvements & fixes

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

* feat: integrate Acquirer for provisioner jobs

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

* Fix imports, whitespace

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

* provisionerdserver always closes; remove poll interval from playwright

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

* post jobs outside transactions

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

* graceful shutdown in test

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

* Mark AcquireJob deprecated

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

* Graceful shutdown on all provisionerd tests

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

* Deprecate, not remove CLI flags

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-19 10:25:57 +04:00
dependabot[bot] 6cf531bfef chore: bump typescript from 5.1.6 to 5.2.2 in /site (#9743)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-19 08:32:14 +03:00
dependabot[bot] 8fe4401e23 chore: bump github.com/klauspost/compress from 1.16.5 to 1.17.0 (#9735)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-19 05:30:04 +00:00
Cian Johnston aa8652c928 fix(dbtestutil): avoid truncating inserts that span multiple lines (#9756) 2023-09-18 19:46:22 +00:00
Kayla Washburn ed25f1449d refactor: use a line graph for DAUChart (#9758) 2023-09-18 12:28:30 -06:00
Kayla Washburn f85aa443dd feat: show version messages in version lists (#9708) 2023-09-18 11:17:07 -06:00
Jon Ayers 622442203d chore: fix test flake in TestProvisionerd (#9709) 2023-09-18 11:23:22 -05:00
Cian Johnston 45eadfc136 fix(cli): specify IgnoreErrors in slogtest options for scaletest cli tests (#9751)
* fix(cli): specify IgnoreErrors in slogtest options for scaletest cli tests
* bump test timeout
2023-09-18 16:39:28 +01:00
Asher 17f9991118 fix: reconnect terminal on non-modified key presses (#9686)
* Listen to web terminal keydown on capture

Instead of bubbling.  I think maybe what happens here is that xterm is
capturing key presses and preventing the event from bubbling?  So
setting the listener on the capture phase instead works around this.
Probably would also work to dipsose the terminal.

* Prevent issuing terminal reload when already reloading

I am not sure this actually causes any issues, but might as well.

* Ignore modifier keys for reconnecting terminal
2023-09-18 07:24:01 -08:00
Michael Smith 2caf7a7ceb fix: remove just-debounce-it (#9707)
* fix: Switch UserAutocomplete to useDebouncedFunction

* fix: switch UserOrGroupAutocomplete to useDebouncedFunction

* chore: remove just-debounce-it dependency

* docs: Clean up comments
2023-09-18 14:20:11 +00:00
Bruno Quaresma a2aff1f527 chore(site): replace xstate by react-query on update password (#9696) 2023-09-18 11:03:35 -03:00
Bruno Quaresma e74d8a7b21 chore(site): refactor starter templates to use react-query (#9697)
* Remove starter templates service

* Remove starter template service

* Remove template x service
2023-09-18 11:02:55 -03:00
dependabot[bot] e1bd6ddc25 chore: bump the otel group with 3 updates (#9731)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:55:38 +03:00
dependabot[bot] a989e8363b chore: bump google.golang.org/api from 0.140.0 to 0.141.0 (#9732)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:54:32 +03:00
dependabot[bot] 24bff1098d chore: bump gopkg.in/DataDog/dd-trace-go.v1 from 1.54.0 to 1.55.0 (#9734)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:53:40 +03:00
dependabot[bot] 1d8a4ed201 chore: bump jest-location-mock from 1.0.9 to 2.0.0 in /site (#9727)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 13:46:08 +00:00
Bruno Quaresma 2319486806 chore(site): replace deployment stats service by react-query (#9698) 2023-09-18 10:44:52 -03:00
dependabot[bot] 5a22f08f3f chore: bump @tanstack/react-query from 4.33.0 to 4.35.3 in /site (#9738)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:34:56 +03:00
dependabot[bot] d326f1b10c chore: bump remark-gfm from 3.0.1 to 4.0.0 in /site (#9726)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:32:57 +03:00
dependabot[bot] 972425e3d4 chore: bump @playwright/test from 1.37.1 to 1.38.0 in /site (#9739)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:32:42 +03:00
dependabot[bot] b76a430d22 chore: bump github.com/valyala/fasthttp from 1.49.0 to 1.50.0 (#9736)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:31:54 +03:00
dependabot[bot] ea93b4bbe4 chore: bump react-icons from 4.10.1 to 4.11.0 in /offlinedocs (#9740)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:31:48 +03:00
dependabot[bot] bd3f2f8c10 chore: bump eslint from 8.48.0 to 8.49.0 in /offlinedocs (#9742)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:31:16 +03:00
dependabot[bot] 010a13c654 chore: bump @testing-library/user-event from 14.4.3 to 14.5.1 in /site (#9730)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:24:05 +03:00
dependabot[bot] 9c8140270a chore: bump the react group in /site with 1 update (#9723)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 16:23:35 +03:00
dependabot[bot] c58e5bf09a chore: bump the eslint group in /site with 1 update (#9725)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 11:41:20 +00:00
Muhammad Atif Ali 3ed65de82e chore: increase dependabot open pr limit for site (#9728) 2023-09-18 11:24:49 +00:00
dependabot[bot] eb72866a29 ci: bump the github-actions group with 2 updates (#9722)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 11:15:56 +00:00
Cian Johnston 1df7589105 feat(coderd/database/dbtestutil): add ability to dump database on failure (#9704)
Adds dbtestutil.DumpOnFailure() to allow dumping the entire test database contents upon test failure.
This does nothing for dbfake currently.
2023-09-18 11:50:15 +01:00
Muhammad Atif Ali e6865e0df5 ci: remove example templates readme from docs filter (#9720) 2023-09-18 10:38:57 +00:00
Cian Johnston 9bcff30dee fix(coderd/database): migrate workspaces.last_used_at to timestamptz (#9699) 2023-09-18 11:07:54 +01:00
Cian Johnston 1f5eb088b5 fix(examples): fix typo in examples.gen.json (#9718) 2023-09-18 09:09:30 +00:00
Cian Johnston 653488e8ee fix(coderd): emit CollectedAt as UTC in convertWorkspaceAgentMetadata (#9700) 2023-09-18 09:17:18 +01:00
Ben Potter 5de5d20808 fix: remove broken fly.io template from starter templates (#9711)
Co-authored-by: Atif Ali <atif@coder.com>
2023-09-17 20:13:36 +03:00
sharkymark b2f84668c8 docs: document display_apps feature to hide/show built-in coder_app resources (#9714)
* docs: display_apps feature to hide/show terminal, vscode desktop, port-forwarding, etc.

* Update docs/templates/index.md

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

* Update docs/templates/index.md

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

---------

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-09-17 15:13:56 +00:00
kpoxo6op ab08b2c3e4 fix typo in README.md (#9715)
typo
2023-09-17 07:07:13 -05:00
Michael Smith fcc8b9ec92 fix: prevent workspace search bar text from getting garbled (#9703)
* chore: Reorganize hook calls for useWorkspacesFilter

* refactor: Clean up some filter logic

* refactor: Create debounce utility hooks

* docs: Clean up comments for clarity

* fix: Update focus logic to apply for any inner focus

* fix: Add onBlur behavior for state syncs

* chore: Add progress for debounce test

* chore: Finish tests for debounce hooks

* docs: Add file description and warning
2023-09-15 15:55:59 -04:00
Ammar Bandukwala b104e0ec0c ci: cache datadog-ci (#9702) 2023-09-15 19:22:38 +00:00
Kayla Washburn 9e053ce220 feat: show update messages on workspace page (#9705) 2023-09-15 13:09:29 -06:00
Kayla Washburn efe804498b feat: add quiet hours settings page (#9676) 2023-09-15 11:14:33 -06:00
Cian Johnston 72dff7f188 fix(enterprise/dbcrypt): do not skip deleted users when encrypting or deleting (#9694)
- Broadens scope of data generation in TestServerDBCrypt over all user login types, statuses, and deletion status.
- Adds support for specifying user status / user deletion status in dbgen
- Adds more comprehensive logging in TestServerDBCrypt upon test failure (to be generalized and expanded upon in a follow-up)
- Adds AllUserIDs query, updates dbcrypt to use this instead of GetUsers.
2023-09-15 15:09:40 +01:00
Mathias Fredriksson bc97eaa41b feat(scaletest): add scaletest-runner template (#9662)
Closes #9571
2023-09-15 13:23:37 +00:00
Marcin Tojek d0d64bbdca refactor: define insights interval (#9693) 2023-09-15 12:01:00 +00:00
Cian Johnston 65db7a71b7 feat(coderd/database/dbtestutil): set default database timezone to non-UTC in unit tests (#9672)
- Adds dbtestutil.WithTimezone(tz) to allow setting the timezone for a test database.
- Modifies our test database setup code to pick a consistently weird timezone for the database.
- Adds the facility randtz.Name() to pick a random timezone which is consistent across subtests (via sync.Once).
- Adds a linter rule to warn against setting the test database timezone to UTC.
2023-09-15 09:01:32 +01:00
Ammar Bandukwala 281faf9ccd ci: upgrade runners (#9689)
Per DataDog, I've doubled the resources of our slowest jobs.
2023-09-14 20:20:39 -05:00
Ammar Bandukwala b63dfe7b75 perf(cli): optimize CPU consumption of help pages (#9607)
This change reduces the CPU consumption of --help by ~50%.

Also, this change removes ANSI escape codes from our golden files. I
don't think those were worth the inability to parallelize golden file tests and
global state fragility.
2023-09-14 19:48:29 -05:00
Jon Ayers 7311ffbd9d feat: implement agent process management (#9461)
- An opt-in feature has been added to the agent to allow
   deprioritizing non coder-related processes for CPU by setting their
   niceness level to 10.
- Opting in to the feature requires setting CODER_PROC_PRIO_MGMT to a non-empty value.
2023-09-14 19:45:05 -05:00
Bruno Quaresma 79d4179123 chore(site): migrate a few services to react-query used in the DashboardProvider (#9667) 2023-09-14 19:35:03 -03:00
Bruno Quaresma 3b088a5cb8 chore(site): refactor deployment values service to react-query (#9669) 2023-09-14 18:49:23 -03:00
Marcin Tojek 225cf8acec chore: print page content on failed promise (#9681) 2023-09-14 13:30:46 +02:00
Marcin Tojek dcad0a437c fix: wait for build job (#9680) 2023-09-14 11:20:09 +02:00
Cian Johnston 8b6e2862fd refactor(coderd): collapse activityBumpWorkspace into a single query (#9652)
* Adds unit-style tests for activityBumpWorkspace
* Ports logic of activityBumpWorkspace to a SQL query
* Updates activityBumpWorkspace to call above query
2023-09-14 09:09:51 +01:00
Colin Adler 38560dd922 chore: remove coder trace telemetry (#9677) 2023-09-14 02:20:28 -04:00
Bruno Quaresma e7b0181519 feat(site): add support to .sh and .tpl files (#9674) 2023-09-13 16:27:02 -03:00
Steven Masley e0e6d7c9a6 fix: case insensitve agent ssh session env var (#9675) 2023-09-13 14:18:00 -05:00
Steven Masley 0e4d6896e3 test: fix cleanup order on provisioner daemon work dir (#9668)
* test: fix cleanup order on provisioner daemon work dir

* Reduce the test race condition
2023-09-13 13:13:08 -05:00
Kayla Washburn 53a985ff11 refactor: clean up workspace and template settings (#9654) 2023-09-13 11:55:27 -06:00
dependabot[bot] 6c409b8872 chore: bump chromatic from 6.24.1 to 7.1.0 in /site (#9629)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.24.1 to 7.1.0.
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.24.1...v7.1.0)

---
updated-dependencies:
- dependency-name: chromatic
  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-09-13 14:49:54 -03:00
Jon Ayers 3dc1e22d56 feat: add template_id and template_name to workspace data source (#9655) 2023-09-13 11:09:08 -05:00
Marcin Tojek d171b3611b fix: flaky: TestDeleteTemplate/NoWorkspaces (#9666) 2023-09-13 17:05:08 +02:00
Cian Johnston 3be783b319 fix(scaletest/workspacetraffic): wait for non-zero metrics before cancelling in TestRun (#9663) 2023-09-13 15:54:56 +01:00
Muhammad Atif Ali 254f459d69 chore(dogfood): add a coder_app for JetBrains gateway IDEs (#9644) 2023-09-13 17:49:36 +03:00
Marcin Tojek a229855e71 test(site): e2e: improve webTerminal test (#9659) 2023-09-13 16:18:10 +02:00
Spike Curtis 4ebf490d97 feat: add Acquirer to provisionerdserver pkg (#9658)
* chore: add Acquirer to provisionerdserver pkg

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

* code review improvements & fixes

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-13 16:36:43 +04:00
Cian Johnston 2ac532982d feat(coderd/database): generate foreign key constraints and add database.IsForeignKeyViolation (#9657)
* feat(coderd/database): generate foreign key constraints, add database.IsForeignKeyViolation

* address PR comments
2023-09-13 13:28:46 +01:00
Cian Johnston a6f7f71808 chore(docs/admin): update encryption.md (#9660) 2023-09-13 12:56:20 +01:00
Marcin Tojek e2579e9440 test: fix flaky TestPatchTemplateMeta/Modified (#9656) 2023-09-13 11:34:53 +02:00
Steven Masley 18c34ee456 chore: support external types in typescript codegen (#9633)
* chore: support external types in typescript codegen
* fix enums on external packages
* Support clibase.struct
* Add regexp
* Make gen with updated generator
2023-09-12 18:21:09 -05:00
Bruno Quaresma 641bf272ed fix(site): fix renderer error (#9653) 2023-09-12 19:59:09 -03:00
Kayla Washburn 0726eb56bb fix: update autostart/autostop text (#9650) 2023-09-12 15:29:39 -06:00
Bruno Quaresma b3c98395ab chore(site): use react-query to fetch roles (#9630) 2023-09-12 15:07:56 -03:00
Bruno Quaresma b33cb0ef97 chore(site): refactor workspace quota to use react-query instead of XState (#9626) 2023-09-12 14:58:35 -03:00
Julio 64bc317cd4 Doc - Remove sysbox 16 pods max. (#9646) 2023-09-12 17:49:51 +00:00
Bruno Quaresma 5ca8c4287f chore(site): move ssh keys management to react-query (#9625) 2023-09-12 14:40:07 -03:00
Bruno Quaresma 6db89b0372 chore(site): move templates fetching to react-query (#9622) 2023-09-12 14:09:16 -03:00
Bruno Quaresma b7550bfda5 chore(site): remove unecessary types and move types to where they are used (#9621) 2023-09-12 13:54:05 -03:00
Marcin Tojek 0e28397c82 fix: use CRC32 to shorten app subdomain (#9645) 2023-09-12 17:11:45 +02:00
Marcin Tojek 898971b329 refactor: generate application URL on backend side (#9618) 2023-09-12 15:25:10 +02:00
dependabot[bot] 228d1cf361 chore: bump the eslint group in /site with 3 updates (#9639)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-12 10:25:04 +00:00
dependabot[bot] 531e1334af chore: bump monaco-editor from 0.41.0 to 0.43.0 in /site (#9642)
Bumps [monaco-editor](https://github.com/microsoft/monaco-editor) from 0.41.0 to 0.43.0.
- [Changelog](https://github.com/microsoft/monaco-editor/blob/main/CHANGELOG.md)
- [Commits](https://github.com/microsoft/monaco-editor/compare/v0.41.0...v0.43.0)

---
updated-dependencies:
- dependency-name: monaco-editor
  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-09-12 12:56:43 +03:00
dependabot[bot] 7f126758a5 chore: bump jest-websocket-mock from 2.4.0 to 2.5.0 in /site (#9641)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-12 09:24:10 +00:00
dependabot[bot] d49bc2003b chore: bump msw from 1.2.2 to 1.3.0 in /site (#9640)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-12 12:16:16 +03:00
dependabot[bot] 8b08a78168 chore: bump google.golang.org/api from 0.138.0 to 0.140.0 (#9636)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-12 08:45:29 +00:00
Muhammad Atif Ali f1f522a9a7 revert: "chore: bump the eslint group in /site with 3 updates" (#9638) 2023-09-12 11:26:51 +03:00
dependabot[bot] 2c19995712 ci: bump the github-actions group with 2 updates (#9620)
Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [crate-ci/typos](https://github.com/crate-ci/typos).


Updates `actions/checkout` from 3 to 4
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

Updates `crate-ci/typos` from 1.16.10 to 1.16.11
- [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.16.10...v1.16.11)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-12 10:22:22 +03:00
dependabot[bot] e85981713d chore: bump the xterm group in /site with 6 updates (#9627)
Bumps the xterm group in /site with 6 updates:

| Package | From | To |
| --- | --- | --- |
| [xterm](https://github.com/xtermjs/xterm.js) | `5.2.1` | `5.3.0` |
| [xterm-addon-canvas](https://github.com/xtermjs/xterm.js) | `0.4.0` | `0.5.0` |
| [xterm-addon-fit](https://github.com/xtermjs/xterm.js) | `0.7.0` | `0.8.0` |
| [xterm-addon-unicode11](https://github.com/xtermjs/xterm.js) | `0.5.0` | `0.6.0` |
| [xterm-addon-web-links](https://github.com/xtermjs/xterm.js) | `0.8.0` | `0.9.0` |
| [xterm-addon-webgl](https://github.com/xtermjs/xterm.js) | `0.15.0` | `0.16.0` |


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

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

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

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

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

Updates `xterm-addon-webgl` from 0.15.0 to 0.16.0
- [Release notes](https://github.com/xtermjs/xterm.js/releases)
- [Commits](https://github.com/xtermjs/xterm.js/compare/0.15...0.16)

---
updated-dependencies:
- dependency-name: xterm
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: xterm
- dependency-name: xterm-addon-canvas
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: xterm
- dependency-name: xterm-addon-fit
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: xterm
- dependency-name: xterm-addon-unicode11
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: xterm
- dependency-name: xterm-addon-web-links
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: xterm
- dependency-name: xterm-addon-webgl
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: xterm
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-12 10:21:59 +03:00
dependabot[bot] 140a7d2de2 chore: bump the eslint group in /site with 3 updates (#9628)
Bumps the eslint group in /site with 3 updates: [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin), [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) and [eslint](https://github.com/eslint/eslint).


Updates `@typescript-eslint/eslint-plugin` from 6.5.0 to 6.7.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/v6.7.0/packages/eslint-plugin)

Updates `@typescript-eslint/parser` from 6.5.0 to 6.7.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/v6.7.0/packages/parser)

Updates `eslint` from 8.48.0 to 8.49.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.48.0...v8.49.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-12 10:21:47 +03:00
dependabot[bot] 3e0969004d chore: bump ts-proto from 1.156.0 to 1.157.0 in /site (#9631)
Bumps [ts-proto](https://github.com/stephenh/ts-proto) from 1.156.0 to 1.157.0.
- [Release notes](https://github.com/stephenh/ts-proto/releases)
- [Changelog](https://github.com/stephenh/ts-proto/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stephenh/ts-proto/compare/v1.156.0...v1.157.0)

---
updated-dependencies:
- dependency-name: ts-proto
  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-09-12 10:21:09 +03:00
dependabot[bot] abbd780373 chore: bump cronstrue from 2.31.0 to 2.32.0 in /site (#9632)
Bumps [cronstrue](https://github.com/bradymholt/cronstrue) from 2.31.0 to 2.32.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.31.0...v2.32.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>
2023-09-12 10:20:54 +03:00
dependabot[bot] d4bdb96883 chore: bump google.golang.org/grpc from 1.57.0 to 1.58.0 (#9563)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.57.0 to 1.58.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.57.0...v1.58.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-09-12 10:18:21 +03:00
Kayla Washburn 13acf5976c chore: remove i18next (#9608) 2023-09-11 11:17:58 -06:00
Marcin Tojek 1a1c230534 fix(docs): skip >> character (#9616) 2023-09-11 12:23:40 +02:00
Marcin Tojek 67fe3ae8d6 feat: clean stale provisioner files (#9545) 2023-09-11 07:37:14 +00:00
sharkymark d055f93706 Docs coder apps web ides (#9613)
* chore: document external URLs, refresh web IDE images

* chore: coder_app external URL, updated images, file browser

* Update docs/ides/web-ides.md

---------

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-09-10 20:26:59 +00:00
Muhammad Atif Ali 84ede326e8 docs: add VS Code Web to web-ides (#9591) 2023-09-10 02:32:41 +00:00
Ammar Bandukwala f703a5b34e chore(cli): lighten flags on help page (#9606) 2023-09-08 13:43:56 -05:00
Ammar Bandukwala e361f1107b feat(cli): colorize help page (#9589) 2023-09-08 18:21:33 +00:00
Bruno Quaresma 11404af9ca chore(site): update files to use a more standard naming (#9605) 2023-09-08 15:14:41 -03:00
Bruno Quaresma 554ddb11cd chore(site): refactor stories and test from page components (#9603)
* Refactor AuditPage

* Refactor CliAuthPageView stories

* Refactor CreateTemplateForm stories

* Refactor CreateUserPage test

* Refactor CreateWorkspacePage tests

* Fix stories name

* Refactor AppereancePageView stories

* Refactor GitAuthSettingsPageView stories

* Refactor NetworkSettingsPageView stories

* Refactor SecuritySettingsPageView stories

* Refactor UserAuthSettingsPageView stories

* Refactor GroupsPage stories

* Refactor LoginPage tests

* Refactor SetupPage stories

* Refactor StarterTemplatePageView stories

* Refactor StarterTemplatesPage tests

* Refactor TemplatePage tests

* RefactorTemplateSettingsPage tests

* Refactor TemplatesPage tests

* Flat TemplateVersionEditorPage

* Refactor TemplateVersionPage stories

* Refactor UserSettingsPage stories

* Refactor UsersPage stories

* Simplify IndexPage

* Refactor WorkspaceSettingsPage stories

* Refactor WorkspacePage stories

* Refactor Conditionals stories

* Fix typo

* Fix imports

* Fix ChooseOne story

* Fix UserAuthSettingsPageView stories
2023-09-08 15:14:13 -03:00
David Morcillo 9e5a59e222 Update upgrade.md (#9569)
Fix wrong docker-compose update instructions.
2023-09-08 10:38:35 -04:00
Marcin Tojek ad23075e1b refactor: build application URL (#9601)
* refactor: build application URL

* fix
2023-09-08 14:01:57 +00:00
Cian Johnston 392b11272b fixup! fix(scripts): modify logic for determining terraform arch (#9595) (#9596) 2023-09-08 11:07:57 +00:00
Cian Johnston a3a16a1586 fix(scripts): modify logic for determining terraform arch (#9595)
Commit fb3616c used a build-arg to set the desired terrafomr
architeture to fetch. This is set in build_docker.sh but not
when building using depot.dev. Baking the logic into the
Dockerfile instead.
2023-09-08 10:47:51 +00:00
Spike Curtis 8d7eb1728c fix: stop inserting provisioner daemons into the database (#9108)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-08 10:37:36 +00:00
Cian Johnston fb3616c37e fix(scripts): wget terraform directly from releases.hashicorp.com (#9594) 2023-09-08 10:02:18 +00:00
Spike Curtis 11b6068112 feat: add support for networked provisioners (#9593)
* Refactor provisionerd to use interface to connect to provisioners

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

* feat: add support for networked provisioners

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

* fix token length and linting

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-08 09:53:48 +00:00
Kayla Washburn 8b51a2f3c5 docs: mention the need for permission to read email addresses (#9588) 2023-09-07 16:40:22 -06:00
Ammar Bandukwala dd97fe2bce chore(cli): replace lipgloss with coder/pretty (#9564)
This change will improve over CLI performance and "snappiness" as well as
substantially reduce our test times. Preliminary benchmarks show
`coder server --help` times cut from 300ms to 120ms on my dogfood
instance.

The inefficiency of lipgloss disproportionately impacts our system, as all help
text for every command is generated whenever any command is invoked.

The `pretty` API could clean up a lot of the code (e.g., by replacing
complex string concatenations with Printf), but this commit is too
expansive as is so that work will be done in a follow up.
2023-09-07 16:28:22 -05:00
Kayla Washburn 8421f56137 refactor: bring back updated install.sh with patches (#9583) 2023-09-07 21:17:16 +00:00
Eric Paulsen ccda1c5c7d fix: rm tf provider versions in examples/ (#9586) 2023-09-07 18:53:23 +00:00
Cian Johnston 0306631518 fix(docs): fix broken link (#9585) 2023-09-07 18:36:26 +00:00
Bruno Quaresma 869d040cc6 chore(site): refactor stories and tests from components directory (#9578)
* Refactor Alert

* Refactor Avatar and its stories

* Refactor AvatarData and its stories

* Refactor CodeExample and its tests

* Refactor ServiceBanner stories

* Refactor Navbar and its tests

* Refactor ServiceBanner stories

* Refactor LicenseBannerView stories

* Refactor DeploymentBannerView stories

* Extract optionValue into a module

* Refactor DeleteDialog stories

* Refactor ConfirmDialog tests

* Refactor EmptyState tests

* Flat ErrorBoundaryState and refactor stories

* Refactor Expander stories

* Refactor FormFooter stories

* Refactor FullPageForm stories

* Refactor EnterpriseSnackbar stories

* Refactor GroupAvatar stories

* Refactor HelpTooltip stories and remove index

* Remove unecessary types module from IconField

* Refactor LoadingButton stories

* Refactor Margins stories

* Refactor Markdown stories

* Refactor PageHeader stories

* Refactor PageButton tests

* Refactor Pill stories

* Refactor Resources stories

* Refactor RichParameterInput stories and flat MultiTextField

* Remove unecessary Stack story

* Refactor TableRowMenu stories

* Refactor TemplateLayout stories

* Refactor Typography props

* Refactor UserAutocomplete

* Refactor WorkspaceBuildLogs components and tests

* Refactor WorkspaceStatusBadge stories

* Fix wrong imports

* Remove Example.args pattern

* Fix wrong import

* Refactor EmptyState stories

* Refactor HelpTooltip stories

* Remove not valid ErrorAlert story

* Fix AvatarData story

* Add border back to CodeExample

* Fix Navbar story

* Fix AgentRow proxy in the stories
2023-09-07 18:38:28 +02:00
Kayla Washburn 4f142fa959 feat: add minimal frontend for creating workspaces from specific template versions (#9475) 2023-09-07 10:33:42 -06:00
Mathias Fredriksson 40fcabfa0e chore(go.mod): update github.com/hashicorp/terraform-json to main (#9582) 2023-09-07 16:06:28 +00:00
Cian Johnston 7d7c84bb4d feat(coderd): connect dbcrypt package implementation (#9523)
See also: https://github.com/coder/coder/pull/9522

- Adds commands `server dbcrypt {rotate,decrypt,delete}` to re-encrypt, decrypt, or delete encrypted data, respectively.
- Plumbs through dbcrypt in enterprise/coderd (including unit tests).
- Adds documentation in admin/encryption.md.

This enables dbcrypt by default, but the feature is soft-enforced on supplying external token encryption keys. Without specifying any keys, encryption/decryption is a no-op.
2023-09-07 15:49:49 +01:00
Mathias Fredriksson ed7f682fd1 chore(go.mod): update github.com/hashicorp/terraform-json to v0.17.1 (#9570) 2023-09-07 14:55:39 +03:00
dependabot[bot] 5a6f6e5679 chore: bump the golang-x group with 4 updates (#9562)
Bumps the golang-x group with 4 updates: [golang.org/x/crypto](https://github.com/golang/crypto), [golang.org/x/net](https://github.com/golang/net), [golang.org/x/oauth2](https://github.com/golang/oauth2) and [golang.org/x/tools](https://github.com/golang/tools).


Updates `golang.org/x/crypto` from 0.12.0 to 0.13.0
- [Commits](https://github.com/golang/crypto/compare/v0.12.0...v0.13.0)

Updates `golang.org/x/net` from 0.14.0 to 0.15.0
- [Commits](https://github.com/golang/net/compare/v0.14.0...v0.15.0)

Updates `golang.org/x/oauth2` from 0.11.0 to 0.12.0
- [Commits](https://github.com/golang/oauth2/compare/v0.11.0...v0.12.0)

Updates `golang.org/x/tools` from 0.12.0 to 0.13.0
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.12.0...v0.13.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-07 08:26:40 +00:00
Kayla Washburn fd565e0e0b chore: enable test-2e (#9567) 2023-09-07 05:49:40 +00:00
Kayla Washburn bfff88d2d3 revert: improve flag interpretation for install.sh (#9566) 2023-09-07 05:29:52 +00:00
Muhammad Atif Ali 2dae60038a fix(docs): fix manifest of gcp docs (#9559) 2023-09-06 22:21:00 +03:00
Kayla Washburn fd8a86808f chore: add #9555 to .git-blame-ignore-revs (#9557) 2023-09-06 13:10:58 -06:00
Kayla Washburn 988c9af015 chore: format code with semicolons when using prettier (#9555) 2023-09-06 12:59:26 -06:00
Muhammad Atif Ali bef38b8413 docs: update google-cloud-platform docs to use our marketplace image (#9549) 2023-09-06 21:58:14 +03:00
Kayla Washburn 4ed8dd0d6c refactor: improve flag interpretation for install.sh (#9554) 2023-09-06 12:57:28 -06:00
Bruno Quaresma b15bfa41c2 chore(site): move components close to where they are used (#9552)
* Move AppLink

* Move AuditLogRow

* Move UserDropdown

* Move BuildsTable

* Remove CodeBlock

* Move CreateUserForm

* Move DeploymentBanner

* Move ResetPassworDialog

* Move EditRolesButton

* Move EnterpriseSnackbar

* Move GitAuth

* Move LicenseBanner

* Move Logs

* Move MultiTextField

* Move Navbar

* Remove PasswordField

* Move RuntimeErrorState

* Remove Section

* Move SectionAction

* Move ServiceBanner

* Move SettingsAccountForm

* Move LicenseCard

* Move SettingsSecurityForm

* Move SignInForm

* Remove TabPanel and TabSidebar

* Move TemplateStats and TemplateVariableField

* Move TemplateEditor

* Move TerminalLink

* Move SSH Button

* Move many tooltips

* Move UsersTable

* Move VersionsTable

* Move VSCodeDesktopButton

* Remove WarningAlert

* Move Workspace

* Move WorkspaceActions

* Move WorkspaceBuildProgress

* Move WorkspaceDeletedBanner

* Move WorkspaceScheduleForm

* Move WorkspaceSection

* Move WorkspaceStats

* Fix imports

* Flat CreateUserForm

* Flat GitAuth

* Transform WorkspaceSection into ChartSection

* Flat AccountForm

* Flat ConfirmDeleteDialog

* Flat ResetPasswordDialog

* Flat BuildsTable
2023-09-06 18:06:08 +00:00
Kayla Washburn 75139d1d06 refactor(site): update versions table design (#9540) 2023-09-06 08:31:07 -06:00
Ben Potter 1bcc4152af chore: avoid formatting changelogs (#9548) 2023-09-06 14:26:50 +00:00
Eric Paulsen 4ec2fea66b docs: fix psk secret cmd (#9524) 2023-09-06 09:04:44 -04:00
Cian Johnston 7918e65510 feat(coderd): add dbcrypt package (#9522)
- Adds package enterprise/dbcrypt to implement database encryption/decryption
- Adds table dbcrypt_keys and associated queries
- Adds columns oauth_access_token_key_id and oauth_refresh_token_key_id
  to tables git_auth_links and user_links

Co-authored-by: Kyle Carberry <kyle@coder.com>
2023-09-06 12:06:26 +01:00
Spike Curtis 3bd0fd396c feat: add boringcrypto builds for linux (#9543)
This reverts commit da0ef92f77.
2023-09-06 12:48:27 +04:00
Kayla Washburn 2849895832 fix: use $coder_version instead of hardcoded version in release script (#9539) 2023-09-05 17:30:54 -06:00
Ben Potter 66019ef70a docs: add v2.1.6 changelog (#9538) 2023-09-05 21:44:12 +00:00
Alexis Emerson d85c354507 docs: add CODER_TLS_ADDRESS to documentation for TLS setup (#9503)
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-09-05 19:07:56 +00:00
Steven Masley 630d125286 chore: fix typo in OpenID on cli help (#9535) 2023-09-05 18:37:21 +00:00
Muhammad Atif Ali 2487e64d25 fix(docs): fix broken markdown links (#9534) 2023-09-05 18:12:04 +00:00
Kyle Carberry 82e238b0c6 chore: exclude generated files from vscode search by default (#9530)
Anyone can feel free to revert some of these, but they were constantly
annoying when searching for symbols in our code.
2023-09-05 15:05:46 +00:00
Steven Masley 58f7071569 fix: make 'NoRefresh' honor unlimited tokens in gitauth (#9472)
* chore: fix NoRefresh to honor unlimited tokens
* improve testing coverage of gitauth
* refactor rest of gitauth tests
2023-09-05 09:08:04 -05:00
Kyle Carberry da0ef92f77 Revert "feat: add boringcrypto builds for linux (#9528)" (#9529)
This reverts commit 79cd6047dc.
2023-09-05 08:37:07 -05:00
Spike Curtis 79cd6047dc feat: add boringcrypto builds for linux (#9528)
* feat: add boringcrypto builds for linux

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

* strip debug symbols, add BoringCryto to buildinfo

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

* Fix TestVersion

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-05 13:12:38 +00:00
dependabot[bot] ce08c47b8a chore: bump github.com/gohugoio/hugo from 0.117.0 to 0.118.2 (#9516)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.117.0 to 0.118.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.117.0...v0.118.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>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-05 11:52:26 +03:00
Mathias Fredriksson 76ab22f539 chore(coderd/database): introduce compile-time guard against import in slim build (#9521)
This change introduces a compile-time error when `coderd/database` is
imported into the slim build. This is to guard against accidentally
growing the binary size via import.

Ref: #9380
2023-09-04 19:01:11 +00:00
Mathias Fredriksson adba421524 refactor(coderd/telemetry): move CLI telemetry to cli/telemetry (#9517)
This change removes an indirect import of `coderd/database` from the
slim binary.

No size change (yet).

Ref: #9380
2023-09-04 21:42:45 +03:00
Mathias Fredriksson b240799f47 refactor(cli): use codersdk for provisioner types (#9508)
This change removes one use of `coderd/database` from the slim binary
and more correctly uses codersdk instead of database or provisionerd
packages.

No size change (yet).

Ref: #9380
2023-09-04 21:42:15 +03:00
Mathias Fredriksson 39e3b049a5 refactor(coderd/healthcheck): move derp report to derphealth package (#9506)
This change helps remove one indirect use of coderd/database in the slim
CLI.

No size change (yet).

Ref: #9380
2023-09-04 21:41:50 +03:00
Mathias Fredriksson a1025f92af refactor(examples): pre-parse frontmatter via scripts/examplegen (#9514)
* refactor(examples): pre-parse frontmatter via scripts/examplegen

This removes 2 MB from the slim binary.

Ref: #9380
2023-09-04 20:15:29 +03:00
Mathias Fredriksson 6fc1f5276d refactor(coderd/httpapi): remove database, dbauthz and rbac imports (#9481)
Ref: #9380
2023-09-04 19:39:14 +03:00
Mathias Fredriksson d2115941b7 refactor(cli)!: remove reset-password from slim binary (#9520)
This is an alternative approach to #9519 and removes 2 MB instead of 1
MB (1.2 MB accounted for by embedded migration SQL files).

Combined with #9481, #9506, #9508, #9517, a total of 5 MB is removed.

Ref: #9380
2023-09-04 19:38:53 +03:00
Mathias Fredriksson ad23d33f28 refactor(coderd/schedule): move cron schedule to cron package (#9507)
This removes an indirect import of `coderd/database` from the CLI and
results in a logical separation between server related and generalized
schedule.

No size change (yet).

Ref: #9380
2023-09-04 16:48:25 +03:00
dependabot[bot] c31292abe8 ci: bump the github-actions group with 2 updates (#9509)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-04 16:29:56 +03:00
Muhammad Atif Ali 29b2eaa217 fix(cli/dotfiles): add an exception for .gitconfig (#9515)
* fix(cli/dotfiles): Only ignore .git directory 

Resolves #8306

* fix fmt

* add exception for .gitconfig

* Update dotfiles.go
2023-09-04 13:17:07 +00:00
Marcin Tojek aa94d89f97 test: improve E2E framework (#9469) 2023-09-04 14:46:48 +02:00
dependabot[bot] 91cb9c65f9 chore: bump github.com/hashicorp/hc-install from 0.5.2 to 0.6.0 (#9511)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-04 15:29:10 +03:00
dependabot[bot] c2be893b7f chore: bump github.com/open-policy-agent/opa from 0.55.0 to 0.56.0 (#9512)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-04 15:28:51 +03:00
dependabot[bot] c5714f2b47 chore: bump github.com/swaggo/swag from 1.8.6 to 1.16.2 (#9513)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-04 15:28:39 +03:00
dependabot[bot] cb5347bb12 chore: bump the golang-x group with 3 updates (#9510)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-04 15:27:03 +03:00
Bruno Quaresma b9f604c58d fix(site): fix workspace parameters update when having immutable parameters (#9500) 2023-09-03 21:56:25 -03:00
Ben Potter f5829d2be6 chore(dogfood): authenticate to coder CLI if unauthenticated (#9487) 2023-09-04 02:26:48 +03:00
Kyle Carberry 05439d2c1b fix: generate username with uuid to prevent collision (#9496)
See https://github.com/coder/coder/actions/runs/6052801777/job/16426982174
2023-09-03 18:02:28 +00:00
sharkymark 43ebf667f0 docs: explain why coder port-forward is more performant than dashboard and sshd (#9494) 2023-09-03 10:10:48 -05:00
Mathias Fredriksson 18c9f33dec chore: use tailscale extra small buildflags (#9490)
Ref: #9380
2023-09-01 19:14:56 +00:00
Mathias Fredriksson 27ab0d9a84 refactor(enterprise/cli): remove provisionerd from slim binary (#9488)
This change saves 8 MB in the slim binary.

Ref: #9380
2023-09-01 18:26:44 +00:00
Mathias Fredriksson 19d7da3d24 refactor(coderd/database): split Time and Now into dbtime package (#9482)
Ref: #9380
2023-09-01 16:50:12 +00:00
Mathias Fredriksson 702b064cac refactor: split coderd/gitauth into two, add cli/gitauth (#9479)
* refactor: split coderd/gitauth into two, add cli/gitauth

Ref: #9380
2023-09-01 15:41:22 +00:00
Mathias Fredriksson d8718c3818 chore: add ts_omit_aws tag to remove aws dependency pulled in by tailscale (#9486)
On Linux, this saves us 7 MB.

Ref: #9380
2023-09-01 18:37:49 +03:00
Mathias Fredriksson f1f9cb030d refactor(cli): avoid importing coderd in slim server (#9483)
This small change removes 11 MB from the slim binary size.

Ref: #9380
2023-09-01 13:32:21 +00:00
Marcin Tojek 5d7a77911e fix: use getProvisionerJobByIDNoLock (#9484) 2023-09-01 13:21:18 +00:00
Cian Johnston bc9fdd15f2 fix(enterprise/cli): correctly set default tags for PSK auth (#9436)
* provisionerd: unconditionally set tag scope to org for psk auth
* provisionerd: add unit tests for MutateTags
* cli: add some informational logging around provisionerd tags
* cli: respect CODER_VERBOSE when initializing logger
2023-09-01 10:37:09 +01:00
Colin Adler 8ee6178c66 chore(tailnet): fix MultiAgentConn mockgen (#9476) 2023-08-31 22:37:05 +00:00
Kayla Washburn eded7a4b88 feat: create a workspace from any template version (#9471) 2023-08-31 15:07:58 -06:00
Colin Adler 796a9754a9 feat(enterprise/audit): add user object to slog exporter (#9456) 2023-08-31 13:32:28 -05:00
Marcin Tojek 11d4b6f758 chore: move dormancy to enterprise package (#9468) 2023-08-31 17:59:53 +02:00
Marcin Tojek 7c4ce62a58 test(site): print agent logs (#9464) 2023-08-31 14:44:44 +02:00
Cian Johnston 22f31e721c fix(coderd/prometheusmetrics): close batcher to force flush before asserting agent stats (#9465) 2023-08-31 11:40:57 +01:00
Cian Johnston fd17857095 fix(cli): template pull tests: await template version job before exiting (#9430) 2023-08-31 11:40:24 +01:00
Spike Curtis ed50acaabf fix: don't log error on context cancel (#9463)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-31 12:08:18 +04:00
Muhammad Atif Ali 73976dd076 fix: fix aws_linux template (#9349) 2023-08-31 04:24:10 +03:00
dependabot[bot] 2aa66ad7c3 chore: bump monaco-editor from 0.40.0 to 0.41.0 in /site (#9458)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 02:23:32 +03:00
dependabot[bot] 723bba98ff chore: bump jest-canvas-mock from 2.4.0 to 2.5.2 in /site (#9460)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 02:22:54 +03:00
dependabot[bot] 83cee77de0 chore: bump cronstrue from 2.28.0 to 2.31.0 in /site (#9459)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 02:22:39 +03:00
dependabot[bot] f4affda554 chore: bump cron-parser from 4.7.0 to 4.9.0 in /site (#9455)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-30 23:13:48 +00:00
dependabot[bot] 03052c2e64 chore: bump @testing-library/jest-dom (#9375)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Atif Ali <atif@coder.com>
2023-08-30 23:02:01 +00:00
dependabot[bot] e8047838b3 chore: bump chart.js from 4.3.3 to 4.4.0 in /site (#9454)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-30 22:45:59 +00:00
dependabot[bot] 8841e23065 chore: bump the eslint group in /site with 7 updates (#9450)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Atif Ali <atif@coder.com>
2023-08-31 01:42:48 +03:00
dependabot[bot] c6f0d5a6e0 chore: bump axios from 1.3.4 to 1.5.0 in /site (#9452)
Bumps [axios](https://github.com/axios/axios) from 1.3.4 to 1.5.0.
- [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/v1.3.4...v1.5.0)

---
updated-dependencies:
- dependency-name: axios
  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-08-30 19:38:10 -03:00
dependabot[bot] a67bd2ce3b chore: bump @tanstack/react-query from 4.32.0 to 4.33.0 in /site (#9453)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 01:31:00 +03:00
Kayla Washburn 4c91146cb8 fix: hide OIDC and Github auth settings when they are disabled (#9447) 2023-08-30 15:56:18 -06:00
Ammar Bandukwala 8f3b4075c7 ci: enable nestif linter (#9363) 2023-08-30 21:50:43 +00:00
Bruno Quaresma d29696296f refactor(site): refactor rich parameter input and form initial data (#9440) 2023-08-30 18:42:36 -03:00
dependabot[bot] db93f17dab chore: bump eslint from 8.46.0 to 8.48.0 in /offlinedocs (#9366)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 00:31:11 +03:00
dependabot[bot] 6268904421 chore: bump the storybook group in /site with 7 updates (#9449)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 00:27:46 +03:00
Steven Masley e827278db7 feat: failed update refresh should redirect to login (#9442)
* chore: update refresh oauth token message
* chore: unauthorized -> forbidden for non authentication failures
* redirect to login on all 401 responses
* add unit test to verify 401 on expired refresh
2023-08-30 16:14:24 -05:00
dependabot[bot] b9fbc541c6 chore: bump framer-motion from 10.15.0 to 10.16.1 in /offlinedocs (#9369)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 00:14:02 +03:00
dependabot[bot] 2bc8ba251d chore: bump archiver from 5.3.1 to 6.0.0 in /offlinedocs (#9367)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 00:13:52 +03:00
dependabot[bot] 5b1da77291 chore: bump github.com/valyala/fasthttp from 1.48.0 to 1.49.0 (#9385)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 00:13:19 +03:00
dependabot[bot] e4543e0e14 chore: bump the otel group with 4 updates (#9413)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 00:12:42 +03:00
dependabot[bot] 2c1b92b1d2 chore: bump chromatic from 6.20.0 to 6.24.1 in /site (#9377)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 00:11:05 +03:00
dependabot[bot] bb478d4939 chore: bump @playwright/test from 1.36.0 to 1.37.1 in /site (#9378)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-31 00:10:31 +03:00
Dean Sheather 1de61246a3 feat: add experimental template autostop requirement template settings UI (#9417) 2023-08-30 20:41:27 +00:00
Kayla Washburn d2462e5b88 docs: add macOS installation page (#9443) 2023-08-30 14:37:51 -06:00
Denbeigh Stevens 53a5f18ba4 fix(examples): remove reference to non-existent local variable (#9448) 2023-08-30 20:14:11 +00:00
Jon Ayers ee24260614 feat: allow configuring display apps from template (#9100) 2023-08-30 14:53:42 -05:00
Kayla Washburn 9c9d035354 feat: automate updating homebrew tap formula (#9412) 2023-08-30 13:44:38 -06:00
Kayla Washburn c6f4f0f8ad feat: install from homebrew in install.sh (#9414) 2023-08-30 11:58:53 -06:00
Mathias Fredriksson 21f3282c82 chore(dogfood): fix code-server folder (#9437) 2023-08-30 20:08:06 +03:00
Bruno Quaresma a2516b5fc3 fix(site): remove checkbox from ws table loader (#9441) 2023-08-30 14:06:39 -03:00
Marcin Tojek 2377ab6624 test(site): improve E2E framework (#9438) 2023-08-30 15:34:45 +00:00
Steven Masley a910e934a4 chore: improve error message around gitaskpass failures (#9407) 2023-08-30 08:58:31 -05:00
Bruno Quaresma 2399063a56 feat(site): make workspace batch deletion GA (#9313) 2023-08-30 10:08:42 -03:00
Spike Curtis 90acf998bf fix: fix null pointer on external provisioner daemons with daily_cost (#9401)
* fix: fix null pointer on external provisioner daemons with daily_cost

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

* Add logging for debounce and job acquire

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

* Return error instead of panic

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

* remove debounce on external provisioners to fix test flakes

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-30 10:48:35 +00:00
Spike Curtis a415395e9e fix: stop dropping error log on context canceled after heartbeat (#9427)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-30 14:44:00 +04:00
Marcin Tojek 3e67d8fa6a docs: describe dynamic options and locals (#9429) 2023-08-30 12:30:24 +02:00
Ammar Bandukwala 16ef97a061 feat(cli): add DataDog Go tracer (#9411) 2023-08-29 22:14:28 +00:00
Eric Paulsen 9ceba20ea4 docs: add jetbrains offline mode config steps (#9388) 2023-08-29 17:04:49 -04:00
Colin Adler 64ef867b4f fix(tailnet): re-add keepalives (#9410) 2023-08-29 15:21:30 -05:00
Colin Adler 8443d3e0f8 fix(enterprise): ensure audit log json fields are formatted correctly (#9397) 2023-08-29 13:36:54 -05:00
Dean Sheather a572800d47 chore: rename template restart requirement to autostop requirement (#9295) 2023-08-29 18:35:05 +00:00
Bruno Quaresma fc4683d8b3 chore: support protobuf files in the UI (#9408) 2023-08-29 17:26:23 +00:00
Mathias Fredriksson 605d2b20e2 chore(go.mod): update github.com/fergusstrange/embedded-postgres to v1.24.0 (#9405) 2023-08-29 19:00:38 +03:00
Marcin Tojek f5d813c4fb test(site): e2e: update workspace with parameters (#9338) 2023-08-29 15:10:31 +02:00
Mathias Fredriksson 3557497ea4 test(coderd): fix workspace rename test (#9402)
Fixes #9400
2023-08-29 11:42:42 +00:00
Dean Sheather 5993f85ec9 fix: avoid redirect loop on workspace proxies (#9389)
* fix: avoid redirect loop on workspace proxies

---------

Co-authored-by: Steven Masley <stevenmasley@coder.com>
2023-08-28 20:34:52 -05:00
Ben Potter eb68684327 docs: add v2.1.4 changelog (#9398)
* docs: add v2.1.4 changelog

* fmt

* reorder

* clarify
2023-08-28 22:55:09 +00:00
Mathias Fredriksson be47cc58ff fix(enterprise/coderd): use websocketNetConn in workspaceProxyCoordinate to bind context (#9395) 2023-08-28 23:12:45 +03:00
Mathias Fredriksson 487bdc2e08 fix(coderd): allow workspaceAgentLogs follow to return on non-latest-build (#9382) 2023-08-28 19:46:42 +00:00
Steven Masley fea8813f13 chore: drop 'template plan' unused command (#9386) 2023-08-28 13:33:40 -05:00
Bruno Quaresma 2167fe16d6 chore: remove e2e workaround (#9393) 2023-08-28 15:24:01 -03:00
Bruno Quaresma d138ed7314 fix(coderd): send updated workspace data adter ws connection (#9392) 2023-08-28 15:14:17 -03:00
Dean Sheather a2be2f9838 fix: avoid derp-map updates endpoint leak (#9390) 2023-08-28 18:13:19 +00:00
Kayla Washburn ce9b048f06 feat(site): improve template publishing flow (#9346) 2023-08-28 11:27:51 -06:00
Marcin Tojek 80425c32bf fix(site): workaround: reload page every 3sec (#9387) 2023-08-28 16:22:39 +00:00
Muhammad Atif Ali 35d0809830 ci: prefix dependabot github-actions PRs with ci: (#9376) 2023-08-28 18:20:52 +03:00
dependabot[bot] b6e808d116 chore: bump github.com/charmbracelet/lipgloss from 0.7.1 to 0.8.0 (#9370)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-28 14:08:32 +03:00
dependabot[bot] 506b81adeb ci: bump crate-ci/typos@v1.16.6 to crate-ci/typos@v1.16.8 (#9372)
bumps crate-ci/typos@v1.16.6 to crate-ci/typos@v1.16.8
2023-08-28 09:41:05 +00:00
Muhammad Atif Ali 79aba1d5ff ci: remove redundant groups from dependabot.yaml (#9365) 2023-08-28 09:21:54 +00:00
Ammar Bandukwala 594a6aae19 chore: format oidctest (#9362) 2023-08-27 19:51:13 +00:00
Ammar Bandukwala 6ba92ef924 ci: enable gocognit (#9359)
And, bring the server under 300:

* Removed the undocumented "disable" STUN address in favor of the
--disable-direct flag.
2023-08-27 14:46:44 -05:00
Ben Potter 173aac959c fix(systemd): use more reasonable restart limit (#9355) 2023-08-27 14:35:06 -05:00
Ammar Bandukwala 4a140536e1 ci: lint against dupl (#9357)
This lint rule should help us keep Go code redundancy under control.
2023-08-27 11:42:51 -05:00
Kyle Carberry 61634d482f fix: truncate websocket close error (#9360)
Related #9324
2023-08-27 16:26:31 +00:00
Kyle Carberry c3ac55ff42 feat: add template_active_version_id to workspaces (#9226)
* feat: add `template_active_version_id` to workspaces

This reduces a fetch in the VS Code extension when getting the
active version update message!

* Fix entities.ts

* Fix golden gen
2023-08-27 16:26:20 +00:00
Muhammad Atif Ali 54032ccfe8 ci: update pr-cleanup.yaml to remove set -x (#9358) 2023-08-26 23:02:22 +00:00
Muhammad Atif Ali f97b497966 chore(dogfood): update docker tf provider and metadata (#9356) 2023-08-27 01:22:28 +03:00
Ammar Bandukwala 451ca042ce feat(site): show entity name in DeleteDialog (#9347) 2023-08-25 22:16:30 +00:00
Muhammad Atif Ali 7904d0b92f docs: list firewall exceptions for restricted internet installations (#8936)
* docs: add firewall exceptions for restricted internet installtions

closes #7542

* fix link

* fmt
2023-08-25 23:48:35 +03:00
Bruno Quaresma 1de1e3b98a fix(site): make right panel scrollable on template editor (#9344) 2023-08-25 13:52:10 -06:00
Steven Masley d9d4d74f99 test: add full OIDC fake IDP (#9317)
* test: implement fake OIDC provider with full functionality
* Refactor existing tests
2023-08-25 14:34:07 -05:00
Bruno Quaresma 0a213a6ac3 refactor(site): improve the overall user table design (#9342) 2023-08-25 17:59:41 +00:00
Ammar Bandukwala 14f769d229 fix(site): use WebGL renderer for terminal (#9320) 2023-08-25 12:46:14 -05:00
Ammar Bandukwala e5c64a8ea9 fix(site): render variable width unicode characters in terminal (#9259)
Previously, characters such as 🟢 were given insufficient space, leading
to mangled output.
2023-08-25 17:45:36 +00:00
Eric Paulsen 91f900ec64 docs: expand on TTL flags (#9286)
* docs: expand on TTL flags

* make: gen

* Discard changes to site/src/api/api.ts

* Discard changes to site/src/xServices/templateVersion/templateVersionXService.ts

---------

Co-authored-by: Muhammad Atif Ali <matifali@live.com>
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-08-25 13:39:12 -04:00
Ammar Bandukwala f149db6ca6 fix(cli): add --max-ttl to template create (#9319)
It was just in template edit by mistake.
2023-08-25 11:00:38 -05:00
Muhammad Atif Ali 3b1ecd3c2f chore: update aws_linux template (#9325) 2023-08-25 13:50:03 +00:00
Marcin Tojek d7a788d89d test(site): e2e: restart workspace with ephemeral parameters (#9304) 2023-08-25 14:50:38 +02:00
Spike Curtis aed891b4ff fix: fix coder template pull on Windows (#9327)
* fix: fix coder template pull on Windows

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

* appease linter

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

* improvements from code review

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-25 10:58:13 +00:00
Spike Curtis e7a231e44f fix: fix test flake introduced by #9264 (#9330)
* Fix test flake introduced by #9264

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

* change check to match suffix

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-25 10:48:42 +00:00
Bruno Quaresma 058fb2ecf0 fix(site): fix default ephemeral parameter value on parameters page (#9314) 2023-08-25 12:28:18 +02:00
Spike Curtis 60d5002eb6 refactor: change template archive extraction to be on provisioner (#9264)
* refactor provisionersdk protocol

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

* refactor provisioners to use new protocol

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

* refactor provisionerd to use new protocol

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

* refactor tests & proto renames

* Fixes from self-review

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

* appease fmt & link

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

* code review fixes & e2e fixes

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

* More fmt

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

* Code review fixes

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

* new gen; use uuid for session workdir

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

* Revert nix-based gen CI task until dogfood is on nix

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

* revert deleting dogfood Docker stuff

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

* Revert "revert deleting dogfood Docker stuff"

This reverts commit 9762158167.

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-25 06:10:15 +00:00
sharkymark 4bed492012 docs: ui option for adding licenses (#9322) 2023-08-24 22:23:59 -05:00
Jon Ayers 7ddb216d87 chore: revert nix-related CI changes (#9321)
* chore: revert nix-related CI changes

- Reverts using nix to run CI-dependencies.
- Running 'make gen' in a dogfood workspace resulted in inconsistent
  results for protobuf-related files making it difficult to pass CI.
  This PR imports the minimum changes necessary to make CI compatible
  with dogfood.
2023-08-24 21:26:30 -05:00
Ammar Bandukwala 630ec55c48 fix(coderd): remove rate limits from agent metadata (#9308)
Include the full update message in the PubSub notification so that
we don't have to refresh metadata from the DB and can avoid rate
limiting.
2023-08-24 15:18:42 -05:00
Jon Ayers 7f14b50dbe chore: rename locked to dormant (#9290)
* chore: rename locked to dormant

- The following columns have been updated:
  - workspace.locked_at -> dormant_at
  - template.inactivity_ttl -> time_til_dormant
  - template.locked_ttl -> time_til_dormant_autodelete

This change has also been reflected in the SDK.

A route has also been updated from /workspaces/<id>/lock to /workspaces/<id>/dormant
2023-08-24 13:25:54 -05:00
Ben Potter ebd878b6b5 chore: v2.1.3 changelog (#9311) 2023-08-24 17:35:00 +00:00
Dean Sheather 64df076328 feat: add server flag to force DERP to use always websockets (#9238) 2023-08-24 17:22:31 +00:00
Mathias Fredriksson 9cb913fb1a fix(go.mod): upgrade cdr.dev/slog to fix isTTY race (#9305) 2023-08-24 18:08:52 +03:00
Mathias Fredriksson af939d1e94 fix(coderd): optimize template app insights query for speed and decrease intervals (#9302) 2023-08-24 14:34:38 +00:00
Bruno Quaresma 67c8635543 fix(site): only show workspace actions if user has permission (#9303) 2023-08-24 11:28:59 -03:00
Bruno Quaresma 14aa1af45f refactor(site): remove as many 100vh units as possible(#9272) 2023-08-24 09:25:27 -03:00
Mathias Fredriksson 04d5e3f54f fix(coderd): rewrite template insights query for speed and fix intervals (#9300) 2023-08-24 14:38:32 +03:00
Mathias Fredriksson d00817ea4a perf(coderd): simplify insights queries to speed them up (#9299) 2023-08-24 10:52:20 +00:00
Mathias Fredriksson 6b69abfec7 fix(coderd): use stable sorting for insights and improve test coverage (#9250)
Fixes #9213
2023-08-24 13:36:40 +03:00
Cian Johnston 970072f61d chore(docs): add example scenario for parameter updates (#9298) 2023-08-24 10:35:20 +01:00
Marcin Tojek 52ea23355a docs: incompatibility in parameter options for workspace builds (#9297) 2023-08-24 11:05:31 +02:00
coryb 113894c045 fix(coderd): prevent oidc refresh being ignored (#9293) 2023-08-24 00:42:20 -05:00
Ben Potter f96622f192 chore: add exempt users to CLAbot allowlist (#9292) 2023-08-23 23:17:22 +00:00
Bruno Quaresma 6c93687095 fix(site): fix vertical scroll in the bottom bar (#9270) 2023-08-23 17:24:47 -03:00
Cian Johnston 2fa6a50de6 chore(docs): update scaling table (#9279) 2023-08-23 20:18:42 +00:00
Ben Potter e0ba80c872 chore: write v2.1.2 changelog (#9288) 2023-08-23 19:51:29 +00:00
Reuben Ellis 868ae06d4e chore: add a base directory for TurboSnap (#9258)
* Add base dir for TurboSnap

* updated main workflow as well

* Add vite configuration

* remove the mergeConfig and return config
2023-08-23 15:12:00 -03:00
dependabot[bot] 69b5c9cc27 chore: bump the react group in /site with 1 update (#9164)
Bumps the react group in /site with 1 update: [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom).

- [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.15.0/packages/react-router-dom)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-23 15:11:02 -03:00
Kyle Carberry 707a0a2d95 fix: resolve deadlock when fetching everyone group for in-memory db (#9277) 2023-08-23 16:54:16 +00:00
Marcin Tojek e845deaa89 fix: prompt when parameter options are incompatible (#9247) 2023-08-23 18:18:38 +02:00
Mathias Fredriksson 8bfa312905 fix(coderd): parallelize queries to improve template insights performance (#9275) 2023-08-23 15:31:23 +00:00
dependabot[bot] d180df1fd5 chore: bump google.golang.org/api from 0.137.0 to 0.138.0 (#9216)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-23 18:04:20 +03:00
dependabot[bot] cff33c2326 chore: bump the github-actions group with 1 update (#9218)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-23 18:03:59 +03:00
Kayla Washburn 72cb42b8e0 feat(site): add descriptions for each auth method to the selection menu (#9252) 2023-08-23 08:58:49 -06:00
Bruno Quaresma b6aedb9f1d refactor(site): improve how string values are displayed (#9273) 2023-08-23 11:32:55 -03:00
Dean Sheather f35423c041 fix: update conn derpmap every 5s in single tailnet (#9176) 2023-08-23 11:20:31 +00:00
Dean Sheather 53de47d4c8 chore: fix flake in TestDERPHeaders (#9262) 2023-08-23 21:03:39 +10:00
Marcin Tojek a3d31268a3 fix(cli): do not ask for immutables on update (#9266) 2023-08-23 12:46:52 +02:00
Marcin Tojek e6d90bd4fe fix: rewrite onlyDataResources (#9263) 2023-08-23 10:17:16 +00:00
Muhammad Atif Ali d37f6d80f7 chore(docs): update docs for correct use of shell and console and enforce linewidth (#9245) 2023-08-23 12:27:57 +03:00
Mathias Fredriksson ed2b1236c0 fix(coderd/batchstats): fix init race and close flush (#9248) 2023-08-23 11:58:25 +03:00
Kayla Washburn 31ffb566d0 fix: disable setup page once setup has been completed (#9198) 2023-08-22 14:57:46 -06:00
Jon Ayers 6e41cd1eda feat: add activity bumping to template scheduling (#9040) 2023-08-22 15:15:13 -05:00
Ammar Bandukwala 6214117d3d fix: pull agent metadata even when rate is high (#9251)
This commit fixes a bug where when the rate of metadata updates was
too high, the debounce caused a new update to get indefinitely delayed.
2023-08-22 13:55:00 -05:00
Kayla Washburn 697b0283c5 chore: fix low hanging lint issues (#9253) 2023-08-22 12:32:37 -06:00
Ben Potter 306615c674 docs: add v2.1.1 changelog (#9249)
* add WPL to manifest

* docs: add v2.1.1 changelog
2023-08-22 16:09:33 +00:00
Steven Masley 262d7692b6 feat: add force refresh of license entitlements (#9155)
* feat: add force refresh of license entitlements
* send "going away" mesasge on licenses pubsub on close
* Add manual refresh to licenses page
2023-08-22 09:26:43 -05:00
Steven Masley 37a3b42c55 feat: add last_used search params to workspaces (#9230)
* feat: add last_used search params to workspaces
2023-08-22 08:41:58 -05:00
Cian Johnston e57d635739 feat: add script to run a local keycloak instance (#9242) 2023-08-22 14:32:03 +01:00
Marcin Tojek 8a1da743cc test(site): e2e: create workspace with rich parameters (#9185) 2023-08-22 14:21:32 +02:00
Ammar Bandukwala 545a256b57 fix: correctly reject quota-violating builds (#9233)
Due to a logical error in CommitQuota, all workspace Stop->Start operations
were being accepted, regardless of the Quota limit. This issue only
appeared after #9201, so this was a minor regression in main for about
3 days. This PR adds a test to make sure this kind of bug doesn't recur.

To make the new test possible, we give the echo provisioner the ability
to simulate responses to specific transitions.
2023-08-22 02:55:39 +00:00
Ammar Bandukwala 69ec8d774b fix(cli/server): apply log filter to log message as well as name (#9232) 2023-08-21 17:53:26 -05:00
Kayla Washburn 2a263b9534 fix: always show add user button (#9229)
Fixes #9172

There is always at least one authentication method enabled (none), so we should remove the authMethod check to make sure that the button is always shown.
2023-08-21 15:44:20 -06:00
Ammar Bandukwala 4a9c7733d8 chore(dogfood): revert to pre-nix image (#9231) 2023-08-21 20:30:09 +00:00
Kyle Carberry 2a04d15c6d chore: downgrade dogfood image to postgres 13 (#9228) 2023-08-21 19:26:31 +00:00
Bruno Quaresma f6e02068e7 fix(site): fix ports update (#9221) 2023-08-21 14:32:59 -03:00
Bruno Quaresma 92445cf52e fix(site): fix locale dates in timeline component (#9223) 2023-08-21 14:24:54 -03:00
Cian Johnston 5c1ecfbd5f feat(scripts/develop.sh): provide an easy way to specify access url (#9222)
Allows `develop.sh --access-url="http://host:port"`
2023-08-21 17:23:07 +00:00
Steven Masley b2ca3ebaa3 fix: add workspace_proxy type to auditlog friendly strings (#9194)
* fix: add workspace_proxy type to auditlog friendly strings
* add unit test and organization type
2023-08-21 10:53:41 -05:00
Kyle Carberry 07188b123a chore: add dependencies for js-test to our nix flake (#9224) 2023-08-21 15:03:33 +00:00
Cian Johnston 5d4a17717f refactor(coderd): fetch owner information when authorizing workspace agent (#9123)
* Refactors the existing httpmw tests to use dbtestutil so that we can test them against a real database if desired,
* Modifies the GetWorkspaceAgentByAuthToken to return the owner and associated roles, removing the need for additional queries
2023-08-21 15:49:26 +01:00
Ammar Bandukwala 6d939b726c fix: correctly assess quota for stopped resources (#9201) 2023-08-21 09:01:16 -05:00
Mathias Fredriksson 509411f87c chore(flake.nix): add kubectx (#9219) 2023-08-21 15:54:22 +03:00
Mathias Fredriksson 03453b1e02 feat(coderd): add template app usage to insights (#9138)
Fixes #8658
2023-08-21 15:08:58 +03:00
Cian Johnston 4de7de420e fix(flake.nix): add gcloud auth plugin (#9215) 2023-08-21 10:58:34 +00:00
Kyle Carberry 7404ee9b21 chore: add name to top-level package.json to allow importing (#9209) 2023-08-20 00:35:38 +00:00
Kyle Carberry 4d85d56327 chore: add version to top-level package.json to allow importing (#9208) 2023-08-20 00:10:53 +00:00
Kyle Carberry 2c83bfdfa5 fix: set the location of locale_archive (#9207)
See https://nixos.wiki/wiki/Locales
2023-08-19 22:37:44 +00:00
Ammar Bandukwala 6b8102cf4c feat(cli): add daily_cost to coder ls (#9200) 2023-08-19 12:56:08 -05:00
Vaibhav Kumar e95557890a docs: remove <> and use shell for code blocks in azure docs (#9078) 2023-08-19 13:52:24 +00:00
Kyle Carberry 40ef9ff779 fix: add sapling to the nix flake (#9202) 2023-08-18 16:41:03 -05:00
Kyle Carberry 22e781eced chore: add /v2 to import module path (#9072)
* chore: add /v2 to import module path

go mod requires semantic versioning with versions greater than 1.x

This was a mechanical update by running:
```
go install github.com/marwan-at-work/mod/cmd/mod@latest
mod upgrade
```

Migrate generated files to import /v2

* Fix gen
2023-08-18 18:55:43 +00:00
Cian Johnston 0d40e7fe24 chore(flake.nix): add gcloud and kubectl to flake (#9197) 2023-08-18 18:29:24 +00:00
Kyle Carberry 9e9c79dbd3 fix: remove nix bash from the dogfood image (#9195)
This was unnecessary.
2023-08-18 17:59:25 +00:00
Mathias Fredriksson bbaa057e15 fix(agent): log correct script timeout for startup script (#9190) 2023-08-18 17:35:49 +00:00
Kyle Carberry 4c133e7058 fix: add yarn to the dogfood image (#9193) 2023-08-18 17:15:33 +00:00
Ben Potter 36fcee50b6 fix: use proper link to workspace proxies page (#9183)
we changed the route in #9070
2023-08-18 11:49:14 -05:00
Kyle Carberry c93782aba6 fix: allow chsh in dev image (#9191) 2023-08-18 16:15:05 +00:00
Kyle Carberry 9725ec0713 fix: separate dev shell and dev image nix deps (#9189)
* fix: separate dev shell and dev image nix deps

* Add less
2023-08-18 15:58:52 +00:00
Kyle Carberry e94ebea5e9 fix: add gh cli to the dogfood image (#9184) 2023-08-18 14:49:54 +00:00
Kyle Carberry 88de63f891 fix: add locale to dogfood image (#9181)
* fix: add locale to dogfood image

* Update flake.nix

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

* Add gcc

---------

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-08-18 09:16:16 -05:00
Cian Johnston 95458ac8a5 chore(scripts/develop.sh): restore original access url setting (#9174) 2023-08-18 13:24:17 +00:00
Bruno Quaresma 8db3869415 chore: add zsh to dogfood (#9178) 2023-08-18 13:05:02 +00:00
Dean Sheather f4f3132120 docs: add workspace process logging doc (#9002) 2023-08-18 23:02:01 +10:00
Bruno Quaresma 531f740070 fix(site): remove mock data from port forward button (#9177) 2023-08-18 12:59:20 +00:00
Marcin Tojek 669ae9d4d3 fix(cli): remove prompt for immutable parameters on start and restart (#9173) 2023-08-18 14:06:46 +02:00
phorcys420 376352eeb3 fix(ci): add github token to chocolatey workflow (#9166) 2023-08-18 13:16:56 +03:00
Marcin Tojek ea34ec7538 chore(site): regenerate provisioner stub (#9151) 2023-08-18 10:50:43 +02:00
Marcin Tojek 04810cb42e fix: do not install strace on OSX (#9167) 2023-08-18 10:07:11 +02:00
Spike Curtis 2f46f2315c fix: fix race in PGCoord at startup (#9144)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-18 09:53:03 +04:00
Kyle Carberry c0a78533bf chore: reduce build time by converting docker image to build with nix (#9099)
* Add Docker image

* Try building the container in CI

* Uncomment testing lines

* Trim image step

* Hit 'em with a Docker load

* Oopsie!

* Add a tag and push!

* Fix image name 🤦

* Fix sudo

* Fix target name

* Build and push

* Fix login to docker hub

* Revert to Docker push

* Fix PATH

* Fix SHA

* Fix ca certs

* Fix ca certs

* Fix coping files in

* Fix docker init

* Fix Docker group and init

* Add comments to our Nix

* Fix build stage

* Add some more comments

* Remove old dogfood image files

* Tag and push with branch name

* Fix tag passing

* Fix tag passing

* Remove old pull triggers

* Convert gen to use Nix

* Add protobuf to the flake

* Add prettier to the dev shell

* Swap to the faster Nix cache action

* Add the correct yq

* Fix gen

* Add make to the flake

* Update extensions
2023-08-17 21:19:36 -05:00
Kayla Washburn 5b165d5cb9 fix: make displayName primary in ParameterLabel component (#9158) 2023-08-17 19:07:57 -06:00
Ben Potter 71d5882341 chore: 2.1.0 changelog (#9160) 2023-08-17 23:02:54 +00:00
Bruno Quaresma 9caa4cfde0 feat(site): display build logs history in the build log page (#9150) 2023-08-17 18:59:26 -03:00
Ammar Bandukwala be40dc85ab chore: cleanup extraneous logging (#9156)
* The batchstats warning went out on every Ctrl+C in my development

Rule of silence:

The provisioner and connect messages messages were sent out on every startup
without a corresponding user event, making them annoying and more-so
debug messages.
2023-08-17 21:01:55 +00:00
Kayla Washburn 9710bada06 fix: redirect to login upon authentication error (#9134) 2023-08-17 13:54:20 -06:00
Ammar Bandukwala 720ad9a653 fix(site): avoid showing disabled fields in group settings page (#9154)
Previously we allowed interaction with the icon setter and showed
confusing help text under the disabled "Display Name" field.
2023-08-17 14:21:36 -05:00
Jon Ayers 2f6687a475 feat: expose Everyone group through UI (#9117)
- Allows setting quota allowances on the 'Everyone' group.
2023-08-17 13:25:16 -05:00
Steven Masley 8910f05172 fix: /workspaces should work even if missing template perms (#9152)
If a user is missing template perms to a workspace, just block reading
that workspace. This is to keep the api consistent, it is not a rbac
enforcement.

This should ublock users reporting this bug that /workspaces returns
nothing when 1 workspace cannot be fully read. We might want to be
able to return missing or unknown fields in our api to account
for this.
2023-08-17 13:22:03 -05:00
Kayla Washburn e39402f1c9 fix: don't navigate away from editor after publishing (#9153) 2023-08-17 10:49:16 -06:00
Reuben Ellis 94cbc2ae7f chore: update storybook build script (#9140) 2023-08-17 09:58:52 -03:00
Oleg Kovalov c639674b39 chore: replace chi with chi/v5 (#9143) 2023-08-17 07:46:56 -05:00
Spike Curtis c66befb548 fix(scaletest): change IP range to non-reserved in GCP (#9146)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-17 13:11:02 +04:00
Spike Curtis c7a6d626b4 fix: make PGCoordinator close connections when unhealthy (#9125)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-17 09:36:47 +04:00
Eric Paulsen c217a0d819 fix!: remove jq from image (#8979)
* fix: remove jq from base and add jq ext image

* Delete Dockerfile.ext-jq

---------

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-08-16 21:20:33 -04:00
Kayla Washburn 5c7780015b chore: rename UsersDropdown.tsx component file to UserDropdown.tsx (#9137) 2023-08-16 17:36:51 -06:00
Ben Potter fa8e103b0e docs: last seen before & after (#9096) 2023-08-16 23:20:03 +00:00
Asher 02ee724d9f fix: do terminal emulation in reconnecting pty tests (#9114)
It looks like it is possible for screen to use control sequences instead
of literal newlines which fails the tests.

This reuses the existing readUntil function used in other pty tests.
2023-08-16 13:02:03 -08:00
Steven Masley 74999305b6 fix: change oauth convert oidc cookie to SameSite=Lax (#9129)
The strict mode was blocking the cookie from being sent on the
redirect flow. This worked on localhost because cookies
behave differently on localhost
2023-08-16 12:50:44 -05:00
Bruno Quaresma b05293572f refactor(site): remove template parameters insights out of experimental (#9126) 2023-08-16 12:29:42 -03:00
Muhammad Atif Ali 8646f7c00d chore: add JFrog VS Code extension to jfrog template (#9128) 2023-08-16 10:03:42 -05:00
Bruno Quaresma 752070baf5 refactor(site): use bar chart for DAUs (#9127) 2023-08-16 10:59:15 -03:00
Spike Curtis ff9252c706 feat: add provisioner chart to release and docs (#9050)
* Add provisioner chart to release and docs

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

* Update docs/admin/provisioners.md

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

* Prettier

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

* spell out PSK first time per section

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
Co-authored-by: Cian Johnston <cian@coder.com>
2023-08-16 16:26:38 +04:00
Mathias Fredriksson 6fd9975aed feat(coderd): add coder_app usage stats (#9001)
Updates #8658
2023-08-16 15:22:00 +03:00
phorcys420 f3c707648c ci: publsh Chocolatey package (#8921) 2023-08-16 15:21:28 +03:00
Ammar Bandukwala 95d66ac385 docs: explain using Artifactory as a template store (#9071) 2023-08-15 16:46:56 -05:00
sharkymark 7261f0a9d4 docs: add bpmct template repo to community markdown (#9113) 2023-08-15 21:13:51 +00:00
Cian Johnston 6cdf1c73c0 chore: update sqlc to version 1.20.0 (#9111) 2023-08-15 20:06:03 +00:00
Colin Adler 5b2ea2e94f fix(tailnet): disable wireguard trimming (#9098)
Co-authored-by: Spike Curtis <spike@coder.com>
2023-08-15 14:26:56 -05:00
Eric Paulsen e4c24e05f8 fix: rename group GET request (#9097)
* fix: group GET req naming

* make: gen
2023-08-15 14:47:08 -04:00
dependabot[bot] 279d9f71f9 chore: bump github.com/gohugoio/hugo from 0.116.0 to 0.117.0 (#9084)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-15 13:40:03 -05:00
Ben Potter ee9deb0a6e docs: add conditional example to optional vs required parameters (#9115) 2023-08-15 18:24:05 +00:00
dependabot[bot] 65d84827cd chore: Bump the github-actions group with 1 update (#9086)
Bumps the github-actions group with 1 update: [crate-ci/typos](https://github.com/crate-ci/typos).

- [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.16.2...v1.16.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-15 19:33:34 +03:00
Bruno Quaresma c5d4a4d85d docs: update FE stack (#9112) 2023-08-15 16:03:14 +00:00
Spike Curtis 63278ab88f Reword latency docs for HA (#8860)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-15 19:58:04 +04:00
Bruno Quaresma 4058f049af feat(site): add batch actions to the workspaces page (#9091) 2023-08-15 12:57:39 -03:00
dependabot[bot] c2c9da7db0 chore: bump google.golang.org/api from 0.134.0 to 0.137.0 (#9093)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-15 10:50:10 -05:00
Colin Adler 9d9b330b16 chore: add request body to patch groups openapi spec (#9101) 2023-08-15 15:29:15 +00:00
Spike Curtis 41433cd1ec feat: add terminationGracePeriodSeconds to provisioner chart (#9048)
* feat: add terminationGracePeriodSeconds to provisioner chart

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

* Remove hardcoded 1 minute graceful timeout

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-15 08:38:58 +00:00
Spike Curtis e893ab232c chore: enables debug logging on TestTemplateInsights (#9103)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-15 12:35:51 +04:00
Muhammad Atif Ali 86fcd4503f Revert "ci: run tests intelligently based on changes between consecutive commits (#9017)" (#9104) 2023-08-15 08:22:49 +00:00
Muhammad Atif Ali 9a1f845553 docs: expand jfrog platform and example template (#9073) 2023-08-15 07:04:07 +00:00
Spike Curtis d54b387e34 fix: fix deadlock on tailnet close (#9079)
* fix: fix deadlock in tailnet close

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

* close another tailscale race

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

* Close another race

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

* HACK - run go tests

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

* Revert "HACK - run go tests"

This reverts commit d2729f36b4.

* tailscale to tip of coder/tailscale/main

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-15 06:54:06 +00:00
Colin Adler 344d32b2f1 feat(coderd): expire agents from server tailnet (#9092) 2023-08-14 20:38:37 -05:00
Asher a08f7b8fb9 fix: catch missing output with reconnecting PTY (#9094)
I forgot that waiting on the cond releases the lock so it was possible
to get pty output after writing the buffer but before adding the pty to
the map.  To fix, add the pty to the map while under the same lock where
we read from the buffer.

The rest does not need to be behind the lock so I moved it out of
doAttach, and that also means we no longer need
waitForStateOrContextLocked.

Also, this can hit a logger error saying the attach failed which fails
the tests however it is not that the attach failed, just that the
process already ran and exited, so when the process exits do not
set an error, instead for now assume this is an expected close.
2023-08-14 15:54:23 -08:00
Steven Masley 6ea82c5ae7 chore: add oidc sequence diagram image to docs (#9089)
* chore: add oidc sequence diagram image to docs

* Change wording

* Direct link to the sequence diagram
2023-08-14 17:35:43 -05:00
Steven Masley 25ce30df36 feat: add azure oidc PKI auth instead of client secret (#9054)
* feat: add azure oidc PKI auth instead of client secret
* add client cert and key as deployment options
* Custom token refresher to handle pki auth
2023-08-14 17:33:13 -05:00
dependabot[bot] 4e36f91ea2 chore: bump the golang-x group with 1 update (#9083)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-14 16:59:28 -05:00
Dean Sheather 47b8bf6585 feat: update workspace deadline when template policy changes (#8964) 2023-08-14 21:16:47 +00:00
Asher 37f9d4b783 feat: add --header-command flag (#9059)
This allows specifying a command to run that can output headers for
cases where users require dynamic headers (like to authenticate to their
VPN).

The primary use case is to add this flag in SSH configs created by the
VS Code plugin, although maybe config-ssh should do the same.
2023-08-14 12:12:17 -08:00
Asher b993cab49a fix: use screen for reconnecting terminal sessions on Linux if available (#8640)
* Add screen backend for reconnecting ptys

The screen portion is a port from wsep.  There is an interface that lets
you choose between screen and the previous method.  By default it will
choose screen if it is installed but this can be overidden (mostly for
tests).

The tests use a scanner instead of a reader now because the reader will
loop infinitely at the end of a stream.

Replace /bin/bash with bash since bash is not always in /bin.

* Remove connection_id from reconnecting PTY logger

This serves multiple connections so it makes no sense to scope it to a
single connection.

Also lets us use "connection_id" when logging write errors instead of
"other_conn_id".

* Use PATH to test buffered reconnecting pty
2023-08-14 11:19:13 -08:00
Muhammad Atif Ali 878315dcaf fix: fix CI concurrency (#9088) 2023-08-14 18:48:14 +03:00
Cian Johnston ef9d84c723 fix(scaletest): cleanup: attempt to cancel in-progress jobs (#9080)
This change modifies the cleanup behaviour to make a best-effort attempt to cancel the in-progress scaletest workspace build jobs before deleting them.
2023-08-14 12:43:45 +01:00
Cian Johnston 72575cc462 chore(docs): fix indentation in install/kubernetes.md (#8906)
* chore(docs): fix indentation in install/kubernetes.md

* fmt
2023-08-14 09:41:00 +01:00
Kyle Carberry 594b9797dd fix: change dashboard route /settings/deployment to /deployment (#9070)
It felt unnecessary to nest this.
2023-08-13 16:58:04 +00:00
Kyle Carberry 0d01d022f7 fix: remove unnecessary newlines from the end of cli output (#9068)
`Infof` already adds a newline, so we don't need to as well!
2023-08-13 11:48:11 -05:00
Kyle Carberry 9a13814b46 fix: remove duplication from language of query param error (#9069) 2023-08-13 11:47:44 -05:00
Muhammad Atif Ali 1629a2a4ee chore: sort DERP regions by latencies on workspace page (#9063) 2023-08-13 18:52:14 +03:00
Kyle Carberry abe17b1164 chore: update speakeasy to fix stty path bug on nixos (#9022)
Prompts failed on NixOS due to /bin/stty being hardcoded for turning
off echo in the terminal prompt. See:
https://github.com/bgentry/speakeasy/commit/760eaf8b681647364e7a400b856e0921248728a5
2023-08-13 15:10:58 +00:00
Muhammad Atif Ali 984f7ce045 fix: update BUILD condition in pr-deploy.yaml (#9064)
This makes the build condition more understandable and fixes an issue where we could not deploy a new PR as the build condition was constantly evaluating false.
2023-08-13 11:18:17 +03:00
Eric Paulsen 6af6e85fe3 docs: add coder login to CI docs (#9038)
* docs: add coder login to CI docs

* add CODER_URL

* add --url flag to login cmd
2023-08-11 20:55:55 +00:00
Eric Paulsen d2a9049fd7 docs: add offline docs for JetBrains Gateway (#9039) 2023-08-11 14:56:35 -05:00
Steven Masley 320de18be7 fix: correct github oauth2 callback url (#9052)
* fix: correct github oauth2 callback url
2023-08-11 09:25:05 -05:00
Steven Masley 47ca84be47 chore: return queried user on failure to help debug (#9051) 2023-08-11 14:02:19 +00:00
Steven Masley 1c7bd57da8 chore: clarify region selection behavior (#9021)
* chore: clarify region selection behavior

* Update site/src/components/Navbar/NavbarView.tsx

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

---------

Co-authored-by: Kyle Carberry <kyle@coder.com>
2023-08-11 08:26:01 -05:00
Muhammad Atif Ali 59fd4e86c9 ci: remove deleting comments section from pr-cleanup.yaml (#9047) 2023-08-11 15:43:37 +03:00
Muhammad Atif Ali a13c8c88d5 fix: prevent unrequested PR deployments (#9049) 2023-08-11 12:32:42 +00:00
Muhammad Atif Ali 7fb9197860 ci: do not run deploy-pr on main (#9046) 2023-08-11 10:54:55 +00:00
Muhammad Atif Ali 114ad4624e ci: upgrade pr deployments workflow (#8924) 2023-08-11 13:49:23 +03:00
Muhammad Atif Ali 4d8152d543 ci: run tests intelligently based on changes between consecutive commits (#9017) 2023-08-11 13:48:24 +03:00
Steven Masley 40f3fc3a1c feat: allow creating manual oidc/github based users (#9000)
* feat: allow creating manual oidc/github based users
* Add unit test for oidc and no login type create
2023-08-10 20:04:35 -05:00
ffais 6fd5344d0a feat: add support for NodePort service type in Helm chart (#8993)
* add support for NodePort service type in Helm chart

* fix nodeport values

* formatting & make update-golden-files

* update-golden-files

---------

Co-authored-by: Eric <ericpaulsen@coder.com>
2023-08-10 20:57:59 -04:00
timquinlan a2d64c08c1 docs: update helm values.yaml code snippet, put quote around boolean value (#9026)
* updated helm values.yaml code snippet, put quote around boolean values and added comments showing that CODER_OAUTH2_GITHUB_ALLOW_EVERYONE and CODER_OAUTH2_GITHUB_ALLOW_EVERYONE are mutually exclusive

* Update auth.md

spotted and fixed minor typo
2023-08-10 17:06:10 -04:00
Dean Sheather d2f22b063a fix: move STUN servers into their own regions (#9030) 2023-08-11 05:04:17 +10:00
Dean Sheather 25c6832772 chore: update tailscale (#9027) 2023-08-11 04:26:28 +10:00
Bruno Quaresma 175aed1685 feat(site): add tooltip showing the error in the failure badge (#9029) 2023-08-10 15:23:31 -03:00
Bruno Quaresma 83061bef7e refactor(site): add minor improvements to the port button (#9028) 2023-08-10 14:47:56 -03:00
Ben Potter 76ad116e12 docs: write 2.0.2 changelog (#9025)
* mention provisioner authentication

* add changelog for 2.1.0

* rename to 2.0.2
2023-08-10 17:02:02 +00:00
Marcin Tojek 967a4b0c7c feat: add example template using rich parameters (#9020) 2023-08-10 16:36:18 +02:00
Muhammad Atif Ali 091c00bd70 fix: make preferred region the first in list (#9014) 2023-08-10 12:59:39 +00:00
Bruno Quaresma 834ce41013 refactor(site): add default background color to html and body (#9009) 2023-08-10 09:41:35 -03:00
Marcin Tojek 9d9814c6b0 refactor(cli): adjust parameter resolver (#9019) 2023-08-10 12:08:00 +02:00
Spike Curtis 21af020386 feat: add external provisioner daemon helm chart (#8939)
* Refactor helm to extract common templates to libcoder

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

* Remove comment from libcoder Chart.yaml

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

* Add provisioner helm chart

* Fix prettier, linting, docs

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

* Log at INFO when provisionerd connects to coderd

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

* remove unnecessary exports in helm tests

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-10 13:59:43 +04:00
Steven Masley cdb089049e chore: add docs for creating missing groups on oidc sync (#8983) 2023-08-09 22:43:44 -05:00
Colin Adler 370bdd6a03 fix(cli): only init clistat.Client when calling coder stat (#9013) 2023-08-09 19:17:57 -05:00
Bruno Quaresma c0d1cacc49 fix(site): fix storybook error and inconsistent snapshots (#9010) 2023-08-09 21:22:13 +00:00
Eric Paulsen fb5e0c4bba docs: add TLS config steps for K8s (#9011)
* docs: add TLS config steps for K8s

* add note on wildcard cert
2023-08-09 17:00:22 -04:00
Bruno Quaresma 3245e91a32 fix(site): set default color and display error on appearance form (#9004) 2023-08-09 16:53:32 -03:00
Colin Adler bc862fa493 chore: upgrade tailscale to v1.46.1 (#8913) 2023-08-09 19:50:26 +00:00
Bruno Quaresma 5b9dc2ee8b fix(site): add search params to auth redirect (#9005) 2023-08-09 16:31:12 -03:00
phorcys420 53f26b313d fix(scripts): check if PR list is empty (#8805)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-08-09 19:22:46 +00:00
Colin Adler 612f1c6a55 chore: use echo provisioners in logging tests (#9008) 2023-08-09 19:03:02 +00:00
Steven Masley f334b66178 chore: do not allow resetting password of non password users (#9003) 2023-08-09 13:56:13 -05:00
Colin Adler 919f5c6fe9 chore: increase e2e timeout to 60s (#9007) 2023-08-09 18:50:27 +00:00
Colin Adler a9e01bf3f1 chore: fix terraform tests (#9006) 2023-08-09 18:11:03 +00:00
Bruno Quaresma 7b35f3b3ad fix(site): add horizontal scroll when having many tabs (#8998) 2023-08-09 14:28:25 +00:00
Bruno Quaresma 7fceb9aaff fix(site): make stats bar scrollable on smaller viewports (#8996) 2023-08-09 11:26:56 -03:00
Bruno Quaresma d73e3ad3f3 fix(site): show user avatar on group page (#8997) 2023-08-09 11:26:43 -03:00
dependabot[bot] a6716ca829 chore: bump chart.js from 3.9.1 to 4.3.3 in /site (#8874)
* chore: bump chart.js from 3.9.1 to 4.3.3 in /site

Bumps [chart.js](https://github.com/chartjs/Chart.js) from 3.9.1 to 4.3.3.
- [Release notes](https://github.com/chartjs/Chart.js/releases)
- [Commits](https://github.com/chartjs/Chart.js/compare/v3.9.1...v4.3.3)

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

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

* Remove timescale

* Fix step size

---------

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>
Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
2023-08-09 09:54:03 -03:00
Bruno Quaresma 73e518b0fb refactor(site): remove last 7 days label (#8986) 2023-08-09 09:46:14 -03:00
Spike Curtis e0f644c598 test(coderd): fix TestWorkspaceWatcher hang waiting for update (#8992)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-09 16:09:25 +04:00
Marcin Tojek 0d382d1e05 feat(cli): provide parameter values via command line (#8898) 2023-08-09 13:00:25 +02:00
Ben Potter 1730d35467 Revert "fix: hide experiment CTA from OIDC copy (#8695)" (#8825)
This reverts commit adbabe4e09.
2023-08-09 10:05:46 +00:00
Dean Sheather 9941f49056 fix: remove stun nodes from workspace proxy regions (#8990) 2023-08-09 09:31:25 +00:00
Dean Sheather 00a8221e51 fix: rename duplicate migration (#8989) 2023-08-09 05:49:13 +00:00
Dean Sheather 07fd73c4a0 chore: allow multiple agent subsystems, add exectrace (#8933) 2023-08-08 22:10:28 -07:00
Bruno Quaresma 70bd23a40a refactor(site): add default title (#8985) 2023-08-08 18:48:53 -03:00
Steven Masley d4e115d267 chore: show basic experiment set value (#8984)
This value is pre-parsed, meaning the experiments listed may not
be valid. This is a very basic display for helping debuging purposes.
2023-08-08 15:33:08 -05:00
Dean Sheather f7a35e0559 chore: add workspace proxies to telemetry (#8963) 2023-08-08 18:29:35 +00:00
Dean Sheather 3c52b01850 chore: add tailscale magicsock debug logging controls (#8982) 2023-08-08 17:56:08 +00:00
Colin Adler a5c59b9934 chore: upgrade to alpine 3.18.3 (#8980) 2023-08-08 12:21:38 -05:00
Bruno Quaresma 76b1594670 feat(site): add date range picker for the template insights (#8976) 2023-08-08 13:43:21 -03:00
Steven Masley f4122fa9f5 feat: add auto group create from OIDC (#8884)
* add flag for auto create groups
* fixup! add flag for auto create groups
* sync missing groups
Also added a regex filter to filter out groups that are not
important
2023-08-08 11:37:49 -05:00
Bruno Quaresma 4a987e9917 feat(site): add parameters usage to insights (#8886) 2023-08-08 13:09:31 -03:00
Steven Masley 5339a31532 fix: remove refresh oauth logic on OIDC login (#8950)
* fix: do not do oauth refresh logic on oidc login
2023-08-08 10:05:12 -05:00
Cem 1d4a72f43f perf(coderd/util/slice): refactor unique method for large lists (#8925) 2023-08-08 10:02:52 -05:00
Muhammad Atif Ali 05054c6a0a ci: make test-e2e a required check (#8977) 2023-08-08 14:57:57 +00:00
Kyle Carberry 4d3230c9ad fix: default to executing e2e ssh without args (#8975)
This was causing the test to fail consistently!
2023-08-08 14:35:34 +00:00
Muhammad Atif Ali c20c4faa7c docs: format CONTRIBUTING.md (#8973) 2023-08-08 17:12:51 +03:00
Dean Sheather b2a84462ab chore: fix ruleguard xerrors rules (#8967) 2023-08-08 12:32:41 +00:00
Muhammad Atif Ali 31b7de6a3e chore: upgrade go to 1.20.7 (#8923)
* chore: upgrade go to 1.20.7

* remove unused env
2023-08-08 09:20:36 +03:00
Kyle Carberry bac3a588b3 chore: add e2e test for backwards client ssh compatibility (#8958)
* chore: add e2e test for backwards client ssh compatibility

This was discussed as part of our regression review for outdated
agents, so here is the reverse with an extremely old client.

* fmt
2023-08-08 05:36:46 +00:00
Kyle Carberry 73b136e3f0 fix: add exp backoff to validate fresh git auth tokens (#8956)
A customer using GitHub in Australia reported that validating immediately
after refreshing the token would intermittently fail with a 401. Waiting
a few milliseconds with the exact same token on the exact same request
would resolve the issue. It seems likely that the write is not propagating
to the read replica in time.
2023-08-08 04:29:35 +00:00
Colin Adler 694729b4f7 chore: disable goleak in windows cli tests (#8955) 2023-08-07 22:23:00 -05:00
Colin Adler 7e3ff5b66e chore: fix TestBatchStats flake (#8952) 2023-08-07 21:55:31 -05:00
Colin Adler 758c368222 chore: fix TestTailnet/ForcesWebSockets flake (#8953) 2023-08-07 21:17:39 -05:00
dependabot[bot] 827de08007 chore: bump the golang-x group with 3 updates (#8940)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-07 14:30:14 -05:00
dependabot[bot] b2dc8897ff chore: bump github.com/go-playground/validator/v10 from 10.14.0 to 10.15.0 (#8941)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-07 14:16:03 -05:00
Ben Potter 3b16e7112d fix: improve formatting in Gateway docs (#8949)
* fix: image formatting for gateway docs

* chore: fix some more spots

* more

* fmt

* space things out more
2023-08-07 17:34:41 +00:00
Ben Potter b67ece1cbc fix: image formatting for gateway docs (#8947) 2023-08-07 11:45:15 -05:00
sharkymark 9f76381fc1 chore: add install more providers step in jetbrains docs; update images (#8943) 2023-08-07 16:31:43 +00:00
Marcin Tojek e8627195a2 feat(coderd): expose parameter description and type (#8944) 2023-08-07 16:11:44 +00:00
dependabot[bot] 00be8ab875 chore: bump the github-actions group with 1 update (#8942)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-07 18:54:20 +03:00
Dean Sheather 67ff2077a6 feat: add derp only text to proxies list in dashboard (#8932) 2023-08-08 01:52:06 +10:00
Cian Johnston 82e0e2e43c fix(cli): clistat: accept positional arg for stat disk cmd (#8911) 2023-08-07 16:26:16 +01:00
Muhammad Atif Ali 6ded748989 fix: update tag name for coder-preview image in ci.yaml (#8945) 2023-08-07 14:35:28 +00:00
Steven Masley 71ea5ace07 feat: add login type to users page (#8912) 2023-08-07 09:34:39 -05:00
Muhammad Atif Ali 90c1647fcf ci: change ghcr.io/coder/coder-preview:main tag to use version names (#8938) 2023-08-07 16:41:20 +03:00
Muhammad Atif Ali e7047726d8 docs: fix a broken link in docs.changelogs/README.md (#8937) 2023-08-07 13:00:05 +03:00
Ammar Bandukwala 81752d1b84 fix(cli/delete): prompt for confirmation after workspace is found (#8579) 2023-08-05 11:25:37 -05:00
Colin Adler eddaa7781d fix: don't close cached tailnet on pty close (#8917) 2023-08-04 22:54:27 +00:00
Colin Adler 0c7ff4fb8a fix(enterprise): ensure SCIM create user can unsuspend (#8916) 2023-08-04 22:03:21 +00:00
Bruno Quaresma 8f7b6a2936 fix(site): fix date range on template insights (#8914) 2023-08-04 18:00:13 +00:00
Cian Johnston 7224ff2af8 fix(enterprise/replicasync): fix data race in Manager.Regional (#8910) 2023-08-04 17:33:05 +01:00
Muhammad Atif Ali 9f5ac4d15d ci: publish main commit tag to ghcr.io/coder/coder-preview (#8897)
* wip

* push new tag and delete old tag

* prune by filtering

* fix permission

* fix filter

* keep last 2 versions

* use first 7 characters of sha for tag

* do not use gh cli

* test

* typo

* use gh cli again

* reduce days to 3

* fixup

* typo

* keep-last 5

* ready to merge

* retain tags from last 7 days

* test

* ready
2023-08-04 19:27:12 +03:00
Cian Johnston 9fb18f3ae5 feat(coderd): batch agent stats inserts (#8875)
This PR adds support for batching inserts to the workspace_agents_stats table.
Up to 1024 stats are batched, and flushed every second in a batch.
2023-08-04 17:00:42 +01:00
Cian Johnston ae88b79fd7 fix(cli): stat: set --host arg in TestStatCPUCmd to avoid test flakes in containers (#8806) 2023-08-04 15:15:33 +00:00
Cian Johnston 607cd11724 fix(cli): address race condition in scaletest_test output (#8902) 2023-08-04 15:06:28 +00:00
Bruno Quaresma 5106dfde52 refactor(site): refactor the ports button design (#8879)
* Refactor button

* Move component to where it is used

* Add base state of port forward component

* Add stories and empty state

* Add listening ports to handlers

* Add review suggestions

* Fix minor thing
2023-08-04 09:55:33 -05:00
Eric Paulsen 1c3ec8743c docs: clean up k8s install steps and order (#8869) 2023-08-04 08:40:48 -04:00
Ammar Bandukwala eae15c0789 chore(examples): bump envbuilder version (#8893) 2023-08-04 06:47:15 -05:00
Cian Johnston aff025e78c chore(docs): fix link to helm values highlighting affinity (#8901) 2023-08-04 10:25:24 +00:00
Spike Curtis cb4989cd8d feat: add PSK for external provisionerd auth (#8877)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-04 12:32:28 +04:00
Muhammad Atif Ali b77d6b2c84 ci: delete comments by github-action[bot] (#8896) 2023-08-04 06:55:38 +00:00
Eric Paulsen 2e45a0ffd7 fix(helm): set correct prom port in helm notes (#8888) 2023-08-04 07:52:59 +03:00
Jon Ayers e43608395c feat: add frontend for locked workspaces (#8655)
- Fix workspaces query for locked workspaces.
2023-08-03 19:46:02 -05:00
Colin Adler 502c7680a2 chore: fix release and security pipelines (#8891) 2023-08-03 18:40:47 -05:00
Ben Potter 7ad944da5f chore: v2 changelog (#8890) 2023-08-03 21:45:32 +00:00
Colin Adler 8ee500c59d fix: generate typescript types for healthcheck pkg (#8846) 2023-08-03 16:20:46 -05:00
Cian Johnston 72780c8031 chore(docs): update scaling.md (#8883)
* chore(docs): update scaling docs

* fixup! chore(docs): update scaling docs

* Update docs/admin/scale.md

* update with compute resources provided to coder

* address PR comments
2023-08-03 21:59:07 +01:00
Ben Potter 1314cd8fcb chore: support manual changelog and version 2.0 for releases (#8880)
* chore(release): add manual changelog + 2.0 support

* add comment

* fix typo

* fmt
2023-08-03 12:41:54 -05:00
Muhammad Atif Ali 10da570916 fix: prevent PR deployment without manual trigger (#8882)
* fix: do not deploy without a manual trigger

This will fix automatic first deployment

* fix typo

* Update pr-deploy.yaml

* Update pr-deploy.yaml

* Update pr-deploy.yaml

* Update pr-deploy.yaml

* Update pr-deploy.yaml

* Update pr-deploy.yaml

* Update pr-deploy.yaml

* build at least once

* wait for certificate

* Update pr-deploy.yaml
2023-08-03 19:32:20 +03:00
Muhammad Atif Ali b47bd7ccb5 ci: implement automatic upgrade of PR deployment (#8876) 2023-08-03 18:11:07 +03:00
Mathias Fredriksson d3991fac26 feat(coderd): add parameter insights to template insights (#8656) 2023-08-03 14:43:23 +00:00
Bruno Quaresma 2ed453035e fix: fix develop script and pnpm command (#8878) 2023-08-03 14:15:45 +00:00
dependabot[bot] 7493b28155 chore: bump the storybook group in /site with 1 update (#8872)
Bumps the storybook group in /site with 1 update: [storybook-addon-react-router-v6](https://github.com/JesusTheHun/storybook-addon-react-router-v6).

- [Release notes](https://github.com/JesusTheHun/storybook-addon-react-router-v6/releases)
- [Changelog](https://github.com/JesusTheHun/storybook-addon-react-router-v6/blob/main/CHANGELOG.md)
- [Commits](https://github.com/JesusTheHun/storybook-addon-react-router-v6/compare/v1.0.2...v2.0.0)

---
updated-dependencies:
- dependency-name: storybook-addon-react-router-v6
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: storybook
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-03 08:19:22 +03:00
Colin Adler e68d508469 chore: bump openssl in base image (#8811) 2023-08-02 16:16:34 -05:00
Bruno Quaresma b6018198b7 chore: remove insights from experimental (#8868) 2023-08-02 20:24:00 +00:00
Muhammad Atif Ali f7327dd2c6 fix: avoid using comment body directly (#8851) 2023-08-02 22:19:17 +03:00
Colin Adler 4b81cfaa0d chore: switch from yarn to pnpm (#8822) 2023-08-02 13:28:16 -05:00
Bruno Quaresma cf35c0dfc5 feat(site): add health warning and a health monitor page (#8844) 2023-08-02 14:49:24 -03:00
Bruno Quaresma 44f9b0228a fix(site): fix initial value for update parameters (#8863) 2023-08-02 14:37:02 -03:00
Bruno Quaresma 00cbb211b4 fix(site): show error when user exists (#8864) 2023-08-02 14:36:35 -03:00
Colin Adler eddd4f8888 chore: fix dupliate migration round 2 (#8867) 2023-08-02 16:28:30 +00:00
Steven Masley 4c1e63aae8 feat: add display_name field to groups (#8740)
* feat: add display_name field to groups

This is a non-unique human friendly group name for display
purposes. This means a display name can be used instead of
using an environment var to remap groups with OIDC names to
Coder names. Now groups can retain the OIDC name for mapping,
and use a display name for display purposes.
2023-08-02 10:53:06 -05:00
Dean Sheather 6ea32e4e80 fix: show current DERP name correctly in vscode (#8856) 2023-08-03 01:30:43 +10:00
Colin Adler aa7b267170 chore: add pnpm to dogfood image (#8865) 2023-08-02 10:26:47 -05:00
Colin Adler e482d39052 chore: fix duplicate migration (#8866) 2023-08-02 15:09:10 +00:00
Dean Sheather cd1e088f7c feat: add --derp-only flag to wsproxy (#8850) 2023-08-03 00:35:06 +10:00
Marcin Tojek d6e9870209 feat: add "dormant" user state (#8644) 2023-08-02 16:31:25 +02:00
Muhammad Atif Ali d2c7c8e1d8 fix: allow ci to publish a package (#8862) 2023-08-02 17:22:11 +03:00
Muhammad Atif Ali 57c7d7d4d2 ci: build and push ghcr.io/coder/coder-preview:main (#8832) 2023-08-02 15:45:14 +03:00
Dean Sheather 496ec6cfc5 fix: add read call to derp-map endpoint to avoid ws ping timeout (#8859) 2023-08-02 08:31:51 +00:00
Muhammad Atif Ali 75fcc24b60 fix: copy secret for the first deployment too (#8857) 2023-08-02 10:44:38 +03:00
Dean Sheather b955c5fefc fix: avoid agent runLoop exiting due to ws ping (#8852) 2023-08-02 07:25:07 +00:00
Muhammad Atif Ali f48e8dcf88 chore: update concurrency to use PR number (#8853) 2023-08-02 10:04:39 +03:00
Colin Adler 1472cce6c3 chore: increment GOCACHE key (#8849) 2023-08-02 03:33:52 +00:00
Dean Sheather 6b69970d7c fix: avoid infinite loop in agent derp-map (#8848) 2023-08-02 13:18:46 +10:00
Colin Adler 805eaca4b7 chore: use fetch-depth: 1 for most ci jobs (#8847) 2023-08-02 02:48:35 +00:00
dependabot[bot] 9b6750a4db chore: bump github.com/open-policy-agent/opa from 0.51.0 to 0.55.0 (#8808)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 21:48:02 -05:00
Ben Potter 4456d0bfea docs: sync roles (enterprise) (#8696)
* docs: role sync (enterprise)

* edits from code review

* fix typo
2023-08-01 13:47:55 -05:00
Eric Paulsen 924bccbfcf docs: rm microsoft vs code server docs (#8845) 2023-08-01 12:46:17 -05:00
Steven Masley 66649f97a8 chore: use system permission to prevent fetching all workspaces (#8843)
* chore: use system permission to prevent fetching all workspaces
2023-08-01 12:26:22 -05:00
Dean Sheather c575292ba6 fix: fix tailnet netcheck issues (#8802) 2023-08-02 01:50:43 +10:00
Steven Masley 929f2d585a fix: intiator user fields are included in the workspace build (#8836) 2023-08-01 10:35:43 -05:00
dependabot[bot] b7eafe1635 chore: bump github.com/gohugoio/hugo from 0.115.0 to 0.116.0 (#8807)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 10:27:23 -05:00
Colin Adler 437256d352 chore: upgrade slog (#8815) 2023-08-01 10:26:52 -05:00
Muhammad Atif Ali e23e5262b4 chore: wait 30 seconds before checking winget PR in release.yaml (#8835) 2023-08-01 14:57:25 +00:00
Muhammad Atif Ali b104bb7005 docs: update CONTRIBUTING.md with PR deployments instructions (#8831)
* docs: Update CONTRIBUTING.md with PR deployments instructions

* update
2023-08-01 16:48:32 +03:00
dependabot[bot] dcc63aec90 chore: bump the storybook group in /site with 6 updates (#8828)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 16:14:20 +03:00
dependabot[bot] 27c2fb8a56 chore: bump the eslint group in /site with 5 updates (#8829)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 15:19:07 +03:00
Muhammad Atif Ali 6a12912d6e ci: use a wildcard subdomain for PR deployments (#8801) 2023-08-01 12:02:42 +01:00
Marcin Tojek 336e663180 fix: parse insights start and end time (#8826) 2023-08-01 10:43:49 +02:00
dependabot[bot] a96c4a3f29 chore: bump framer-motion from 6.5.1 to 10.15.0 in /offlinedocs (#8817)
Bumps [framer-motion](https://github.com/framer/motion) from 6.5.1 to 10.15.0.
- [Changelog](https://github.com/framer/motion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/framer/motion/compare/v6.5.1...v10.15.0)

---
updated-dependencies:
- dependency-name: framer-motion
  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-08-01 07:28:06 +03:00
dependabot[bot] 8d0e8f45e0 chore: bump eslint from 8.45.0 to 8.46.0 in /offlinedocs (#8816)
Bumps [eslint](https://github.com/eslint/eslint) from 8.45.0 to 8.46.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.45.0...v8.46.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-08-01 07:27:19 +03:00
dependabot[bot] 280fc9d5ef chore: bump typescript from 4.7.3 to 5.1.6 in /offlinedocs (#8819)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.7.3 to 5.1.6.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.7.3...v5.1.6)

---
updated-dependencies:
- dependency-name: 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>
2023-08-01 07:27:04 +03:00
Colin Adler b84bba8fd1 chore: increase fmt timeout (#8820) 2023-07-31 16:36:53 -05:00
Steven Masley cb36783e8c feat: convert to oidc out of experimental (#8742) 2023-07-31 10:30:34 -05:00
Colin Adler ed82b864d0 chore: reenable prisma image scan (#8810) 2023-07-31 10:12:24 -05:00
Muhammad Atif Ali af036b440b docs: allow multiple Coder deployments to use single GitHub OAuth app (#8786)
* docs: Add instructions for using the same GitHub OAuth app for multiple Coder deployments

* fmt

* typo

* Update auth.md
2023-07-31 10:00:48 -04:00
Marcin Tojek ddabe9cc7f feat: improve RBAC preconditions for Insights endpoint (#8794) 2023-07-31 13:44:32 +00:00
Colin Adler 4cc270b12b revert(enterprise): make pgcoord experimental again (#8797) 2023-07-28 18:38:32 -05:00
Colin Adler 98d9a65cf5 chore: mark site/src/api/typesGenerated.ts as generated (#8798) 2023-07-28 18:22:37 -05:00
Colin Adler 0b4f333a6f chore: add http debug support to pgcoord (#8795) 2023-07-28 17:59:31 -05:00
Bruno Quaresma a75346dd32 refactor(site): simplify workspaces page component structure (#8793) 2023-07-28 13:07:50 -03:00
Kyle Carberry bd944e0d21 chore: rename startup logs to agent logs (#8649)
* chore: rename startup logs to agent logs

This also adds a `source` property to every agent log. It
should allow us to group logs and display them nicer in
the UI as they stream in.

* Fix migration order

* Fix naming

* Rename the frontend

* Fix tests

* Fix down migration

* Match enums for workspace agent logs

* Fix inserting log source

* Fix migration order

* Fix logs tests

* Fix psql insert
2023-07-28 15:57:23 +00:00
Bruno Quaresma 78b06397a6 fix(site): fix metadata value changing width all the time (#8780) 2023-07-28 09:59:49 -03:00
Muhammad Atif Ali ea2ae10bc3 ci: update terraform to ~1.5 (#8766)
* ci: update terraform to 1.5.3

* Update action.yaml
2023-07-28 10:12:06 +00:00
Muhammad Atif Ali e029df61ff ci: update secret name in pr-cleanup.yaml (#8790) 2023-07-28 08:26:11 +00:00
Bruno Quaresma e8f82538e8 refactor(site): sort proxies in navbar by latency (#8781) 2023-07-27 21:50:11 -03:00
Kyle Carberry 91a0c7abe0 fix: improve the language of the template insights page (#8777) 2023-07-27 21:04:28 +00:00
Bruno Quaresma 471dc6126c chore: upgrade nodejs version to 18.x (#8768) 2023-07-27 17:54:38 -03:00
Bruno Quaresma 3114a60e5c ci: optimize chromatic (#8776)
* Update ci.yaml

Modified the Chromatic job configuration to reduce snapshot usage and only run Chromatic on necessary UI changes.

Signed-off-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>

* fix fmt

---------

Signed-off-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
Co-authored-by: Reuben Ellis <ethriel3695@gmail.com>
2023-07-27 15:51:26 -03:00
dependabot[bot] c236a29307 chore: bump google.golang.org/grpc from 1.56.2 to 1.57.0 (#8757)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-27 12:49:13 -05:00
Bruno Quaresma 4d36b859d2 refactor(site): make few ui changes on template insights (#8774) 2023-07-27 14:37:04 -03:00
Cian Johnston 5c9167df36 chore(helm): update sample resource requests/limits (#8773)
The sample resource requests/limits are undersized.
2023-07-27 13:28:06 -04:00
dependabot[bot] ca710e52b6 chore: bump google.golang.org/api from 0.133.0 to 0.134.0 (#8756)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-27 16:50:18 +00:00
Yinon Avraham de60bff88e chore(docs): small fixes in JFrog integration docs (#8736) 2023-07-27 11:46:06 -05:00
Ammar Bandukwala edd9628aa6 fix(cli): correctly print deprecated warnings (#8771)
In the previous implementation, it was possible for default-set values
to trigger the deprecation warning.
2023-07-27 16:42:18 +00:00
Kyle Carberry ff794e4b23 chore: add e2e test for backwards ssh compatibility (#8761)
* chore: add e2e test for backwards ssh compatibility

* Use the SSH client directly

* fmt
2023-07-27 10:42:11 -05:00
Ben Potter 34dfbfa9d3 ci: add DB to PR deploys (#8770)
* ci: add DB to PR deploys

* add bitnami remo

* fix namespace

* change ingress host

* remove wildcard host
2023-07-27 14:50:53 +00:00
dependabot[bot] 975424b3a2 chore: bump the eslint group in /site with 5 updates (#8636)
* chore: bump the eslint group in /site with 5 updates

Bumps the eslint group in /site with 5 updates:

| Package | Update |
| --- | --- |
| [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) | 5.62.0 to 6.1.0 |
| [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) | 5.62.0 to 6.1.0 |
| [eslint](https://github.com/eslint/eslint) | 8.44.0 to 8.45.0 |
| [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) | 7.31.1 to 7.33.0 |
| [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) | 47.0.0 to 48.0.0 |


Updates `@typescript-eslint/eslint-plugin` from 5.62.0 to 6.1.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/v6.1.0/packages/eslint-plugin)

Updates `@typescript-eslint/parser` from 5.62.0 to 6.1.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/v6.1.0/packages/parser)

Updates `eslint` from 8.44.0 to 8.45.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.44.0...v8.45.0)

Updates `eslint-plugin-react` from 7.31.1 to 7.33.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.31.1...v7.33.0)

Updates `eslint-plugin-unicorn` from 47.0.0 to 48.0.0
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v47.0.0...v48.0.0)

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

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

* ignore no-redundant-type-constituents

* Fix minor lint errors

* Discard changes to site/.eslintrc.yaml

* Fix redudant types

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Atif Ali <atif@coder.com>
Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
Co-authored-by: Muhammad Atif Ali <matifali@live.com>
2023-07-27 10:51:18 -03:00
Muhammad Atif Ali 92798e957f chore: bump typescript from 4.8.2 to 5.1.6 in /site (#8688) 2023-07-27 10:21:38 -03:00
Muhammad Atif Ali f6c36d903e ci: prevent running deploy on all comments (#8767) 2023-07-27 13:00:00 +00:00
Muhammad Atif Ali 3761205bae ci: further improve pr deployments (#8764) 2023-07-27 12:40:59 +00:00
Bruno Quaresma e85b88ca90 feat(site): add restart button when workspace is unhealthy (#8765) 2023-07-27 09:20:24 -03:00
Bruno Quaresma f54d385266 feat(site): add auto mode on create workspace form (#8651) 2023-07-27 08:47:58 -03:00
Muhammad Atif Ali bc55ffdf0d ci: improve deploy-pr workflow (#8735) 2023-07-27 13:07:53 +03:00
Cian Johnston 32829080ac feat(cli): add dashboard load test command (#8723) 2023-07-27 09:40:13 +01:00
Jon Ayers c3aface285 fix: fix coder stat mem (#8762)
- For cgroups v1 the wrong cgroup file was being read
  to determine max memory. This commit updates the file
  from '/sys/fs/cgroup/memory/memory.max_usage_in_bytes' to
  '/sys/fs/cgroup/memory/memory.limit_in_bytes'
2023-07-27 09:33:43 +01:00
Colin Adler 74c4553a3f fix(codersdk): always dial agents with WorkspaceAgentIP (#8760) 2023-07-27 03:44:44 +00:00
dependabot[bot] 7b08be8000 chore: bump google.golang.org/api from 0.132.0 to 0.133.0 (#8746)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-26 18:53:06 -05:00
Colin Adler 2811ab62d0 chore: fix workspace proxy flake (#8755) 2023-07-26 23:50:25 +00:00
Colin Adler 5cfa7082d1 chore: attempt to fix windows goleak failures (#8753) 2023-07-26 18:50:13 -05:00
Colin Adler 6af1f6a9d9 chore: fix Test_parseInsightsStartAndEndTime test (#8754) 2023-07-26 23:27:30 +00:00
Colin Adler dd2f79995b chore(tailnet): rewrite coordinator debug using html/template (#8752) 2023-07-26 22:54:21 +00:00
Ammar Bandukwala 02550a9062 fix(cli): apply log-filter to debug logs only (#8751) 2023-07-26 22:31:41 +00:00
Kyle Carberry 131babfb00 fix: request trial after password is validated (#8750) 2023-07-26 22:04:15 +00:00
Ammar Bandukwala 25e30c6f41 feat(cli): support fine-grained server log filtering (#8748) 2023-07-26 16:46:22 -05:00
Bruno Quaresma 4e9e480cc6 fix(site): fix latency values (#8749) 2023-07-26 17:14:45 -03:00
Ammar Bandukwala f28bac1b05 chore(scripts): use fake semver when using sapling (#8747)
The fact that the Sapling commit didn't conform to semver
broke the agent handshake with coderd.
2023-07-26 20:00:21 +00:00
Colin Adler 6b92abebb9 fix(tailnet): track agent names for http debug (#8744) 2023-07-26 18:44:10 +00:00
Bruno Quaresma b5dec61cd5 feat(site): show metadata stale data (#8745) 2023-07-26 15:41:07 -03:00
Dean Sheather 9ffbdc6696 hotfix: fix failed 32-bit builds (#8741) 2023-07-26 17:30:47 +00:00
Dean Sheather 2f0a9996e7 chore: add derpserver to wsproxy, add proxies to derpmap (#7311) 2023-07-27 02:21:04 +10:00
Marcin Tojek 70692c2e4e fix: unify parameter validation errors (#8738) 2023-07-26 17:44:50 +02:00
Steven Masley 2089006fbc feat!: drop reading other 'user' permission (#8650)
* feat: drop reading other 'user' permission

Members of the platform can no longer read or list other users.
Resources that have "created_by" or "initiated_by" still retain
user context, but only include username and avatar url.

Attempting to read a user found via those means will result in
a 404.

* Hide /users page for regular users
* make groups a privledged endpoint
* Permissions page for template perms
* Admin for a given template enables an endpoint for listing users/groups.
2023-07-26 10:33:48 -04:00
Bruno Quaresma 8649a10441 feat(site): add template insights page (#8722) 2023-07-26 13:13:56 +00:00
Muhammad Atif Ali da7e1eb75d ci: add a missing end quote (#8734) 2023-07-26 00:39:00 +00:00
Muhammad Atif Ali 0b5a01aa1b test: fix comments in deploy-pr.yaml (#8733) 2023-07-26 00:06:59 +00:00
Muhammad Atif Ali 26264bd3ef test: remove erroneous quotes from deploy-pr.yaml (#8732) 2023-07-25 23:16:57 +00:00
Muhammad Atif Ali 2c7d8ee06a fix: remove the usage of -u flag (#8731) 2023-07-25 22:54:42 +00:00
Colin Adler f07d2ff68d fix(enterprise): ensure creating a SCIM user is idempotent (#8730) 2023-07-25 17:49:52 -05:00
Muhammad Atif Ali 0feb855b8f fix: revert back to curl in deply-pr.yaml (#8729) 2023-07-25 22:40:26 +00:00
Muhammad Atif Ali 733ae5038a fix: a small issue with pr_deploy.yaml (#8728) 2023-07-25 22:15:44 +00:00
Muhammad Atif Ali 86d4c4ff0e test: improve pr deployments (#8720) 2023-07-26 00:56:38 +03:00
Muhammad Atif Ali 844ef76d39 fix: handle issue_comment event (#8726) 2023-07-25 19:52:44 +00:00
Muhammad Atif Ali 67f1123808 use gh cli (#8725) 2023-07-25 19:35:28 +00:00
Ammar Bandukwala ee652d525d docs: explain how to install the JFrog VS Code extension (#8724) 2023-07-25 18:06:30 +00:00
Muhammad Atif Ali 7447bfa320 fix: checkout correct branch for PR deployment (#8721) 2023-07-25 16:08:44 +00:00
Bruno Quaresma dfb1a1df3a feat(site): add terminal icon (#8719) 2023-07-25 11:41:29 -03:00
Ammar Bandukwala 2a01747804 feat(cli): add --var shorthand for --variable (#8710)
`--variable` is used frequently enough to deserve a shorthand. Unfortunately,
`-v` is taken by verbose, and `-V` is too easily confused with version or
verbose, so we're left with "--var".
2023-07-25 14:36:02 +00:00
Bruno Quaresma 30e16052d6 fix(coderd): update icon url to the right one (#8718) 2023-07-25 14:06:58 +00:00
Steven Masley de1a7a9210 chore: join user information to workspace_build and template_version (#8625)
* include minimial user on template version and build
* Add unit test to ensure join is superset
2023-07-25 09:14:38 -04:00
Bruno Quaresma fbb2a6a434 refactor(coderd): add avatar URL to the users' latency endpoint (#8701) 2023-07-25 12:15:46 +02:00
Marcin Tojek 7004013537 chore: update nix flake to include sqlc v1.19.1 (#8715) 2023-07-25 09:09:16 +00:00
Ammar Bandukwala f6f61dfa26 docs: fix duplicate sentence (#8712)
Resolves #8664
2023-07-25 02:22:41 +00:00
Ammar Bandukwala b8e792bf8a chore: make update-golden-files (#8711)
One of the recent helm changes snuck in CI breakage.
2023-07-25 01:18:53 +00:00
Ammar Bandukwala 5eb825155e docs: slightly improve wording in jfrog.md (#8709) 2023-07-24 20:05:54 -05:00
Ammar Bandukwala a0f478c02f docs: cleanup jfrog (#8708)
* Add a missing requirement
* Improve English
2023-07-24 19:29:30 -05:00
Ammar Bandukwala 8686b7a499 docs: explain JFrog integration 🐸 (#8682) 2023-07-24 23:16:09 +00:00
Eric Paulsen 29963433ee feat(helm)!: set enableDeployments default to true (#8704) 2023-07-24 17:13:28 -05:00
Eric Paulsen 353bfb618c fix: missing manifest for deployment logs doc (#8703) 2023-07-24 17:12:48 -05:00
Ben Potter adbabe4e09 fix: hide experiment CTA from OIDC copy (#8695) 2023-07-24 14:51:28 -05:00
Steven Masley ac559f101e fix: handle omitted role sync claim (#8697)
* fix: handle omitted role sync claim
2023-07-24 15:50:23 -04:00
Bruno Quaresma ac973a4b2c fix(site): fix error 'Reduce of empty array with no initial value' (#8700) 2023-07-24 14:17:27 -03:00
Ammar Bandukwala c32085ca10 chore(scripts): handle Sapling in version.sh (#8687) 2023-07-24 11:11:46 -05:00
Muhammad Atif Ali 6929792a58 docs: add coder-logstream-kube docs and update k8s example template (#8675)
* docs: add kubestream docs and update example template

* make fmt

* add to template's README

* add the seperate page

* make fmt

* make fmt

* add namespace to deployment resource

* fmt

* add screenshots

* link docs in template

* Add remaining examples

* enable deployments requirement

* Update deployment-logs.md

* rewording

* fix spelling

* how?

* cleanup

* Update docs/platforms/kubernetes/deployment-logs.md

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

* suggestions

* use online link

* refine

---------

Co-authored-by: Eric <ericpaulsen@coder.com>
Co-authored-by: Ben Potter <ben@coder.com>
2023-07-24 11:51:25 -04:00
Marcin Tojek b7ced94f0f fix: prevent repetition of template IDs in template_usage_by_day (#8693) 2023-07-24 15:07:01 +02:00
Steven Masley f827829afe feat: synchronize oidc user roles (#8595)
* feat: oidc user role sync
User roles come from oidc claims. Prevent manual user role changes
if set.
* allow mapping 1:many
2023-07-24 08:34:24 -04:00
dependabot[bot] 94541d201f chore: bump react-chartjs-2 in /site from 4.3.1 to 5.2.0 (#8632)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-07-24 14:44:14 +03:00
dependabot[bot] 75265ecf68 chore: bump fs-extra from 10.1.0 to 11.1.1 in /offlinedocs (#8630)
Bumps [fs-extra](https://github.com/jprichardson/node-fs-extra) from 10.1.0 to 11.1.1.
- [Changelog](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jprichardson/node-fs-extra/compare/10.1.0...11.1.1)

---
updated-dependencies:
- dependency-name: fs-extra
  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-24 14:25:55 +03:00
dependabot[bot] 0f915e1e75 chore: bump @types/react-dom from 18.0.5 to 18.2.7 in /offlinedocs (#8671)
Bumps [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) from 18.0.5 to 18.2.7.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-dom)

---
updated-dependencies:
- dependency-name: "@types/react-dom"
  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-24 11:21:33 +00:00
dependabot[bot] 625eef93c5 chore: bump next from 12.1.6 to 13.4.12 in /offlinedocs (#8669)
Bumps [next](https://github.com/vercel/next.js) from 12.1.6 to 13.4.12.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](https://github.com/vercel/next.js/compare/v12.1.6...v13.4.12)

---
updated-dependencies:
- dependency-name: next
  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-24 14:17:08 +03:00
dependabot[bot] c136fa9e52 chore: bump @types/react from 18.0.14 to 18.2.15 in /offlinedocs (#8672)
Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.0.14 to 18.2.15.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

---
updated-dependencies:
- dependency-name: "@types/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>
2023-07-24 14:16:57 +03:00
dependabot[bot] d54bc60842 chore: bump react-icons from 4.4.0 to 4.10.1 in /offlinedocs (#8673)
Bumps [react-icons](https://github.com/react-icons/react-icons) from 4.4.0 to 4.10.1.
- [Release notes](https://github.com/react-icons/react-icons/releases)
- [Commits](https://github.com/react-icons/react-icons/compare/v4.4.0...v4.10.1)

---
updated-dependencies:
- dependency-name: react-icons
  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-24 14:16:44 +03:00
Muhammad Atif Ali 757ea68d4a ci: fmt, lint and build offlinedocs (#8642)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-07-24 10:54:08 +00:00
Muhammad Atif Ali 87f07b9f2f ci: reduce duplication (#8692)
* ci: reduce duplication

* typo
2023-07-24 10:51:43 +00:00
Muhammad Atif Ali 196b29983b docs: fix a broken link (#8691) 2023-07-24 09:13:59 +00:00
Ammar Bandukwala c3b8898f0a fix(coderd/unhanger): de-duplicate logs (#8686)
The final warning just repeated previous lines.
2023-07-24 14:28:09 +10:00
Ammar Bandukwala c9ade6f6c5 chore: enforce that site icons are .svg (#8684) 2023-07-23 16:27:11 -05:00
Ammar Bandukwala d56bf52141 chore(scripts): support Sapling in project_root (#8685) 2023-07-23 15:59:49 -05:00
Ammar Bandukwala 9833cd32b3 Revert "chore(scripts): support sappling in project_root"
This reverts commit 6855735085.

This was pushed accidentally.
2023-07-23 19:40:28 +00:00
Ammar Bandukwala 6855735085 chore(scripts): support sappling in project_root 2023-07-23 19:34:44 +00:00
Muhammad Atif Ali 43cc5449a1 fix: fix a typo in deploy-pr.yaml (#8678) 2023-07-23 16:21:29 +00:00
Muhammad Atif Ali 30e86e0058 chore: do not deploy a PR on deleted comment (#8677)
* chore: improve deploy-pr.yaml

* Update pr-deploy.yaml

* make fmt
2023-07-23 19:06:24 +03:00
Muhammad Atif Ali e7330436c9 chore: insatll coder-logstream-kube for PR deployments (#8676) 2023-07-23 15:35:53 +00:00
Muhammad Atif Ali ec880f26b4 chore: enable deployments for PR deplyments (#8674) 2023-07-23 17:32:17 +03:00
Sebastiaan ten Pas a28883d9f0 fix: do not wait for devcontainer template volume claim bound (#8539) 2023-07-23 06:06:23 +00:00
dependabot[bot] 1cadfa4e4f chore: bump the storybook group in /site with 6 updates (#8635)
Bumps the storybook group in /site with 6 updates:

| Package | Update |
| --- | --- |
| [@storybook/addon-actions](https://github.com/storybookjs/storybook/tree/HEAD/code/addons/actions) | 7.0.26 to 7.1.0 |
| [@storybook/addon-essentials](https://github.com/storybookjs/storybook/tree/HEAD/code/addons/essentials) | 7.0.26 to 7.1.0 |
| [@storybook/addon-links](https://github.com/storybookjs/storybook/tree/HEAD/code/addons/links) | 7.0.26 to 7.1.0 |
| [@storybook/addon-mdx-gfm](https://github.com/storybookjs/storybook/tree/HEAD/code/addons/gfm) | 7.0.26 to 7.1.0 |
| [@storybook/react-vite](https://github.com/storybookjs/storybook/tree/HEAD/code/frameworks/react-vite) | 7.0.26 to 7.1.0 |
| [storybook](https://github.com/storybookjs/storybook/tree/HEAD/code/lib/cli) | 7.0.26 to 7.1.0 |


Updates `@storybook/addon-actions` from 7.0.26 to 7.1.0
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/next/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v7.1.0/code/addons/actions)

Updates `@storybook/addon-essentials` from 7.0.26 to 7.1.0
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/next/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v7.1.0/code/addons/essentials)

Updates `@storybook/addon-links` from 7.0.26 to 7.1.0
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/next/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v7.1.0/code/addons/links)

Updates `@storybook/addon-mdx-gfm` from 7.0.26 to 7.1.0
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/next/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v7.1.0/code/addons/gfm)

Updates `@storybook/react-vite` from 7.0.26 to 7.1.0
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/next/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v7.1.0/code/frameworks/react-vite)

Updates `storybook` from 7.0.26 to 7.1.0
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/next/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v7.1.0/code/lib/cli)

---
updated-dependencies:
- dependency-name: "@storybook/addon-actions"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: storybook
- dependency-name: "@storybook/addon-essentials"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: storybook
- dependency-name: "@storybook/addon-links"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: storybook
- dependency-name: "@storybook/addon-mdx-gfm"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: storybook
- dependency-name: "@storybook/react-vite"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: storybook
- dependency-name: storybook
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: storybook
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-23 01:00:42 +03:00
dependabot[bot] 9a7729d60f chore: bump @testing-library/jest-dom from 5.16.5 to 5.17.0 in /site (#8670)
Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 5.16.5 to 5.17.0.
- [Release notes](https://github.com/testing-library/jest-dom/releases)
- [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/jest-dom/compare/v5.16.5...v5.17.0)

---
updated-dependencies:
- dependency-name: "@testing-library/jest-dom"
  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-22 21:46:39 +00:00
dependabot[bot] 82310896ad chore: bump eslint from 8.17.0 to 8.45.0 in /offlinedocs (#8631)
Bumps [eslint](https://github.com/eslint/eslint) from 8.17.0 to 8.45.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.17.0...v8.45.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-07-22 21:39:59 +00:00
dependabot[bot] aae7175a83 chore: bump @chakra-ui/react from 2.7.1 to 2.8.0 in /offlinedocs (#8633)
Bumps [@chakra-ui/react](https://github.com/chakra-ui/chakra-ui/tree/HEAD/packages/components/react) from 2.7.1 to 2.8.0.
- [Release notes](https://github.com/chakra-ui/chakra-ui/releases)
- [Changelog](https://github.com/chakra-ui/chakra-ui/blob/main/packages/components/react/CHANGELOG.md)
- [Commits](https://github.com/chakra-ui/chakra-ui/commits/@chakra-ui/react@2.8.0/packages/components/react)

---
updated-dependencies:
- dependency-name: "@chakra-ui/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-07-23 00:34:23 +03:00
dependabot[bot] e056d0243a chore: bump @tanstack/react-query from 4.29.19 to 4.32.0 in /site (#8668)
Bumps [@tanstack/react-query](https://github.com/tanstack/query) from 4.29.19 to 4.32.0.
- [Release notes](https://github.com/tanstack/query/releases)
- [Commits](https://github.com/tanstack/query/compare/v4.29.19...v4.32.0)

---
updated-dependencies:
- dependency-name: "@tanstack/react-query"
  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-22 21:33:18 +00:00
dependabot[bot] a9036ed02b chore: bump chromatic from 6.19.9 to 6.20.0 in /site (#8667)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.19.9 to 6.20.0.
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.19.9...v6.20.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-07-22 21:31:50 +00:00
dependabot[bot] b7db4ee69f chore: bump eslint-config-next from 12.1.6 to 13.4.10 in /offlinedocs (#8629)
Bumps [eslint-config-next](https://github.com/vercel/next.js/tree/HEAD/packages/eslint-config-next) from 12.1.6 to 13.4.10.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](https://github.com/vercel/next.js/commits/v13.4.10/packages/eslint-config-next)

---
updated-dependencies:
- dependency-name: eslint-config-next
  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-23 00:28:56 +03:00
Mathias Fredriksson e0c1aacac1 fix(coderd): fix template insight intervals (#8662) 2023-07-21 20:51:35 +00:00
Jyotirmoy Bandyopadhyaya 65583eca47 feat(cli): check if dotfiles install script is executable (#8588)
* feat(cli): check if dotfiles install script is executable

* feat(docs): add section for dotfiles setup and document executable fix

---------

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Co-authored-by: Muhammad Atif Ali <matifali@live.com>
2023-07-21 18:39:50 +00:00
Bruno Quaresma 7f67000b90 fix(site): send build parameters over the confirmation dialog on restart (#8660) 2023-07-21 12:35:28 -06:00
Mathias Fredriksson 30fe153296 feat(coderd): add user latency and template insights endpoints (#8519)
Part of #8514
Refs #8109
2023-07-21 18:00:19 +00:00
Cian Johnston 539fcf9e6b chore(coderd/util/tz): skip flaky test (#8652) 2023-07-21 16:31:52 +00:00
Eric Paulsen 001670cc13 docs: add steps for postgres SSL cert config (#8648)
* docs: add steps for postgres SSL cert config

* make fmt

* Update docs/install/kubernetes.md

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

* fixup! Update docs/install/kubernetes.md

---------

Co-authored-by: Cian Johnston <cian@coder.com>
2023-07-21 10:36:11 -04:00
Ben Potter 1a915f5b30 chore: improve workspace proxy copy (#8427)
* chore: workspace proxy copy

* fmt
2023-07-21 13:34:29 +00:00
Ben Potter 12b51ca804 ci: fix release notes compare link (#8581)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-07-21 15:22:54 +03:00
Marcin Tojek c8772fba82 chore: update nix flake to include sqlc v1.19.0 (#8645) 2023-07-21 14:21:44 +02:00
Cian Johnston fd372f6735 fix(cli/clistat): improve detection of container environment (#8643)
Use the presence of /var/run/secrets/kubernetes.io/serviceaccount/token to determine if we are in a container in addition to sniffing /proc/1/cgroup
2023-07-21 10:18:56 +00:00
dependabot[bot] 87d5cdaf58 chore: bump ts-proto from 1.153.2 to 1.156.0 in /site (#8637)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-21 10:49:25 +03:00
Colin Adler 2901147ae3 test: fix race in templateedit_test.go (#8641) 2023-07-21 03:26:55 +00:00
Jon Ayers b47d076756 feat: add deleting_at column to workspaces (#8333) 2023-07-20 22:01:11 -05:00
Muhammad Atif Ali 0c73164f15 chore: add offlinedocs to ts filter in ci.yaml (#8616) 2023-07-20 20:33:50 +00:00
dependabot[bot] 2d3d78b5b1 chore: bump google.golang.org/api from 0.131.0 to 0.132.0 (#8596)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.131.0 to 0.132.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.131.0...v0.132.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-20 23:13:07 +03:00
Muhammad Atif Ali cc659163ef chore: add offlinedocs to depemdabot.yaml (#8617)
Add offlinedocs to depemdabot.yaml
2023-07-20 23:12:08 +03:00
Colin Adler 830020df15 fix(site): don't mark metadata with interval: 0 as stale (#8627) 2023-07-20 15:05:32 -05:00
Colin Adler 1cb39fc65d test: ignore more spurious pgcoord errors (#8628) 2023-07-20 19:55:25 +00:00
Colin Adler 71d4e4e6e8 fix(agent): check agent metadata every second instead of minute (#8614) 2023-07-20 14:02:58 -05:00
Colin Adler c8d65de4b7 test(agent): fix TestAgent_Metadata/Once flake (#8613) 2023-07-20 18:49:44 +00:00
Muhammad Atif Ali deb9261232 ci: allow running other jobs in the matrix if one of them fails (#8624) 2023-07-20 15:56:47 +00:00
Muhammad Atif Ali fd5d26d385 chore: prevent running chromatic on all merged PRs (#8623) 2023-07-20 15:18:02 +00:00
Bruno Quaresma 6de95f4f32 chore(site): remove build logs from experimental (#8619) 2023-07-20 15:02:19 +00:00
Dean Sheather dc8b73168e feat: add user quiet hours schedule and restart requirement feature flag (#8115) 2023-07-20 23:35:41 +10:00
Ben Potter 4821e2e6d8 chore: add jq to base image (#8563)
* chore: add jq to base image

* fix formatting
2023-07-20 07:04:56 -05:00
Cian Johnston 68a46198d3 fix(scaletest): deploy external provisionerd (#8618)
* scaletest: stop kubernetes_secret from being constantly recreated
* scaletest: ensure we do not get auto-upgraded
* scaletest: add external provisionerd deployment, the lazy way
2023-07-20 11:38:46 +01:00
Marcin Tojek 9689bca5d2 feat(cli): implement ssh remote forward (#8515) 2023-07-20 12:05:39 +02:00
dependabot[bot] c68e80970d chore: bump semver from 6.3.0 to 6.3.1 in /offlinedocs (#8600)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-20 10:14:09 +03:00
dependabot[bot] bd5eb9dc1b chore: bump word-wrap from 1.2.3 to 1.2.4 in /offlinedocs (#8598)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-20 10:14:00 +03:00
dependabot[bot] b16901485e chore: bump json5 from 1.0.1 to 1.0.2 in /offlinedocs (#8599)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-20 10:13:27 +03:00
Colin Adler 39889179ea test(coderd): fix TestWorkspaceWatcher flake (#8612) 2023-07-19 18:03:56 -05:00
Jon Ayers 80b940c556 feat: support localhost apps running https (#8585) 2023-07-19 17:33:07 -05:00
Colin Adler 00b9a3ce58 fix: prevent error log when pgcoord query is canceled (#8609) 2023-07-19 16:40:57 -05:00
Steven Masley aceedefce3 chore: add template_with_user view to include user contextual data (#8568)
* chore: Refactor template sql queries to use new view
* TemplateWithUser -> Template
* Add unit test to enforce good view
2023-07-19 16:07:33 -04:00
Ben Potter cdbae29a83 fix: agent health copy (#8608)
* fix: agent health copy

* remove restart in place of upcoming button
2023-07-19 19:56:23 +00:00
Bruno Quaresma d96a6575af docs: add link to CODER_DOCS_URL (#8606) 2023-07-19 19:47:38 +00:00
Bruno Quaresma 16cd1a675c docs: add documentation about the offline docs (#8603) 2023-07-19 13:51:44 -05:00
Bruno Quaresma 0e52461624 feat(site): add support for custom docs url (#8601) 2023-07-19 15:27:38 -03:00
Colin Adler f8a2bd0f4d chore: remove duplicate logger name in wsproxy ServerTailnet (#8604) 2023-07-19 18:06:26 +00:00
Ben Potter b4bb77f2f3 hotfix: change permissions for /deploy-pr comment (#8597) 2023-07-19 17:02:51 +00:00
Bruno Quaresma acc12d3426 feat: add offline docs (#8527) 2023-07-19 13:57:57 -03:00
Marcin Tojek 164672e5d3 feat: expose docs URL via static meta (#8594) 2023-07-19 13:57:43 -03:00
Colin Adler 517fb19474 feat: add single tailnet support to moons (#8587) 2023-07-19 11:11:11 -05:00
Colin Adler cc8d0af027 fix(enterprise): avoid initial license reconfig if feature isn't enabled (#8586) 2023-07-19 10:32:29 -05:00
Cian Johnston 0965a2de70 fix(cli/clistat): read from alternate cgroup path (#8591)
* Attempts reading cgroupv1 quota, period, usage from /sys/fs/cgroup/cpu,cpuacct by default
* Fall back to /sys/fs/cgroup/cpu for v1 quota and period
* Fall back to /sys/fs/cgroup/cpuacct for v1 usage

Fixes https://github.com/coder/coder/issues/8468
2023-07-19 16:25:26 +01:00
Josh Vawdrey 6318c4c09f feat(site): increase TTL and max TTL validation to 30 days (#8258)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-07-19 23:43:10 +10:00
Marcin Tojek 4232a2eb96 feat: add custom docs URL to deployment config (#8590) 2023-07-19 08:31:17 -03:00
Eric Paulsen 164b816679 feat(helm): add commandArgs for custom entrypoint (#8567) 2023-07-19 00:50:52 +00:00
Mathias Fredriksson 611fbd8215 test(coderd): fix TestWorkspaceWatcher skipped pending state (#8584) 2023-07-18 21:58:50 +03:00
Bruno Quaresma d12221c782 feat(site): add build parameters option when starting or restarting a workspace (#8524) 2023-07-18 14:53:26 -03:00
Mathias Fredriksson 2fae9b0a69 chore(scripts/dbgen): only add arg validation for dbfake (#8578) 2023-07-18 17:26:03 +00:00
Kyle Carberry 98164f687e fix!: remove startup logs eof for streaming (#8528)
* fix: remove startup logs eof for streaming

We have external utilities like logstream-kube that may send
logs after an agent shuts down unexpectedly to report additional
information. In a recent change we stopped accepting these logs,
which broke these utilities.

In the future we'll rename startup logs to agent logs or something
more generalized so this is less confusing in the future.

* fix(cli/cliui): handle never ending startup log stream in Agent

---------

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-07-18 09:57:29 -06:00
Mathias Fredriksson 58265881af test(testutil): increase wait times to reduce flakes (#8576) 2023-07-18 17:25:54 +03:00
Muhammad Atif Ali 9e170a7332 chore: add filebrowser to dogfood (#8535) 2023-07-18 17:04:00 +03:00
Cian Johnston 278527cff4 feat(scaletest): add option to send traffic over SSH (#8521)
- Refactors the metrics logic to avoid needing to pass in a whole prometheus registry
- Adds an --ssh option to the workspace-traffic command to send SSH traffic

Fixes #8242
2023-07-18 12:17:11 +01:00
Marcin Tojek ab54008c94 feat: make ephemeral parameters optional (#8571) 2023-07-18 11:56:41 +02:00
Muhammad Atif Ali 7d92537af5 chore: fix a typo dogfood.yaml (#8572) 2023-07-18 09:51:46 +00:00
Muhammad Atif Ali b012b4a810 chore: use commit title as template message in dogfood (#8570)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-07-18 09:08:58 +00:00
Mathias Fredriksson d467160581 feat(cli): show workspace health in show (#8548) 2023-07-18 11:28:47 +03:00
dependabot[bot] 6b978bef71 chore: bump the github-actions group with 1 update (#8544)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-17 19:58:03 +00:00
Colin Adler fd7c019fff chore(coderd): require api key to access derpmap (#8569) 2023-07-17 19:40:12 +00:00
Bruno Quaresma a823ce7337 refactor(site): add sticky option to the build logs (#8565) 2023-07-17 14:58:25 -03:00
Bruno Quaresma 0bf1b01a9d fix(site): remove extra spacing on template variables page 2023-07-17 14:58:06 -03:00
Cian Johnston 56889d6cd4 fix(cli): unskip TestStatCPUCmd/JSON and explicitly set --host in test cmd invocation (#8558)
- Un-skips TestStatCPUCmd/JSON
- Explicitly sets --host flag when running the cli tests for the stat command as when these are invoked inside a container without a CPU or memory limit set, these tests may fail.
2023-07-17 17:24:46 +01:00
Mathias Fredriksson 854643236a chore(go.mod): update gvisor via github.com/coder/gvisor fork (#8561)
Fixes #7388
2023-07-17 16:09:26 +00:00
Muhammad Atif Ali bf5e0675fe chore: allow running multiple preview deployments in parallel (#8562) 2023-07-17 16:06:29 +00:00
Muhammad Atif Ali 0a56ea6916 chore: do not cancel in progress runs in pr-deploy.yaml (#8559) 2023-07-17 18:40:25 +03:00
Muhammad Atif Ali db8ba6cb68 chore: remove buggy comment reaction from deploy-pr.yaml (#8555) 2023-07-17 18:29:40 +03:00
Bruno Quaresma c83975cee0 fix(site): fix bottom border on build logs (#8554) 2023-07-17 11:57:24 -03:00
Bruno Quaresma 2218160e35 refactor(site): redirect the user to the workspace page after update parameters (#8553) 2023-07-17 11:26:24 -03:00
Steven Masley 67494a3012 chore: push GetUsers authorization filter to SQL (#8497)
* feat: push GetUsers filter to SQL
* Remove GetAuthorizedUserFilter
* Remove GetFilteredUserCount
* remove GetUsersWithCount
2023-07-17 09:44:58 -04:00
Mathias Fredriksson dfac0745f3 feat(cli): show workspace health in list (#8541)
Ref #6461
2023-07-17 15:04:06 +03:00
Alexander Hansen 616e1d7e9a Remove unmaintained 8Bitz0/coder-rust-template template (#8534) 2023-07-16 09:03:48 +00:00
sharkymark 3ea9699908 docs: added kubernetes option to workspace proxies (#8533) 2023-07-15 14:54:52 -05:00
Sebastiaan ten Pas dbc422f29e fix: devcontainer template workspace directory (#8530) 2023-07-15 09:04:51 +00:00
Muhammad Atif Ali ce114a7f9f chore: upgrade sqlc to 1.19.1 (#8511) 2023-07-15 09:07:19 +03:00
Dean Sheather 7a62534359 fix: allow unhanger to unhang canceling jobs (#8529) 2023-07-15 01:54:57 +00:00
Asher 7ed17b2605 fix: add some missing workspace updates (#7790)
* Standardize on function to get workspace channel name

There were two, now there is one.

* Add some missing workspace updates

There are some failure cases where we do not set the type as a workspace
build which causes the workspace update to never be published.

* Make build failures warnings

Otherwise the associated test fails due to the logger fataling on
error messages.
2023-07-14 15:07:48 -08:00
Ammar Bandukwala 970a829939 ci: relax stalebot (#8522)
\#6243 and others suggest the stalebot is too aggressive.
2023-07-14 16:38:04 +00:00
Cian Johnston 52b4563106 fix(scripts/develop.sh): use correct variables-file arg for template create (#8520) 2023-07-14 16:31:29 +00:00
Steven Masley 4c4d966c7b feat: add ability to make workspace for other user from cli (#8481)
* feat: add ability to make workspace for other user from cli
* Add example to show functionality
2023-07-14 09:48:02 -04:00
Mathias Fredriksson 5fd77ad7cf test(agent): fix service banner and metadata intervals (#8516) 2023-07-14 16:10:26 +03:00
Marcin Tojek b7806fd216 fix(site): paginate audit logs (#8513) 2023-07-14 12:24:30 +02:00
dependabot[bot] 9aae983821 chore: bump @fontsource/ibm-plex-mono from 4.5.10 to 5.0.5 in /site (#8512)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-14 01:38:45 +03:00
Muhammad Atif Ali be1013899f chore: use names for all GitHub actions steps and use sqlc setup action (#8495) 2023-07-13 22:46:18 +03:00
Colin Adler 132f1d0eb5 chore: fuzzy match alpine terraform version (#8506) 2023-07-13 14:36:45 -05:00
Bruno Quaresma dc52df940b chore: update coder tf provider on dogfood (#8503) 2023-07-13 14:50:23 -03:00
Dean Sheather ecee3ceeec chore: improve listener algorithm in apptest (#8502) 2023-07-13 17:34:14 +00:00
Steven Masley c2acc35d45 feat: add custom coder bin path for ProxyCommand (#8425)
* feat: add custom coder bin path for ProxyCommand
* force cli path to be absolute (on non-windows)
2023-07-13 13:17:39 -04:00
dependabot[bot] 47d5806e2c chore: bump monaco-editor from 0.39.0 to 0.40.0 in /site (#8475)
Bumps [monaco-editor](https://github.com/microsoft/monaco-editor) from 0.39.0 to 0.40.0.
- [Changelog](https://github.com/microsoft/monaco-editor/blob/main/CHANGELOG.md)
- [Commits](https://github.com/microsoft/monaco-editor/compare/v0.39.0...v0.40.0)

---
updated-dependencies:
- dependency-name: monaco-editor
  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-13 11:13:26 -06:00
Steven Masley 3b433181be chore: add custom querier functions to dbgen (#8496)
* chore: add custom querier functions to dbgen
* chore: parse package was missing some imports, so force them
2023-07-13 13:12:29 -04:00
dependabot[bot] b650ab40f0 chore: bump @tanstack/react-query from 4.22.4 to 4.29.19 in /site (#8488)
Bumps [@tanstack/react-query](https://github.com/tanstack/query) from 4.22.4 to 4.29.19.
- [Release notes](https://github.com/tanstack/query/releases)
- [Commits](https://github.com/tanstack/query/compare/v4.22.4...v4.29.19)

---
updated-dependencies:
- dependency-name: "@tanstack/react-query"
  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-13 10:58:36 -06:00
Muhammad Atif Ali 9249309d8e docs: add docs to use remote Docker host (#8479)
Co-authored-by: Ben Potter <ben@coder.com>
2023-07-13 14:41:15 +00:00
Bruno Quaresma b833861960 feat(site): display version message (#8435) 2023-07-13 10:36:10 -03:00
Ben Potter 44e25185ff docs: add custom API use cases (#8445) 2023-07-13 13:24:09 +00:00
Marcin Tojek ebdc510f12 fix(site): delete workspace action in audit log (#8494) 2023-07-13 14:43:10 +02:00
dependabot[bot] 24ec05b5c5 chore: bump prettier from 2.8.1 to 3.0.0 in /site (#8477)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Cian Johnston <cian@coder.com>
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-07-13 14:44:12 +03:00
Marcin Tojek 3727e02bbf feat(cli): add --create flag to templates push (#8454) 2023-07-13 12:58:34 +02:00
Marcin Tojek 5432c3f5ea feat(cli): support ephemeral parameters (#8415) 2023-07-13 12:56:02 +02:00
Cian Johnston cdf9b9045f fix(scaletest/terraform): fix prometheus namespace deps, disable auto-upgrade (#8490)
* hotfix(scaletest/terraform): fix prometheus namespace deps, disable auto-upgrade

* fixup! hotfix(scaletest/terraform): fix prometheus namespace deps, disable auto-upgrade
2023-07-13 10:54:57 +01:00
Mathias Fredriksson 70047ffd15 chore(scripts): use slim and always run make in coder-dev.sh (#8418) 2023-07-13 11:51:53 +03:00
Muhammad Atif Ali f21541c0e4 chore: update gh cli in dogfood Dockerfile (#8489) 2023-07-13 11:49:43 +03:00
dependabot[bot] 837f88d38e chore: bump ts-proto from 1.152.0 to 1.153.2 in /site (#8486)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-13 09:07:48 +03:00
Colin Adler d7cbdbd9c6 chore: replace wsconncache with a single tailnet (#8176) 2023-07-12 17:38:25 -05:00
Colin Adler c47b78c44b chore: replace wsconncache with a single tailnet (#8176) 2023-07-12 17:37:31 -05:00
dependabot[bot] 0a37dd20d6 chore: bump google.golang.org/api from 0.130.0 to 0.131.0 (#8482)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-13 00:15:04 +03:00
dependabot[bot] ecda87060a chore: bump @octokit/types from 10.0.0 to 11.1.0 in /site (#8483)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 23:26:34 +03:00
dependabot[bot] 1bd188db66 chore: bump @emoji-mart/data from 1.0.5 to 1.1.2 in /site (#8484)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 23:22:56 +03:00
dependabot[bot] 79772f2f3f chore: bump @playwright/test from 1.35.1 to 1.36.0 in /site (#8476)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 22:45:24 +03:00
dependabot[bot] 7fc5cce356 chore: bump cronstrue from 2.27.0 to 2.28.0 in /site (#8478)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 22:44:35 +03:00
Colin Adler b5c17048c6 chore: upgrade github.com/codeclysm/extract to v3.1.1 (#8480) 2023-07-12 14:33:46 -05:00
Muhammad Atif Ali a0fedebd62 chore: rename dependabot groups (#8473) 2023-07-12 17:01:57 +00:00
ElioDiNino d502de8ca8 docs: fix git credentials file name (#8406) 2023-07-12 20:00:15 +03:00
Bruno Quaresma f8f4ae8e2c refactor(site): update build log to be displayed only on active statuses (#8459) 2023-07-12 13:34:07 -03:00
Mathias Fredriksson 29e4205abf ci(scripts): add support for --force in release.sh (#8469) 2023-07-12 16:31:13 +00:00
dependabot[bot] ffc28e6b93 chore: bump xterm in /site from 5.1.0 to 5.2.1 (#8465)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 18:35:32 +03:00
Colin Adler 1c3bfacca3 fix(cli): ensure cliui.Agent doesn't fetch infinitely (#8446) 2023-07-12 10:21:54 -05:00
dependabot[bot] 14caa9b7c1 chore: bump the npm-eslint group in /site with 3 updates (#8464)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 18:21:02 +03:00
dependabot[bot] b62798303c chore: bump just-debounce-it from 3.1.1 to 3.2.0 in /site (#8466)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 18:11:36 +03:00
dependabot[bot] d7eeb4118e chore: bump the npm-mui group in /site with 3 updates (#8460)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 15:04:08 +00:00
dependabot[bot] 49081e0383 chore: bump @emotion/react from 11.10.8 to 11.11.1 in /site (#8380)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 17:58:24 +03:00
dependabot[bot] 861efe7b50 chore: bump the npm-xstate group in /site with 3 updates (#8461)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-12 17:56:52 +03:00
Muhammad Atif Ali 765fd29336 chore: upgrade go version to 1.20.6 (#8457) 2023-07-12 17:27:17 +03:00
Ben Potter 280112a366 docs: add devcontainer templates (#8256)
* start

* start a template

* basic structure

* Update docs/templates/devcontainers.md

Co-authored-by: Sebastiaan ten Pas <sebastiaan@diggimedia.nl>

* Update examples/templates/devcontainer-docker/main.tf

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

* add kubernetes template

* mention parameters

* fixups

* fixes from feedback

---------

Co-authored-by: Sebastiaan ten Pas <sebastiaan@diggimedia.nl>
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2023-07-12 10:22:39 -04:00
Muhammad Atif Ali 19f58350f2 chore: group various npm dependencies (#8453) 2023-07-12 16:45:50 +03:00
Bruno Quaresma bff73ade6a feat(site): add warning for unhealthy workspace (#8422) 2023-07-12 10:27:25 -03:00
dependabot[bot] 86f89892c8 chore: bump msw from 1.1.0 to 1.2.2 in /site (#8440)
Bumps [msw](https://github.com/mswjs/msw) from 1.1.0 to 1.2.2.
- [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/v1.1.0...v1.2.2)

---
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>
2023-07-12 10:26:51 -03:00
Mathias Fredriksson f6a8a5f7be fix(site): prevent ExtractAPIKey from dirtying the HTML output (#8450)
If `httpmw.ExtractAPIKey` fails when we are rendering an HTML page, the
HTML output will be dirtied with the error repsonse and the HTTP status
will also be wrong.

The use of this function in the `renderHTMLWithState` is additive, and
failure means we simply can't embed static data. To fix this, we can
simply pass a `http.ResponseWriter` that is no-op.

Fixes #8351
2023-07-12 15:38:30 +03:00
Steven Masley e9d7a230fa chore: server header specifies if wsproxy (#8432) 2023-07-12 12:07:36 +00:00
Steven Masley 928091aa05 feat!: add table format to 'coder license ls', 'license_expires' --> 'license_expires_human' (#8421)
* feat: add table format to 'coder license ls'
* feat: license expires_at to table view
* change: `license_expires` to `license_expires_human` and `license_expires` is unix timestamp
2023-07-12 08:06:18 -04:00
dependabot[bot] 2c2dd0eb83 chore: bump crate-ci/typos from v1.14.12 to v1.16.0 and fix typos (#8455)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Muhammad Atif Ali <atif@coder.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-07-12 12:01:30 +00:00
Muhammad Atif Ali 7a210d941e chore: remove invalid dependabot config for example templates (#8452) 2023-07-12 14:33:57 +03:00
Spike Curtis b4057bd74a feat: make pgCoordinator generally available (#8419)
* pgCoord to GA, fix tests

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

* Fix generation and coordinator delete RBAC

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

* Fix fakeQuerier -> FakeQuerier

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-07-12 13:35:29 +04:00
dependabot[bot] 2e9f3e0a6b chore: bump the go-otel group with 4 updates (#8437)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2023-07-11 17:12:59 -05:00
dependabot[bot] 13b9ed3240 chore: bump google.golang.org/api from 0.129.0 to 0.130.0 (#8438)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-11 20:50:23 +00:00
Colin Adler 2c0f653aa8 chore(dogfood): give Asher more ram (#8442) 2023-07-11 15:24:29 -05:00
Marcin Tojek bc835dbf69 fix: use numeric comparison to check monotonicity (#8436) 2023-07-11 22:08:41 +02:00
Eric Paulsen d8d8eb2c8d docs: add note on recommended Azure LB (#8431) 2023-07-11 18:19:45 +00:00
Colin Adler 21597e2d69 chore: upgrade Go to 1.20.6 (#8433) 2023-07-11 13:06:34 -05:00
goodspark dd4aafb350 feat: add template info tags to coderd_agents_up metric (#7942)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2023-07-11 12:39:14 -05:00
Mathias Fredriksson 398e8fdf89 fix(coderd/httpmw): handle oauth config removed for existing auth (#8420)
This commit fixes an edge case tied to unexpired oauth logins where the
oauth provider is removed, the server restarted, and the users auth
expiring after the fact.

Refs #8351, #8352, #8390
2023-07-11 20:29:29 +03:00
Mathias Fredriksson e508d9aa6e fix(agent/usershell): check shell on darwin via dscl (#8366) 2023-07-11 20:27:50 +03:00
Mathias Fredriksson de1d04d7bb fix(dogfood): use gcr.io/coder-dev-1/alpine mirror to fix rate limit (#8424) 2023-07-11 20:27:07 +03:00
Steven Masley 704212e271 feat: expand wsproxy settings page by default (#8428)
* feat: wsproxy settings page expanded by default
* chore: warnings & defaults on proxy setting page start open
* always expanded
2023-07-11 13:15:11 -04:00
Steven Masley 0a911d58f9 chore: change workspace proxy badge names (#8429)
* chore: "Not Reachable" --> "Not Dialable"
* chore: "Not registered" --> "Never seen"
2023-07-11 13:05:42 -04:00
Steven Masley f67ccc9bc0 feat: add resource_target to audit log search (#8423)
* feat: add resource_target to audit log search
2023-07-11 13:05:21 -04:00
Muhammad Atif Ali 700ec966e3 chore: use dogfood-oss image in .devcontainer (#8231)
* use dogfood-oss image in devcontainer

* fix image name

* use Dockerfile

* Discard changes to dogfood/Dockerfile

* Use features to get docker in docker

* use previleged container

* use codercom/oss-dogfood image

* add `--priviliged` to fix GitHub Codespaces builds

* remove default options
2023-07-11 10:48:34 -04:00
Steven Masley bc102d6bd7 feat: add cli first class validation (#8374)
* feat: add cli first class validation
* feat: add required flag to cli options
* Add unit test to catch invalid and missing flag
2023-07-11 09:59:55 -04:00
Cian Johnston 3f6a158016 chore: enable exhaustruct linter (#8403)
* chore: enable exhaustruct linter

* add exlusion rules

* move to allowlist instead

* exhaustruct httpmw package

* fixup! exhaustruct httpmw package

* make lint

* address PR comments
2023-07-11 14:30:33 +01:00
Mathias Fredriksson 75f62dc39d feat: add support for template version messages in api and cli (#8336) 2023-07-11 13:11:08 +03:00
Kyle Carberry b4a7fe3221 fix: use expires_in field for git device refresh (#8411)
This was causing git auth to never refresh after the token
became expired after 8hrs.
2023-07-11 09:28:52 +00:00
Colin Adler 9df80530d7 chore(cli): unhide netcheck command (#8412) 2023-07-10 21:38:02 -05:00
Bruno Quaresma d896b74fa2 feat(site): display build logs on workspace transitioning statuses (#8397) 2023-07-10 17:47:39 -03:00
dependabot[bot] b7641b219e chore: bump the golang-x group with 4 updates (#8400)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-10 15:33:17 -05:00
dependabot[bot] ff62f70f55 chore: bump ts-proto from 1.150.0 to 1.152.0 in /site (#8402)
Bumps [ts-proto](https://github.com/stephenh/ts-proto) from 1.150.0 to 1.152.0.
- [Release notes](https://github.com/stephenh/ts-proto/releases)
- [Changelog](https://github.com/stephenh/ts-proto/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stephenh/ts-proto/compare/v1.150.0...v1.152.0)

---
updated-dependencies:
- dependency-name: ts-proto
  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-10 17:28:52 -03:00
dependabot[bot] 000d538ace chore: bump react-router-dom from 6.13.0 to 6.14.1 in /site (#8398)
Bumps [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) from 6.13.0 to 6.14.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.14.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>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-10 17:28:40 -03:00
Bruno Quaresma ecb99717ef refactor(site) re-design proxies table (#8410) 2023-07-10 17:01:59 -03:00
Bruno Quaresma 3c2ce4f52a refactor(site): adjust the proxy menu design (#8409) 2023-07-10 17:01:09 -03:00
Colin Adler ef836de330 fix: document workspace filter query param correctly (#8408) 2023-07-10 18:57:09 +00:00
dependabot[bot] cee8fde93d chore: bump tough-cookie from 4.1.2 to 4.1.3 in /site (#8384)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-10 13:36:48 -05:00
Muhammad Atif Ali bf8af90d5a chore: group golang.org/x/* dependencies (#8392) 2023-07-10 18:07:14 +03:00
Steven Masley 2ee406d7b6 feat: log out and redirect user when converting to oidc (#8347)
* feat: log out user on conver to oidc

Log out user and redirect to login page and log out user when
they convert to oidc.
2023-07-10 10:25:41 -04:00
Mathias Fredriksson 90a3debe3f fix(coderd): pass oauth configs to site (#8390) 2023-07-10 17:23:41 +03:00
dependabot[bot] 9a3d9053a0 chore: bump @types/uuid from 8.3.4 to 9.0.2 in /site (#8377)
Bumps [@types/uuid](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/uuid) from 8.3.4 to 9.0.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/uuid)

---
updated-dependencies:
- dependency-name: "@types/uuid"
  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-10 11:11:54 -03:00
dependabot[bot] 19ec5789a4 chore: bump vite from 4.3.9 to 4.4.2 in /site (#8381)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.3.9 to 4.4.2.
- [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.4.2/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  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-10 11:11:10 -03:00
Mathias Fredriksson 9a72ddf7d4 fix(enterprise/coderd): add missing fields to extract api key config (#8393) 2023-07-10 16:51:50 +03:00
Marcin Tojek 9f2a931eb8 feat(coderd): support ephemeral parameters (#8367) 2023-07-10 13:44:03 +02:00
Marcin Tojek 8f4157c28d chore: go mod tidy (#8389) 2023-07-10 11:27:24 +00:00
Mathias Fredriksson b73f9d8e86 feat: add computed workspace and agent health fields to the api (#8280) 2023-07-10 12:40:11 +03:00
dependabot[bot] eabf929676 chore: bump actions/checkout from 2 to 3 (#8382) 2023-07-09 01:43:44 +03:00
Ammar Bandukwala 0115adf9d7 chore(.golangci.yaml): make gocyclo slightly more sensitive (#8383) 2023-07-08 22:43:34 +00:00
Muhammad Atif Ali d19e679c20 chore: use dependabot groups (#8372) 2023-07-08 17:29:47 +03:00
Steven Masley a297a014d6 chore: improve error message for incorrect login type (#8349)
* chore: add better error in wrong login type
2023-07-07 11:33:31 -04:00
Cian Johnston c1ab5cf0ba fix(cli/clistat): better handle cgroups with no limits (#8373) 2023-07-07 15:49:36 +01:00
Steven Masley f75d497c41 chore: touch ups to wsproxy UX (#8350)
* chore: update wording on wsproxy help
* chore: show help if no fields specified in wsproxy edit
* chore: Add run command example to wsproxy create
* chore: remove localhost warning
* chore: navbar match page title
* chore: Add helper text to latency picker
* chore: add confirm delete to workspace proxy delete cli
* chore: add errors + warnings to workspace proxy table
2023-07-07 10:06:11 -04:00
Cian Johnston 396e5e9a60 chore(database): fix test flake in TestUserLastSeenFilter (#8369) 2023-07-07 14:28:45 +01:00
Bruno Quaresma 2baa34364a fix(site): resize terminal when alert is dismissed (#8368) 2023-07-07 10:19:39 -03:00
Marcin Tojek e088303382 feat!: drop LegacyVariableName from coder parameter (#8360) 2023-07-07 14:14:29 +02:00
Cian Johnston 4e42c33769 chore(Makefile): specify count=1 instead of cleaning test cache (#8359)
* chore(Makefile): specify count=1 instead of cleaning test cache

* Update Makefile

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

* add comment to test-clean target

---------

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-07-07 12:16:16 +01:00
Mathias Fredriksson 34c3f919dc fix(agent/agentssh): check for hushlogin via afero fs (#8358) 2023-07-07 13:30:23 +03:00
Cian Johnston 259453007e chore(Makefile): add test-race target (#8357)
* chore(Makefile): add test-race target

* fixup! chore(Makefile): add test-race target
2023-07-07 10:15:50 +00:00
Marcin Tojek 64687631aa feat: enable Terraform template-wide variables by default (#8334) 2023-07-07 11:49:02 +02:00
Cian Johnston 435c67ab75 refactor(cli)!: move scaletest to exp/scaletest (#8339)
* refactor(cli): mv scaletest exp/scaletest

* make gen
2023-07-07 09:10:14 +01:00
Colin Adler ccea595b39 chore: temporarily skip prisma scan (#8355) 2023-07-07 00:48:29 +00:00
Colin Adler 6079cda851 chore(dogfood): add docker compose (#8354) 2023-07-06 19:46:40 -05:00
Colin Adler 9a0ba1bdc3 fix(coderd): remove CREATE INDEX CONCURRENTLY from migrations (#8353) 2023-07-06 16:44:29 -05:00
Steven Masley 2ebd0ec6c5 fix: resolve nil pointer dereference on missing oauth config (#8352) 2023-07-06 16:46:22 -04:00
Steven Masley 9f5bc7c10b feat: add --branch option to clone or checkout different dotfiles branch (#8331)
* feat: --branch option to clone different dotfiles branch
* chore: checkout specified branch if dotfiles already exist
2023-07-06 20:24:04 +00:00
Muhammad Atif Ali 5bb6bc5571 chore: update fly.io example to remove deprecated parameters (#8194)
* chore: update fly.io example to remove deprecated parameters

* `make fmt`

* update provider version
2023-07-06 10:20:23 -04:00
Bruno Quaresma a33a255885 chore: upgrade node version on CI to match workspace version (#8340) 2023-07-06 14:04:29 +00:00
Colin Adler 33bdc23e1d chore(site): fix node vulnerabilities (#8330)
* chore: fix node vulnerabilities

https://github.com/advisories/GHSA-c2qf-rxjj-qqgw
https://github.com/advisories/GHSA-j8xg-fqg3-53r7

* fixup! chore: fix node vulnerabilities

* fixup! chore: fix node vulnerabilities

* fixup! chore: fix node vulnerabilities

* fixup! chore: fix node vulnerabilities

* fixup! chore: fix node vulnerabilities
2023-07-06 10:26:55 -03:00
Mathias Fredriksson 4a13c58077 test(pty/ptytest): fix error message on deadline exceeded (#8337) 2023-07-06 16:18:03 +03:00
Mathias Fredriksson 814534d6b7 fix(enterprise/audit): improve error message for missing action (#8335) 2023-07-06 15:43:32 +03:00
Cian Johnston 7fcf319e01 fix(cli)!: protect client Logger and refactor cli scaletest tests (#8317)
- (breaking) Protects Logger and LogBodies fields of codersdk.Client with its mutex. This addresses a data race in cli/scaletest.
- Fillets the existing cli/createworkspaces unit test and moves the testing logic there into the tests under scaletest/createworkspaces.
- Adds testutil.RaceEnabled bool const and conditionaly skips previously-skipped tests under scaletest/ if the race detector is enabled. This is unfortunate and sad, but I would prefer to have these tests at least running without the race detector than not running at all.
- Adds IgnoreErrors option to fake in-memory agent loggers; having the agents fail the test immediately when they encounter any sort of error isn't really helpful.
2023-07-06 09:43:39 +01:00
Mathias Fredriksson 1d746b901b fix(Makefile): add dbmock to swagger deps and improve performance (#8332) 2023-07-06 10:59:08 +03:00
Mathias Fredriksson 3f058f28e7 test(agent): use afero for motd tests to allow parallel execution (#8329) 2023-07-06 10:57:51 +03:00
Marcin Tojek c6fcd7ee93 fix: report failed CompletedJob (#8318) 2023-07-06 07:26:33 +00:00
Marcin Tojek 45eca671fe feat: delay pending-in-queue banner (#8309) 2023-07-06 09:13:25 +02:00
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
3072 changed files with 319057 additions and 121799 deletions
-83
View File
@@ -1,83 +0,0 @@
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
+8 -20
View File
@@ -1,24 +1,12 @@
// For format details, see https://aka.ms/devcontainer.json
{
"name": "Development environments on your infrastructure",
"image": "codercom/oss-dogfood:latest",
// 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"
]
"features": {
// See all possible options here https://github.com/devcontainers/features/tree/main/src/docker-in-docker
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
// SYS_PTRACE to enable go debugging
// without --priviliged the Github Codespace build fails (not required otherwise)
"runArgs": ["--cap-add=SYS_PTRACE", "--privileged"]
}
+5
View File
@@ -0,0 +1,5 @@
# If you would like `git blame` to ignore commits from this file, run...
# git config blame.ignoreRevsFile .git-blame-ignore-revs
# chore: format code with semicolons when using prettier (#9555)
988c9af0153561397686c119da9d1336d2433fdd
+3
View File
@@ -1,5 +1,7 @@
# Generated files
coderd/apidoc/docs.go linguist-generated=true
docs/api/*.md linguist-generated=true
docs/cli/*.md linguist-generated=true
coderd/apidoc/swagger.json linguist-generated=true
coderd/database/dump.sql linguist-generated=true
peerbroker/proto/*.go linguist-generated=true
@@ -9,3 +11,4 @@ provisionersdk/proto/*.go linguist-generated=true
*.tfstate.json linguist-generated=true
*.tfstate.dot linguist-generated=true
*.tfplan.dot linguist-generated=true
site/src/api/typesGenerated.ts linguist-generated=true
-3
View File
@@ -1,3 +0,0 @@
docs/ @coder/docs
README.md @coder/docs
ADOPTERS.md @coder/docs
+70
View File
@@ -0,0 +1,70 @@
name: "Setup Go"
description: |
Sets up the Go environment for tests, builds, etc.
inputs:
version:
description: "The Go version to use."
default: "1.20.10"
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 }}-
- name: Setup Go
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 aren't used because it causes the cache to grow
# infinitely. go.sum changes very infrequently, so rebuilding from
# scratch every now and then isn't terrible.
- 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.
# The number in the key is incremented when the cache gets too large,
# since this technically grows without bound.
key: gocache2-${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.go', 'go.**') }}
restore-keys: |
gocache2-${{ runner.os }}-${{ github.job }}-
gocache2-${{ 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
+31
View File
@@ -0,0 +1,31 @@
name: "Setup Node"
description: |
Sets up the node environment for tests, builds, etc.
inputs:
directory:
description: |
The directory to run the setup in.
required: false
default: "site"
runs:
using: "composite"
steps:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node
uses: buildjet/setup-node@v3
with:
node-version: 18.17.0
# See https://github.com/actions/setup-node#caching-global-packages-data
cache: "pnpm"
cache-dependency-path: ${{ inputs.directory }}/pnpm-lock.yaml
- name: Install root node_modules
shell: bash
run: ./scripts/pnpm_install.sh
- name: Install node_modules
shell: bash
run: ../scripts/pnpm_install.sh
working-directory: ${{ inputs.directory }}
+10
View File
@@ -0,0 +1,10 @@
name: Setup sqlc
description: |
Sets up the sqlc environment for tests, builds, etc.
runs:
using: "composite"
steps:
- name: Setup sqlc
uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: "1.20.0"
+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.5
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.21.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 }}
+87 -5
View File
@@ -3,12 +3,12 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
interval: "weekly"
time: "06:00"
timezone: "America/Chicago"
labels: []
commit-message:
prefix: "chore"
prefix: "ci"
ignore:
# These actions deliver the latest versions by updating the major
# release tag, so ignore minor and patch versions
@@ -24,11 +24,15 @@ updates:
update-types:
- version-update:semver-minor
- version-update:semver-patch
groups:
github-actions:
patterns:
- "*"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "monthly"
interval: "weekly"
time: "06:00"
timezone: "America/Chicago"
commit-message:
@@ -39,6 +43,33 @@ updates:
- dependency-name: "*"
update-types:
- version-update:semver-patch
groups:
otel:
patterns:
- "go.nhat.io/otelsql"
- "go.opentelemetry.io/otel*"
golang-x:
patterns:
- "golang.org/x/*"
# Update our Dockerfile.
- package-ecosystem: "docker"
directory: "/scripts/"
schedule:
interval: "weekly"
time: "06:00"
timezone: "America/Chicago"
commit-message:
prefix: "chore"
labels: []
ignore:
# We need to coordinate terraform updates with the version hardcoded in
# our Go code.
- dependency-name: "terraform"
groups:
scripts-docker:
patterns:
- "*"
- package-ecosystem: "npm"
directory: "/site/"
@@ -46,6 +77,56 @@ updates:
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"
update-types:
- version-update:semver-major
open-pull-requests-limit: 15
groups:
react:
patterns:
- "react*"
- "@types/react*"
xterm:
patterns:
- "xterm*"
xstate:
patterns:
- "xstate"
- "@xstate*"
mui:
patterns:
- "@mui*"
storybook:
patterns:
- "@storybook*"
- "storybook*"
eslint:
patterns:
- "eslint*"
- "@eslint*"
- "@typescript-eslint/eslint-plugin"
- "@typescript-eslint/parser"
- package-ecosystem: "npm"
directory: "/offlinedocs/"
schedule:
interval: "monthly"
time: "06:00"
timezone: "America/Chicago"
reviewers:
- "coder/ts"
commit-message:
prefix: "chore"
labels: []
@@ -60,10 +141,11 @@ updates:
update-types:
- version-update:semver-major
# Update dogfood.
- package-ecosystem: "terraform"
directory: "/examples/templates"
directory: "/dogfood/"
schedule:
interval: "monthly"
interval: "weekly"
time: "06:00"
timezone: "America/Chicago"
commit-message:
+13
View File
@@ -0,0 +1,13 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: pr${PR_NUMBER}-tls
namespace: pr-deployment-certs
spec:
secretName: pr${PR_NUMBER}-tls
issuerRef:
name: letsencrypt
kind: ClusterIssuer
dnsNames:
- "${PR_HOSTNAME}"
- "*.${PR_HOSTNAME}"
+31
View File
@@ -0,0 +1,31 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: coder-workspace-pr${PR_NUMBER}
namespace: pr${PR_NUMBER}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: coder-workspace-pr${PR_NUMBER}
namespace: pr${PR_NUMBER}
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: coder-workspace-pr${PR_NUMBER}
namespace: pr${PR_NUMBER}
subjects:
- kind: ServiceAccount
name: coder-workspace-pr${PR_NUMBER}
namespace: pr${PR_NUMBER}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: coder-workspace-pr${PR_NUMBER}
+314
View File
@@ -0,0 +1,314 @@
terraform {
required_providers {
coder = {
source = "coder/coder"
}
kubernetes = {
source = "hashicorp/kubernetes"
}
}
}
provider "coder" {
}
variable "namespace" {
type = string
description = "The Kubernetes namespace to create workspaces in (must exist prior to creating workspaces)"
}
data "coder_parameter" "cpu" {
name = "cpu"
display_name = "CPU"
description = "The number of CPU cores"
default = "2"
icon = "/icon/memory.svg"
mutable = true
option {
name = "2 Cores"
value = "2"
}
option {
name = "4 Cores"
value = "4"
}
option {
name = "6 Cores"
value = "6"
}
option {
name = "8 Cores"
value = "8"
}
}
data "coder_parameter" "memory" {
name = "memory"
display_name = "Memory"
description = "The amount of memory in GB"
default = "2"
icon = "/icon/memory.svg"
mutable = true
option {
name = "2 GB"
value = "2"
}
option {
name = "4 GB"
value = "4"
}
option {
name = "6 GB"
value = "6"
}
option {
name = "8 GB"
value = "8"
}
}
data "coder_parameter" "home_disk_size" {
name = "home_disk_size"
display_name = "Home disk size"
description = "The size of the home disk in GB"
default = "10"
type = "number"
icon = "/emojis/1f4be.png"
mutable = false
validation {
min = 1
max = 99999
}
}
provider "kubernetes" {
config_path = null
}
data "coder_workspace" "me" {}
resource "coder_agent" "main" {
os = "linux"
arch = "amd64"
startup_script_timeout = 180
startup_script = <<-EOT
set -e
# install and start code-server
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
/tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
EOT
# The following metadata blocks are optional. They are used to display
# information about your workspace in the dashboard. You can remove them
# if you don't want to display any information.
# For basic resources, you can use the `coder stat` command.
# If you need more control, you can write your own script.
metadata {
display_name = "CPU Usage"
key = "0_cpu_usage"
script = "coder stat cpu"
interval = 10
timeout = 1
}
metadata {
display_name = "RAM Usage"
key = "1_ram_usage"
script = "coder stat mem"
interval = 10
timeout = 1
}
metadata {
display_name = "Home Disk"
key = "3_home_disk"
script = "coder stat disk --path $${HOME}"
interval = 60
timeout = 1
}
metadata {
display_name = "CPU Usage (Host)"
key = "4_cpu_usage_host"
script = "coder stat cpu --host"
interval = 10
timeout = 1
}
metadata {
display_name = "Memory Usage (Host)"
key = "5_mem_usage_host"
script = "coder stat mem --host"
interval = 10
timeout = 1
}
metadata {
display_name = "Load Average (Host)"
key = "6_load_host"
# get load avg scaled by number of cores
script = <<EOT
echo "`cat /proc/loadavg | awk '{ print $1 }'` `nproc`" | awk '{ printf "%0.2f", $1/$2 }'
EOT
interval = 60
timeout = 1
}
}
# code-server
resource "coder_app" "code-server" {
agent_id = coder_agent.main.id
slug = "code-server"
display_name = "code-server"
icon = "/icon/code.svg"
url = "http://localhost:13337?folder=/home/coder"
subdomain = false
share = "owner"
healthcheck {
url = "http://localhost:13337/healthz"
interval = 3
threshold = 10
}
}
resource "kubernetes_persistent_volume_claim" "home" {
metadata {
name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}-home"
namespace = var.namespace
labels = {
"app.kubernetes.io/name" = "coder-pvc"
"app.kubernetes.io/instance" = "coder-pvc-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}"
"app.kubernetes.io/part-of" = "coder"
//Coder-specific labels.
"com.coder.resource" = "true"
"com.coder.workspace.id" = data.coder_workspace.me.id
"com.coder.workspace.name" = data.coder_workspace.me.name
"com.coder.user.id" = data.coder_workspace.me.owner_id
"com.coder.user.username" = data.coder_workspace.me.owner
}
annotations = {
"com.coder.user.email" = data.coder_workspace.me.owner_email
}
}
wait_until_bound = false
spec {
access_modes = ["ReadWriteOnce"]
resources {
requests = {
storage = "${data.coder_parameter.home_disk_size.value}Gi"
}
}
}
}
resource "kubernetes_deployment" "main" {
count = data.coder_workspace.me.start_count
depends_on = [
kubernetes_persistent_volume_claim.home
]
wait_for_rollout = false
metadata {
name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}"
namespace = var.namespace
labels = {
"app.kubernetes.io/name" = "coder-workspace"
"app.kubernetes.io/instance" = "coder-workspace-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}"
"app.kubernetes.io/part-of" = "coder"
"com.coder.resource" = "true"
"com.coder.workspace.id" = data.coder_workspace.me.id
"com.coder.workspace.name" = data.coder_workspace.me.name
"com.coder.user.id" = data.coder_workspace.me.owner_id
"com.coder.user.username" = data.coder_workspace.me.owner
}
annotations = {
"com.coder.user.email" = data.coder_workspace.me.owner_email
}
}
spec {
replicas = 1
selector {
match_labels = {
"app.kubernetes.io/name" = "coder-workspace"
}
}
strategy {
type = "Recreate"
}
template {
metadata {
labels = {
"app.kubernetes.io/name" = "coder-workspace"
}
}
spec {
security_context {
run_as_user = 1000
fs_group = 1000
}
service_account_name = "coder-workspace-${var.namespace}"
container {
name = "dev"
image = "bencdr/devops-tools"
image_pull_policy = "Always"
command = ["sh", "-c", coder_agent.main.init_script]
security_context {
run_as_user = "1000"
}
env {
name = "CODER_AGENT_TOKEN"
value = coder_agent.main.token
}
resources {
requests = {
"cpu" = "250m"
"memory" = "512Mi"
}
limits = {
"cpu" = "${data.coder_parameter.cpu.value}"
"memory" = "${data.coder_parameter.memory.value}Gi"
}
}
volume_mount {
mount_path = "/home/coder"
name = "home"
read_only = false
}
}
volume {
name = "home"
persistent_volume_claim {
claim_name = kubernetes_persistent_volume_claim.home.metadata.0.name
read_only = false
}
}
affinity {
// This affinity attempts to spread out all workspace pods evenly across
// nodes.
pod_anti_affinity {
preferred_during_scheduling_ignored_during_execution {
weight = 1
pod_affinity_term {
topology_key = "kubernetes.io/hostname"
label_selector {
match_expressions {
key = "app.kubernetes.io/name"
operator = "In"
values = ["coder-workspace"]
}
}
}
}
}
}
}
}
}
}
+38
View File
@@ -0,0 +1,38 @@
coder:
image:
repo: "${REPO}"
tag: "pr${PR_NUMBER}"
pullPolicy: Always
service:
type: ClusterIP
ingress:
enable: true
className: traefik
host: "${PR_HOSTNAME}"
wildcardHost: "*.${PR_HOSTNAME}"
tls:
enable: true
secretName: "pr${PR_NUMBER}-tls"
wildcardSecretName: "pr${PR_NUMBER}-tls"
env:
- name: "CODER_ACCESS_URL"
value: "https://${PR_HOSTNAME}"
- name: "CODER_WILDCARD_ACCESS_URL"
value: "*.${PR_HOSTNAME}"
- name: "CODER_EXPERIMENTS"
value: "${EXPERIMENTS}"
- name: CODER_PG_CONNECTION_URL
valueFrom:
secretKeyRef:
name: coder-db-url
key: url
- name: "CODER_OAUTH2_GITHUB_ALLOW_SIGNUPS"
value: "true"
- name: "CODER_OAUTH2_GITHUB_CLIENT_ID"
value: "${PR_DEPLOYMENTS_GITHUB_OAUTH_CLIENT_ID}"
- name: "CODER_OAUTH2_GITHUB_CLIENT_SECRET"
value: "${PR_DEPLOYMENTS_GITHUB_OAUTH_CLIENT_SECRET}"
- name: "CODER_OAUTH2_GITHUB_ALLOWED_ORGS"
value: "coder"
- name: "CODER_DERP_CONFIG_URL"
value: "https://controlplane.tailscale.com/derpmap/default"
-3
View File
@@ -1,3 +0,0 @@
<!--
Check if your change requires documentation edits before merging: https://coder.com/docs/coder. Make edits in `docs/`.
-->
+487 -345
View File
File diff suppressed because it is too large Load Diff
+8 -18
View File
@@ -19,13 +19,14 @@ concurrency: pr-${{ github.ref }}
jobs:
# Dependabot is annoying, but this makes it a bit less so.
auto-approve:
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
- name: auto-approve dependabot
uses: hmarr/auto-approve-action@v3
if: github.actor == 'dependabot[bot]'
cla:
@@ -33,7 +34,7 @@ jobs:
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.2.1
uses: contributor-assistant/github-action@v2.3.1
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
@@ -45,27 +46,16 @@ jobs:
path-to-document: "https://github.com/coder/cla/blob/main/README.md"
# branch should not be protected
branch: "main"
allowlist: dependabot*
title:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target'
steps:
- name: Validate PR title
uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
requireScope: false
# Some users have signed a corporate CLA with Coder so are exempt from signing our community one.
allowlist: "coryb,aaronlehmann,dependabot*"
release-labels:
runs-on: ubuntu-latest
# Depend on lint so that title is Conventional Commits-compatible.
needs: [title]
# Skip tagging for draft PRs.
if: ${{ github.event_name == 'pull_request_target' && success() && !github.event.pull_request.draft }}
steps:
- uses: actions/github-script@v6
- name: release-labels
uses: actions/github-script@v6
with:
# This script ensures PR title and labels are in sync:
#
+33 -2
View File
@@ -31,10 +31,11 @@ jobs:
runs-on: ubuntu-latest
if: github.repository_owner == 'coder'
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
- name: Docker login
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
@@ -53,8 +54,38 @@ jobs:
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
+41 -24
View File
@@ -5,19 +5,29 @@ on:
branches:
- main
paths:
- "flake.nix"
- "flake.lock"
- "dogfood/**"
pull_request:
paths:
- "dogfood/**"
- ".github/workflows/dogfood.yaml"
# Uncomment these lines when testing with CI.
# pull_request:
# paths:
# - "flake.nix"
# - "flake.lock"
# - "dogfood/**"
# - ".github/workflows/dogfood.yaml"
workflow_dispatch:
jobs:
deploy_image:
runs-on: ubuntu-latest
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6.4
uses: tj-actions/branch-names@v6.5
- name: "Branch name to Docker tag name"
id: docker-tag-name
@@ -27,42 +37,48 @@ jobs:
tag=${tag//\//--}
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Run the Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix build .#devEnvImage && ./result | docker load
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
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
- name: Tag and Push
run: |
docker tag codercom/oss-dogfood:latest codercom/oss-dogfood:${{ steps.docker-tag-name.outputs.tag }}
docker push codercom/oss-dogfood -a
deploy_template:
needs: deploy_image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Get short commit SHA
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: "Install latest Coder"
- name: Get latest commit title
id: message
run: echo "pr_title=$(git log --format=%s -n 1 ${{ github.sha }})" >> $GITHUB_OUTPUT
- name: "Get latest Coder binary from the server"
run: |
curl -L https://coder.com/install.sh | sh
# env:
# VERSION: 0.x
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
./coder templates push $CODER_TEMPLATE_NAME --directory $CODER_TEMPLATE_DIR --yes --name=$CODER_TEMPLATE_VERSION --message="$CODER_TEMPLATE_MESSAGE"
env:
# Consumed by Coder CLI
CODER_URL: https://dev.coder.com
@@ -71,3 +87,4 @@ jobs:
CODER_TEMPLATE_NAME: ${{ secrets.CODER_TEMPLATE_NAME }}
CODER_TEMPLATE_VERSION: ${{ steps.vars.outputs.sha_short }}
CODER_TEMPLATE_DIR: ./dogfood
CODER_TEMPLATE_MESSAGE: ${{ steps.message.outputs.pr_title }}
+2 -1
View File
@@ -18,5 +18,6 @@
{
"pattern": "tailscale.com"
}
]
],
"aliveStatusCodes": [200, 0]
}
+60
View File
@@ -0,0 +1,60 @@
# 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:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Setup Terraform
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 ./...
- name: Upload test results to DataDog
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:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Run Tests
run: |
gotestsum --junitfile="gotests.xml" -- --tags="timing" -p=1 -run='_Timing/' ./...
- name: Upload test results to DataDog
uses: ./.github/actions/upload-datadog
if: always()
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
+17
View File
@@ -0,0 +1,17 @@
# 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:
- name: Assign author
uses: toshimaru/auto-author-assign@v2.0.1
+73
View File
@@ -0,0 +1,73 @@
name: pr-cleanup
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 -euo pipefail
mkdir -p ~/.kube
echo "${{ secrets.PR_DEPLOYMENTS_KUBECONFIG }}" > ~/.kube/config
export KUBECONFIG=~/.kube/config
- name: Delete helm release
run: |
set -euo 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"
- name: "Remove DNS records"
run: |
set -euo pipefail
# Get identifier for the record
record_id=$(curl -X GET "https://api.cloudflare.com/client/v4/zones/${{ secrets.PR_DEPLOYMENTS_ZONE_ID }}/dns_records?name=%2A.pr${{ steps.pr_number.outputs.PR_NUMBER }}.${{ secrets.PR_DEPLOYMENTS_DOMAIN }}" \
-H "Authorization: Bearer ${{ secrets.PR_DEPLOYMENTS_CLOUDFLARE_API_TOKEN }}" \
-H "Content-Type:application/json" | jq -r '.result[0].id') || echo "DNS record not found"
echo "::add-mask::$record_id"
# Delete the record
(
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${{ secrets.PR_DEPLOYMENTS_ZONE_ID }}/dns_records/$record_id" \
-H "Authorization: Bearer ${{ secrets.PR_DEPLOYMENTS_CLOUDFLARE_API_TOKEN }}" \
-H "Content-Type:application/json" | jq -r '.success'
) || echo "DNS record not found"
- name: "Delete certificate"
if: ${{ github.event.pull_request.merged == true }}
run: |
set -euxo pipefail
kubectl delete certificate "pr${{ steps.pr_number.outputs.PR_NUMBER }}-tls" -n pr-deployment-certs || echo "certificate not found"
+470
View File
@@ -0,0 +1,470 @@
# This action will trigger when
# 1. when the workflow is manually triggered
# 2. ./scripts/deploy_pr.sh is run locally
# 3. when a PR is updated
name: Deploy PR
on:
push:
branches-ignore:
- main
workflow_dispatch:
inputs:
pr_number:
description: "PR number"
type: number
required: true
experiments:
description: "Experiments to enable"
required: false
type: string
default: "*"
build:
description: "Force new build"
required: false
type: boolean
default: false
deploy:
description: "Force new deployment"
required: false
type: boolean
default: false
env:
REPO: ghcr.io/coder/coder-preview
permissions:
contents: read
packages: write
pull-requests: write # needed for commenting on PRs
jobs:
check_pr:
runs-on: ubuntu-latest
outputs:
PR_OPEN: ${{ steps.check_pr.outputs.pr_open }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check if PR is open
id: check_pr
run: |
set -euo pipefail
pr_open=true
if [[ "$(gh pr view --json state | jq -r '.state')" != "OPEN" ]]; then
echo "PR doesn't exist or is closed."
pr_open=false
fi
echo "pr_open=$pr_open" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
get_info:
needs: check_pr
if: ${{ needs.check_pr.outputs.PR_OPEN == 'true' }}
outputs:
PR_NUMBER: ${{ steps.pr_info.outputs.PR_NUMBER }}
PR_TITLE: ${{ steps.pr_info.outputs.PR_TITLE }}
PR_URL: ${{ steps.pr_info.outputs.PR_URL }}
CODER_BASE_IMAGE_TAG: ${{ steps.set_tags.outputs.CODER_BASE_IMAGE_TAG }}
CODER_IMAGE_TAG: ${{ steps.set_tags.outputs.CODER_IMAGE_TAG }}
NEW: ${{ steps.check_deployment.outputs.NEW }}
BUILD: ${{ steps.build_conditionals.outputs.first_or_force_build == 'true' || steps.build_conditionals.outputs.automatic_rebuild == 'true' }}
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get PR number, title, and branch name
id: pr_info
run: |
set -euo pipefail
PR_NUMBER=$(gh pr view --json number | jq -r '.number')
PR_TITLE=$(gh pr view --json title | jq -r '.title')
PR_URL=$(gh pr view --json url | jq -r '.url')
echo "PR_URL=$PR_URL" >> $GITHUB_OUTPUT
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set required tags
id: set_tags
run: |
set -euo 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_info.outputs.PR_NUMBER }}
CODER_IMAGE_TAG: ghcr.io/coder/coder-preview:pr${{ steps.pr_info.outputs.PR_NUMBER }}
- name: Set up kubeconfig
run: |
set -euo pipefail
mkdir -p ~/.kube
echo "${{ secrets.PR_DEPLOYMENTS_KUBECONFIG }}" > ~/.kube/config
chmod 644 ~/.kube/config
export KUBECONFIG=~/.kube/config
- name: Check if the helm deployment already exists
id: check_deployment
run: |
set -euo pipefail
if helm status "pr${{ steps.pr_info.outputs.PR_NUMBER }}" --namespace "pr${{ steps.pr_info.outputs.PR_NUMBER }}" > /dev/null 2>&1; then
echo "Deployment already exists. Skipping deployment."
NEW=false
else
echo "Deployment doesn't exist."
NEW=true
fi
echo "NEW=$NEW" >> $GITHUB_OUTPUT
- name: Check changed files
uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.ref }}
filters: |
all:
- "**"
ignored:
- "docs/**"
- "README.md"
- "examples/web-server/**"
- "examples/monitoring/**"
- "examples/lima/**"
- ".github/**"
- "offlinedocs/**"
- ".devcontainer/**"
- "helm/**"
- "*[^g][^o][^.][^s][^u][^m]*"
- "*[^g][^o][^.][^m][^o][^d]*"
- "*[^M][^a][^k][^e][^f][^i][^l][^e]*"
- "scripts/**/*[^D][^o][^c][^k][^e][^r][^f][^i][^l][^e]*"
- "scripts/**/*[^D][^o][^c][^k][^e][^r][^f][^i][^l][^e][.][b][^a][^s][^e]*"
- name: Print number of changed files
run: |
set -euo pipefail
echo "Total number of changed files: ${{ steps.filter.outputs.all_count }}"
echo "Number of ignored files: ${{ steps.filter.outputs.ignored_count }}"
- name: Build conditionals
id: build_conditionals
run: |
set -euo pipefail
# build if the workflow is manually triggered and the deployment doesn't exist (first build or force rebuild)
echo "first_or_force_build=${{ (github.event_name == 'workflow_dispatch' && steps.check_deployment.outputs.NEW == 'true') || github.event.inputs.build == 'true' }}" >> $GITHUB_OUTPUT
# build if the deployment alreday exist and there are changes in the files that we care about (automatic updates)
echo "automatic_rebuild=${{ steps.check_deployment.outputs.NEW == 'false' && steps.filter.outputs.all_count > steps.filter.outputs.ignored_count }}" >> $GITHUB_OUTPUT
comment-pr:
needs: get_info
if: needs.get_info.outputs.BUILD == 'true' || github.event.inputs.deploy == 'true'
runs-on: "ubuntu-latest"
steps:
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ needs.get_info.outputs.PR_NUMBER }}
comment-author: "github-actions[bot]"
body-includes: ":rocket:"
direction: last
- 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: ${{ needs.get_info.outputs.PR_NUMBER }}
edit-mode: replace
body: |
---
:rocket: Deploying PR ${{ needs.get_info.outputs.PR_NUMBER }} ...
---
reactions: eyes
reactions-edit-mode: replace
build:
needs: get_info
# Run build job only if there are changes in the files that we care about or if the workflow is manually triggered with --build flag
if: needs.get_info.outputs.BUILD == 'true'
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
# This concurrency only cancels build jobs if a new build is triggred. It will avoid cancelling the current deployemtn in case of docs chnages.
concurrency:
group: build-${{ github.workflow }}-${{ github.ref }}-${{ needs.get_info.outputs.BUILD }}
cancel-in-progress: true
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
CODER_IMAGE_TAG: ${{ needs.get_info.outputs.CODER_IMAGE_TAG }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: ./.github/actions/setup-node
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Setup sqlc
uses: ./.github/actions/setup-sqlc
- name: GHCR Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Linux amd64 Docker image
run: |
set -euo 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, get_info]
# Run deploy job only if build job was successful or skipped
if: |
always() && (needs.build.result == 'success' || needs.build.result == 'skipped') &&
(needs.get_info.outputs.BUILD == 'true' || github.event.inputs.deploy == 'true')
runs-on: "ubuntu-latest"
env:
CODER_IMAGE_TAG: ${{ needs.get_info.outputs.CODER_IMAGE_TAG }}
PR_NUMBER: ${{ needs.get_info.outputs.PR_NUMBER }}
PR_TITLE: ${{ needs.get_info.outputs.PR_TITLE }}
PR_URL: ${{ needs.get_info.outputs.PR_URL }}
PR_HOSTNAME: "pr${{ needs.get_info.outputs.PR_NUMBER }}.${{ secrets.PR_DEPLOYMENTS_DOMAIN }}"
steps:
- name: Set up kubeconfig
run: |
set -euo pipefail
mkdir -p ~/.kube
echo "${{ secrets.PR_DEPLOYMENTS_KUBECONFIG }}" > ~/.kube/config
chmod 644 ~/.kube/config
export KUBECONFIG=~/.kube/config
- name: Check if image exists
run: |
set -euo pipefail
foundTag=$(
gh api /orgs/coder/packages/container/coder-preview/versions |
jq -r --arg tag "pr${{ env.PR_NUMBER }}" '.[] |
select(.metadata.container.tags == [$tag]) |
.metadata.container.tags[0]'
)
if [ -z "$foundTag" ]; then
echo "Image not found"
echo "${{ env.CODER_IMAGE_TAG }} not found in ghcr.io/coder/coder-preview"
exit 1
else
echo "Image found"
echo "$foundTag tag found in ghcr.io/coder/coder-preview"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add DNS record to Cloudflare
if: needs.get_info.outputs.NEW == 'true'
run: |
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.PR_DEPLOYMENTS_ZONE_ID }}/dns_records" \
-H "Authorization: Bearer ${{ secrets.PR_DEPLOYMENTS_CLOUDFLARE_API_TOKEN }}" \
-H "Content-Type:application/json" \
--data '{"type":"CNAME","name":"*.${{ env.PR_HOSTNAME }}","content":"${{ env.PR_HOSTNAME }}","ttl":1,"proxied":false}'
- name: Create PR namespace
if: needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
run: |
set -euo 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: Checkout
uses: actions/checkout@v4
- name: Check and Create Certificate
if: needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
run: |
# Using kubectl to check if a Certificate resource already exists
# we are doing this to avoid letsenrypt rate limits
if ! kubectl get certificate pr${{ env.PR_NUMBER }}-tls -n pr-deployment-certs > /dev/null 2>&1; then
echo "Certificate doesn't exist. Creating a new one."
envsubst < ./.github/pr-deployments/certificate.yaml | kubectl apply -f -
else
echo "Certificate exists. Skipping certificate creation."
fi
echo "Copy certificate from pr-deployment-certs to pr${{ env.PR_NUMBER }} namespace"
until kubectl get secret pr${{ env.PR_NUMBER }}-tls -n pr-deployment-certs &> /dev/null
do
echo "Waiting for secret pr${{ env.PR_NUMBER }}-tls to be created..."
sleep 5
done
(
kubectl get secret pr${{ env.PR_NUMBER }}-tls -n pr-deployment-certs -o json |
jq 'del(.metadata.namespace,.metadata.creationTimestamp,.metadata.resourceVersion,.metadata.selfLink,.metadata.uid,.metadata.managedFields)' |
kubectl -n pr${{ env.PR_NUMBER }} apply -f -
)
- name: Set up PostgreSQL database
if: needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install coder-db bitnami/postgresql \
--namespace pr${{ env.PR_NUMBER }} \
--set auth.username=coder \
--set auth.password=coder \
--set auth.database=coder \
--set persistence.size=10Gi
kubectl create secret generic coder-db-url -n pr${{ env.PR_NUMBER }} \
--from-literal=url="postgres://coder:coder@coder-db-postgresql.pr${{ env.PR_NUMBER }}.svc.cluster.local:5432/coder?sslmode=disable"
- name: Create a service account, role, and rolebinding for the PR namespace
if: needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
run: |
set -euo pipefail
# Create service account, role, rolebinding
envsubst < ./.github/pr-deployments/rbac.yaml | kubectl apply -f -
- name: Create values.yaml
env:
EXPERIMENTS: ${{ github.event.inputs.experiments }}
PR_DEPLOYMENTS_GITHUB_OAUTH_CLIENT_ID: ${{ secrets.PR_DEPLOYMENTS_GITHUB_OAUTH_CLIENT_ID }}
PR_DEPLOYMENTS_GITHUB_OAUTH_CLIENT_SECRET: ${{ secrets.PR_DEPLOYMENTS_GITHUB_OAUTH_CLIENT_SECRET }}
run: |
set -euo pipefail
envsubst < ./.github/pr-deployments/values.yaml > ./pr-deploy-values.yaml
- name: Install/Upgrade Helm chart
run: |
set -euo pipefail
helm upgrade --install "pr${{ env.PR_NUMBER }}" ./helm/coder \
--namespace "pr${{ env.PR_NUMBER }}" \
--values ./pr-deploy-values.yaml \
--force
- name: Install coder-logstream-kube
if: needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
run: |
helm repo add coder-logstream-kube https://helm.coder.com/logstream-kube
helm upgrade --install coder-logstream-kube coder-logstream-kube/coder-logstream-kube \
--namespace "pr${{ env.PR_NUMBER }}" \
--set url="https://${{ env.PR_HOSTNAME }}"
- name: Get Coder binary
if: needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
run: |
set -euo pipefail
DEST="${HOME}/coder"
URL="https://${{ env.PR_HOSTNAME }}/bin/coder-linux-amd64"
mkdir -p "$(dirname ${DEST})"
COUNT=0
until $(curl --output /dev/null --silent --head --fail "$URL"); do
printf '.'
sleep 5
COUNT=$((COUNT+1))
if [ $COUNT -ge 60 ]; then
echo "Timed out waiting for URL to be available"
exit 1
fi
done
curl -fsSL "$URL" -o "${DEST}"
chmod +x "${DEST}"
"${DEST}" version
mv "${DEST}" /usr/local/bin/coder
- name: Create first user, template and workspace
if: needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
id: setup_deployment
run: |
set -euo pipefail
# Create first user
# create a masked random password 12 characters long
password=$(openssl rand -base64 16 | tr -d "=+/" | cut -c1-12)
# add mask so that the password is not printed to the logs
echo "::add-mask::$password"
echo "password=$password" >> $GITHUB_OUTPUT
coder login \
--first-user-username coder \
--first-user-email pr${{ env.PR_NUMBER }}@coder.com \
--first-user-password $password \
--first-user-trial \
--use-token-as-session \
https://${{ env.PR_HOSTNAME }}
# Create template
cd ./.github/pr-deployments/template
coder templates create -y --variable namespace=pr${{ env.PR_NUMBER }} kubernetes
# Create workspace
coder create --template="kubernetes" kube --parameter cpu=2 --parameter memory=4 --parameter home_disk_size=2 -y
coder stop kube -y
- name: Send Slack notification
if: needs.get_info.outputs.NEW == 'true' || github.event.inputs.deploy == 'true'
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": "'"https://${{ env.PR_HOSTNAME }}"'",
"pr_username": "'"test"'",
"pr_email": "'"pr${{ env.PR_NUMBER }}@coder.com"'",
"pr_password": "'"${{ steps.setup_deployment.outputs.password }}"'",
"pr_actor": "'"${{ github.actor }}"'"
}' \
${{ secrets.PR_DEPLOYMENTS_SLACK_WEBHOOK }}
echo "Slack notification sent"
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ env.PR_NUMBER }}
comment-author: "github-actions[bot]"
body-includes: ":rocket:"
direction: last
- name: Comment on PR
uses: peter-evans/create-or-update-comment@v3
env:
STATUS: ${{ needs.get_info.outputs.NEW == 'true' && 'Created' || 'Updated' }}
with:
issue-number: ${{ env.PR_NUMBER }}
edit-mode: replace
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
---
:heavy_check_mark: PR ${{ env.PR_NUMBER }} ${{ env.STATUS }} successfully.
:rocket: Access the credentials [here](${{ secrets.PR_DEPLOYMENTS_SLACK_CHANNEL_URL }}).
---
cc: @${{ github.actor }}
reactions: rocket
reactions-edit-mode: replace
+193 -28
View File
@@ -32,14 +32,15 @@ env:
jobs:
release:
name: Build and publish
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
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:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
@@ -71,11 +72,11 @@ jobs:
set -euo pipefail
ref=HEAD
old_version="$(git describe --abbrev=0 "$ref^1")"
version="$(./scripts/version.sh)"
version="v$(./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"
./scripts/release/generate_release_notes.sh --check-for-changelog --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
@@ -84,26 +85,17 @@ jobs:
cat "$CODER_RELEASE_NOTES_FILE"
- name: Docker Login
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v3
with:
go-version: "~1.20"
- name: Setup Go
uses: ./.github/actions/setup-go
- 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: Setup Node
uses: ./.github/actions/setup-node
- name: Install nsis and zstd
run: sudo apt-get install -y nsis zstd
@@ -149,7 +141,8 @@ jobs:
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
build/coder_helm_"$version".tgz \
build/provisioner_helm_"$version".tgz
env:
CODER_SIGN_DARWIN: "1"
AC_CERTIFICATE_FILE: /tmp/apple_cert.p12
@@ -188,12 +181,42 @@ jobs:
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
@@ -225,6 +248,11 @@ jobs:
env:
CODER_BASE_IMAGE_TAG: ${{ steps.image-base-tag.outputs.tag }}
- name: Generate offline docs
run: |
version="$(./scripts/version.sh)"
make -j build/coder_docs_"$version".tgz
- name: ls build
run: ls -lh build
@@ -268,14 +296,17 @@ jobs:
version="$(./scripts/version.sh)"
mkdir -p build/helm
cp "build/coder_helm_${version}.tgz" build/helm
cp "build/provisioner_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/provisioner_helm_${version}.tgz gs://helm.coder.com/v2
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/index.yaml gs://helm.coder.com/v2
gsutil -h "Cache-Control:no-cache,max-age=0" cp helm/artifacthub-repo.yml gs://helm.coder.com/v2
- name: Upload artifacts to actions (if dry-run)
if: ${{ inputs.dry_run }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: release-artifacts
path: |
@@ -297,12 +328,88 @@ jobs:
event-type: coder-release
client-payload: '{"coder_version": "${{ steps.version.outputs.version }}"}'
publish-homebrew:
name: Publish to Homebrew tap
runs-on: ubuntu-latest
needs: release
if: ${{ !inputs.dry_run }}
steps:
# TODO: skip this if it's not a new release (i.e. a backport). This is
# fine right now because it just makes a PR that we can close.
- name: Update homebrew
env:
# Variables used by the `gh` command
GH_REPO: coder/homebrew-coder
GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
run: |
# Keep version number around for reference, removing any potential leading v
coder_version="$(echo "${{ needs.release.outputs.version }}" | tr -d v)"
set -euxo pipefail
# Setup Git
git config --global user.email "ci@coder.com"
git config --global user.name "Coder CI"
git config --global credential.helper "store"
temp_dir="$(mktemp -d)"
cd "$temp_dir"
# Download checksums
checksums_url="$(gh release view --repo coder/coder "v$coder_version" --json assets \
| jq -r ".assets | map(.url) | .[]" \
| grep -e ".checksums.txt\$")"
wget "$checksums_url" -O checksums.txt
# Get the SHAs
darwin_arm_sha="$(cat checksums.txt | grep "darwin_arm64.zip" | awk '{ print $1 }')"
darwin_intel_sha="$(cat checksums.txt | grep "darwin_amd64.zip" | awk '{ print $1 }')"
linux_sha="$(cat checksums.txt | grep "linux_amd64.tar.gz" | awk '{ print $1 }')"
echo "macOS arm64: $darwin_arm_sha"
echo "macOS amd64: $darwin_intel_sha"
echo "Linux amd64: $linux_sha"
# Check out the homebrew repo
git clone "https://github.com/$GH_REPO" homebrew-coder
brew_branch="auto-release/$coder_version"
cd homebrew-coder
# Check if a PR already exists.
pr_count="$(gh pr list --search "head:$brew_branch" --json id,closed | jq -r ".[] | select(.closed == false) | .id" | wc -l)"
if [[ "$pr_count" > 0 ]]; then
echo "Bailing out as PR already exists" 2>&1
exit 0
fi
# Set up cdrci credentials for pushing to homebrew-coder
echo "https://x-access-token:$GH_TOKEN@github.com" >> ~/.git-credentials
# Update the formulae and push
git checkout -b "$brew_branch"
./scripts/update-v2.sh "$coder_version" "$darwin_arm_sha" "$darwin_intel_sha" "$linux_sha"
git add .
git commit -m "coder $coder_version"
git push -u origin -f "$brew_branch"
# Create PR
gh pr create \
-B master -H "$brew_branch" \
-t "coder $coder_version" \
-b "" \
-r "${{ github.actor }}" \
-a "${{ github.actor }}" \
-b "This automatic PR was triggered by the release of Coder v$coder_version"
publish-winget:
name: Publish to winget-pkgs
runs-on: windows-latest
needs: release
if: ${{ !inputs.dry_run }}
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
@@ -335,12 +442,6 @@ jobs:
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,
@@ -364,8 +465,9 @@ jobs:
WINGET_GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
- name: Comment on PR
if: ${{ !inputs.dry_run }}
run: |
# wait 30 seconds
Start-Sleep -Seconds 30.0
# 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 | `
@@ -378,3 +480,66 @@ jobs:
# 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 }}
publish-chocolatey:
name: Publish to Chocolatey
runs-on: windows-latest
needs: release
if: ${{ !inputs.dry_run }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Same reason as for release.
- name: Fetch git tags
run: git fetch --tags --force
# From https://chocolatey.org
- name: Install Chocolatey
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
- name: Build chocolatey package
run: |
cd scripts/chocolatey
# 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 URL for the Windows ZIP from the release assets.
$zip_url = $release_assets.assets | `
Where-Object name -Match ".*_windows_amd64.zip$" | `
Select -ExpandProperty url
echo "ZIP URL: ${zip_url}"
echo "Package version: ${version}"
echo "Downloading ZIP..."
Invoke-WebRequest $zip_url -OutFile assets.zip
echo "Extracting ZIP..."
Expand-Archive assets.zip -DestinationPath assets/
# No need to specify nuspec if there's only one in the directory.
choco pack --version=$version binary_path=assets/coder.exe
choco apikey --api-key $env:CHOCO_API_KEY --source https://push.chocolatey.org/
# No need to specify nupkg if there's only one in the directory.
choco push --source https://push.chocolatey.org/
env:
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
# We need a GitHub token for the gh CLI to function under GitHub Actions
GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
+68 -51
View File
@@ -6,17 +6,14 @@ permissions:
security-events: write
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
# Uncomment when testing.
# pull_request:
schedule:
# Run every week at 10:24 on Thursday.
- cron: "24 10 * * 4"
# Run every 6 hours Monday-Friday!
- cron: "0 0/6 * * 1-5"
# Cancel in-progress runs for pull requests when developers push
# additional changes
@@ -26,9 +23,10 @@ concurrency:
jobs:
codeql:
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
@@ -36,20 +34,7 @@ jobs:
languages: go, javascript
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "~1.20"
- name: Go Cache Paths
id: go-cache-paths
run: |
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.GOMODCACHE }}
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
uses: ./.github/actions/setup-go
# Workaround to prevent CodeQL from building the dashboard.
- name: Remove Makefile
@@ -59,41 +44,54 @@ jobs:
- 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' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: "~1.20"
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Go Cache Paths
id: go-cache-paths
run: |
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- name: Setup Node
uses: ./.github/actions/setup-node
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.GOMODCACHE }}
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
- 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: Setup sqlc
uses: ./.github/actions/setup-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
@@ -115,8 +113,16 @@ jobs:
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: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@9ab158e8597f3b310480b9a69402b419bc03dbd5
uses: aquasecurity/trivy-action@fbd16365eb88e12433951383f5e99bd901fc618f
with:
image-ref: ${{ steps.build.outputs.image }}
format: sarif
@@ -130,8 +136,19 @@ jobs:
category: "Trivy"
- name: Upload Trivy scan results as an artifact
uses: actions/upload-artifact@v2
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 }}"
+32 -13
View File
@@ -1,4 +1,4 @@
name: Stale Issue and Branch Cleanup
name: Stale Issue, Banch and Old Workflows Cleanup
on:
schedule:
# Every day at midnight
@@ -10,24 +10,22 @@ jobs:
permissions:
issues: write
pull-requests: write
actions: write
steps:
- uses: actions/stale@v7.0.0
- name: stale
uses: actions/stale@v8.0.0
with:
stale-issue-label: "stale"
stale-pr-label: "stale"
days-before-stale: 90
days-before-stale: 180
# 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
stale-pr-message: >
This Pull Request is becoming stale. In order to minimize WIP,
prevent merge conflicts and keep the tracker readable, I'm going
close to this PR in 3 days if there isn't more activity.
stale-issue-message: >
This issue is becoming stale. In order to keep the tracker readable
and actionable, I'm going close to this issue in 7 days if there
isn't more activity.
# 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.
@@ -36,9 +34,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run delete-old-branches-action
uses: beatlabs/delete-old-branches-action@v0.0.9
uses: beatlabs/delete-old-branches-action@v0.0.10
with:
repo_token: ${{ github.token }}
date: "6 months ago"
@@ -46,3 +44,24 @@ jobs:
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
+13 -8
View File
@@ -4,6 +4,7 @@ Jetbrains = "JetBrains"
IST = "IST"
MacOS = "macOS"
AKS = "AKS"
O_WRONLY = "O_WRONLY"
[default.extend-words]
AKS = "AKS"
@@ -16,12 +17,16 @@ 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",
"**.svg",
"**.png",
"**.lock",
"go.sum",
"go.mod",
# These files contain base64 strings that confuse the detector
"**XService**.ts",
"**identity.go",
"scripts/ci-report/testdata/**",
"**/*_test.go",
"**/*.test.tsx",
"**/pnpm-lock.yaml",
]
+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 }}
+26 -7
View File
@@ -6,7 +6,8 @@
**/*.swp
gotests.coverage
gotests.xml
gotestsum.json
gotests_stats.json
gotests.json
node_modules/
vendor/
yarn-error.log
@@ -26,15 +27,17 @@ site/storybook-static/
site/test-results/*
site/e2e/test-results/*
site/e2e/states/*.json
site/e2e/.auth.json
site/playwright-report/*
site/.swc
# Make target for updating golden files.
cli/testdata/.gen-golden
# Make target for updating golden files (any dir).
.gen-golden
# Build
/build/
/dist/
site/out/
build/
dist/
out/
# Bundle analysis
site/stats/
@@ -45,8 +48,24 @@ site/stats/
*.lock.hcl
.terraform/
/.coderv2/*
**/.coderv2/*
**/__debug_bin
# direnv
.envrc
*.test
# Loadtesting
./scaletest/terraform/.terraform
./scaletest/terraform/.terraform.lock.hcl
scaletest/terraform/secrets.tfvars
.terraform.tfstate.*
# Nix
result
# Data dumps from unit tests
**/*.test.sql
# Filebrowser.db
**/filebrowser.db
+29 -11
View File
@@ -2,8 +2,19 @@
# Over time we should try tightening some of these.
linters-settings:
dupl:
# goal: 100
threshold: 412
exhaustruct:
include:
# Gradually extend to cover more of the codebase.
- 'httpmw\.\w+'
# We want to enforce all values are specified when inserting or updating
# a database row. Ref: #9936
- 'github.com/coder/coder/v2/coderd/database\.[^G][^e][^t]\w+Params'
gocognit:
min-complexity: 46 # Min code complexity (def 30).
min-complexity: 300
goconst:
min-len: 4 # Min length of string consts (def 3).
@@ -54,7 +65,6 @@ linters-settings:
# - importShadow
- indexAlloc
- initClause
- ioutilDeprecated
- mapKey
- methodExprCall
# - nestingReduce
@@ -115,9 +125,6 @@ linters-settings:
goimports:
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
gocyclo:
min-complexity: 50
importas:
no-unaliased: true
@@ -127,7 +134,8 @@ linters-settings:
- trialer
nestif:
min-complexity: 4 # Min complexity of if statements (def 5, goal 4)
# goal: 10
min-complexity: 20
revive:
# see https://github.com/mgechev/revive#available-rules for details.
@@ -194,18 +202,23 @@ issues:
linters:
# We use assertions rather than explicitly checking errors in tests
- errcheck
- forcetypeassert
- exhaustruct # This is unhelpful in tests.
- path: scripts/*
linters:
- exhaustruct
fix: true
max-issues-per-linter: 0
max-same-issues: 0
run:
concurrency: 4
skip-dirs:
- node_modules
- .git
skip-files:
- scripts/rules.go
timeout: 5m
timeout: 10m
# Over time, add more and more linters from
# https://golangci-lint.run/usage/linters/ as the code improves.
@@ -215,15 +228,20 @@ linters:
- asciicheck
- bidichk
- bodyclose
- deadcode
- dogsled
- errcheck
- errname
- errorlint
- exhaustruct
- exportloopref
- forcetypeassert
- gocritic
- gocyclo
# gocyclo is may be useful in the future when we start caring
# about testing complexity, but for the time being we should
# create a good culture around cognitive complexity.
# - gocyclo
- gocognit
- nestif
- goimports
- gomodguard
- gosec
@@ -259,4 +277,4 @@ linters:
- typecheck
- unconvert
- unused
- varcheck
- dupl
+35 -8
View File
@@ -9,7 +9,8 @@
**/*.swp
gotests.coverage
gotests.xml
gotestsum.json
gotests_stats.json
gotests.json
node_modules/
vendor/
yarn-error.log
@@ -29,15 +30,17 @@ site/storybook-static/
site/test-results/*
site/e2e/test-results/*
site/e2e/states/*.json
site/e2e/.auth.json
site/playwright-report/*
site/.swc
# Make target for updating golden files.
cli/testdata/.gen-golden
# Make target for updating golden files (any dir).
.gen-golden
# Build
/build/
/dist/
site/out/
build/
dist/
out/
# Bundle analysis
site/stats/
@@ -48,15 +51,31 @@ site/stats/
*.lock.hcl
.terraform/
/.coderv2/*
**/.coderv2/*
**/__debug_bin
# direnv
.envrc
*.test
# Loadtesting
./scaletest/terraform/.terraform
./scaletest/terraform/.terraform.lock.hcl
scaletest/terraform/secrets.tfvars
.terraform.tfstate.*
# Nix
result
# Data dumps from unit tests
**/*.test.sql
# Filebrowser.db
**/filebrowser.db
# .prettierignore.include:
# Helm templates contain variables that are invalid YAML and can't be formatted
# by Prettier.
helm/templates/*.yaml
helm/**/templates/*.yaml
# Terraform state files used in tests, these are automatically generated.
# Example: provisioner/terraform/testdata/instance-id/instance-id.tfstate.json
@@ -64,3 +83,11 @@ helm/templates/*.yaml
# Testdata shouldn't be formatted.
scripts/apitypings/testdata/**/*.ts
# Generated files shouldn't be formatted.
site/e2e/provisionerGenerated.ts
**/pnpm-lock.yaml
# Ignore generated JSON (e.g. examples/examples.gen.json).
**/*.gen.json
+9 -1
View File
@@ -1,6 +1,6 @@
# Helm templates contain variables that are invalid YAML and can't be formatted
# by Prettier.
helm/templates/*.yaml
helm/**/templates/*.yaml
# Terraform state files used in tests, these are automatically generated.
# Example: provisioner/terraform/testdata/instance-id/instance-id.tfstate.json
@@ -8,3 +8,11 @@ helm/templates/*.yaml
# Testdata shouldn't be formatted.
scripts/apitypings/testdata/**/*.ts
# Generated files shouldn't be formatted.
site/e2e/provisionerGenerated.ts
**/pnpm-lock.yaml
# Ignore generated JSON (e.g. examples/examples.gen.json).
**/*.gen.json
+9 -7
View File
@@ -1,16 +1,18 @@
# 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.
# `site/.editorconfig` for whitespace formatting options.
printWidth: 80
semi: false
proseWrap: always
trailingComma: all
useTabs: false
tabWidth: 2
overrides:
- files:
- README.md
- docs/api/**/*.md
- docs/cli/**/*.md
- docs/changelogs/*.md
- .github/**/*.{yaml,yml,toml}
- scripts/**/*.{yaml,yml,toml}
options:
proseWrap: preserve
- files:
- "site/**/*.yaml"
- "site/**/*.yml"
options:
proseWrap: always
+2 -2
View File
@@ -1,8 +1,8 @@
// Replace all NullTime with string
replace github.com/coder/coder/codersdk.NullTime string
replace github.com/coder/coder/v2/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
replace github.com/coder/coder/v2/codersdk.ProvisionerType string
// Do not render netip.Addr
replace netip.Addr string
+20 -13
View File
@@ -4,6 +4,7 @@
"agentsdk",
"apps",
"ASKPASS",
"authcheck",
"autostop",
"awsidentity",
"bodyclose",
@@ -19,6 +20,8 @@
"codersdk",
"cronstrue",
"databasefake",
"dbfake",
"dbgen",
"dbtype",
"DERP",
"derphttp",
@@ -33,8 +36,10 @@
"Dsts",
"embeddedpostgres",
"enablements",
"enterprisemeta",
"errgroup",
"eventsourcemock",
"externalauth",
"Failf",
"fatih",
"Formik",
@@ -89,7 +94,6 @@
"pqtype",
"prometheusmetrics",
"promhttp",
"promptui",
"protobuf",
"provisionerd",
"provisionerdserver",
@@ -113,6 +117,7 @@
"stretchr",
"STTY",
"stuntest",
"tanstack",
"tailbroker",
"tailcfg",
"tailexchange",
@@ -134,6 +139,7 @@
"thead",
"tios",
"tmpdir",
"tokenconfig",
"tparallel",
"trialer",
"trimprefix",
@@ -181,12 +187,20 @@
]
},
"eslint.workingDirectories": ["./site"],
"files.exclude": {
"**/node_modules": true
},
"search.exclude": {
"**.pb.go": true,
"**/*.gen.json": true,
"**/testdata/*": true,
"**Generated.ts": true,
"coderd/apidoc/**": true,
"docs/api/*.md": true,
"docs/templates/*.md": true,
"LICENSE": true,
"scripts/metricsdocgen/metrics": true,
"docs/api/*.md": true
"site/out/**": true,
"site/storybook-static/**": true,
"**.map": true,
"pnpm-lock.yaml": true
},
// Ensure files always have a newline.
"files.insertFinalNewline": true,
@@ -206,12 +220,5 @@
"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",
"grammarly.selectors": [
{
"language": "markdown",
"scheme": "file",
"pattern": "docs/contributing/frontend.md"
}
]
"typescript.tsdk": "./site/node_modules/typescript/lib"
}
+143 -47
View File
@@ -50,11 +50,11 @@ endif
# 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/*' \) -prune \)
-not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path '*/node_modules/*' -o -path '*/out/*' -o -path './coderd/apidoc/*' -o -path '*/.next/*' \) -prune \)
# Source files used for make targets, evaluated on use.
GO_SRC_FILES = $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go')
GO_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go' -not -name '*_test.go')
# All the shell files in the repo, excluding ignored files.
SHELL_SRC_FILES = $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.sh')
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 := \
@@ -107,9 +107,9 @@ endif
clean:
rm -rf build site/out
mkdir -p build site/out/bin
git restore site/out
rm -rf build/ site/build/ site/out/
mkdir -p build/ site/out/bin/
git restore site/out/
.PHONY: clean
build-slim: $(CODER_SLIM_BINARIES)
@@ -344,21 +344,33 @@ push/$(CODER_MAIN_IMAGE): $(CODER_MAIN_IMAGE)
docker manifest push "$$image_tag"
.PHONY: push/$(CODER_MAIN_IMAGE)
# Helm charts that are available
charts = coder provisioner
# Shortcut for Helm chart package.
build/coder_helm.tgz: build/coder_helm_$(VERSION).tgz
$(foreach chart,$(charts),build/$(chart)_helm.tgz): build/%_helm.tgz: build/%_helm_$(VERSION).tgz
rm -f "$@"
ln "$<" "$@"
# Helm chart package.
build/coder_helm_$(VERSION).tgz:
$(foreach chart,$(charts),build/$(chart)_helm_$(VERSION).tgz): build/%_helm_$(VERSION).tgz:
./scripts/helm.sh \
--version "$(VERSION)" \
--chart $* \
--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
../scripts/pnpm_install.sh
pnpm build
offlinedocs/out/index.html: $(shell find ./offlinedocs $(FIND_EXCLUSIONS) -type f) $(shell find ./docs $(FIND_EXCLUSIONS) -type f | sed 's: :\\ :g')
cd offlinedocs
../scripts/pnpm_install.sh
pnpm export
build/coder_docs_$(VERSION).tgz: offlinedocs/out/index.html
tar -czf "$@" -C offlinedocs/out .
install: build/coder_$(VERSION)_$(GOOS)_$(GOARCH)$(GOOS_BIN_EXT)
install_dir="$$(go env GOPATH)/bin"
@@ -382,9 +394,9 @@ fmt/prettier:
cd site
# Avoid writing files in CI to reduce file write activity
ifdef CI
yarn run format:check
pnpm run format:check
else
yarn run format:write
pnpm run format:write
endif
.PHONY: fmt/prettier
@@ -402,11 +414,21 @@ else
endif
.PHONY: fmt/shfmt
lint: lint/shellcheck lint/go
lint: lint/shellcheck lint/go lint/ts lint/helm lint/site-icons
.PHONY: lint
lint/site-icons:
./scripts/check_site_icons.sh
.PHONY: lint/site-icons
lint/ts:
cd site
pnpm i && pnpm lint
.PHONY: lint/ts
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
@@ -416,35 +438,55 @@ lint/shellcheck: $(SHELL_SRC_FILES)
shellcheck --external-sources $(SHELL_SRC_FILES)
.PHONY: lint/shellcheck
lint/helm:
cd helm
make lint
.PHONY: lint/helm
# All files generated by the database should be added here, and this can be used
# as a target for jobs that need to run after the database is generated.
DB_GEN_FILES := \
coderd/database/querier.go \
coderd/database/unique_constraint.go \
coderd/database/dbfake/dbfake.go \
coderd/database/dbmetrics/dbmetrics.go \
coderd/database/dbauthz/dbauthz.go \
coderd/database/dbmock/dbmock.go
# all gen targets should be added here and to gen/mark-fresh
gen: \
coderd/database/dump.sql \
coderd/database/querier.go \
provisionersdk/proto/provisioner.pb.go \
provisionerd/proto/provisionerd.pb.go \
coderd/database/dump.sql \
$(DB_GEN_FILES) \
site/src/api/typesGenerated.ts \
coderd/rbac/object_gen.go \
docs/admin/prometheus.md \
docs/cli/coder.md \
docs/cli.md \
docs/admin/audit-logs.md \
coderd/apidoc/swagger.json \
.prettierignore.include \
.prettierignore \
site/.prettierrc.yaml \
site/.prettierignore \
site/.eslintignore
site/.eslintignore \
site/e2e/provisionerGenerated.ts \
site/src/theme/icons.json \
examples/examples.gen.json
.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 \
provisionersdk/proto/provisioner.pb.go \
provisionerd/proto/provisionerd.pb.go \
coderd/database/dump.sql \
$(DB_GEN_FILES) \
site/src/api/typesGenerated.ts \
coderd/rbac/object_gen.go \
docs/admin/prometheus.md \
docs/cli/coder.md \
docs/cli.md \
docs/admin/audit-logs.md \
coderd/apidoc/swagger.json \
.prettierignore.include \
@@ -452,6 +494,9 @@ gen/mark-fresh:
site/.prettierrc.yaml \
site/.prettierignore \
site/.eslintignore \
site/e2e/provisionerGenerated.ts \
site/src/theme/icons.json \
examples/examples.gen.json \
"
for file in $$files; do
echo "$$file"
@@ -471,9 +516,14 @@ coderd/database/dump.sql: coderd/database/gen/dump/main.go $(wildcard coderd/dat
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/gen/enum/main.go
# coderd/database/queries.sql.go
# coderd/database/models.go
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 \
--go_out=. \
@@ -490,35 +540,70 @@ provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
--go-drpc_opt=paths=source_relative \
./provisionerd/proto/provisionerd.proto
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
site/src/api/typesGenerated.ts: $(wildcard scripts/apitypings/*) $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
go run ./scripts/apitypings/ > $@
pnpm run format:write:only "$@"
site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisionersdk/proto/provisioner.pb.go
cd site
yarn run format:types
../scripts/pnpm_install.sh
pnpm run gen:provisioner
site/src/theme/icons.json: $(wildcard scripts/gensite/*) $(wildcard site/static/icon/*)
go run ./scripts/gensite/ -icons "$@"
pnpm run format:write:only "$@"
examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates)
go run ./scripts/examplegen/main.go > examples/examples.gen.json
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
pnpm run format:write:only ./docs/admin/prometheus.md
docs/cli/coder.md: scripts/clidocgen/main.go $(GO_SRC_FILES) docs/manifest.json
BASE_PATH="." go run scripts/clidocgen/main.go
cd site
yarn run format:write:only ../docs/cli/*.md ../docs/manifest.json
docs/cli.md: scripts/clidocgen/main.go examples/examples.gen.json $(GO_SRC_FILES)
CI=true BASE_PATH="." go run ./scripts/clidocgen
pnpm 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
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
pnpm 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) .swaggo docs/manifest.json
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) $(DB_GEN_FILES) .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
pnpm run format:write:only ./docs/api ./docs/manifest.json ./coderd/apidoc/swagger.json
update-golden-files: cli/testdata/.gen-golden
update-golden-files: cli/testdata/.gen-golden helm/coder/tests/testdata/.gen-golden helm/provisioner/tests/testdata/.gen-golden scripts/ci-report/testdata/.gen-golden enterprise/cli/testdata/.gen-golden coderd/.gen-golden provisioner/terraform/testdata/.gen-golden
.PHONY: update-golden-files
cli/testdata/.gen-golden: $(wildcard cli/testdata/*.golden) $(GO_SRC_FILES)
go test ./cli -run=TestCommandHelp -update
cli/testdata/.gen-golden: $(wildcard cli/testdata/*.golden) $(wildcard cli/*.tpl) $(GO_SRC_FILES) $(wildcard cli/*_test.go)
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) $(wildcard enterprise/cli/*_test.go)
go test ./enterprise/cli -run="TestEnterpriseCommandHelp" -update
touch "$@"
helm/coder/tests/testdata/.gen-golden: $(wildcard helm/coder/tests/testdata/*.yaml) $(wildcard helm/coder/tests/testdata/*.golden) $(GO_SRC_FILES) $(wildcard helm/coder/tests/*_test.go)
go test ./helm/coder/tests -run=TestUpdateGoldenFiles -update
touch "$@"
helm/provisioner/tests/testdata/.gen-golden: $(wildcard helm/provisioner/tests/testdata/*.yaml) $(wildcard helm/provisioner/tests/testdata/*.golden) $(GO_SRC_FILES) $(wildcard helm/provisioner/tests/*_test.go)
go test ./helm/provisioner/tests -run=TestUpdateGoldenFiles -update
touch "$@"
coderd/.gen-golden: $(wildcard coderd/testdata/*/*.golden) $(GO_SRC_FILES) $(wildcard coderd/*_test.go)
go test ./coderd -run="Test.*Golden$$" -update
touch "$@"
provisioner/terraform/testdata/.gen-golden: $(wildcard provisioner/terraform/testdata/*/*.golden) $(GO_SRC_FILES) $(wildcard provisioner/terraform/*_test.go)
go test ./provisioner/terraform -run="Test.*Golden$$" -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
@@ -535,7 +620,7 @@ site/.prettierrc.yaml: .prettierrc.yaml
# - ./ -> ../
# - ./site -> ./
yq \
'.overrides[].files |= map(. | sub("^./"; "") | sub("^"; "../") | sub("../site/"; "./"))' \
'.overrides[].files |= map(. | sub("^./"; "") | sub("^"; "../") | sub("../site/"; "./") | sub("../!"; "!../"))' \
"$<" >> "$@"
# Combine .gitignore with .prettierignore.include to generate .prettierignore.
@@ -581,22 +666,23 @@ site/.eslintignore site/.prettierignore: .prettierignore Makefile
echo "$${ignore}$${rule}" >> "$@"
done < "$<"
test: test-clean
gotestsum -- -v -short ./...
test:
gotestsum --format standard-quiet -- -v -short -count=1 ./...
.PHONY: test
# When updating -timeout for this test, keep in sync with
# test-go-postgres (.github/workflows/coder.yaml).
test-postgres: test-clean test-postgres-docker
# Do add coverage flags so that test caching works.
test-postgres: 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="./..." -- \
-covermode=atomic -coverprofile="gotests.coverage" -timeout=20m \
-parallel=4 \
-coverpkg=./... \
-count=1 -race -failfast
-timeout=20m \
-failfast \
-count=1
.PHONY: test-postgres
test-postgres-docker:
@@ -611,8 +697,10 @@ test-postgres-docker:
--name test-postgres-docker \
--restart no \
--detach \
postgres:13 \
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 \
@@ -625,6 +713,14 @@ test-postgres-docker:
done
.PHONY: test-postgres-docker
# Make sure to keep this in sync with test-go-race from .github/workflows/ci.yaml.
test-race:
gotestsum --junitfile="gotests.xml" -- -race -count=1 ./...
.PHONY: test-race
# Note: we used to add this to the test target, but it's not necessary and we can
# achieve the desired result by specifying -count=1 in the go test invocation
# instead. Keeping it here for convenience.
test-clean:
go clean -testcache
.PHONY: test-clean
+2 -2
View File
@@ -74,7 +74,7 @@ You can run the install script with `--dry-run` to see the commands that will be
Once installed, you can start a production deployment<sup>1</sup> with a single command:
```console
```shell
# Automatically sets up an external access URL on *.try.coder.app
coder server
@@ -84,7 +84,7 @@ 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 [quickstart guide](https://coder.com/docs/v2/latest/quickstart) for a full walkthrough.
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
+47 -39
View File
@@ -1,7 +1,7 @@
# 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,
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.
@@ -10,64 +10,72 @@ 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.
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.
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
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.
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.
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.
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.
- 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:
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;
- 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;
- 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
- 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.
+1018 -824
View File
File diff suppressed because it is too large Load Diff
+1618 -384
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -0,0 +1,5 @@
// Package agentproctest contains utility functions
// for testing process management in the agent.
package agentproctest
//go:generate mockgen -destination ./syscallermock.go -package agentproctest github.com/coder/coder/v2/agent/agentproc Syscaller
+49
View File
@@ -0,0 +1,49 @@
package agentproctest
import (
"fmt"
"testing"
"github.com/spf13/afero"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/agent/agentproc"
"github.com/coder/coder/v2/cryptorand"
)
func GenerateProcess(t *testing.T, fs afero.Fs, muts ...func(*agentproc.Process)) agentproc.Process {
t.Helper()
pid, err := cryptorand.Intn(1<<31 - 1)
require.NoError(t, err)
arg1, err := cryptorand.String(5)
require.NoError(t, err)
arg2, err := cryptorand.String(5)
require.NoError(t, err)
arg3, err := cryptorand.String(5)
require.NoError(t, err)
cmdline := fmt.Sprintf("%s\x00%s\x00%s", arg1, arg2, arg3)
process := agentproc.Process{
CmdLine: cmdline,
PID: int32(pid),
}
for _, mut := range muts {
mut(&process)
}
process.Dir = fmt.Sprintf("%s/%d", "/proc", process.PID)
err = fs.MkdirAll(process.Dir, 0o555)
require.NoError(t, err)
err = afero.WriteFile(fs, fmt.Sprintf("%s/cmdline", process.Dir), []byte(process.CmdLine), 0o444)
require.NoError(t, err)
return process
}
@@ -0,0 +1,78 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/coder/coder/v2/agent/agentproc (interfaces: Syscaller)
// Package agentproctest is a generated GoMock package.
package agentproctest
import (
reflect "reflect"
syscall "syscall"
gomock "github.com/golang/mock/gomock"
)
// MockSyscaller is a mock of Syscaller interface.
type MockSyscaller struct {
ctrl *gomock.Controller
recorder *MockSyscallerMockRecorder
}
// MockSyscallerMockRecorder is the mock recorder for MockSyscaller.
type MockSyscallerMockRecorder struct {
mock *MockSyscaller
}
// NewMockSyscaller creates a new mock instance.
func NewMockSyscaller(ctrl *gomock.Controller) *MockSyscaller {
mock := &MockSyscaller{ctrl: ctrl}
mock.recorder = &MockSyscallerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockSyscaller) EXPECT() *MockSyscallerMockRecorder {
return m.recorder
}
// GetPriority mocks base method.
func (m *MockSyscaller) GetPriority(arg0 int32) (int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetPriority", arg0)
ret0, _ := ret[0].(int)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetPriority indicates an expected call of GetPriority.
func (mr *MockSyscallerMockRecorder) GetPriority(arg0 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPriority", reflect.TypeOf((*MockSyscaller)(nil).GetPriority), arg0)
}
// Kill mocks base method.
func (m *MockSyscaller) Kill(arg0 int32, arg1 syscall.Signal) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Kill", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// Kill indicates an expected call of Kill.
func (mr *MockSyscallerMockRecorder) Kill(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Kill", reflect.TypeOf((*MockSyscaller)(nil).Kill), arg0, arg1)
}
// SetPriority mocks base method.
func (m *MockSyscaller) SetPriority(arg0 int32, arg1 int) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SetPriority", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// SetPriority indicates an expected call of SetPriority.
func (mr *MockSyscallerMockRecorder) SetPriority(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetPriority", reflect.TypeOf((*MockSyscaller)(nil).SetPriority), arg0, arg1)
}
+3
View File
@@ -0,0 +1,3 @@
// Package agentproc contains logic for interfacing with local
// processes running in the same context as the agent.
package agentproc
+24
View File
@@ -0,0 +1,24 @@
//go:build !linux
// +build !linux
package agentproc
import (
"github.com/spf13/afero"
)
func (p *Process) Niceness(sc Syscaller) (int, error) {
return 0, errUnimplemented
}
func (p *Process) SetNiceness(sc Syscaller, score int) error {
return errUnimplemented
}
func (p *Process) Cmd() string {
return ""
}
func List(fs afero.Fs, syscaller Syscaller) ([]*Process, error) {
return nil, errUnimplemented
}
+166
View File
@@ -0,0 +1,166 @@
package agentproc_test
import (
"runtime"
"syscall"
"testing"
"github.com/golang/mock/gomock"
"github.com/spf13/afero"
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/agent/agentproc"
"github.com/coder/coder/v2/agent/agentproc/agentproctest"
)
func TestList(t *testing.T) {
t.Parallel()
if runtime.GOOS != "linux" {
t.Skipf("skipping non-linux environment")
}
t.Run("OK", func(t *testing.T) {
t.Parallel()
var (
fs = afero.NewMemMapFs()
sc = agentproctest.NewMockSyscaller(gomock.NewController(t))
expectedProcs = make(map[int32]agentproc.Process)
)
for i := 0; i < 4; i++ {
proc := agentproctest.GenerateProcess(t, fs)
expectedProcs[proc.PID] = proc
sc.EXPECT().
Kill(proc.PID, syscall.Signal(0)).
Return(nil)
}
actualProcs, err := agentproc.List(fs, sc)
require.NoError(t, err)
require.Len(t, actualProcs, len(expectedProcs))
for _, proc := range actualProcs {
expected, ok := expectedProcs[proc.PID]
require.True(t, ok)
require.Equal(t, expected.PID, proc.PID)
require.Equal(t, expected.CmdLine, proc.CmdLine)
require.Equal(t, expected.Dir, proc.Dir)
}
})
t.Run("FinishedProcess", func(t *testing.T) {
t.Parallel()
var (
fs = afero.NewMemMapFs()
sc = agentproctest.NewMockSyscaller(gomock.NewController(t))
expectedProcs = make(map[int32]agentproc.Process)
)
for i := 0; i < 3; i++ {
proc := agentproctest.GenerateProcess(t, fs)
expectedProcs[proc.PID] = proc
sc.EXPECT().
Kill(proc.PID, syscall.Signal(0)).
Return(nil)
}
// Create a process that's already finished. We're not adding
// it to the map because it should be skipped over.
proc := agentproctest.GenerateProcess(t, fs)
sc.EXPECT().
Kill(proc.PID, syscall.Signal(0)).
Return(xerrors.New("os: process already finished"))
actualProcs, err := agentproc.List(fs, sc)
require.NoError(t, err)
require.Len(t, actualProcs, len(expectedProcs))
for _, proc := range actualProcs {
expected, ok := expectedProcs[proc.PID]
require.True(t, ok)
require.Equal(t, expected.PID, proc.PID)
require.Equal(t, expected.CmdLine, proc.CmdLine)
require.Equal(t, expected.Dir, proc.Dir)
}
})
t.Run("NoSuchProcess", func(t *testing.T) {
t.Parallel()
var (
fs = afero.NewMemMapFs()
sc = agentproctest.NewMockSyscaller(gomock.NewController(t))
expectedProcs = make(map[int32]agentproc.Process)
)
for i := 0; i < 3; i++ {
proc := agentproctest.GenerateProcess(t, fs)
expectedProcs[proc.PID] = proc
sc.EXPECT().
Kill(proc.PID, syscall.Signal(0)).
Return(nil)
}
// Create a process that doesn't exist. We're not adding
// it to the map because it should be skipped over.
proc := agentproctest.GenerateProcess(t, fs)
sc.EXPECT().
Kill(proc.PID, syscall.Signal(0)).
Return(syscall.ESRCH)
actualProcs, err := agentproc.List(fs, sc)
require.NoError(t, err)
require.Len(t, actualProcs, len(expectedProcs))
for _, proc := range actualProcs {
expected, ok := expectedProcs[proc.PID]
require.True(t, ok)
require.Equal(t, expected.PID, proc.PID)
require.Equal(t, expected.CmdLine, proc.CmdLine)
require.Equal(t, expected.Dir, proc.Dir)
}
})
}
// These tests are not very interesting but they provide some modicum of
// confidence.
func TestProcess(t *testing.T) {
t.Parallel()
if runtime.GOOS != "linux" {
t.Skipf("skipping non-linux environment")
}
t.Run("SetNiceness", func(t *testing.T) {
t.Parallel()
var (
sc = agentproctest.NewMockSyscaller(gomock.NewController(t))
proc = &agentproc.Process{
PID: 32,
}
score = 20
)
sc.EXPECT().SetPriority(proc.PID, score).Return(nil)
err := proc.SetNiceness(sc, score)
require.NoError(t, err)
})
t.Run("Cmd", func(t *testing.T) {
t.Parallel()
var (
proc = &agentproc.Process{
CmdLine: "helloworld\x00--arg1\x00--arg2",
}
expectedName = "helloworld --arg1 --arg2"
)
require.Equal(t, expectedName, proc.Cmd())
})
}
+109
View File
@@ -0,0 +1,109 @@
//go:build linux
// +build linux
package agentproc
import (
"errors"
"path/filepath"
"strconv"
"strings"
"syscall"
"github.com/spf13/afero"
"golang.org/x/xerrors"
)
func List(fs afero.Fs, syscaller Syscaller) ([]*Process, error) {
d, err := fs.Open(defaultProcDir)
if err != nil {
return nil, xerrors.Errorf("open dir %q: %w", defaultProcDir, err)
}
defer d.Close()
entries, err := d.Readdirnames(0)
if err != nil {
return nil, xerrors.Errorf("readdirnames: %w", err)
}
processes := make([]*Process, 0, len(entries))
for _, entry := range entries {
pid, err := strconv.ParseInt(entry, 10, 32)
if err != nil {
continue
}
// Check that the process still exists.
exists, err := isProcessExist(syscaller, int32(pid))
if err != nil {
return nil, xerrors.Errorf("check process exists: %w", err)
}
if !exists {
continue
}
cmdline, err := afero.ReadFile(fs, filepath.Join(defaultProcDir, entry, "cmdline"))
if err != nil {
var errNo syscall.Errno
if xerrors.As(err, &errNo) && errNo == syscall.EPERM {
continue
}
return nil, xerrors.Errorf("read cmdline: %w", err)
}
processes = append(processes, &Process{
PID: int32(pid),
CmdLine: string(cmdline),
Dir: filepath.Join(defaultProcDir, entry),
})
}
return processes, nil
}
func isProcessExist(syscaller Syscaller, pid int32) (bool, error) {
err := syscaller.Kill(pid, syscall.Signal(0))
if err == nil {
return true, nil
}
if err.Error() == "os: process already finished" {
return false, nil
}
var errno syscall.Errno
if !errors.As(err, &errno) {
return false, err
}
switch errno {
case syscall.ESRCH:
return false, nil
case syscall.EPERM:
return true, nil
}
return false, xerrors.Errorf("kill: %w", err)
}
func (p *Process) Niceness(sc Syscaller) (int, error) {
nice, err := sc.GetPriority(p.PID)
if err != nil {
return 0, xerrors.Errorf("get priority for %q: %w", p.CmdLine, err)
}
return nice, nil
}
func (p *Process) SetNiceness(sc Syscaller, score int) error {
err := sc.SetPriority(p.PID, score)
if err != nil {
return xerrors.Errorf("set priority for %q: %w", p.CmdLine, err)
}
return nil
}
func (p *Process) Cmd() string {
return strings.Join(p.cmdLine(), " ")
}
func (p *Process) cmdLine() []string {
return strings.Split(p.CmdLine, "\x00")
}
+19
View File
@@ -0,0 +1,19 @@
package agentproc
import (
"syscall"
)
type Syscaller interface {
SetPriority(pid int32, priority int) error
GetPriority(pid int32) (int, error)
Kill(pid int32, sig syscall.Signal) error
}
const defaultProcDir = "/proc"
type Process struct {
Dir string
CmdLine string
PID int32
}
+30
View File
@@ -0,0 +1,30 @@
//go:build !linux
// +build !linux
package agentproc
import (
"syscall"
"golang.org/x/xerrors"
)
func NewSyscaller() Syscaller {
return nopSyscaller{}
}
var errUnimplemented = xerrors.New("unimplemented")
type nopSyscaller struct{}
func (nopSyscaller) SetPriority(pid int32, priority int) error {
return errUnimplemented
}
func (nopSyscaller) GetPriority(pid int32) (int, error) {
return 0, errUnimplemented
}
func (nopSyscaller) Kill(pid int32, sig syscall.Signal) error {
return errUnimplemented
}
+42
View File
@@ -0,0 +1,42 @@
//go:build linux
// +build linux
package agentproc
import (
"syscall"
"golang.org/x/sys/unix"
"golang.org/x/xerrors"
)
func NewSyscaller() Syscaller {
return UnixSyscaller{}
}
type UnixSyscaller struct{}
func (UnixSyscaller) SetPriority(pid int32, nice int) error {
err := unix.Setpriority(unix.PRIO_PROCESS, int(pid), nice)
if err != nil {
return xerrors.Errorf("set priority: %w", err)
}
return nil
}
func (UnixSyscaller) GetPriority(pid int32) (int, error) {
nice, err := unix.Getpriority(0, int(pid))
if err != nil {
return 0, xerrors.Errorf("get priority: %w", err)
}
return nice, nil
}
func (UnixSyscaller) Kill(pid int32, sig syscall.Signal) error {
err := syscall.Kill(int(pid), sig)
if err != nil {
return xerrors.Errorf("kill: %w", err)
}
return nil
}
+283
View File
@@ -0,0 +1,283 @@
package agentscripts
import (
"context"
"errors"
"fmt"
"io"
"os"
"os/exec"
"os/user"
"path/filepath"
"sync"
"sync/atomic"
"time"
"github.com/robfig/cron/v3"
"github.com/spf13/afero"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
"cdr.dev/slog"
"github.com/coder/coder/v2/agent/agentssh"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
)
var (
// ErrTimeout is returned when a script times out.
ErrTimeout = xerrors.New("script timed out")
parser = cron.NewParser(cron.Second | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.DowOptional)
)
// Options are a set of options for the runner.
type Options struct {
LogDir string
Logger slog.Logger
SSHServer *agentssh.Server
Filesystem afero.Fs
PatchLogs func(ctx context.Context, req agentsdk.PatchLogs) error
}
// New creates a runner for the provided scripts.
func New(opts Options) *Runner {
cronCtx, cronCtxCancel := context.WithCancel(context.Background())
return &Runner{
Options: opts,
cronCtx: cronCtx,
cronCtxCancel: cronCtxCancel,
cron: cron.New(cron.WithParser(parser)),
closed: make(chan struct{}),
}
}
type Runner struct {
Options
cronCtx context.Context
cronCtxCancel context.CancelFunc
cmdCloseWait sync.WaitGroup
closed chan struct{}
closeMutex sync.Mutex
cron *cron.Cron
initialized atomic.Bool
scripts []codersdk.WorkspaceAgentScript
}
// Init initializes the runner with the provided scripts.
// It also schedules any scripts that have a schedule.
// This function must be called before Execute.
func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript) error {
if r.initialized.Load() {
return xerrors.New("init: already initialized")
}
r.initialized.Store(true)
r.scripts = scripts
r.Logger.Info(r.cronCtx, "initializing agent scripts", slog.F("script_count", len(scripts)), slog.F("log_dir", r.LogDir))
for _, script := range scripts {
if script.Cron == "" {
continue
}
script := script
_, err := r.cron.AddFunc(script.Cron, func() {
err := r.run(r.cronCtx, script)
if err != nil {
r.Logger.Warn(context.Background(), "run agent script on schedule", slog.Error(err))
}
})
if err != nil {
return xerrors.Errorf("add schedule: %w", err)
}
}
return nil
}
// StartCron starts the cron scheduler.
// This is done async to allow for the caller to execute scripts prior.
func (r *Runner) StartCron() {
r.cron.Start()
}
// Execute runs a set of scripts according to a filter.
func (r *Runner) Execute(ctx context.Context, filter func(script codersdk.WorkspaceAgentScript) bool) error {
if filter == nil {
// Execute em' all!
filter = func(script codersdk.WorkspaceAgentScript) bool {
return true
}
}
var eg errgroup.Group
for _, script := range r.scripts {
if !filter(script) {
continue
}
script := script
eg.Go(func() error {
err := r.run(ctx, script)
if err != nil {
return xerrors.Errorf("run agent script %q: %w", script.LogSourceID, err)
}
return nil
})
}
return eg.Wait()
}
// run executes the provided script with the timeout.
// If the timeout is exceeded, the process is sent an interrupt signal.
// If the process does not exit after a few seconds, it is forcefully killed.
// This function immediately returns after a timeout, and does not wait for the process to exit.
func (r *Runner) run(ctx context.Context, script codersdk.WorkspaceAgentScript) error {
logPath := script.LogPath
if logPath == "" {
logPath = fmt.Sprintf("coder-script-%s.log", script.LogSourceID)
}
if logPath[0] == '~' {
// First we check the environment.
homeDir, err := os.UserHomeDir()
if err != nil {
u, err := user.Current()
if err != nil {
return xerrors.Errorf("current user: %w", err)
}
homeDir = u.HomeDir
}
logPath = filepath.Join(homeDir, logPath[1:])
}
logPath = os.ExpandEnv(logPath)
if !filepath.IsAbs(logPath) {
logPath = filepath.Join(r.LogDir, logPath)
}
logger := r.Logger.With(slog.F("log_path", logPath))
logger.Info(ctx, "running agent script", slog.F("script", script.Script))
fileWriter, err := r.Filesystem.OpenFile(logPath, os.O_CREATE|os.O_RDWR, 0o600)
if err != nil {
return xerrors.Errorf("open %s script log file: %w", logPath, err)
}
defer func() {
err := fileWriter.Close()
if err != nil {
logger.Warn(ctx, fmt.Sprintf("close %s script log file", logPath), slog.Error(err))
}
}()
var cmd *exec.Cmd
cmdCtx := ctx
if script.Timeout > 0 {
var ctxCancel context.CancelFunc
cmdCtx, ctxCancel = context.WithTimeout(ctx, script.Timeout)
defer ctxCancel()
}
cmdPty, err := r.SSHServer.CreateCommand(cmdCtx, script.Script, nil)
if err != nil {
return xerrors.Errorf("%s script: create command: %w", logPath, err)
}
cmd = cmdPty.AsExec()
cmd.SysProcAttr = cmdSysProcAttr()
cmd.WaitDelay = 10 * time.Second
cmd.Cancel = cmdCancel(cmd)
send, flushAndClose := agentsdk.LogsSender(script.LogSourceID, r.PatchLogs, logger)
// If ctx is canceled here (or in a writer below), we may be
// discarding logs, but that's okay because we're shutting down
// anyway. We could consider creating a new context here if we
// want better control over flush during shutdown.
defer func() {
if err := flushAndClose(ctx); err != nil {
logger.Warn(ctx, "flush startup logs failed", slog.Error(err))
}
}()
infoW := agentsdk.LogsWriter(ctx, send, script.LogSourceID, codersdk.LogLevelInfo)
defer infoW.Close()
errW := agentsdk.LogsWriter(ctx, send, script.LogSourceID, codersdk.LogLevelError)
defer errW.Close()
cmd.Stdout = io.MultiWriter(fileWriter, infoW)
cmd.Stderr = io.MultiWriter(fileWriter, errW)
start := time.Now()
defer func() {
end := time.Now()
execTime := end.Sub(start)
exitCode := 0
if err != nil {
exitCode = 255 // Unknown status.
var exitError *exec.ExitError
if xerrors.As(err, &exitError) {
exitCode = exitError.ExitCode()
}
logger.Warn(ctx, fmt.Sprintf("%s script failed", logPath), slog.F("execution_time", execTime), slog.F("exit_code", exitCode), slog.Error(err))
} else {
logger.Info(ctx, fmt.Sprintf("%s script completed", logPath), slog.F("execution_time", execTime), slog.F("exit_code", exitCode))
}
}()
err = cmd.Start()
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
return ErrTimeout
}
return xerrors.Errorf("%s script: start command: %w", logPath, err)
}
cmdDone := make(chan error, 1)
err = r.trackCommandGoroutine(func() {
cmdDone <- cmd.Wait()
})
if err != nil {
return xerrors.Errorf("%s script: track command goroutine: %w", logPath, err)
}
select {
case <-cmdCtx.Done():
// Wait for the command to drain!
select {
case <-cmdDone:
case <-time.After(10 * time.Second):
}
err = cmdCtx.Err()
case err = <-cmdDone:
}
if errors.Is(err, context.DeadlineExceeded) {
err = ErrTimeout
}
return err
}
func (r *Runner) Close() error {
r.closeMutex.Lock()
defer r.closeMutex.Unlock()
if r.isClosed() {
return nil
}
close(r.closed)
r.cronCtxCancel()
r.cron.Stop()
r.cmdCloseWait.Wait()
return nil
}
func (r *Runner) trackCommandGoroutine(fn func()) error {
r.closeMutex.Lock()
defer r.closeMutex.Unlock()
if r.isClosed() {
return xerrors.New("track command goroutine: closed")
}
r.cmdCloseWait.Add(1)
go func() {
defer r.cmdCloseWait.Done()
fn()
}()
return nil
}
func (r *Runner) isClosed() bool {
select {
case <-r.closed:
return true
default:
return false
}
}
+20
View File
@@ -0,0 +1,20 @@
//go:build !windows
package agentscripts
import (
"os/exec"
"syscall"
)
func cmdSysProcAttr() *syscall.SysProcAttr {
return &syscall.SysProcAttr{
Setsid: true,
}
}
func cmdCancel(cmd *exec.Cmd) func() error {
return func() error {
return syscall.Kill(-cmd.Process.Pid, syscall.SIGHUP)
}
}
+80
View File
@@ -0,0 +1,80 @@
package agentscripts_test
import (
"context"
"testing"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/afero"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"
"go.uber.org/goleak"
"cdr.dev/slog/sloggers/slogtest"
"github.com/coder/coder/v2/agent/agentscripts"
"github.com/coder/coder/v2/agent/agentssh"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
)
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
func TestExecuteBasic(t *testing.T) {
t.Parallel()
logs := make(chan agentsdk.PatchLogs, 1)
runner := setup(t, func(ctx context.Context, req agentsdk.PatchLogs) error {
logs <- req
return nil
})
defer runner.Close()
err := runner.Init([]codersdk.WorkspaceAgentScript{{
Script: "echo hello",
}})
require.NoError(t, err)
require.NoError(t, runner.Execute(context.Background(), func(script codersdk.WorkspaceAgentScript) bool {
return true
}))
log := <-logs
require.Equal(t, "hello", log.Logs[0].Output)
}
func TestTimeout(t *testing.T) {
t.Parallel()
runner := setup(t, nil)
defer runner.Close()
err := runner.Init([]codersdk.WorkspaceAgentScript{{
Script: "sleep infinity",
Timeout: time.Millisecond,
}})
require.NoError(t, err)
require.ErrorIs(t, runner.Execute(context.Background(), nil), agentscripts.ErrTimeout)
}
func setup(t *testing.T, patchLogs func(ctx context.Context, req agentsdk.PatchLogs) error) *agentscripts.Runner {
t.Helper()
if patchLogs == nil {
// noop
patchLogs = func(ctx context.Context, req agentsdk.PatchLogs) error {
return nil
}
}
fs := afero.NewMemMapFs()
logger := slogtest.Make(t, nil)
s, err := agentssh.NewServer(context.Background(), logger, prometheus.NewRegistry(), fs, 0, "")
require.NoError(t, err)
s.AgentToken = func() string { return "" }
s.Manifest = atomic.NewPointer(&agentsdk.Manifest{})
t.Cleanup(func() {
_ = s.Close()
})
return agentscripts.New(agentscripts.Options{
LogDir: t.TempDir(),
Logger: logger,
SSHServer: s,
Filesystem: fs,
PatchLogs: patchLogs,
})
}
@@ -0,0 +1,17 @@
package agentscripts
import (
"os"
"os/exec"
"syscall"
)
func cmdSysProcAttr() *syscall.SysProcAttr {
return &syscall.SysProcAttr{}
}
func cmdCancel(cmd *exec.Cmd) func() error {
return func() error {
return cmd.Process.Signal(os.Interrupt)
}
}
+875
View File
@@ -0,0 +1,875 @@
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/kballard/go-shellquote"
"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/v2/agent/usershell"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/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:]...)
}
// Always force lowercase checking to be case-insensitive.
switch strings.ToLower(magicType) {
case strings.ToLower(MagicSessionTypeVSCode):
s.connCountVSCode.Add(1)
defer s.connCountVSCode.Add(-1)
case strings.ToLower(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(s.fs, session.RawCommand()) {
manifest := s.Manifest.Load()
if manifest != nil {
err := showMOTD(s.fs, 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"
}
name := shell
args := []string{caller, script}
// A preceding space is generally not idiomatic for a shebang,
// but in Terraform it's quite standard to use <<EOF for a multi-line
// string which would indent with spaces, so we accept it for user-ease.
if strings.HasPrefix(strings.TrimSpace(script), "#!") {
// If the script starts with a shebang, we should
// execute it directly. This is useful for running
// scripts that aren't executable.
shebang := strings.SplitN(strings.TrimSpace(script), "\n", 2)[0]
shebang = strings.TrimSpace(shebang)
shebang = strings.TrimPrefix(shebang, "#!")
words, err := shellquote.Split(shebang)
if err != nil {
return nil, xerrors.Errorf("split shebang: %w", err)
}
name = words[0]
if len(words) > 1 {
args = words[1:]
} else {
args = []string{}
}
args = append(args, 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, name, 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(fs afero.Fs, 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 = fs.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(fs afero.Fs, dest io.Writer, filename string) error {
if filename == "" {
return nil
}
f, err := fs.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/v2/pty"
"github.com/coder/coder/v2/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")
}
+181
View File
@@ -0,0 +1,181 @@
// 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"
"runtime"
"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/v2/agent/agentssh"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/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_ExecuteShebang(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("bash doesn't exist on Windows")
}
ctx := context.Background()
logger := slogtest.Make(t, nil)
s, err := agentssh.NewServer(ctx, logger, prometheus.NewRegistry(), afero.NewMemMapFs(), 0, "")
require.NoError(t, err)
t.Cleanup(func() {
_ = s.Close()
})
s.AgentToken = func() string { return "" }
s.Manifest = atomic.NewPointer(&agentsdk.Manifest{})
t.Run("Basic", func(t *testing.T) {
t.Parallel()
cmd, err := s.CreateCommand(ctx, `#!/bin/bash
echo test`, nil)
require.NoError(t, err)
output, err := cmd.AsExec().CombinedOutput()
require.NoError(t, err)
require.Equal(t, "test\n", string(output))
})
t.Run("Args", func(t *testing.T) {
t.Parallel()
cmd, err := s.CreateCommand(ctx, `#!/usr/bin/env bash
echo test`, nil)
require.NoError(t, err)
output, err := cmd.AsExec().CombinedOutput()
require.NoError(t, err)
require.Equal(t, "test\n", string(output))
})
}
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:
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
package agent
package agentssh
import (
"context"
+85
View File
@@ -0,0 +1,85 @@
package agentssh
import (
"strings"
"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"
}
// Always be case insensitive
return strings.ToLower(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/v2/agent/agentssh"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/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 agenttest
import (
"context"
"net/url"
"testing"
"github.com/stretchr/testify/assert"
"cdr.dev/slog"
"cdr.dev/slog/sloggers/slogtest"
"github.com/coder/coder/v2/agent"
"github.com/coder/coder/v2/codersdk/agentsdk"
)
// New starts a new agent for use in tests.
// The agent will use the provided coder URL and session token.
// The options passed to agent.New() can be modified by passing an optional
// variadic func(*agent.Options).
// Returns the agent. Closing the agent is handled by the test cleanup.
// It is the responsibility of the caller to call coderdtest.AwaitWorkspaceAgents
// to ensure agent is connected.
func New(t testing.TB, coderURL *url.URL, agentToken string, opts ...func(*agent.Options)) agent.Agent {
t.Helper()
var o agent.Options
log := slogtest.Make(t, nil).Leveled(slog.LevelDebug).Named("agent")
o.Logger = log
for _, opt := range opts {
opt(&o)
}
if o.Client == nil {
agentClient := agentsdk.New(coderURL)
agentClient.SetSessionToken(agentToken)
agentClient.SDK.SetLogger(log)
o.Client = agentClient
}
if o.ExchangeToken == nil {
o.ExchangeToken = func(_ context.Context) (string, error) {
return agentToken, nil
}
}
if o.LogDir == "" {
o.LogDir = t.TempDir()
}
agt := agent.New(o)
t.Cleanup(func() {
assert.NoError(t, agt.Close(), "failed to close agent during cleanup")
})
return agt
}
+224
View File
@@ -0,0 +1,224 @@
package agenttest
import (
"context"
"io"
"net"
"sync"
"testing"
"time"
"github.com/google/uuid"
"golang.org/x/exp/maps"
"golang.org/x/xerrors"
"cdr.dev/slog"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/tailnet"
"github.com/coder/coder/v2/testutil"
)
func NewClient(t testing.TB,
logger slog.Logger,
agentID uuid.UUID,
manifest agentsdk.Manifest,
statsChan chan *agentsdk.Stats,
coordinator tailnet.Coordinator,
) *Client {
if manifest.AgentID == uuid.Nil {
manifest.AgentID = agentID
}
return &Client{
t: t,
logger: logger.Named("client"),
agentID: agentID,
manifest: manifest,
statsChan: statsChan,
coordinator: coordinator,
derpMapUpdates: make(chan agentsdk.DERPMapUpdate),
}
}
type Client struct {
t testing.TB
logger slog.Logger
agentID uuid.UUID
manifest agentsdk.Manifest
metadata map[string]agentsdk.Metadata
statsChan chan *agentsdk.Stats
coordinator tailnet.Coordinator
LastWorkspaceAgent func()
PatchWorkspaceLogs func() error
GetServiceBannerFunc func() (codersdk.ServiceBannerConfig, error)
mu sync.Mutex // Protects following.
lifecycleStates []codersdk.WorkspaceAgentLifecycle
startup agentsdk.PostStartupRequest
logs []agentsdk.Log
derpMapUpdates chan agentsdk.DERPMapUpdate
}
func (c *Client) Manifest(_ context.Context) (agentsdk.Manifest, error) {
return c.manifest, nil
}
func (c *Client) Listen(_ context.Context) (net.Conn, error) {
clientConn, serverConn := net.Pipe()
closed := make(chan struct{})
c.LastWorkspaceAgent = func() {
_ = serverConn.Close()
_ = clientConn.Close()
<-closed
}
c.t.Cleanup(c.LastWorkspaceAgent)
go func() {
_ = c.coordinator.ServeAgent(serverConn, c.agentID, "")
close(closed)
}()
return clientConn, nil
}
func (c *Client) ReportStats(ctx context.Context, _ slog.Logger, statsChan <-chan *agentsdk.Stats, setInterval func(time.Duration)) (io.Closer, error) {
doneCh := make(chan struct{})
ctx, cancel := context.WithCancel(ctx)
go func() {
defer close(doneCh)
setInterval(500 * time.Millisecond)
for {
select {
case <-ctx.Done():
return
case stat := <-statsChan:
select {
case c.statsChan <- stat:
case <-ctx.Done():
return
default:
// We don't want to send old stats.
continue
}
}
}
}()
return closeFunc(func() error {
cancel()
<-doneCh
close(c.statsChan)
return nil
}), nil
}
func (c *Client) GetLifecycleStates() []codersdk.WorkspaceAgentLifecycle {
c.mu.Lock()
defer c.mu.Unlock()
return c.lifecycleStates
}
func (c *Client) PostLifecycle(ctx context.Context, req agentsdk.PostLifecycleRequest) error {
c.mu.Lock()
defer c.mu.Unlock()
c.lifecycleStates = append(c.lifecycleStates, req.State)
c.logger.Debug(ctx, "post lifecycle", slog.F("req", req))
return nil
}
func (c *Client) PostAppHealth(ctx context.Context, req agentsdk.PostAppHealthsRequest) error {
c.logger.Debug(ctx, "post app health", slog.F("req", req))
return nil
}
func (c *Client) GetStartup() agentsdk.PostStartupRequest {
c.mu.Lock()
defer c.mu.Unlock()
return c.startup
}
func (c *Client) GetMetadata() map[string]agentsdk.Metadata {
c.mu.Lock()
defer c.mu.Unlock()
return maps.Clone(c.metadata)
}
func (c *Client) PostMetadata(ctx context.Context, req agentsdk.PostMetadataRequest) error {
c.mu.Lock()
defer c.mu.Unlock()
if c.metadata == nil {
c.metadata = make(map[string]agentsdk.Metadata)
}
for _, md := range req.Metadata {
c.metadata[md.Key] = md
c.logger.Debug(ctx, "post metadata", slog.F("key", md.Key), slog.F("md", md))
}
return nil
}
func (c *Client) PostStartup(ctx context.Context, startup agentsdk.PostStartupRequest) error {
c.mu.Lock()
defer c.mu.Unlock()
c.startup = startup
c.logger.Debug(ctx, "post startup", slog.F("req", startup))
return nil
}
func (c *Client) GetStartupLogs() []agentsdk.Log {
c.mu.Lock()
defer c.mu.Unlock()
return c.logs
}
func (c *Client) PatchLogs(ctx context.Context, logs agentsdk.PatchLogs) error {
c.mu.Lock()
defer c.mu.Unlock()
if c.PatchWorkspaceLogs != nil {
return c.PatchWorkspaceLogs()
}
c.logs = append(c.logs, logs.Logs...)
c.logger.Debug(ctx, "patch startup logs", slog.F("req", logs))
return nil
}
func (c *Client) SetServiceBannerFunc(f func() (codersdk.ServiceBannerConfig, error)) {
c.mu.Lock()
defer c.mu.Unlock()
c.GetServiceBannerFunc = f
}
func (c *Client) GetServiceBanner(ctx context.Context) (codersdk.ServiceBannerConfig, error) {
c.mu.Lock()
defer c.mu.Unlock()
c.logger.Debug(ctx, "get service banner")
if c.GetServiceBannerFunc != nil {
return c.GetServiceBannerFunc()
}
return codersdk.ServiceBannerConfig{}, nil
}
func (c *Client) PushDERPMapUpdate(update agentsdk.DERPMapUpdate) error {
timer := time.NewTimer(testutil.WaitShort)
defer timer.Stop()
select {
case c.derpMapUpdates <- update:
case <-timer.C:
return xerrors.New("timeout waiting to push derp map update")
}
return nil
}
func (c *Client) DERPMapUpdates(_ context.Context) (<-chan agentsdk.DERPMapUpdate, io.Closer, error) {
closed := make(chan struct{})
return c.derpMapUpdates, closeFunc(func() error {
close(closed)
return nil
}), nil
}
type closeFunc func() error
func (c closeFunc) Close() error {
return c()
}
+16 -8
View File
@@ -5,13 +5,13 @@ import (
"sync"
"time"
"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/codersdk"
)
func (*agent) apiHandler() http.Handler {
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{
@@ -19,16 +19,24 @@ func (*agent) apiHandler() http.Handler {
})
})
lp := &listeningPortsHandler{}
// 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
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
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"golang.org/x/xerrors"
"cdr.dev/slog"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/codersdk/agentsdk"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/retry"
)
+5 -5
View File
@@ -13,11 +13,11 @@ import (
"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"
"github.com/coder/coder/v2/agent"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/testutil"
)
func TestAppHealth_Healthy(t *testing.T) {
+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/v2/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))
}
}
+6 -1
View File
@@ -8,7 +8,7 @@ import (
"github.com/cakturk/go-netstat/netstat"
"golang.org/x/xerrors"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/v2/codersdk"
)
func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.WorkspaceAgentListeningPort, error) {
@@ -36,6 +36,11 @@ func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.WorkspaceAgentL
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 {
+1 -1
View File
@@ -2,7 +2,7 @@
package agent
import "github.com/coder/coder/codersdk"
import "github.com/coder/coder/v2/codersdk"
func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.WorkspaceAgentListeningPort, error) {
// Can't scan for ports on non-linux or non-windows_amd64 systems at the
+34 -37
View File
@@ -14,58 +14,55 @@ import (
"github.com/hashicorp/go-reap"
"github.com/stretchr/testify/require"
"github.com/coder/coder/agent/reaper"
"github.com/coder/coder/testutil"
"github.com/coder/coder/v2/agent/reaper"
"github.com/coder/coder/v2/testutil"
)
//nolint:paralleltest // Non-parallel subtest.
// 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 _, ok := os.LookupEnv("CI"); ok {
if testutil.InCI() {
t.Skip("Detected CI, skipping reaper tests")
}
// OK checks that's the reaper is successfully reaping
// exited processes and passing the PIDs through the shared
// channel.
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)
//nolint:paralleltest // Signal handling.
t.Run("OK", func(t *testing.T) {
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)
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)
cmd2 := exec.Command("tail", "-f", "/dev/null")
err = cmd2.Start()
require.NoError(t, err)
err = cmd.Process.Kill()
require.NoError(t, err)
err = cmd.Process.Kill()
require.NoError(t, err)
err = cmd2.Process.Kill()
require.NoError(t, err)
err = cmd2.Process.Kill()
require.NoError(t, err)
expectedPIDs := []int{cmd.Process.Pid, cmd2.Process.Pid}
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)
}
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.
@@ -73,7 +70,7 @@ 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 _, ok := os.LookupEnv("CI"); ok {
if testutil.InCI() {
t.Skip("Detected CI, skipping reaper tests")
}
+241
View File
@@ -0,0 +1,241 @@
package reconnectingpty
import (
"context"
"errors"
"io"
"net"
"time"
"github.com/armon/circbuf"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"cdr.dev/slog"
"github.com/coder/coder/v2/pty"
)
// bufferedReconnectingPTY provides a reconnectable PTY by using a ring buffer to store
// scrollback.
type bufferedReconnectingPTY struct {
command *pty.Cmd
activeConns map[string]net.Conn
circularBuffer *circbuf.Buffer
ptty pty.PTYCmd
process pty.Process
metrics *prometheus.CounterVec
state *ptyState
// timer will close the reconnecting pty when it expires. The timer will be
// reset as long as there are active connections.
timer *time.Timer
timeout time.Duration
}
// newBuffered starts the buffered pty. If the context ends the process will be
// killed.
func newBuffered(ctx context.Context, cmd *pty.Cmd, options *Options, logger slog.Logger) *bufferedReconnectingPTY {
rpty := &bufferedReconnectingPTY{
activeConns: map[string]net.Conn{},
command: cmd,
metrics: options.Metrics,
state: newState(),
timeout: options.Timeout,
}
// Default to buffer 64KiB.
circularBuffer, err := circbuf.NewBuffer(64 << 10)
if err != nil {
rpty.state.setState(StateDone, xerrors.Errorf("create circular buffer: %w", err))
return rpty
}
rpty.circularBuffer = circularBuffer
// Add TERM then start the command with a pty. pty.Cmd duplicates Path as the
// first argument so remove it.
cmdWithEnv := pty.CommandContext(ctx, cmd.Path, cmd.Args[1:]...)
cmdWithEnv.Env = append(rpty.command.Env, "TERM=xterm-256color")
cmdWithEnv.Dir = rpty.command.Dir
ptty, process, err := pty.Start(cmdWithEnv)
if err != nil {
rpty.state.setState(StateDone, xerrors.Errorf("start pty: %w", err))
return rpty
}
rpty.ptty = ptty
rpty.process = process
go rpty.lifecycle(ctx, logger)
// Multiplex the output onto the circular buffer and each active connection.
// We do not need to separately monitor for the process exiting. When it
// exits, our ptty.OutputReader() will return EOF after reading all process
// output.
go func() {
buffer := make([]byte, 1024)
for {
read, err := ptty.OutputReader().Read(buffer)
if err != nil {
// When the PTY is closed, this is triggered.
// Error is typically a benign EOF, so only log for debugging.
if errors.Is(err, io.EOF) {
logger.Debug(ctx, "unable to read pty output, command might have exited", slog.Error(err))
} else {
logger.Warn(ctx, "unable to read pty output, command might have exited", slog.Error(err))
rpty.metrics.WithLabelValues("output_reader").Add(1)
}
// Could have been killed externally or failed to start at all (command
// not found for example).
// TODO: Should we check the process's exit code in case the command was
// invalid?
rpty.Close(nil)
break
}
part := buffer[:read]
rpty.state.cond.L.Lock()
_, err = rpty.circularBuffer.Write(part)
if err != nil {
logger.Error(ctx, "write to circular buffer", slog.Error(err))
rpty.metrics.WithLabelValues("write_buffer").Add(1)
}
// TODO: Instead of ranging over a map, could we send the output to a
// channel and have each individual Attach read from that?
for cid, conn := range rpty.activeConns {
_, err = conn.Write(part)
if err != nil {
logger.Warn(ctx,
"error writing to active connection",
slog.F("connection_id", cid),
slog.Error(err),
)
rpty.metrics.WithLabelValues("write").Add(1)
}
}
rpty.state.cond.L.Unlock()
}
}()
return rpty
}
// lifecycle manages the lifecycle of the reconnecting pty. If the context ends
// or the reconnecting pty closes the pty will be shut down.
func (rpty *bufferedReconnectingPTY) lifecycle(ctx context.Context, logger slog.Logger) {
rpty.timer = time.AfterFunc(attachTimeout, func() {
rpty.Close(xerrors.New("reconnecting pty timeout"))
})
logger.Debug(ctx, "reconnecting pty ready")
rpty.state.setState(StateReady, nil)
state, reasonErr := rpty.state.waitForStateOrContext(ctx, StateClosing)
if state < StateClosing {
// If we have not closed yet then the context is what unblocked us (which
// means the agent is shutting down) so move into the closing phase.
rpty.Close(reasonErr)
}
rpty.timer.Stop()
rpty.state.cond.L.Lock()
// Log these closes only for debugging since the connections or processes
// might have already closed on their own.
for _, conn := range rpty.activeConns {
err := conn.Close()
if err != nil {
logger.Debug(ctx, "closed conn with error", slog.Error(err))
}
}
// Connections get removed once they close but it is possible there is still
// some data that will be written before that happens so clear the map now to
// avoid writing to closed connections.
rpty.activeConns = map[string]net.Conn{}
rpty.state.cond.L.Unlock()
// Log close/kill only for debugging since the process might have already
// closed on its own.
err := rpty.ptty.Close()
if err != nil {
logger.Debug(ctx, "closed ptty with error", slog.Error(err))
}
err = rpty.process.Kill()
if err != nil {
logger.Debug(ctx, "killed process with error", slog.Error(err))
}
logger.Info(ctx, "closed reconnecting pty")
rpty.state.setState(StateDone, reasonErr)
}
func (rpty *bufferedReconnectingPTY) Attach(ctx context.Context, connID string, conn net.Conn, height, width uint16, logger slog.Logger) error {
logger.Info(ctx, "attach to reconnecting pty")
// This will kill the heartbeat once we hit EOF or an error.
ctx, cancel := context.WithCancel(ctx)
defer cancel()
err := rpty.doAttach(connID, conn)
if err != nil {
return err
}
defer func() {
rpty.state.cond.L.Lock()
defer rpty.state.cond.L.Unlock()
delete(rpty.activeConns, connID)
}()
state, err := rpty.state.waitForStateOrContext(ctx, StateReady)
if state != StateReady {
return err
}
go heartbeat(ctx, rpty.timer, rpty.timeout)
// Resize the PTY to initial height + width.
err = rpty.ptty.Resize(height, width)
if err != nil {
// We can continue after this, it's not fatal!
logger.Warn(ctx, "reconnecting PTY initial resize failed, but will continue", slog.Error(err))
rpty.metrics.WithLabelValues("resize").Add(1)
}
// Pipe conn -> pty and block. pty -> conn is handled in newBuffered().
readConnLoop(ctx, conn, rpty.ptty, rpty.metrics, logger)
return nil
}
// doAttach adds the connection to the map and replays the buffer. It exists
// separately only for convenience to defer the mutex unlock which is not
// possible in Attach since it blocks.
func (rpty *bufferedReconnectingPTY) doAttach(connID string, conn net.Conn) error {
rpty.state.cond.L.Lock()
defer rpty.state.cond.L.Unlock()
// Write any previously stored data for the TTY. Since the command might be
// short-lived and have already exited, make sure we always at least output
// the buffer before returning, mostly just so tests pass.
prevBuf := slices.Clone(rpty.circularBuffer.Bytes())
_, err := conn.Write(prevBuf)
if err != nil {
rpty.metrics.WithLabelValues("write").Add(1)
return xerrors.Errorf("write buffer to conn: %w", err)
}
rpty.activeConns[connID] = conn
return nil
}
func (rpty *bufferedReconnectingPTY) Wait() {
_, _ = rpty.state.waitForState(StateClosing)
}
func (rpty *bufferedReconnectingPTY) Close(error error) {
// The closing state change will be handled by the lifecycle.
rpty.state.setState(StateClosing, error)
}
+226
View File
@@ -0,0 +1,226 @@
package reconnectingpty
import (
"context"
"encoding/json"
"io"
"net"
"os/exec"
"runtime"
"sync"
"time"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/xerrors"
"cdr.dev/slog"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/pty"
)
// attachTimeout is the initial timeout for attaching and will probably be far
// shorter than the reconnect timeout in most cases; in tests it might be
// longer. It should be at least long enough for the first screen attach to be
// able to start up the daemon and for the buffered pty to start.
const attachTimeout = 30 * time.Second
// Options allows configuring the reconnecting pty.
type Options struct {
// Timeout describes how long to keep the pty alive without any connections.
// Once elapsed the pty will be killed.
Timeout time.Duration
// Metrics tracks various error counters.
Metrics *prometheus.CounterVec
}
// ReconnectingPTY is a pty that can be reconnected within a timeout and to
// simultaneous connections. The reconnecting pty can be backed by screen if
// installed or a (buggy) buffer replay fallback.
type ReconnectingPTY interface {
// Attach pipes the connection and pty, spawning it if necessary, replays
// history, then blocks until EOF, an error, or the context's end. The
// connection is expected to send JSON-encoded messages and accept raw output
// from the ptty. If the context ends or the process dies the connection will
// be detached.
Attach(ctx context.Context, connID string, conn net.Conn, height, width uint16, logger slog.Logger) error
// Wait waits for the reconnecting pty to close. The underlying process might
// still be exiting.
Wait()
// Close kills the reconnecting pty process.
Close(err error)
}
// New sets up a new reconnecting pty that wraps the provided command. Any
// errors with starting are returned on Attach(). The reconnecting pty will
// close itself (and all connections to it) if nothing is attached for the
// duration of the timeout, if the context ends, or the process exits (buffered
// backend only).
func New(ctx context.Context, cmd *pty.Cmd, options *Options, logger slog.Logger) ReconnectingPTY {
if options.Timeout == 0 {
options.Timeout = 5 * time.Minute
}
// Screen seems flaky on Darwin. Locally the tests pass 100% of the time (100
// runs) but in CI screen often incorrectly claims the session name does not
// exist even though screen -list shows it. For now, restrict screen to
// Linux.
backendType := "buffered"
if runtime.GOOS == "linux" {
_, err := exec.LookPath("screen")
if err == nil {
backendType = "screen"
}
}
logger.Info(ctx, "start reconnecting pty", slog.F("backend_type", backendType))
switch backendType {
case "screen":
return newScreen(ctx, cmd, options, logger)
default:
return newBuffered(ctx, cmd, options, logger)
}
}
// heartbeat resets timer before timeout elapses and blocks until ctx ends.
func heartbeat(ctx context.Context, timer *time.Timer, timeout time.Duration) {
// Reset now in case it is near the end.
timer.Reset(timeout)
// Reset when the context ends to ensure the pty stays up for the full
// timeout.
defer timer.Reset(timeout)
heartbeat := time.NewTicker(timeout / 2)
defer heartbeat.Stop()
for {
select {
case <-ctx.Done():
return
case <-heartbeat.C:
timer.Reset(timeout)
}
}
}
// State represents the current state of the reconnecting pty. States are
// sequential and will only move forward.
type State int
const (
// StateStarting is the default/start state. Attaching will block until the
// reconnecting pty becomes ready.
StateStarting = iota
// StateReady means the reconnecting pty is ready to be attached.
StateReady
// StateClosing means the reconnecting pty has begun closing. The underlying
// process may still be exiting. Attaching will result in an error.
StateClosing
// StateDone means the reconnecting pty has completely shut down and the
// process has exited. Attaching will result in an error.
StateDone
)
// ptyState is a helper for tracking the reconnecting PTY's state.
type ptyState struct {
// cond broadcasts state changes and any accompanying errors.
cond *sync.Cond
// error describes the error that caused the state change, if there was one.
// It is not safe to access outside of cond.L.
error error
// state holds the current reconnecting pty state. It is not safe to access
// this outside of cond.L.
state State
}
func newState() *ptyState {
return &ptyState{
cond: sync.NewCond(&sync.Mutex{}),
state: StateStarting,
}
}
// setState sets and broadcasts the provided state if it is greater than the
// current state and the error if one has not already been set.
func (s *ptyState) setState(state State, err error) {
s.cond.L.Lock()
defer s.cond.L.Unlock()
// Cannot regress states. For example, trying to close after the process is
// done should leave us in the done state and not the closing state.
if state <= s.state {
return
}
s.error = err
s.state = state
s.cond.Broadcast()
}
// waitForState blocks until the state or a greater one is reached.
func (s *ptyState) waitForState(state State) (State, error) {
s.cond.L.Lock()
defer s.cond.L.Unlock()
for state > s.state {
s.cond.Wait()
}
return s.state, s.error
}
// waitForStateOrContext blocks until the state or a greater one is reached or
// the provided context ends.
func (s *ptyState) waitForStateOrContext(ctx context.Context, state State) (State, error) {
s.cond.L.Lock()
defer s.cond.L.Unlock()
nevermind := make(chan struct{})
defer close(nevermind)
go func() {
select {
case <-ctx.Done():
// Wake up when the context ends.
s.cond.Broadcast()
case <-nevermind:
}
}()
for ctx.Err() == nil && state > s.state {
s.cond.Wait()
}
if ctx.Err() != nil {
return s.state, ctx.Err()
}
return s.state, s.error
}
// readConnLoop reads messages from conn and writes to ptty as needed. Blocks
// until EOF or an error writing to ptty or reading from conn.
func readConnLoop(ctx context.Context, conn net.Conn, ptty pty.PTYCmd, metrics *prometheus.CounterVec, logger slog.Logger) {
decoder := json.NewDecoder(conn)
var req codersdk.ReconnectingPTYRequest
for {
err := decoder.Decode(&req)
if xerrors.Is(err, io.EOF) {
return
}
if err != nil {
logger.Warn(ctx, "reconnecting pty failed with read error", slog.Error(err))
return
}
_, err = ptty.InputWriter().Write([]byte(req.Data))
if err != nil {
logger.Warn(ctx, "reconnecting pty failed with write error", slog.Error(err))
metrics.WithLabelValues("input_writer").Add(1)
return
}
// Check if a resize needs to happen!
if req.Height == 0 || req.Width == 0 {
continue
}
err = ptty.Resize(req.Height, req.Width)
if err != nil {
// We can continue after this, it's not fatal!
logger.Warn(ctx, "reconnecting pty resize failed, but will continue", slog.Error(err))
metrics.WithLabelValues("resize").Add(1)
}
}
}
+389
View File
@@ -0,0 +1,389 @@
package reconnectingpty
import (
"bytes"
"context"
"crypto/rand"
"encoding/hex"
"errors"
"io"
"net"
"os"
"os/exec"
"path/filepath"
"strings"
"sync"
"time"
"github.com/gliderlabs/ssh"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/xerrors"
"cdr.dev/slog"
"github.com/coder/coder/v2/pty"
)
// screenReconnectingPTY provides a reconnectable PTY via `screen`.
type screenReconnectingPTY struct {
command *pty.Cmd
// id holds the id of the session for both creating and attaching. This will
// be generated uniquely for each session because without control of the
// screen daemon we do not have its PID and without the PID screen will do
// partial matching. Enforcing a unique ID should guarantee we match on the
// right session.
id string
// mutex prevents concurrent attaches to the session. Screen will happily
// spawn two separate sessions with the same name if multiple attaches happen
// in a close enough interval. We are not able to control the screen daemon
// ourselves to prevent this because the daemon will spawn with a hardcoded
// 24x80 size which results in confusing padding above the prompt once the
// attach comes in and resizes.
mutex sync.Mutex
configFile string
metrics *prometheus.CounterVec
state *ptyState
// timer will close the reconnecting pty when it expires. The timer will be
// reset as long as there are active connections.
timer *time.Timer
timeout time.Duration
}
// newScreen creates a new screen-backed reconnecting PTY. It writes config
// settings and creates the socket directory. If we could, we would want to
// spawn the daemon here and attach each connection to it but since doing that
// spawns the daemon with a hardcoded 24x80 size it is not a very good user
// experience. Instead we will let the attach command spawn the daemon on its
// own which causes it to spawn with the specified size.
func newScreen(ctx context.Context, cmd *pty.Cmd, options *Options, logger slog.Logger) *screenReconnectingPTY {
rpty := &screenReconnectingPTY{
command: cmd,
metrics: options.Metrics,
state: newState(),
timeout: options.Timeout,
}
go rpty.lifecycle(ctx, logger)
// Socket paths are limited to around 100 characters on Linux and macOS which
// depending on the temporary directory can be a problem. To give more leeway
// use a short ID.
buf := make([]byte, 4)
_, err := rand.Read(buf)
if err != nil {
rpty.state.setState(StateDone, xerrors.Errorf("generate screen id: %w", err))
return rpty
}
rpty.id = hex.EncodeToString(buf)
settings := []string{
// Tell screen not to handle motion for xterm* terminals which allows
// scrolling the terminal via the mouse wheel or scroll bar (by default
// screen uses it to cycle through the command history). There does not
// seem to be a way to make screen itself scroll on mouse wheel. tmux can
// do it but then there is no scroll bar and it kicks you into copy mode
// where keys stop working until you exit copy mode which seems like it
// could be confusing.
"termcapinfo xterm* ti@:te@",
// Enable alternate screen emulation otherwise applications get rendered in
// the current window which wipes out visible output resulting in missing
// output when scrolling back with the mouse wheel (copy mode still works
// since that is screen itself scrolling).
"altscreen on",
// Remap the control key to C-s since C-a may be used in applications. C-s
// is chosen because it cannot actually be used because by default it will
// pause and C-q to resume will just kill the browser window. We may not
// want people using the control key anyway since it will not be obvious
// they are in screen and doing things like switching windows makes mouse
// wheel scroll wonky due to the terminal doing the scrolling rather than
// screen itself (but again copy mode will work just fine).
"escape ^Ss",
}
rpty.configFile = filepath.Join(os.TempDir(), "coder-screen", "config")
err = os.MkdirAll(filepath.Dir(rpty.configFile), 0o700)
if err != nil {
rpty.state.setState(StateDone, xerrors.Errorf("make screen config dir: %w", err))
return rpty
}
err = os.WriteFile(rpty.configFile, []byte(strings.Join(settings, "\n")), 0o600)
if err != nil {
rpty.state.setState(StateDone, xerrors.Errorf("create config file: %w", err))
return rpty
}
return rpty
}
// lifecycle manages the lifecycle of the reconnecting pty. If the context ends
// the reconnecting pty will be closed.
func (rpty *screenReconnectingPTY) lifecycle(ctx context.Context, logger slog.Logger) {
rpty.timer = time.AfterFunc(attachTimeout, func() {
rpty.Close(xerrors.New("reconnecting pty timeout"))
})
logger.Debug(ctx, "reconnecting pty ready")
rpty.state.setState(StateReady, nil)
state, reasonErr := rpty.state.waitForStateOrContext(ctx, StateClosing)
if state < StateClosing {
// If we have not closed yet then the context is what unblocked us (which
// means the agent is shutting down) so move into the closing phase.
rpty.Close(reasonErr)
}
rpty.timer.Stop()
// If the command errors that the session is already gone that is fine.
err := rpty.sendCommand(context.Background(), "quit", []string{"No screen session found"})
if err != nil {
logger.Error(ctx, "close screen session", slog.Error(err))
}
logger.Info(ctx, "closed reconnecting pty")
rpty.state.setState(StateDone, reasonErr)
}
func (rpty *screenReconnectingPTY) Attach(ctx context.Context, _ string, conn net.Conn, height, width uint16, logger slog.Logger) error {
logger.Info(ctx, "attach to reconnecting pty")
// This will kill the heartbeat once we hit EOF or an error.
ctx, cancel := context.WithCancel(ctx)
defer cancel()
state, err := rpty.state.waitForStateOrContext(ctx, StateReady)
if state != StateReady {
return err
}
go heartbeat(ctx, rpty.timer, rpty.timeout)
ptty, process, err := rpty.doAttach(ctx, conn, height, width, logger)
if err != nil {
if errors.Is(err, context.Canceled) {
// Likely the process was too short-lived and canceled the version command.
// TODO: Is it worth distinguishing between that and a cancel from the
// Attach() caller? Additionally, since this could also happen if
// the command was invalid, should we check the process's exit code?
return nil
}
return err
}
defer func() {
// Log only for debugging since the process might have already exited on its
// own.
err := ptty.Close()
if err != nil {
logger.Debug(ctx, "closed ptty with error", slog.Error(err))
}
err = process.Kill()
if err != nil {
logger.Debug(ctx, "killed process with error", slog.Error(err))
}
}()
// Pipe conn -> pty and block.
readConnLoop(ctx, conn, ptty, rpty.metrics, logger)
return nil
}
// doAttach spawns the screen client and starts the heartbeat. It exists
// separately only so we can defer the mutex unlock which is not possible in
// Attach since it blocks.
func (rpty *screenReconnectingPTY) doAttach(ctx context.Context, conn net.Conn, height, width uint16, logger slog.Logger) (pty.PTYCmd, pty.Process, error) {
// Ensure another attach does not come in and spawn a duplicate session.
rpty.mutex.Lock()
defer rpty.mutex.Unlock()
logger.Debug(ctx, "spawning screen client", slog.F("screen_id", rpty.id))
// Wrap the command with screen and tie it to the connection's context.
cmd := pty.CommandContext(ctx, "screen", append([]string{
// -S is for setting the session's name.
"-S", rpty.id,
// -U tells screen to use UTF-8 encoding.
// -x allows attaching to an already attached session.
// -RR reattaches to the daemon or creates the session daemon if missing.
// -q disables the "New screen..." message that appears for five seconds
// when creating a new session with -RR.
// -c is the flag for the config file.
"-UxRRqc", rpty.configFile,
rpty.command.Path,
// pty.Cmd duplicates Path as the first argument so remove it.
}, rpty.command.Args[1:]...)...)
cmd.Env = append(rpty.command.Env, "TERM=xterm-256color")
cmd.Dir = rpty.command.Dir
ptty, process, err := pty.Start(cmd, pty.WithPTYOption(
pty.WithSSHRequest(ssh.Pty{
Window: ssh.Window{
// Make sure to spawn at the right size because if we resize afterward it
// leaves confusing padding (screen will resize such that the screen
// contents are aligned to the bottom).
Height: int(height),
Width: int(width),
},
}),
))
if err != nil {
rpty.metrics.WithLabelValues("screen_spawn").Add(1)
return nil, nil, err
}
// This context lets us abort the version command if the process dies.
versionCtx, versionCancel := context.WithCancel(ctx)
defer versionCancel()
// Pipe pty -> conn and close the connection when the process exits.
// We do not need to separately monitor for the process exiting. When it
// exits, our ptty.OutputReader() will return EOF after reading all process
// output.
go func() {
defer versionCancel()
defer func() {
err := conn.Close()
if err != nil {
// Log only for debugging since the connection might have already closed
// on its own.
logger.Debug(ctx, "closed connection with error", slog.Error(err))
}
}()
buffer := make([]byte, 1024)
for {
read, err := ptty.OutputReader().Read(buffer)
if err != nil {
// When the PTY is closed, this is triggered.
// Error is typically a benign EOF, so only log for debugging.
if errors.Is(err, io.EOF) {
logger.Debug(ctx, "unable to read pty output; screen might have exited", slog.Error(err))
} else {
logger.Warn(ctx, "unable to read pty output; screen might have exited", slog.Error(err))
rpty.metrics.WithLabelValues("screen_output_reader").Add(1)
}
// The process might have died because the session itself died or it
// might have been separately killed and the session is still up (for
// example `exit` or we killed it when the connection closed). If the
// session is still up we might leave the reconnecting pty in memory
// around longer than it needs to be but it will eventually clean up
// with the timer or context, or the next attach will respawn the screen
// daemon which is fine too.
break
}
part := buffer[:read]
_, err = conn.Write(part)
if err != nil {
// Connection might have been closed.
if errors.Unwrap(err).Error() != "endpoint is closed for send" {
logger.Warn(ctx, "error writing to active conn", slog.Error(err))
rpty.metrics.WithLabelValues("screen_write").Add(1)
}
break
}
}
}()
// Version seems to be the only command without a side effect (other than
// making the version pop up briefly) so use it to wait for the session to
// come up. If we do not wait we could end up spawning multiple sessions with
// the same name.
err = rpty.sendCommand(versionCtx, "version", nil)
if err != nil {
// Log only for debugging since the process might already have closed.
closeErr := ptty.Close()
if closeErr != nil {
logger.Debug(ctx, "closed ptty with error", slog.Error(closeErr))
}
closeErr = process.Kill()
if closeErr != nil {
logger.Debug(ctx, "killed process with error", slog.Error(closeErr))
}
rpty.metrics.WithLabelValues("screen_wait").Add(1)
return nil, nil, err
}
return ptty, process, nil
}
// sendCommand runs a screen command against a running screen session. If the
// command fails with an error matching anything in successErrors it will be
// considered a success state (for example "no session" when quitting and the
// session is already dead). The command will be retried until successful, the
// timeout is reached, or the context ends. A canceled context will return the
// canceled context's error as-is while a timed-out context returns together
// with the last error from the command.
func (rpty *screenReconnectingPTY) sendCommand(ctx context.Context, command string, successErrors []string) error {
ctx, cancel := context.WithTimeout(ctx, attachTimeout)
defer cancel()
var lastErr error
run := func() bool {
var stdout bytes.Buffer
//nolint:gosec
cmd := exec.CommandContext(ctx, "screen",
// -x targets an attached session.
"-x", rpty.id,
// -c is the flag for the config file.
"-c", rpty.configFile,
// -X runs a command in the matching session.
"-X", command,
)
cmd.Env = append(rpty.command.Env, "TERM=xterm-256color")
cmd.Dir = rpty.command.Dir
cmd.Stdout = &stdout
err := cmd.Run()
if err == nil {
return true
}
stdoutStr := stdout.String()
for _, se := range successErrors {
if strings.Contains(stdoutStr, se) {
return true
}
}
// Things like "exit status 1" are imprecise so include stdout as it may
// contain more information ("no screen session found" for example).
if !errors.Is(err, context.Canceled) && !errors.Is(err, context.DeadlineExceeded) {
lastErr = xerrors.Errorf("`screen -x %s -X %s`: %w: %s", rpty.id, command, err, stdoutStr)
}
return false
}
// Run immediately.
if done := run(); done {
return nil
}
// Then run on an interval.
ticker := time.NewTicker(250 * time.Millisecond)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
if errors.Is(ctx.Err(), context.Canceled) {
return ctx.Err()
}
return errors.Join(ctx.Err(), lastErr)
case <-ticker.C:
if done := run(); done {
return nil
}
}
}
}
func (rpty *screenReconnectingPTY) Wait() {
_, _ = rpty.state.waitForState(StateClosing)
}
func (rpty *screenReconnectingPTY) Close(err error) {
// The closing state change will be handled by the lifecycle.
rpty.state.setState(StateClosing, err)
}
+20 -3
View File
@@ -1,8 +1,25 @@
package usershell
import "os"
import (
"os"
"os/exec"
"path/filepath"
"strings"
"golang.org/x/xerrors"
)
// Get returns the $SHELL environment variable.
func Get(_ string) (string, error) {
return os.Getenv("SHELL"), nil
func Get(username string) (string, error) {
// This command will output "UserShell: /bin/zsh" if successful, we
// can ignore the error since we have fallback behavior.
out, _ := exec.Command("dscl", ".", "-read", filepath.Join("/Users", username), "UserShell").Output()
s, ok := strings.CutPrefix(string(out), "UserShell: ")
if ok {
return strings.TrimSpace(s), nil
}
if s = os.Getenv("SHELL"); s != "" {
return s, nil
}
return "", xerrors.Errorf("shell for user %q not found via dscl or in $SHELL", username)
}
+4 -1
View File
@@ -27,5 +27,8 @@ func Get(username string) (string, error) {
}
return parts[6], nil
}
return "", xerrors.Errorf("user %q not found in /etc/passwd", username)
if s := os.Getenv("SHELL"); s != "" {
return s, nil
}
return "", xerrors.Errorf("shell for user %q not found in /etc/passwd or $SHELL", username)
}
-27
View File
@@ -1,27 +0,0 @@
//go:build !windows && !darwin
// +build !windows,!darwin
package usershell_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/agent/usershell"
)
func TestGet(t *testing.T) {
t.Parallel()
t.Run("Has", func(t *testing.T) {
t.Parallel()
shell, err := usershell.Get("root")
require.NoError(t, err)
require.NotEmpty(t, shell)
})
t.Run("NotFound", func(t *testing.T) {
t.Parallel()
_, err := usershell.Get("notauser")
require.Error(t, err)
})
}
+46
View File
@@ -0,0 +1,46 @@
package usershell_test
import (
"os/user"
"runtime"
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/agent/usershell"
)
//nolint:paralleltest,tparallel // This test sets an environment variable.
func TestGet(t *testing.T) {
if runtime.GOOS == "windows" {
t.SkipNow()
}
t.Run("Fallback", func(t *testing.T) {
t.Setenv("SHELL", "/bin/sh")
t.Run("NonExistentUser", func(t *testing.T) {
shell, err := usershell.Get("notauser")
require.NoError(t, err)
require.Equal(t, "/bin/sh", shell)
})
})
t.Run("NoFallback", func(t *testing.T) {
// Disable env fallback for these tests.
t.Setenv("SHELL", "")
t.Run("NotFound", func(t *testing.T) {
_, err := usershell.Get("notauser")
require.Error(t, err)
})
t.Run("User", func(t *testing.T) {
u, err := user.Current()
require.NoError(t, err)
shell, err := usershell.Get(u.Username)
require.NoError(t, err)
require.NotEmpty(t, shell)
})
})
}
+7
View File
@@ -0,0 +1,7 @@
//go:build boringcrypto
package buildinfo
import "crypto/boring"
var boringcrypto = boring.Enabled()
+24 -7
View File
@@ -30,8 +30,15 @@ var (
)
const (
// develPrefix is prefixed to developer versions of the application.
develPrefix = "v0.0.0-devel"
// noVersion is the reported version when the version cannot be determined.
// Usually because `go build` is run instead of `make build`.
noVersion = "v0.0.0"
// develPreRelease is the pre-release tag for developer versions of the
// application. This includes CI builds. The pre-release tag should be appended
// to the version with a "-".
// Example: v0.0.0-devel
develPreRelease = "devel"
)
// Version returns the semantic version of the build.
@@ -45,7 +52,8 @@ func Version() string {
if tag == "" {
// This occurs when the tag hasn't been injected,
// like when using "go run".
version = develPrefix + revision
// <version>-<pre-release>+<revision>
version = fmt.Sprintf("%s-%s%s", noVersion, develPreRelease, revision)
return
}
version = "v" + tag
@@ -63,18 +71,23 @@ func Version() string {
// 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) {
// If no version is attached, then it is a dev build outside of CI. The version
// will be disregarded... hopefully they know what they are doing.
if strings.Contains(v1, noVersion) || strings.Contains(v2, noVersion) {
return true
}
return semver.MajorMinor(v1) == semver.MajorMinor(v2)
}
func IsDevVersion(v string) bool {
return strings.Contains(v, "-"+develPreRelease)
}
// IsDev returns true if this is a development build.
// CI builds are also considered development builds.
func IsDev() bool {
return strings.HasPrefix(Version(), develPrefix)
return IsDevVersion(Version())
}
// IsSlim returns true if this is a slim build.
@@ -87,6 +100,10 @@ func IsAGPL() bool {
return strings.Contains(agpl, "t")
}
func IsBoringCrypto() bool {
return boringcrypto
}
// 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.
+9 -3
View File
@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/mod/semver"
"github.com/coder/coder/buildinfo"
"github.com/coder/coder/v2/buildinfo"
)
func TestBuildInfo(t *testing.T) {
@@ -57,13 +57,19 @@ func TestBuildInfo(t *testing.T) {
expectMatch: true,
},
// Our CI instance uses a "-devel" prerelease
// flag. This is not the same as a developer WIP build.
// flag.
{
name: "DevelPreleaseNotIgnored",
name: "DevelPreleaseMajor",
v1: "v1.1.1-devel+123abac",
v2: "v1.2.3",
expectMatch: false,
},
{
name: "DevelPreleaseSame",
v1: "v1.1.1-devel+123abac",
v2: "v1.1.9",
expectMatch: true,
},
{
name: "MajorMismatch",
v1: "v1.2.3",
+5
View File
@@ -0,0 +1,5 @@
//go:build !boringcrypto
package buildinfo
var boringcrypto = false
+309 -60
View File
@@ -11,58 +11,113 @@ import (
"os/signal"
"path/filepath"
"runtime"
"strconv"
"strings"
"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"
"github.com/coder/coder/agent"
"github.com/coder/coder/agent/reaper"
"github.com/coder/coder/buildinfo"
"github.com/coder/coder/cli/cliflag"
"github.com/coder/coder/codersdk/agentsdk"
"cdr.dev/slog/sloggers/slogjson"
"cdr.dev/slog/sloggers/slogstackdriver"
"github.com/coder/coder/v2/agent"
"github.com/coder/coder/v2/agent/agentproc"
"github.com/coder/coder/v2/agent/reaper"
"github.com/coder/coder/v2/buildinfo"
"github.com/coder/coder/v2/cli/clibase"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
)
func workspaceAgent() *cobra.Command {
func (r *RootCmd) workspaceAgent() *clibase.Cmd {
var (
auth string
logDir string
pprofAddress string
noReap bool
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, _ []string) error {
ctx, cancel := context.WithCancel(cmd.Context())
Handler: func(inv *clibase.Invocation) error {
ctx, cancel := context.WithCancel(inv.Context())
defer cancel()
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)
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
}
isLinux := runtime.GOOS == "linux"
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 := &lumberjack.Logger{
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()
logger := slog.Make(sloghuman.Sink(cmd.ErrOrStderr()), sloghuman.Sink(logWriter)).Leveled(slog.LevelDebug)
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
@@ -73,7 +128,7 @@ func workspaceAgent() *cobra.Command {
reaper.WithCatchSignals(InterruptSignals...),
)
if err != nil {
logger.Error(ctx, "failed to reap", slog.Error(err))
logger.Error(ctx, "agent process reaper unable to fork", slog.Error(err))
return xerrors.Errorf("fork reap: %w", err)
}
@@ -92,36 +147,51 @@ func workspaceAgent() *cobra.Command {
ctx, stopNotify := signal.NotifyContext(ctx, InterruptSignals...)
defer stopNotify()
// dumpHandler does signal handling, so we call it after the
// DumpHandler does signal handling, so we call it after the
// reaper.
go dumpHandler(ctx)
go DumpHandler(ctx)
ljLogger := &lumberjack.Logger{
logWriter := &lumberjackWriteCloseFixer{w: &lumberjack.Logger{
Filename: filepath.Join(logDir, "coder-agent.log"),
MaxSize: 5, // MB
}
defer ljLogger.Close()
logWriter := &closeWriter{w: ljLogger}
// 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)
sinks = append(sinks, sloghuman.Sink(logWriter))
logger := slog.Make(sinks...).Leveled(slog.LevelDebug)
version := buildinfo.Version()
logger.Info(ctx, "starting agent",
slog.F("url", coderURL),
logger.Info(ctx, "agent is starting now",
slog.F("url", r.agentURL),
slog.F("auth", auth),
slog.F("version", version),
)
client := agentsdk.New(coderURL)
client.SDK.Logger = logger
client := agentsdk.New(r.agentURL)
client.SDK.SetLogger(logger)
// Set a reasonable timeout so requests can't hang forever!
client.SDK.HTTPClient.Timeout = 10 * time.Second
// 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")
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
@@ -129,9 +199,19 @@ func workspaceAgent() *cobra.Command {
var exchangeToken func(context.Context) (agentsdk.AuthenticateResponse, error)
switch auth {
case "token":
token, err := cmd.Flags().GetString(varAgentToken)
if err != nil {
return xerrors.Errorf("CODER_AGENT_TOKEN must be set for token auth: %w", err)
token, _ := inv.ParsedFlags().GetString(varAgentToken)
if token == "" {
tokenFile, _ := inv.ParsedFlags().GetString(varAgentTokenFile)
if tokenFile != "" {
tokenBytes, err := os.ReadFile(tokenFile)
if err != nil {
return xerrors.Errorf("read token file %q: %w", tokenFile, err)
}
token = strings.TrimSpace(string(tokenBytes))
}
}
if token == "" {
return xerrors.Errorf("CODER_AGENT_TOKEN or CODER_AGENT_TOKEN_FILE must be set for token auth")
}
client.SetSessionToken(token)
case "google-instance-identity":
@@ -184,10 +264,27 @@ func workspaceAgent() *cobra.Command {
return xerrors.Errorf("add executable to $PATH: %w", err)
}
closer := agent.New(agent.Options{
Client: client,
Logger: logger,
LogDir: logDir,
prometheusRegistry := prometheus.NewRegistry()
subsystemsRaw := inv.Environ.Get(agent.EnvAgentSubsystem)
subsystems := []codersdk.AgentSubsystem{}
for _, s := range strings.Split(subsystemsRaw, ",") {
subsystem := codersdk.AgentSubsystem(strings.TrimSpace(s))
if subsystem == "" {
continue
}
if !subsystem.Valid() {
return xerrors.Errorf("invalid subsystem %q", subsystem)
}
subsystems = append(subsystems, subsystem)
}
procTicker := time.NewTicker(time.Second)
defer procTicker.Stop()
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
@@ -200,22 +297,119 @@ func workspaceAgent() *cobra.Command {
return resp.SessionToken, nil
},
EnvironmentVariables: map[string]string{
"GIT_ASKPASS": executablePath,
"GIT_ASKPASS": executablePath,
agent.EnvProcPrioMgmt: os.Getenv(agent.EnvProcPrioMgmt),
},
IgnorePorts: ignorePorts,
SSHMaxTimeout: sshMaxTimeout,
Subsystems: subsystems,
PrometheusRegistry: prometheusRegistry,
Syscaller: agentproc.NewSyscaller(),
// Intentionally set this to nil. It's mainly used
// for testing.
ModifiedProcesses: nil,
})
prometheusSrvClose := ServeHandler(ctx, logger, prometheusMetricsHandler(prometheusRegistry, logger), prometheusAddress, "prometheus")
defer prometheusSrvClose()
debugSrvClose := ServeHandler(ctx, logger, agnt.HTTPDebug(), debugAddress, "debug")
defer debugSrvClose()
<-ctx.Done()
return closer.Close()
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")
cliflag.StringVarP(cmd.Flags(), &logDir, "log-dir", "", "CODER_AGENT_LOG_DIR", os.TempDir(), "Specify the location for the agent log files")
cliflag.StringVarP(cmd.Flags(), &pprofAddress, "pprof-address", "", "CODER_AGENT_PPROF_ADDRESS", "127.0.0.1:6060", "The address to serve pprof.")
cliflag.BoolVarP(cmd.Flags(), &noReap, "no-reap", "", "", false, "Do not start a process reaper.")
return cmd
}
func serveHandler(ctx context.Context, logger slog.Logger, handler http.Handler, addr, name string) (closeFunc func()) {
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
@@ -238,16 +432,16 @@ func serveHandler(ctx context.Context, logger slog.Logger, handler http.Handler,
}
}
// closeWriter is a wrapper around an io.WriteCloser that prevents
// writes after Close. This is necessary because lumberjack will
// re-open the file on write.
type closeWriter struct {
// 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 *closeWriter) Close() error {
func (c *lumberjackWriteCloseFixer) Close() error {
c.mu.Lock()
defer c.mu.Unlock()
@@ -255,7 +449,7 @@ func (c *closeWriter) Close() error {
return c.w.Close()
}
func (c *closeWriter) Write(p []byte) (int, error) {
func (c *lumberjackWriteCloseFixer) Write(p []byte) (int, error) {
c.mu.Lock()
defer c.mu.Unlock()
@@ -264,3 +458,58 @@ func (c *closeWriter) Write(p []byte) (int, error) {
}
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))
}
})
}
}
+111 -98
View File
@@ -2,6 +2,7 @@ package cli_test
import (
"context"
"fmt"
"os"
"path/filepath"
"runtime"
@@ -12,11 +13,13 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/provisioner/echo"
"github.com/coder/coder/provisionersdk/proto"
"github.com/coder/coder/testutil"
"github.com/coder/coder/v2/agent"
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/provisioner/echo"
"github.com/coder/coder/v2/provisionersdk/proto"
"github.com/coder/coder/v2/pty/ptytest"
)
func TestWorkspaceAgent(t *testing.T) {
@@ -31,49 +34,30 @@ func TestWorkspaceAgent(t *testing.T) {
})
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
ProvisionApply: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
Resources: []*proto.Resource{{
Name: "somename",
Type: "someinstance",
Agents: []*proto.Agent{{
Id: uuid.NewString(),
Name: "someagent",
Auth: &proto.Agent_Token{
Token: authToken,
},
}},
}},
},
},
}},
Parse: echo.ParseComplete,
ProvisionApply: echo.ProvisionApplyWithAgent(authToken),
})
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
logDir := t.TempDir()
cmd, _ := clitest.New(t,
inv, _ := clitest.New(t,
"agent",
"--auth", "token",
"--agent-token", authToken,
"--agent-url", client.URL.String(),
"--log-dir", logDir,
)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
defer cancel()
errC := make(chan error, 1)
go func() {
errC <- cmd.ExecuteContext(ctx)
}()
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
cancel()
err := <-errC
require.NoError(t, err)
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)
@@ -91,9 +75,9 @@ func TestWorkspaceAgent(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
ProvisionApply: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
ProvisionApply: []*proto.Response{{
Type: &proto.Response_Apply{
Apply: &proto.ApplyComplete{
Resources: []*proto.Resource{{
Name: "somename",
Type: "someinstance",
@@ -108,20 +92,17 @@ func TestWorkspaceAgent(t *testing.T) {
}},
})
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
coderdtest.AwaitWorkspaceBuildJobCompleted(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()
errC := make(chan error)
go func() {
// A linting error occurs for weakly typing the context value here.
//nolint // The above seems reasonable for a one-off test.
ctx := context.WithValue(ctx, "azure-client", metadataClient)
errC <- cmd.ExecuteContext(ctx)
}()
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)
@@ -132,10 +113,7 @@ func TestWorkspaceAgent(t *testing.T) {
dialer, err := client.DialWorkspaceAgent(ctx, resources[0].Agents[0].ID, nil)
require.NoError(t, err)
defer dialer.Close()
require.True(t, dialer.AwaitReachable(context.Background()))
cancelFunc()
err = <-errC
require.NoError(t, err)
require.True(t, dialer.AwaitReachable(ctx))
})
t.Run("AWS", func(t *testing.T) {
@@ -149,9 +127,9 @@ func TestWorkspaceAgent(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
ProvisionApply: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
ProvisionApply: []*proto.Response{{
Type: &proto.Response_Apply{
Apply: &proto.ApplyComplete{
Resources: []*proto.Resource{{
Name: "somename",
Type: "someinstance",
@@ -166,20 +144,17 @@ func TestWorkspaceAgent(t *testing.T) {
}},
})
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
coderdtest.AwaitWorkspaceBuildJobCompleted(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()
errC := make(chan error)
go func() {
// A linting error occurs for weakly typing the context value here.
//nolint // The above seems reasonable for a one-off test.
ctx := context.WithValue(ctx, "aws-client", metadataClient)
errC <- cmd.ExecuteContext(ctx)
}()
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)
@@ -190,26 +165,24 @@ func TestWorkspaceAgent(t *testing.T) {
dialer, err := client.DialWorkspaceAgent(ctx, resources[0].Agents[0].ID, nil)
require.NoError(t, err)
defer dialer.Close()
require.True(t, dialer.AwaitReachable(context.Background()))
cancelFunc()
err = <-errC
require.NoError(t, err)
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,
IncludeProvisionerDaemon: true,
})
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
owner := coderdtest.CreateFirstUser(t, client)
member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
ProvisionApply: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
ProvisionApply: []*proto.Response{{
Type: &proto.Response_Apply{
Apply: &proto.ApplyComplete{
Resources: []*proto.Resource{{
Name: "somename",
Type: "someinstance",
@@ -223,21 +196,23 @@ func TestWorkspaceAgent(t *testing.T) {
},
}},
})
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)
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
workspace := coderdtest.CreateWorkspace(t, member, owner.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, 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, member, cfg)
clitest.Start(t,
inv.WithContext(
//nolint:revive,staticcheck
context.WithValue(inv.Context(), "gcp-client", metadataClient),
),
)
ctx := inv.Context()
cmd, _ := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String())
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
errC := make(chan error)
go func() {
// A linting error occurs for weakly typing the context value here.
//nolint // The above seems reasonable for a one-off test.
ctx := context.WithValue(ctx, "gcp-client", metadata)
errC <- cmd.ExecuteContext(ctx)
}()
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
workspace, err := client.Workspace(ctx, workspace.ID)
require.NoError(t, err)
@@ -248,7 +223,7 @@ func TestWorkspaceAgent(t *testing.T) {
dialer, err := client.DialWorkspaceAgent(ctx, resources[0].Agents[0].ID, nil)
require.NoError(t, err)
defer dialer.Close()
require.True(t, dialer.AwaitReachable(context.Background()))
require.True(t, dialer.AwaitReachable(ctx))
sshClient, err := dialer.SSHClient(ctx)
require.NoError(t, err)
defer sshClient.Close()
@@ -264,9 +239,47 @@ func TestWorkspaceAgent(t *testing.T) {
require.NoError(t, err)
_, err = uuid.Parse(strings.TrimSpace(string(token)))
require.NoError(t, err)
})
cancelFunc()
err = <-errC
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.AwaitTemplateVersionJobCompleted(t, client, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJobCompleted(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 subsystems for the agent.
inv.Environ.Set(agent.EnvAgentSubsystem, fmt.Sprintf("%s,%s", codersdk.AgentSubsystemExectrace, 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.Len(t, resources[0].Agents[0].Subsystems, 2)
// Sorted
require.Equal(t, codersdk.AgentSubsystemEnvbox, resources[0].Agents[0].Subsystems[0])
require.Equal(t, codersdk.AgentSubsystemExectrace, resources[0].Agents[0].Subsystems[1])
})
}
+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
}
+581
View File
@@ -0,0 +1,581 @@
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"
"github.com/coder/coder/v2/coderd/util/slice"
)
// 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) int {
return slice.Ascending(a.Name, b.Name)
})
slices.SortFunc(c.Children, func(a, b *Cmd) int {
return slice.Ascending(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,
)
}
// All options should be set. Check all required options have sources,
// meaning they were set by the user in some way (env, flag, etc).
var missing []string
for _, opt := range inv.Command.Options {
if opt.Required && opt.ValueSource == ValueSourceNone {
missing = append(missing, opt.Flag)
}
}
if len(missing) > 0 {
return xerrors.Errorf("Missing values for the required flags: %s", strings.Join(missing, ", "))
}
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
+719
View File
@@ -0,0 +1,719 @@
package clibase_test
import (
"bytes"
"context"
"fmt"
"os"
"strings"
"testing"
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/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
reqBool bool
reqStr 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: "required-flag --req-bool=true --req-string=foo",
Short: "Example with required flags",
Options: clibase.OptionSet{
clibase.Option{
Name: "req-bool",
Flag: "req-bool",
Value: clibase.BoolOf(&reqBool),
Required: true,
},
clibase.Option{
Name: "req-string",
Flag: "req-string",
Value: clibase.Validate(clibase.StringOf(&reqStr), func(value *clibase.String) error {
ok := strings.Contains(value.String(), " ")
if !ok {
return xerrors.Errorf("string must contain a space")
}
return nil
}),
Required: true,
},
},
Handler: func(i *clibase.Invocation) error {
_, _ = i.Stdout.Write([]byte(fmt.Sprintf("%s-%t", reqStr, reqBool)))
return nil
},
},
{
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())
})
t.Run("RequiredFlagsMissing", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"required-flag",
)
fio := fakeIO(i)
err := i.Run()
require.Error(t, err, fio.Stdout.String())
require.ErrorContains(t, err, "Missing values")
})
t.Run("RequiredFlagsMissingBool", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"required-flag", "--req-string", "foo bar",
)
fio := fakeIO(i)
err := i.Run()
require.Error(t, err, fio.Stdout.String())
require.ErrorContains(t, err, "Missing values for the required flags: req-bool")
})
t.Run("RequiredFlagsMissingString", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"required-flag", "--req-bool", "true",
)
fio := fakeIO(i)
err := i.Run()
require.Error(t, err, fio.Stdout.String())
require.ErrorContains(t, err, "Missing values for the required flags: req-string")
})
t.Run("RequiredFlagsInvalid", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"required-flag", "--req-string", "nospace",
)
fio := fakeIO(i)
err := i.Run()
require.Error(t, err, fio.Stdout.String())
require.ErrorContains(t, err, "string must contain a space")
})
t.Run("RequiredFlagsOK", func(t *testing.T) {
t.Parallel()
i := cmd().Invoke(
"required-flag", "--req-bool", "true", "--req-string", "foo bar",
)
fio := fakeIO(i)
err := i.Run()
require.NoError(t, err, 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/v2/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)
}
})
}
}
+346
View File
@@ -0,0 +1,346 @@
package clibase
import (
"bytes"
"encoding/json"
"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"`
// Required means this value must be set by some means. It requires
// `ValueSource != ValueSourceNone`
// If `Default` is set, then `Required` is ignored.
Required bool `json:"required,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"`
}
// optionNoMethods is just a wrapper around Option so we can defer to the
// default json.Unmarshaler behavior.
type optionNoMethods Option
func (o *Option) UnmarshalJSON(data []byte) error {
// If an option has no values, we have no idea how to unmarshal it.
// So just discard the json data.
if o.Value == nil {
o.Value = &DiscardValue
}
return json.Unmarshal(data, (*optionNoMethods)(o))
}
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
// UnmarshalJSON implements json.Unmarshaler for OptionSets. Options have an
// interface Value type that cannot handle unmarshalling because the types cannot
// be inferred. Since it is a slice, instantiating the Options first does not
// help.
//
// However, we typically do instantiate the slice to have the correct types.
// So this unmarshaller will attempt to find the named option in the existing
// set, if it cannot, the value is discarded. If the option exists, the value
// is unmarshalled into the existing option, and replaces the existing option.
//
// The value is discarded if it's type cannot be inferred. This behavior just
// feels "safer", although it should never happen if the correct option set
// is passed in. The situation where this could occur is if a client and server
// are on different versions with different options.
func (optSet *OptionSet) UnmarshalJSON(data []byte) error {
dec := json.NewDecoder(bytes.NewBuffer(data))
// Should be a json array, so consume the starting open bracket.
t, err := dec.Token()
if err != nil {
return xerrors.Errorf("read array open bracket: %w", err)
}
if t != json.Delim('[') {
return xerrors.Errorf("expected array open bracket, got %q", t)
}
// As long as json elements exist, consume them. The counter is used for
// better errors.
var i int
OptionSetDecodeLoop:
for dec.More() {
var opt Option
// jValue is a placeholder value that allows us to capture the
// raw json for the value to attempt to unmarshal later.
var jValue jsonValue
opt.Value = &jValue
err := dec.Decode(&opt)
if err != nil {
return xerrors.Errorf("decode %d option: %w", i, err)
}
// This counter is used to contextualize errors to show which element of
// the array we failed to decode. It is only used in the error above, as
// if the above works, we can instead use the Option.Name which is more
// descriptive and useful. So increment here for the next decode.
i++
// Try to see if the option already exists in the option set.
// If it does, just update the existing option.
for optIndex, have := range *optSet {
if have.Name == opt.Name {
if jValue != nil {
err := json.Unmarshal(jValue, &(*optSet)[optIndex].Value)
if err != nil {
return xerrors.Errorf("decode option %q value: %w", have.Name, err)
}
// Set the opt's value
opt.Value = (*optSet)[optIndex].Value
} else {
// Hopefully the user passed empty values in the option set. There is no easy way
// to tell, and if we do not do this, it breaks json.Marshal if we do it again on
// this new option set.
opt.Value = (*optSet)[optIndex].Value
}
// Override the existing.
(*optSet)[optIndex] = opt
// Go to the next option to decode.
continue OptionSetDecodeLoop
}
}
// If the option doesn't exist, the value will be discarded.
// We do this because we cannot infer the type of the value.
opt.Value = DiscardValue
*optSet = append(*optSet, opt)
}
t, err = dec.Token()
if err != nil {
return xerrors.Errorf("read array close bracket: %w", err)
}
if t != json.Delim(']') {
return xerrors.Errorf("expected array close bracket, got %q", t)
}
return nil
}
// Add adds the given Options to the OptionSet.
func (optSet *OptionSet) Add(opts ...Option) {
*optSet = append(*optSet, opts...)
}
// Filter will only return options that match the given filter. (return true)
func (optSet OptionSet) Filter(filter func(opt Option) bool) OptionSet {
cpy := make(OptionSet, 0)
for _, opt := range optSet {
if filter(opt) {
cpy = append(cpy, opt)
}
}
return cpy
}
// FlagSet returns a pflag.FlagSet for the OptionSet.
func (optSet *OptionSet) FlagSet() *pflag.FlagSet {
if optSet == nil {
return &pflag.FlagSet{}
}
fs := pflag.NewFlagSet("", pflag.ContinueOnError)
for _, opt := range *optSet {
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 (optSet *OptionSet) ParseEnv(vs []EnvVar) error {
if optSet == 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 *optSet {
if opt.Env == "" {
continue
}
envVal, ok := envs[opt.Env]
if !ok {
// Homebrew strips all environment variables that do not start with `HOMEBREW_`.
// This prevented using brew to invoke the Coder agent, because the environment
// variables to not get passed down.
//
// A customer wanted to use their custom tap inside a workspace, which was failing
// because the agent lacked the environment variables to authenticate with Git.
envVal, ok = envs[`HOMEBREW_`+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
}
(*optSet)[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 (optSet *OptionSet) SetDefaults() error {
if optSet == nil {
return nil
}
var merr *multierror.Error
for i, opt := range *optSet {
// 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
}
(*optSet)[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 (optSet *OptionSet) ByName(name string) *Option {
for i := range *optSet {
opt := &(*optSet)[i]
if opt.Name == name {
return opt
}
}
return nil
}
+391
View File
@@ -0,0 +1,391 @@
package clibase_test
import (
"bytes"
"encoding/json"
"regexp"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/cli/clibase"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/codersdk"
)
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)
})
t.Run("RegexValid", func(t *testing.T) {
t.Parallel()
var regexpString clibase.Regexp
os := clibase.OptionSet{
clibase.Option{
Name: "RegexpString",
Value: &regexpString,
Flag: "regexp-string",
},
}
err := os.FlagSet().Parse([]string{"--regexp-string", "$test^"})
require.NoError(t, err)
})
t.Run("RegexInvalid", func(t *testing.T) {
t.Parallel()
var regexpString clibase.Regexp
os := clibase.OptionSet{
clibase.Option{
Name: "RegexpString",
Value: &regexpString,
Flag: "regexp-string",
},
}
err := os.FlagSet().Parse([]string{"--regexp-string", "(("})
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)
})
t.Run("Homebrew", func(t *testing.T) {
t.Parallel()
var agentToken clibase.String
os := clibase.OptionSet{
clibase.Option{
Name: "Agent Token",
Value: &agentToken,
Env: "AGENT_TOKEN",
},
}
err := os.ParseEnv([]clibase.EnvVar{
{Name: "HOMEBREW_AGENT_TOKEN", Value: "foo"},
})
require.NoError(t, err)
require.EqualValues(t, "foo", agentToken)
})
}
func TestOptionSet_JsonMarshal(t *testing.T) {
t.Parallel()
// This unit test ensures if the source optionset is missing the option
// and cannot determine the type, it will not panic. The unmarshal will
// succeed with a best effort.
t.Run("MissingSrcOption", func(t *testing.T) {
t.Parallel()
var str clibase.String = "something"
var arr clibase.StringArray = []string{"foo", "bar"}
opts := clibase.OptionSet{
clibase.Option{
Name: "StringOpt",
Value: &str,
},
clibase.Option{
Name: "ArrayOpt",
Value: &arr,
},
}
data, err := json.Marshal(opts)
require.NoError(t, err, "marshal option set")
tgt := clibase.OptionSet{}
err = json.Unmarshal(data, &tgt)
require.NoError(t, err, "unmarshal option set")
for i := range opts {
compareOptionsExceptValues(t, opts[i], tgt[i])
require.Empty(t, tgt[i].Value.String(), "unknown value types are empty")
}
})
t.Run("RegexCase", func(t *testing.T) {
t.Parallel()
val := clibase.Regexp(*regexp.MustCompile(".*"))
opts := clibase.OptionSet{
clibase.Option{
Name: "Regex",
Value: &val,
Default: ".*",
},
}
data, err := json.Marshal(opts)
require.NoError(t, err, "marshal option set")
var foundVal clibase.Regexp
newOpts := clibase.OptionSet{
clibase.Option{
Name: "Regex",
Value: &foundVal,
},
}
err = json.Unmarshal(data, &newOpts)
require.NoError(t, err, "unmarshal option set")
require.EqualValues(t, opts[0].Value.String(), newOpts[0].Value.String())
})
t.Run("AllValues", func(t *testing.T) {
t.Parallel()
vals := coderdtest.DeploymentValues(t)
opts := vals.Options()
sources := []clibase.ValueSource{
clibase.ValueSourceNone,
clibase.ValueSourceFlag,
clibase.ValueSourceEnv,
clibase.ValueSourceYAML,
clibase.ValueSourceDefault,
}
for i := range opts {
opts[i].ValueSource = sources[i%len(sources)]
}
data, err := json.Marshal(opts)
require.NoError(t, err, "marshal option set")
newOpts := (&codersdk.DeploymentValues{}).Options()
err = json.Unmarshal(data, &newOpts)
require.NoError(t, err, "unmarshal option set")
for i := range opts {
exp := opts[i]
found := newOpts[i]
compareOptionsExceptValues(t, exp, found)
compareValues(t, exp, found)
}
thirdOpts := (&codersdk.DeploymentValues{}).Options()
data, err = json.Marshal(newOpts)
require.NoError(t, err, "marshal option set")
err = json.Unmarshal(data, &thirdOpts)
require.NoError(t, err, "unmarshal option set")
// Compare to the original opts again
for i := range opts {
exp := opts[i]
found := thirdOpts[i]
compareOptionsExceptValues(t, exp, found)
compareValues(t, exp, found)
}
})
}
func compareOptionsExceptValues(t *testing.T, exp, found clibase.Option) {
t.Helper()
require.Equalf(t, exp.Name, found.Name, "option name %q", exp.Name)
require.Equalf(t, exp.Description, found.Description, "option description %q", exp.Name)
require.Equalf(t, exp.Required, found.Required, "option required %q", exp.Name)
require.Equalf(t, exp.Flag, found.Flag, "option flag %q", exp.Name)
require.Equalf(t, exp.FlagShorthand, found.FlagShorthand, "option flag shorthand %q", exp.Name)
require.Equalf(t, exp.Env, found.Env, "option env %q", exp.Name)
require.Equalf(t, exp.YAML, found.YAML, "option yaml %q", exp.Name)
require.Equalf(t, exp.Default, found.Default, "option default %q", exp.Name)
require.Equalf(t, exp.ValueSource, found.ValueSource, "option value source %q", exp.Name)
require.Equalf(t, exp.Hidden, found.Hidden, "option hidden %q", exp.Name)
require.Equalf(t, exp.Annotations, found.Annotations, "option annotations %q", exp.Name)
require.Equalf(t, exp.Group, found.Group, "option group %q", exp.Name)
// UseInstead is the same comparison problem, just check the length
require.Equalf(t, len(exp.UseInstead), len(found.UseInstead), "option use instead %q", exp.Name)
}
func compareValues(t *testing.T, exp, found clibase.Option) {
t.Helper()
if (exp.Value == nil || found.Value == nil) || (exp.Value.String() != found.Value.String() && found.Value.String() == "") {
// If the string values are different, this can be a "nil" issue.
// So only run this case if the found string is the empty string.
// We use MarshalYAML for struct strings, and it will return an
// empty string '""' for nil slices/maps/etc.
// So use json to compare.
expJSON, err := json.Marshal(exp.Value)
require.NoError(t, err, "marshal")
foundJSON, err := json.Marshal(found.Value)
require.NoError(t, err, "marshal")
expJSON = normalizeJSON(expJSON)
foundJSON = normalizeJSON(foundJSON)
assert.Equalf(t, string(expJSON), string(foundJSON), "option value %q", exp.Name)
} else {
assert.Equal(t,
exp.Value.String(),
found.Value.String(),
"option value %q", exp.Name)
}
}
// normalizeJSON handles the fact that an empty map/slice is not the same
// as a nil empty/slice. For our purposes, they are the same.
func normalizeJSON(data []byte) []byte {
if bytes.Equal(data, []byte("[]")) || bytes.Equal(data, []byte("{}")) {
return []byte("null")
}
return data
}
+567
View File
@@ -0,0 +1,567 @@
package clibase
import (
"encoding/csv"
"encoding/json"
"fmt"
"net"
"net/url"
"reflect"
"regexp"
"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
}
// Validator is a wrapper around a pflag.Value that allows for validation
// of the value after or before it has been set.
type Validator[T pflag.Value] struct {
Value T
// validate is called after the value is set.
validate func(T) error
}
func Validate[T pflag.Value](opt T, validate func(value T) error) *Validator[T] {
return &Validator[T]{Value: opt, validate: validate}
}
func (i *Validator[T]) String() string {
return i.Value.String()
}
func (i *Validator[T]) Set(input string) error {
err := i.Value.Set(input)
if err != nil {
return err
}
if i.validate != nil {
err = i.validate(i.Value)
if err != nil {
return err
}
}
return nil
}
func (i *Validator[T]) Type() string {
return i.Value.Type()
}
// 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
}
//nolint:revive
func (s *Struct[T]) Set(v string) error {
return yaml.Unmarshal([]byte(v), &s.Value)
}
//nolint:revive
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)
}
//nolint:revive
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"
}
func (discardValue) UnmarshalJSON([]byte) error {
return nil
}
// jsonValue is intentionally not exported. It is just used to store the raw JSON
// data for a value to defer it's unmarshal. It implements the pflag.Value to be
// usable in an Option.
type jsonValue json.RawMessage
func (jsonValue) Set(string) error {
return xerrors.Errorf("json value is read-only")
}
func (jsonValue) String() string {
return ""
}
func (jsonValue) Type() string {
return "json"
}
func (j *jsonValue) UnmarshalJSON(data []byte) error {
if j == nil {
return xerrors.New("json.RawMessage: UnmarshalJSON on nil pointer")
}
*j = append((*j)[0:0], data...)
return nil
}
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
}
type Regexp regexp.Regexp
func (r *Regexp) MarshalJSON() ([]byte, error) {
return json.Marshal(r.String())
}
func (r *Regexp) UnmarshalJSON(data []byte) error {
var source string
err := json.Unmarshal(data, &source)
if err != nil {
return err
}
exp, err := regexp.Compile(source)
if err != nil {
return xerrors.Errorf("invalid regex expression: %w", err)
}
*r = Regexp(*exp)
return nil
}
func (r *Regexp) MarshalYAML() (interface{}, error) {
return yaml.Node{
Kind: yaml.ScalarNode,
Value: r.String(),
}, nil
}
func (r *Regexp) UnmarshalYAML(n *yaml.Node) error {
return r.Set(n.Value)
}
func (r *Regexp) Set(v string) error {
exp, err := regexp.Compile(v)
if err != nil {
return xerrors.Errorf("invalid regex expression: %w", err)
}
*r = Regexp(*exp)
return nil
}
func (r Regexp) String() string {
return r.Value().String()
}
func (r *Regexp) Value() *regexp.Regexp {
if r == nil {
return nil
}
return (*regexp.Regexp)(r)
}
func (Regexp) Type() string {
return "regexp"
}
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 (optSet *OptionSet) MarshalYAML() (any, error) {
root := yaml.Node{
Kind: yaml.MappingNode,
}
for _, opt := range *optSet {
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 (optSet *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 *optSet {
opt := &(*optSet)[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/v2/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)
})
}
}
-185
View File
@@ -1,185 +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"
"time"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/coder/coder/cli/cliui"
)
// IsSetBool returns the value of the boolean flag if it is set.
// It returns false if the flag isn't set or if any error occurs attempting
// to parse the value of the flag.
func IsSetBool(cmd *cobra.Command, name string) bool {
val, ok := IsSet(cmd, name)
if !ok {
return false
}
b, err := strconv.ParseBool(val)
return err == nil && b
}
// IsSet returns the string value of the flag and whether it was set.
func IsSet(cmd *cobra.Command, name string) (string, bool) {
flag := cmd.Flag(name)
if flag == nil {
return "", false
}
return flag.Value.String(), flag.Changed
}
// 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 StringArray(flagset *pflag.FlagSet, name, shorthand, env string, def []string, usage string) {
v, ok := os.LookupEnv(env)
if !ok || v == "" {
if v == "" {
def = []string{}
} else {
def = strings.Split(v, ",")
}
}
flagset.StringArrayP(name, shorthand, def, 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 {
if val == "" {
def = []string{}
} else {
def = strings.Split(val, ",")
}
}
flagset.StringArrayVarP(ptr, name, shorthand, def, fmtUsage(usage, env))
}
// 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))
}
// IntVarP sets a uint8 flag on the given flag set.
func IntVarP(flagset *pflag.FlagSet, ptr *int, name string, shorthand string, env string, def int, usage string) {
val, ok := os.LookupEnv(env)
if !ok || val == "" {
flagset.IntVarP(ptr, name, shorthand, def, fmtUsage(usage, env))
return
}
vi64, err := strconv.ParseUint(val, 10, 8)
if err != nil {
flagset.IntVarP(ptr, name, shorthand, def, fmtUsage(usage, env))
return
}
flagset.IntVarP(ptr, name, shorthand, int(vi64), fmtUsage(usage, env))
}
func Bool(flagset *pflag.FlagSet, name, shorthand, env string, def bool, usage string) {
val, ok := os.LookupEnv(env)
if !ok || val == "" {
flagset.BoolP(name, shorthand, def, fmtUsage(usage, env))
return
}
valb, err := strconv.ParseBool(val)
if err != nil {
flagset.BoolP(name, shorthand, def, fmtUsage(usage, env))
return
}
flagset.BoolP(name, shorthand, valb, 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))
}
// DurationVarP sets a time.Duration flag on the given flag set.
func DurationVarP(flagset *pflag.FlagSet, ptr *time.Duration, name string, shorthand string, env string, def time.Duration, usage string) {
val, ok := os.LookupEnv(env)
if !ok || val == "" {
flagset.DurationVarP(ptr, name, shorthand, def, fmtUsage(usage, env))
return
}
valb, err := time.ParseDuration(val)
if err != nil {
flagset.DurationVarP(ptr, name, shorthand, def, fmtUsage(usage, env))
return
}
flagset.DurationVarP(ptr, name, shorthand, valb, fmtUsage(usage, env))
}
func fmtUsage(u string, env string) string {
if env != "" {
// Avoid double dotting.
dot := "."
if strings.HasSuffix(u, ".") {
dot = ""
}
u = fmt.Sprintf("%s%s\n"+cliui.Styles.Placeholder.Render("Consumes $%s"), u, dot, env)
}
return u
}
-277
View File
@@ -1,277 +0,0 @@
package cliflag_test
import (
"fmt"
"strconv"
"testing"
"time"
"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("StringArrayEnvVarEmpty", func(t *testing.T) {
var ptr []string
flagset, name, shorthand, env, usage := randomFlag()
t.Setenv(env, "")
cliflag.StringArrayVarP(flagset, &ptr, name, shorthand, env, nil, usage)
got, err := flagset.GetStringArray(name)
require.NoError(t, err)
require.Equal(t, []string{}, got)
})
t.Run("UInt8Default", 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("UInt8EnvVar", 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("UInt8FailParse", 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("IntDefault", func(t *testing.T) {
var ptr int
flagset, name, shorthand, env, usage := randomFlag()
def, _ := cryptorand.Int63n(10)
cliflag.IntVarP(flagset, &ptr, name, shorthand, env, int(def), usage)
got, err := flagset.GetInt(name)
require.NoError(t, err)
require.Equal(t, int(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 int
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.Int63n(10)
t.Setenv(env, strconv.FormatUint(uint64(envValue), 10))
def, _ := cryptorand.Int()
cliflag.IntVarP(flagset, &ptr, name, shorthand, env, def, usage)
got, err := flagset.GetInt(name)
require.NoError(t, err)
require.Equal(t, int(envValue), got)
})
t.Run("IntFailParse", func(t *testing.T) {
var ptr int
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.String(10)
t.Setenv(env, envValue)
def, _ := cryptorand.Int63n(10)
cliflag.IntVarP(flagset, &ptr, name, shorthand, env, int(def), usage)
got, err := flagset.GetInt(name)
require.NoError(t, err)
require.Equal(t, int(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)
})
t.Run("DurationDefault", func(t *testing.T) {
var ptr time.Duration
flagset, name, shorthand, env, usage := randomFlag()
def, _ := cryptorand.Duration()
cliflag.DurationVarP(flagset, &ptr, name, shorthand, env, def, usage)
got, err := flagset.GetDuration(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("DurationEnvVar", func(t *testing.T) {
var ptr time.Duration
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.Duration()
t.Setenv(env, envValue.String())
def, _ := cryptorand.Duration()
cliflag.DurationVarP(flagset, &ptr, name, shorthand, env, def, usage)
got, err := flagset.GetDuration(name)
require.NoError(t, err)
require.Equal(t, envValue, got)
})
t.Run("DurationFailParse", func(t *testing.T) {
var ptr time.Duration
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.String(10)
t.Setenv(env, envValue)
def, _ := cryptorand.Duration()
cliflag.DurationVarP(flagset, &ptr, name, shorthand, env, def, usage)
got, err := flagset.GetDuration(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
}
+360
View File
@@ -0,0 +1,360 @@
package clistat
import (
"bufio"
"bytes"
"strconv"
"strings"
"github.com/hashicorp/go-multierror"
"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/cpuacct.usage"
// CFS quota and period for cgroup in MICROseconds
cgroupV1CFSQuotaUs = "/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us"
// CFS period for cgroup in MICROseconds
cgroupV1CFSPeriodUs = "/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_period_us"
// Maximum memory usable by cgroup in bytes
cgroupV1MemoryMaxUsageBytes = "/sys/fs/cgroup/memory/memory.limit_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,
Prefix: PrefixDefault,
}
if total > 0 {
r.Total = ptr.To(total)
}
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 {
if xerrors.Is(err, strconv.ErrSyntax) {
// If the value is not a valid integer, assume it is the string
// 'max' and that there is no limit set.
return -1, nil
}
return 0, xerrors.Errorf("get cpu quota: %w", err)
}
return float64(quotaUs) / float64(periodUs), nil
}
func (s *Statter) cGroupV1CPUTotal() (float64, error) {
periodUs, err := readInt64(s.fs, cgroupV1CFSPeriodUs)
if err != nil {
// Try alternate path under /sys/fs/cpu
var merr error
merr = multierror.Append(merr, xerrors.Errorf("get cpu period: %w", err))
periodUs, err = readInt64(s.fs, strings.Replace(cgroupV1CFSPeriodUs, "cpu,cpuacct", "cpu", 1))
if err != nil {
merr = multierror.Append(merr, xerrors.Errorf("get cpu period: %w", err))
return 0, merr
}
}
quotaUs, err := readInt64(s.fs, cgroupV1CFSQuotaUs)
if err != nil {
// Try alternate path under /sys/fs/cpu
var merr error
merr = multierror.Append(merr, xerrors.Errorf("get cpu quota: %w", err))
quotaUs, err = readInt64(s.fs, strings.Replace(cgroupV1CFSQuotaUs, "cpu,cpuacct", "cpu", 1))
if err != nil {
merr = multierror.Append(merr, xerrors.Errorf("get cpu quota: %w", err))
return 0, merr
}
}
if quotaUs < 0 {
return -1, nil
}
return float64(quotaUs) / float64(periodUs), nil
}
func (s *Statter) cGroupV1CPUUsed() (float64, error) {
usageNs, err := readInt64(s.fs, cgroupV1CPUAcctUsage)
if err != nil {
// Try alternate path under /sys/fs/cgroup/cpuacct
var merr error
merr = multierror.Append(merr, xerrors.Errorf("read cpu used: %w", err))
usageNs, err = readInt64(s.fs, strings.Replace(cgroupV1CPUAcctUsage, "cpu,cpuacct", "cpuacct", 1))
if err != nil {
merr = multierror.Append(merr, xerrors.Errorf("read cpu used: %w", err))
return 0, merr
}
}
// usage is in ns, convert to us
usageNs /= 1000
periodUs, err := readInt64(s.fs, cgroupV1CFSPeriodUs)
if err != nil {
// Try alternate path under /sys/fs/cpu
var merr error
merr = multierror.Append(merr, xerrors.Errorf("get cpu period: %w", err))
periodUs, err = readInt64(s.fs, strings.Replace(cgroupV1CFSPeriodUs, "cpu,cpuacct", "cpu", 1))
if err != nil {
merr = multierror.Append(merr, xerrors.Errorf("get cpu period: %w", err))
return 0, merr
}
}
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) {
r := &Result{
Unit: "B",
Prefix: p,
}
maxUsageBytes, err := readInt64(s.fs, cgroupV2MemoryMaxBytes)
if err != nil {
if !xerrors.Is(err, strconv.ErrSyntax) {
return nil, xerrors.Errorf("read memory total: %w", err)
}
// If the value is not a valid integer, assume it is the string
// 'max' and that there is no limit set.
} else {
r.Total = ptr.To(float64(maxUsageBytes))
}
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)
}
r.Used = float64(currUsageBytes - inactiveFileBytes)
return r, nil
}
func (s *Statter) cGroupV1Memory(p Prefix) (*Result, error) {
r := &Result{
Unit: "B",
Prefix: p,
}
maxUsageBytes, err := readInt64(s.fs, cgroupV1MemoryMaxUsageBytes)
if err != nil {
if !xerrors.Is(err, strconv.ErrSyntax) {
return nil, xerrors.Errorf("read memory total: %w", err)
}
// I haven't found an instance where this isn't a valid integer.
// Nonetheless, if it is not, assume there is no limit set.
maxUsageBytes = -1
}
// 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)
}
// If max usage bytes is -1, there is no memory limit set.
if maxUsageBytes > 0 {
r.Total = ptr.To(float64(maxUsageBytes))
}
// Total memory used is usage - total_inactive_file
r.Used = float64(usageBytes - totalInactiveFileBytes)
return r, 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 := strings.TrimSpace(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)
}

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