Compare commits

...

2566 Commits

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

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

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

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

* Switch to backend fix

* Increase e2e test timeout

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

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

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

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

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

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

* Limit release concurrency

* Add automatic release watching

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

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

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

* Swagger comments in workspacebuilds.go

* structs in workspacebuilds.go

* workspaceagents: instance identity

* workspaceagents.go in progress

* workspaceagents.go in progress

* Agents

* workspacebuilds.go

* /workspaces

* templates.go, templateversions.go

* templateversion.go in progress

* cancel

* templateversions

* wip

* Merge

* x-apidocgen

* NullTime hack not needed anymore

* Fix: x-apidocgen

* Members

* Fixes

* Fix

* WIP

* WIP

* Users

* Logout

* User profile

* Status suspend activate

* User roles

* User tokens

* Keys

* SSH key

* All

* Typo

* Fix

* Entitlements

* Groups

* SCIM

* Fix

* Fix

* Clean templates

* Sort API pages

* Fix: HashedSecret

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

* Swagger comments in workspacebuilds.go

* structs in workspacebuilds.go

* workspaceagents: instance identity

* workspaceagents.go in progress

* workspaceagents.go in progress

* Agents

* workspacebuilds.go

* /workspaces

* templates.go, templateversions.go

* templateversion.go in progress

* cancel

* templateversions

* wip

* Merge

* x-apidocgen

* NullTime hack not needed anymore

* Fix: x-apidocgen

* Members

* Fixes

* Fix

* WIP

* WIP

* Users

* Logout

* User profile

* Status suspend activate

* User roles

* User tokens

* Keys

* SSH key

* All

* Typo

* Fix

* Fix

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

* Swagger comments in workspacebuilds.go

* structs in workspacebuilds.go

* workspaceagents: instance identity

* workspaceagents.go in progress

* workspaceagents.go in progress

* Agents

* workspacebuilds.go

* /workspaces

* templates.go, templateversions.go

* templateversion.go in progress

* cancel

* templateversions

* wip

* Merge

* x-apidocgen

* NullTime hack not needed anymore

* Fix: x-apidocgen

* Members

* Fixes

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

* Save auth state

* Add template creation - wip

Remove saved auth state because it wasn't working

* Try adding the rest of the tests

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

* Update playwright

* Update gitignore

* Write tests

* Format

* Update ignores

* Check that start worked

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

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

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

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

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

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

* Fix: format

* swaggo: time.Duration

* swaggo: provisionertype

* Fix: AuthorizationObject

* Fix: enums

* Fix: netip.Addr

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

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

* refactor: split page view SecuritySettingsPage

* feat: add storybook for security page

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

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

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

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

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

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

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

* refactor: split page/view UserAuthSettings

* feat: add storybook for user auth

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

* - Corrected formatting errors, and renamed functions

* - Fixed typos
- Added recommend changes for consistency

* Removed unzip check in standalone function

* Fixed styling

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

* refactor: split page/view NetworkSettings

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

* refactor: split page and view GitAuthSettingsPage

* fixup!: formatting

* refactor: narrow props in git auth view

* feat: add storybook for GitAuthSettingsPageView

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

* feat: add story for generalsettingspageview

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

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

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

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

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

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

* wip: move appearancesettingspage

* refactor: separate page and view ApperanceSettings

* refactor: create storybook from AppearanceSettingsView

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

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

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

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

* added transformer for esm

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

* fix: lima: make docker socket usable by Lima user without sudo

* fix: lima: set access URL to host.lima.internal

* apply suggestion from PR
2023-01-05 11:47:33 +00:00
Muhammad Atif Ali 0124289f1a fix(ci): fix winget installer workflow (#5569)
* fix(ci): add GH_TOKEN env

* chore: fix windows installer build filename

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-01-05 04:56:00 +00:00
Ben Potter 04d45f3c1c fix!: remove AUTO_IMPORT_TEMPLATE for Kubernetes installs (#5401)
* fix!: remove AUTO_IMPORT_TEMPLATE

* chore: remove template auto importing

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-01-05 04:04:32 +00:00
dependabot[bot] 24592332e2 chore: bump github.com/gohugoio/hugo from 0.107.0 to 0.109.0 (#5541)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-05 10:34:53 +10:30
dependabot[bot] 2db9df4491 chore: bump github.com/prometheus/common from 0.37.0 to 0.39.0 (#5544)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-04 23:42:13 +00:00
dependabot[bot] c0dfbdf143 chore: bump emoji-mart from 5.3.3 to 5.4.0 in /site (#5527)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-05 10:00:56 +10:30
Ammar Bandukwala 0b63825a07 site: fix copy in users roles view (#5583) 2023-01-04 17:13:04 -06:00
Joe Previte a231c1a384 fix: styles for <AlertBanner /> (#5579)
* feat: add new story for LoginPageView

* fix: update <AlertBanner /> styles

- align text to the left
- add padding to the top of span inside

* fixup: formatting
2023-01-04 14:46:41 -07:00
Kyle Carberry c51b5a05db fix: add case for non-entitled logo url (#5580)
This was missing from my prior contribution, which
would lead any user to believe they could customize the logo.
2023-01-04 21:39:54 +00:00
Kyle Carberry 0dba2defd1 feat: enable enterprise users to specify a custom logo (#5566)
* feat: enable enterprise users to specify a custom logo

This adds a field in deployment settings that allows users to specify
the URL to a custom logo that will display in the dashboard.

This also groups service banner into a new appearance settings page.
It adds a Fieldset component to allow for modular fields moving forward.

* Fix tests
2023-01-04 15:31:45 -06:00
Bruno Quaresma 175be621cf refactor: Improve roles UI (#5576) 2023-01-04 18:30:35 -03:00
Jan Losinski de0601d611 feat: allow configurable username claim field in OIDC (#5507)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2023-01-04 15:16:31 -06:00
Kyle Carberry 8968a00035 fix: add spacing between the copyright and login box (#5578)
I forgot to commit this before merging my prior PR!
2023-01-04 16:00:25 -03:00
Mathias Fredriksson ebe1b56c08 chore: Switch from npm to yarn in scripts/apidocgen (#5575) 2023-01-04 19:38:48 +01:00
Kyle Carberry a36cd0bd7b refactor: move footer items into the user dropdown (#5562)
* refactor: move footer items into the user dropdown

The items at the bottom looked unprofessional. Users don't
always need to be prompted to join our Discord or see the
active version of Coder.

This moves the items in the user dropdown which looks better.

* Update site/src/components/UserDropdownContent/UserDropdownContent.tsx

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

* Fix import order

Co-authored-by: Asher <ash@coder.com>
2023-01-04 12:36:25 -06:00
Marcin Tojek 925b29836c docs: improve authentication page (#5567)
* docs: improve authentication page

* Update docs/admin/automation.md

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

* Update docs/admin/automation.md

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

* Fix

* Fix

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2023-01-04 10:14:47 -08:00
Dean Sheather 91a4c2dce1 chore: remove address from deployment page (#5565) 2023-01-04 23:50:55 +10:00
Steven Masley 5e540e3439 chore: Log out the failed audit log on failures (#5561) 2023-01-03 17:22:57 -06:00
Bruno Quaresma 4e14cc5207 refactor: Remove template UI from experimental (#5555) 2023-01-03 19:29:38 +00:00
Steven Masley c5128db484 docs: Add auditor role to roles table (#5557)
* docs: Add auditor role to roles table
* make fmt
2023-01-03 12:55:26 -06:00
dependabot[bot] 3e2477f255 chore: bump actions/stale from 6.0.0 to 7.0.0 (#5515)
Bumps [actions/stale](https://github.com/actions/stale) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v6.0.0...v7.0.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-03 12:51:26 -06:00
dependabot[bot] ed114ec341 chore: bump golang.org/x/tools from 0.3.0 to 0.4.0 (#5542)
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.3.0...v0.4.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-03 12:44:37 -06:00
dependabot[bot] f1419bbc49 chore: bump golang.org/x/term from 0.2.0 to 0.3.0 (#5543)
Bumps [golang.org/x/term](https://github.com/golang/term) from 0.2.0 to 0.3.0.
- [Release notes](https://github.com/golang/term/releases)
- [Commits](https://github.com/golang/term/compare/v0.2.0...v0.3.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-03 12:44:31 -06:00
Marcin Tojek e67d131514 docs: audit, deploymentconfig, files, parameters (#5506)
* docs: audit, deploymentconfig, files, parameters

* Fix: mark as binary

* Fix: show format in docs

* Fix: use .swaggo

* Fix: swagger notice

* Swagger notice
2023-01-03 19:21:10 +01:00
Bruno Quaresma 829cfee29d refactor: Improve users table view for non admins (#5547) 2023-01-03 13:21:58 -03:00
dependabot[bot] 5e36fd522c chore: bump cronstrue from 2.14.0 to 2.21.0 in /site (#5545)
Bumps [cronstrue](https://github.com/bradymholt/cronstrue) from 2.14.0 to 2.21.0.
- [Release notes](https://github.com/bradymholt/cronstrue/releases)
- [Changelog](https://github.com/bradymholt/cRonstrue/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bradymholt/cronstrue/compare/v2.14.0...v2.21.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-03 13:21:42 -03:00
dependabot[bot] 3969a8b58b chore: bump prettier from 2.7.1 to 2.8.1 in /site (#5526)
Bumps [prettier](https://github.com/prettier/prettier) from 2.7.1 to 2.8.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.7.1...2.8.1)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-03 10:00:14 -05:00
Mathias Fredriksson 856f0ab6f5 chore: Improve project-wide prettier formatting and ignored files (#5505)
* chore: Improve project-wide prettier formatting and ignored files

* chore: `Run make fmt/prettier`

* Fix gitignore for `.vscode` folder so that ! works

* Add comment in `.prettierrc.yaml` to explain `.editorconfig`

* Remove scripts/apidocgen/markdown-template/README.md

* Use `yq` for processing prettierrc, update lib.sh dependency check

* Add `yq` to Dockerfile and Nix
2023-01-03 15:11:13 +02:00
dependabot[bot] 5435bceaf0 chore: bump tj-actions/branch-names from 6.3 to 6.4 (#5518)
Bumps [tj-actions/branch-names](https://github.com/tj-actions/branch-names) from 6.3 to 6.4.
- [Release notes](https://github.com/tj-actions/branch-names/releases)
- [Changelog](https://github.com/tj-actions/branch-names/blob/main/HISTORY.md)
- [Commits](https://github.com/tj-actions/branch-names/compare/v6.3...v6.4)

---
updated-dependencies:
- dependency-name: tj-actions/branch-names
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:42:58 -06:00
Marcin Tojek 8bb7e17bf1 chore!: remove GET workspaceagents/me/report-stats (#5530)
* chore!: remove GET workspaceagents/me/report-stats

* Fix: tests
2023-01-02 21:38:51 +01:00
dependabot[bot] d124fab642 chore: bump jaxxstorm/action-install-gh-release from 1.7.1 to 1.9.0 (#5516)
Bumps [jaxxstorm/action-install-gh-release](https://github.com/jaxxstorm/action-install-gh-release) from 1.7.1 to 1.9.0.
- [Release notes](https://github.com/jaxxstorm/action-install-gh-release/releases)
- [Commits](https://github.com/jaxxstorm/action-install-gh-release/compare/v1.7.1...v1.9.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:37:17 -06:00
dependabot[bot] 4b093115e2 chore: bump google-github-actions/setup-gcloud from 0 to 1 (#5517)
Bumps [google-github-actions/setup-gcloud](https://github.com/google-github-actions/setup-gcloud) from 0 to 1.
- [Release notes](https://github.com/google-github-actions/setup-gcloud/releases)
- [Changelog](https://github.com/google-github-actions/setup-gcloud/blob/main/CHANGELOG.md)
- [Commits](https://github.com/google-github-actions/setup-gcloud/compare/v0...v1)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:37:06 -06:00
Ammar Bandukwala 05dc83e522 docs: add hero image to About (#5539)
A reddit comment recently linked to this page, so we want to
make it convert better.
2023-01-02 14:36:36 -06:00
dependabot[bot] b6dab5fbf7 chore: bump golang.org/x/text from 0.4.0 to 0.5.0 (#5521)
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.4.0...v0.5.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:34:25 -06:00
dependabot[bot] 54eb6a5b42 chore: bump github.com/valyala/fasthttp from 1.41.0 to 1.43.0 (#5522)
Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.41.0 to 1.43.0.
- [Release notes](https://github.com/valyala/fasthttp/releases)
- [Commits](https://github.com/valyala/fasthttp/compare/v1.41.0...v1.43.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:34:02 -06:00
dependabot[bot] 8d254bd94e chore: bump github.com/prometheus/client_model from 0.2.0 to 0.3.0 (#5523)
Bumps [github.com/prometheus/client_model](https://github.com/prometheus/client_model) from 0.2.0 to 0.3.0.
- [Release notes](https://github.com/prometheus/client_model/releases)
- [Commits](https://github.com/prometheus/client_model/compare/v0.2.0...v0.3.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:33:51 -06:00
dependabot[bot] f711abb236 chore: bump github.com/elastic/go-sysinfo from 1.8.1 to 1.9.0 (#5524)
Bumps [github.com/elastic/go-sysinfo](https://github.com/elastic/go-sysinfo) from 1.8.1 to 1.9.0.
- [Release notes](https://github.com/elastic/go-sysinfo/releases)
- [Changelog](https://github.com/elastic/go-sysinfo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/elastic/go-sysinfo/compare/v1.8.1...v1.9.0)

---
updated-dependencies:
- dependency-name: github.com/elastic/go-sysinfo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 14:33:41 -06:00
dependabot[bot] 86c1753e2b chore: bump react-i18next from 12.0.0 to 12.1.1 in /site (#5525)
Bumps [react-i18next](https://github.com/i18next/react-i18next) from 12.0.0 to 12.1.1.
- [Release notes](https://github.com/i18next/react-i18next/releases)
- [Changelog](https://github.com/i18next/react-i18next/blob/master/CHANGELOG.md)
- [Commits](https://github.com/i18next/react-i18next/compare/v12.0.0...v12.1.1)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 10:35:39 -03:00
Geoffrey Huntley 26b54cd144 chore(autofix): upgrade-examples-terraform-provider-coder (#5498)
Automatically generated via https://github.com/coder/autofix
2022-12-23 12:25:56 +10:30
Dean Sheather 3e2e2ac49e fix: enforce unique agent names per workspace (#5497) 2022-12-22 15:20:35 -08:00
sharkymark 461c0d0d39 docs: v1 docs redirect (#5509)
* docs: v1 docs redirect

* fix link

Co-authored-by: Ben <me@bpmct.net>
2022-12-22 15:14:36 -08:00
Muhammad Atif Ali 341c4329f4 ci: enable CodeQL code scanning (#5279)
Co-authored-by: Dean Sheather <dean@deansheather.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Co-authored-by: Geoffrey Huntley <ghuntley@ghuntley.com>
2022-12-22 22:12:55 +02:00
Presley Pizzo c8f34bbad7 Test enabling deadline change buttons (#5508) 2022-12-22 13:47:07 -05:00
Presley Pizzo 418022943a fix: use template default ttl when enabling auto-stop (#5494)
* Fetch default ttl - wip

* Convert ms to hours

* Format

* Fix story

* Add test
2022-12-22 12:52:27 -05:00
Marcin Tojek cfd02d959c docs: api root, buildinfo, csp (#5493)
* docs: Applications

* WIP

* WIP

* WIP

* Fix: consume

* Fix: @Description

* Fix

* docs: apiroot, buildinfo, csp

* Fix: buildinfo

* docs: updatecheck

* docs: apiroot

* Fix: s/none//g

* Fix: godoc nice

* Fix: description

* Fix: It

* Fix: code sample trim empty line

* More fixes

* Fix: br

* Merge

* Fix: no-security on updatecheck

* Fix: code tags

* Fix: enumerated values in code tags

* Rephrased

* Address PR comments

* Fix: URL, id

* Fix: array items

* Fix: any property

* Fix: array item singular
2022-12-22 15:53:14 +01:00
Bruno Quaresma c505e8b207 feat: Add create template from the UI (#5427) 2022-12-21 18:07:00 -03:00
Dean Sheather 43b61ce33c chore: support underscores in agent bin filenames (#5496) 2022-12-21 21:06:38 +00:00
Mathias Fredriksson bae69df8f9 build: Fix site/bin tar/zstd build step in rare error cases (#5495) 2022-12-21 22:59:49 +02:00
Colin Adler ac27cf8c07 fix: properly apply metadata when multiple resources share the same id (#5443) 2022-12-21 13:48:49 -05:00
whitney-coder 308a0602b6 Update high-availability.md (#5473)
Capitalization corrections
2022-12-21 09:47:32 -08:00
Presley Pizzo 0eb25306ad fix: stop time incrementer on workspace page (#5406)
* Check template default ttl while setting max

* Lint

* Remove template default from max ttl consideration

* Finish removing template

* Fix disabling buttons

* Simplify, wip

* Handle NaN

* Format

* Add aria labels

* Explain NaN handling

* Use more realistic storybook args
2022-12-21 10:44:18 -05:00
Presley Pizzo 8d9528545a feat: offer to restart workspace when ttl is changed (#5391)
* Update xstate machine

* Fix autoStopChanged

* Add dialog

* Restart workspace

* Clearing location doesn't work and doesn't seem necessary

* Fix test

* Fix second test

* Format

* Lint

* Use i18n

* Switch to fire and forget restart

* Improve error handling

* Format

* Format

* Update site/src/pages/WorkspaceSchedulePage/WorkspaceSchedulePage.test.tsx

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

* Fix name of guard

* Make done state final

* Format

Co-authored-by: Kira Pilot <kira@coder.com>
2022-12-21 10:11:54 -05:00
Marcin Tojek 2bbeff53f9 docs: applications and authorization (#5477)
* docs: Applications

* WIP

* WIP

* WIP

* Fix: consume

* Fix: @Description

* Fix

* Fix: s/none//g

* Fix: godoc nice

* Fix: description

* Fix: It

* Fix: code sample trim empty line

* More fixes

* Fix: br
2022-12-21 15:37:30 +01:00
Mathias Fredriksson 935bb99bed test: Merge env maps to simplify (#5481) 2022-12-20 20:40:41 +00:00
Dean Sheather 2ac31684f4 fix: use UIDs in Dockerfile (#5480) 2022-12-20 12:22:27 -08:00
Mathias Fredriksson c5cfefe3b2 test: Generate golden files for all (visible) CLI commands (#5479) 2022-12-20 22:17:51 +02:00
Mathias Fredriksson c7ce3e70da feat: Add --raw-url to coder server postgres-builtin-* commands (#5478) 2022-12-20 18:51:17 +00:00
Dean Sheather 50dfc2082b feat: endpoint to logout app subdomain URLs (#5428)
Co-authored-by: Bruno Quaresma <bruno@coder.com>
2022-12-20 18:45:13 +00:00
sharkymark 86257ce7fc docs: add contact us form for sales; improve enterprise page (#5459)
Co-authored-by: Geoffrey Huntley <ghuntley@ghuntley.com>
2022-12-20 13:01:28 +00:00
Mathias Fredriksson ca31f1b782 test: Update go-scp to fix data race (#5469) 2022-12-20 09:33:11 +00:00
Mathias Fredriksson a7e8f98e33 feat: Unhide workspace rename command (#5464) 2022-12-19 22:11:10 +02:00
Steven Masley e3cf759968 test: Unit tests creating fake audit logs require create permission (#5455) 2022-12-19 14:02:52 -06:00
Dean Sheather 1bc4eb5329 fix: fix security vulnerabilities reported by CodeQL (#5467) 2022-12-19 19:25:59 +00:00
Dean Sheather e359f3cd23 fix: change TLS client auth default to "none" (#5468) 2022-12-19 19:14:37 +00:00
Marcin Tojek dc6d271293 feat: Build framework for generating API docs (#5383)
* WIP

* Gen

* WIP

* chi swagger

* WIP

* WIP

* WIP

* GetWorkspaces

* GetWorkspaces

* Markdown

* Use widdershins

* WIP

* WIP

* WIP

* Markdown template

* Fix: makefile

* fmt

* Fix: comment

* Enable swagger conditionally

* fix: site

* Default false

* Flag tests

* fix

* fix

* template fixes

* Fix

* Fix

* Fix

* WIP

* Formatted

* Cleanup

* Templates

* BEGIN END SECTION

* subshell exit code

* Fix

* Fix merge

* WIP

* Fix

* Fix fmt

* Fix

* Generic api.md page

* Fix merge

* Link pages

* Fix

* Fix

* Fix: links

* Add icon

* Write manifest file

* Fix fmt

* Fix: enterprise

* Fix: Swagger.Enable

* Fix: rename apidocs to apidoc

* Fix: find -not -prune

* Fix: json not available

* Fix: rename Coderd API to Coder API

* Fix: npm exec

* Fix: api dir

* Fix: by ID

* Fix: string uuid

* Fix: include deleted

* Fix: indirect go.mod

* Fix: source lib.sh

* Fix: shellcheck

* Fix: pushd popd

* Fix: fmt

* Fix: improve workspaces

* Fix: swagger-enable

* Fix

* Fix: mention only HTTP 200

* Fix: IDs

* Fix: https

* Fix: icon

* More APis

* Fix: format swagger.json

* Fix: SwaggerEndpoint

* Fix: SCRIPT_DIR

* Fix: PROJECT_ROOT

* Fix: use code tags in schemas.md

* Fix: examples

* Fix: examples

* Fix: improve format

* Fix: date-time,enums

* Fix: include_deleted

* Fix: array of

* Fix: parameter, response

* Fix: string time or null

* Workspaces: more docs

* Workspaces: more docs

* Fix: renderDisplayName

* Fix: ActiveUserCount

* Fix

* Fix: typo

* Templates: docs

* Notice: incomplete
2022-12-19 18:43:46 +01:00
Kyle Carberry f239ca7ee3 fix: add the "workflow" scope for managing GitHub Actions with gitauth (#5461)
Seen in Discord: https://discord.com/channels/747933592273027093/1054155742871031858/1054155742871031858
2022-12-19 15:17:17 +02:00
Mathias Fredriksson 9983c07e13 build: Improve speed of find commands in Makefile (#5463) 2022-12-19 14:41:36 +02:00
Mathias Fredriksson 5a786edc3d test: Fix new name too long for cli/rename (#5462) 2022-12-19 11:58:22 +00:00
Kyle Carberry e61234f260 feat: Add vscodeipc subcommand for VS Code Extension (#5326)
* Add extio

* feat: Add `vscodeipc` subcommand for VS Code Extension

This enables the VS Code extension to communicate with a Coder client.
The extension will download the slim binary from `/bin/*` for the
respective client architecture and OS, then execute `coder vscodeipc`
for the connecting workspace.

* Add authentication header, improve comments, and add tests for the CLI

* Update cli/vscodeipc_test.go

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

* Update cli/vscodeipc_test.go

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

* Update cli/vscodeipc/vscodeipc_test.go

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

* Fix requested changes

* Fix IPC tests

* Fix shell execution

* Fix nix flake

* Silence usage

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-12-18 17:50:06 -06:00
Kyle Carberry d1f8fec1d3 fix: use static base date for timeline tests (#5460)
It was returning "yesterday" since today is Sunday ;p
2022-12-18 15:27:09 -06:00
Dean Sheather 88d3496a99 fix: fix helm prometheus block causing failures (#5458) 2022-12-19 04:48:08 +10:00
Joe Previte a19c6fc988 fix: update coder dotfiles in dogfood (#5451)
I wasn't calling the environment variable I set.
2022-12-16 12:08:13 -07:00
ElliotG e76f947da2 Added sessionAffinity to values.yaml (#5448) 2022-12-16 09:58:43 -07:00
Dean Sheather 0c0e3f0e4d fix: fix nested dirs in example tars (#5447) 2022-12-17 02:19:19 +10:00
Kyle Carberry fcd5511403 fix: add provisioner tags to template push (#5446)
This was previously only on template create!
2022-12-16 15:13:03 +00:00
Mathias Fredriksson ffb8df9655 test: Disable error on agent log in scaletest/reconnectingpty (#5445)
They way the reconnectingpty tests behave inherently will cause the
agent to occasionally log an error (e.g. due to test disconnecting at a
certain time), allowing these error logs to fail the test will cause
these tests to be flakey.

It's best for these tests to only rely on the observed behavior.
2022-12-16 16:13:31 +02:00
Mathias Fredriksson e2aec2709b test: Fix scaletest/reconnectingpty commands for use in powershell (#5439) 2022-12-16 12:18:14 +02:00
Steven Masley 79c71d2d2c chore: Upgrade to sqlc version 2 yaml configuration (#5442)
* chore: Upgrade to sqlc version 2 yaml configuration
2022-12-15 20:40:11 +00:00
Joe Previte fceac39143 refactor: pin code-server to 4.8.3 (#5440)
* chore(templates): pin code-server to 4.8.3

* docs: use code-server 4.8.3 in install snippets
2022-12-15 13:14:49 -07:00
Dean Sheather 31d38d4246 feat: allow http and https listening simultaneously (#5365) 2022-12-15 20:09:19 +00:00
Dean Sheather 787b8b2a51 fix: fix app hostname returning port number (#5441) 2022-12-16 04:43:00 +10:00
Mathias Fredriksson 44c10bbe3c build: Fix parallelism of make -j build (#5438) 2022-12-15 18:36:37 +02:00
Dean Sheather 6b6eac2518 feat: remove loadtest cmd, add new scaletest cmd (#5310) 2022-12-15 15:04:24 +00:00
Mathias Fredriksson 306fe4a91b ci: Fix release publish script (#5436) 2022-12-15 14:31:57 +00:00
Mathias Fredriksson e96fdbed26 feat: Add release.sh script and detect breaking changes (#5366)
This commit introduces three new scripts:

- `release.sh` To be run by a user on their local machine to preview and
  create a new release (tag + push)
- `check_commit_metadata.sh` For e.g. detecting breaking changes
- `genereate_release_notes.sh` To display the generated release notes,
  used for previews and in `publish_release.sh`

The `release.sh` script can be run without arguments, and it will
automatically determine if we're to do a patch or minor release. A minor
release can be forced via `--minor` flag.

Breaking changes can be annotated either via commit/merge title prefix
(`feat!:`, `feat(api)!:`), or by adding the `release/breaking` label to
the PR that was merged (on GitHub).

Related #5233
2022-12-15 15:41:30 +02:00
Mathias Fredriksson 4bc420dc48 test: Fix data race in loadtest/reconnectingpty (#5431) 2022-12-15 15:06:58 +02:00
Mathias Fredriksson 25ebebac5f ci: Improve gotestsum failure detection, prevent early exit (#5420) 2022-12-15 12:47:42 +02:00
Kyle Carberry d170d27e80 feat: add external property to coder_app (#5425)
* Add schema

* feat: add `external` property to `coder_app`

This allows exposing applications that open an external URL.
2022-12-14 15:54:18 -06:00
Kyle Carberry 8bc247d0c9 fix: use proper validate url for gitauth (#5426)
This was preventing custom validation URLs from being
used to verify git tokens.
2022-12-14 21:02:35 +00:00
Kyle Carberry 84995b7320 fix: preserve workspace resource metadata order (#5421)
Fixes #4511.
2022-12-14 19:08:22 +00:00
Kyle Carberry c0b251ac52 fix: improve error messages when the agent token is invalid (#5423)
I'm not sure why this issue is common, but it seems to be
based on: https://github.com/coder/coder/issues/4551.

This improves the error messages to be unique,
and also fixes a small edge-case bug a user ran into.
2022-12-14 12:24:22 -06:00
Mathias Fredriksson b39ba02bf0 ci: Increase Go mock db test timeout to 5m (#5413)
Our Windows test-runner often takes close to 3m to complete the test,
this was producing a few false failures due to us adding tests over time
and test times increasing.
2022-12-14 19:37:01 +02:00
Steven Masley 27386d49d0 fix: No org admins until organizations are in the UI (#5414)
* fix: No org admins until organizations are in the UI

Until organizations have management UI, we should not set any org
admins. This goes around the site wide perms transparently and
is confusing to users.

Default user is no longer an org admin, so the demotion test makes
no sense
2022-12-14 11:05:42 -06:00
Mathias Fredriksson 012a9e759e fix: Avoid deadlock in AgentReportStats Close during agent Close (#5415)
Since AgentReportStats takes a stats function which was doing mutex
locking on agent shutdown, it was possible for there to be a deadlock
depending on how the AgentReportsStats Close function is implemented.

This mostly seems to happen on Windows test runners as it's pretty hard
to hit this edge case. The bug currently only exists in the test
implementation of AgentReportStats, however, this was refactored to be
more robust in case of future changes.
2022-12-14 18:45:46 +02:00
Kyle Carberry 8e702d89bb fix: improve the warning mismatch to display the release assets on windows (#5418)
* fix: improve the warning mismatch to display the release assets on windows

Fixes #4226.

* Update cli/root.go

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

* Update cli/root.go

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

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-12-14 16:36:28 +00:00
Marcin Tojek b103685170 chore: Collect gotests.xml files (#5398)
* chore: Use datadog-ci to collect gotests.xml

* WIP

* Fix: github ref

* fix

* just store gotests.xml
2022-12-14 16:23:31 +01:00
Arthur Normand ad0dd1be5d fix: Add client certs to OAuth HTTPClient context (#5126) 2022-12-14 16:44:29 +02:00
Mathias Fredriksson 663f7a3f12 ci: Output tail of gotestsum.json if test timed out (#5411)
This is to eternalize the log in case "re-run failed" is used, which
erases artifacts from previous run.
2022-12-14 15:04:39 +02:00
Mathias Fredriksson 2a4ef38a4f fix(site): Use correct UUID for web terminal when first opened (#5404) 2022-12-14 15:03:47 +02:00
Geoffrey Huntley 90b0adabc1 docs(readme): uppercase H in Self-Hosted (#5412) 2022-12-14 13:01:51 +00:00
Geoffrey Huntley ec2293a4e4 docs(readme): update comparison table (#5405) 2022-12-14 10:35:20 +01:00
Mathias Fredriksson 1a018c571b chore: Add PR Lint workflow (#5387)
Fixes #5381
2022-12-14 16:34:08 +10:00
Ricky Grassmuck f7baf45ae3 feat: support partial parameter files (#5392)
Fixes https://github.com/coder/coder/issues/5390
2022-12-13 19:58:57 -06:00
Joe Previte 5a568d8a9b refactor: conditionally use dotfiles in dogfood template (#5332)
* feat: add dotfiles_uri var to dogfood template

* refactor: use dotfiles if dotfiles var exists

This ensures the `coder dotfiles` command only runs if the dotfiles var
in the template is not empty.

* Update dogfood/main.tf

* refactor: assign variable to shell variable

* Update dogfood/main.tf

* fixup!: add default value
2022-12-13 21:15:25 +00:00
sharkymark 8df02f42c0 docs: make it clear the CLI must be downloaded to use templates (#5373) 2022-12-13 19:31:09 +00:00
Mathias Fredriksson 4fc4c01cea fix: Enable reconnectingpty loadtest and fix/improve logging (#5403)
* fix: Enable reconnectingpty loadtest and fix/improve logging

This commit re-enabled reconnectingpty loadtests after a logging
refactor of `(*agent).handleReconnectingPTY`. The reasons the tests were
flaking was that `logger.Error` was being called and `slogtest` failing
the test.

We could have set the option for `slogtest` to disable failing, but that
could hide real issues. The current approach improves reconnectingpty
logging overall and provides more insight into what's happening. It's
expected that reconnectingpty sessions fail after the agent is closed,
so calling `logger.Error` at that point is not wanted.

Ref: #5322
2022-12-13 21:28:07 +02:00
Garrett Delfosse 560c8ce0f6 fix: allow example files to be reused and not error (#5402) 2022-12-13 16:27:37 +00:00
Marcin Tojek 50d1c7191a fix: double quote in fake_cancel.sh (#5399) 2022-12-13 11:03:34 +01:00
Colin Adler 1c42a20865 chore: add debugging to agent stats report (#5395) 2022-12-13 01:03:03 -06:00
Geoffrey Huntley d72d312e1f docs(readme): update comparison table (#5394) 2022-12-13 00:55:23 +00:00
Kira Pilot a071bfa8aa fix: Store dismissedBanner key in localStorage (#5388)
* fix: Store dismissedBanner key in localStorage

* cleanup

* removed comment

* spelling

* fixed eslint

* wote test
2022-12-12 16:17:29 -05:00
Garrett Delfosse 40a5c0476f feat: add flag for token lifetime (#5385) 2022-12-12 15:39:31 -05:00
Mathias Fredriksson 760419a965 chore: Refactor agent tests to avoid t.Run when not needed (#5376)
It turns out that writing tests that contain subtests should probably be
limited to table-based tests and tests that share a common setup shared
between tests.

Writing tests with a subtest like this:

```
func TestSomething(t *testing.T) {
	t.Run("Subtest", func(t *testing.t) {})
}
```

Has the following disadvantages:

- It can lead to multiple tests failing with `(unknown)` status when
  only one of the subtests hang (never exit)
- In Go 1.20rc1, using `t.Setenv` is no longer allowed if the parent
  test is parallel
2022-12-12 22:20:46 +02:00
Geoffrey Huntley 08a6a18226 docs(comparisons): update comparison table (#5371) 2022-12-12 19:14:15 +00:00
Bruno Quaresma e7fc21e285 chore: Add react-syntax-highlight back (#5369) 2022-12-12 15:46:33 -03:00
Kyle Carberry 2b864cee9e fix: Remove @main tag from pkg.go.dev in docs links (#5384)
This seems to have broken, but removing the `main` tag makes
it resolve to the latest version.

See: https://github.com/coder/coder/actions/runs/3675316304/jobs/6215503383
2022-12-12 18:06:58 +00:00
Mathias Fredriksson 88bb901283 fix: Close tailnet if agent is closed during creation (#5375) 2022-12-12 11:26:49 +00:00
Mathias Fredriksson 1907f13c5f fix(site): Use relative date in Timeline test (#5377) 2022-12-12 13:15:28 +02:00
Garrett Delfosse ca0374b94f feat: add examples to api (#5331)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-12-09 14:29:50 -05:00
Bruno Quaresma 6cc864c048 chore: Add icons to templates (#5368) 2022-12-09 18:47:09 +00:00
Kira Pilot c6ae151f49 feat: amending audit string to show workspace owner (#5364)
* resolves #5269

* clean up

* fixed audit link
2022-12-09 12:19:30 -05:00
Joe Previte 66ec98f647 fix: pin code-server to 4.8.3 (#5363)
* fix: pin code-server to 4.8.3

We're having some terminal issues on macOS clients (i.e. iPad) with 4.9.0 so downgrading to 4.8.3 in the meantime.

* Update dogfood/main.tf
2022-12-09 17:07:27 +00:00
Marcin Tojek 971e36781b chore: improve logging in provisionerd_test (#5353) 2022-12-09 13:11:54 +01:00
Marcin Tojek cd04330ca6 fix: replace fireEvent with userEvent (#5361)
* fix: replace fireEvent with userEvent

* fmt
2022-12-09 13:11:36 +01:00
Marcin Tojek 935d2eb582 fix: fmt should check for unstaged files (#5362) 2022-12-09 12:00:39 +01:00
Mathias Fredriksson 05130db571 fix: Improve closing of services in agent tests (#5355) 2022-12-09 12:22:27 +02:00
Bruno Quaresma 92c5e97f85 fix: Fix CSP style directive for Monaco editor (#5360) 2022-12-08 16:53:50 -03:00
Bruno Quaresma 3c9dab34bf fix: Fix CSP for monaco editor (#5358) 2022-12-08 18:32:41 +00:00
Bruno Quaresma ce76d9d5a3 feat: Add diff and Dockerfile support for template version page (#5339) 2022-12-08 10:24:15 -05:00
Ben Potter f68a65697d fix: winget package releases (#5352)
* chore: fix winget package releases

* Update .github/workflows/packages.yaml

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-12-08 09:13:13 -06:00
dependabot[bot] 7eb3ab0498 chore: bump decode-uri-component from 0.2.0 to 0.2.2 in /site (#5251)
Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2.
- [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases)
- [Commits](https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.2)

---
updated-dependencies:
- dependency-name: decode-uri-component
  dependency-type: indirect
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-08 09:52:30 -05:00
Mathias Fredriksson 687261c827 fix: Close coordinator in wsconncache test (#5348)
Possibly related to #5302
2022-12-08 11:44:03 +00:00
Marcin Tojek c063ac24a3 fix: use doWithRetries when making HTTP calls (#5344) 2022-12-08 10:24:50 +01:00
Eric Paulsen 59af8349c6 docs: add offical kubernetes provider runtime_class_name (#5157)
* add: offical kubernetes provider runtime_class_name

* fix: typos

* add: coder data source & vars
2022-12-07 23:30:57 -06:00
Eric Paulsen fd54512858 helm: add certs secret mount (#4641)
* helm: add certs secret mount

* fix: values ref

* fix: conditional brackets

* rm: comment

* refactor: cert secrets list

* fix: undefined var

* chore: remove deprecated value coder.tls.secretName

* chore: improve helm volumes logic

* feat: add support for multiple CA bundles to helm

* fix: grammar

* resolve: conflict

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-12-07 17:27:36 -06:00
Kyle Carberry 3d95c9256d chore: Add DatoCMS token to dogfood template (#5254)
* chore: Add DatoCMS token to dogfood template

This is used for developing coder.com!
2022-12-07 15:59:32 -06:00
dependabot[bot] 1ac1af7db8 chore: bump emoji-mart from 5.2.1 to 5.3.3 in /site (#5226)
Bumps [emoji-mart](https://github.com/missive/emoji-mart/tree/HEAD/packages/emoji-mart) from 5.2.1 to 5.3.3.
- [Release notes](https://github.com/missive/emoji-mart/releases)
- [Commits](https://github.com/missive/emoji-mart/commits/v5.3.3/packages/emoji-mart)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-08 02:55:38 +10:00
Marcin Tojek 534bff2ff5 fix: coderd/prometheusmetrics wait for all metrics in require.Eventually (#5338) 2022-12-07 17:50:17 +01:00
Presley Pizzo 8ea09235f9 fix: UX issues in template settings form's default auto-stop field (#5330)
* Fix helper text

- handles 0 ttl
- uses helper text typography
- pluralizes
- still doesn't override error (once considered touched)

* Show user friendly field name in error text

* Format

* Override label through Yup instead

* Switch to i18n - wip

* Fix i18n by thunking schema

* Fix template settings tests

* Replace third arg to getFieldHelpers -is used after all
2022-12-07 11:32:39 -05:00
Ammar Bandukwala ee605b34b6 fix: Don't show progress bar for new templates (#5298) 2022-12-07 16:22:20 +00:00
Mathias Fredriksson f7467cac50 fix: Improve ptytest closure on expect match timeout (#5337)
To ensure ptytest closure always happens the same way, we now define a
new `Close` function on `PTY` and always call the close function instead
of manually closing read/writers.

A few additional log messages have been added as well, to better
understand the shutdown process in case of errors.
2022-12-07 15:20:06 +00:00
Marcin Tojek a973c35a02 chore: collect gotestsum TestEvents as workflow artifacts (#5336) 2022-12-07 15:04:39 +01:00
Marcin Tojek 3cea5f96f0 fix: wait for creating template versions (#5335) 2022-12-07 14:19:18 +01:00
Marcin Tojek 2f3ff6ced8 fix: improve pty and ptytest (#5327)
* Fix: improve ptytest

* Disable skip

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* Fix

* WIP

* Fix

* fix: pty close on Windows

* Revert changes around workflow

* fix
2022-12-07 14:18:09 +01:00
Dean Sheather 161465db55 fix: do not canonicalize Sec-WebSocket-* headers in apps (#5334)
* fix: do not canonicalize Sec-WebSocket-* headers in apps

* chore: test for non-canonical header name subst
2022-12-07 22:55:02 +10:00
Kira Pilot 85945af55e fixed bug; wrote tests (#5329) 2022-12-06 16:58:32 -05:00
Ammar Bandukwala 1cfe5de1c5 Add Service Banners (#5272) 2022-12-06 18:38:38 +00:00
Kira Pilot df389d429c Add build number to workspace_build audit logs (#5267)
* got links working

* added translations

* fixed translation

* added translation for unavailable ip

* added support for group, template, user links

* cleaned up string

* added deleted label

* querying for workspace id

* remove prints

* fix/write tests

* added build number

* checking for existence of additional fields

* adjust documentation

* PR feedback
2022-12-06 13:33:21 -05:00
Dean Sheather 6651c1632d fix: avoid terraform state concurrent access, remove global mutex (#5273) 2022-12-06 17:05:14 +00:00
Marcin Tojek 85a6d14fbb skip: reconnectingpty tests (#5322) 2022-12-06 16:36:54 +01:00
Kyle Carberry c77c1b4bc2 fix: Retry if there is no git auth user yet (#5316)
Fixes part of #4900.
2022-12-06 16:06:41 +01:00
Marcin Tojek b2dc60c030 fix: markdown-link-check base-branch should not be set on main branch (#5311) 2022-12-06 15:41:06 +01:00
Bruno Quaresma e17fd0bb25 feat: Add GET previous template version endpoint (#5230) 2022-12-06 14:15:03 +00:00
Marcin Tojek 84872d970d fix: loadtest/reconnectingpty tweak timeout (#5300)
* flaky

* fix: load test increase timeout

* Remove flaky

* Improvement

* only Linux

* WaitSuperLong

* Fix

* Try longer

* Try: sleep 120
2022-12-06 14:40:38 +01:00
dependabot[bot] 03328d4f6d chore: bump eslint from 8.24.0 to 8.29.0 in /site (#5306)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-06 12:14:31 +00:00
dependabot[bot] 4a0ca4818f chore: bump @typescript-eslint/parser from 5.38.1 to 5.45.1 in /site (#5305)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-06 12:01:01 +00:00
dependabot[bot] 825480ae9b chore: bump crate-ci/typos from 1.12.12 to 1.13.3 (#5304)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Geoffrey Huntley <ghuntley@ghuntley.com>
2022-12-06 11:50:33 +00:00
Marcin Tojek 133b2de1ca chore: improve markdown-link-check workflow (#5303) 2022-12-06 21:46:17 +10:00
Joe Previte 9e4d213c2d feat: add lazygit, remove kubic, use dotfiles in dogfood image (#5271) 2022-12-06 20:11:44 +10:00
Presley Pizzo ee74df3d07 Fix scope of dbTTL (#5197) 2022-12-05 17:19:30 -05:00
Marcin Tojek d3200382f6 fix: agent panics on closed network (#5295)
* fix: agent panics on closed network

* Remove a.network = network

* Fix

* Fix

* Fix
2022-12-05 23:18:23 +01:00
Daniel Carrion 061635c36d feat: Allow multiple OIDC domains (#5210)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-12-05 20:20:53 +02:00
Bruno Quaresma 02bb052d09 Fix template Avatar (#5294) 2022-12-05 10:50:50 -07:00
Bruno Quaresma 02dcd0e20d fix: Fix resource avatar when icon is empty string (#5291) 2022-12-05 14:37:14 -03:00
Marcin Tojek e04877a638 fix: race conditions in replicasync (#5289) 2022-12-05 17:18:15 +01:00
Bruno Quaresma 9cfdbec2ef refactor: Remove login banner (#5239) 2022-12-05 11:24:53 -03:00
Marcin Tojek cec667d309 fix: prettier misses docs directory (#5285)
* chore: keep admin/prometheus.md if make target fails

* Address PR comments

* Formatted

* fix: prettier misses docs

* make fmt

* More md files
2022-12-05 12:21:09 +01:00
Muhammad Atif Ali b46035823e docs: add templates link to README.md (#5201) 2022-12-05 16:20:01 +10:00
Muhammad Atif Ali a3083f77c7 docs: fix community templates link on site. (#5278)
Fixes #5259
2022-12-05 04:59:53 +00:00
Colin Adler a02617b66b fix: remove unnecessary WHEREs from AcquireProvisionerJob (#5257) 2022-12-02 23:53:49 +00:00
Marcin Tojek 137a48c215 fix: workspaceapps: overloaded test server responds with 502s (#5255) 2022-12-02 23:16:07 +01:00
Ammar Bandukwala 91973e1e88 cli: remove redundant client creation requests (#5264) 2022-12-02 15:40:23 -06:00
Kira Pilot 65407462d1 Add audit links/kira pilot (#5156)
* got links working

* added translations

* fixed translation

* added translation for unavailable ip

* added support for group, template, user links

* cleaned up string

* added deleted label

* querying for workspace id

* remove prints

* fix/write tests

* PR feedback pt 1

* PR feedback part 2
2022-12-02 15:14:45 -05:00
Mathias Fredriksson fa641554e8 fix: Improve agent connection tracking when agent is closed (#5253) 2022-12-02 16:24:40 +02:00
Mathias Fredriksson 81c3948792 fix: Close tty first in ptytest cleanup (#5252) 2022-12-02 12:32:50 +00:00
Marcin Tojek ee4f0fc592 chore: enable debug logging for gotestsum (#5248) 2022-12-02 12:35:14 +01:00
Colin Adler 8469dbc045 fix: add index to provisioner_jobs.started_at (#5245) 2022-12-01 19:29:15 -06:00
Colin Adler 92c217bd85 fix: add index on workspace_agents.auth_token (#5244) 2022-12-02 01:29:05 +00:00
Dean Sheather 9e80322fe5 fix: do not truncate system PATH in win installer (#5243)
The path.nsh script in the NSIS installer provided methods for adding
paths to the PATH and removing them. It would do this by reading the
current PATH value from the registry, adding the new value (if it
doesn't exist) and then writing it to the registry.

Unfortunately, it would read from the user's PATH and write the updated
result to the system PATH, which would remove important PATH entries
like the following in the process:

- C:\Windows\System32
- C:\Windows
- C:\Windows\System32\wbem
- C:\Windows\System32\WindowsPowerShell\v1.0
- C:\Windows\System32\OpenSSH
- C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
- C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common

and would copy all user environment variables in their place. The
variables listed above were the ones missing from my machine when I
compared with a friend's machine.

Recommended course of action for affected users:
1. Add the paths listed above to your system PATH if they aren't there
   already and exist on your system.
2. Remove any paths that are in your user's PATH from your system PATH.

The existing installers for the last couple of versions of Coder have
been yanked from GitHub releases and this message will be included in
the release notes for the next patch.

Thanks to @cmor for finding and reporting this bug in #5240.
2022-12-02 09:56:49 +10:00
Colin Adler ab3b3d5fca feat: add debouncing to provisionerd rpc calls (#5198) 2022-12-01 16:54:53 -06:00
Tao Yang 5457dd0c65 feat: Let port-forwarding support custom http(s) port (#5084) 2022-12-02 06:39:19 +10:00
Mathias Fredriksson 2ec3b09ca7 fix: Fix nil-pointer deref on checkAuthorization (#5236)
Remove call to `err.Error()` on a `nil` error in `checkAuthorization`.
2022-12-01 18:42:10 +00:00
dependabot[bot] f77a445bfe chore: bump cron-parser from 4.6.0 to 4.7.0 in /site (#5221)
Bumps [cron-parser](https://github.com/harrisiirak/cron-parser) from 4.6.0 to 4.7.0.
- [Release notes](https://github.com/harrisiirak/cron-parser/releases)
- [Commits](https://github.com/harrisiirak/cron-parser/compare/4.6.0...4.7.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 18:34:56 +00:00
dependabot[bot] 9724dbd36d chore: bump github.com/gohugoio/hugo from 0.105.0 to 0.107.0 (#5222)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 18:11:58 +00:00
dependabot[bot] 9675ea90e2 chore: bump google.golang.org/api from 0.100.0 to 0.103.0 (#5219)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 18:08:12 +00:00
dependabot[bot] 6c68126486 chore: bump github.com/spf13/viper from 1.13.0 to 1.14.0 (#5220)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 17:56:45 +00:00
Ammar Bandukwala 9a0a6b7002 .github: remove "never stale" 2022-12-01 11:47:01 -06:00
dependabot[bot] 7f94235419 chore: bump google.golang.org/grpc from 1.50.1 to 1.51.0 (#5223)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 11:43:36 -06:00
Mathias Fredriksson d9f2aaf3b4 feat: Add support for update checks and notifications (#4810)
Co-authored-by: Kira Pilot <kira@coder.com>
2022-12-01 19:43:28 +02:00
dependabot[bot] 4f1cf6c9d8 chore: bump golang.org/x/crypto from 0.1.0 to 0.3.0 (#5224)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 11:42:54 -06:00
dependabot[bot] 82d4aaea0b chore: bump tj-actions/branch-names from 6.2 to 6.3 (#5217)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 17:40:54 +00:00
dependabot[bot] 785d8750ce chore: bump hmarr/auto-approve-action from 2 to 3 (#5216)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 17:39:23 +00:00
dependabot[bot] e3103f3a5e chore: bump google-github-actions/auth from 0 to 1 (#5218)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 11:37:33 -06:00
dependabot[bot] 9a1ffe4121 chore: bump golangci/golangci-lint-action from 3.3.0 to 3.3.1 (#5214)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-01 17:11:03 +00:00
ElliotG 07560eefc0 Refactored Quota Docs (#5195) 2022-12-01 09:37:50 -07:00
Marcin Tojek 916ed284ce feat: Define Prometheus port in the pod spec (#5213)
* WIP

* portSpec

* Done

* Docs

* Fix: env
2022-12-01 15:43:32 +00:00
Mathias Fredriksson 9557d456e8 fix: Generate trial in scripts/develop.sh (#5231) 2022-12-01 17:12:16 +02:00
Marcin Tojek 883cf8afa9 chore: Add missing metrics description (#5212)
* chore: Add missing metrics description

* Update provisionerd/provisionerd.go

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

* Fix

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-12-01 12:50:57 +01:00
Muhammad Atif Ali 8cd8b6d858 docs: add community templates link to docs. (#5200) 2022-12-01 11:59:59 +10:00
Kyle Carberry af2c47b1a3 fix: Update install script text to separate run and use (#5203) 2022-11-30 13:38:25 -08:00
Marcin Tojek 38bdae7016 docs: Prometheus metrics + generator (#5179)
* docs: Prometheus metrics

* Fix

* Typo

* Typo

* Typo

* Fix: link

* Update docs/admin/prometheus.md

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

* Update docs/admin/prometheus.md

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

* Update docs/admin/prometheus.md

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

* Update docs/admin/prometheus.md

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

* Update docs/admin/prometheus.md

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

* Rephrase

* notice

* use ```shell

* Generator

* gosec

* fix: lint

* PR comments

* not needed anymore

Co-authored-by: Dean Sheather <dean@deansheather.com>
Co-authored-by: Geoffrey Huntley <ghuntley@ghuntley.com>
2022-11-30 17:39:51 +01:00
Bruno Quaresma be79ae7d48 refactor: Add coder tip pill on sign in page (#5196) 2022-11-30 13:38:12 -03:00
Kyle Carberry 2a73362026 fix: add mutex to MockAuditor export to prevent race (#5189)
See: https://github.com/coder/coder/actions/runs/3575201153/jobs/6011435900.
2022-11-30 16:25:30 +00:00
Bruno Quaresma 41f10e7b69 refactor: Show template version in the workspace page (#5194) 2022-11-30 09:13:07 -05:00
Marcin Tojek 5817d2a301 skip: loadtest/reconnectingpty Test_Runner/Timeout (#5199) 2022-11-30 11:04:01 +01:00
Presley Pizzo 2e3db274f1 fix: send auto start/stop api calls only when changed (#5184)
* Send auto start/stop api calls only when changed

* Format

* Extract and test util function
2022-11-29 15:12:36 -05:00
Kyle Carberry 8b73844f69 feat: Validate Git tokens before consuming them (#5167)
* feat: Validate Git tokens before consuming them

This works the exact same way that the Git credential manager does. It ensures the user token is valid before returning it to the client.

It's been manually tested on GitHub, GitLab, and BitBucket.

* Fix requested changes
2022-11-29 12:08:27 -06:00
Marcin Tojek a8f5af1245 skip: loadtest/reconnectingpty Test_Runner/ExpectOutput (#5188) 2022-11-29 15:05:04 +00:00
Mathias Fredriksson 085f1917db fix: Fix develop script pid tracking, improve logging and interrupt (#5186) 2022-11-29 15:45:14 +02:00
Dean Sheather 15f8967a8a feat: tracing improvements (#4988) 2022-11-29 07:22:10 +10:00
Bruno Quaresma d402914eb7 refactor: Return template version name in the workspace build API (#5178) 2022-11-28 19:53:56 +00:00
Steven Masley ab9298f382 chore: Rewrite rbac rego -> SQL clause (#5138)
* chore: Rewrite rbac rego -> SQL clause

Previous code was challenging to read with edge cases
- bug: OrgAdmin could not make new groups
- Also refactor some function names
2022-11-28 12:12:34 -06:00
Presley Pizzo d5ab4fdeb8 fix: auto-stop bumper works and refreshes (#5162)
* Publish updates to workspace deadline

* Fix sync between machines
2022-11-28 10:59:43 -05:00
Muhammad Atif Ali 898ba11ef0 fix: packages.yaml action is not running on release trigger (#5173)
This commit is a workaround to run the `packages.yaml` action after the release action
Fixes #5137.
Check #5137 for context.
2022-11-27 07:06:34 -06:00
Muhammad Atif Ali 25c80566e7 docs: Add GitHub action to push template changes automatically (#5166)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-11-26 13:36:14 +00:00
Muhammad Atif Ali 5f31ea3ffb docs: add docs on how to allow public github signups (#5168) 2022-11-25 20:03:07 +02:00
Cian Johnston a4a319a76e feat: add CODER_OIDC_IGNORE_EMAIL_VERIFIED config knob (#5165)
* Adds a configuration knob CODER_OIDC_IGNORE_EMAIL_VERIFIED that allows
  ignoring the email_verified OIDC claim
* Adds warning message at startup if CODER_OIDC_IGNORE_EMAIL_VERIFIED=true
* Adds warning whenever an unverified OIDC email is let through
* Skips flaky test on non-linux platforms

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-11-25 10:10:09 +00:00
Mathias Fredriksson 6ed12ade54 fix: Improve debuggability of ptytest cleanup (#5170)
There are sporadic flakes in some tests on Windows related to the use of
`ptytest`. Since it's not clear why they fail, this commit adds some
more logging and timeouts to the cleanup methods.
2022-11-24 15:20:17 +00:00
Marcin Tojek 25da224513 Filter query: has-agent connecting, connected, disconnected, timeout (#5145)
* WIP

* has-agent:connecting, connected

* Fix

* Fix

* has-agent:disconnected, timeout

* Fix: typo

* Fix

* TODOs

* databasefake

* Fix: typo

* More TODOs

* databasefake

* Timeout tests

* Address PR comments

* Implement FIXMEs

* Renamings

* Address PR comments

* Fix: readability

* Fix: refactor CASE logic

* CASE logic

* Fix

* Use CTE

* Polishing

* Comment

* WIP

* IS NOT NULL

* Without CTE

* One more optimization

* 2nd optimization
2022-11-24 15:33:13 +01:00
Bruno Quaresma 511bb469c4 feat: Change workspace version using the UI (#5158) 2022-11-24 13:36:50 +00:00
Mathias Fredriksson eff99f78fa feat: Add support for MOTD file in coder agents (#5147) 2022-11-24 12:22:20 +00:00
Mathias Fredriksson 8ff89c4288 fix: Fix flakeyness of TestProvisionerd/ReconnectAndComplete (#5169) 2022-11-24 14:09:56 +02:00
Presley Pizzo 913e461f79 Don't override 0 ttl with template default (#5151) 2022-11-23 10:30:38 -05:00
Bruno Quaresma 59355431d0 refactor: Refactor login page (#5148) 2022-11-23 14:53:42 +00:00
Presley Pizzo 71bc48dda4 feat: tweak timeline design (#5144)
* Tweak timeline design

* Extract timeline style into component
2022-11-22 17:30:43 -05:00
Kira Pilot 6786ca2854 Audit build outcomes/kira pilot (#5143)
* auditing failed builds

* logging workspace build successes

* remove duplicate workspace build entry

* fixed workspacebuilds_test

* PR feedback

* lint and migrations

* fix nil auditors

* workspace_build test

* fixed workspaces_teest

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-11-22 13:22:56 -05:00
Colin Adler 1f20cab110 fix: don't use yamux for in-memory provisioner{,d} streams (#5136) 2022-11-22 12:19:32 -06:00
Mathias Fredriksson 2b6c229e4e fix: Trigger workspace event after agent timeout seconds (#5141)
Fixes #5116
2022-11-22 11:01:28 +00:00
Marcin Tojek e94b27bce4 fix: Adjust description for cancel in-progress workspace jobs (#5142)
* fix: Adjust description for cancel in-progress workspace jobs

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

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>
2022-11-21 17:00:18 +00:00
Presley Pizzo 67941b4f80 chore: refactor audit page to use window function for count (#5133)
* Move count query to window function

* Unpack count and update types

* Remove count endpoint

* Update tests, wip

* Fix tests

* Update frontend, wip

* Remove space

* Fix frontend test

* Don't hang on error

* Handle no results

* Don't omit count

* Fix frontend tests
2022-11-21 11:30:41 -05:00
Bruno Quaresma 7a369e0a30 refactor: Minor build bar UI improvement (#5132) 2022-11-21 10:04:24 -05:00
Marcin Tojek e86539db11 feat: Allow user to cancel workspace jobs (#5115)
* Add database column allow_user_cancel_workspace_jobs

* Adjust API

* site: typesGenerated.ts

* Expose template.allow_ in Workspaces API

* Fix: site tests

* Fix: make fmt/prettier

* Fix: enterprise

* Database tests

* Add CLI tests

* Add checkbox

* i18n

* Logic: block cancelling

* Unit tests for conditional cancel

* Fix: message

* Address PR comment

* Address PR comments

* Fix: make
2022-11-21 11:43:53 +01:00
Bruno Quaresma 5fa3fdeca0 refactor: Improve empty views (#5134) 2022-11-19 01:46:11 +00:00
Bruno Quaresma a477d901d6 refactor: Fix up to date color (#5131) 2022-11-19 01:18:40 +00:00
Colin Adler ae38bbeab6 chore: refactor agent stats streaming (#5112) 2022-11-18 16:46:53 -06:00
Bruno Quaresma 13a4cfa670 chore: Remove unused test files and code (#5130) 2022-11-18 18:03:15 +00:00
Presley Pizzo 4c24adb471 Fix filter bug (#5124) 2022-11-18 09:53:16 -05:00
Bruno Quaresma 5866ca48a9 refactor: Reemove mono font from empty title (#5125) 2022-11-18 10:09:13 -03:00
Ben Potter edad2d01da chore: fix typo in cvm docs (#5120) 2022-11-18 06:01:01 +00:00
Dean Sheather 69e8c9e7b4 feat: add reconnectingpty loadtest (#5083) 2022-11-17 16:57:15 +00:00
Ammar Bandukwala acf34d4295 site: support high build time variation in progress bar (#4941) 2022-11-17 16:56:56 +00:00
Kyle Carberry 60cec022eb fix: Parse boolean in slice for gitauth (#5113)
This was causing a panic for the new `no_refesh` option!
2022-11-17 07:52:11 -06:00
Ben Potter 8e468c49cb chore: default to generic troubleshooting link (#5007) 2022-11-17 11:10:49 +00:00
Kyle Carberry fb9ca7b830 feat: Add the option to generate a trial license during setup (#5110)
This allows users to generate a 30 day free license during setup to
test out Enterprise features.
2022-11-16 17:09:49 -06:00
Kyle Carberry b6703b11c6 feat: Add external provisioner daemons (#4935)
* Start to port over provisioner daemons PR

* Move to Enterprise

* Begin adding tests for external registration

* Move provisioner daemons query to enterprise

* Move around provisioner daemons schema

* Add tags to provisioner daemons

* make gen

* Add user local provisioner daemons

* Add provisioner daemons

* Add feature for external daemons

* Add command to start a provisioner daemon

* Add provisioner tags to template push and create

* Rename migration files

* Fix tests

* Fix entitlements test

* PR comments

* Update migration

* Fix FE types
2022-11-16 16:34:06 -06:00
Colin Adler 66d20cabac fix: index GetWorkspaceAgentsByResourceIDs query (#5021) 2022-11-16 14:40:57 -06:00
Colin Adler e7f1192614 fix: add index for GetProvisionerLogsByIDBetween (#5020) 2022-11-16 14:32:29 -06:00
Ammar Bandukwala da758ba712 site: fix quota_allowance == 0 bug (#5108) 2022-11-16 18:20:07 +00:00
Steven Masley 894953db3d fix: Workspace ls show only me by default (#5107) 2022-11-16 17:58:50 +00:00
Steven Masley 015a6f9e26 fix: RBAC should default deny missing variables. (#5105)
* fix: RBAC should default deny missing variables.

The default behavior was to use 'true' for missing variables. This
was an incorrect assumption. If the variable is missing, the new
default is to deny (fail secure).

* Assert 1 workspace is returned for the owners
2022-11-16 11:01:09 -06:00
Bruno Quaresma 1fcc7caf99 fix: Fix tab default (#5104) 2022-11-16 16:43:35 +00:00
Presley Pizzo e6ead7d915 chore: refactor workspaces query to use window function (#5079)
* Use window function in query

* Convert workspace rows and unpack count

* Update types

* Fix Scan bug

* Remove getCountError
2022-11-16 10:16:37 -05:00
Presley Pizzo 560d3c9fd0 fix: remove pagination widget when filter is invalid (#5095)
* Clear count along with user, remove count error

* Format
2022-11-16 09:55:41 -05:00
Marcin Tojek 32927b1a24 feat: show template.display_name on Workspace pages (#5082)
* feat: expose template.display_name via Workspaces endpoint

* Fix: MockWorkspace

* UI: Workspace stats and row

* Show template.display_name on pages

* Fix: address PR comments

* Add helper function: getDisplayWorkspaceTemplateName
2022-11-16 15:50:32 +01:00
Mathias Fredriksson c1ecc91aab feat: Add fallback troubleshooting URL for coder agents (#5005) 2022-11-16 12:53:02 +02:00
Geoffrey Huntley 1f4f0cee2a chore(branding): update branding (#5028) 2022-11-16 07:15:33 -03:00
Ben Potter 09ee844389 fix: git docs link (#5099) 2022-11-15 21:19:52 +00:00
Kyle Carberry fc0a493b72 feat: Add no_refresh option to Git auth configs (#5097)
This allows organizations to disable refreshing Git tokens
and instead prompt for authentication again.
2022-11-15 21:06:13 +00:00
Bruno Quaresma 2a46702fc5 fix: Syntax highlighting with long lines and untar content with emojis (#5098) 2022-11-15 20:09:54 +00:00
Ammar Bandukwala 44d3225932 .github: remove issue templates
Developers prefer no template based on Slack poll.
2022-11-15 20:02:50 +00:00
Mathias Fredriksson d9a83fc723 fix: Refactor tailnet conn AwaitReachable to allow for pings >1s RTT (#5096) 2022-11-15 20:59:22 +02:00
Marcin Tojek eda7c66896 chore: TemplatesPage tests failing on M1 (#5088) 2022-11-15 19:45:01 +01:00
Bruno Quaresma e68923fa36 fix: Worker security policy (#5093) 2022-11-15 17:02:24 +00:00
Mathias Fredriksson 9fb710a04f feat: Add allow everyone option to GitHub OAuth2 logins (#5086)
* feat: Add allow everyone option for GitHub OAuth

* fix: Detect team when multiple orgs are present

Co-authored-by: 李董睿煊 <dongruixuan@hotmail.com>
2022-11-15 18:56:46 +02:00
Bruno Quaresma f262fb4811 feat: Add template version page (#5071) 2022-11-15 16:24:13 +00:00
Kyle Carberry 773fc73280 fix: Add debug logging for connecting to psql (#5078)
If a database connection hung, the output was unclear.
2022-11-14 20:10:37 -06:00
Kyle Carberry 50b5becfb0 fix: Invert err nil check for opening Git URL (#5077)
Thanks @kconley-sq! 🥳
2022-11-14 20:10:23 -06:00
Geoffrey Huntley b5181aacd7 feat(i18n): adjust language when deleting a template (#5056) 2022-11-15 10:12:53 +10:00
Garrett Delfosse 88f3691dcc feat: add count to get users endpoint (#5016) 2022-11-14 17:22:57 -05:00
Marcin Tojek 49b340e039 Show template.display_name in the site UI (#5069)
* Show display_name field in the template settings

* Show template.display_name on pages: Templates, CreateWorkspace

* Fix: template.display_name pattern

* make fmt/prettier

* Fix tests

* Fix: make fmt/prettier

* Fix: merge

* Fix: autoFocus

* i18n: display_name
2022-11-14 21:11:50 +01:00
Mathias Fredriksson e872e18883 chore: Set initialism for DefaultTTL (from DefaultTtl) (#4996) 2022-11-14 20:14:08 +02:00
Ammar Bandukwala 97dbd4dc5d Implement Quotas v3 (#5012)
* provisioner/terraform: add cost to resource_metadata

* provisionerd/runner: use Options struct

* Complete provisionerd implementation

* Add quota_allowance to groups

* Combine Quota and RBAC licenses

* Add Opts to InTx
2022-11-14 17:57:33 +00:00
Kira Pilot 3fb7892c07 fix: template permissions page never loads (#5014)
* removed redundant permissions loader

* fixed tests
2022-11-14 12:33:17 -05:00
Kyle Carberry fefacc5bfd chore: Expose additional agent options to telemetry (#5070)
This also adds a few properties for deployments!
2022-11-14 10:11:08 -06:00
Geoffrey Huntley 9692cc2e22 housekeeping: structure GitHub issues via templates (#5025) 2022-11-14 09:32:54 -06:00
Marcin Tojek cf5d48bb5a fix: do not skip properties on creating templates (#5060)
* fix: do not skip properties while creating templates

* test: empty edit
2022-11-14 15:32:18 +01:00
Mathias Fredriksson 4b3d211e00 fix: Use UTC in cli/cliui table test to match expected output (#5063) 2022-11-14 15:08:51 +02:00
Muhammad Atif Ali 990be63c60 feat: create winget package workflow (#4761)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-11-14 12:59:08 +00:00
Marcin Tojek 1b6d0c39e1 docs: Rephrase Templates section (#5062)
* docs: Rephrase Templates section

* Update docs/templates.md

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

* Update docs/templates.md

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

* Update docs/templates.md

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

* Update docs/templates.md

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

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-11-14 12:06:16 +00:00
Mathias Fredriksson e72927f3ab fix: Avoid running shell twice in coder agent (#5061)
The users login shell would be executed as:

	/bin/bash -c '/bin/bash -l'

This simplifies the command for login shells so that the executed
command is:

	/bin/bash -l
2022-11-14 14:01:22 +02:00
Mathias Fredriksson c515085450 fix: Unify context usage for agent cmd and logs (#5059) 2022-11-14 13:48:44 +02:00
Geoffrey Huntley cbb1e91372 feat(windows): default to PowerShell v7 over v6 and fallback to cmd.exe (#5053) 2022-11-14 15:43:40 +10:00
Mathias Fredriksson f017548a9c fix: Return correct exit code for SFTP sessions (#5044)
Fixes #5038
2022-11-13 23:22:50 +02:00
Kyle Carberry 2a6fff9227 fix: Set a default CODER_ACCESS_URL in Helm (#5041)
* fix: Set a default `CODER_ACCESS_URL` in Helm

This allows for a simple `helm apply` to create a full Coder
deployment that works for creating workspaces.

* Update docs
2022-11-13 14:49:57 -06:00
Ammar Bandukwala 73f91e4690 ci: use big runners (#4990)
* chore: Close idle connections on test cleanup

It's possible that this was the source of a leak on Windows...

* ci: use big runners

* fix: Improve tailnet connections by reducing timeouts

This awaits connection ping before running a dial. Before,
we were hitting the TCP retransmission and handshake timeouts,
which could intermittently add 1 or 5 seconds to a connection
being initialized.

* Add logging to Startupscript test

* Add better logging

* Write startup script logs to fs dir

* Fix startup script test

* Fix startup script test

* Reduce test timeout

* Use central tmp dir in agent

* Adjust output

* Skip startup script test on Windows

Co-authored-by: Kyle Carberry <kyle@carberry.com>
2022-11-13 14:23:23 -06:00
Arthur Normand 9578ce9f77 OAuth now uses client TLS certs (if configured) (#5042)
* OAuth now uses client TLS certs (if configured)

* Update docs

* Cleaning

* Fix lint errors and generate static files

* Fix lint error and regenerate more static files

* Suppress lint error
2022-11-13 14:15:06 -06:00
Kyle Carberry 49c7648af5 chore: Close idle connections on test cleanup (#4993)
It's possible that this was the source of a leak on Windows...
2022-11-13 14:06:03 -06:00
zhaozhiming 30e9ecbc96 docs: fix offline install docs some errors (#5039)
* docs: fix offline install docs some error

* retrigger checks
2022-11-13 14:05:19 -06:00
Kyle Carberry 82f494c99c fix: Improve tailnet connections by reducing timeouts (#5043)
* fix: Improve tailnet connections by reducing timeouts

This awaits connection ping before running a dial. Before,
we were hitting the TCP retransmission and handshake timeouts,
which could intermittently add 1 or 5 seconds to a connection
being initialized.

* Update Tailscale
2022-11-13 11:33:05 -06:00
Geoffrey Huntley 4646f58072 housekeeping(terraform): bump TerraformVersion (#4867) 2022-11-12 09:35:12 +10:00
Ammar Bandukwala 95fb59696e Refactor Provisioner to distinguish Plan and Apply (#5036) 2022-11-11 16:45:58 -06:00
Mathias Fredriksson 71601f4971 fix: Fix log wrapper for vite in scripts/develop.sh (#5030)
The pid tracking refactor resulted in the pipe while echo to block the
script from continuing and showing the banner at the end. This change
redirects the stdout for the `start_cmd` to a new fd which `while` is
reading from.
2022-11-11 12:39:33 +00:00
Eric Paulsen 823b02ac9c docs: deprecate name arg (#5026) 2022-11-11 06:16:14 +00:00
Kyle Carberry 4b7c710755 fix: Block creating workspaces with deleted templates (#5019)
@coadler and @deansheather bricked a Coder deployment with this...
2022-11-10 16:53:14 -06:00
Kyle Carberry 927c241995 fix: Debounce AcquireJob when no jobs are available (#5017)
This prevents constant database spam at scale to a maximum
of 60 queries/s per coderd instance.
2022-11-10 22:37:33 +00:00
Geoffrey Huntley f32748c929 housekeeping(stalebot): never close never stales (#4891) 2022-11-10 16:28:20 -06:00
Dean Sheather 8e5af82275 feat: add api-rate-limit flag (#5013) 2022-11-10 21:53:48 +00:00
Marcin Tojek 2042b575dc feat: Add template display name (backend) (#4966)
* Rename to nameValidator

* Refactor: NameValid

* Fix: comment

* Define new migration

* Include display_name

* Update typesGenerated.ts

* Update meta

* Adjust tests

* CLI tests

* Fix: audit

* Fix: omitempty

* site: display_name is optional

* unit: TestUsernameValid

* entities.ts: add display_name

* site: TemplateSettingsPage.test.tsx

* Fix: TemplateSettingsForm.tsx

* Adjust tests

* Add comment to display_name column

* Fix: rename

* Fix: make

* Loosen regexp

* Fix: err check

* Fix: template name length

* Allow for whitespaces

* Update migration number
2022-11-10 21:51:09 +01:00
Colin Adler f3eb662208 fix: add index for workspace_resource.job_id column (#5009) 2022-11-10 20:09:44 +00:00
Mathias Fredriksson 5e2253030f fix: Revert develop.sh timeout -> curl change (#5008)
It seems `--retry-all-errors` is not available on e.g. curl 7.68.0.
2022-11-10 19:49:11 +00:00
Colin Adler 8c8344ca13 fix: tolerate non-json lines in provisionerd logs (#5006)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-11-10 13:26:57 -06:00
Mathias Fredriksson a25deb939b fix: Misc improvements to scripts/develop.sh (#4995)
* Use new `/healthz` endpoint for checking API liveness
* Improved credential handling/retrying in failure scenarios
* Separate site (`vite`) logs with prefix and date, additionally this
  method also disables the `vite` clearing of the screen
* Show all interfaces coder API is listening on (due to `0.0.0.0`)
* Improved shutdown procedure / interrupt handling
2022-11-10 20:47:42 +02:00
Garrett Delfosse 766a2ad590 chore: refactor workspace count to single route (#4809)
Co-authored-by: Presley Pizzo <presley@coder.com>
2022-11-10 13:25:46 -05:00
Mathias Fredriksson 5fb9c33ecd fix: Fix ssh message/spinner in VSCode integrated terminal (#5000)
* fix: Fix ssh message/spinner in VSCode integrated terminal

The messages never show up in VSCode integrated terminal due to the
defer `fmt.Fprintf`. There could be a race in VSCode in handling the
terminal codes but ultimately, we can simplify our logic by just
stopping the spinner for the duration of the update.

* Avoid race in starting spinner after exit
2022-11-10 18:21:38 +00:00
Dean Sheather e847276d74 feat: add cleanup strategy to loadtest (#4991) 2022-11-11 04:14:50 +10:00
Kira Pilot 1c9677d37a Template delete button/kira pilot (#4992)
* removed button

* ripped out delete dialog

* fixed tests

* added error message back

* redirecting after success
2022-11-10 10:41:36 -05:00
Mathias Fredriksson 0eed533b17 fix: Improve agent waiting/timeout message behavior in ssh (#4999) 2022-11-10 15:41:23 +00:00
Kyle Carberry aa9fa2bdff chore: Disable load test for flakes (#4998) 2022-11-10 15:31:35 +00:00
Marcin Tojek d64c73dd74 chore: ignore .envrc (#4994) 2022-11-10 11:55:55 +01:00
Mathias Fredriksson 570a1ffc2b fix: Improve docker example first user experience (#4972)
The base ubuntu image lands the user as root, but the terraform tempalte
expected /home/coder to be used. This change adds a user with the same
name as the Coder users username and allows them to sudo.
2022-11-10 12:55:39 +02:00
Mathias Fredriksson 4885ecc3ad fix: Allow dumping db with pg_dump, utilize make cache (#4964) 2022-11-10 12:54:47 +02:00
Eric Paulsen 18a97c6f59 helm: add affinity, nodeSelectors, tolerations (#4763) 2022-11-09 22:08:44 +00:00
Bruno Quaresma d225f2c6ba feat: Display warning on agent connection timeout (#4983) 2022-11-09 20:40:34 +00:00
Kyle Carberry 16e9b1eb1a fix: Add timeouts to every tailnet ping (#4986)
A ping isn't guaranteed to deliver, so these need to have a
tight timeout for tests to not flake.
2022-11-09 20:12:51 +00:00
Dean Sheather 45f81a7cd5 fix: prevent terraform init races (#4985) 2022-11-09 19:40:52 +00:00
Garrett Delfosse d277e28427 feat: change template max_ttl to default_ttl (#4843) 2022-11-09 19:36:25 +00:00
Dean Sheather ffc24dcbe0 feat: create tracing.SlogSink for storing logs as span events (#4962) 2022-11-09 12:58:23 -06:00
Dean Sheather 0ae8d5eeec fix: prevent races from processing build logs after channel close (#4984) 2022-11-10 04:32:59 +10:00
Kyle Carberry 3c10c7f5f4 fix: Subscribe to template updates on the workspace page (#4979)
Fixes #4969.
2022-11-09 11:01:34 -06:00
Mathias Fredriksson 5592f85c11 chore: Find source files once in Makefile targets (#4968) 2022-11-09 18:39:42 +02:00
Kyle Carberry 089659ffb1 fix: Move SQL connection limits to initialization (#4981)
The connection limit wasn't being applied to pubsub, which would
overload the server if a ton of logs were being published at once.

This should fix it, and improve scale a lot!
2022-11-09 16:25:25 +00:00
Mathias Fredriksson 90c34b74de feat: Add connection_timeout and troubleshooting_url to agent (#4937)
* feat: Add connection_timeout and troubleshooting_url to agent

This commit adds the connection timeout and troubleshooting url fields
to coder agents.

If an initial connection cannot be established within connection timeout
seconds, then the agent status will be marked as `"timeout"`.

The troubleshooting URL will be present, if configured in the Terraform
template, it can be presented to the user when the agent state is either
`"timeout"` or `"disconnected"`.

Fixes #4678
2022-11-09 17:27:05 +02:00
Mathias Fredriksson ed7de90a55 fix: Use immutable names for volumes in example templates (#4954)
* fix: Use immutable names for volumes in example templates

This contributes towards #3000, #3386

Related #3409

* Add lifecycle and labels
2022-11-09 16:18:19 +02:00
Mathias Fredriksson 26ab0d37c1 fix: Protect codersdk.Client SessionToken so it can be updated (#4965)
This feature is used by the coder agent to exchange a new token. By
protecting the SessionToken via mutex we ensure there are no data races
when accessing it.
2022-11-09 15:31:24 +02:00
sharkymark 8cadb33396 chore: remove sample jetbrains projector code, only use 2 kubernetes example repos (#4819) 2022-11-09 10:30:38 +00:00
sharkymark b6f2a29b7e docs: update port forwarding to state it works without a wildcard with tunnel (#4887) 2022-11-09 20:25:32 +10:00
Dean Sheather d82364b9b5 feat: make trace provider in loadtest, add tracing to sdk (#4939) 2022-11-09 08:10:48 +10:00
Presley Pizzo fa844d0878 Feat: hide pagination widget when not needed (#4957)
* Hide pagination widget when not needed. Don't merge until count is in.

* Format

* Refactor

* Remove story

* Fix bug

* Format
2022-11-08 13:29:32 -05:00
Mathias Fredriksson e906d0dc54 feat: Add database fixtures for testing migrations (#4858) 2022-11-08 19:59:44 +02:00
Kyle Carberry b97043850b fix: Remove action from build cancelation names (#4930)
This looked weird in the UI and didn't conform to our other states.
2022-11-08 17:12:06 +00:00
Garrett Delfosse 2789fb7cac fix: move experimental flag to server (#4959) 2022-11-08 16:59:39 +00:00
Mathias Fredriksson b2a16d46c6 chore: Unify Docker terraform templates (#4952)
Changes to terraform templates:

* Remove DNS (this can interfere with users running their own DNS
  servers)
* Remove `lower()` restriction from hostnames so that it will show the
  name set by the user, as-is (there is no restriction on upper case
  letters in hostnames)
* Remove superfluous `trap` in entrypoints, this is already handled by
  the init script
* Switch from `command` to `entrypoint` as the latter can support more
  Docker images out-of-the-box
2022-11-08 18:52:19 +02:00
dependabot[bot] 6baaf205c8 chore: bump loader-utils from 1.4.0 to 1.4.1 in /site (#4956)
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 1.4.0 to 1.4.1.
- [Release notes](https://github.com/webpack/loader-utils/releases)
- [Changelog](https://github.com/webpack/loader-utils/blob/v1.4.1/CHANGELOG.md)
- [Commits](https://github.com/webpack/loader-utils/compare/v1.4.0...v1.4.1)

---
updated-dependencies:
- dependency-name: loader-utils
  dependency-type: indirect
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-08 10:09:33 -06:00
Presley Pizzo 87b3fe1afb feat: add "on this page" to empty table message when you're past page 1 (#4886)
* Use empty page message on workspaces page

* Add prop for story

* AuditPage

* UsersPage

* Lint and format

* Fix tests

* Remove log

* Try to fix story

* Fix the right story
2022-11-08 11:08:51 -05:00
Presley Pizzo f496b149df feat: add count endpoint for users, enabling better pagination (#4848)
* Start on backend

* Hook up frontend

* Add to frontend test

* Add go test, wip

* Fix some test bugs

* Fix test

* Format

* Add to authorize.go

* copy user array into local variable

* Authorize route

* Log count error

* Authorize better

* Tweaks to authorization

* More authorization tweaks

* Make gen

* Fix test

Co-authored-by: Garrett <garrett@coder.com>
2022-11-08 10:58:44 -05:00
Kyle Carberry a4fbc74751 chore: Update gotestsum (#4955)
This was breaking CI!
2022-11-08 09:58:01 -06:00
Mathias Fredriksson d1c82f6c52 fix: Off-by-one created after notification for provisioner logs (#4949)
Fixes #4948
2022-11-08 17:56:16 +02:00
Bruno Quaresma e7bd04999f fix: Optimistically update the UI when a workspace action is triggered (#4929) 2022-11-08 09:35:19 -05:00
Marcin Tojek bf4a6fb5b5 feat: pprof is always on (#4951) 2022-11-08 15:02:07 +01:00
Marcin Tojek 16384f8594 feat: Add provisioner force-cancel flag (#4947)
* feat: Add provisionerd force cancel flag

* Golden files

* Fix: typesGenerated.ts

* Use single struct for Provisioner config
2022-11-08 14:19:40 +01:00
Bruno Quaresma f6130e25b2 refactor: Disable auto-complete for the new user form (#4933) 2022-11-08 13:10:25 +00:00
Bruno Quaresma 2af698c43d refactor: Remove workspace schedule banner (#4932) 2022-11-08 10:05:47 -03:00
Kyle Carberry da05bbbdf7 chore: Separate the provisionerd server into it's own package (#4940)
* chore: Separate the provisionerd server into it's own package

This code should be thoroughly tested now that we understand the abstraction.

I separated it to make our lives a bit easier for external provisioner daemons
as well!

* Add tests

* Add workspace builds

* Add test for workspace resources
2022-11-08 01:10:49 +00:00
Kyle Carberry bf2f7b575e chore: Disable docs.github.com for link checks (#4945)
This was causing CI to fail... maybe they have bot detection?
2022-11-07 18:39:46 -06:00
Kyle Carberry 165b6fbc6a fix: Use app slugs instead of the display name to report health (#4944)
All applications without display names were reporting broken health.
2022-11-07 23:35:01 +00:00
Colin Adler 50ad4a8535 fix: use backend for /healthz page (#4938) 2022-11-07 19:35:52 +00:00
Ben Potter bda76368bc docs: git auth (#4902) 2022-11-07 19:04:00 +00:00
sharkymark 1545979e6f docs: 1. fix closing ) on projector examples 2.update jupyter section for slug config and removal of owner and workspace baseURL (#4920) 2022-11-07 12:41:03 -06:00
Marcin Tojek 641aacf793 feat: show banner when workspace is outdated (#4926)
* feat: show banner when workspace is outdated

* Address PR comments

* Fix: writer
2022-11-07 19:12:39 +01:00
Bruno Quaresma f15854c179 fix: Fix long audit log string (#4931) 2022-11-07 14:39:37 -03:00
Dean Sheather 5f099ea488 feat: loadtest output formats (#4928) 2022-11-08 03:26:50 +10:00
Dean Sheather f9189772d7 feat: add new loadtest type agentconn (#4899) 2022-11-07 17:18:07 +00:00
Kyle Carberry 56b963a940 feat: Make workspace watching realtime instead of polling (#4922)
* feat: Make workspace watching realtime instead of polling

This was leading to performance issues on the frontend, where
the page should only be rendered if changes occur. While this
could be changed on the frontend, it was always the intention
to make this socket ~realtime anyways.

* Fix workspace tests waiting, erroring on workspace update, and add comments to workspace events
2022-11-07 15:25:18 +00:00
Muhammad Atif Ali a5cc1970cf bug: fixed prompt in .devcontainer/Dockerfile (#4820)
The user prompt was causing the GitHub codespaces build to fail.
2022-11-07 09:03:55 -03:00
Kyle Carberry 53f2449e4f chore: Fix changes from buffer provisioner logs (#4924)
Comments from #4918 were missed because of auto-merge.
2022-11-06 23:59:01 -06:00
Kyle Carberry 30281852d6 feat: Add buffering to provisioner job logs (#4918)
* feat: Add bufferring to provisioner job logs

This should improve overall build performance, and especially under load.

It removes the old `id` column on the `provisioner_job_logs` table
and replaces it with an auto-incrementing big integer to preserve order.

Funny enough, we never had to care about order before because inserts
would at minimum be 1ms different. Now they aren't, so the order needs
to be preserved.

* Fix log bufferring

* Fix frontend log streaming

* Fix JS test
2022-11-06 20:50:34 -06:00
sharkymark 531f7cd489 docs: adding sharkymark example templates to community page (#4911) 2022-11-06 17:03:37 -06:00
Colin Adler 65ffa20ba2 fix: use correct empty uuids (#4917) 2022-11-06 16:49:43 -06:00
Kyle Carberry 1898f67fe0 fix: Ensure the session token is properly passed to instance identity (#4923)
Fixes #4921.
2022-11-06 16:46:51 -06:00
Kyle Carberry 5be6c7071e feat: Associate connected workspace agents with replicas (#4914)
This will enable displaying a graph that associates agents
to running replicas.
2022-11-06 15:27:09 -06:00
Bruno Quaresma 267b81af83 Revert "fix: Optimistically update the UI when a workspace action is triggered (#4898)" (#4912)
This reverts commit 8f4ae5b6ac.
2022-11-06 10:22:01 -06:00
Colin Adler e740aebf26 feat: add provisionerd prometheus metrics (#4909) 2022-11-04 19:03:01 -05:00
Colin Adler 8dd567dd89 fix: use prometheus default registry (#4907) 2022-11-04 20:19:58 +00:00
Marcin Tojek dad89453d4 docs: Setup external PostgreSQL server (#4901)
* docs: Setup external PostgreSQL server

* Update docs/install/database.md

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

* Use user:password pattern

* Fix

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-11-04 21:15:03 +01:00
Bruno Quaresma 8f4ae5b6ac fix: Optimistically update the UI when a workspace action is triggered (#4898) 2022-11-04 19:09:45 +00:00
Jon Ayers 55fe26bdfa feat: publish helm chart to helm.coder.com (#4793) 2022-11-04 13:43:29 -05:00
Bruno Quaresma ab78f9c2c5 refactor: Improve long rows in audit log (#4904) 2022-11-04 15:24:49 -03:00
Mathias Fredriksson 587924fc42 feat: Add golden files to test cli help output (#4897) 2022-11-04 19:48:36 +02:00
Mathias Fredriksson 70048acd73 fix: Disable viper auto-env to avoid assigning to parent structs (#4893)
The viper automatic env mapping and BindEnv were both creating mappings
like `vip.BindEnv("telemetry", "CODER_TELEMETRY")` which we don't want
since `DeploymentConfig.Telemetry` is a struct housing fields.

For some reason, this was causing `DeploymentConfig.Telemetry.URL` to
**not** be assigned its default value when `CODER_TELEMETRY=false` was
set as an environment variable.

Potentially we would want `"telemetry.enable"` to be mapped to
`"CODER_TELEMETRY"` for simplicity. But that behavior is not changed by
this commit.

Arguably, we could remove `vip.SetEnvPrefix` and `vip.SetEnvKeyReplacer`
as well since we're manually controlling all environment variable names
via `formatEnv`.
2022-11-04 19:46:59 +02:00
Colin Adler 1bbe37a602 chore: update tailscale (#4903) 2022-11-04 12:32:55 -05:00
Kyle Carberry 8e743d28c8 fix: Use instance identity session token for git subcommands (#4884)
This broke using gitssh with instance identity!
2022-11-04 09:44:36 -07:00
Marcin Tojek 3f6c4486f7 Allow changing db schema from public (#4873)
* Remove public schema from enum defs

* Update queries

* Fix
2022-11-04 09:15:17 +01:00
Kyle Carberry 104d6608d9 feat: Add VSCODE_PROXY_URI to surface code-server ports (#4798)
* feat: Add `VSCODE_PROXY_URI` to surface code-server ports

Fixes #4776.

* Check if app host is provided
2022-11-04 04:45:43 +00:00
Geoffrey Huntley e83e6dc583 docs(cli): proxy-trusted-origins should be an ip (#4890) 2022-11-04 03:14:02 +00:00
Eric Paulsen c9a311331a docs: fix DB URL (#4888) 2022-11-04 02:32:59 +00:00
Ben Potter 75da08740c docs: consolidate docker quickstarts (#4882) 2022-11-04 04:30:10 +10:00
Mathias Fredriksson 04ae4c036b fix: Avoid parsing telemetry URL when telemetry is disabled (#4881) 2022-11-03 20:09:21 +02:00
Ben Potter 9b76b10206 chore: hide Coder message on code-server's "Getting Started" page (#4847) 2022-11-03 11:04:27 -05:00
sharkymark 1882edaa9a docs: change format from console to sh for psql URL and coder update repair sections (#4878) 2022-11-03 10:56:20 -05:00
sharkymark 9cd74f307c chore: update port forward dashboard docs for coder_app, sharing, and showing running processes (#4876)
* chore: update port forward dashboard docs for coder_app and sharing

* Update docs/networking/port-forwarding.md

Co-authored-by: Ben Potter <ben@coder.com>
2022-11-03 15:44:56 +00:00
dependabot[bot] 7f0f522b92 chore: bump chromatic from 6.10.1 to 6.11.4 in /site (#4833)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.10.1 to 6.11.4.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.10.1...v6.11.4)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-03 11:23:37 -04:00
Kira Pilot a73dd4f45d Audit date filter/kira pilot (#4845)
* sql query

* added time_to

* added validation error

* documentation

* attempt to add test

* removed whiitespace

* fix: ensure date_from and date_to are applied correct audit logs

* added more tests

* ran make gen

* PR feedback

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-11-03 11:04:36 -04:00
Joe Previte 6bfdccda2f refactor: rm eslint-disable CreateWorkspacePage (#4865) 2022-11-02 22:06:22 -03:00
sharkymark 3fc3b9f89f docs: add psql URL for built-in db and repair workspace CLI (#4864) 2022-11-02 23:56:24 +00:00
Bruno Quaresma f76e7b1dbd refactor: Refactor create workspace page (#4862) 2022-11-02 20:44:41 +00:00
Bruno Quaresma 86fc3e09a3 refactor: Better colocate suspense (#4863) 2022-11-02 13:17:14 -07:00
Dean Sheather e7dd3f9378 feat: add load testing harness, coder loadtest command (#4853) 2022-11-02 18:30:00 +00:00
sharkymark b1c400a7df chore: update web-ides section with revised docker examples and Airflow/RStudio using subdomain config (#4855)
* chore: update web-ides section with docker examples and subdomain rstudio and airflow examples

* Update docs/ides/web-ides.md

* Update docs/ides/web-ides.md

Co-authored-by: Ben Potter <ben@coder.com>
2022-11-02 15:09:42 +00:00
Colin Adler e26bc20723 fix: actually fix template version created by migration (#4850) 2022-11-01 22:19:58 +00:00
Kyle Carberry a672ae8c7d feat: Extract instance type when provisioning VMs (#4839)
This should help us identify what instances our users consume.
2022-11-01 21:51:57 +00:00
Presley Pizzo 26a920a740 chore: do less calculation on users page (#4801)
* Do less calculation on users page

* Handle missing usernames
2022-11-01 16:57:44 -04:00
Kyle Carberry 29dc5f66b8 experiment: Switch to BuildJet Linux Runners (#4846) 2022-11-01 20:56:33 +00:00
Kyle Carberry 288e7d1045 fix: Flake on TestReplica/TwentyConcurrent (#4842)
This could actually cause connections to intermittently fail too
when a CPU is absolutely pegged. It just so happens that only
our runners have been that slow!

Fixes #4607.
2022-11-01 20:28:34 +00:00
dependabot[bot] a390b73386 chore: bump cloud.google.com/go/compute/metadata from 0.1.0 to 0.2.1 (#4841)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 20:27:33 +00:00
dependabot[bot] 88fc37d015 chore: bump github.com/gohugoio/hugo from 0.104.2 to 0.105.0 (#4828)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 18:41:43 +00:00
dependabot[bot] 0b2296a843 chore: bump cloud.google.com/go/compute from 1.10.0 to 1.12.1 (#4826)
Bumps [cloud.google.com/go/compute](https://github.com/googleapis/google-cloud-go) from 1.10.0 to 1.12.1.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/pubsub/v1.10.0...pubsub/v1.12.1)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/compute
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 11:23:40 -07:00
Garrett Delfosse ddbae4da59 fix: error if protocol isn't specified in --access-url (#4835) 2022-11-01 12:59:37 -04:00
Colin Adler a930cf42b4 fix: templates created_by migration (#4838) 2022-11-01 16:35:14 +00:00
dependabot[bot] 9d1d0bce59 chore: bump cronstrue from 2.11.0 to 2.14.0 in /site (#4831)
Bumps [cronstrue](https://github.com/bradymholt/cronstrue) from 2.11.0 to 2.14.0.
- [Release notes](https://github.com/bradymholt/cronstrue/releases)
- [Changelog](https://github.com/bradymholt/cRonstrue/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bradymholt/cronstrue/compare/v2.11.0...v2.14.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 11:18:07 -05:00
dependabot[bot] 261154869d chore: bump github.com/moby/moby from 20.10.18+incompatible to 20.10.21+incompatible (#4822)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 15:11:52 +00:00
dependabot[bot] a5fa54ff23 chore: bump crate-ci/typos from 1.12.8 to 1.12.12 (#4825)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 10:06:41 -05:00
dependabot[bot] d25f770488 chore: bump golangci/golangci-lint-action from 3.2.0 to 3.3.0 (#4824)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 10:02:08 -05:00
dependabot[bot] 88c18775d3 chore: bump tj-actions/branch-names from 6.1 to 6.2 (#4823)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 10:01:14 -05:00
Mathias Fredriksson e508057d1a fix: Avoid panic in ServerSentEventSender by keeping handler alive (#4821)
The goroutine launched by `ServerSentEventSender` can perform a write
and flush after the calling http handler has exited, at this point the
resources (e.g. `http.ResponseWriter`) are no longer safe to use.

To work around this issue, heartbeats and sending events are now handled
by the goroutine which signals its closure via a channel. This allows
the calling handler to ensure it is kept alive until it's safe to exit.

Fixes #4807
2022-11-01 16:57:38 +02:00
Bruno Quaresma a7e5588a65 refactor: Refactor build page (#4815)
* refactor: Improve build page

* Add build translation

* Add build avatar better props

* Get build number from build
2022-11-01 11:49:32 -03:00
dependabot[bot] cf794f1046 chore: bump react-i18next from 11.18.4 to 12.0.0 in /site (#4832)
Bumps [react-i18next](https://github.com/i18next/react-i18next) from 11.18.4 to 12.0.0.
- [Release notes](https://github.com/i18next/react-i18next/releases)
- [Changelog](https://github.com/i18next/react-i18next/blob/master/CHANGELOG.md)
- [Commits](https://github.com/i18next/react-i18next/compare/v11.18.4...v12.0.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-01 11:21:45 -03:00
Colin Adler 4c5bf42355 feat: add option for exporting traces to a provided Honeycomb team (#4816) 2022-11-01 09:15:41 -05:00
Mathias Fredriksson 21e64943ac fix: Use immutable links for docker with intellij/pycharm (#4834) 2022-11-01 15:04:50 +02:00
Joe Previte 17f5e830c7 refactor: extend Overrides for MuiSkeleton (#4818)
* refactor: extend Overrides for MuiSkeleton

Looking at the types provided with `@material-ui/core`, it is indeed
missing `MuiSkeleton`. I'm not sure why. I found this issues upstream: https://github.com/mui/material-ui/issues/24959

I also tried upgrading the package to the latest - 4.12.4 I believe but
that didn't fix it either.

I resorted to extending the `Overrides` type based on what I saw in the
most recent version of the declaration file. This is a temporary fix but
opts back in to type safety instead of resorting to `@ts-ignore`.

* formatting
2022-10-31 16:33:01 -07:00
Joe Previte 34268e6dee refactor: remove eslint-disable (#4817) 2022-10-31 22:04:51 +00:00
Bruno Quaresma 97bcd441f3 refactor: Improve agent loading state (#4814) 2022-10-31 17:35:05 -03:00
Colin Adler dde9a43b7e chore: fix otel dependency versions (#4813) 2022-10-31 19:16:16 +00:00
Colin Adler 1bd67b8064 fix: use -no-color when calling terraform show state (#4812) 2022-10-31 13:03:59 -05:00
Colin Adler cffb723ecc fix: small typos in proxy-trusted-headers help (#4811) 2022-10-31 17:00:04 +00:00
Bruno Quaresma 46e0953876 refactor: Show template versions as timeline (#4800) 2022-10-31 16:38:07 +00:00
Bruno Quaresma cc655672eb refactor: Fix list styles in markdown (#4802) 2022-10-31 11:56:26 -04:00
Alexander Hansen ec4b397aa4 Add 8Bitz0/coder-rust-template (#4804)
Put `8Bitz0/coder-rust-template` in `community-templates.md`
2022-10-31 09:25:41 -05:00
Arthur Normand 7635736be6 Fix link to supported terraform versions (#4803)
* Fix link to supported terraform versions

* Update offline.md
2022-10-29 11:07:06 -07:00
Joe Previte ffe461ae58 chore(site): enable eslint-plugin-eslint-comments (#4799)
* chore(site): enable eslint-plugin-eslint-comments

* chore: add descriptions to eslint-disable comments

* chore: update eslint-disable comments in main.go
2022-10-28 17:46:51 -03:00
Presley Pizzo 506a81e3dc feat: paginating Users page (#4792)
* Extract PageButton

* Fix import

* Extract utils

* Format

* Separate pagination - wip

* Spawn pagination machine - buggy filter

* Make labels optional

* Layout, fix send reset bug

* Format

* Fix refresh data bug

* Remove debugging line

* Fix url updates

setSearchParams overwrites all search params, rather than merging

* Update Audit Page

* Simplify pagination widget

* Fix workspaces story

* Fix Audit story

* Fix pagination story and pagebutton highlight

* Fix pagination tests

* Add to utils tests

* Format

* Add tests

* Start adding pagination - type error

* Tweak machine

* Refactor paginated api calls

* Show pagination when count is undefined

* fix stories

* Fix api helper

* Add test

* Format

* Make widget show all the time to avoid blink
2022-10-28 15:43:10 -04:00
Bruno Quaresma 708abd37cf refactor: Improve template README section (#4794)
* refactor: Improve template README section

* Fix version

* Add darcula

* Fix typos
2022-10-28 19:40:41 +00:00
Bruno Quaresma 6add465365 fix: display None when there are no apps (#4797) 2022-10-28 19:37:45 +00:00
Bruno Quaresma d2fac850cb refactor: Align values when there are more than one row in agent preview (#4795) 2022-10-28 19:09:05 +00:00
Dean Sheather 10df2fd4fb feat: add new required slug property to coder_app, use in URLs (#4573) 2022-10-28 17:41:31 +00:00
Jon Ayers 90f77a3415 feat: add groups support to the CLI (#4755) 2022-10-27 16:49:35 -05:00
Bruno Quaresma ce2a7d49b1 refactor: Refactor template resources (#4789) 2022-10-27 17:27:15 -03:00
Kira Pilot 8282e46813 chore: add audit log tests (#4764)
* added test for stopping a workspace build

* formatted sfriendly string; added tests

* logging unmarshal error in auditLogDescription

* prettier

* got rid of extra workspace word

* PR feedback

* fixed mistake; wrote tests in penance

* fix be
2022-10-27 15:57:41 -04:00
Asher 01ec483ecc docs: fix base path for JupyterLab (#4790)
It seems the base path uses the app name (for now anyway).
2022-10-27 17:38:54 +00:00
Kyle Carberry b34a67e6cb fix: Allow custom Git OAuth URLs (#4758)
Fixes an issue reported in Discord where custom endpoints
weren't working.
2022-10-27 10:38:05 -07:00
Bruno Quaresma 3e15ee3ba0 fix: Fix audit log collapse (#4781) 2022-10-27 01:02:52 +00:00
Ben Potter 670d5adfd7 chore: fix install.sh typo (#4770) 2022-10-26 15:32:20 -04:00
Bruno Quaresma d88b824328 refactor: Inline workspace badge (#4774) 2022-10-26 12:30:02 -07:00
Eric Paulsen 896f628473 site: fix networking docs link (#4778) 2022-10-26 19:29:50 +00:00
Bruno Quaresma 00495568e4 refactor: Make the audit log looks like a timeline (#4765) 2022-10-26 19:20:26 +00:00
Joe Previte 9d8c3ca59c docs(templates): add edit templates section (#4754)
* docs(templates): add edit templates section

* minor changes

Co-authored-by: Ben <me@bpmct.net>
2022-10-26 11:18:47 -07:00
Shyim 820306a32c set correct case for env (#4713) 2022-10-26 12:09:05 -05:00
Presley Pizzo b0d5e0613e chore: refactor pagination (#4753)
* Extract PageButton

* Fix import

* Extract utils

* Format

* Separate pagination - wip

* Spawn pagination machine - buggy filter

* Make labels optional

* Layout, fix send reset bug

* Format

* Fix refresh data bug

* Remove debugging line

* Fix url updates

setSearchParams overwrites all search params, rather than merging

* Update Audit Page

* Simplify pagination widget

* Fix workspaces story

* Fix Audit story

* Fix pagination story and pagebutton highlight

* Fix pagination tests

* Add to utils tests

* Format

* Add tests
2022-10-26 13:08:22 -04:00
Mathias Fredriksson a0bdb4fca2 fix: Remove pkg/sftp fork, fix SFTP test (#4759) 2022-10-26 16:02:06 +03:00
Bruno Quaresma b217f2c210 refactor: Refactor resources colors and avatars (#4751) 2022-10-25 16:41:38 -03:00
Kira Pilot 3c5e292c5a feat: add workspace build start/stop to audit log (#4744)
* adding workspace_build resource

* added migration

* fix keyword

* got rid oof diffs for workspace builds

* adding workspace name to string

* renamed migrations

* fixed lint

* pass throough AdditionalFields and fix tests

* no need to pass through each handler

* cleaned up migrations

* generated types; fixed missing cases

* logging error
2022-10-25 15:34:48 -04:00
Bruno Quaresma 9070fcd5e7 refactor: Refactor page header spacing and stats (#4750) 2022-10-25 14:51:58 -03:00
Bruno Quaresma 2ffefc3bbd fix: Don't show pagination during workspaces load (#4743) 2022-10-25 17:41:18 +00:00
dependabot[bot] f622247b51 chore: bump github.com/spf13/cobra from 1.5.0 to 1.6.1 (#4746)
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.5.0 to 1.6.1.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.5.0...v1.6.1)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-25 15:51:37 +00:00
dependabot[bot] 8b199c00e5 chore: bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc (#4723)
Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc](https://github.com/open-telemetry/opentelemetry-go) from 1.10.0 to 1.11.1.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.10.0...v1.11.1)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-25 15:48:10 +00:00
sonnysasaka 7d831e31c6 fix: Line gets erased due to updateJob (#4740)
The first updateJob should be called after the first printStage to
guarantee that only stage prints can get erased and overwritten,
otherwise there could be an unrelated line that gets erased.

fixes #3967
2022-10-25 10:27:44 -05:00
Ben Potter df89e2c3b0 chore: Move deployment UI and HA out of experimental (#4722)
* Revert "chore: Move deployment UI and HA into experimental (#4595)"

This reverts commit 18c4368571.

* restore flag in coderdtest
2022-10-25 14:33:37 +00:00
Dean Sheather 067362cf31 feat: add windows amd64 installer (#4719) 2022-10-26 00:19:54 +10:00
Kyle Carberry 7d04bf2abe Revert "adding workspace_build resource (#4636)" (#4742)
This reverts commit 145faf4400.
2022-10-25 08:41:00 -05:00
Kira Pilot 145faf4400 adding workspace_build resource (#4636)
* adding workspace_build resource

* added migration

* added migration for audit_actions

* fix keyword

* got rid oof diffs for workspace builds

* adding workspace name to string

* renamed migrations

* fixed lint

* pass throough AdditionalFields and fix tests

* no need to pass through each handler

* cleaned up migrations
2022-10-25 09:27:50 -04:00
Bruno Quaresma 3e08bb4842 feat: Redesign build logs (#4734) 2022-10-25 00:44:13 -03:00
Kyle Carberry 6449443c1f dogfood: remove gitconfig to allow cloning with HTTPS (#4739)
This reflects a more natural environment that our customers might have,
and enables us to use the new git authentication!
2022-10-25 02:37:20 +00:00
Joe Previte 49b3ea02cc refactor: clean up WorkspaceBuildLogs types (#4738)
* refactor: clean up types in WorkspaceBuildLogs

* feat: add tests for groupLogsByStage

* fixup!: formatting
2022-10-24 21:57:12 -03:00
Joe Previte dea329705a chore: clean up eslint-disable lines (#4735)
* chore: drop eslint-disable rule

* refactor: add types for makeMockApiError
2022-10-24 21:55:44 -03:00
Kyle Carberry eec406b739 feat: Add Git auth for GitHub, GitLab, Azure DevOps, and BitBucket (#4670)
* Add scaffolding

* Move migration

* Add endpoints for gitauth

* Add configuration files and tests!

* Update typesgen

* Convert configuration format for git auth

* Fix unclosed database conn

* Add overriding VS Code configuration

* Fix Git screen

* Write VS Code special configuration if providers exist

* Enable automatic cloning from VS Code

* Add tests for gitaskpass

* Fix feature visibiliy

* Add banner for too many configurations

* Fix update loop for oauth token

* Jon comments

* Add deployment config page
2022-10-24 19:46:24 -05:00
Garrett Delfosse 585045b359 feat: support nested structs, structured arrays, and better secret value handling in config (#4727) 2022-10-25 00:11:00 +00:00
Joe Previte f9c6220263 refactor: clean up types in DAUChart (#4737)
This cleans up some types in `DAUChart.tsx`. Previously, we were
type-casting which can lead to errors in production.
2022-10-24 23:28:07 +00:00
Kira Pilot afb806f71a Added the Group resource in audit-logs.md (#4733) 2022-10-24 16:26:22 -04:00
Ben b43b721b1e chore: minor tweaks to architecture diagram 2022-10-24 20:07:48 +00:00
Ben Potter 9ea3e96447 docs: update architecture & diagram (#4721)
* docs: update architecture & diagram

* remove old diagrams

* fix typo
2022-10-24 20:00:46 +00:00
Ammar Bandukwala a0249bea61 docs: better explain persistent resources (#4703) 2022-10-24 19:59:27 +00:00
Eric Paulsen 54261b6e8b docs: add auto-start/stop (#4728)
* docs: add auto-start/stop

* feedback

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

Co-authored-by: Ben Potter <ben@coder.com>
2022-10-24 15:32:05 -04:00
Ammar Bandukwala a82f05a0a0 docs: move enterprise to root (#4720) 2022-10-24 18:10:06 +00:00
dependabot[bot] dc18b0e442 chore: bump go.opentelemetry.io/otel/exporters/otlp/otlptrace (#4591)
Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace](https://github.com/open-telemetry/opentelemetry-go) from 1.10.0 to 1.11.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.10.0...v1.11.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-24 13:07:32 -05:00
dependabot[bot] 65b4106eac chore: bump github.com/u-root/u-root from 0.9.0 to 0.10.0 (#4579)
Bumps [github.com/u-root/u-root](https://github.com/u-root/u-root) from 0.9.0 to 0.10.0.
- [Release notes](https://github.com/u-root/u-root/releases)
- [Changelog](https://github.com/u-root/u-root/blob/main/RELEASES)
- [Commits](https://github.com/u-root/u-root/compare/v0.9.0...v0.10.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-24 13:07:06 -05:00
Ali Diamond 1c9c450399 docs: fix typo (#4520)
missing word
2022-10-24 13:06:37 -05:00
Eric Paulsen fba03aea6e helm: add imagePullSecret for air-gapped cust's (#4700)
* helm: add imagePullSecret for air-gapped cust's

* helm: pullSecrets array

* fix: tag

* indentation

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

* array

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

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-10-24 13:24:21 -04:00
John 0783ca3793 cli: version to the $ coder header in CLI (#4709) 2022-10-24 11:17:48 -05:00
Kyle Carberry 6e06cf10e8 fix: Loading template twice on page load (#4688)
The template page loaded the template twice immediately!
2022-10-24 11:10:50 -04:00
Kyle Carberry c41bdc21cb fix: Add names to config properties for the UI (#4718)
This was reverted in the configuration PR, which broke the UI.
2022-10-24 14:37:37 +00:00
Kyle Carberry bf3224e373 fix: Refactor agent to consume API client (#4715)
* fix: Refactor agent to consume API client

This simplifies a lot of code by creating an interface for
the codersdk client into the agent. It also moves agent
authentication code so instance identity will work between
restarts.

Fixes #3485 and #4082.

* Fix client reconnections
2022-10-23 22:35:08 -05:00
Ammar Bandukwala c9bf2a9099 ci: verify that all docs links work (#4710) 2022-10-23 17:09:58 -05:00
Shyim 05f38d6fe9 remove unused yarn file (#4711) 2022-10-23 21:10:16 +00:00
Shyim 2a47efc546 fix service name (#4712) 2022-10-23 21:08:06 +00:00
Kyle Carberry f75a54cd1e feat: Support x-forwarded-for headers for IPs (#4684)
* feat: Support x-forwarded-for headers for IPs

Fixes #4430.

* Fix realip accepting headers

* Fix unused headers
2022-10-23 13:21:49 -05:00
Ammar Bandukwala 795ed3dc97 provisioner: fix multi-dir installs (#4690)
In the previous implementation, tests would occasionally fail since the original install directory was deleted.
2022-10-22 20:44:05 +00:00
Dean Sheather d0fb054a55 fix: improve codersdk error messages when not JSON (#4495) 2022-10-21 23:36:31 +00:00
Kyle Carberry 7bc5b89f7a feat: Support config files with viper (#4696) 2022-10-21 17:08:23 -05:00
Kyle Carberry adc5c1a131 fix: Load template page chunks without blocking (#4689) 2022-10-21 16:56:52 -05:00
Garrett Delfosse e8537067ef Revert "Revert "Revert "feat: Support config files with viper"" (#4693)" (#4695)
This reverts commit 372fb1f345.
2022-10-21 16:07:38 -05:00
Garrett Delfosse 372fb1f345 Revert "Revert "feat: Support config files with viper"" (#4693) 2022-10-21 20:55:20 +00:00
Kyle Carberry d15b4159ef Add import for use translation 2022-10-21 20:35:21 +00:00
Garrett Delfosse a2fb444911 Revert "feat: Support config files with viper (#4558)" (#4692)
This reverts commit c8e299c8f1.
2022-10-21 20:04:27 +00:00
Kyle Carberry 0d27b59ebb feat: Add emoji picker to group settings (#4685)
Fixes #4413.
2022-10-21 19:42:38 +00:00
Garrett Delfosse c8e299c8f1 feat: Support config files with viper (#4558) 2022-10-21 19:26:39 +00:00
Kyle Carberry 2c47cda3d1 fix: Wrap applications if there are a bunch (#4686)
Fixes #4672.
2022-10-21 14:08:08 -05:00
Kyle Carberry 31b61d1bf8 fix: Remove license on Coder Docker image (#4683)
I didn't know what do change it to, but figured removing it
made the most sense. Fixes #3723.
2022-10-21 12:31:10 -05:00
Kyle Carberry 4d8cc7594d fix: Remove extra unicode char from some emojis (#4682)
Fixes #3689.
2022-10-21 17:28:01 +00:00
Eric Paulsen 72288c3685 fix: coder resource template (#4681) 2022-10-21 10:07:05 -05:00
Mathias Fredriksson 173b7a2c83 fix: Start SFTP sessions in user home (working directory) (#4549)
* fix: Start SFTP sessions in user home (working directory)

This commit switches to our fork of `pkg/sftp` which includes a Server
option for changing the current working directory.

Attempt to upstream: https://github.com/pkg/sftp/pull/528

Supercedes and closes #4420

Fixes #3620

* Update fork
2022-10-21 09:54:06 -05:00
Kira Pilot 940201313f chore: remove org_id from audit diffs (#4668)
* chore: remove org_id from audit diffs

* PR feedback

* fix tests
2022-10-21 10:34:24 -04:00
Dean Sheather 47cb9abfc2 feat: support wildcard apps over tunnel (#4602) 2022-10-21 08:09:44 +10:00
Kyle Carberry 43d1f724b1 chore: Implement database limits from v1 (#4669)
Under scale if there wasn't a PostgreSQL connection available,
an error was occurring instead of blocking for a new connection.

This fixes it!
2022-10-20 18:17:05 +00:00
Presley Pizzo 7c238f13e5 feat: paginate workspaces page (#4647)
* Start - still needs api call changes

* Some xservice changes

* Finish adding count to xservice

* Mock out api call on frontend

* Handle errors

* Doctor getWorkspaces

* Add types, start writing count function

* Hook up route

* Use empty page struct

* Write interface and database fake

* SQL query

* Fix params type

* Missed a spot

* Space after alert banner

* Fix model queries

* Unpack query correctly

* Fix filter-page interaction

* Make mobile friendly

* Format

* Test backend

* Fix key

* Delete unnecessary conditional

* Add test helpers

* Use limit constant

* Show widget with no count

* Add test

* Format

* make gen from garretts workspace idk why

* fix authorize test'

* Hide widget with 0 records

* Fix tests

* Format

* Fix types generated

* Fix story

* Add alert banner story

* Format

* Fix import

* Format

* Try removing story

* Revert "Fix story"

This reverts commit c06765b7fb.

* Add counts to page view story

* Revert "Try removing story"

This reverts commit 476019b041.

Co-authored-by: Garrett <garrett@coder.com>
2022-10-20 13:23:14 -04:00
Ammar Bandukwala 423ac04156 coderd: tighten /login rate limiting (#4432)
* coderd: tighten /login rate limit

* coderd: add Bypass rate limit header
2022-10-20 17:01:23 +00:00
Ben Potter 43f199a987 docs: small tweaks to "change management" (#4532) 2022-10-20 15:14:06 +00:00
Steven Masley 369b5d1c2d chore: Add generics to typescript generator (#4664)
* feat: Support generating generics in interfaces
* Switch struct to a template
* Support generics in apitypings
2022-10-20 08:15:24 -05:00
Jon Ayers d0b1c36d51 fix: prevent refreshing tokens that don't exist (#4661)
- When logging in with Google OIDC refresh tokens are not
  provided unless explicitly asked for. This PR updates
  the logic to avoid attempting to refresh the token if
  a refresh token does not exist.

  A session should only be dependent on a valid Coder API
  key, the state of its OAuth token (beyond initial authentication)
  should be irrelevant.
2022-10-20 00:25:57 -05:00
Ben Essex 49787a4924 docs: fix typo in dotfiles.md (#4663) 2022-10-20 04:57:37 +00:00
Ammar Bandukwala 63602bf568 dogfood: upgrade postgres to version 13 (#4657)
* Fix container updating
2022-10-20 03:06:57 +00:00
Ammar Bandukwala fa49ccd058 coderd/metricscache: fix test race (#4662) 2022-10-20 02:36:00 +00:00
Jon Ayers 7a5ae1e552 fix: delete all sessions on password change (#4659)
- Prevent users from reusing their old password
  as their new password.
2022-10-19 21:12:03 -05:00
Ammar Bandukwala ea156cce2e dogfood: upgrade postgres (#4642) 2022-10-19 19:33:26 +00:00
Ali Diamond eb04a7e7a5 feat: adding gcp quickstart (#4348)
* adding gcp tutorial

* refactor(seo): gcp to google cloud platform

* docs(quickstart): add next steps and title

* adding changes and gcp image

* adding ammar changes

Co-authored-by: Ali Diamond <user@ali.dev>
Co-authored-by: Geoffrey Huntley <ghuntley@ghuntley.com>
2022-10-19 13:52:56 -05:00
Ben Potter 75b058a475 chore: fix agent tooltips (#4654) 2022-10-19 11:40:01 -05:00
Eric Paulsen f9480ed576 add: helm binary download cmd (#4526) 2022-10-19 11:39:44 -05:00
Ben Potter df39920fcd fix: remove default namespace in k8s example (#4645) 2022-10-19 16:34:03 +00:00
Ben Potter 487cc0cd74 docker quickstart: mention tunnel + troubleshooting (#4653) 2022-10-19 11:30:27 -05:00
Eric Paulsen fbbecf0846 helm: add sa annotations (#4640)
* helm: add sa annotations

* rm: test annotation

* fix: labels bracket

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

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-10-19 13:49:48 +00:00
Ammar Bandukwala d49d57ec4b provisioner: don't pass CODER_ variables (#4638) 2022-10-19 09:42:29 -04:00
Ben Potter 12cb4f1eb3 docs: add Caddy+LetsEncrypt TLS example (#4585)
* structure

* docs: add Caddy+LetsEncrypt TLS example
2022-10-19 07:20:11 -05:00
Ben Potter 0727c98313 docs: offline (air-gapped) installs (#4644)
* chore: add docs for offline (air-gapped) installs

* mention postgresql
2022-10-19 06:12:43 -05:00
Jon Ayers 0d1096da6c feat: add auditing for groups (#4527)
- Clean up `database.TemplateACL` implementation.
2022-10-19 02:00:45 -05:00
Ben Potter d4585fefb8 chore: remove bare template (#4629) 2022-10-19 03:47:08 +00:00
Colin Adler 0a5e5544b1 fix: time.NewTicker leaks (#4630) 2022-10-18 15:26:21 -05:00
Bruno Quaresma 5d7d8c3a9a refactor: Update resources to look as a stack (#4631) 2022-10-18 15:52:47 -04:00
Bruno Quaresma 906046c1cc feat: Add minor settings improvements (#4626) 2022-10-18 19:25:52 +00:00
Bruno Quaresma 0d67dfc215 fix: Agent version is only visible when connected (#4619) 2022-10-18 18:19:25 +00:00
Ammar Bandukwala 1984932dc9 coderd/metricscache: attempt to fix macOS race (#4622) 2022-10-18 17:28:40 +00:00
Ben Potter 39498b6531 fix: invalid docs links in "deployment settings" (#4617) 2022-10-18 17:12:06 +00:00
Bruno Quaresma 616fe7a3b1 feat: Redesign resources table (#4600) 2022-10-18 13:44:58 +00:00
Jon Ayers 61683f1961 fix: allow for alternate usernames on conflict (#4614) 2022-10-17 22:07:11 -05:00
Kyle Carberry 3c40698033 chore: Enforce PostgreSQL >=13 (#4612)
* chore: Enforce PostgreSQL >=13

Fixes #4608.

* Fix version string parsing
2022-10-17 20:02:25 -05:00
Eric Paulsen 614e40c0f5 add: postgres version requirement (#4611) 2022-10-18 00:24:49 +00:00
Eric Paulsen d1c537407d fix: install index 404 (#4610) 2022-10-17 19:22:56 -05:00
Colin Adler e95239cfcd fix: agent stats websocket blocking until next interval (#4609) 2022-10-18 00:15:07 +00:00
Kyle Carberry 7851fb1c99 Fix unlock of unlocked mutex in tailnet coordinator 2022-10-17 23:51:41 +00:00
Kyle Carberry 211ffabe39 Fix kill mode stopping the built-in PostgreSQL
This was preventing final cleanups from occurring!
2022-10-17 23:50:29 +00:00
Kyle Carberry c5afaffa7e fix: Tidy up closes for nicer output (#4605)
* fix: Tidy up closes for nicer output

There was a context canceled message that would appear
because of traces, and this was using the wrong close.

I don't think it was causing any specific problems, but
it could make a replica warning appear on restart.

* Fix migration and experimental
2022-10-17 18:36:23 -05:00
Jon Ayers e0a14f68fa feat: add avatar urls to groups (#4525) 2022-10-17 17:46:01 -05:00
Jon Ayers 9b4ab82044 fix: potential deadlock in coordinator (#4598) 2022-10-17 20:46:19 +00:00
Ben Potter 8ab4d26474 chore: add note that HA is experimental (#4601) 2022-10-17 20:14:27 +00:00
Ammar Bandukwala 8acba0ccff site: cleanup code in WorkspaceBuildProgress (#4584) 2022-10-17 16:45:06 -03:00
Kyle Carberry 6f5544e0e4 fix: Pass experimental to the FE through the API (#4597) 2022-10-17 19:44:04 +00:00
Kyle Carberry 4e44716b0c docs: add high availability (#4583)
- Rename `CODER_DERP_SERVER_RELAY_ADDRESS`

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>
2022-10-17 14:27:38 -05:00
Kyle Carberry fda71dadcb fix: Copy replicas to prevent race (#4596)
This was seen in https://github.com/coder/coder/actions/runs/3267638198/jobs/5373066836
2022-10-17 19:22:54 +00:00
Kyle Carberry 618c6dcaa4 fix: Allow OIDC with the username as email (#4594)
Fixes #4472.
2022-10-17 14:14:49 -05:00
Ammar Bandukwala ae9d7f6b4c coderd: fix race condition in template test 2022-10-17 19:12:21 +00:00
Kyle Carberry 18c4368571 chore: Move deployment UI and HA into experimental (#4595)
These are new, so they deserve a bit of gel-time!
2022-10-17 18:29:40 +00:00
Kyle Carberry 5325bec26c fix: Add timeout to selecting a dev tunnel (#4592)
For some reason this timed out for a prospect. Even if this
doesn't fix it, the problem will be revealed.
2022-10-17 18:03:17 +00:00
dependabot[bot] 4895e011df chore: bump go.opentelemetry.io/otel from 1.10.0 to 1.11.0 (#4582)
Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.10.0 to 1.11.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.10.0...v1.11.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-17 12:23:26 -05:00
Kyle Carberry 6b1b3a2037 feat: Add deployment settings page (#4590)
* Add base components for the Settings Page

* WIP OIDC page

* Imrove layout

* Add table

* Abstract option

* Refactor badges

* Load settings from the API

* Update deployment page

* feat: Add deployment settings page

This allows deployment admins to view options
set on their deployments.

* Format

* Remove replicas table since it's not used

* Remove references to HA table

* Fix tests

* Improve language

Co-authored-by: Bruno Quaresma <bruno@coder.com>
2022-10-17 12:22:59 -05:00
Colin Adler 9b5d627a55 fix(tailnet): data race in coordinator.Close() (#4589) 2022-10-17 11:47:45 -05:00
Colin Adler 29acd25b4e fix: chrome requests hanging over port-forward (#4588) 2022-10-17 11:45:29 -05:00
Kyle Carberry d2ee18c14f fix: Don't check for existing replicas when starting up (#4587)
This was blocking startup, creating a chicken and egg problem where
if a replica died, a single one couldn't be bootstrapped again.
2022-10-17 15:27:28 +00:00
Kyle Carberry 2ba4a62a0d feat: Add high availability for multiple replicas (#4555)
* feat: HA tailnet coordinator

* fixup! feat: HA tailnet coordinator

* fixup! feat: HA tailnet coordinator

* remove printlns

* close all connections on coordinator

* impelement high availability feature

* fixup! impelement high availability feature

* fixup! impelement high availability feature

* fixup! impelement high availability feature

* fixup! impelement high availability feature

* Add replicas

* Add DERP meshing to arbitrary addresses

* Move packages to highavailability folder

* Move coordinator to high availability package

* Add flags for HA

* Rename to replicasync

* Denest packages for replicas

* Add test for multiple replicas

* Fix coordination test

* Add HA to the helm chart

* Rename function pointer

* Add warnings for HA

* Add the ability to block endpoints

* Add flag to disable P2P connections

* Wow, I made the tests pass

* Add replicas endpoint

* Ensure close kills replica

* Update sql

* Add database latency to high availability

* Pipe TLS to DERP mesh

* Fix DERP mesh with TLS

* Add tests for TLS

* Fix replica sync TLS

* Fix RootCA for replica meshing

* Remove ID from replicasync

* Fix getting certificates for meshing

* Remove excessive locking

* Fix linting

* Store mesh key in the database

* Fix replica key for tests

* Fix types gen

* Fix unlocking unlocked

* Fix race in tests

* Update enterprise/derpmesh/derpmesh.go

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

* Rename to syncReplicas

* Reuse http client

* Delete old replicas on a CRON

* Fix race condition in connection tests

* Fix linting

* Fix nil type

* Move pubsub to in-memory for twenty test

* Add comment for configuration tweaking

* Fix leak with transport

* Fix close leak in derpmesh

* Fix race when creating server

* Remove handler update

* Skip test on Windows

* Fix DERP mesh test

* Wrap HTTP handler replacement in mutex

* Fix error message for relay

* Fix API handler for normal tests

* Fix speedtest

* Fix replica resend

* Fix derpmesh send

* Ping async

* Increase wait time of template version jobd

* Fix race when closing replica sync

* Add name to client

* Log the derpmap being used

* Don't connect if DERP is empty

* Improve agent coordinator logging

* Fix lock in coordinator

* Fix relay addr

* Fix race when updating durations

* Fix client publish race

* Run pubsub loop in a queue

* Store agent nodes in order

* Fix coordinator locking

* Check for closed pipe

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-10-17 13:43:30 +00:00
Ammar Bandukwala dc3519e973 Support all transitions in build progress bar (#4575)
* Use null types instead of -1 for simplicity

* Fix pgcrypto bug in migration 59

* Add stories

* Fix visual stutter
2022-10-16 23:34:03 -05:00
Phorcys ee2c29d520 Rename the noVNC icon to match the other icons (#4574) 2022-10-16 19:37:02 -05:00
unknowndevQwQ efdd5d5a0c feat: add doas support (#4531)
* feat: add doas support

Some people may have some reason to drop sudo and switch to doas

* chore: doas at the end

Just because it is relatively cold :-(

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

* chore(CI): add doas to pass CI

* fix syntax error

Co-authored-by: Kyle Carberry <kyle@carberry.com>
Co-authored-by: Ben <me@bpmct.net>
2022-10-16 02:18:30 +00:00
Ammar Bandukwala de5ba47557 site: minor build stats fixes (#4569)
- Correct variable used in the template stats summary
- Don't use dayjs.humanize (it thinks 30 seconds is "a few seconds")
2022-10-15 21:30:51 +00:00
Ammar Bandukwala e456799f1a Add template build time stats (#4557)
- Expose time in Template pages
- Show progress bar when building a workspace
2022-10-15 20:36:50 +00:00
Ben Potter 5b7d204b9d chore: fix tooltip behavior (#4563) 2022-10-15 13:04:52 +00:00
Dean Sheather 1515d755e1 feat: add app sharing icon and tooltip (#4556)
Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-10-14 21:49:24 +00:00
Colin Adler 7ec88bf841 feat: audit git ssh key regeneration (#4544) 2022-10-14 16:25:46 -05:00
Kira Pilot dd8ebf10db fix: duplicate workspace update entries (#4513)
* fix: duplicate workspace update entries

* remove console log

* attempting to fix tests

* keep diffs with 0 changes

* cleaned up test
2022-10-14 14:39:20 -04:00
Dean Sheather a029817d3d feat: allow suffix after wildcard in wildcard access URL (#4524) 2022-10-14 18:25:11 +00:00
Presley Pizzo ccc008eb5e fix: redesign schedule bumper to handle multiple hours of change at once (#4535)
* Start sketching out new design

* Working but ugly

* Highlight chosen mode

* Format

* Set hours field width

* Alignment on desktop

* Use primary button color

* Make 1 the default change

* Add stepper max

* Fix storybook

* Handle undefined deadline

* Access deadline correctly

* Format

* Fix overflow on mobile
2022-10-14 13:23:00 -04:00
Dean Sheather d898737d6d feat: app sharing (now open source!) (#4378) 2022-10-15 02:46:38 +10:00
Mathias Fredriksson 19d7281daf fix: Fix template create with sub-folders on Windows (#4548)
On Windows, files in tar archives were stored with Windows
path-separators resulting in them being individual files as opposed to
contained in a folder.

This commit ensures Unix-based paths (slash) are being used inside tar
archives.

Exmple of previous output:

```
/tmp/provisionerd673501182/images:
/tmp/provisionerd673501182/:
README.md
images
images\base.Dockerfile
images\java.Dockerfile
images\node.Dockerfile
main.tf
```

Fixes #2815
2022-10-14 19:28:47 +03:00
Joe Previte 88f7505fdf feat: upgrade prettier and add --cache (#4543)
This uses the `--cache` flag with `prettier --check` to cache the
results and speed up subsequent runs.
2022-10-14 12:22:07 -04:00
Kira Pilot bf0aca35fa fix: ensure deleting workspace creates audit log (#4537)
* fix: ensure deleting workspace creates audit log

* getting rid of comments

* remove whitespace

* pushing failing test

* fixed test
2022-10-14 09:47:38 -04:00
Joe Previte b1409831a3 refactor: clean up api/error.ts (#4542)
This removes an eslint-disable lint and updates the `err` type to
`unknown` instead of `any` which is more correct.
2022-10-14 09:09:09 -03:00
Joe Previte 94db085b51 chore(site): remove some eslint-disables (#4265)
* fix: await promises in WorkspacePage.test.tsx

* chore: add eventsourcemock to cspell words

* fix: clean up UsersPage.test.tsx

* refactor: clean up eventsource mock

* revert: remove changes from WorkspacePage.test.tsx
2022-10-13 18:09:04 -05:00
Jon Ayers 4e57b9fbdc fix: allow regular users to push files (#4500)
- As part of merging support for Template RBAC
  and user groups a permission check on reading files
  was relaxed.

  With the addition of admin roles on individual templates, regular
  users are now able to push template versions if they have
  inherited the 'admin' role for a template. In order to do so
  they need to be able to create and read their own files. Since
  collisions on hash in the past were ignored, this means that a regular user
  who pushes a template version with a file hash that collides with
  an existing hash will not be able to read the file (since it belongs to
  another user).

  This commit fixes the underlying problem which was that
  the files table had a primary key on the 'hash' column.
  This was not a problem at the time because only template
  admins and other users with similar elevated roles were
  able to read all files regardless of ownership. To fix this
  a new column and primary key 'id' has been introduced to the files
  table. The unique constraint has been updated to be hash+created_by.
  Tables (provisioner_jobs) that referenced files.hash have been updated
  to reference files.id. Relevant API endpoints have also been updated.
2022-10-13 18:02:52 -05:00
Colin Adler a55186cd02 fix(database): remove usage of String() for comparing UUIDs (#4547) 2022-10-13 22:38:30 +00:00
Kira Pilot 9c0cc65973 fix: removing unsupported resources from audit log documentation (#4540) 2022-10-13 16:59:27 -04:00
Garrett Delfosse 459ee4e66a feat: add pagination to getWorkspaces (#4521) 2022-10-13 12:41:13 -04:00
Kyle Carberry 574e5d37c7 fix: Remove case sensitivity check in OIDC email domain (#4534)
Fixes #4533.
2022-10-13 15:51:54 +00:00
Kyle Carberry 0d0ea981da fix: Filter by deleted when querying workspaces (#4512)
Fixes #4508.
2022-10-12 14:53:03 -05:00
Jon Ayers 0fa8f528c2 chore: change view perm to use (#4496) 2022-10-12 14:33:21 -05:00
Jon Ayers 47805643f7 fix: allow user admins to manage groups (#4498) 2022-10-12 14:33:03 -05:00
Ben Potter 2a1bfb3e44 docs: API tokens & CI automation (#4510)
* reword: chore: add CI to dogfood template

* use hardcoded URL

* use consistent name for tokens

* chore: add docs for template change management

* add an example

* fix case
2022-10-12 15:43:59 +00:00
Dean Sheather abf14d976a chore: rename feature rbac to template_rbac (#4486)
* chore: rename feature rbac to template_rbac

* Fix feature visibility on FE

* fixup! Fix feature visibility on FE

Co-authored-by: Bruno Quaresma <bruno@coder.com>
2022-10-11 13:51:41 -05:00
Garrett Delfosse 0f3221f9d0 fix: use more descriptive login flags (#4493) 2022-10-11 18:45:30 +00:00
Bruno Quaresma c13e68248b docs: Add initial docs to groups and rbac (#4455)
* docs: Add initial docs to groups and rbac

* Update manifest

* Apply suggestions from code review

Co-authored-by: Joe Previte <jjprevite@gmail.com>

* use single user icon

* chore: add labels and standardize enterprise messaging

* clarify template role

* add groups role

* fix typo

* rename access to use

Co-authored-by: Joe Previte <jjprevite@gmail.com>
Co-authored-by: Ben <me@bpmct.net>
2022-10-11 13:34:41 -05:00
Kyle Carberry 9dcbe753f4 chore: Update docs for secretNames TLS change (#4469)
This was changed but the docs didn't reflect it.
2022-10-11 13:21:04 -05:00
Ben Potter cc1602ad78 fix: enterprise link for groups (#4491) 2022-10-11 18:19:19 +00:00
Bruno Quaresma c619138ece fix: Display Everyone group in the autocomplete (#4488) 2022-10-11 13:17:19 -05:00
Presley Pizzo 62357084ba feat: filter for running workspaces (#4157)
* Refactor workspaces xservice

* Remove layout comment

* Format

* Add comments

* Add running workspaces filter to frontend

* Start on backend - add status to filter

* Update sql and add test - wip

* Attempt to unconvert status for easier querying

* Fix syntax

* Join jobs table, untested

* sql

* Add Status to GetAuthorizedWorkspaces

* Update job tests to have canceled time

* fmt

* add status filter to database fake

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-10-11 13:50:41 -04:00
Bruno Quaresma aefb477e21 refactor: Add description to the roles options (#4480) 2022-10-11 14:08:13 -03:00
Ben Potter 443173c071 fix: delete random file (#4481) 2022-10-11 11:08:13 -05:00
Garrett Delfosse 3cb2d52a08 fix: issue with token auth (#4483) 2022-10-11 15:58:28 +00:00
Garrett Delfosse a70278e0e1 feat: make flags in one place (#4452) 2022-10-11 15:16:19 +00:00
Dean Sheather b1a095e486 feat: show listening ports in port forward popup (#4389)
* feat: show listening ports in port forward popup

* Move fetch logic to a machine

* feat: don't show  app ports and common non-HTTP ports

Co-authored-by: Bruno Quaresma <bruno@coder.com>
2022-10-12 01:10:02 +10:00
Bruno Quaresma a64731eea5 refactor: Add group badge to diff groups from users (#4478) 2022-10-11 14:39:03 +00:00
Bruno Quaresma 934777d9ca refactor: Add enterprise badge to paywalls (#4477) 2022-10-11 11:27:33 -03:00
Eric Paulsen 5411abb9c1 fix: PVC volume binding mode (#4471) 2022-10-10 22:05:54 -05:00
Kyle Carberry b402c6aba8 fix: Use lower function in default Kubernetes template (#4468)
Fixes #4467.
2022-10-10 21:16:06 -05:00
Joe Previte 8047a3ea61 refactor(site): remove eslint-disable in ResourceAvatar (#4463) 2022-10-10 18:23:23 -07:00
Geoffrey Huntley cf999f3e28 docs(contributing): styleguide for authoring docs (#4355) 2022-10-10 23:33:25 +00:00
Geoffrey Huntley 704840c04e chore(cla): implement coder.com/cla (#4354) 2022-10-10 17:49:03 -05:00
Ben Potter 5ca17c3f63 feat: add ingress to helm chart (#4446)
* feat: add ingress to helm chart

* chore: multiple hostname support in ingress

* fixup! chore: multiple hostname support in ingress

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-10-10 21:57:24 +00:00
Jon Ayers 3120c94c22 feat: add template RBAC/groups (#4235) 2022-10-10 15:37:06 -05:00
Garrett Delfosse 2687e3db49 fix: bug with CODER_OAUTH2_GITHUB_ALLOW_SIGNUPS (#4451) 2022-10-10 16:19:37 -04:00
Garrett Delfosse d22996ea20 fix: bug with TLS Client auth flag (#4450) 2022-10-11 05:26:27 +10:00
Ben Potter 6bc03907bd chore: add git token management to enterprise roadmap (#4447) 2022-10-10 14:06:36 -05:00
Garrett Delfosse b1faaef482 feat: deployment flags (#4426) 2022-10-10 15:04:15 -04:00
Kyle Carberry b50bb99fe7 fix: Check if the response body is nil before panicing (#4448)
If a WebSocket connection couldn't be established, a panic would occur.
2022-10-10 18:45:03 +00:00
Kyle Carberry daa34cf7b8 fix: Return deleted users when fetching workspace builds (#4441)
Fixes #4359.
2022-10-10 18:03:54 +00:00
Ammar Bandukwala 85c679597c site: reduce printWidth to 80 (#4437)
Resolves #4435
2022-10-10 10:33:35 -07:00
Ammar Bandukwala cb54986d3f docs: fix bullet points in kubernetes.md (#4445) 2022-10-10 17:21:32 +00:00
Bruno Quaresma 5e594adfba refactor: Display tooltip on cancel action (#4421) 2022-10-10 12:34:09 -03:00
Ammar Bandukwala eefc26c108 Hide build logs older than 30 days (#4436) 2022-10-09 20:01:18 +00:00
Andrei Kondratiev dd5173b45c fix: apply loadBalancerIP and externalTrafficPolicy values in helm chart (#4427) 2022-10-08 21:15:56 +00:00
Ammar Bandukwala c01910fb75 docs: use enterprise badges (#4428) 2022-10-07 23:44:41 -05:00
Colin Adler 0ad8e775a5 fix(ci): use correct retention-days in e2e (#4424) 2022-10-07 13:46:16 -05:00
Mathias Fredriksson 3ad27b547f chore: Rename context in cli/agent (#4422)
Rename context from common `ctx` to `retryCtx` to avoid later re-use.

Also kind of a bug-fix since client post was using `cmd.Context()`.
2022-10-07 18:06:20 +00:00
Bruno Quaresma 50966c4cf7 fix: Fix keyboard focus styles on buttons (#4418) 2022-10-07 14:39:39 -03:00
Bruno Quaresma 34f799257c refactor: Remove user roles from dropdown (#4419) 2022-10-07 14:17:56 -03:00
Kira Pilot 257df81667 chore: replace old ErrorSummary component (#4417)
* replaced error summary

* fixed tests

* positioning caret
2022-10-07 13:14:32 -04:00
Joe Previte 2b6586d542 chore: add ignoreRestSiblings to no-unused-vars ESLint rule (#4404)
* chore: add ignoreRestSiblings to eslint config

* fix(site): remove eslint warning in <Markdown />
2022-10-07 09:55:27 -07:00
Mathias Fredriksson adcf8838d2 fix: Ensure GitHub OAuth2 users are active in organization (#4416) 2022-10-07 19:53:58 +03:00
Kira Pilot e8e095e2f8 feat: redesign error alert (#4403)
* added a warning summary component

* added warning to workspace page

* consolidated warnings

* prettier

* updated design

* added color scheme

* updated expander component

* cleanup

* fixed tests

* fixed height issue

* prettier

* use theme constants

* increased icon margin
2022-10-07 10:39:27 -04:00
Kyle Carberry 3cc77d96eb feat: Add tunnel by default (#4399)
* feat: Add tunnel by default

If an access URL is not specified, we will always tunnel.

This is from community-member feedback who exclaimed that
it's confusing having the default for `coder server` display
a warning message, and I agree.

There is very little (maybe none) in running `coder server`
without tunnel and without an access URL, so this seems like
overall a much better UX.

* Update install.sh

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

* Update docs/install/packages.md

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

* Fix reset pass test

* Fix e2e test

Co-authored-by: Ben Potter <ben@coder.com>
2022-10-07 08:05:56 -05:00
Kyle Carberry 3049a56355 fix: Use the maximum number of users for a license warning (#4410)
This was causing a banner on dev.coder.com. But now we have a test!
2022-10-06 20:59:25 -05:00
Kyle Carberry 915bb41ea2 feat: Add trial property to licenses (#4372)
* feat: Add trial property to licenses

This allows the frontend to display whether the user is on
a trial license of Coder. This is useful for advertising
Enterprise functionality.

* Improve tests for license enablement code

* Add all features property
2022-10-06 19:28:22 -05:00
Timo 05670d133e fix: Spelling in audit log docs (#4384) 2022-10-06 22:13:25 +00:00
Garrett Delfosse 32bb1e7ce9 fix: add back missing postAPIKey route (#4406) 2022-10-06 17:56:43 -04:00
Garrett Delfosse a89d6909b2 fix: show help on wraper commands (#4402) 2022-10-06 20:15:28 +00:00
Garrett Delfosse f5df54831a feat: tokens (#4380) 2022-10-06 19:02:27 +00:00
Kyle Carberry fe7c9f8ec1 chore: Stop building images on tag pushes (#4397)
This was causing a red X on releases!
2022-10-06 15:39:53 +00:00
Kyle Carberry 9cf3e102ba chore: Pin typos to fix CI (#4396) 2022-10-06 10:27:23 -05:00
Dean Sheather 3b15f13ae4 fix: fix apps being unavailable until rebuild (#4395) 2022-10-06 10:23:55 -05:00
Kyle Carberry 9b1ff43e9f fix: Don't run CI for releases (#4393)
This was unnecessary and causing weird issues like double deploys and runs.
2022-10-06 10:02:37 -05:00
Ben Potter ea42212a2a chore: add icons to quickstarts (#4379) 2022-10-06 10:56:46 -04:00
Kyle Carberry 0ebcb7de55 fix: Remove reliance of relative_path on subdomains (#4390)
This broke all relative path applications.
2022-10-06 09:30:10 -05:00
Kyle Carberry d275331c13 fix: Remove audit warning if unlicensed (#4387)
Fixes #4383.
2022-10-06 08:48:44 -05:00
Dean Sheather 29a2fe46e8 fix: fix builds on windows_arm64 (#4388) 2022-10-06 23:42:58 +10:00
Mathias Fredriksson 93b8121c9b fix: Change use of 1337 to 13337 in example templates (#4386) 2022-10-06 13:25:18 +00:00
Dean Sheather 1386465631 feat: add endpoint to get listening ports in agent (#4260) 2022-10-06 22:38:22 +10:00
Kyle Carberry bbe2baf3f6 fix: Ignore all hidden files and folders in archive (#4382)
This also adds a suite of tests to ensure this cannot happen again!
2022-10-06 00:36:45 +00:00
Kira Pilot 3ad5e11d22 feat: add warning if workspace page becomes stale (#4375)
* added a warning summary component

* added warning to workspace page

* consolidated warnings

* prettier

* updated design
2022-10-05 18:46:46 -04:00
Presley Pizzo 9a670b90df chore: refactor frontend to use workspace status directly (#4361)
* Add/update copy

* Update mocks

* Handle disabled button labels separately

* Use workspace status directly, use i18n

* Update stories and tests

* Fix optimistic update in xservice to use status, pending

* Rename started to running in story

* Fix deletion banner conditional

* Send label to disabled button

* Refactor workspace actions
2022-10-05 16:20:29 -04:00
Dean Sheather 2a66395fb7 feat: use app wildcards for apps if configured (#4263)
* feat: use app wildcards for apps if configured

* feat: relative_path -> subdomain

- rename relative_path -> subdomain when referring to apps
    - migrate workspace_apps.relative_path to workspace_apps.subdomain
- upgrade coder/coder terraform module to 0.5.0
2022-10-05 19:23:01 +00:00
Ammar Bandukwala 4f3958c831 docs: link all enterprise features (#4368) 2022-10-05 15:05:28 -04:00
Garrett Delfosse b65c555dfc fix: warn user if not entitled feature is enabled (#4377) 2022-10-05 17:45:05 +00:00
Garrett Delfosse 8d14076a23 fix: move quotas above inputs (#4376) 2022-10-05 13:44:15 -04:00
Muhammad Atif Ali 3759bb2a9a docs: fixed a typo (#4374) 2022-10-05 09:50:56 -05:00
Kyle Carberry 504cd462a7 fix: Check for a response body when dialing the Tailnet WebSocket (#4327)
There was a panic in this code that caused it to fail on error!
2022-10-04 19:46:59 -05:00
Kyle Carberry 8940ea179e fix: Always set DisconnectedAt if the agent isn't connected (#4328)
Fixes #4315.
2022-10-05 00:28:47 +00:00
Steven Masley 587017665a feat: Also log out of apps if they are hosted on the same domain (#4334)
* feat: Also log out of apps if they are hosted on the same domain

* Update comment
2022-10-04 19:01:16 -04:00
Kyle Carberry 06d7e368ab fix: Ignore hidden folders when archiving (#4370)
Fixes #4369.
2022-10-04 22:27:14 +00:00
Kyle Carberry f2952000d9 fix: Ensure WebSockets routinely transfer data (#4367)
Fixes #4351.
2022-10-04 17:10:58 -05:00
Ammar Bandukwala a6bb3b29d0 docs: add quotas (#4366) 2022-10-04 20:55:43 +00:00
Ammar Bandukwala db7030716d docs: add minor quickstart fixups (#4363)
- And fix Telemetry in manifest.json
2022-10-04 14:57:06 -05:00
Kyle Carberry 45c05a0896 Fix additional .md on port-forwarding docs 2022-10-04 19:52:30 +00:00
Garrett Delfosse ffbaa93722 feat: add experimental flag (#4364) 2022-10-04 19:45:00 +00:00
Geoffrey Huntley 18b282cabb docs(quickstart): styling fixes (#4356) 2022-10-05 03:16:21 +10:00
Joe Previte 78283cf236 fix: add keys to createCtas elements (#4362) 2022-10-04 16:50:15 +00:00
Dean Sheather d165d76338 feat: static error page in applications handlers (#4299) 2022-10-05 02:30:55 +10:00
Joe Previte ce953441fb refactor: clean up types in jest.setup.ts (#4285) 2022-10-04 09:04:23 -07:00
Steven Masley cd4ab97efa feat: Convert rego queries into SQL clauses (#4225)
* feat: Convert rego queries into SQL clauses

* Fix postgres quotes to single quotes

* Ensure all test cases can compile into SQL clauses

* Do not export extra types

* Add custom query with rbac filter

* First draft of a custom authorized db call

* Add comments + tests

* Support better regex style matching for variables

* Handle jsonb arrays

* Remove auth call on workspaces

* Fix PG endpoints test

* Match psql implementation

* Add some comments

* Remove unused argument

* Add query name for tracking

* Handle nested types

This solves it without proper types in our AST.
Might bite the bullet and implement some better types

* Add comment

* Renaming function call to GetAuthorizedWorkspaces
2022-10-04 11:35:33 -04:00
Dean Sheather 6325a9ea91 feat: support multiple certificates in coder server and helm (#4150) 2022-10-04 21:45:21 +10:00
Ammar Bandukwala a1056bfa2a docs: describe our telemetry (#2641) 2022-10-04 04:03:46 +00:00
Bruno Quaresma bf63cc929a fix: Fix audit search query (#4352) 2022-10-03 20:56:54 -03:00
Ali Diamond 1d88b9c65c Add AWS and Azure quickstarts (#4176)
* Creating Azure QS and adding images

* adding AWS images and QS, plus fix on azure

* adding ben changes

* adding ammar changes

* adding ammar and ben edits

* pushing final changes to AWS

* removed troubleshooting

* fixing access word

* ammar pls

Co-authored-by: Ali Diamond <user@ali.dev>
2022-10-03 17:15:52 -04:00
Garrett Delfosse 738a38d71f chore: remove resources calls (#4344) 2022-10-03 21:01:13 +00:00
Kyle Carberry 9bc0d06aa0 fix: Install Terraform once and only log >=500 (#4339)
Fixes #4302.
2022-10-03 15:19:02 -05:00
Eric Paulsen aa3812ff4e add: deployment annotations (#4342) 2022-10-03 13:31:34 -05:00
Bruno Quaresma 15d7b78527 fix: Handle invalid resource types and actions (#4341)
* fix: Handle invalid resource types and actions

* Return all values if invalid

* Use types
2022-10-03 15:29:01 -03:00
dependabot[bot] cb62e16b41 chore: bump react-router-dom from 6.3.0 to 6.4.1 in /site (#4300)
Bumps [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) from 6.3.0 to 6.4.1.
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router-dom@6.4.1/packages/react-router-dom)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 12:30:28 -05:00
Kyle Carberry 46f194e7f1 fix: Output help on license subcommand (#4338)
Fixes #4314.
2022-10-03 12:30:18 -05:00
Steven Masley 0a95ba62b1 chore: Deprecate old cookie value (#4336)
Older clis will need to be updated.
Modern clis cannot communicate with <8.15 coderd
2022-10-03 13:04:22 -04:00
Kyle Carberry 4f6355506c fix: Remove "Starts at Manual" label (#4179)
Fixes #2798.
2022-10-03 17:03:11 +00:00
Kyle Carberry df2649ed2a fix: Test flake in TestWorkspaceStatus (#4333)
This also changes the status to be on the workspace build, since
that's where the true value is calculated. This exposed a bug where
jobs could never enter the canceled state unless fetched by a
provisioner daemon, which was nice to fix!

See: https://github.com/coder/coder/actions/runs/3175304200/jobs/5173479506
2022-10-03 11:43:11 -05:00
Steven Masley d11d83cc98 chore: Template-admin cannot create/update/delete workspaces (#4329)
This perm was changed to only be able to read workspaces
2022-10-03 11:20:13 -05:00
dependabot[bot] bbebc1a86a chore: bump @typescript-eslint/parser from 5.36.2 to 5.38.1 in /site (#4325)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.36.2 to 5.38.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.38.1/packages/parser)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 10:58:42 -04:00
Mathias Fredriksson 74cd31bdb1 Revert "refactor(ci): conditionally run jobs based on file changes (#4242)" (#4321)
This reverts commit f9b7588963.
2022-10-03 09:51:31 -05:00
Kyle Carberry 88d49dbcab fix: Add isFirst check before err check (#4326)
This was causing TestBlockNonBrowser to hang and fail.
2022-10-03 09:51:20 -05:00
Bruno Quaresma c7aea2fc42 feat: Add static error page (#4276) 2022-10-03 14:42:11 +00:00
dependabot[bot] 087a7defde chore: bump eslint-plugin-unicorn from 43.0.2 to 44.0.0 in /site (#4324)
Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 43.0.2 to 44.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v43.0.2...v44.0.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 14:40:23 +00:00
dependabot[bot] 951343aa06 chore: bump cloud.google.com/go/compute from 1.9.0 to 1.10.0 (#4291)
Bumps [cloud.google.com/go/compute](https://github.com/googleapis/google-cloud-go) from 1.9.0 to 1.10.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/pubsub/v1.9.0...pubsub/v1.10.0)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/compute
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:25:28 -05:00
dependabot[bot] 2c74d974ca chore: bump github.com/jedib0t/go-pretty/v6 from 6.3.5 to 6.4.0 (#4323)
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.3.5 to 6.4.0.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.3.5...v6.4.0)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 14:21:04 +00:00
dependabot[bot] 132a788c54 chore: bump @typescript-eslint/eslint-plugin in /site (#4298)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.36.1 to 5.38.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.38.1/packages/eslint-plugin)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:13:38 -05:00
dependabot[bot] f2051218ee chore: bump @playwright/test from 1.25.1 to 1.26.1 in /site (#4297)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.25.1 to 1.26.1.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.25.1...v1.26.1)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:13:31 -05:00
dependabot[bot] fc1536daab chore: bump actions/stale from 5.0.0 to 6.0.0 (#4289)
Bumps [actions/stale](https://github.com/actions/stale) from 5.0.0 to 6.0.0.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v5.0.0...v6.0.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:46 -05:00
dependabot[bot] bf0d530e78 chore: bump tj-actions/branch-names from 5.4 to 6.1 (#4290)
Bumps [tj-actions/branch-names](https://github.com/tj-actions/branch-names) from 5.4 to 6.1.
- [Release notes](https://github.com/tj-actions/branch-names/releases)
- [Changelog](https://github.com/tj-actions/branch-names/blob/main/HISTORY.md)
- [Commits](https://github.com/tj-actions/branch-names/compare/v5.4...v6.1)

---
updated-dependencies:
- dependency-name: tj-actions/branch-names
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:41 -05:00
dependabot[bot] 093e3bb3d7 chore: bump github.com/gohugoio/hugo from 0.101.0 to 0.104.2 (#4292)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.101.0 to 0.104.2.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/hugoreleaser.toml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.101.0...v0.104.2)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:23 -05:00
dependabot[bot] f077e14b38 chore: bump google.golang.org/api from 0.95.0 to 0.98.0 (#4293)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.95.0 to 0.98.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.95.0...v0.98.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:17 -05:00
dependabot[bot] 6c0552a5d4 chore: bump chart.js from 3.5.0 to 3.9.1 in /site (#4294)
Bumps [chart.js](https://github.com/chartjs/Chart.js) from 3.5.0 to 3.9.1.
- [Release notes](https://github.com/chartjs/Chart.js/releases)
- [Commits](https://github.com/chartjs/Chart.js/compare/v3.5.0...v3.9.1)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:11 -05:00
dependabot[bot] 9104a067d6 chore: bump eslint from 8.23.0 to 8.24.0 in /site (#4295)
Bumps [eslint](https://github.com/eslint/eslint) from 8.23.0 to 8.24.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.23.0...v8.24.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-03 09:12:04 -05:00
Mathias Fredriksson 00d0620679 fix: Fix err check in DialWorkspaceAgentTailnet (#4320) 2022-10-03 16:53:11 +03:00
Ammar Bandukwala 78a39a809d examples: support both localhost and 127.0.0.1 in Docker examples (#4306)
And some minor fixes
2022-10-03 08:31:12 -05:00
Mathias Fredriksson 092a22f242 feat: Support for comma-separation and ranges in port-forward (#4166)
Fixes #3766
2022-10-03 11:58:43 +03:00
Steven Masley 4919975f13 chore: Remove template-admin can create/update/delete workspaces (#4280)
Cannot crud someone else's workspace
2022-10-02 18:54:57 -04:00
dependabot[bot] 3ab8d57630 chore: bump chromatic from 6.9.0 to 6.10.1 in /site (#4296)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.9.0 to 6.10.1.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.9.0...v6.10.1)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-01 11:49:19 -03:00
Presley Pizzo d931b2c10d chore: refactor schedule banner (#4274)
* Start refactor

* Fix color of auto stop switch

* Format

* Use helper functions for min/max check

* Fix type

* Put new component in own file

* Fix decrease deadline bug

* Simplify functions

* Use ChooseOne

* Remove commented code
2022-09-30 17:39:14 -04:00
Garrett Delfosse 139bc6f58b chore: derive workspace status on backend (#4284) 2022-09-30 17:36:21 -04:00
Steven Masley d8008de77a chore: Optimize Filter() for small lists (#4282) 2022-09-30 15:55:08 -04:00
Garrett Delfosse 69c73b2d28 feat: workspace quotas (#4184) 2022-09-30 14:01:20 -04:00
Joe Previte f9b7588963 refactor(ci): conditionally run jobs based on file changes (#4242)
* refactor(ci): only run ts jobs on ts changes

This modifies the `style-lint-typescript` and `test-js` jobs to only run
when there are changes in `site`.

* refactor(ci): only run lint-shellcheck on sh changes

* refactor(ci): only run go jobs on go changes

* refactor(ci): only run style-fmt when needed

This adds a new item to `changes` for `**.tf` changes. Now it will only
run `style-fmt` if PR includes changes to `site/**`, `**.tf`, or
`**.ts`.

* refactor(ci): run e2e on go, ts or tf changes

* refactor(ci): run gen on gen changes

* refactor(ci): delete old comments

* fixup: try moving if step inside test-go job

* fixup: try if all steps

* fixup!: refactor(ci): run gen on gen changes

* Revert "refactor(ci): run gen on gen changes"

This reverts commit d0a5ba1c4b.
2022-09-30 09:34:55 -07:00
Kira Pilot c9bedc5e58 Feat: add showAvatar option to User Autocomplete (#4269)
* added avatar

* remove commented code
2022-09-30 09:50:36 -04:00
Bruno Quaresma 8c4de49359 chore: Remove unused deps (#4273) 2022-09-30 10:37:23 -03:00
Ammar Bandukwala 4b540b7c42 docs: simplify Docker quickstart (#4257) 2022-09-29 17:55:15 -05:00
Bruno Quaresma e49ef68ebc chore: Add XState inspector back (#4268) 2022-09-29 18:29:24 -03:00
Bruno Quaresma 1755e97748 chore: Remove webpack (#4270) 2022-09-29 18:28:44 -03:00
Kyle Carberry d9a61dd4c8 fix: Don't generate files for deploy (#4245)
This should fix a common race we've been seeing!
2022-09-29 13:54:04 -05:00
Kira Pilot 776f287685 feat: allow admins to create workspaces for other users in UI (#4247)
* added permission for creating a workspace on behalf of a user

* committing stashed files

* hooked up autocomplete for users

* added label

* added translations

* wrote test

* added inputMargin prop

* fixed permissions

* added inputSTyle prop

* ran prettier

* fix lint
2022-09-29 14:32:38 -04:00
Joe Previte 70d7dd9b2f docs: fix port forward link (#4252) 2022-09-29 11:04:13 -07:00
Cian Johnston e6f568fcac refactor: cli: address comments from #4240 (#4259) 2022-09-29 11:04:37 +01:00
Steven Masley 028a4edbd4 chore: Add flusher to make implement http.Flusher interface (#4255) 2022-09-29 01:16:11 +00:00
Colin Adler 6d2b7ea3ba fix(audit): only generate diff on request success (#4253) 2022-09-28 17:28:33 -05:00
Colin Adler 9339d597b9 fix(audit): properly set old workspace in putWorkspaceTTL (#4251) 2022-09-28 16:50:21 -05:00
Colin Adler 574635f43d chore: ignore db spans in workspace watch endpoint (#4250) 2022-09-28 16:17:24 -05:00
Ali Diamond 0c75ea6286 feat: coder ls should show possible columns to filter by (#4240)
* added showing columns in help call, need to format to make pretty

* finished formatting column  strings for print of list /ls command

Co-authored-by: Ali Diamond <user@ali.dev>
2022-09-28 16:39:44 -04:00
Bruno Quaresma df7c7393ad chore: Ignore dynamic message for chromatic (#4244) 2022-09-28 18:18:12 +00:00
Bruno Quaresma 2a7fe13397 chore: Remove extra typegen (#4243) 2022-09-28 16:58:50 +00:00
Bruno Quaresma af502a6a66 chore: Use Vite as build tool (#4239) 2022-09-28 13:11:00 -03:00
Kyle Carberry 6c83012082 chore: Add comments to indicate what each field on a network node means (#4241)
* chore: Add comments to indicate what each field on a network node means

* Update tailnet/coordinator.go

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

* Update tailnet/coordinator.go

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

* Update tailnet/coordinator.go

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

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-09-28 16:04:10 +00:00
Ammar Bandukwala 518f6960d0 docs: add missing icons to Administration section (#4233) 2022-09-28 10:12:31 -05:00
Bruno Quaresma d38cc75f31 fix: Port forward button (#4238) 2022-09-28 14:19:04 +00:00
Mathias Fredriksson 31aaa1ed59 docs: Update Docker docs and docker-compose, mention group-add (#4237) 2022-09-28 16:33:36 +03:00
Bruno Quaresma 59cc4a2586 chore: Use Vite as main dev runner for FE (#4230) 2022-09-27 21:09:16 -03:00
Joe Previte 9775228b00 fix: call testing lib cleanup afterEach test (#4232) 2022-09-27 16:27:42 -07:00
Kira Pilot 65ff604969 fix: update workspace button should properly update the workspace (#4228)
* resolves #4098

* PR comments
2022-09-27 19:23:28 -04:00
Presley Pizzo fedb180735 chore: Change usage of ChooseOne (no final condition) (#4158)
* Change contract of Cond: no condition on default case

* Handle no children case

* Format
2022-09-27 15:58:25 -04:00
Ben Potter 21e6bea792 docs: add health checks to docs & examples (#4223) 2022-09-27 12:58:39 -05:00
Steven Masley 27c8345ef2 chore: Add linter rule to prevent breaking of sse (#4144)
* chore: Add linter rule to prevent breaking of sse
2022-09-27 11:14:58 -04:00
Bruno Quaresma 5a449bf86f chore: Add user autocomplete (#4210)
* chore: Add user autocomplete

* Update value type

* fix initial load and option updates

* cleaned up styling

* PR comments

* prettier

Co-authored-by: Kira Pilot <kira.pilot23@gmail.com>
2022-09-27 10:23:38 -04:00
Ben Potter a7e08db16d docs: fix link 404 in port-forwarding (#4211) 2022-09-27 08:24:49 -05:00
Ben Potter b6426083b9 fix: inline code blocks in template README (#4141) 2022-09-27 07:54:29 -05:00
Kyle Carberry 4f453544d4 chore: Update hero image (#4216) 2022-09-27 07:38:18 -05:00
Ammar Bandukwala 47a53ce6c5 coderd: treat email case insensitively (#4215) 2022-09-27 03:51:58 +00:00
Garrett Delfosse 20bcb04e8a fix: use correct interval for healthcheck loop (#4212) 2022-09-26 21:00:58 +00:00
Ben Potter c86fc6e976 chore: examples/lima: bump terraform version (#4205)
Download terraform binary directly instead of using Hashicorp APT
repo.
Workaround for https://github.com/hashicorp/terraform/issues/31826

Signed-off-by: Cian Johnston <cian@coder.com>
Co-authored-by: Ben Potter <ben@coder.com>
2022-09-26 20:04:59 +00:00
Steven Masley 2f0d30d7b5 chore: Reduce the amount of bytes allocated for Filter (#4209)
Reuse parsed data structure for subsequent queries
2022-09-26 15:16:46 -04:00
Steven Masley 48c0b59447 fix: Log out of legacy cookie (#4202) 2022-09-26 14:20:38 -04:00
Kyle Carberry 39cf329404 fix: Replace access URL for built-in DERP servers (#4197)
Fixes #4195.
2022-09-26 12:56:04 -05:00
Ammar Bandukwala ee4b934601 Add Users Last Seen At (#4192) 2022-09-26 15:31:03 +00:00
Kyle Carberry b8ec5c786d fix: Ensure tailnet coordinations are sent orderly (#4198) 2022-09-26 10:16:04 -05:00
Bruno Quaresma c37ecdb9ff feat: Add port forward button (#4167) 2022-09-26 14:56:17 +00:00
Kyle Carberry 413bfb8d58 fix: Retry reporting agent version (#4190)
It's possible that an agent starts before a build is reported
as complete. This ensures the version is successfully sent
before the startup completes.

Fixes #4151.
2022-09-25 11:11:36 -05:00
Kyle Carberry 112eaf80d1 fix: Add logging to Terraform install (#4191)
Fixes #4129.
2022-09-24 14:55:17 -05:00
Kyle Carberry 4054a9c7cb Fix permissions for welcome message 2022-09-24 02:27:23 +00:00
Ryan Merolle 6571e52f17 Add coder binary to Dockerfile $PATH (#4189) 2022-09-24 02:25:15 +00:00
Kyle Carberry 28428d1294 feat: Add custom version names (#4186)
Fixes #4137.
2022-09-23 20:17:36 -05:00
Kyle Carberry 3c215a83b6 feat: Allow admins to create workspaces (#4183)
Fixes #3263.

This is now possible via the API, but still isn't possible via the UI.
2022-09-23 20:17:10 -05:00
Kyle Carberry 266a3b24e7 fix: Replace getFormHelpers (#4181)
Fixes #3209.
2022-09-23 16:37:44 -05:00
Kyle Carberry f9075cab0e fix: Hide agent status when a workspace is stopped (#4185)
Fixes #4033.
2022-09-23 21:36:33 +00:00
Kyle Carberry b64f624d17 fix: Remove unused scopes from parameter computation (#4171) 2022-09-23 16:09:45 -05:00
Kyle Carberry ea115c981d fix: Make entire row clickable in responsive navbar (#4182)
Fixes #3235.
2022-09-23 20:38:24 +00:00
Kyle Carberry 1c85799be5 fix: Update Terraform to v1.3.0 (#4180)
Contributes to #3202.
2022-09-23 15:31:26 -05:00
Colin Adler 15b9a59786 chore: only trace rbac.Filter (#4177) 2022-09-23 15:21:56 -05:00
Colin Adler 95aea104c7 chore: ignore traces from (*API).workspaceAgentCoordinate after accept (#4178) 2022-09-23 15:21:44 -05:00
Garrett Delfosse 4c8be34d81 feat: add health check monitoring to workspace apps (#4114) 2022-09-23 15:51:04 -04:00
Kyle Carberry f160830226 fix: Update default cache directory (#4175)
Fixes #2534.
2022-09-23 14:26:29 -05:00
Bruno Quaresma 38e2a28ada chore: Pin site deps (#4173) 2022-09-23 16:09:35 -03:00
Bruno Quaresma 189c562826 chore: Use Vite instead of Webpack for development (#4156) 2022-09-23 15:22:48 -03:00
Joe Previte ee00a1d886 chore(site): fix material ui warning (#4161)
* chore(deps): upgrade @material-ui/core to 4.12.4

This is the latest version which includes a fix for the warning we were
seeing while running our tests about `css` function being deprecated.

* refactor: use alpha() instead of fade

`fade()` was deprecated in favor of `alpha()` in a previous version of
`@material-ui/core/styles`.

* refactor: rows -> minRows

This was deprecated in a previous version of `@material-ui/core`.

* refactor: overlap circle -> circular

overlap="circle" was deprecated in favor of overlap="circular".

* refactor: createMuiTheme -> createTheme

This was deprecated and changed to `createTheme`.

* fixup!: chore(deps): upgrade @material-ui/core to 4.12.4

* fixup!: refactor: createMuiTheme -> createTheme

* fix: add SvgIconProps on icons

I couldn't find any release notes or breaking changes related to this
but it seems `props` can no longer be inferred on `SvgIcon`s so I had to
manually add the type.

* Revert "refactor: rows -> minRows"

This reverts commit 94dae6fea8.

* chore(deps): downgrade @material-ui/core to 4.12.0

* fixup!: fix: add SvgIconProps on icons

* fix: pass {} to useStyles

Looks like we may need to pass an empty object if some components in a
file use `props` in styles and some don't.

* fix: update types in Pill.tsx

We need to use generics so that `makeStyles` correctly infers the types
for the `Pill.tsx` styles.

I also updated the types to use `PillProps` directly to make sure they
stay in sync.
2022-09-23 18:14:02 +00:00
Kyle Carberry 99013b3aed chore: Close dials in tailnet conn on close (#4174)
Fixes a race seen in: https://github.com/coder/coder/actions/runs/3114263658/jobs/5049905647
2022-09-23 12:10:47 -05:00
Kira Pilot 8cd5aeaf25 cleanup workspace machine (#4160)
* removed dead build states

* removed dead code

* removed guards

* not calling events from actions

* simplified timeline

* simplify refresh template
2022-09-23 13:06:48 -04:00
Bruno Quaresma 1214022c5a Improve DAU chart view (#4172) 2022-09-23 13:58:00 -03:00
Kyle Carberry 8738755ffc chore: Compile rego once to save CPU cycles in testing (#4169)
Compiling rego isn't very fast, so this should speed up tests in CI!
2022-09-23 16:26:04 +00:00
Mathias Fredriksson 1e1967e0db fix: Avoid using hijacked http.ResponseWriter in workspaceAgentReportStats (#4165) 2022-09-23 19:08:56 +03:00
Bruno Quaresma 7898581e50 feat: Show a full screen loader while is loading a lazy loading page (#4168) 2022-09-23 10:32:28 -05:00
Mathias Fredriksson 6b365f46f5 fix: Ensure coordinator is closed and freed in agent (#4164)
* fix: Close coordinator on context cancellation

* fix: Refactor runCoordinator so that previous is closed/freed
2022-09-23 18:08:13 +03:00
Steven Masley 2e30d0512e chore: Move scope into the same auth call (#4162)
Scopes now are enforced in the same Authorize call as the roles. 
Vs 2 `Authorize()` calls
2022-09-23 11:07:30 -04:00
Kyle Carberry 4183c5e1d0 chore: Clean up unused and outdated dependencies from go.mod (#4163) 2022-09-23 00:58:19 +00:00
Dean Sheather 6deef06ad2 feat: secure and cross-domain subdomain-based proxying (#4136)
Co-authored-by: Kyle Carberry <kyle@carberry.com>
2022-09-22 22:30:32 +00:00
Kyle Carberry 80b45f1aa1 fix: Buffer tailnet nodes from connection initialization (#4159)
* fix: Don't use StatusAbnormalClosure

This is reserved for WASM use, and might be the cause of some weird leaks.

* Add close to provisioner logs
2022-09-22 20:22:49 +00:00
Kyle Carberry a7ee8b31e0 fix: Don't use StatusAbnormalClosure (#4155) 2022-09-22 18:26:05 +00:00
Ben Potter 9e099b543f chore: revert open in coder docs for now (#4154)
* chore: revert open in coder docs for now

* remove in dogfood
2022-09-22 18:02:11 +00:00
Kira Pilot 5fd90471fc Cleanup dead states in workspace machine
* removed dead build states

* removed dead code

* removed guards
2022-09-22 13:32:40 -04:00
Colin Adler 57c84d6446 chore: add option for specifically disabling Coder tracing (#4153) 2022-09-22 11:53:08 -05:00
Kyle Carberry b77d6bdd91 fix: Panic when loading coordination override (#4152)
This was broken because of browser-only. This should fix it!

Signed-off-by: Kyle Carberry <kyle@carberry.com>

Signed-off-by: Kyle Carberry <kyle@carberry.com>
2022-09-22 11:03:49 -05:00
Joe Previte 764600003b feat: add open in coder docs, fix missing templates (#4124)
* docs: add open in coder

This adds new documentation for the "Open in Coder" button that admins
can use to get their developers up and running faster.

* fix: display error if template not found

Previously, we weren't handling a case where we tried to get a template
that returned a 404 from the backend.

Now we handle that case in our state machine and display the error
message from the API on the frontend.

* feat: support template query param in index

This adds support to navigate directly to a template from the index by
using the `?template=<name>` query  param.

* Revert "feat: support template query param in index"

This reverts commit bad7ffb677.

We decided to use the `/template/path` route instead.

* fixup!: docs: add open in coder

* docs: add open in coder to dogfood readme

* Update docs/admin/open-in-coder.md

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

* Update docs/admin/open-in-coder.md

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

* Update docs/admin/open-in-coder.md

Co-authored-by: Ben Potter <ben@coder.com>
2022-09-22 08:48:03 -07:00
Kyle Carberry 7ad4276224 feat: Add browser-only connections to Enterprise (#4135)
* feat: Add browser-only connections to Enterprise

Fixes #4131.

* Fix formatting
2022-09-22 15:14:22 +00:00
Mohammed Agboola 656dcc0050 fix: typo (#4149) 2022-09-21 17:38:51 -05:00
Colin Adler 5de6f86959 feat: trace httpapi.{Read,Write} (#4134) 2022-09-21 17:07:00 -05:00
Joe Previte 1bf2dc0cc3 chore: add explicit-length-check eslint rule (#4147)
* chore: add eslint rule explicit-length-check

* fix: add explicit-length-check
2022-09-21 15:42:10 -04:00
Kira Pilot 5698b9d706 feat: use sse for workspace page (#4122)
* added error handling

* workspace machine cleanup

* renaming callback

* general cleanup

* fixed tests

* PR comments
2022-09-21 14:32:00 -04:00
Joe Previte 3db9ea9dd2 fix: disable inspect xstate in develop (#4145) 2022-09-21 11:08:54 -07:00
Ben Potter 93475453d8 chore: sync autostart helpers+values when toggled (#4143) 2022-09-21 12:59:06 -05:00
Ben Potter ceef283bfd chore: minor changes to SSH dialog (#4142) 2022-09-20 23:02:50 -05:00
Ammar Bandukwala d30945c5c5 feat: bump workspace deadline on user activity (#4119)
Resolves #2995
2022-09-20 21:17:24 +00:00
Presley Pizzo 0899548208 feat: have user type name of thing to delete for extra safety (#4080)
* Add info and text field to delete dialog

* Format

* Use DeleteDialog for Users, nix info except for Workspaces

* Format

* Update storybook

* Add and update tests

* Fix the worst of the UsersPage test bugs

* Fix users page tests

* Fix workspace tests

* Format
2022-09-20 17:13:48 -04:00
Colin Adler eb71053e56 chore: update wireguard-go (#4139) 2022-09-20 16:02:49 -05:00
Colin Adler 5e2efb68f1 feat: add SCIM provisioning via Okta (#4132)
Co-authored-by: Ben Potter <ben@coder.com>
2022-09-20 15:16:26 -05:00
Bruno Quaresma 50321ba2aa docs: Add missing audit logs filtering fields (#4133)
* docs: Add missing audit logs filtering fields

* Update docs/admin/audit-logs.md

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

Co-authored-by: Ben Potter <ben@coder.com>
2022-09-20 17:44:00 +00:00
Bruno Quaresma bc47d7ce69 feat: Add extra fields to the audit filter (#4123) 2022-09-20 13:07:21 -03:00
Kyle Carberry 3618b098cb fix: Return deprecation error when using WebRTC endpoint (#4130)
Fixes #4126.
2022-09-20 09:56:19 -05:00
Mathias Fredriksson 2ca7214259 fix: Produce unknown subcommand errors for bad command names (#4089)
Fixes #1616
2022-09-20 15:31:38 +03:00
Colin Adler 8d7954b015 fix: ignore context canceled error on server (#4128) 2022-09-19 23:56:51 -05:00
Colin Adler 67230babc0 fix: properly shutdown tracers (#4127) 2022-09-19 23:35:18 -05:00
Colin Adler 3993f66997 chore: bump github.com/open-policy-agent/opa from 0.41.0 to 0.44.0 (#4094) 2022-09-20 04:16:03 +00:00
Kyle Carberry db0ba8588e chore: Refactor Enterprise code to layer on top of AGPL (#4034)
* chore: Refactor Enterprise code to layer on top of AGPL

This is an experiment to invert the import order of the Enterprise
code to layer on top of AGPL.

* Fix Garrett's comments

* Add pointer.Handle to atomically obtain references

This uses a context to ensure the same value persists through
multiple executions to `Load()`.

* Remove entitlements API from AGPL coderd

* Remove AGPL Coder entitlements endpoint test

* Fix warnings output

* Add command-line flag to toggle audit logging

* Fix hasLicense being set

* Remove features interface

* Fix audit logging default

* Add bash as a dependency

* Add comment

* Add tests for resync and pubsub, and add back previous exp backoff retry

* Separate authz code again

* Add pointer loading example from comment

* Fix duplicate test, remove pointer.Handle

* Fix expired license

* Add entitlements struct

* Fix context passing
2022-09-19 23:11:01 -05:00
Kyle Carberry 714c366d16 chore: Remove WebRTC networking (#3881)
* chore: Remove WebRTC networking

* Fix race condition

* Fix WebSocket not closing
2022-09-19 19:46:29 -05:00
Bruno Quaresma 1186e643ec feat: Add audit logs filtering to the UI (#4120) 2022-09-19 21:28:23 -03:00
Garrett Delfosse 7fe7ffea6d chore: make fmt (#4121) 2022-09-19 20:22:46 +00:00
Kyle Carberry 72d6731924 fix: Only update workspace LastUsed when the connection payload has changed (#4115)
This was causing every workspace to update last used to time.Now() when
coderd was restarted!
2022-09-19 14:11:18 -05:00
Colin Adler 153e96f574 fix: use consistent tracer name (#4117) 2022-09-19 13:46:26 -05:00
Ammar Bandukwala 794b88fab4 Fix wireguard dependency (#4116)
The old commit disappeared(?).
2022-09-19 18:23:44 +00:00
Dean Sheather 29d804e692 feat: add API key scopes and application_connect scope (#4067) 2022-09-19 17:39:02 +00:00
Bruno Quaresma adad347902 refactor: Refactor audit logs count to support filtering (#4113) 2022-09-19 17:08:25 +00:00
Kyle Carberry 6f82ad09c8 fix: Improve consistency on CLI help (#4112)
This makes the english consistent on flags, and improves
the contrast for the placeholder color on dark themes.
2022-09-19 11:36:18 -05:00
Ben Potter 353fb8724a add docs: "docker in docker" and "systemd in docker" (#4051) 2022-09-19 16:33:31 +00:00
Bruno Quaresma 3e4b67893e fix: Workspace default filter on search bar (#4111) 2022-09-19 13:27:41 -03:00
James Ottaway 9196b3978d Fix kubectl get pods command in k8s install docs (#4053) 2022-09-19 15:55:32 +00:00
Ben Potter 732bc5910c fix: docs: remove reference to fixed issue (#4104) 2022-09-19 10:23:41 -05:00
Ben Potter 64e4ea73c0 fix: docs: use diff view in Docker docs (#4110) 2022-09-19 09:43:54 -05:00
Bruno Quaresma bf8d823ae3 feat: Add audit log filters in the API (#4078) 2022-09-19 10:37:33 -03:00
Geoffrey Huntley f314f30ebc housekeeping(gitignore): update gitignore/eslintignore/prettierignore (#4108) 2022-09-19 17:16:19 +10:00
Denbeigh Stevens 36a599ea9a docs: fix ephemeral resources link (#4101)
[This link](https://coder.com/docs/coder-oss/latest/templates#persistent-and-ephemeral-resources)
directs to the top of the Templates page, we should use
[this link](https://coder.com/docs/coder-oss/latest/templates#persistent-vs-ephemeral-resources) instead.
2022-09-19 02:23:17 +00:00
Kyle Carberry 68ee82437e fix: Remove hiding Tailscale flags (#4103)
Now that Tailscale is defualt, we shouldn't be hiding these!

Fixes #4083.
2022-09-18 20:24:26 -05:00
Geoffrey Huntley d499416024 housekeeping(branding): be consistent (#4075) 2022-09-19 09:57:18 +10:00
Kyle Carberry b3d07ffd87 fix: Test race for TestPostWorkspaceBuild (#4102) 2022-09-18 16:40:24 -05:00
Garrett Delfosse 63fd4945a2 chore: watch workspace endpoint (#4060) 2022-09-16 18:54:23 +00:00
Colin Adler b340634aaa feat: add rbac tracing (#4093) 2022-09-16 18:32:15 +00:00
Joe Previte 1bca269b90 refactor: add type safety in utils.test.ts (#4091)
This makes a few changes to the typings in
site/src/components/GlobalSnackbar/utils.test.ts to more accurately
represent the types we're using. It allows us to remove from type
assertion and one eslin-disable comment..
2022-09-16 10:11:37 -07:00
Colin Adler 77acf0c340 feat: provisionerd tracing, add public trace ingestion (#4070) 2022-09-16 11:43:22 -05:00
Dean Sheather fc841898cd fix: remove path-based port proxying (#4063) 2022-09-16 16:31:08 +00:00
Dean Sheather 6e9c05f859 chore: use zstd -6 in dev (#4092) 2022-09-16 16:03:16 +00:00
Mathias Fredriksson 21664c5c58 fix: Revert change from zstd level 22 to level 6 compression (#4086) 2022-09-16 18:36:11 +03:00
Mathias Fredriksson 9e12850f38 fix: Remove TestWorkspaceBuildResources/ListRunning (#4088) 2022-09-16 16:39:57 +03:00
Colin Adler 86fdafda23 fix: data races in databasefake (#4084) 2022-09-16 00:06:39 +00:00
Kyle Carberry b2bc74e3af chore: Skip TestPortForward due to flakes (#4081)
We'll have to fix this in a future PR... it's unfortunate but
these are *really* flakey.
2022-09-15 21:05:43 +00:00
Colin Adler 87ab6ae8a0 fix: incorrect templates list test assert (#4079) 2022-09-15 15:03:29 -05:00
Joe Previte b8bd3208ca chore: update cSpell and fix isNotificationTextPrefixed (#4076)
* chore: update cSpell words

* chore: add ignorePaths for cSpell

* fix: update isNotificationTextPrefixed

This removes an eslint-disable rule and adds two new tests to ensure
isNotificationTextPrefixed is working as expected.

* fix(e2e): remove filter in workspacesPage
2022-09-15 16:59:22 -03:00
Bruno Quaresma 9e9a9e0cd2 fix: Setup redirect (#4064) 2022-09-15 13:26:24 +00:00
Bruno Quaresma 40c0fc285c refactor: Remove users redirect to active filter (#4056) 2022-09-15 10:05:33 -03:00
Bruno Quaresma b78ab9e028 Fix form tab (#4066) 2022-09-15 09:59:13 -03:00
Andrei Kondratiev 938bd7341b helm: added service annotations (#4062) 2022-09-15 00:01:40 -05:00
Eric Paulsen 45f39ba488 chore: rename AWS ECS template & fix docker template var (#4068) 2022-09-14 20:59:31 -05:00
Kyle Carberry e847e7386a fix: Resolve flake in TestPortForward (#4069) 2022-09-14 20:21:53 -05:00
Kyle Carberry ec453f01e4 fix: Wait for connections before port-forwarding (#4057)
UDP packets were being dropped if a connection was started
before the Tailscale connection has been established.
2022-09-14 21:57:42 +00:00
Joe Previte 22e49c4316 feat(cli): add error message for bad login URL (#4042) 2022-09-14 20:15:47 +00:00
Bruno Quaresma 62d97b18f4 refactor: Typography, action hover and table head colors (#4046)
* Adjust primary text color

* refactor: Typography and table head colors
2022-09-14 15:09:06 -03:00
Geoffrey Huntley a01ab27751 docs(contributing): enable contribution via devcontainer (#3970) 2022-09-14 10:30:12 -07:00
Bruno Quaresma b20ecfdf37 refactor: Minor improvements and fixes for the page headers (#4045) 2022-09-14 11:04:01 -03:00
Presley Pizzo b6712ffbee chore: add wrapper components for conditional rendering (#4047)
* Add conditional wrappers

* Use wrappers in TemplatesPageView
2022-09-14 09:55:00 -04:00
Kyle Carberry 4f0417c6ad Revert "feat: Add portforward to the UI (#3812)" (#4048)
This reverts commit 0552c36e29.
2022-09-13 17:18:27 -05:00
Kyle Carberry 0f8c2f592e feat: Use Tailscale networking by default (#4003)
* feat: Use Tailscale networking by default

Removal of WebRTC code will happen in another PR, but it
felt dangerious to default and remove in a single commit.

Ideally, we can release this version and collect final
thoughts and  feedback before a full commitment.

* Remove UNIX forwarding

Tailscale doesn't support this, and adding support
for it shouldn't block our rollout. Customers can
always forward over SSH.

* Update cli/portforward_test.go

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

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-09-13 15:55:56 -05:00
Bruno Quaresma 478d49c19c docs: Custom resource icon (#4041)
* Fix missed unresolved conflict

* docs: Custom resource icons

* Fix title

* Apply suggestions from code review

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

Co-authored-by: Ben Potter <ben@coder.com>
2022-09-13 20:45:17 +00:00
Bruno Quaresma 0552c36e29 feat: Add portforward to the UI (#3812)
* feat: Add portforward to the UI

* Update site/src/components/PortForwardButton/PortForwardButton.tsx

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>

* Add CODER_ENABLE_WILDCARD_APPS env var

* Fix portforward link

* Remove t file

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>
2022-09-13 17:41:40 -03:00
Steven Masley 9b5ee8f267 feat: Implement (but not enforce) CSRF for FE requests (#3786)
Future work is to enforce CSRF

Co-authored-by: Presley Pizzo <presley@coder.com>
2022-09-13 15:26:46 -04:00
Steven Masley 9ab437d6e2 feat: Add serving applications on subdomains and port-based proxying (#3753)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-09-14 03:31:33 +10:00
Presley Pizzo 99a7a8dd22 chore: Turn predictable action arguments on (#3964)
* Turn predictable action arguments on

* Remove layout strings
2022-09-13 12:54:04 -04:00
Ben Potter f16dd5acb4 docs: explain SSH key behavior (#3990) 2022-09-13 11:36:39 -05:00
Eric Paulsen d57c181aad Delete template docs (#4029)
* add: delete template docs

* add: RBAC context

* fix: caps

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

* add: deletion note

Co-authored-by: Ben Potter <ben@coder.com>
2022-09-13 10:51:50 -05:00
Ben Potter 3ded910cca Add support for coder tunnel in docker-compose (#4027) 2022-09-13 14:53:41 +00:00
Bruno Quaresma 214e59452f feat: Show custom resource icons in the UI (#4020) 2022-09-13 11:32:59 -03:00
Presley Pizzo 83c35bb916 feat: display specific errors if templates page fails (#4023)
* Surface templates page errors

* Format

* Separate error messages

* Fix story

* Format

* Format

* Fix imports

* Remove unnecessary check

* Format
2022-09-13 10:26:58 -04:00
Steven Masley 21e8fb243b fix: Allow develop.sh to host docker workspaces (#3802) 2022-09-13 09:21:05 -04:00
Kyle Carberry 57c7fcf27f fix: Ignore deleted users when signing up with OAuth (#4036)
This prevented a deleted user from signing up again when they
were already linked with a previous account.
2022-09-13 07:33:35 -05:00
Christian Feldkirchner 1ee1db9664 Update docker.md (#4004)
Added a more detailed description on how to create the initial user (via the web ui)
2022-09-13 05:17:01 +00:00
Kyle Carberry a4980446c5 fix: Update Tailscale to resolve race condition (#4032)
This is being fixed upstream here: https://github.com/tailscale/tailscale/pull/5611
2022-09-13 03:32:51 +00:00
Geoffrey Huntley 708bdbc134 docs(contributing): add macos homebrew commands (#3968) 2022-09-13 13:13:30 +10:00
Kyle Carberry 850a83097c feat: Allow deleting users (#4028)
* Add deleted column to the users table

* Fix user indexes

* Add frontend

* Add test
2022-09-12 23:24:20 +00:00
Kyle Carberry a2098254cd feat: Support --header for CLI commands to support proxies (#4008)
Fixes #3527.
2022-09-12 16:22:05 -05:00
Bruno Quaresma 846dd999b7 refactor: Remove cli example from the Audit page (#4031) 2022-09-12 17:17:59 -03:00
Ammar Bandukwala 7e54413d3b docs: add networking (#4030) 2022-09-12 19:07:03 +00:00
dependabot[bot] e9efb7e253 chore: bump github.com/go-chi/httprate from 0.6.0 to 0.7.0 (#4018)
Bumps [github.com/go-chi/httprate](https://github.com/go-chi/httprate) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/go-chi/httprate/releases)
- [Commits](https://github.com/go-chi/httprate/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: github.com/go-chi/httprate
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 18:51:44 +00:00
dependabot[bot] 34a2d40f27 chore: bump github.com/prometheus/client_golang from 1.12.2 to 1.13.0 (#4025)
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.12.2 to 1.13.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.12.2...v1.13.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 18:08:48 +00:00
Bruno Quaresma 184e7dbce0 docs: Add docs about coder_metadata hide attribute (#3985) 2022-09-12 14:57:53 -03:00
dependabot[bot] 0e59cb21ce chore: bump go.uber.org/atomic from 1.9.0 to 1.10.0 (#3793)
Bumps [go.uber.org/atomic](https://github.com/uber-go/atomic) from 1.9.0 to 1.10.0.
- [Release notes](https://github.com/uber-go/atomic/releases)
- [Changelog](https://github.com/uber-go/atomic/blob/master/CHANGELOG.md)
- [Commits](https://github.com/uber-go/atomic/compare/v1.9.0...v1.10.0)

---
updated-dependencies:
- dependency-name: go.uber.org/atomic
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 12:47:59 -05:00
Kyle Carberry 5c0d63d31f fix: Only hold tailnet.*Conn.Close() for a short duration (#4015)
* fix: Only hold `tailnet.*Conn.Close()` for a short duration

The long duration could be cause to a test deadlock.

* Add closed chan to listener struct
2022-09-12 17:46:45 +00:00
dependabot[bot] d4f0a6fecf chore: bump github.com/hashicorp/hcl/v2 from 2.13.0 to 2.14.0 (#4026)
Bumps [github.com/hashicorp/hcl/v2](https://github.com/hashicorp/hcl) from 2.13.0 to 2.14.0.
- [Release notes](https://github.com/hashicorp/hcl/releases)
- [Changelog](https://github.com/hashicorp/hcl/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/hcl/compare/v2.13.0...v2.14.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hcl/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 17:44:14 +00:00
dependabot[bot] 4db98b2b9f chore: bump cloud.google.com/go/compute from 1.7.0 to 1.9.0 (#4012)
Bumps [cloud.google.com/go/compute](https://github.com/googleapis/google-cloud-go) from 1.7.0 to 1.9.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/video/v1.7.0...pubsub/v1.9.0)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/compute
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 12:34:28 -05:00
dependabot[bot] cab6fe9482 chore: bump github.com/moby/moby (#4021)
Bumps [github.com/moby/moby](https://github.com/moby/moby) from 20.10.17+incompatible to 20.10.18+incompatible.
- [Release notes](https://github.com/moby/moby/releases)
- [Changelog](https://github.com/moby/moby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moby/moby/compare/v20.10.17...v20.10.18)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 12:33:51 -05:00
dependabot[bot] edec39baef chore: bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc (#4016)
Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.9.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.9.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 12:10:55 -05:00
dependabot[bot] a7a56f9a26 chore: bump github.com/unrolled/secure from 1.12.0 to 1.13.0 (#4017)
Bumps [github.com/unrolled/secure](https://github.com/unrolled/secure) from 1.12.0 to 1.13.0.
- [Release notes](https://github.com/unrolled/secure/releases)
- [Commits](https://github.com/unrolled/secure/compare/v1.12.0...v1.13.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 12:10:38 -05:00
Kyle Carberry 0551a6cba2 chore: Automatically approve dependabot PRs (#4014)
Dependabot is annoying but now it makes merging it's PRs a
little bit easier!
2022-09-12 16:56:38 +00:00
dependabot[bot] 42d1b5e4ba chore: bump go.uber.org/goleak from 1.1.12 to 1.2.0 (#4010)
Bumps [go.uber.org/goleak](https://github.com/uber-go/goleak) from 1.1.12 to 1.2.0.
- [Release notes](https://github.com/uber-go/goleak/releases)
- [Changelog](https://github.com/uber-go/goleak/blob/master/CHANGELOG.md)
- [Commits](https://github.com/uber-go/goleak/compare/v1.1.12...v1.2.0)

---
updated-dependencies:
- dependency-name: go.uber.org/goleak
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 11:55:46 -05:00
dependabot[bot] 4f78368403 chore: bump github.com/coreos/go-oidc/v3 from 3.2.0 to 3.4.0 (#4013)
Bumps [github.com/coreos/go-oidc/v3](https://github.com/coreos/go-oidc) from 3.2.0 to 3.4.0.
- [Release notes](https://github.com/coreos/go-oidc/releases)
- [Commits](https://github.com/coreos/go-oidc/compare/v3.2.0...v3.4.0)

---
updated-dependencies:
- dependency-name: github.com/coreos/go-oidc/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 11:55:34 -05:00
dependabot[bot] 31f25002a6 chore: bump github.com/charmbracelet/lipgloss from 0.5.0 to 0.6.0 (#4011)
Bumps [github.com/charmbracelet/lipgloss](https://github.com/charmbracelet/lipgloss) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/charmbracelet/lipgloss/releases)
- [Commits](https://github.com/charmbracelet/lipgloss/compare/v0.5.0...v0.6.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 11:55:04 -05:00
Kyle Carberry 2b8223bdd5 fix: Use command property when launching an application (#3998)
Fixes #3777.
2022-09-12 16:46:13 +00:00
dependabot[bot] 07e2565a4f chore: bump go.opentelemetry.io/otel/trace from 1.8.0 to 1.9.0 (#3794)
Bumps [go.opentelemetry.io/otel/trace](https://github.com/open-telemetry/opentelemetry-go) from 1.8.0 to 1.9.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.8.0...v1.9.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/trace
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 11:40:58 -05:00
dependabot[bot] 761f1e7c1a chore: bump google.golang.org/api from 0.94.0 to 0.95.0 (#3921)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.94.0 to 0.95.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.94.0...v0.95.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-12 11:38:07 -05:00
Mathias Fredriksson 09da3858ce fix: Terminal emulation used by SSH sessions (#3473)
Fixes #3371
2022-09-12 19:27:51 +03:00
Kyle Carberry b4c29f34c3 fix: Always use UTC time when inserting stats (#4009)
Fixes a flake reported by @mafredri
2022-09-12 16:01:42 +00:00
Mathias Fredriksson d0b02e581d feat: Improve experience with local SSH keys (#3835)
* feat: Improve experience with local SSH keys

This change means that users can place SSH keys in the default locations
for OpenSSH, like `~/.ssh/id_rsa` and it will be automatically picked
up (as per a default OpenSSH experience).

Fixes #3126

* fix: Ensure gitssh cleans up temporary file on interrupt

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-09-12 17:26:04 +03:00
Kyle Carberry 66ad86a755 fix: Update workspace wasn't using the latest build (#4001)
This was an oversight in a prior contribution. It broke the update
button, but fixed the other cases.
2022-09-12 08:22:29 -03:00
Bruno Quaresma 43f368dfc4 docs: Add audit logs docs (#3975)
* docs: Add audit logs docs

* Apply suggestions from code review

Co-authored-by: Joe Previte <jjprevite@gmail.com>

* Add contact link

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-09-12 01:04:56 +00:00
Ben Potter e5e1ed2f9c chore: minor clarifications to install docs (#3983) 2022-09-12 10:50:20 +10:00
Joe Previte 067069d2e2 docs: add jsjoeio/coder-templates to community (#3986) 2022-09-12 10:49:05 +10:00
Kyle Carberry 5b5bc1da56 feat: Add local configuration option for DERP mapping (#3996)
This allows entirely airgapped geodistributed deployments of Coder!
2022-09-11 16:45:49 -05:00
Kyle Carberry 6e20f9c729 fix: Recursively ignore hidden folders (#3997)
Fixes #3938.
2022-09-11 15:13:20 -05:00
Kyle Carberry 9e148a5cac fix: Update embedded DERP server default name (#3995)
* fix: Update embedded DERP server default name

This is still configurable, but exposing the name DERP
seemed awkward.

* Update relay name
2022-09-11 13:06:07 -05:00
Kyle Carberry f5bbbdf638 chore: Fix VSCode configuration to hide visual test overlay (#3994)
This made it impossible to code 😅
2022-09-11 10:50:50 -05:00
Denbeigh Stevens 522fde47dc docs: fix incorrect terraform providers docs link (#3991) 2022-09-10 16:20:28 -05:00
Colin Adler 29bac36816 feat: add workspace auditing (#3966) 2022-09-10 11:07:45 -05:00
J Bruni 442df9e132 Fix phrase at templates.md (#3987) 2022-09-10 16:07:51 +10:00
Kyle Carberry 849e389388 Update manifest.json 2022-09-09 15:53:00 -05:00
Presley Pizzo 20d950d1b3 feat: Update template page automatically (#3962)
* Update template page automatically

* Remove misleading test
2022-09-09 16:27:21 -04:00
Spike Curtis ba6a868a80 Licensed features docs (#3934)
* Licensed features docs

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

* Licensed features -> Enterprise features

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-09-09 20:10:39 +00:00
Bruno Quaresma ce211fd8f5 fix: Do not update workspace on start (#3984) 2022-09-09 12:56:41 -07:00
Bruno Quaresma 8a94b72c7d feat: Allow hide resources (#3977) 2022-09-09 16:38:00 -03:00
Ammar Bandukwala f6aa025a01 feat: use active users instead of total users in Template views (#3900) 2022-09-09 19:30:31 +00:00
Bruno Quaresma 346583f13e fix: Audit log human parse message and nullable diffs (#3978)
* fix: Audit log human parse message and nullable diffs

* Fix diff values
2022-09-09 13:53:38 -03:00
Colin Adler abb804f2de feat: add template/template version auditing (#3965) 2022-09-09 11:34:23 -05:00
Ben Potter d380c9494d fix: broken docker-compose link (#3976) 2022-09-09 11:04:02 -05:00
Colin Adler 4e26e325a6 feat: add auditing to user routes (#3961) 2022-09-08 21:16:16 -05:00
sharkymark c026464375 chore: add uninstall steps to remove a Coder OSS deployment from docs (#3742)
Co-authored-by: Ben <ben@coder.com>
2022-09-09 00:31:29 +00:00
Ben Potter 3610f09c77 chore: separate install docs (#3859) 2022-09-08 14:41:00 -05:00
Geoffrey Huntley d38e645492 housekeeping(welcome): notify employees when it is someones first PR (#3884) 2022-09-08 14:35:51 -05:00
Eric Paulsen 9c5b879b16 add: ECS example template (#3915)
* add: ECS example template

* fix: empty main.tf

* cleanup

* rm: cluster & compute

* set CPU & memory vars

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

Co-authored-by: Ben Potter <ben@coder.com>
2022-09-08 15:27:27 +00:00
Kyle Carberry 2c41343ce5 fix: Show audit log in production if allowed (#3960) 2022-09-08 14:58:53 +00:00
Colin Adler 7dc73ed6c6 feat: add description to audit log responses (#3949) 2022-09-08 09:36:34 -05:00
Kyle Carberry 5e04a2f800 chore: Remove DataDog test reporting (#3958)
It was costing a lot of money, and it wasn't being used very much.
2022-09-08 14:29:30 +00:00
Kyle Carberry e1afec6db4 fix: Optionally consume email_verified if it's provided (#3957)
This reduces our OIDC requirement claims to only `email`. If `email_verified`
is provided and is `false`, we will block authentication.

Fixes #3954.
2022-09-08 14:06:00 +00:00
Dean Sheather bb4a681833 fix: don't check buildinfo or entitlements in agent (#3956) 2022-09-08 23:59:28 +10:00
Dean Sheather 6a3876d6df chore: hide template check 404 error from develop.sh (#3942) 2022-09-08 15:22:08 +10:00
Kyle Carberry 8596023e31 chore: Update PR template to mention checking for docs (#3913)
This arose from a conversation Presley and I had about developers
maintaining docs, and that this little reminder could be useful!
2022-09-07 22:20:02 -05:00
Kyle Carberry 7718fa53c9 fix: Use a channel for bufferring tailnet connection updates (#3940) 2022-09-07 22:18:35 -05:00
Kyle Carberry 519d724ca4 fix: Sort resources by name (#3941)
Fixes #3489.
2022-09-08 03:16:26 +00:00
Ben Potter 332056af29 dogfood: remove folder from code-server (#3944) 2022-09-07 17:37:30 -05:00
Kyle Carberry 2b0fcf3ece fix: Show the users workspaces by default on coder ls (#3947)
Fixes #3945.
2022-09-07 17:30:49 -05:00
Kyle Carberry c8d9c44aba fix: Sort workspaces by last used then name (#3943) 2022-09-07 21:16:53 +00:00
Kyle Carberry f510f01768 fix: Require an argument for speedtest (#3946) 2022-09-07 21:10:17 +00:00
Presley Pizzo 2a085d1936 chore: refactor dialogs (#3935)
* Move dialogs

* Repurpose WorkspaceDeleteDialog

* Rename to DeleteDialog

Pausing on the typing part for now, leaving this as a refactor

* Rename handlers
2022-09-07 17:04:42 -04:00
dependabot[bot] 47ee44e5ca chore: bump msw from 0.45.0 to 0.47.0 in /site (#3917)
Bumps [msw](https://github.com/mswjs/msw) from 0.45.0 to 0.47.0.
- [Release notes](https://github.com/mswjs/msw/releases)
- [Changelog](https://github.com/mswjs/msw/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mswjs/msw/compare/v0.45.0...v0.47.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 20:58:30 +00:00
dependabot[bot] 9a07d5de6e chore: bump eslint-plugin-jest from 26.7.0 to 27.0.1 in /site (#3828)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 26.7.0 to 27.0.1.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v26.7.0...v27.0.1)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 13:51:12 -07:00
Kyle Carberry 11abb85df5 fix: Rename IncludeProvisionerD to IncludeProvisionerDaemon in test
This was an artifact from merging!
2022-09-07 20:29:26 +00:00
Bruno Quaresma a00fdd699f feat: Add Audit page in the UI (#3782) 2022-09-07 17:26:12 -03:00
Joe Previte 1359850715 feat(cli): validate name length on template create (#3823)
* feat(cli): add template create validation test

This adds a test to validate that `template create` prints an error
message if called with a template name exceeding the 32-char limit.

* fixup

* fixup test

* feat(cli): add name validation to templatecreate

This adds a validation step to ensure the template name is less than 32
characters.

* fixup!: use utf8.RuneCountInString

* fixup!: remove pty from test
2022-09-07 15:01:18 -05:00
Kyle Carberry 720c9dadcf fix: Remove name from workspace builds (#3937)
Fixes #1561.
2022-09-07 19:49:57 +00:00
Colin Adler 762063ed8f fix: add avatar_url to user object in audit log response (#3939) 2022-09-07 19:22:04 +00:00
dependabot[bot] 87379f413f chore: bump @typescript-eslint/parser from 5.31.0 to 5.36.2 in /site (#3912)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.31.0 to 5.36.2.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.36.2/packages/parser)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 15:59:18 -03:00
dependabot[bot] c880263926 chore: bump eslint from 8.21.0 to 8.23.0 in /site (#3920)
Bumps [eslint](https://github.com/eslint/eslint) from 8.21.0 to 8.23.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.21.0...v8.23.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 15:58:58 -03:00
Dean Sheather a79e34c0c7 chore: build releases on a single Linux runner (switch to rcodesign) (#3890)
* chore: build, sign and notarize darwin binaries on linux

* chore: download rcodesign during release

* chore: change nfpm install to be a download instead of compile

* chore: delete apple cert secrets after build

* fix: fix dependencies in archive.sh and build_go.sh

* chore: reduce output from rcodesign
2022-09-07 18:56:46 +00:00
Spike Curtis ac279b3483 Add periods to end of license warning text. (#3933)
* Add periods to end of license warning text.

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

* Fix tests

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-09-07 17:27:42 +00:00
Spike Curtis d46b04cb1e Add Enterprise License text (#3932)
Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-09-07 16:55:57 +00:00
Dean Sheather 819622182b chore: parallel makefile attempt 3 (#3926)
* Revert "chore: Revert parallel Makefile builds (#3918)"

This reverts commit b077f71015.

* fix: fix release workflow with parallel makefile

* fix: mark generated files as fresh during releases
2022-09-08 02:40:17 +10:00
Colin Adler 3d6d51fbd0 feat: audit log api (#3898) 2022-09-07 16:38:19 +00:00
Jon Ayers ad24404018 fix: fix creating users with wrong login type (#3929) 2022-09-07 10:37:15 -05:00
Presley Pizzo 69f430257c chore: remove unused sql-formatter (#3903) 2022-09-07 11:06:43 -04:00
dependabot[bot] cd85be52de chore: bump eslint-import-resolver-typescript in /site (#3925)
Bumps [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) from 3.3.0 to 3.5.0.
- [Release notes](https://github.com/import-js/eslint-import-resolver-typescript/releases)
- [Changelog](https://github.com/import-js/eslint-import-resolver-typescript/blob/master/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-import-resolver-typescript/compare/v3.3.0...v3.5.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 11:06:01 -04:00
Kyle Carberry 3db927bc09 fix: Add contents permission for release CI (#3927) 2022-09-07 14:53:31 +00:00
Kyle Carberry 00104096c2 fix: Resolve CI flakes for tailnet agent (#3924) 2022-09-07 09:24:58 -05:00
dependabot[bot] 73ec618aff chore: bump @testing-library/react from 13.3.0 to 13.4.0 in /site (#3905)
Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 13.3.0 to 13.4.0.
- [Release notes](https://github.com/testing-library/react-testing-library/releases)
- [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/react-testing-library/compare/v13.3.0...v13.4.0)

---
updated-dependencies:
- dependency-name: "@testing-library/react"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-07 10:12:42 -04:00
Kyle Carberry f9ef4b148b fix: Add package write permission to releases (#3923) 2022-09-07 13:58:22 +00:00
Kyle Carberry 80352656e9 fix: Improve speedtest by adding direct connection toggle (#3919)
It's weird to test connection speeds over DERP, because most
connections will eventually migrate to direct.
2022-09-07 03:21:08 +00:00
dependabot[bot] 0f0e3d1068 chore: bump uuid from 8.3.2 to 9.0.0 in /site (#3914)
Bumps [uuid](https://github.com/uuidjs/uuid) from 8.3.2 to 9.0.0.
- [Release notes](https://github.com/uuidjs/uuid/releases)
- [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uuidjs/uuid/compare/v8.3.2...v9.0.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-06 21:57:32 -05:00
Kyle Carberry b077f71015 chore: Revert parallel Makefile builds (#3918)
This was breaking the release process. Namely it was running
the `gen` targets due to the dependency tree, which was failing
on macOS and Linux runners. This revert can be reverted once
we fix that up.
2022-09-07 01:56:51 +00:00
Kyle Carberry d2e6f305b1 Lower protoc version requirement for easy CI install 2022-09-06 20:35:52 -05:00
Kyle Carberry 502a7370c8 Pin to a static version of protoc 2022-09-06 20:32:24 -05:00
Kyle Carberry d970d2d3da Install protoc in release build 2022-09-06 20:13:08 -05:00
Kyle Carberry bb17fe5398 Use go run when executing goimports in gen 2022-09-06 19:59:14 -05:00
Kyle Carberry 65d63f9167 Use go run for executing goimports 2022-09-06 19:53:39 -05:00
Bruno Quaresma b1bdf10e38 feat: Add table support and syntax highlights for markdowns (#3910) 2022-09-06 22:20:23 +00:00
Kyle Carberry dca24bd15d fix: Don't clear out peers that haven't connected yet (#3916)
This was causing parallel connections to fail, because they wouldn't
be established yet.
2022-09-06 21:27:59 +00:00
Joe Previte 18af9426c0 chore: add no implicit coercion eslint rule (#3909)
* chore: add no-implicit-coercion ESLint rule

This adds a new ESLint rule to prevent us from using implicit coercion
in the codebase. See https://eslint.org/docs/latest/rules/no-implicit-coercion

* chore: fix implicit coercion errors

* fixup: formatting
2022-09-06 21:27:10 +00:00
dependabot[bot] bb0e79eb88 chore: bump prettier-plugin-organize-imports in /site (#3891)
Bumps [prettier-plugin-organize-imports](https://github.com/simonhaenisch/prettier-plugin-organize-imports) from 3.0.0 to 3.1.1.
- [Release notes](https://github.com/simonhaenisch/prettier-plugin-organize-imports/releases)
- [Commits](https://github.com/simonhaenisch/prettier-plugin-organize-imports/compare/v3.0.0...v3.1.1)

---
updated-dependencies:
- dependency-name: prettier-plugin-organize-imports
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-06 17:21:16 -04:00
dependabot[bot] 5301d36027 chore: bump canvas from 2.9.3 to 2.10.0 in /site (#3904)
Bumps [canvas](https://github.com/Automattic/node-canvas) from 2.9.3 to 2.10.0.
- [Release notes](https://github.com/Automattic/node-canvas/releases)
- [Changelog](https://github.com/Automattic/node-canvas/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Automattic/node-canvas/compare/v2.9.3...v2.10.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-06 13:47:12 -07:00
Andrei Kondratiev f5ba90b963 Home folder can be empty, so copying default bash settings (#3897) 2022-09-06 15:11:53 -05:00
dependabot[bot] 30ce62b5b4 chore: bump @playwright/test from 1.24.1 to 1.25.1 in /site (#3843)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.24.1 to 1.25.1.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.24.1...v1.25.1)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-06 15:07:48 -04:00
Spike Curtis a7cdec5d39 Feature server implementation (#3899)
* Feature server implementation

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

* Fix imports

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-09-06 18:59:10 +00:00
Dean Sheather 1b6f9e54a3 fix: fix ERRPIPE in scripts/lib.sh (#3908) 2022-09-07 04:42:45 +10:00
Kyle Carberry 3264960fb3 Change the primary UI font, darken the background, and show template icons for workspaces (#3863)
* Use darker colors in the dashboard

I think this looks a bit nicer. It's pretty subjective, but right now
we sit in-between a light and a dark mode, but more on the dark side.

This essentially transforms us into a dark mode.

* Add icons to workspaces rows and apge

* Add narrowed navbar to tighten up design

* Swap gray[3] for gray[4]
2022-09-06 18:26:36 +00:00
Bruno Quaresma 3c94ca9cbe fix: Skip empty values so Terraform can use the default value (#3902) 2022-09-06 15:15:19 -03:00
dependabot[bot] 94eb503aac chore: bump chromatic from 6.7.1 to 6.9.0 in /site (#3837)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.7.1 to 6.9.0.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.7.1...v6.9.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-06 14:05:13 -04:00
Dean Sheather 419d701927 chore: parallel builds with Makefile (#3854)
* Revert "revert: Makefile buff-ification (#3700) (#3848)"

This reverts commit e490bdd531.

* fix: fix slim targets in makefile

* fix: don't clobber slim binaries, make sure they're in the correct location
2022-09-06 17:27:06 +00:00
Ammar Bandukwala 4f0105ef7e feat: add orphan support (#3849)
* feat: add resource orphanage

* feat: deny custom state in build for regular users

* Minor protoc improvements
2022-09-06 17:07:00 +00:00
Bruno Quaresma 209e011404 fix: Escape # character on appName (#3895) 2022-09-06 15:16:03 +00:00
Presley Pizzo 1f55135765 Make color usage more consistent (#3842)
* Tweak overrides - should not cause visual change

* Use closest color for avatar

* Change hover color of contained buttons

* Change nav item color (matches avatar now)

* Format

* Use lighter border for contained button hover

This looks more clickable than lightening the background

* Delete unused component

* Make dropdown arrow consistent

Same up as down. Contrast text everywhere except nav, where it matches links and avatar.

* No need to fade right arrows

* Add hover color

* Consistent box shadows

* Format

* Delete unused DialogSearch

* Deleting unused button types to avoid confusion

* Use disabled arrow on disabled action buttons
2022-09-06 10:58:12 -04:00
dependabot[bot] 8e1dfc2763 chore: bump typescript from 4.7.4 to 4.8.2 in /site (#3836)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.7.4 to 4.8.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.7.4...v4.8.2)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bruno Quaresma <bruno@coder.com>
2022-09-06 14:15:29 +00:00
Geoffrey Huntley 1b56a8cccb docs(readme): use /chat link in the README.md (#3868) 2022-09-06 08:58:27 +00:00
dependabot[bot] e3bbc77c35 chore: bump google.golang.org/api from 0.90.0 to 0.94.0 (#3882)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.90.0 to 0.94.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.90.0...v0.94.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-05 18:02:17 -05:00
Kyle Carberry 1254e7a902 feat: Add speedtest command for tailnet (#3874) 2022-09-05 17:15:49 -05:00
Ammar Bandukwala 38825b9ab4 dogfood: keep image locally (#3878)
Avoid delete conflicts
2022-09-05 19:23:52 +00:00
Geoffrey Huntley d6812e0be8 housekeeping(codeowners): migrate to teams (#3867) 2022-09-05 13:38:29 -05:00
Kyle Carberry 2fa77a9bbd fix: Run status callbacks async to solve tailnet race (#3866) 2022-09-05 10:43:24 -05:00
Mathias Fredriksson 3ca6f1fcd4 fix: Prevent nil pointer deref in reconnectingPTY (#3871)
Related #3870
2022-09-05 16:45:10 +03:00
Ammar Bandukwala 1a5d3eace4 dogfood: dynamically pull image (#3864)
Previously, the template would never pull new image updates.
2022-09-04 21:06:36 +00:00
Kyle Carberry 00f05e798b Fix avatar_url dump.sql 2022-09-04 16:56:09 +00:00
Kyle Carberry d8f9537880 Fix avatar_url database type 2022-09-04 16:55:25 +00:00
Kyle Carberry 05e2806ff3 feat: Add profile pictures to OAuth users (#3855)
This supports GitHub and OIDC login for profile pictures!
2022-09-04 11:44:27 -05:00
Kyle Carberry 67c4605370 chore: Reduce test times (#3856)
* chore: Reduce test times

* Rename IncludeProvisionerD to IncludeProvisionerDaemon

* Make  TestTemplateDAUs use Tailnet
2022-09-04 11:28:09 -05:00
J Bruni 271d075667 Update Coder contact at ADOPTERS.md (#3861) 2022-09-04 09:15:25 -05:00
Ammar Bandukwala 0a7fad674a dogfood: remove github apt source (#3860) 2022-09-03 20:44:40 -05:00
Ammar Bandukwala 1b3e75c3ab add watchexec to dogfood image (#3858)
* add watchexec to dogfood image

This comes in handy quite frequently.

* Fix dogfood image
2022-09-03 18:38:13 -05:00
Geoffrey Huntley aae57476f1 docs(adopters): add ADOPTERS.md (#3825) 2022-09-03 06:18:04 +00:00
Geoffrey Huntley 0372586382 housekeeping(discord): use /chat instead of the discord.gg link (#3826) 2022-09-03 06:16:57 +00:00
Kyle Carberry a24f26c137 fix: Allow disabling built-in DERP server (#3852) 2022-09-02 23:47:25 +00:00
Kyle Carberry 4f4d470c7c feat: Add wireguard to port-forward (#3851)
This allows replacement of the WebRTC networking!
2022-09-02 18:26:01 -05:00
Ammar Bandukwala a09ffd6c0d feat: show better error on invalid template upload (#3847)
* feat: show better error on invalid template upload

* Fix tests
2022-09-02 22:48:40 +00:00
Kyle Carberry ac50070713 fix: Add omitempty for proper latency type (#3850)
This was causing an error on the frontend, because this value can be nil!
2022-09-02 22:05:27 +00:00
Kyle Carberry 2e1db6cc63 feat: Add latency indicator to the UI (#3846)
With Tailscale, we now get latency of all regions.
2022-09-02 20:09:05 +00:00
Kyle Carberry e490bdd531 revert: Makefile buff-ification (#3700) (#3848)
This caused the following issues:
- Slim binaries weren't being updated.
- The coder.tar.ztd was misplaced.
- There is no coder.sha1 file with proper filenames.

This should be reintroduced in a future change with those fixes.
2022-09-02 14:46:58 -05:00
Bruno Quaresma d350d9033c refactor: Remove extra line from table bottom (#3831) 2022-09-02 19:32:28 +00:00
Colin Adler ff0aa8d742 feat: add unique ids to all HTTP requests (#3845) 2022-09-02 13:04:29 -05:00
Kyle Carberry de219d966d fix: Run Tailnet SSH connections in a goroutine (#3838)
This was causing SSH connections in parallel to fail 🤦!
2022-09-02 11:58:15 -05:00
dependabot[bot] 3be7bb58b4 chore: bump @storybook/addon-essentials from 6.4.22 to 6.5.10 in /site (#3827)
Bumps [@storybook/addon-essentials](https://github.com/storybookjs/storybook/tree/HEAD/addons/essentials) from 6.4.22 to 6.5.10.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.10/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.10/addons/essentials)

---
updated-dependencies:
- dependency-name: "@storybook/addon-essentials"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-02 16:58:04 +00:00
Bruno Quaresma 6fe63ed358 refactor: Keep focused style when input is hovered (#3832) 2022-09-02 09:53:46 -07:00
Bruno Quaresma 5618640227 refactor: Remove duplicated title (#3829) 2022-09-02 16:49:41 +00:00
Colin Adler 55c13c8ff9 chore: fully implement enterprise audit pkg (#3821) 2022-09-02 16:42:28 +00:00
Dean Sheather fefdff4946 fix: install goimports in deploy build (#3841) 2022-09-03 02:38:33 +10:00
Dean Sheather e6699d25ca fix: fix CI calling script/version.sh instead of scripts (#3839) 2022-09-03 02:16:19 +10:00
Bruno Quaresma 8c70b6c360 refactor: Update table cell colors to match the ones in the Workspace (#3830)
page
2022-09-02 13:04:08 -03:00
Bruno Quaresma 21ae411237 refactor: Fix README spacing (#3833) 2022-09-02 13:03:59 -03:00
Bruno Quaresma b9e5cc97a1 refactor: Make user columns consistent (#3834) 2022-09-02 13:03:36 -03:00
dependabot[bot] f1976a086f chore: bump webpack-bundle-analyzer from 4.5.0 to 4.6.1 in /site (#3818)
Bumps [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) from 4.5.0 to 4.6.1.
- [Release notes](https://github.com/webpack-contrib/webpack-bundle-analyzer/releases)
- [Changelog](https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack-contrib/webpack-bundle-analyzer/compare/v4.5.0...v4.6.1)

---
updated-dependencies:
- dependency-name: webpack-bundle-analyzer
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-02 10:25:26 -05:00
dependabot[bot] e20ff62c9f chore: bump xstate from 4.32.1 to 4.33.5 in /site (#3817)
Bumps [xstate](https://github.com/statelyai/xstate) from 4.32.1 to 4.33.5.
- [Release notes](https://github.com/statelyai/xstate/releases)
- [Commits](https://github.com/statelyai/xstate/compare/xstate@4.32.1...xstate@4.33.5)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-02 13:11:20 +00:00
dependabot[bot] afd6834ff7 chore: bump @typescript-eslint/eslint-plugin in /site (#3804)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.31.0 to 5.36.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.36.1/packages/eslint-plugin)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-02 10:08:26 -03:00
Dean Sheather e1a4f3a16b Makefile buff-ification (#3700)
Remove old go_build_matrix and go_build_slim scripts in favor of full makefile-ification.
2022-09-02 12:58:23 +00:00
Dean Sheather 46bf265e9b fix: prevent running helm chart without valid tag (#3770)
Co-authored-by: Eric Paulsen <ericpaulsen@coder.com>
2022-09-02 21:01:30 +10:00
Mathias Fredriksson 4c18034260 fix: Prevent autobuild executor from slowing down API requests (#3726)
With just a few workspaces, the autobuild executor can slow down API
requests every time it runs. This is because we started a long running
transaction and checked all eligible (for autostart) workspaces inside
that transaction. PostgreSQL doesn't know if we're modifying rows and as
such is locking the tables for read operations.

This commit changes the behavior so each workspace is checked in its own
transaction reducing the time the table/rows needs to stay locked.

For now concurrency has been arbitrarily limited to 10 workspaces at a
time, this could be made configurable or adjusted as the need arises.
2022-09-02 13:24:47 +03:00
Ammar Bandukwala 3f73243b37 feat: improve formatting of last used (#3824) 2022-09-01 23:03:02 -05:00
Ammar Bandukwala 2d347657dc site: correct documentation on gitsshkey (#3690)
* site: correct documentation on gitsshkey

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>
2022-09-02 02:29:57 +00:00
Joe Previte 3c91b92930 docs: add comment to ResourceAvatar (#3822) 2022-09-01 18:16:20 -07:00
Ammar Bandukwala 04b03792cb feat: add last used to Workspaces page (#3816) 2022-09-02 00:08:51 +00:00
Garrett Delfosse 80e9f24ac7 feat: add loaders to ssh and terminal buttons (#3820) 2022-09-01 19:58:43 -04:00
Kyle Carberry be273a20a7 fix: Update Tailscale to add HTTP(s) latency reporting (#3819)
This was broken in Tailscale, and I'll be sending an upstream PR
to resolve it. See: https://github.com/coder/tailscale/commit/2c5af585574d4e1432f0d5dc9d02c63db3f497b0
2022-09-01 22:02:05 +00:00
dependabot[bot] 081259314b chore: bump cron-parser from 4.5.0 to 4.6.0 in /site (#3809)
Bumps [cron-parser](https://github.com/harrisiirak/cron-parser) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/harrisiirak/cron-parser/releases)
- [Commits](https://github.com/harrisiirak/cron-parser/compare/4.5.0...4.6.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 21:25:53 +00:00
dependabot[bot] ff026d4890 chore: bump eslint-plugin-react from 7.30.1 to 7.31.1 in /site (#3806)
Bumps [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) from 7.30.1 to 7.31.1.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-react/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jsx-eslint/eslint-plugin-react/compare/v7.30.1...v7.31.1)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 14:20:08 -07:00
Kyle Carberry cde036c1ab fix: Update to Go 1.19 for releases (#3814) 2022-09-01 20:10:53 +00:00
Ammar Bandukwala 30f8fd9b95 Daily Active User Metrics (#3735)
* agent: add StatsReporter

* Stabilize protoc
2022-09-01 14:58:23 -05:00
Kyle Carberry e0cb52ceea fix: Use an unnamed region instead of erroring for DERP (#3810) 2022-09-01 18:43:52 +00:00
Presley Pizzo 5f0b13795a feat: make scrollbars match color scheme (#3807) 2022-09-01 14:28:18 -04:00
dependabot[bot] 1efcd33d63 chore: bump jest-runner-eslint from 1.0.0 to 1.1.0 in /site (#3799)
Bumps [jest-runner-eslint](https://github.com/jest-community/jest-runner-eslint) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/jest-community/jest-runner-eslint/releases)
- [Changelog](https://github.com/jest-community/jest-runner-eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/jest-runner-eslint/compare/v1.0.0...v1.1.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 14:26:45 -04:00
Presley Pizzo 6d95145d3b Feat: delete template button (#3781)
* Add api call

* Extract DropDownButton

* Start adding DropdownButton to Template page

* Move stories to dropdown button

* Format

* Update xservice to delete

* Deletion flow

* Format

* Move ErrorSummary for consistency

* RBAC (unfinished) and style tweak

* Format

* Test rbac

* Format

* Move ErrorSummary under PageHeader in workspace and template

* Format

* Replace hook with onBlur

* Make style arg optional

* Format
2022-09-01 14:24:14 -04:00
Kyle Carberry 6826b976d7 fix: Add latency-check for DERP over HTTP(s) (#3788)
* fix: Add latency-check for DERP over HTTP(s)

This fixes scenarios where latency wasn't being reported if
a connection had UDP entirely blocked.

* Add inactivity ping

* Improve coordinator error reporting consistency
2022-09-01 16:41:47 +00:00
dependabot[bot] f4c8bfdc18 chore: bump webpack-dev-server from 4.9.3 to 4.10.1 in /site (#3801)
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.9.3 to 4.10.1.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.9.3...v4.10.1)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 16:26:50 +00:00
dependabot[bot] 5b9573d7c1 chore: bump just-debounce-it from 3.0.1 to 3.1.1 in /site (#3800)
Bumps [just-debounce-it](https://github.com/angus-c/just) from 3.0.1 to 3.1.1.
- [Release notes](https://github.com/angus-c/just/releases)
- [Commits](https://github.com/angus-c/just/compare/just-debounce-it@3.0.1...just-pick@3.1.1)

---
updated-dependencies:
- dependency-name: just-debounce-it
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 09:15:42 -07:00
dependabot[bot] b57b8b887d chore: bump jest-websocket-mock from 2.3.0 to 2.4.0 in /site (#3797)
Bumps [jest-websocket-mock](https://github.com/romgain/jest-websocket-mock) from 2.3.0 to 2.4.0.
- [Release notes](https://github.com/romgain/jest-websocket-mock/releases)
- [Commits](https://github.com/romgain/jest-websocket-mock/compare/v2.3.0...v2.4.0)

---
updated-dependencies:
- dependency-name: jest-websocket-mock
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-01 09:14:57 -07:00
Mathias Fredriksson f4a78c976f docs: Update direnv docs for Nix and remove .envrc (#3790) 2022-09-01 20:24:08 +10:00
Kyle Carberry 567e750659 fix: Prepend STUN nodes for DERP (#3787)
This makes Tailscale prefer STUN over DERP when possible.
2022-09-01 02:21:21 +00:00
Kyle Carberry 9bd83e5ec7 feat: Add Tailscale networking (#3505)
* fix: Add coder user to docker group on installation

This makes for a simpler setup, and reduces the likelihood
a user runs into a strange issue.

* Add wgnet

* Add ping

* Add listening

* Finish refactor to make this work

* Add interface for swapping

* Fix conncache with interface

* chore: update gvisor

* fix tailscale types

* linting

* more linting

* Add coordinator

* Add coordinator tests

* Fix coordination

* It compiles!

* Move all connection negotiation in-memory

* Migrate coordinator to use net.conn

* Add closed func

* Fix close listener func

* Make reconnecting PTY work

* Fix reconnecting PTY

* Update CI to Go 1.19

* Add CLI flags for DERP mapping

* Fix Tailnet test

* Rename ConnCoordinator to TailnetCoordinator

* Remove print statement from workspace agent test

* Refactor wsconncache to use tailnet

* Remove STUN from unit tests

* Add migrate back to dump

* chore: Upgrade to Go 1.19

This is required as part of #3505.

* Fix reconnecting PTY tests

* fix: update wireguard-go to fix devtunnel

* fix migration numbers

* linting

* Return early for status if endpoints are empty

* Update cli/server.go

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

* Update cli/server.go

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

* Fix frontend entites

* Fix agent bicopy

* Fix race condition for the last node

* Fix down migration

* Fix connection RBAC

* Fix migration numbers

* Fix forwarding TCP to a local port

* Implement ping for tailnet

* Rename to ForceHTTP

* Add external derpmapping

* Expose DERP region names to the API

* Add global option to enable Tailscale networking for web

* Mark DERP flags hidden while testing

* Update DERP map on reconnect

* Add close func to workspace agents

* Fix race condition in upstream dependency

* Fix feature columns race condition

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-08-31 20:09:44 -05:00
Colin Adler 00da01fdf7 chore: rearrange audit logging code into enterprise folder (#3741) 2022-08-31 21:12:54 +00:00
Mickael 9583e16a05 Update community-templates.md (#3785)
added kubernetes dind template
2022-08-31 15:40:41 -05:00
Cian Johnston 5362f4636e feat: show agent version in UI and CLI (#3709)
This commit adds the ability for agents to set their version upon start.
This is then reported in the UI and CLI.
2022-08-31 16:33:50 +01:00
Steven Masley aa9a1c3f56 fix: Prevent suspending owners (#3757) 2022-08-31 15:26:36 +00:00
Joe Previte e6802f0a56 refactor: use WidgetsIcon for null resources (#3754)
* refactor: replace HelpIcon w/WidgetsIcon

Based on user feedback, we believe the `WidgetsIcon` will cause less
confusion.

* fixup

* refactor: clean up types in ResourceAvatar.tsx

Before, we were using `string` for `type` in `ResourceAvatar`. This
meant it wasn't tied to the types generated from the backend.

Now it imports `WorkspaceResource` so that there is a single source of
truth and they always stay in sync.
2022-08-31 07:44:20 -07:00
Muhammad Atif Ali 774d7588dd docs: Update community-templates.md (#3778)
Added docker based deep learning and matlab coder-templates
2022-08-31 12:04:16 +00:00
Michael Eanes 126d71f41d Remove alpha warning from about (#3774)
The doc was outdated; I don't think the software is alpha anymore.
2022-08-31 03:23:56 +00:00
Kyle Carberry 6644e951d8 fix: Scope error to test functions to fix TestFeaturesService race (#3765)
Fixes #3747.
2022-08-30 19:17:57 -05:00
Bruno Quaresma 02c0100d4d fix: Use a select when parameter input has many options (#3762) 2022-08-30 15:56:36 -07:00
Garrett Delfosse 01a06e1213 feat: Add dedicated labels to agent status and OS (#3759) 2022-08-30 19:18:10 +00:00
Kyle Carberry a410ac42f5 fix: Use first user for telemetry email (#3761)
This was causing other users email to be sent, which isn't desired.
2022-08-30 19:00:23 +00:00
Bruno Quaresma f037aad456 fix: Accepts empty string for the icon prop to remove it (#3760) 2022-08-30 18:48:03 +00:00
Mathias Fredriksson 1dc0485027 fix: Use smarter quoting for ProxyCommand in config-ssh (#3755)
* fix: Use smarter quoting for ProxyCommand in config-ssh

This change takes better into account how OpenSSH executes
`ProxyCommand`s and applies quoting accordingly.

This supercedes #3664, which was reverted.

Fixes #2853

* fix: Ensure `~/.ssh` directory exists
2022-08-30 21:08:20 +03:00
Bruno Quaresma 0708e37a38 feat: Sort templates by workspaces count (#3734) 2022-08-30 17:27:33 +00:00
Muhammad Atif Ali 190310464d Update username in connecting to a workspace documenation (using JetBrains Gateway) (#3746)
if someone is not using coder-provided templates, they might not have coder as a user name.
2022-08-30 16:18:04 +00:00
Eric Paulsen 8a60ee0391 add: code-server to template examples (#3739)
* add: code-server to template examples

* add: code-server to gcp templates

* add: code-server to gcp-linux template

* update: READMEs

* update: boot disk version

* update: google provider version
2022-08-30 10:55:40 -05:00
Geoffrey Huntley 20086c1e77 feat(devenv): use direnv to invoke nix-shell (#3745) 2022-08-30 02:33:11 +00:00
Eric Paulsen c4a9be9c41 update: google provider to latest (#3743)
* update: google provider to latest

* rm: code-server
2022-08-29 19:12:26 -05:00
Spike Curtis cc346afce6 Use licenses to populate the Entitlements API (#3715)
* Use licenses for entitlements API

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

* Tests for entitlements API

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

* Add commentary about FeatureService

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

* Lint

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

* Quiet down the logs

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

* Tell revive it's ok

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-29 16:45:40 -07:00
Joe Previte 05f932b37e refactor(scripts): remove -P from ln calls (#3740) 2022-08-29 15:05:08 -07:00
Jon Ayers 053fe6ff61 feat: add panic recovery middleware (#3687) 2022-08-29 17:00:52 -05:00
Bruno Quaresma 3cf17d34e7 refactor: Redesign auth cli page and add workspaces link (#3737) 2022-08-29 16:57:54 -03:00
Spike Curtis 779c446a6e cli prints license warnings (#3716)
* cli prints license warnings

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

* Satisfy the linter

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-29 11:30:06 -07:00
Bruno Quaresma 62f686c003 fix: Templates table columns width (#3731) 2022-08-29 14:49:04 -03:00
Colin Adler 6285d65b6a fix: remove (http.Server).ReadHeaderTimeout (#3730)
* fix: remove `(http.Server).ReadHeaderTimeout`

Fixes https://github.com/coder/coder/issues/3710. It caused some race
condition for websockets where the server sent the first message.

* comment why disabled
2022-08-29 12:07:49 -05:00
Kyle Carberry 611ca55458 fix: Use "data" scheme when creating parameters from the site (#3732)
Fixes #3691.
2022-08-29 16:32:57 +00:00
Steven Masley 34d902ebf1 fix: Fix properly selecting workspace apps by agent (#3684) 2022-08-29 08:56:52 -04:00
Mathias Fredriksson dc9b4155e0 feat: Generate DB unique constraints as enums (#3701)
* feat: Generate DB unique constraints as enums

This fixes a TODO from #3409.
2022-08-29 14:56:51 +03:00
Mathias Fredriksson f4c5020f63 fix: Print postgres-builtin-url to stdout without formatting (#3727)
This allows use-cases like `eval $(coder server postgres-builtin-url)`.
2022-08-29 11:37:18 +00:00
Dean Sheather b9b9c2fb9f fix: mount TLS secret in helm chart (#3717) 2022-08-27 15:03:10 +00:00
Garrett Delfosse ccabec6dd1 fi stop tracing 4xx http status codes as errors (#3707) 2022-08-26 15:18:42 +00:00
Spike Curtis 23f61fce2a CLI: coder licensese delete (#3699)
Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-26 08:15:46 -07:00
Mathias Fredriksson 98a6958f10 Revert "fix: Avoid double escaping of ProxyCommand on Windows (#3664)" (#3704)
This reverts commit 123fe0131e.
2022-08-26 17:52:25 +03:00
Mathias Fredriksson 6a00baf235 fix: Transform branch name to valid Docker tag for dogfood (#3703) 2022-08-26 17:38:40 +03:00
Mathias Fredriksson c8f8c95f6a feat: Add support for renaming workspaces (#3409)
* feat: Implement workspace renaming

* feat: Add hidden rename command (and data loss warning)

* feat: Implement database.IsUniqueViolation
2022-08-26 12:28:38 +03:00
Presley Pizzo 623fc5baac feat: condition Audit log on licensing (#3685)
* Update XService

* Add simple wrapper

* Add selector

* Condition page

* Condition link

* Format and lint

* Integration test

* Add username to api call

* Format

* Format

* Fix link name

* Upgrade xstate/react to fix crashing tests

* Fix tests

* Format

* Abstract strings

* Debug test

* Increase timeout

* Add comments and try shorter timeout

* Use PropsWithChildren

* Undo PropsWithChildren, try lower timeout

* Format, lower timeout
2022-08-25 19:20:31 -04:00
Spike Curtis ca3811499e DELETE license API endpoint (#3697)
* DELETE license API endpoint

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

* Fix new lint stuff

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-25 14:04:31 -07:00
Dean Sheather 14a9576b77 Auto import kubernetes template in Helm charts (#3550) 2022-08-26 05:32:35 +10:00
Joe Previte 94e96fa40b chore: enable react/no-array-index-key eslint (#3696)
* chore: enable react/no-array-index-key eslint

* fix: add missing key to ResourcesTable
2022-08-25 11:20:24 -07:00
Dean Sheather 8a446837d4 chore: remove exa -> ls and bat -> cat replacements from dogfood img (#3695) 2022-08-26 04:03:27 +10:00
Garrett Delfosse 7a77e55bd4 fix: match term color (#3694) 2022-08-25 16:34:37 +00:00
Garrett Delfosse b412cc1a4b fix: use correct response writer for tracing middle (#3693) 2022-08-25 11:24:43 -05:00
Mathias Fredriksson 78a24941fe feat: Add codersdk.NullTime, change workspace build deadline (#3552)
Fixes #2015

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-08-25 19:10:42 +03:00
Roman Zubov a21a6d2f4a docs: replaced manual up next blocks with doc tag in workspaces.md (#3023)
* docs: replaced manual up next blocks with doc tag in workspaces.md

* replaced up next blocks with <doc page=""> tags

* revert back to markdown

now that we updated how these links work, we can have them as markdown on github and as cards on the docs website.

Co-authored-by: Anton Korzhuk <antonkorzhuk@gmail.com>
2022-08-25 08:26:04 -07:00
Spike Curtis 4de1fc8339 CLI: coder licenses list (#3686)
* Check GET license calls authz

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

* CLI: coder licenses list

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-25 08:24:39 -07:00
Garrett Delfosse a05fad4efd fix: stop tracing static file server (#3683) 2022-08-25 09:37:59 -04:00
Steven Masley 6e496077ae feat: Support search query and --me in workspace list (#3667) 2022-08-24 17:43:41 -04:00
Kira Pilot cf0d2c9bbc added react-i18next to FE (#3682)
* added react-i18next

* fixing typo

* snake case to camel case

* typo

* clearer error in catch block
2022-08-24 17:28:02 -04:00
Joe Previte e6b6b7f610 chore: upload playwright videos on failure (#3677) 2022-08-24 13:45:03 -07:00
Steven Masley 0b53b06fc6 chore: Make member role struct match site roles (#3671) 2022-08-24 15:58:57 -04:00
Spike Curtis 076c4a0aa8 Fix authz test for GET licenses (#3681)
Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-24 12:25:37 -07:00
Spike Curtis 9e35793b43 Enterprise rbac testing (#3653)
* WIP refactor Auth tests to allow enterprise

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

* enterprise RBAC testing

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

* Fix import ordering

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-24 12:05:46 -07:00
Joe Previte 254e91a08f Update stale.yaml (#3674)
- remove close-issue-reason (only valid in 5.1.0)
- add days-before-issue-stale 30
2022-08-24 12:02:12 -07:00
Garrett Delfosse 5d7c4092ac fix: end long lived connection traces (#3679) 2022-08-24 14:57:31 -04:00
Spike Curtis c9bce19d88 GET license endpoint (#3651)
* GET license endpoint

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

* SDK GetLicenses -> Licenses

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-24 18:44:22 +00:00
Kira Pilot da54874958 fixed users test (#3676) 2022-08-24 14:10:41 -04:00
Kira Pilot 57c202d112 Template settings fixes/kira pilot (#3668)
* using hours instead of seconds

* checking out

* added ttl tests

* added description validation  and tests

* added some helper text

* fix typing

* Update site/src/pages/TemplateSettingsPage/TemplateSettingsForm.tsx

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

* ran prettier

* added ttl of 0 test

* typo

* PR feedback

Co-authored-by: Cian Johnston <cian@coder.com>
2022-08-24 14:07:56 -04:00
Garrett Delfosse 4e3b212707 make agent 'connecting' visually different from 'connected' (#3675) 2022-08-24 17:54:45 +00:00
Kyle Carberry 4f8270d95b fix: Exclude time column when selecting build log (#3673)
Closes #2962.
2022-08-24 12:04:33 -05:00
Garrett Delfosse 1400d7cd84 fix: correctly link agent name in app urls (#3672) 2022-08-24 16:49:03 +00:00
Eric Paulsen ca3c0490e0 chore: k8s example persistence & coder images (#3619)
* add: persistence & coder images

* add: code-server

* chore: README updates

* chore: README example
2022-08-24 11:23:02 -05:00
Mathias Fredriksson 123fe0131e fix: Avoid double escaping of ProxyCommand on Windows (#3664)
Fixes #2853
2022-08-24 19:12:40 +03:00
Kyle Carberry 09142255e6 fix: Add consistent use of coder templates init (#3665)
Closes #2303.
2022-08-24 11:40:36 -04:00
Kyle Carberry 706bceb7e7 fix: Remove reference to coder rebuild command (#3670)
Closes #2464.
2022-08-24 15:35:46 +00:00
Cian Johnston eba753ba87 fix: template: enforce bounds of template max_ttl (#3662)
This PR makes the following changes:

- enforces lower and upper limits on template `max_ttl_ms`
- adds a migration to enforce 7-day cap on `max_ttl`
- allows setting template `max_ttl` to 0
- updates template edit CLI help to be clearer
2022-08-24 15:45:14 +01:00
Mathias Fredriksson 343d1184b2 fix: Clean up coder config-ssh dry-run behavior (#3660)
This commit also drops old deprecated code.

Fixes #2982
2022-08-24 16:58:46 +03:00
Mathias Fredriksson 7a71180ae6 chore: Enable comments for database dump / models (#3661) 2022-08-24 12:44:30 +00:00
Ammar Bandukwala 253e6cbffa web: fix template permission check (#3652)
Resolves #3582
2022-08-23 23:44:32 +00:00
Spike Curtis 184f0625e1 coder licenses add CLI command (#3632)
* coder licenses add CLI command

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

* Fix up lint

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

* Fix t.parallel call

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

* Code review improvements

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

* Lint

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-23 13:55:39 -07:00
Cian Johnston 6dacf70898 fix: disable AccountForm when user is not allowed edit users (#3649)
* RED: add unit tests for AccountForm username field
* GREEN: disable username field and button on account form when user edits are not allowed

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-08-23 20:19:26 +00:00
Garrett Delfosse b9dd566804 fix scrollbar on ssh key view (#3647) 2022-08-23 15:22:42 -04:00
Mathias Fredriksson e44f7adb7e feat: Set SSH env vars: SSH_CLIENT, SSH_CONNECTION and SSH_TTY (#3622)
Fixes #2339
2022-08-23 21:19:57 +03:00
Garrett Delfosse 9c0cd5287c fix: clarify we download templates on template select (#3296)
Co-authored-by: Joe Previte <jjprevite@gmail.com>
Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
2022-08-23 17:30:46 +00:00
Mathias Fredriksson 5025fe2fa0 fix: Protect circular buffer during close in reconnectingPTY (#3646) 2022-08-23 16:07:31 +00:00
Presley Pizzo 49de44c76d feat: Add LicenseBanner (#3568)
* Extract reusable Pill component

* Make icon optional

* Get pills in place

* Rough styling

* Extract Expander component

* Fix alignment

* Put it in action - type error

* Hide banner by default

* Use generated type

* Move PaletteIndex type

* Tweak colors

* Format, another color tweak

* Add stories

* Add tests

* Update site/src/components/Pill/Pill.tsx

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

* Update site/src/components/Pill/Pill.tsx

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

* Comments

* Remove empty story, improve empty test

* Lint

Co-authored-by: Kira Pilot <kira@coder.com>
2022-08-23 11:26:22 -04:00
Mathias Fredriksson f7ccfa2ab9 feat: Set CODER=true in workspaces (#3637)
Fixes #2340
2022-08-23 14:29:01 +03:00
Colin Adler 8343a4f199 chore: cleanup go.mod (#3636) 2022-08-22 22:40:11 -05:00
Jon Ayers a7b49788f5 chore: deduplicate OAuth login code (#3575) 2022-08-22 18:13:46 -05:00
Ammar Bandukwala a07ca946c3 Increase default auto-stop to 12h (#3631)
Resolves #3462.

And, clarify language to resolve #3509.
2022-08-22 17:24:15 -05:00
Ben Potter 8ca3fa9712 fix: use hardcoded "coder" user for AWS and Azure (#3625) 2022-08-22 22:19:30 +00:00
Spike Curtis b101a6f3f4 POST license API endpoint (#3570)
* POST license API

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

* Support interface{} types in generated Typescript

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

* Disable linting on empty interface any

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

* Code review updates

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

* Enforce unique licenses

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

* Renames from code review

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

* Code review renames and comments

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-22 15:02:50 -07:00
dependabot[bot] 85acfdf0dc chore: bump msw from 0.44.2 to 0.45.0 in /site (#3629)
Bumps [msw](https://github.com/mswjs/msw) from 0.44.2 to 0.45.0.
- [Release notes](https://github.com/mswjs/msw/releases)
- [Changelog](https://github.com/mswjs/msw/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mswjs/msw/compare/v0.44.2...v0.45.0)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-22 16:56:39 -04:00
Ammar Bandukwala 2ee6acb2ad Upgrade frontend to React 18 (#3353)
Co-authored-by: Kira Pilot <kira.pilot23@gmail.com>
2022-08-22 15:42:06 -05:00
Ammar Bandukwala 6fde537f9c web: use seconds in max TTL input (#3576)
Milliseconds are more difficult to deal with due to
all of the zeros.

Also, describe this feature as "auto-stop" to be
consistent with our Workspace page UI and CLI. "ttl"
is our backend lingo which should eventually be updated.
2022-08-22 20:35:17 +00:00
Ammar Bandukwala 5e36be8cbb docs: remove architecture diagram (#3615)
The diagram was more confusion than helpful.
2022-08-22 10:56:10 -05:00
Kyle Carberry 58d29264aa feat: Add template icon to the workspaces page (#3612)
This removes the last built by column from the page. It seemed
cluttered to have both on the page, and is simple enough to
click on the workspace to see additional info.
2022-08-22 09:42:11 -05:00
Dean Sheather 369a9fb535 fix: add writeable home dir to docker image (#3603) 2022-08-22 19:43:13 +10:00
Eric Paulsen 68e17921f0 fix: tooltip 404 (#3618) 2022-08-21 18:50:36 -05:00
Kyle Carberry b0fe9bcdd1 chore: Upgrade to Go 1.19 (#3617)
This is required as part of #3505.
2022-08-21 22:32:53 +00:00
Ammar Bandukwala d37fb054c8 docs: outdent remote desktop docs (#3614)
Resolves #3590
2022-08-21 01:59:40 +00:00
Bruno Quaresma 54b8e794ce feat: Add emoji picker for template icons (#3601) 2022-08-19 16:42:05 -04:00
Bruno Quaresma a4c90c591d feat: Add icon to the template page (#3604) 2022-08-19 15:37:16 -03:00
Spike Curtis 690e6c6585 Check AGPL code doesn't import enterprise (#3602)
* Check AGPL code doesn't import enterprise

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

* use error/log instead of echo/exit

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-19 17:49:08 +00:00
Joe Previte 91bfcca287 fix(ui): decrease WorkspaceActions popover padding (#3555)
There was too much padding on the WorkspaceActions dropdown. This fixes
that.
2022-08-19 09:58:31 -07:00
Bruno Quaresma c14a4b92ed feat: Display and edit template icons in the UI (#3598) 2022-08-19 13:09:07 -03:00
Joe Previte e938e8577f fix: add missing && \ in Dockerfile (#3594)
* fix: add missing && \ in Dockerfile

* fixup: add goboring after PATH goboring
2022-08-19 15:41:17 +00:00
Kyle Carberry 985eea6099 fix: Update icon when metadata is changed (#3587)
This was causing names to become empty! Fixes #3586.
2022-08-19 10:11:54 -05:00
Joe Previte c417115eb1 feat: add cmake, nfpm to dogfood dockerfile (#3558)
* feat: add cmake, nfpm to dogfood dockerfile

* fixup: formatting

* Update dogfood/Dockerfile

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

Co-authored-by: Cian Johnston <cian@coder.com>
2022-08-19 15:10:56 +00:00
Mathias Fredriksson 544bf01fbb chore: Update coder/coder provider in example templates (#3581)
Additionally, a convenience script was added to
`examples/update_template_versions.sh` to keep the templates up-to-date.

Fixes #2966
2022-08-19 17:18:11 +03:00
Bruno Quaresma 80f042f01b feat: Add icon to templates (#3561) 2022-08-19 13:17:35 +00:00
Cian Johnston 57f3410009 cli: remove confirm prompt when starting a workspace (#3580) 2022-08-19 11:08:56 +01:00
Mathias Fredriksson 3fdae47b87 fix: Shadow err in TestProvision_Cancel to fix test race (#3579)
Fixes #3574
2022-08-19 11:56:28 +03:00
Eric Paulsen 4ba3573632 fix: quickstart 404 (#3564) 2022-08-18 18:47:12 -05:00
Jon Ayers f6b0835982 fix: avoid processing updates to usernames (#3571)
- With the support of OIDC we began processing updates to a user's
  email and username to stay in sync with the upstream provider. This
  can cause issues in templates that use the user's username as a stable
  identifier, potentially causing the deletion of user's home volumes.
- Fix some faulty error wrapping.
2022-08-18 17:56:17 -05:00
Cian Johnston 04c5f924d7 fix: ui: workspace bumpers now honour template max_ttl (#3532)
- chore: WorkspacePage: invert workspace schedule bumper logic for readibility
- fix: make workspace bumpers honour template max_ttl
- chore: refactor workspace schedule bumper logic to util/schedule.ts and unit test separately
2022-08-18 23:32:23 +01:00
Bruno Quaresma 7599ad4bf6 feat: Add template settings page (#3557) 2022-08-18 16:58:01 -03:00
Joe Previte aabb72783c docs: update CONTRIBUTING requirements (#3541)
* docs: update CONTRIBUTING requirements

* Update docs/CONTRIBUTING.md

* refactor: remove dev from Makefile

* fixup: add linux section
2022-08-18 17:11:58 +00:00
Dean Sheather 55890df6f1 feat: add helm README, install guide, linters (#3268) 2022-08-19 02:41:23 +10:00
Dean Sheather 3610402cd8 Use new table formatter everywhere (#3544) 2022-08-19 02:41:00 +10:00
Kyle Carberry c43297937b feat: Add Kubernetes and resource metadata telemetry (#3548)
Fixes #3524.
2022-08-18 15:57:46 +00:00
Mathias Fredriksson f1423450bd fix: Allow terraform provisions to be gracefully cancelled (#3526)
* fix: Allow terraform provisions to be gracefully cancelled

This change allows terraform commands to be gracefully cancelled on
Unix-like platforms by signaling interrupt on provision cancellation.

One implementation detail to note is that we do not necessarily kill a
running terraform command immediately even if the stream is closed. The
reason for this is to allow for graceful cancellation even in such an
event. Currently the timeout is set to 5 minutes by default.

Related: #2683

The above issue may be partially or fully fixed by this change.

* fix: Remove incorrect minimumTerraformVersion variable

* Allow init to return provision complete response
2022-08-18 17:03:55 +03:00
Mathias Fredriksson 6a0f8ae9cc fix: Add SIGHUP and SIGTERM handling to coder server (#3543)
* fix: Add `SIGHUP` and `SIGTERM` handling to `coder server`

To prevent additional signals from aborting program execution, signal
handling was moved to the beginning of the main function, this ensures
that signals stays registered for the entire shutdown procedure.

Fixes #1529
2022-08-18 16:25:32 +03:00
Jon Ayers 380022fe63 fix: update oauth token on each login (#3542) 2022-08-17 23:06:03 -05:00
Jon Ayers c3eea98db0 fix: use unique ID for linked accounts (#3441)
- move OAuth-related fields off of api_keys into a new user_links table
- restrict users to single form of login
- process updates to user email/usernames for OIDC
- added a login_type column to users
2022-08-17 18:00:53 -05:00
Cian Johnston 53d1fb36db update-alternatives to ensure gofmt is goboring gofmt (#3540) 2022-08-17 20:03:44 +00:00
whitney-coder d6351a6b9f Update README.md (#3539)
Minor grammatical change on line 14
2022-08-17 14:48:41 -05:00
Bruno Quaresma 546157b63e feat: Make template name editable (#3538) 2022-08-17 19:04:00 +00:00
Kira Pilot 4b646cc4fa fix: hiding agent status on stopped workspaces (#3512)
* hiding agent status on a stopped workspaace

resolves #3484

* run prettier and lint

* Update site/src/components/Resources/Resources.tsx

Co-authored-by: Joe Previte <jjprevite@gmail.com>

* running prettier

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-08-17 14:37:54 -04:00
Spike Curtis acd0cd66f6 coder features list CLI command (#3533)
* AGPL Entitlements API

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

* Generate typesGenerated.ts

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

* AllFeatures -> FeatureNames

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

* Features CLI command

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

* Validate columns

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

* Tests for features list CLI command

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

* Drop empty EntitlementsRequest

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

* Fix dump.sql generation

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-17 11:26:16 -07:00
Spike Curtis 5c898d0c83 Fix archive.sh for LICENSE files (#3535)
Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-17 10:27:52 -07:00
Kyle Carberry c3f946737c fix: Strip session_token cookie from app proxy requests (#3528)
Fixes coder/security#1.
2022-08-17 17:09:45 +00:00
Noah Huppert 000e1a5ef2 Fixed env block in Emacs IDE docs (#3534) 2022-08-17 16:30:45 +00:00
Dean Sheather a872330a8d feat: add generic table formatter (#3415) 2022-08-18 02:28:22 +10:00
Spike Curtis b1b2d1b2b2 AGPL Entitlements API (#3523)
* AGPL Entitlements API

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

* Generate typesGenerated.ts

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

* AllFeatures -> FeatureNames

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-17 09:02:36 -07:00
Spike Curtis 5817c6ac7f Build enterprise coder binary by default (#3517)
* Build enterprise coder binary by default

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

* Add --agpl to develop.sh

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

* Add --agpl flag to archive.sh

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

* shell format

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

* Move AGPL back to LICENSE, explain enterprise license is forthcoming

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

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-17 09:02:25 -07:00
Steven Masley 4be61d9250 fix: Role assign ui fixes (#3521)
Co-authored-by: Kira Pilot <kira@coder.com>
2022-08-16 10:39:42 -05:00
Ben Potter 4b6a82f92a chore: rename to "template push" in docs (#3525) 2022-08-16 14:52:31 +00:00
Steven Masley 01dd35f1ba chore: Rename 'admin' to 'owner' (#3498)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-08-15 14:40:19 -05:00
Steven Masley 2306d2c709 chore: Fix misspelled "referrer" in site.go (#3507) 2022-08-15 14:12:34 +00:00
Mathias Fredriksson e749070193 chore: Update readme with note about embedded database (#3488) 2022-08-15 12:32:22 +03:00
Jon Ayers 301727d1fc chore: improve dump error output (#3499)
* chore: improve dump error output

- Properly report the error that occurs during the DB connection retry
  loop.
- Fail fatally if migration is unsuccessful.
2022-08-12 22:15:13 -05:00
Ammar Bandukwala 8cf82112ad docs: document additional roles (#3496)
Co-authored-by: Steven Masley <stevenmasley@coder.com>
2022-08-12 22:42:16 +00:00
Steven Masley 40e68cb80b feat: Add template-admin + user-admin role for managing templates + users (#3490)
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-08-12 17:27:48 -05:00
Bruno Quaresma c41261cf6e fix: Remove unexpected break lines when copy logs (#3492) 2022-08-12 19:18:41 +00:00
Bruno Quaresma 351d55e1f4 chore: Minor table design changes (#3494) 2022-08-12 16:18:03 -03:00
Kyle Carberry 3b951f77fb fix: Unskip SuspendAnotherUser test (#3430)
It wasn't clear why this was skipped, it seems accidental.
2022-08-12 19:12:44 +00:00
Oxylibrium 0a46b1e59d chore: remove swr and dead code (#3495) 2022-08-12 15:06:40 -04:00
Mathias Fredriksson 010f64e8e9 fix: Enable goleak for cli tests (#3370) 2022-08-12 21:02:10 +03:00
Bruno Quaresma 0e8c68ebc5 chore: Increase border radius (#3493) 2022-08-12 14:58:14 -03:00
Muhammad Atif Ali c3fcf7c953 chore: renamed coder template edit flags in coder CLI (#3471)
Use `-` over `_` for cli flags
2022-08-12 10:21:42 -05:00
Kyle Carberry b3d3b8ba0f fix: Stop multiple buttons from compounding in the workspace action dropdown (#3482)
The variadic function on an object doesn't clone the inner array.

This was causing the `secondary` property to accumulate more and
more button types as time went on!

Fixes #3154.
2022-08-12 13:19:52 +00:00
Kyle Carberry 16c12e976e chore: Improve agent logging (#3483) 2022-08-12 07:01:00 -05:00
Kyle Carberry ca342067b3 fix: Remove typo in policy.rego 2022-08-11 23:33:50 -05:00
Ammar Bandukwala d7b96f7d58 Correct spelling of macOS (#3478)
* Correct spelling of macOS

* fixup! Correct spelling of macOS

* fixup! Correct spelling of macOS
2022-08-11 21:22:06 -04:00
Jon Ayers 923c212960 chore: add zstd to dogfood image (#3479) 2022-08-11 17:48:49 -05:00
Steven Masley 3ae42f4de9 chore: Update rego to be partial execution friendly (#3449)
- Improves performance of batch authorization calls
- Enables possibility to convert rego auth calls into SQL WHERE clauses
2022-08-11 22:07:48 +00:00
Bruno Quaresma 4a17e0d91f feat: Add setup page (#3476) 2022-08-11 17:22:46 +00:00
Sagar Vora 604f211674 fix: replace broken link with Github contributors graph (#3472) 2022-08-11 14:35:51 +00:00
Kira Pilot 6122df6f1f feature: gate audit log by permissions (#3464)
* pairing

* restricting audit route

resolvees #3460

* updated tests

* fixing lint

* useSelector instead of useActor
2022-08-11 09:34:45 -04:00
Ammar Bandukwala 4e6645af50 docs: outdent generic quickstart (#3467) 2022-08-10 21:53:35 -05:00
Jon Ayers 426b30ed16 fix: add missing dependencies to dogfood image (#3470) 2022-08-11 01:24:56 +00:00
Eric Paulsen 272962cfae docs: add upgrade page & update getting started (#3439) 2022-08-10 17:56:21 -05:00
Presley Pizzo 5d40b1f0f4 feat: Add switches for auto-start and auto-stop (#3358)
* Add elements

* Add Loading story

* Make form show empty values when manual

* Make form depend on switches

* Fix style

* Format

* Update unit tests

* Tweaks

* Update storybook

* Move util files

* Pull out more util functions

* Pull out strings

* Add border to section

* Make min ttl 1

* Format

* Fix import

* Fix validation for falsey values

* Format and fix tests

* Put switches in form, persist form state

* Fix bug

* Remove helper text when disabled

* Fix storybook

* Revert "Remove helper text when disabled"

This reverts commit a6271ca6c4.

* Format

* Use nicer function to set values

* Format
2022-08-10 22:03:15 +00:00
Ben Potter cee0d1f848 chore: add metadata to example templates (#3451) 2022-08-10 16:34:17 -05:00
Mathias Fredriksson 95f26f74b6 fix: Close response body in cli server test (#3459) 2022-08-10 16:30:46 +00:00
Kyle Carberry d6d9cf9b30 fix: Downgrade embedded PostgreSQL (#3453)
This was causing a new data path to occur, which broke existing installs.
It needs to use the same path and upgrade instead.
2022-08-10 10:08:24 -05:00
Kyle Carberry fd73d6dd0d fix: Reduce variables needed for Docker template (#3442)
* fix: Reduce variables needed for Docker template

This should make initial setup a bit simpler!

* Fix for M2 Macbooks

PostgreSQL 13 doesn't support the M series architecture.

* Fix name <-> id swap

* Update Docker provider to remove host requirement

Co-authored-by: Kyle Carberry <kyle@air.local>
2022-08-10 14:45:05 +00:00
Bruno Quaresma 758eb21b36 feat: Support booleans for parameters input (#3437) 2022-08-10 10:41:26 -03:00
Ammar Bandukwala f28cd15706 docs: remove incorrect SSH key info (#3448) 2022-08-09 22:15:18 -05:00
Ammar Bandukwala 3ceee76784 docs: explain resource metadata (#3447) 2022-08-09 20:21:26 -05:00
Ammar Bandukwala c73f708678 docs: remove configuring prefix from IDEs (#3446) 2022-08-09 20:10:09 -05:00
Ammar Bandukwala 815bf1b668 docs: fix IDE icon (#3445) 2022-08-09 20:07:51 -05:00
Ammar Bandukwala 88c9f31007 docs: explain how to display secrets (#3443) 2022-08-09 23:45:30 +00:00
Ammar Bandukwala fd59e2e812 add metadata to dogfood template (#3444) 2022-08-09 23:40:12 +00:00
Steven Masley db665e7261 chore: Drop resource_id support in rbac system (#3426) 2022-08-09 18:16:53 +00:00
Mathias Fredriksson ccf6f4e7ed chore: Use contexts with timeout in coderd tests (#3381) 2022-08-09 20:17:00 +03:00
Bruno Quaresma 690ba661a7 feat: Add metadata support to the UI (#3431) 2022-08-09 16:49:06 +00:00
Kyle Carberry 53400c6205 fix: Check if an API error has data before checking the message (#3427)
This was causing the app to crash with an error. I found this manually
by looking through the obfuscated sources in DevTools. It's a
data-point for #3425 though!
2022-08-09 14:26:18 +00:00
Kyle Carberry e1da2b6467 fix: Don't fetch resources when a workspace is building (#3424)
Fixes #3423.
2022-08-09 14:07:01 +00:00
Mathias Fredriksson c0cc8b9935 fix: Improve friendly validation error messages (#3390)
* fix: Add validations to `(*codersdk.Error).Friendly`

* fix: Add named validators for template and workspace name
2022-08-09 14:25:23 +03:00
Kyle Carberry f62e1ede77 feat: Add support for GitHub Enterprise authentication (#3422)
This was manually tested with GitHub Enterprise v3.6.0-rc1.
2022-08-08 20:49:51 -05:00
Kyle Carberry 7bdb8ff9cf feat: Add workspace metrics export to Prometheus (#3421)
This adds workspace totals indexed by status. It could be any
codersdk.ProvisionerJobStatus.
2022-08-09 01:08:42 +00:00
Kira Pilot e62677efab feat: add audit page title, subtitle, and CLI snippet (#3419)
* resolves #3356

* scaffolded out new audit page header

resolves #3357

* added tests and stories

* run prettier
2022-08-08 21:08:36 -04:00
Spike Curtis 049e7cb5df azure-linux example template (#3348)
* azure-linux example template

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

* Use azurerm_linux_virtual_machine and wait for attachment

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

* Use azure-instance-identity

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-08 15:25:20 -07:00
Kyle Carberry a848e71f58 fix: Make the twitter handle lowercase in README (#3413)
The uppercase was bothering...
2022-08-08 13:17:38 -05:00
Kyle Carberry 42bac09c1a fix: Sort workspace agents by name (#3407)
Fixes #2778.
2022-08-08 12:25:29 -05:00
Kyle Carberry d275e52a41 fix: Add godoc badge to README (#3412)
This helps allude to the idea that Coder provides an API as
seen in #3411.

This also fixes the codecov badge from always being red ;p
2022-08-08 12:16:40 -05:00
Kira Pilot eb7d947d10 resolves #3356 (#3408) 2022-08-08 12:23:01 -04:00
Kyle Carberry 9c12b4ed8e chore: Add nix shell for simple development setup (#3399)
* chore: Add nix shell for simple development setup

This enables contributors using Nix to set up their environment with ease.

* improve nix style, flake output schema

* fix error message

* Update scripts/build_go_slim.sh

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

* Update scripts/build_go_slim.sh

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

* Add UTC default for timezone and remove unnecessary goreleaser dependency

* Skip TZ test if localtime does not exist

Co-authored-by: Charlie Moog <moogcharlie@gmail.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-08-08 15:49:12 +00:00
Kyle Carberry 3279504cbe feat: Add active users prometheus metric (#3406)
This  allows deployments using our Prometheus export t determine
the number of active users in the past hour.

The interval is an hour to align with API key last used refresh times.

SSH connections poll to check shutdown time, so this will be accurate
even on long-running connections without dashboard requests.
2022-08-08 10:09:46 -05:00
Ammar Bandukwala 13a2014d7f docs: fix up port-forwarding (#3403)
- Improve English
- Make new page live in manifest.json
- Add icon
- Outdent page to root
2022-08-07 22:22:47 +00:00
mark-theshark 8d4b6086f6 chore: docs: add port-forwarding options (CLI & ssh) (#3394)
* chore: docs: add port-forwarding options

* fix: code type

Co-authored-by: Eric Paulsen <eric@Erics-MacBook-Air.local>
2022-08-07 17:30:15 -04:00
mark-theshark 44a826dc06 docs: fix address specification in Docker quickstart (#3396) 2022-08-07 14:52:55 -05:00
Mathias Fredriksson 1fb274cbda fix: Disallow args for config-ssh subcommand in cli (#3393) 2022-08-06 20:56:42 +03:00
Mathias Fredriksson b10a1b84e5 fix: Fix close in pty and ptytest (#3392) 2022-08-05 21:31:54 +03:00
Ben Potter f14efd1a2b chore: alphabetize template list (#3363) 2022-08-05 13:03:22 -05:00
Cian Johnston 854bb5dbeb fix: post-hoc testutil fix (#3391) 2022-08-05 16:09:20 +00:00
Abhineet Jain e7bc01383c fix: handle workspace errors (#3341) 2022-08-05 10:38:07 -05:00
Cian Johnston 01fe5e668e chore: add testutil.Eventually and friends (#3389)
This PR adds a `testutil` function aimed to replace `require.Eventually`.

Before:
```go
require.Eventually(t, func() bool { ... }, testutil.WaitShort, testutil.IntervalFast)
```

After:
```go
require.True(t, testutil.EventuallyShort(t, func(ctx context.Context) bool { ... }))

// or the full incantation if you need more control
ctx, cancel := context.WithTimeout(ctx.Background(), testutil.WaitLong)
require.True(t, testutil.Eventually(t, ctx, func(ctx context.Context) bool { ... }, testutil.IntervalSlow))
```

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-08-05 16:34:44 +01:00
Mathias Fredriksson 46d64c624a fix: Add ps.Kill/Wait to test cleanup in ptytest.Start (#3387) 2022-08-05 13:35:33 +03:00
Mathias Fredriksson fb9fca8bc9 fix: Ensure terraform tests have a cache path and logger (#3161)
* fix: Ensure terraform tests have a cache path and logger

* fix: Protect against concurrent `terraform init`
2022-08-04 20:37:07 +03:00
Kyle Carberry ad20b23178 fix: Move state pull output to stdout (#3382)
* fix: Move state pull output to stdout

Fixes #1645.

* Update cli/state.go

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>
2022-08-04 15:33:59 +00:00
Kyle Carberry 303b280e0e fix: Associate spot instances with their instance IDs for auth (#3383)
Fixes #2162.
2022-08-04 10:20:56 -05:00
Ben Potter 075454cce8 chore: use consistent button type for settings (#3362) 2022-08-04 10:15:35 -05:00
David Wahler 9f54fa8e52 Make gcp-linux example template use a non-root user (#2480)
* make gcp-linux example template use a non-root user

* don't try to create user account if it already exists

* upgrade to debian-10 image since debian-9 is no longer available
2022-08-03 18:07:10 -05:00
Ben Potter fd4e2cc331 chore: improve contrast for terminal overlay (#3375) 2022-08-03 15:39:38 -05:00
Ammar Bandukwala 8a4438895b Add fish to dogfood (#3373) 2022-08-03 18:21:34 +00:00
dependabot[bot] b6774ead2c chore: bump eslint-plugin-jest from 26.6.0 to 26.7.0 in /site (#3334)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 26.6.0 to 26.7.0.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v26.6.0...v26.7.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-03 14:15:47 -04:00
Ben Potter 7e1caa7086 chore: add helper text to help admins create new templates (#3364) 2022-08-03 17:27:39 +00:00
Kyle Carberry 69664ed168 fix: Use "virtual_machine_id" for instance identity with Azure (#3355)
This was using the wrong property, causing automatic auth to break.
2022-08-03 12:19:13 -05:00
Ben Potter 420fae886a chore: link to the hosted docs site instead of GitHub (#3365) 2022-08-03 17:04:45 +00:00
Mathias Fredriksson 6e426cf47d fix: Fix goleak in cli TestSSH/ForwardAgent test (#3369) 2022-08-03 16:06:40 +03:00
Mathias Fredriksson 9a023dd63b fix: Skip waiting for exit output in SSH test (#3368)
This seems to have caused flakes on Windows, the reason could be that
the input is lost due to writing to stdin before the shell is ready, or
simply that the command wasn't echoed (for the same reason).

We no longer need to consume the output since #2122 has been fixed, so
this might remove the flake in the latter case.

Ideally we would wait for the prompt to be present, but since we are
spawning the users shell, we have no control of what the prompt looks
like. In CI we can make assumption but even then it could change in the
future.
2022-08-03 13:37:12 +03:00
Mathias Fredriksson 1d6283bdac fix: Improve debuggability of ptytest failures (#3367)
Since we were not failing tests with `require` the error output was
somewhat hidden in the stream of log messages. This change standardizes
`ptytest` logging and failing to improve visibility.
2022-08-03 13:27:20 +03:00
Ammar Bandukwala 8f338782db Make minor improvements to Dogfood README (#3361) 2022-08-02 21:14:12 +00:00
Ammar Bandukwala 81e292be44 Add dogfood image (#3350) 2022-08-02 20:20:54 +00:00
Abhineet Jain 8bcf23e60a fix: handle create workspace errors (#3346) 2022-08-02 13:19:00 -04:00
Mathias Fredriksson 83c63d4a63 fix: Improve shutdown procedure of ssh, portforward, wgtunnel cmds (#3354)
* fix: Improve shutdown procedure of ssh, portforward, wgtunnel cmds

We could turn it into a practice to wrap `cmd.Context()` so that we have
more fine-grained control of cancellation. Sometimes in tests we may be
running commands with a context that is never canceled.

Related to #3221

* fix: Set ssh session stderr to stderr
2022-08-02 17:44:59 +03:00
Abhineet Jain 5ae19f097e fix: chromatic workflow filter (#3352) 2022-08-02 04:23:32 -04:00
Ammar Bandukwala bd785ddd87 Fix docs links (#3351) 2022-08-02 01:22:14 -04:00
Jon Ayers c1885dab27 fix: NPE when no arg provided to 'coder update' (#3347)
- Add test suite for 'coder update'.
2022-08-01 19:46:50 -05:00
David Wahler 8a2811210a feat: Add backend API support for resource metadata (#3242)
* Initial support for metadata in provisioner API and Terraform provisioner

* add support for nullable metadata fields

* handle metadata fields in provisionerd and API
2022-08-01 16:53:05 -05:00
Noah Huppert 877519232c Added Emacs Tips Documentation (#3247) 2022-08-01 16:47:22 -05:00
Dean Sheather 66a5b0f7bc fix: don't use adduser and addgroup for docker images (#3344)
* fix: don't use adduser and addgroup for docker images

* Revert "fix: Remove alternative image architectures until we virtualize (#3336)"

This reverts commit 00c5116a2e.
2022-08-01 19:28:38 +00:00
Kyle Carberry 8f3727d05d fix: Update issue reporting link with body (#3339) 2022-08-01 17:03:02 +00:00
Anton Korzhuk 80223a5e41 replace inline svgs with svg icon_path (#3332) 2022-08-01 16:57:51 +00:00
Ben Potter 56ee105a2a chore: add Discord link to footer (#3239) 2022-08-01 10:03:52 -05:00
Kyle Carberry 00c5116a2e fix: Remove alternative image architectures until we virtualize (#3336)
With the addition of a command being executed inside the Docker build,
we could no longer build non-amd64 images on amd64. They will be added
back, but to allow for releases this temporarily removes them.
2022-08-01 08:37:37 -05:00
Ammar Bandukwala 0d93e9bde1 ci: move chromatic to coder workflow (#3330) 2022-08-01 09:36:00 -04:00
Ammar Bandukwala 19fcf60864 ci: add typo detection (#3327)
And fix them.
2022-08-01 09:29:52 -04:00
dependabot[bot] eb514357bb chore: bump eslint from 8.20.0 to 8.21.0 in /site (#3335)
Bumps [eslint](https://github.com/eslint/eslint) from 8.20.0 to 8.21.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.20.0...v8.21.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-01 08:22:53 -05:00
Mathias Fredriksson 4730c589fe chore: Use standardized test timeouts and delays (#3291) 2022-08-01 15:45:05 +03:00
Kyle Carberry 3d0febdd90 feat: Add OIDC authentication (#3314)
* feat: Add OIDC authentication

* Extract username into a separate package and add OIDC tests

* Add test case for invalid tokens

* Add test case for username as email

* Add OIDC to the frontend

* Improve comments from self-review

* Add authentication docs

* Add telemetry

* Update docs/install/auth.md

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

* Update docs/install/auth.md

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

* Remove username package

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>
2022-07-31 23:05:35 -05:00
Jon Ayers 8b17bf98ea fix: prepend scheme to access url (#3317)
- Problems can arise spawning workspaces if a schemeless URL is passed
  as the access URL.

  If an access url is detected to not have an "http" or "https" scheme
  then it is prepended with "https". If the hostname is detected
  to be a loopback device then "http" is preferred.
2022-07-31 17:49:25 -05:00
Ammar Bandukwala f82df1bd78 docs: clean up English (#3324)
Fix issues from #3319 and #3320
2022-07-31 20:06:05 +00:00
dependabot[bot] 70bf66e030 chore: bump github.com/go-chi/httprate from 0.5.3 to 0.6.0 (#3311)
Bumps [github.com/go-chi/httprate](https://github.com/go-chi/httprate) from 0.5.3 to 0.6.0.
- [Release notes](https://github.com/go-chi/httprate/releases)
- [Commits](https://github.com/go-chi/httprate/compare/v0.5.3...v0.6.0)

---
updated-dependencies:
- dependency-name: github.com/go-chi/httprate
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-31 13:44:38 -05:00
dependabot[bot] 921de16d98 chore: bump google.golang.org/api from 0.88.0 to 0.90.0 (#3310)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.88.0 to 0.90.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.88.0...v0.90.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-31 13:44:25 -05:00
Noah Huppert 16f0f1a2db 3293, cli: Updated Placeholder color to have a dark theme alt (#3294)
Co-authored-by: Ubuntu <ubuntu@ip-172-31-1-230.us-east-2.compute.internal>
2022-07-31 13:44:05 -05:00
mark-theshark c553829fbf chore: document startup_script and agent log location (#3319) 2022-07-30 17:57:16 -05:00
Ben Potter 52041becf7 Revert "chore: relax template name validation"
This reverts commit 7806f3bebe.
2022-07-30 22:34:59 +00:00
mark-theshark beed6c7222 chore: updated web ide screenshots to be current, and fix minor spelling errors. (#3153) 2022-07-30 22:31:22 +00:00
Ben Potter c8d7b38418 Merge branch 'main' of github.com:coder/coder into main 2022-07-30 22:31:08 +00:00
Ben Potter 7806f3bebe chore: relax template name validation 2022-07-30 22:31:06 +00:00
mark-theshark 7367253097 chore: update jetbrains gateway docs with screenshots (#3320)
* chore: update jetbrains gateway with screenshots

* organize & add to manifest

Co-authored-by: Ben <ben@coder.com>
2022-07-30 17:29:05 -05:00
whitney-coder d764b3d0c3 Update oauth.md 2 (#3312)
I messed up the order of the brackets/parenthesis on the first commit.  This time, it should be correct and in line with Markdown syntax which states: Markdown syntax for a hyperlink is square brackets followed by parentheses. The square brackets hold the text, the parentheses hold the link.
2022-07-29 16:34:49 -05:00
Ammar Bandukwala 09776f33dd docs: rm postgres (#3313)
This is not our job.
2022-07-29 19:55:40 +00:00
Spike Curtis 6ea9298656 Update Gateway 2022.2 RC docs (#3256)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-29 14:36:43 -05:00
Ammar Bandukwala 6e63487b27 Rename template update to template push (#3307)
Before, there was a `template edit` AND a `template update`. The
distinction between both commands was easy to forget. `push` more
clearly indicates that the template's source code is being updated.

It is also complimentary to existing `template pull`.
2022-07-29 19:21:48 +00:00
whitney-coder 4b9daf5777 Update oauth.md (#3308)
Markdown syntax on line 9 caused a funky looking link on the website
2022-07-29 14:18:53 -05:00
Kira Pilot f49328bee5 chore: fix yaml file config error (#3306) 2022-07-29 15:18:22 -04:00
dependabot[bot] 9614bfea6b chore: bump @xstate/cli from 0.2.1 to 0.3.0 in /site (#3262)
Bumps @xstate/cli from 0.2.1 to 0.3.0.

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-29 14:59:00 -04:00
Ammar Bandukwala 29eccbe4da ci: revert skips of required checks (#3303)
These were putting certain PRs in an unmergeable state.
2022-07-29 18:49:51 +00:00
dependabot[bot] d12e6b394f chore: bump typescript from 4.6.4 to 4.7.4 in /site (#2941)
* chore: bump typescript from 4.6.4 to 4.7.4 in /site

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.6.4 to 4.7.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.6.4...v4.7.4)

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

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

* Remove unnecessary React imports

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Presley Pizzo <presley@coder.com>
2022-07-29 14:48:58 -04:00
mark-theshark 1f2ead80c6 chore: remove duplicative kube config info in projector section (#3290) 2022-07-29 13:40:14 -05:00
Kyle Carberry 183b2e80b9 fix: Increase zoom of hero for README (#3300)
This was pretty small before which made it difficult to see
what was going on.
2022-07-29 13:39:30 -05:00
Kira Pilot aaa2db6f8b feat: add pagination component to components directory (#3295)
* proof of concept

* added tests

* fixed tests

* wrote unit tests

* preettier
2022-07-29 14:37:53 -04:00
Kira Pilot b9936d2310 updated dependabot (#3297) 2022-07-29 13:31:49 -04:00
Abhineet Jain e94fe20b6b fix: handle getUser error (#3285) 2022-07-29 13:10:22 -04:00
Cian Johnston 4658b3f0d2 fix: coderd: putExtendWorkspace: move error from validation to message (#3289)
* refactor: coderd: extract error messages to variables
* fix: putExtendWorkspace: return validation error in message field
2022-07-29 15:01:17 +01:00
Abhineet Jain 74c87664c1 fix: handle more auth API errors (#3241) 2022-07-28 17:14:05 -04:00
Presley Pizzo 6b82fdd0c0 Surface backend error when extending schedule (#3275) 2022-07-28 17:13:46 -04:00
Spike Curtis d6faf8f524 remove character limit on instance ids (#3274)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-28 13:52:03 -07:00
dependabot[bot] 6d14dcb1ee chore: bump eslint-plugin-jest from 26.5.3 to 26.6.0 in /site (#3204)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 26.5.3 to 26.6.0.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v26.5.3...v26.6.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-28 15:24:59 -04:00
dependabot[bot] 7ba69739f6 chore: bump ts-node from 10.8.2 to 10.9.1 in /site (#3213)
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.8.2 to 10.9.1.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v10.8.2...v10.9.1)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-28 15:11:44 -04:00
dependabot[bot] 736084ca5d chore: bump @typescript-eslint/eslint-plugin in /site (#3214)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.30.6 to 5.31.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.31.0/packages/eslint-plugin)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-28 15:09:51 -04:00
Mathias Fredriksson 29d44b6283 fix: Guard pty window resize after close (#3270)
Could help alleviate #3236.
2022-07-28 19:07:11 +00:00
Denbeigh Stevens 43b8cf04f0 fix: remove pipefail from standard shell options (#3269)
This isn't well-supported by every POSIX shell anyways.
2022-07-28 18:50:04 +00:00
Presley Pizzo 73f145e45f fix: error messages from workspaceScheduleXService (#3255)
* Update color palette

* Edit dialog error colors

* Format

* Lighten links

* Lighten link just in ErrorSummary

* Format

* Fix errors in schedule xservice

* Add error summary to form for generic message

* Format

* Extend getFormHelpers to remap field name

* Add mock error and use in storybook

* Format
2022-07-28 13:18:51 -04:00
Bruno Quaresma 1a8cce27ae fix: Workspace schedule button on responsive (#3264) 2022-07-28 16:17:50 +00:00
Bruno Quaresma 2805d86ba9 chore: Replace stop icon to use pause icon (#3261) 2022-07-28 11:02:14 -03:00
dependabot[bot] 663d0475b9 chore: bump @typescript-eslint/parser from 5.30.6 to 5.31.0 in /site (#3212)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.30.6 to 5.31.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.31.0/packages/parser)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-28 09:48:58 -04:00
Spike Curtis 043768076f Explain pty Process abstraction (#3254)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-27 17:03:55 -07:00
Steven Masley 6230d5512e chore: Remove line numbers from auto-gen typescript (#3258)
* chore: Remove line numbers from auto-gen typescript

The line numbers are just extra noise that change when things shift
around. They are not required and usually make CI fail when you
forget to run 'make gen'.
2022-07-27 21:36:15 +00:00
Cian Johnston 27ea415b6c fix: remove string TTL from workspace error responses (#3257)
- Rewrites some error messages to better integrate with the frontend (ttl_ms -> time until shutdown)
- Makes codersdk.ValidationError implement the error interface
- Only return validations if the error was a validation error, return detail otherwise (e.g. database error)
2022-07-27 21:20:02 +00:00
Spike Curtis 36ffdce065 Return proper exit code on ssh with TTY (#3192)
* Return proper exit code on ssh with TTY

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

* Fix revive lint

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

* Fix Windows exit code for missing command

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

* Fix close error handling on agent TTY

Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-27 14:23:28 -05:00
Presley Pizzo a37e61a099 fix: make text colors legible (#3250)
* Update color palette

* Edit dialog error colors

* Format

* Lighten links

* Lighten link just in ErrorSummary

* Format
2022-07-27 13:49:03 -04:00
Mathias Fredriksson 46564fb470 fix: Fix goleak in cli TestSSH tests (#3253)
Commands are now also run with contexts that time out.

Work towards #3221.
2022-07-27 17:33:00 +00:00
Mathias Fredriksson a0320f455a fix: Close notifier Poll goroutine on stop (#3252)
Fix towards #3221.
2022-07-27 20:26:13 +03:00
Cian Johnston 6377f17fda chore: update terraform to 1.2.1 (#3243)
* chore: update terraform to 1.2.1

* allow terraform version equal to max
2022-07-27 17:11:38 +01:00
Mathias Fredriksson d27076cac7 fix: Improve coder server shutdown procedure (#3246)
* fix: Improve `coder server` shutdown procedure

This commit improves the `coder server` shutdown procedure so that all
triggers for shutdown do so in a graceful way without skipping any
steps.

We also improve cancellation and shutdown of services by ensuring
resources are cleaned up at the end.

Notable changes:
- We wrap `cmd.Context()` to allow us to control cancellation better
- We attempt graceful shutdown of the http server (`server.Shutdown`)
  because it's less abrupt (compared to `shutdownConns`)
- All exit paths share the same shutdown procedure (except for early
  exit)
- `provisionerd`s are now shutdown concurrently instead of one at a
  time, the also now get a new context for shutdown because
  `cmd.Context()` may be cancelled
- Resources created by `newProvisionerDaemon` are cleaned up
- Lifecycle `Executor` exits its goroutine on context cancellation

Fixes #3245
2022-07-27 18:21:21 +03:00
Mathias Fredriksson bb05b1f749 fix: Use slog for devtunnel logging (#3248)
Ensures standardized logging for server.
2022-07-27 18:05:47 +03:00
Mathias Fredriksson cef622d77c fix: Order database queries for templates (#3249)
* fix: Order database queries for templates

Fixes a race in a test where the order of templates varies.

* fix: Add sorting to databasefake as well
2022-07-27 15:04:29 +00:00
Ammar Bandukwala 5802c29c38 docs: add versions (#3147)
Resolves #3111
2022-07-27 10:52:18 -04:00
Spike Curtis f310aeb4cb Disable skipping job acquire log (#3240)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-26 16:36:45 -07:00
Abhineet Jain b1e0d69789 Implement basic templates versions CLI (#3145) 2022-07-26 18:31:17 -04:00
Dean Sheather df20dd7374 feat: improve coder users show output, add json format (#3176) 2022-07-26 15:47:12 -05:00
Bruno Quaresma aaf0da27ef chore: Update viewport to support responsive (#3233) 2022-07-26 17:33:46 -03:00
Abhineet Jain 6f93acd964 feat: make template pages responsive (#3232) 2022-07-26 16:31:58 -04:00
Bruno Quaresma 991b4f7480 feat: Make settings page responsive (#3228) 2022-07-26 19:48:41 +00:00
Bruno Quaresma 509a601efe feat: Make users page responsive (#3229) 2022-07-26 16:46:43 -03:00
Abhineet Jain 0128ca6bd1 fix: manage backend authXService errors (#3190) 2022-07-26 15:39:45 -04:00
Dean Sheather b19cf701c5 feat: change docker to use "coder" user and add basic Helm chart (#2746) 2022-07-26 13:19:29 -05:00
Bruno Quaresma d2aa75dd0d fix: Responsive for workspaces and workspace page (#3189) 2022-07-26 15:05:00 -03:00
David Wahler fbd1a272fe fix: Fix dangling references in provisioner/terraform/testdata (#3193) 2022-07-26 12:04:21 -05:00
dependabot[bot] 8115a11e58 chore: bump webpack from 5.73.0 to 5.74.0 in /site (#3208)
Bumps [webpack](https://github.com/webpack/webpack) from 5.73.0 to 5.74.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.73.0...v5.74.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 10:53:45 -04:00
dependabot[bot] c8d2254028 chore: bump chromatic from 6.7.0 to 6.7.1 in /site (#3206)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.7.0 to 6.7.1.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/commits)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 10:53:21 -04:00
dependabot[bot] f49b015fc7 chore: bump cronstrue from 2.5.0 to 2.11.0 in /site (#2943)
Bumps [cronstrue](https://github.com/bradymholt/cronstrue) from 2.5.0 to 2.11.0.
- [Release notes](https://github.com/bradymholt/cronstrue/releases)
- [Changelog](https://github.com/bradymholt/cRonstrue/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bradymholt/cronstrue/compare/v2.5.0...v2.11.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 14:52:17 +00:00
Kira Pilot ef260faf27 fix: remove flaking test (#3207) 2022-07-26 10:35:13 -04:00
Mathias Fredriksson 159137dc10 fix: Use stdin/out defined in command (#3199) 2022-07-26 17:23:32 +03:00
dependabot[bot] 9fe260d5ea chore: bump eslint from 8.15.0 to 8.20.0 in /site (#3205)
Bumps [eslint](https://github.com/eslint/eslint) from 8.15.0 to 8.20.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.15.0...v8.20.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 10:22:52 -04:00
dependabot[bot] 8d6949a0b1 chore: bump @fontsource/ibm-plex-mono from 4.5.9 to 4.5.10 in /site (#2944)
Bumps [@fontsource/ibm-plex-mono](https://github.com/fontsource/fontsource/tree/HEAD/fonts/google/ibm-plex-mono) from 4.5.9 to 4.5.10.
- [Release notes](https://github.com/fontsource/fontsource/releases)
- [Changelog](https://github.com/fontsource/fontsource/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fontsource/fontsource/commits/HEAD/fonts/google/ibm-plex-mono)

---
updated-dependencies:
- dependency-name: "@fontsource/ibm-plex-mono"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 10:12:18 -04:00
dependabot[bot] 3f2cbc9b85 chore: bump @playwright/test from 1.23.2 to 1.24.1 in /site (#3203)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.23.2 to 1.24.1.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.23.2...v1.24.1)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 10:11:04 -04:00
dependabot[bot] 9a3baffe43 chore: bump @pmmmwh/react-refresh-webpack-plugin in /site (#3184)
Bumps [@pmmmwh/react-refresh-webpack-plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) from 0.5.6 to 0.5.7.
- [Release notes](https://github.com/pmmmwh/react-refresh-webpack-plugin/releases)
- [Changelog](https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pmmmwh/react-refresh-webpack-plugin/compare/v0.5.6...v0.5.7)

---
updated-dependencies:
- dependency-name: "@pmmmwh/react-refresh-webpack-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 09:54:28 -04:00
dependabot[bot] 100584d95c chore: bump github.com/klauspost/compress from 1.15.8 to 1.15.9 (#3162)
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.15.8 to 1.15.9.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Changelog](https://github.com/klauspost/compress/blob/master/.goreleaser.yml)
- [Commits](https://github.com/klauspost/compress/compare/v1.15.8...v1.15.9)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 16:46:30 +03:00
Mathias Fredriksson d1d89210b8 fix: Disable telemetry by default in tests (#3200)
I also noticed we don't have `goleak` enabled for CLI tests, this commit
adds it, but commented out. The reason being that we're nowhere near
being able to enable it yet.

Co-authored-by: Cian Johnston <cian@coder.com>
2022-07-26 16:27:48 +03:00
dependabot[bot] 122c6f06d8 chore: bump github.com/unrolled/secure from 1.11.0 to 1.12.0 (#3017)
Bumps [github.com/unrolled/secure](https://github.com/unrolled/secure) from 1.11.0 to 1.12.0.
- [Release notes](https://github.com/unrolled/secure/releases)
- [Commits](https://github.com/unrolled/secure/compare/v1.11.0...v1.12.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-26 16:26:07 +03:00
Cian Johnston 2c0d57e8c0 fix: update reference to agent.dev in examples and docs (#3198)
* fix: update agent ID in example templates
* fix: update agent ID in dogfood template
* chore: update default agent ID in documentation
* fix: develop.sh: start FE after template is created; leave template dir around if template creation fails
2022-07-26 14:09:09 +01:00
Mathias Fredriksson 9a9912c8ce fix: Add go.mod to prcontext and use build vs go run (#3197) 2022-07-26 16:04:00 +03:00
Mathias Fredriksson 0b86c8047c fix: Close connections in agent tests (#3196) 2022-07-26 13:24:54 +03:00
Mathias Fredriksson f34b5000cb fix: Avoid logging to stdout in devtunnel test (#3194)
The device keeps logging to the logger even after `dev.Close()` but
doing that with `t.Log` is unsafe (test has ended). This is why
`slogtest` was used.

`dev.Close()` has a wait on encryption and decryption routines, however,
these are left running even after the wait. The implementation uses the
WaitGroups in a weird way.
2022-07-26 12:20:21 +03:00
Kira Pilot 9bf5537b0f feat: showcase workspace state in actions dropdown (#3133)
* show progress indicator within workspace dropdown

resolves #2020

* wrote tests

* fix loading button

* PR feedback

* added stories for dropdown content

* PR feedbac
2022-07-25 18:12:59 -04:00
Bruno Quaresma b0957f32e3 feat: Add mobile navbar (#3186) 2022-07-25 17:54:11 +00:00
Mathias Fredriksson 173ab297be chore: Increase style/gen CI test timeout (#3187) 2022-07-25 17:10:53 +00:00
Mathias Fredriksson 92a95fbd5f fix: Rewrite ptytest to buffer stdout (#3170)
Fixes #2122
2022-07-25 20:02:34 +03:00
Mathias Fredriksson d7dee2c069 fix: Improve code coverage reporting in codecov (#2715)
* fix: Remove explicit coverpkg github.com/coder/coder/codersdk

This package is already covered by ./...

* fix: Ignore test utils in coverage (clitest, coderdtest, ptytest)
2022-07-25 19:55:19 +03:00
dependabot[bot] 6c5a142674 chore: bump dayjs from 1.11.3 to 1.11.4 in /site (#3180)
Bumps [dayjs](https://github.com/iamkun/dayjs) from 1.11.3 to 1.11.4.
- [Release notes](https://github.com/iamkun/dayjs/releases)
- [Changelog](https://github.com/iamkun/dayjs/blob/v1.11.4/CHANGELOG.md)
- [Commits](https://github.com/iamkun/dayjs/compare/v1.11.3...v1.11.4)

---
updated-dependencies:
- dependency-name: dayjs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 12:35:42 -04:00
dependabot[bot] 1859ca568d chore: bump eslint-plugin-jsx-a11y from 6.6.0 to 6.6.1 in /site (#3179)
Bumps [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y) from 6.6.0 to 6.6.1.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/compare/v6.6.0...v6.6.1)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 12:35:17 -04:00
Mathias Fredriksson 1c04b20fde fix: Set cache dir for coderd tests (#3160)
* fix: Set cache dir for coderd in codedtest

* fix: Ensure server cli tests have a cache path

To avoid sharing default path.
2022-07-25 19:24:32 +03:00
Mathias Fredriksson 6916d34458 fix: Fix cleanup in test helpers, prefer defer in tests (#3113)
* fix: Change uses of t.Cleanup -> defer in test bodies

Mixing t.Cleanup and defer can lead to unexpected order of execution.

* fix: Ensure t.Cleanup is not aborted by require

* chore: Add helper annotations
2022-07-25 19:22:02 +03:00
dependabot[bot] c2cd51d8b8 chore: bump sql-formatter from 8.0.2 to 8.2.0 in /site (#3178)
Bumps [sql-formatter](https://github.com/sql-formatter-org/sql-formatter) from 8.0.2 to 8.2.0.
- [Release notes](https://github.com/sql-formatter-org/sql-formatter/releases)
- [Changelog](https://github.com/sql-formatter-org/sql-formatter/blob/master/.release-it.json)
- [Commits](https://github.com/sql-formatter-org/sql-formatter/compare/v8.0.2...v8.2.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 12:12:58 -04:00
dependabot[bot] 456318cbd8 chore: bump eslint-import-resolver-typescript in /site (#3177)
Bumps [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) from 3.2.5 to 3.3.0.
- [Release notes](https://github.com/import-js/eslint-import-resolver-typescript/releases)
- [Changelog](https://github.com/import-js/eslint-import-resolver-typescript/blob/master/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-import-resolver-typescript/compare/v3.2.5...v3.3.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 12:09:30 -04:00
dependabot[bot] 4a0b8440bc chore: bump @types/node from 14.18.21 to 14.18.22 in /site (#3174)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.18.21 to 14.18.22.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 12:04:51 -04:00
dependabot[bot] 3c38a23e27 chore: bump eslint-plugin-react from 7.30.0 to 7.30.1 in /site (#3172)
Bumps [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) from 7.30.0 to 7.30.1.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-react/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jsx-eslint/eslint-plugin-react/compare/v7.30.0...v7.30.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-react
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 11:55:48 -04:00
Bruno Quaresma 821ae5dbd7 chore: Add colors object with the Coder color palette (#3173) 2022-07-25 12:49:00 -03:00
Mathias Fredriksson 4d53934eb0 fix: (Re-)enable TestPasswordTerminalState test (#3169) 2022-07-25 18:42:20 +03:00
David Wahler 5312296283 fix: Add a slightly better error message for dropped SSH connection (#3131) 2022-07-25 10:25:34 -05:00
dependabot[bot] f0f0aebdbb chore: bump @testing-library/user-event from 14.2.0 to 14.3.0 in /site (#3163)
Bumps [@testing-library/user-event](https://github.com/testing-library/user-event) from 14.2.0 to 14.3.0.
- [Release notes](https://github.com/testing-library/user-event/releases)
- [Changelog](https://github.com/testing-library/user-event/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/user-event/compare/v14.2...v14.3)

---
updated-dependencies:
- dependency-name: "@testing-library/user-event"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-25 10:35:21 -04:00
Mathias Fredriksson d7ec407a7c fix: Improve coder list and show CLI help (#3167) 2022-07-25 16:56:20 +03:00
Mathias Fredriksson 233aa17848 fix: Avoid dirtying stdout/stderr in test (#3165)
* fix: Default all clitest commands to io.Discard stdout/err

* fix: Never write to stdout or stderr in tests
2022-07-25 16:55:53 +03:00
Mathias Fredriksson ad2b29a571 fix: Remove hardcoded /tmp path in test (#3168) 2022-07-25 16:55:06 +03:00
Mathias Fredriksson 2c67a2f30b fix: Close bug in pty (#3166) 2022-07-25 16:31:30 +03:00
Mathias Fredriksson 592340c6ce fix: Data race in cliui.Styles without clone (#3164) 2022-07-25 16:30:52 +03:00
Ammar Bandukwala 54547a4e9a ci: fix postgres skipper (#3157) 2022-07-24 19:58:20 +00:00
Ammar Bandukwala 60de8d0279 ci: add skip directives for long tests (#3151)
This PR introduces many CI optimizations:

1. The `[ci-skip]` PR body directive to skip the Postgres and end to end tests
2. Improved caching that cuts the Go test matrix in half
3. Increasing Go test parallelism for ~20% gains
4. Enable caching in webpack (4x frontend build)
2022-07-24 14:33:58 -05:00
Ammar Bandukwala 5578facf8f Fix stalebot (#3156) 2022-07-24 19:32:41 +00:00
Ammar Bandukwala ecb6301cab docs: make small style improvements (#3065) 2022-07-23 16:37:54 -05:00
Ammar Bandukwala e4251af8f3 ci: configure stale bot some more (#3148) 2022-07-23 16:37:19 -05:00
Ammar Bandukwala 3eb6f28d81 ci: fix master build 2022-07-23 21:36:15 +00:00
Ammar Bandukwala d10513f43a ci: optimize jobs with path filtering (#3074) 2022-07-23 21:33:25 +00:00
mark-theshark 1ddff0abcd chore: docs to create admin user and workspace creation from UI screenshot (#3149) 2022-07-23 20:44:28 +00:00
Ammar Bandukwala f28d14197a Rename default agent to "main" instead of "dev" (#3150)
Resolves #3143
2022-07-23 20:26:56 +00:00
Ammar Bandukwala 257e52e014 ci: aggressively close stale PRs (#3146) 2022-07-23 14:57:35 -05:00
Spike Curtis 5e32468a73 Add JetBrains Gateway doc (#3104)
* Add JetBrains Gateway doc

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

* Added GitHub issue to track Gateway failure

Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-22 15:32:16 -07:00
Kyle Carberry c6016d247d docs: Update hero image to the dashboard (#3132) 2022-07-22 21:00:21 +00:00
Bruno Quaresma ca93614c3f refactor: Make workspace status more visible (#3130) 2022-07-22 19:18:52 +00:00
Abhineet Jain 1b19a09a37 feat: New static error summary component (#3107) 2022-07-22 19:10:40 +00:00
Kyle Carberry fd4954b4e5 fix: Use membership endpoint to ensure user exists in team (#3129)
This was using the incorrect GitHub endpoint prior, which fetched a team
by slug. Any user in a GitHub organization can view all teams, so this
didn't block signups like intended.

I've verified this API returns an error when the calling user is not a
member  of the team requested.

Fixes #3105.
2022-07-22 13:54:08 -05:00
Kira Pilot 471564df7d feat: improve update button visibility (#3115)
* feat: give update button primary focus when applicable

resolves #3024

* added update tooltip

* cleanup

* prettier

* PR feedback
2022-07-22 14:28:52 -04:00
Joe Previte 2dd98c7ec8 docs: add dogfooding guide (#3099) 2022-07-22 18:22:11 +00:00
Mathias Fredriksson 51dd1fde3b fix: Remove use of require in require.Eventually in tests (#3110)
* fix: Remove use of `require` in `require.Eventually` in tests

Because require uses `t.FailNow()` and `require.Eventually` runs the
function in a goroutine, which is not allowed.

* feat: Add ruleguard for require.Eventually

Co-authored-by: Cian Johnston <cian@coder.com>
2022-07-22 20:02:49 +03:00
Bruno Quaresma 3bb760576b fix: Add resource icons into template page (#3124) 2022-07-22 11:46:51 -05:00
Spike Curtis fa4361db76 restore devtunnel test (#3050)
* Dev tunnel test uses local fake server; fixed port

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

* Remove parallel for test

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

* Fix segfault
2022-07-22 08:26:39 -07:00
Kira Pilot 882ee55fd0 fix: storybook should use absolute paths (#3119) 2022-07-22 11:02:54 -04:00
Ben Potter f43eb0e77c fix: minor fixes to templates docs (#3117) 2022-07-22 09:59:19 -05:00
Cian Johnston 1140e29a17 chore: autobuild/executor: refactor big switch statement for legibility (#3116) 2022-07-22 15:45:12 +01:00
Mathias Fredriksson ef7d357e19 fix: Move timeout ctx closer to use in tests, increase timeout (#3109)
Some contexts were moved closer to use so that test setup doesn't affect
timeout. And timeout was increased for some others to avoid flakyness
due to slow test runners.
2022-07-22 17:42:09 +03:00
Bruno Quaresma e874d538fb feat: Add resource icons (#3118) 2022-07-22 11:38:38 -03:00
Mathias Fredriksson 7d07e670ca chore: Improve test cleanup (#3112) 2022-07-22 15:14:45 +03:00
Mathias Fredriksson 75ff579051 fix: Decrease postgres test timeout (make test-postgres) (#3108)
This commit lowers the postgres test timeout from 30m to 20m, currently
our postgres tests seem to take 8-10m, a 2x factor should suffice.
Comments were updated in both places to reflect the reasoning and
necessity of keeping these values in sync.

They used to take longer but the `count` was lowered in
3d40cb85b7.

The actual timeout value of `make test-postgres` got overlooked in
https://github.com/coder/coder/pull/3079.
2022-07-22 12:47:03 +03:00
Kira Pilot 0aa8c2efeb fix: set a failed canceled job status correctly (#3101)
* set a failed canceled job status correctly

resolves #1374

* added unit test for convertProvisionerJob

* Update coderd/provisionerjobs_internal_test.go

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

* PR feedback

Co-authored-by: Cian Johnston <cian@coder.com>
2022-07-21 16:47:06 -04:00
mark-theshark 77f4ab16a4 feat: update IDE docs with advanced examples with pods and custom images (#3002) 2022-07-21 20:03:03 +00:00
David Wahler 7f54628848 config-ssh: always support agent name in host alias (#3036) 2022-07-21 14:49:32 -05:00
dependabot[bot] c9d7cbca48 chore: bump github.com/nhatthm/otelsql from 0.3.4 to 0.4.0 (#3069)
Bumps [github.com/nhatthm/otelsql](https://github.com/nhatthm/otelsql) from 0.3.4 to 0.4.0.
- [Release notes](https://github.com/nhatthm/otelsql/releases)
- [Commits](https://github.com/nhatthm/otelsql/compare/v0.3.4...v0.4.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-21 14:39:15 -05:00
dependabot[bot] 06e0a5b1e4 chore: bump google.golang.org/api from 0.86.0 to 0.88.0 (#3070)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.86.0 to 0.88.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.86.0...v0.88.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-21 14:38:56 -05:00
Cian Johnston 59b04c154e fix: coderdtest: increase ForceCancelInterval (#3085)
Two coderd unit tests (TestPatchCancelTemplateVersion/Success and TestPatchCancelWorkspaceBuild) implied erroneously that the job was canceled successfully.

This is not the case, as these unit tests do not include a Provision_Complete response in the input to the
echo provisioner. Now explicitly checking the job error and bumping the force cancel interval to be longer.

Fixes #3083.
2022-07-21 19:29:45 +00:00
Jon Ayers e01905821f fix: avoid emitting version warning when connection error encountered (#3082) 2022-07-21 14:28:24 -05:00
Bruno Quaresma 5b78251592 refactor: Initial color palette changes (#3087) 2022-07-21 17:56:16 +00:00
Mathias Fredriksson e33a74975e fix: Deadlock and race in peer, test improvements (#3086)
* fix: Potential deadlock in peer.Channel dc.OnOpen

* fix: Potential send on closed channel

* fix: Improve robustness of waitOpened during close

* chore: Simplify statements

* fix: Improve teardown and timeout of peer tests

* fix: Improve robustness of TestConn/Buffering test

* Update peer/channel.go

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
2022-07-21 18:47:17 +03:00
Jon Ayers 62e685669f feat: add verbose error messaging (#3053) 2022-07-20 15:17:51 -05:00
Mathias Fredriksson 4a7d067c6c fix: Increase CI timeout for postgres test (#3079)
The Go test timeout uses 20m, if we want to get a stack trace, we must
allow the actions worker to run longer than that.
2022-07-20 19:09:26 +00:00
Mathias Fredriksson 96edc8af9a fix: Add continue-on-error to codecov action step (#3081)
Avoid relying on codecov to manage action step failure, hopefully works
around:
https://github.com/codecov/codecov-action/issues/788
2022-07-20 19:04:40 +00:00
Mathias Fredriksson 3e5affd28a fix: Increase test timeout for TestCreate/CreateFromListWithSkip (#3077)
Considering database load and CI performance during testing, we should
avoid failing too early.
2022-07-20 17:51:33 +00:00
Ammar Bandukwala b0c26745fb ci: fix stale issue workflow (#3073) 2022-07-20 17:24:30 +00:00
Bruno Quaresma 916c388d8d fix: Statuses breaking line in the UI (#3071)
* fix: Fix statuses breaking line in the UI

* fix: AppLink stories
2022-07-20 17:11:20 +00:00
dependabot[bot] 82f159b8c3 chore: bump terser from 4.8.0 to 4.8.1 in /site (#3068)
Bumps [terser](https://github.com/terser/terser) from 4.8.0 to 4.8.1.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-20 12:58:43 -04:00
Ammar Bandukwala cf9bc71c03 ci: skip long jobs when only docs change (#3072) 2022-07-20 16:47:41 +00:00
Mathias Fredriksson 4fde5366be fix: Improve TestSSH reliability on macOS (#3067)
Related issue: https://github.com/coder/coder/issues/2122
2022-07-20 19:24:15 +03:00
dependabot[bot] 6199e6a060 chore: bump github.com/spf13/afero from 1.9.0 to 1.9.2 (#3046)
Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.9.0 to 1.9.2.
- [Release notes](https://github.com/spf13/afero/releases)
- [Commits](https://github.com/spf13/afero/compare/v1.9.0...v1.9.2)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-20 11:20:48 -05:00
Kira Pilot 0c18a2313f clarify start validation in schedule (#3052)
resolves #2792
2022-07-20 11:54:57 -04:00
Mathias Fredriksson 034416f141 chore: Speed up port-forward tests (#3062)
* chore: Speed up port-forward tests

* chore: Add t.Helper and ensure listener closure on error
2022-07-20 18:11:25 +03:00
Mathias Fredriksson cd74afcccc fix: Increase randomness for names used in tests (#3063)
We are starting to run into test flakes due to lack of randomness in CI,
this change simply bumps randomness by additional suffix numbers.

See: https://github.com/coder/coder/issues/3038#issuecomment-1190283608
2022-07-20 18:03:04 +03:00
Ammar Bandukwala 87b0b4b1ea docs: add secrets (#3057) 2022-07-20 07:31:33 -05:00
David Wahler f7ea016494 Pass git configuration variables via terraform (#3034)
* Pass workspace owner email address to provisioner

* Remove owner_email and owner_username fields from agent metadata

* Add Git environment variables to example templates

* Remove "owner_name" field from provisioner metadata, use username instead

* Remove Git configuration from most templates, add documentation

* Proofreading/typo fixes from @mafredri

* Update example templates to latest version of terraform-provider-coder
2022-07-19 13:24:06 -05:00
Alon David b9847c18f4 solves #2535. (#2557)
remove leading V in coder container image tag
2022-07-19 17:06:03 +00:00
dependabot[bot] a69bd47b3a chore: bump github.com/jedib0t/go-pretty/v6 from 6.3.3 to 6.3.5 (#3028)
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.3.3 to 6.3.5.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.3.3...v6.3.5)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-19 11:41:51 -05:00
dependabot[bot] caf2478cf6 chore: bump github.com/pion/webrtc/v3 from 3.1.42 to 3.1.43 (#3027)
Bumps [github.com/pion/webrtc/v3](https://github.com/pion/webrtc) from 3.1.42 to 3.1.43.
- [Release notes](https://github.com/pion/webrtc/releases)
- [Commits](https://github.com/pion/webrtc/compare/v3.1.42...v3.1.43)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-19 11:27:41 -05:00
Ammar Bandukwala c86a623ff8 Remove Joe from docs CODEOWNERS (#3037) 2022-07-19 16:27:13 +00:00
Kira Pilot 1830a18565 feat: amend schedule form valiidation string (#3043)
resolves #2792
2022-07-19 12:04:06 -04:00
Ben Potter b6ad5623a3 example: add a bare/custom template (#2965) 2022-07-19 13:29:24 +00:00
Ammar Bandukwala a2f6b25110 Add new Dogfood template (#2959)
* Setup base template

* Add sysbox

* Run code-server in background

* Fix small typo
2022-07-18 22:44:09 +00:00
Ammar Bandukwala a66b852c81 ci: fix stale (#3030)
- Add necessary runs-on
- Use lowercase labels for consistency
2022-07-18 19:58:51 +00:00
Ammar Bandukwala 5919e96ac2 ci: add stale workflow (#3029) 2022-07-18 19:34:04 +00:00
Mathias Fredriksson 54cf677e80 chore: Switch back to upstream for hashicorp/yamux (#3026)
All our fixes have been upstreamed, so we are switching back.
2022-07-18 20:27:26 +03:00
dependabot[bot] 4f6b2cff83 chore: bump github.com/spf13/afero from 1.8.2 to 1.9.0 (#3014)
Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.8.2 to 1.9.0.
- [Release notes](https://github.com/spf13/afero/releases)
- [Commits](https://github.com/spf13/afero/compare/v1.8.2...v1.9.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-18 12:12:10 -05:00
Mathias Fredriksson 3a692a6cdb fix: Sort ComputedValue according to parameter schema index (#3022)
This fixes a test-flake in TestTemplateVersionParameters/List and gives
us consistent sorting for parameters.
2022-07-18 19:39:24 +03:00
Kira Pilot c0d19ebea2 chore: configure absolute paths with webpack (#3011)
* coonfigure absolute paths with webpack

resolves #1855

* fixed jest config
2022-07-18 10:43:11 -04:00
dependabot[bot] 6d1ec409d0 chore: bump github.com/klauspost/compress from 1.15.7 to 1.15.8 (#3015)
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.15.7 to 1.15.8.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Changelog](https://github.com/klauspost/compress/blob/master/.goreleaser.yml)
- [Commits](https://github.com/klauspost/compress/compare/v1.15.7...v1.15.8)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-18 10:08:43 -04:00
Abhineet Jain ccdf82dd7e feat: show template versions (#3003) 2022-07-15 15:25:47 -07:00
Kira Pilot 9a5fa3f050 fix: border fixes for workspace schedule button (#3010)
* border fixes for workspace schedule button

* fixing chromatic snapshots

* chromatic fix
2022-07-15 18:04:33 -04:00
Abhineet Jain d04ba2cc02 feat: add template version creator (#3001) 2022-07-15 14:12:39 -07:00
Bruno Quaresma d26b3b7ba1 refactor: Remove avatar from workspace name (#3006) 2022-07-15 15:49:18 +00:00
Colin Adler 680e24a14b Revert "feat: add template version creator (#2991)" (#2999)
This reverts commit aea3b3b83e.
2022-07-14 21:57:42 +00:00
Colin Adler 1033e02d79 feat: add coder server postgres-builtin-serve to run the built-in DB (#2997) 2022-07-14 21:51:44 +00:00
Kira Pilot eebf0dd736 feat: consolidate workspace buttons/kira pilot (#2996)
* added workspace cta dropdown

resolves #2748

* added tests

* fixed failing tests

* clean up snapshots
2022-07-14 16:47:10 -04:00
Abhineet Jain aea3b3b83e feat: add template version creator (#2991) 2022-07-14 20:44:33 +00:00
Ali Diamond 6ef8a625d5 Update workspaces.md (#2993)
adding missing command word
2022-07-14 18:31:01 +00:00
Bruno Quaresma adcd6f5cf1 refactor: Make the workspace panels more light (#2984) 2022-07-14 15:09:07 -03:00
Bruno Quaresma c8d04aff6b feat: Add status badge to the favicon (#2978) 2022-07-14 14:45:03 +00:00
Abhineet Jain bf1af216e1 fix: remove access column header (#2976) 2022-07-13 17:59:09 -07:00
Kyle Carberry 8e17254785 fix: Add test for wrapping init script with single quotes (#2979)
This ensures our initialization script works with single  uotes.
2022-07-13 17:43:48 -05:00
David Wahler b5f5e909bd Return template parameters in consistent order (#2975)
* return parameters from Terraform provisioner in sorted order

* persist parameter indices in database and return them in correct order from API

* don't re-sort parameters by name when creating templates
2022-07-13 15:29:34 -05:00
Abhineet Jain b692b7ea14 fix: remove system user highlighting (#2973) 2022-07-13 11:48:26 -07:00
Bruno Quaresma 000bc50258 refactor: Refactor last built by column (#2968) 2022-07-13 12:37:12 -03:00
Bruno Quaresma 02129332d7 fix: Loading state in the workspaces page (#2967) 2022-07-13 11:49:07 -03:00
Cian Johnston 0f5f30b6f6 fix: make agent scripts easier to troubleshoot (#2922)
- Adds distinct exit statuses to the bootstrap scripts
- Makes the bootstrap scripts loop forever trying to download the coder agent
- Surfaces and logs the status codes returned by the download tool
2022-07-13 10:17:40 +01:00
Kyle Carberry 6f34cbff1e fix: Use double quotes for trap signal (#2956)
Frequently callers will wrap our shell script in `sh -c ''`.
Having single quotes on our `trap` led to a syntax error when
doing this.
2022-07-13 01:09:59 +00:00
Kyle Carberry 8b76e40629 fix: Fetch GitHub teams by name for performance (#2955)
In large organizations with thousands of teams, looping took >5s.
This fetches organizations by team name, which should be very fast!
2022-07-13 00:45:43 +00:00
Jon Ayers 7e9819f2a8 ref: move httpapi.Reponse into codersdk (#2954) 2022-07-12 19:15:02 -05:00
Kyle Carberry dde51f1caa fix: Force trap to always succeed due to incompatibility (#2953)
There are some instances of Linux that don't support trap. We should
ignore the failure in those cases.
2022-07-12 23:31:25 +00:00
Kyle Carberry 5ee112bc00 fix: Fetch all GitHub teams on login (#2951)
This wasn't looping prior, so organizations with >100 teams
couldn't login. Contributes to #2848.
2022-07-12 23:06:27 +00:00
Mathias Fredriksson 59facdd8dc fix: Show schedule commands in help, improve template (#2923)
* fix: Show schedule commands in help, improve template

* chore: Remove schedule long help, fixed by listing missing commands

* chore: Clean up annotation usage with template function

* fix: Drive-by fix for trailing whitespace for flags

Introduced in c7681370b5.
2022-07-12 23:24:53 +03:00
Mathias Fredriksson 2d048803c8 chore: Switch drpc from fork to upstream (#2949)
The https://github.com/storj/drpc/pull/31 PR was not merged, but was
replaced by:

https://github.com/storj/drpc/commit/9206537a4db76809da6ec768a0c5e45ddb618ef5

This fixes the underlying issue fixed in the fork.
2022-07-12 22:20:22 +03:00
Mathias Fredriksson e035b642b8 chore: Update yamux fork (#2948) 2022-07-12 22:10:24 +03:00
Cian Johnston 5e6320163d change default aws linux instance type to t3.micro, reduce default template TTL (#2776)
- make default template max TTL 24 hours (still less than 168)
- make default workspace autostop 2 hours unless specified otherwise
- add instance type selector to aws templates
2022-07-12 19:37:59 +01:00
Steven Masley c07a45e610 fix: Fix workspace count to exclude deleted workspaces (#2916) 2022-07-12 12:52:28 -05:00
Abhineet Jain 61c52b3090 feat: default confirm to no for cli delete (#2919) 2022-07-12 10:36:07 -07:00
Abhineet Jain b0bab3e432 feat: show last build initiator for workspaces (#2921) 2022-07-12 10:14:36 -07:00
Bruno Quaresma e172a40a91 fix: Add links to the SSH popover (#2945) 2022-07-12 16:45:53 +00:00
Bruno Quaresma 166bc273b3 feature: Add SSH button in the agent access column (#2931) 2022-07-12 13:10:38 -03:00
dependabot[bot] 0645176e66 chore: bump webpack-dev-server from 4.9.0 to 4.9.3 in /site (#2939)
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.9.0 to 4.9.3.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.9.0...v4.9.3)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 12:07:47 -04:00
dependabot[bot] 8df4212bbb chore: bump ts-loader from 9.3.0 to 9.3.1 in /site (#2940)
Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 9.3.0 to 9.3.1.
- [Release notes](https://github.com/TypeStrong/ts-loader/releases)
- [Changelog](https://github.com/TypeStrong/ts-loader/blob/main/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/ts-loader/compare/v9.3.0...v9.3.1)

---
updated-dependencies:
- dependency-name: ts-loader
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 11:58:11 -04:00
dependabot[bot] 18a9d070af chore: bump @playwright/test from 1.22.1 to 1.23.2 in /site (#2934)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.22.1 to 1.23.2.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.22.1...v1.23.2)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kira Pilot <kira@coder.com>
2022-07-12 11:22:03 -04:00
dependabot[bot] 919e3a5fb5 chore: bump @testing-library/react-hooks from 8.0.0 to 8.0.1 in /site (#2936)
Bumps [@testing-library/react-hooks](https://github.com/testing-library/react-hooks-testing-library) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/testing-library/react-hooks-testing-library/releases)
- [Changelog](https://github.com/testing-library/react-hooks-testing-library/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/react-hooks-testing-library/compare/v8.0.0...v8.0.1)

---
updated-dependencies:
- dependency-name: "@testing-library/react-hooks"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kira Pilot <kira@coder.com>
2022-07-12 11:21:49 -04:00
dependabot[bot] 8acae4b5aa chore: bump chromatic from 6.5.4 to 6.7.0 in /site (#2935)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.5.4 to 6.7.0.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.5.4...v6.7.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kira Pilot <kira@coder.com>
2022-07-12 11:19:17 -04:00
dependabot[bot] 516dc190ad chore: bump @typescript-eslint/eslint-plugin in /site (#2933)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.27.0 to 5.30.6.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.30.6/packages/eslint-plugin)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:50:45 -04:00
dependabot[bot] 4cfa240065 chore: bump eslint-plugin-jest from 26.2.2 to 26.5.3 in /site (#2926)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 26.2.2 to 26.5.3.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v26.2.2...v26.5.3)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kira Pilot <kira@coder.com>
2022-07-12 10:46:46 -04:00
dependabot[bot] 516d955219 chore: bump webpack from 5.72.0 to 5.73.0 in /site (#2932)
Bumps [webpack](https://github.com/webpack/webpack) from 5.72.0 to 5.73.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.72.0...v5.73.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:46:15 -04:00
dependabot[bot] 453d6ff75d chore: bump eslint-plugin-jsx-a11y from 6.5.1 to 6.6.0 in /site (#2930)
Bumps [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y) from 6.5.1 to 6.6.0.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/compare/v6.5.1...v6.6.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:31:35 -04:00
dependabot[bot] 701821ab28 chore: bump webpack-cli from 4.9.2 to 4.10.0 in /site (#2929)
Bumps [webpack-cli](https://github.com/webpack/webpack-cli) from 4.9.2 to 4.10.0.
- [Release notes](https://github.com/webpack/webpack-cli/releases)
- [Changelog](https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-cli/compare/webpack-cli@4.9.2...webpack-cli@4.10.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:25:49 -04:00
dependabot[bot] b4bee421e9 chore: bump xterm from 4.18.0 to 4.19.0 in /site (#2927)
Bumps [xterm](https://github.com/xtermjs/xterm.js) from 4.18.0 to 4.19.0.
- [Release notes](https://github.com/xtermjs/xterm.js/releases)
- [Commits](https://github.com/xtermjs/xterm.js/compare/4.18.0...4.19.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:18:11 -04:00
dependabot[bot] c178f37a3e chore: bump eslint-import-resolver-typescript in /site (#2928)
Bumps [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) from 2.7.1 to 3.2.5.
- [Release notes](https://github.com/import-js/eslint-import-resolver-typescript/releases)
- [Changelog](https://github.com/import-js/eslint-import-resolver-typescript/blob/master/CHANGELOG.md)
- [Commits](https://github.com/import-js/eslint-import-resolver-typescript/compare/v2.7.1...v3.2.5)

---
updated-dependencies:
- dependency-name: eslint-import-resolver-typescript
  dependency-type: direct:development
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 10:13:38 -04:00
dependabot[bot] 3070ef8903 chore: bump @xstate/cli from 0.1.7 to 0.2.1 in /site (#2908)
Bumps @xstate/cli from 0.1.7 to 0.2.1.

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 09:49:07 -04:00
dependabot[bot] d497e1ce8d chore: bump cron-parser from 4.4.0 to 4.5.0 in /site (#2924)
Bumps [cron-parser](https://github.com/harrisiirak/cron-parser) from 4.4.0 to 4.5.0.
- [Release notes](https://github.com/harrisiirak/cron-parser/releases)
- [Commits](https://github.com/harrisiirak/cron-parser/compare/4.4.0...4.5.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 09:45:22 -04:00
dependabot[bot] 146473cafd chore: bump prettier-plugin-organize-imports in /site (#2910)
Bumps [prettier-plugin-organize-imports](https://github.com/simonhaenisch/prettier-plugin-organize-imports) from 2.3.4 to 3.0.0.
- [Release notes](https://github.com/simonhaenisch/prettier-plugin-organize-imports/releases)
- [Commits](https://github.com/simonhaenisch/prettier-plugin-organize-imports/compare/v2.3.4...v3.0.0)

---
updated-dependencies:
- dependency-name: prettier-plugin-organize-imports
  dependency-type: direct:development
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 09:45:09 -04:00
dependabot[bot] dcf5d57357 chore: bump @typescript-eslint/parser from 5.25.0 to 5.30.6 in /site (#2911)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.25.0 to 5.30.6.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.30.6/packages/parser)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-12 09:26:53 -04:00
Colin Adler 92ebdaec5a feat: force legacy tunnels to new version (#2914) 2022-07-12 00:33:35 +00:00
Ammar Bandukwala 59de95b8bb Minor docs fixes (#2920)
* Fix image links in quickstart

* Add myself to CODEOWNERS for docs
2022-07-11 22:35:24 +00:00
Abhineet Jain df13b9dfea fix: open multiple app windows (#2912) 2022-07-11 12:24:28 -07:00
Kyle Carberry 2c89e07e12 fix: Redirect to login when unauthenticated and requesting a workspace app (#2903)
Fixes #2884.
2022-07-11 13:46:01 -05:00
dependabot[bot] 08d90f7b4f chore: bump mini-css-extract-plugin from 2.6.0 to 2.6.1 in /site (#2906)
Bumps [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/webpack-contrib/mini-css-extract-plugin/releases)
- [Changelog](https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack-contrib/mini-css-extract-plugin/compare/v2.6.0...v2.6.1)

---
updated-dependencies:
- dependency-name: mini-css-extract-plugin
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 14:45:16 -04:00
dependabot[bot] 00fee2e501 chore: bump jest-junit from 13.2.0 to 14.0.0 in /site (#2907)
Bumps [jest-junit](https://github.com/jest-community/jest-junit) from 13.2.0 to 14.0.0.
- [Release notes](https://github.com/jest-community/jest-junit/releases)
- [Commits](https://github.com/jest-community/jest-junit/compare/v13.2.0...v14.0.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 14:45:05 -04:00
Ketan Gangatirkar 536c77af5d fix: confirm when deleting template (#2866)
* prompt for confirmation before deleting templates (#2830)

* populate templateNames from the interactive picker too

* allow skipping delete confirmation prompt with --yes flag

* eliminate unnecessary newline

* test both confirmation of delete and `--yes` with no confirmation

* fix failing test that needed --yes

* remove unnecessary empty line the linter disliked

* make the tests correct
2022-07-11 13:13:56 -05:00
dependabot[bot] fa7dcf615a chore: bump prettier from 2.6.2 to 2.7.1 in /site (#2896)
Bumps [prettier](https://github.com/prettier/prettier) from 2.6.2 to 2.7.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.6.2...2.7.1)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 14:13:42 -04:00
dependabot[bot] 7d8b092af9 chore: bump @types/node from 14.18.16 to 14.18.21 in /site (#2905)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.18.16 to 14.18.21.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 14:12:26 -04:00
dependabot[bot] 312a19c270 chore: bump github.com/hashicorp/go-version from 1.5.0 to 1.6.0 (#2818)
Bumps [github.com/hashicorp/go-version](https://github.com/hashicorp/go-version) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/hashicorp/go-version/releases)
- [Changelog](https://github.com/hashicorp/go-version/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/go-version/compare/v1.5.0...v1.6.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 18:06:28 +00:00
dependabot[bot] a585a986d8 chore: bump eslint-plugin-react-hooks from 4.5.0 to 4.6.0 in /site (#2864)
Bumps [eslint-plugin-react-hooks](https://github.com/facebook/react/tree/HEAD/packages/eslint-plugin-react-hooks) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/HEAD/packages/eslint-plugin-react-hooks)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 13:01:50 -05:00
dependabot[bot] 420a07762a chore: bump go.opentelemetry.io/otel/exporters/otlp/otlptrace (#2895)
Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 13:01:30 -05:00
dependabot[bot] ef691f297a chore: bump @storybook/addon-actions from 6.4.22 to 6.5.9 in /site (#2519)
Bumps [@storybook/addon-actions](https://github.com/storybookjs/storybook/tree/HEAD/addons/actions) from 6.4.22 to 6.5.9.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.9/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.9/addons/actions)

---
updated-dependencies:
- dependency-name: "@storybook/addon-actions"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 13:54:11 -04:00
Ammar Bandukwala 13d7466ebc docs: add Docker quickstart (#2875)
* Fix docker-compose file

* Add docker quickstart
2022-07-11 12:05:05 -05:00
Ketan Gangatirkar 5eecbaa534 fix: trim leading and trailing spaces from template parameters (#2829) (#2879) 2022-07-11 11:46:03 -05:00
Mathias Fredriksson 749694b7de fix: Standardize and wrap example descriptions at 80 chars (#2894) 2022-07-11 19:08:09 +03:00
Kira Pilot 50e8a27d04 fix: removing noisy shutdown snapshots (#2899)
* fix: removing noisy shutdown snapshots

resolves #2685

* removing workspaceSchedule stories
2022-07-11 11:34:58 -04:00
Nicholas Pease 74d484eacf Update docs in reference to command change in #2530 (#2902) 2022-07-11 15:30:54 +00:00
dependabot[bot] 6d0aab4d2c chore: bump go.opentelemetry.io/otel/sdk from 1.7.0 to 1.8.0 (#2900)
Bumps [go.opentelemetry.io/otel/sdk](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/sdk
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 10:22:59 -05:00
Ben Potter 71cb223564 chore: add matlab icon (#2891) 2022-07-11 17:19:35 +02:00
dependabot[bot] daadb9a532 chore: bump github.com/nhatthm/otelsql from 0.3.3 to 0.3.4 (#2898)
Bumps [github.com/nhatthm/otelsql](https://github.com/nhatthm/otelsql) from 0.3.3 to 0.3.4.
- [Release notes](https://github.com/nhatthm/otelsql/releases)
- [Commits](https://github.com/nhatthm/otelsql/compare/v0.3.3...v0.3.4)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 09:36:05 -05:00
dependabot[bot] 8f55254167 chore: bump github.com/elastic/go-sysinfo from 1.8.0 to 1.8.1 (#2889)
Bumps [github.com/elastic/go-sysinfo](https://github.com/elastic/go-sysinfo) from 1.8.0 to 1.8.1.
- [Release notes](https://github.com/elastic/go-sysinfo/releases)
- [Changelog](https://github.com/elastic/go-sysinfo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/elastic/go-sysinfo/compare/v1.8.0...v1.8.1)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 09:11:11 -05:00
Kyle Carberry 1973786335 fix: Add trap to agent startup script to sleep on failure (#2873)
* fix: Add `trap` to agent startup script to sleep on failure

The Docker Terraform provider removes containers immediately on exit, making
it difficult to debug a failed container start with Coder. This will sleep on
exit and output a friendly log, which should assist with debugging failures.

* Update provisionersdk/agent.go

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

* Update provisionersdk/agent.go

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

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-07-11 14:10:06 +00:00
dependabot[bot] 3e279b6d23 chore: bump tailscale.com from 1.26.1 to 1.26.2 (#2890)
Bumps [tailscale.com](https://github.com/tailscale/tailscale) from 1.26.1 to 1.26.2.
- [Release notes](https://github.com/tailscale/tailscale/releases)
- [Commits](https://github.com/tailscale/tailscale/compare/v1.26.1...v1.26.2)

---
updated-dependencies:
- dependency-name: tailscale.com
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 09:09:17 -05:00
Mathias Fredriksson c7681370b5 fix: Wrap help flags at 100 chars (#2893)
Because the actual flags take quite a bit of space, wrapping at 80
characters creates a very cramped output for e.g. `coder server`, for
this reasons, flags are wrapped at 100 chars (vs. standard 80).

The `Consumes $ENV_FLAG` message was put on a newline for consistency,
this should allow users to learn where to look for the informations.

Side note: we should perhaps stop adding period (`.`) at the end of flag
descriptions to be consistent, for instance, command helps usually don't
have one.

This change fixes the biggest issue in #2363, but not all `--help`
output is guaranteed (yet) to wrap at 80-100 chars.

Fixes #2363
2022-07-11 17:07:25 +03:00
dependabot[bot] 2bf78aa548 chore: bump go.opentelemetry.io/otel/trace from 1.7.0 to 1.8.0 (#2887)
Bumps [go.opentelemetry.io/otel/trace](https://github.com/open-telemetry/opentelemetry-go) from 1.7.0 to 1.8.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.7.0...v1.8.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/trace
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 08:54:26 -05:00
Mathias Fredriksson 41de2d8b67 fix: Replace github.com/hashicorp/yamux with our fork (#2883) 2022-07-11 16:51:03 +03:00
dependabot[bot] c99c15232c chore: bump xterm-addon-web-links from 0.5.1 to 0.6.0 in /site (#2892)
Bumps [xterm-addon-web-links](https://github.com/xtermjs/xterm.js) from 0.5.1 to 0.6.0.
- [Release notes](https://github.com/xtermjs/xterm.js/releases)
- [Commits](https://github.com/xtermjs/xterm.js/commits/0.6)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 08:48:22 -05:00
dependabot[bot] 70d394f6a1 chore: bump @storybook/addon-links from 6.4.22 to 6.5.9 in /site (#2861)
Bumps [@storybook/addon-links](https://github.com/storybookjs/storybook/tree/HEAD/addons/links) from 6.4.22 to 6.5.9.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.9/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.5.9/addons/links)

---
updated-dependencies:
- dependency-name: "@storybook/addon-links"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-11 08:56:33 -04:00
Cian Johnston 8a59178e7e provisionersdk: extract and embed agent bootstrap scripts (#2886)
This commit extracts the existing hard-coded agent scripts to their own files and embeds them using go:embed.
We can more easily use e.g. shellcheck to validate our agent scripts.
2022-07-11 12:43:14 +01:00
Cian Johnston 8d8c1a1927 develop.sh: add missing embed tag (#2885) 2022-07-11 12:20:54 +01:00
Kyle Carberry 4f1df88529 fix: Always output job failure reason in provisioner daemon tests (#2850)
This flake can be seen here: https://github.com/coder/coder/runs/7186604615?check_suite_focus=true
2022-07-10 14:52:33 -05:00
mark-theshark 08a781f401 docs: expand web IDE documentation
* docker group for coder user and code-server xterm issue and port-forward web IDEs

* add screenshots of jupyterlab, rstudio and airflow in Coder

* Clean up English in install and minor edits

* Integrate Jupyter

Co-authored-by: ammario <ammar@ammar.io>
2022-07-09 02:40:05 +00:00
Kyle Carberry dff6e97f83 feat: Add allowlist of GitHub teams for OAuth (#2849)
Fixes #2848.
2022-07-08 21:37:18 -05:00
Kyle Carberry c801da45f3 fix: Add https: to image CSP to allow external images (#2870)
This broke external application icons.
2022-07-08 21:35:59 -05:00
Kyle Carberry 411caa20df fix: Refactor preinstall script to use useradd if adduser is not available (#2858)
Fixes #2800 preventing installation on Alpine.
2022-07-08 16:09:19 -05:00
Kyle Carberry 52fa1f2464 fix: Handle all method types for app proxying (#2868)
All methods need to be accepted on app routes. Some apps
may POST (like Jupyter).
2022-07-08 15:45:28 -05:00
dependabot[bot] 8589eb693a chore: bump sql-formatter from 6.1.1 to 8.0.2 in /site (#2862)
Bumps [sql-formatter](https://github.com/sql-formatter-org/sql-formatter) from 6.1.1 to 8.0.2.
- [Release notes](https://github.com/sql-formatter-org/sql-formatter/releases)
- [Changelog](https://github.com/sql-formatter-org/sql-formatter/blob/master/.release-it.json)
- [Commits](https://github.com/sql-formatter-org/sql-formatter/compare/v6.1.1...v8.0.2)

---
updated-dependencies:
- dependency-name: sql-formatter
  dependency-type: direct:development
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 14:54:43 -05:00
dependabot[bot] ff5930c7fe chore: bump ts-node from 10.7.0 to 10.8.2 in /site (#2823)
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.7.0 to 10.8.2.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v10.7.0...v10.8.2)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 14:29:15 -05:00
Ketan Gangatirkar 2609be767d feat: add timestamps to output at end of some workspace and template subcommands (#2831) 2022-07-08 14:27:56 -05:00
Kyle Carberry 584448e089 fix: worksapces -> workspaces in template create CLI (#2857)
Fixes #2846.
2022-07-08 14:22:30 -05:00
Ketan Gangatirkar ca90189a9b fix: Upload the Windows .exe in CI (#2833)
Co-authored-by: kylecarbs <kyle@carberry.com>
2022-07-08 18:32:16 +00:00
dependabot[bot] c2bb5ee2b1 chore: bump github.com/klauspost/compress from 1.15.6 to 1.15.7 (#2816)
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.15.6 to 1.15.7.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Changelog](https://github.com/klauspost/compress/blob/master/.goreleaser.yml)
- [Commits](https://github.com/klauspost/compress/compare/v1.15.6...v1.15.7)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 13:13:50 -05:00
dependabot[bot] 5df5507cf3 chore: bump github.com/stretchr/testify from 1.7.5 to 1.8.0 (#2817)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.5 to 1.8.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.5...v1.8.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 13:13:18 -05:00
dependabot[bot] a7b73fe001 chore: bump google.golang.org/api from 0.85.0 to 0.86.0 (#2819)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.85.0 to 0.86.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.85.0...v0.86.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 13:13:07 -05:00
dependabot[bot] 7ae1878c51 chore: bump github.com/unrolled/secure from 1.10.0 to 1.11.0 (#2820)
Bumps [github.com/unrolled/secure](https://github.com/unrolled/secure) from 1.10.0 to 1.11.0.
- [Release notes](https://github.com/unrolled/secure/releases)
- [Commits](https://github.com/unrolled/secure/compare/v1.10.0...v1.11.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 13:12:56 -05:00
Kyle Carberry bacfd630fb fix: Disable random workspace filter tests due to flakes (#2855)
Contributes towards #2854.
2022-07-08 13:01:00 -05:00
Kyle Carberry 3d40cb85b7 fix: Reduce count to 1 for PostgreSQL tests (#2852)
It's unnecessary for these to run twice. It increases CI times  without
providing much additional assurance tests don't have race conditions.
This already runs with `-race` too.
2022-07-07 23:14:35 -05:00
Kyle Carberry dc58d1b734 fix: Update text in logout tests (#2851)
This fixes CI!
2022-07-07 21:46:31 -05:00
Ketan Gangatirkar 4f1e9dae27 Ketan/cli help tweak (#2803)
* fix CLI help text for logout

"log out" is verb, "logout" is a noun

* add CLI help for port-forward command (#2802)

* found another noun where a verb should be
2022-07-04 15:48:08 -05:00
Ketan Gangatirkar 88f852b42f restore windows builds to CI (#2827)
restore windows builds to CI
2022-07-04 15:37:48 -05:00
Spike Curtis b1e4cfe6c8 fix pubsub/poll race on provisioner job logs (#2783)
* fix pubsub/poll race on provisioner job logs

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

* only cancel on non-error

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

* Improve logging & comments

Signed-off-by: spikecurtis <spike@spikecurtis.com>
2022-07-01 14:07:18 -07:00
Abhineet Jain c1b3080162 fix: restrict edit schedule access (#2698) 2022-07-01 20:43:51 +00:00
Bruno Quaresma ea5c2cd09b refactor: Downsize the search bar a bit (#2789) 2022-07-01 17:37:08 -03:00
Kira Pilot ead3516fb5 fixing searchBar style type (#2785) 2022-07-01 15:09:44 -04:00
Bruno Quaresma 2d0ea00ffd refactor: Move schedule to the header (#2775) 2022-07-01 18:26:27 +00:00
Spike Curtis 22febc749a provisionerd sends failed or complete last (#2732)
* provisionerd sends failed or complete last

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

* Move runner into package

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

* Remove jobRunner interface

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

* renames and slight reworking from code review

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

* Reword comment about okToSend

Signed-off-by: Spike Curtis <spike@coder.com>
2022-07-01 09:55:46 -07:00
Jon Ayers e5d5fa7706 fix: reprompt for matching passwords on mismatch (#2758)
- Previously we only re-prompted for the password confirmation.
2022-07-01 11:49:39 -05:00
Jon Ayers 554d9917c0 feat: make 'templates update [name]' optional (#2761)
- If the name is not specified the current working directory
  name is used or the name specified by "--directory". This
  reflects 'templates create" behavior.
2022-07-01 11:49:29 -05:00
David Wahler 0dbfd265fb chore: clean up scripts for internal godoc site that's no longer used (#2770) 2022-07-01 10:55:05 -05:00
Abhineet Jain de1fc40000 fix: consistent workspace status b/w CLI and UI (#2743) 2022-07-01 14:40:03 +00:00
Bruno Quaresma 9776e66ff9 refactor: Make the applications more notable in the resources table (#2774) 2022-07-01 10:48:48 -03:00
Cian Johnston e14953461c fix: develop.sh: do not clobber existing login, pre-build coder binary for speed (#2750) 2022-07-01 11:09:19 +01:00
Colin Adler 482feef373 feat(devtunnel): support geodistributed tunnels (#2711) 2022-06-30 19:11:13 -05:00
Kira Pilot ae59f166fd chore: cleaning up workspaces table code (#2765)
* cleaning up workspace table code

* Update site/src/components/WorkspacesTable/WorkspacesTableBody.tsx

Co-authored-by: Joe Previte <jjprevite@gmail.com>

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-06-30 16:50:15 -04:00
David Wahler 29be359f3d Clarify wording of install.sh --dry-run output (#2751) 2022-06-30 13:01:54 -05:00
Jon Ayers 6ad0f31687 fix: don't check version on gitssh cmds (#2757) 2022-06-30 12:03:41 -05:00
Kira Pilot 64997705ab feat: adding active and hover states to search input (#2741)
* feat: adding active and hover states to search input

* adding error state

* cleaning up error state

* adding input value
2022-06-30 11:57:38 -04:00
Cian Johnston 8ad35c7353 feature: allow editing workspace deadline in UI (#2721)
This PR adds two buttons to edit the workspace deadline.

- These buttons only appear when a workspace is running and has a non-zero deadline
- Clicking the  button increases the deadline by one hour, to a max of 24 hours in the future
- Clicking the  button decreases the deadline by one hour, to a minimum of 30 minutes in the future (when the warning banner appears)
2022-06-30 16:45:14 +01:00
Abhineet Jain 9df6bc7ba1 fix: update template updated_at value (#2729)
* fix: update template updated_at value

* use Go time for all updated_at updates
2022-06-30 12:14:51 +00:00
Jon Ayers 7df5827767 feat: add version checking to CLI (#2725) 2022-06-29 17:49:40 -05:00
dependabot[bot] 45328ec0f1 chore: bump github.com/AlecAivazis/survey/v2 from 2.3.4 to 2.3.5 (#2277)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-29 16:49:24 -05:00
Steven Masley 38fb6cb4b4 test: Try again in unit test if user already exists (#2730) 2022-06-29 14:17:32 -05:00
Kira Pilot 03fd063d20 chore: adding some quality of life Playwright comments (#2726) 2022-06-29 14:25:56 -04:00
Kira Pilot d9668f7a4e add debounced search on type to the search bar (#2703)
* debounced search on type

* loading workspaces on page entry

* fixing e2e test

* removing boilerplate
2022-06-29 13:43:41 -04:00
Colin Adler 6a55889362 fix: disable wireguard in portforward and gitssh tests (#2728) 2022-06-29 17:37:26 +00:00
Steven Masley baa36182c0 fix: Allow spaces in searches (#2723) 2022-06-29 11:59:38 -05:00
Steven Masley 889e2e68ea security: Tighten csp connect-src to prevent external websockets (#2705) 2022-06-29 16:42:17 +00:00
Steven Masley ea7f9e2d47 chore: Parameter listing cmd default adding scope column (#2718) 2022-06-29 11:29:21 -05:00
Ammar Bandukwala a06bea7a3f docs: improve providers illustration (#2713)
* Remove unused providers.png

* Add beautiful providers-compute
2022-06-28 22:11:43 -05:00
Colin Adler 2b6dcb842d Revert "feat: add version checking to CLI" (#2712) 2022-06-29 02:42:23 +00:00
Jon Ayers 7ee7be3391 feat: add version checking to CLI (#2643)
* feat: add version checking to CLI
2022-06-28 20:55:34 -05:00
Jon Ayers 4b6189c9e9 fix: fix panic in template pull (#2710) 2022-06-28 19:54:28 -05:00
Abhineet Jain 0d25e1752f feat: Add filter on Users page (#2653)
This commit adds a new filter feature to the Users page.

- adds a filter to the getUsers API call and users state machine.
- adds filter UI to Users page view.
- addresses error handling in the filter component, users page and machine.
- refactors user table code.
- refactors common code for workspace filter.
- adds and updates unit tests and stories.
2022-06-28 19:12:15 -04:00
Spike Curtis cb2d1f488a fix: ci uses a migrated DB template (#2696)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-28 14:42:19 -07:00
Steven Masley 576aef40f2 chore: Add linter rule to catch missing return after http writes (#2702) 2022-06-28 14:13:37 -05:00
Katie Horne 09cb778620 chore: add info re: always updating images (#2635) 2022-06-28 14:06:54 -05:00
Abhineet Jain 37f9dffc02 fix: remove gotests.xml from .gitignore (#2704) 2022-06-28 15:20:30 +00:00
Cian Johnston 0052e6a21b add CAP_NET_BIND_SERVICE to coder.service (#2699)
* add CAP_NET_BIND_SERVICE to systemd unit

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-06-28 16:02:42 +01:00
Colin Adler a494489ffa fix: use valid ip mask in api keys when remote address is ipv6 (#2695) 2022-06-27 20:31:18 +00:00
Kyle Carberry 69f27efead fix: Close parameter file before test exit (#2694)
Flake seen here:
https://github.com/coder/coder/runs/7079404499?check_suite_focus=true
2022-06-27 14:42:26 -05:00
Kyle Carberry abfae1b4aa fix: Add coder user to docker group on installation (#2693)
This makes for a simpler setup, and reduces the likelihood
a user runs into a strange issue.
2022-06-27 14:12:43 -05:00
Timo 752d6096a1 example: Added docker volume to docker-code-server (#2592) 2022-06-27 14:07:30 -05:00
Jon Ayers 2353687610 feat: unexpose coderdtest.NewWithAPI (#2613)
* feat: unexpose coderdtest.NewWithAPI
2022-06-27 13:50:52 -05:00
Timo 7dfec821f5 example: Added code-server icon (#2591) 2022-06-27 14:46:41 -04:00
dependabot[bot] 2d3d822273 chore: bump tailscale.com from 1.26.0 to 1.26.1 (#2677)
Bumps [tailscale.com](https://github.com/tailscale/tailscale) from 1.26.0 to 1.26.1.
- [Release notes](https://github.com/tailscale/tailscale/releases)
- [Commits](https://github.com/tailscale/tailscale/compare/v1.26.0...v1.26.1)

---
updated-dependencies:
- dependency-name: tailscale.com
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 12:29:16 -05:00
Jon Ayers 3a3aa493f1 fix: use absolute path for config-ssh coder binary (#2647) 2022-06-27 12:15:55 -05:00
Kyle Carberry 6429dfee1f test: Use a template to prevent migrations from running for every test (#2462)
* test: Use a template to prevent migrations from running for every test

* Create a single makefile target

* Fix built-in race

* Extend timeout of built-in PostgreSQL fetch
2022-06-27 17:07:39 +00:00
Kyle Carberry d9da96cad0 fix: Add test for SCP (#2692)
* fix: Elongate agent disconnect timeout in tests

This will fix the flake seen here:
https://github.com/coder/coder/runs/7071719863?check_suite_focus=true

* fix: Add test for SCP

This was hanging due to the stdin pipe never being closed.
A test has been added to make sure it works!
2022-06-27 17:41:53 +01:00
dependabot[bot] a805565cd4 chore: bump github.com/hashicorp/hcl/v2 from 2.12.0 to 2.13.0 (#2680)
Bumps [github.com/hashicorp/hcl/v2](https://github.com/hashicorp/hcl) from 2.12.0 to 2.13.0.
- [Release notes](https://github.com/hashicorp/hcl/releases)
- [Changelog](https://github.com/hashicorp/hcl/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/hcl/compare/v2.12.0...v2.13.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hcl/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 11:36:32 -05:00
Steven Masley f41b50a253 feat: Updating workspace prompts new parameters (#2598) 2022-06-27 16:19:10 +00:00
Katie Horne 407c47fd65 chore: change Coder v2 to Coder OSS in docs (#2630) 2022-06-27 11:07:17 -05:00
dependabot[bot] 68b5f0a35a chore: bump github.com/jedib0t/go-pretty/v6 from 6.3.2 to 6.3.3 (#2689)
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.3.2 to 6.3.3.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.3.2...v6.3.3)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 15:54:30 +00:00
dependabot[bot] 998e75feb3 chore: bump github.com/hashicorp/hc-install from 0.3.2 to 0.4.0 (#2691)
Bumps [github.com/hashicorp/hc-install](https://github.com/hashicorp/hc-install) from 0.3.2 to 0.4.0.
- [Release notes](https://github.com/hashicorp/hc-install/releases)
- [Changelog](https://github.com/hashicorp/hc-install/blob/main/.goreleaser.yml)
- [Commits](https://github.com/hashicorp/hc-install/compare/v0.3.2...v0.4.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hc-install
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 15:48:41 +00:00
dependabot[bot] 5c8b09fee7 chore: bump github.com/stretchr/testify from 1.7.3 to 1.7.5 (#2690)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.3 to 1.7.5.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.3...v1.7.5)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 10:37:43 -05:00
dependabot[bot] 975b4f6df2 chore: bump github.com/pion/webrtc/v3 from 3.1.41 to 3.1.42 (#2688)
Bumps [github.com/pion/webrtc/v3](https://github.com/pion/webrtc) from 3.1.41 to 3.1.42.
- [Release notes](https://github.com/pion/webrtc/releases)
- [Commits](https://github.com/pion/webrtc/compare/v3.1.41...v3.1.42)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 15:12:22 +00:00
Kyle Carberry 08f4b193e1 fix: Elongate agent disconnect timeout in tests (#2687)
This will fix the flake seen here:
https://github.com/coder/coder/runs/7071719863?check_suite_focus=true
2022-06-27 15:06:51 +00:00
dependabot[bot] 4a2d29948e chore: bump github.com/spf13/cobra from 1.4.0 to 1.5.0 (#2679)
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.4.0...v1.5.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-27 09:58:02 -05:00
Kyle Carberry 33a04f661f fix: Check if start is nil before consuming in echo provisioner (#2686)
This caused a race seen here:
https://github.com/coder/coder/runs/7074123929?check_suite_focus=true#step:10:217
2022-06-27 09:57:37 -05:00
Abhineet Jain 82938944e7 refactor: update Prettier printWidth to 100 (#2684) 2022-06-27 10:53:44 -04:00
Camdon 09722ae1ef Bump version number for coder terraform provider (#2673) 2022-06-27 08:49:26 -05:00
Cian Johnston bbbd5241c3 develop.sh: attempt to create a Docker template automatically (#2627)
This commit makes the following changes:

- Adds two variables docker_host and docker_arch to the example docker-code-server template
- Adds an example params.yaml to docker-code-server and updates the README.md to reference these parameters
- scripts/develop.sh will now attempt to create a template using docker-code-server with the appropriate parameters for the environment
- Updated Lima example to make use of the template parameters for docker-code-server


Additional drive-bys:

- webpack.dev.ts references CODER_HOST and not CODERV2_HOST; updated develop.sh accordingly
- develop.sh should now terminate child processes upon error.
2022-06-27 09:59:08 +01:00
dependabot[bot] f9d830a2b6 chore: bump google.golang.org/api from 0.82.0 to 0.85.0 (#2632)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.82.0 to 0.85.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.82.0...v0.85.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-26 18:43:21 -05:00
Kyle Carberry 16ac54cbd9 fix: Wait for workspace build to complete before running SSH tests (#2671)
This was causing a race shown here:
https://github.com/coder/coder/runs/7063713786?check_suite_focus=true
2022-06-26 23:10:52 +00:00
Kyle Carberry dac6838fc3 fix: Await workspace build job before waiting for CLI output (#2670)
This was causing occasional flakes seen here:
https://github.com/coder/coder/runs/7063142245?check_suite_focus=true
2022-06-26 22:05:37 +00:00
Kyle Carberry 4851d932c4 fix: Split host and port before storing IP (#2594)
The IP was always nil prior, and this fixes the test to
check for that as well!
2022-06-26 21:22:03 +00:00
Kyle Carberry 545a9f3435 fix: Increase wait time for agent connection tests (#2667)
This was causing a test flake seen here:
https://github.com/coder/coder/runs/7063032150?check_suite_focus=true
2022-06-26 21:15:59 +00:00
Kyle Carberry 01c31b47a3 fix: Adjust pagination limit to be zero-based (#2663)
There isn't a use-case for querying a limit of zero. Using
-1 led to issues when using default parameters for querying.
2022-06-26 20:23:25 +00:00
Kyle Carberry 95e854d144 fix: Update database fake to check for nil time when streaming logs (#2664)
This caused a test flake seen here: https://github.com/coder/coder/runs/7056544834?check_suite_focus=true
2022-06-26 19:52:15 +00:00
Steven Masley 47796211d7 fix: Properly remove non matched workspaces (#2649) 2022-06-25 16:37:21 -05:00
Steven Masley 3312c814bd feat: Workspace filters case insensitive (#2646) 2022-06-25 06:22:59 -05:00
Abhineet Jain 90815e5119 feat: improve Users filter API (#2645) 2022-06-24 23:55:28 +00:00
Jon Ayers d1c69866e8 fix: provide environment variable for CLI session token (#2648) 2022-06-24 18:50:35 -05:00
Colin Adler 6aed58f486 feat: add ssh support over wireguard (#2642) 2022-06-24 16:21:46 -05:00
Colin Adler 26e85b0bbc fix: use typed wireguard public keys in database structs (#2639) 2022-06-24 15:45:28 -05:00
Oxylibrium 115730341e fix: ensure gcp resource names are lowercase (#2619) 2022-06-24 15:11:24 -04:00
Colin Adler 46c6b9ee27 fix: use correct default wireguard public key (#2638) 2022-06-24 17:16:36 +00:00
Abhineet Jain bd07284a68 feat: Add success messages for CLI commands (#2634) 2022-06-24 16:30:22 +00:00
Colin Adler 05b67ab1cf feat: peer wireguard (#2445) 2022-06-24 10:25:01 -05:00
Steven Masley d21ab2115d feat: Backend api for filtering users using filter query string (#2553)
* User search query string
2022-06-24 10:02:23 -05:00
Oxylibrium 981fb2764f fix: add copy fallback for insecure contexts (#2044) 2022-06-23 16:35:12 -04:00
Oxylibrium 885e7fd03e chore: update tsconfig target to es2018 (#2616) 2022-06-23 15:52:42 -04:00
Garrett Delfosse 0bcdfd584f fix: order apps by name (#2614) 2022-06-23 19:18:03 +00:00
Ben Potter a39a8563cc docs: use simplified path for dotfiles (#2615) 2022-06-23 14:12:35 -05:00
Abhineet Jain 9c8079b25e refactor: Extract workspace filter into a separate component (#2601) 2022-06-23 11:30:53 -04:00
Kira Pilot 929227d0f8 bug: fix chromatic schedule bug (#2481) 2022-06-23 11:25:07 -04:00
Presley Pizzo 65870e65ce feat: Move agent status (#2593)
* Move agent status

* Format
2022-06-23 10:18:56 -04:00
Cian Johnston ac557e02b8 clean site/out and enforce make bin (#2604) 2022-06-23 15:16:27 +01:00
Katie Horne 4eda7034ee chore: fix broken links to use full path (#2606) 2022-06-23 09:04:31 -05:00
Kyle Carberry b55fca4904 fix: Increase timeout for streaming logs (#2596)
One second wasn't long enough, and was causing flakes in CI.
2022-06-23 09:00:00 -05:00
Abhineet Jain c6b1daabc5 feat: Download default terraform version when minor version mismatches (#1775) 2022-06-22 23:11:52 +00:00
Garrett Delfosse 6a2a145545 fix: simplify terminal link (#2597) 2022-06-22 17:10:58 -05:00
Kira Pilot 97d1d2f4f0 added a default app icon (#2595)
resolves #2268
2022-06-22 17:05:21 -04:00
Eric Paulsen 7dc3f5f92b init: oauth docs (#2565)
* init: oauth docs

* chore: update directories

* update: feedback
2022-06-22 15:25:06 -05:00
Mathias Fredriksson 69b7eed7ed feat: Check decompressed coder-slim binaries via SHA1 (#2556) 2022-06-22 21:33:23 +03:00
Cian Johnston a0c8e70d1b scripts/develop.sh: remove nc dependency (#2590) 2022-06-22 18:04:12 +00:00
Kyle Carberry 3f9776784c fix: Subtract a second when listening in TestWorkspaceBuildLogs (#2588)
This allowed a test flake seen here:
https://github.com/coder/coder/runs/7009119403?check_suite_focus=true#step:9:151
2022-06-22 17:48:03 +00:00
Abhineet Jain cfbda57990 fix: Parse 24h time format from schedule cron in CLI (#2586)
* fix: parse 24h time format from schedule cron in cli

* add unit test
2022-06-22 17:45:00 +00:00
Kyle Carberry b7eeb436ad feat: Add ip_address to API keys (#2580)
Fixes #2561.
2022-06-22 17:32:21 +00:00
Kyle Carberry caf9c41a9e fix: Stop sending before logs when after is specified (#2585)
This fixes duplicate logs appearing in completed jos!
2022-06-22 17:09:28 +00:00
Kyle Carberry 437066ce20 fix: Stop sending additional signals in Shutdown test (#2582)
Coder was exiting before the additional signals were handled,
which caused occasional CI failures.
2022-06-22 11:32:34 -05:00
Abhineet Jain f72a6d09fc fix: Open new windows for terminals (#2568) 2022-06-22 12:29:08 -04:00
David Wahler c366725472 Revert changes to scripts/build_go_matrix.sh from 1778db2 (#2581) 2022-06-22 15:59:20 +00:00
Mathias Fredriksson 11c47e0d3b feat: Rename config-ssh --diff to --dry-run (#2575)
* feat: Rename config-ssh `--diff` to `--dry-run`

Since the intent between diff and dry-run are different, this change
allows for interactive prompts to be shown during `--dry-run`,
previously prompts were disabled. Dry-run can also be chanied with
`--yes` and `--use-previous-options` for non-interactive modes.

Dry-run is like a normal run with changes replaced by diff.

Fixes #2530

Co-authored-by: Cian Johnston <cian@coder.com>
2022-06-22 18:33:08 +03:00
Abhineet Jain bd19fcbae1 Wrap code text in template readme files (#2562) 2022-06-22 11:01:43 -04:00
Cian Johnston 92bcacebde cli/templateinit: add links to template READMEs (#2576)
- template init: add links to template docs
- examples: add URL field to examples, ensure that example fields are always non-empty
- cliui: bump wrap width to 80 from 58
2022-06-22 14:15:04 +00:00
Katie Horne 34222b2260 chore: add doc on roles, user management (#2548) 2022-06-22 13:36:48 +00:00
Kyle Carberry 1778db23cb fix: Use WebSockets to stream workspace build logs (#2569)
* fix: Use WebSockets to stream workspace build logs

This was using a streaming HTTP request before, which didn't work
on my version of Chrome. This method seemed less reliable and standard
than a WebSocket, so figured switching would be best.

* Update site/src/xServices/workspaceBuild/workspaceBuildXService.ts

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>

* Update site/src/pages/WorkspaceBuildPage/WorkspaceBuildPage.test.tsx

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>

* Update site/src/api/api.ts

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>

* Remove unused prop

Co-authored-by: Abhineet Jain <AbhineetJain@users.noreply.github.com>
2022-06-22 13:23:14 +00:00
Cian Johnston dc7d6def8e improve develop.sh (#2572)
- Running make dev now prompts you to run ./scripts/develop.sh manually, as GNU make does not appear to pass SIGINT to subprocesses.
- Added checks to develop.sh to ensure that coderd is listening before running our initial setup steps
- Add some more troubleshooting/debugging output to develop.sh
2022-06-22 14:02:31 +01:00
Kyle Carberry 7f778316ac fix: Remove duplicate logs from WorkspaceBuildPage (#2564) 2022-06-21 18:30:40 -05:00
Ketan Gangatirkar 5d2368cb1e remove incorrect coder open invocation from README.md screenshot (#2566) 2022-06-21 23:22:32 +00:00
Jon Ayers ee5918217b fix: cleanup reaper implementation (#2563)
- Clean up the agent/reaper API to be a more isolated and reusable package.
2022-06-21 18:01:34 -05:00
Ben Potter 0585372170 add enhanced docs for creating & troubleshooting templates (#2546)
Co-authored-by: Katie Horne <katie@coder.com>
2022-06-21 15:17:07 -05:00
Ammar Bandukwala 9d02a37ba9 Condense footer (#2555)
Since the footer is included in every page, we should try extra
hard to use little vertical space.

Also, I add an icon to the version text for balance.
2022-06-21 19:46:43 +00:00
Kyle Carberry 06ea7c8388 test: Remove max processes on Windows runner (#2457)
This was added because the runner was running out of memory.
It has potential to reduce our CI time significantly, so we'll
see if it still happens.
2022-06-21 12:04:27 -05:00
Mathias Fredriksson e2785ada5e feat: Compress and extract slim binaries with zstd (#2533)
Fixes #2202

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-06-21 19:53:36 +03:00
Mathias Fredriksson 64f0473499 chore: Prefer [[ over [ in bash build scripts (#2543) 2022-06-21 19:51:32 +03:00
Kyle Carberry fe81b0b859 fix: Wait for TestServer/Telemetry to close before exit (#2554)
This was causing occasional test failures due to leakage!
2022-06-21 19:50:29 +03:00
Kyle Carberry a48a838c9e fix: Wrap TableCell with Link for native browser routing (#2532)
Tables were previously using an onClick handler which replicated some
Link behavior, but not natively through the browser.

Fixes #2525.
2022-06-21 16:31:16 +00:00
dependabot[bot] 1ce28836d1 chore: bump github.com/stretchr/testify from 1.7.2 to 1.7.3 (#2518)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.2 to 1.7.3.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.2...v1.7.3)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-21 10:32:32 -05:00
Kira Pilot 5d2579fcda fix: adjusting language and icon for feedback link (#2483)
* fix: adjusting language and icon for feedback link

* adjust classname
2022-06-21 09:56:08 -04:00
Abhineet Jain a40089c22a Update template users language (#2523) 2022-06-21 09:38:03 -04:00
Katie Horne f476a4ad37 chore: fix broken links and formatting issues (#2547) 2022-06-21 13:13:38 +00:00
Ketan Gangatirkar 93b78755a6 change Docker main.tf to be multiline and make the README.md wrap more nicely (#2537)
see issue #2385
2022-06-21 05:34:14 -05:00
Abhineet Jain 7a4fd12911 Alias users CLI subcommand as user (#2522) 2022-06-20 10:40:08 -04:00
Abhineet Jain 8a853a64a5 Show build initiator on Workspace Build page (#2446)
* show build initiator in ui

* update autostop story
2022-06-20 10:38:57 -04:00
Katie Horne 6d0579d6b6 chore: sync readme and install (#2442) 2022-06-19 15:49:42 -05:00
Ben Potter a19493bd53 add docs for web IDEs (code-server, JetBrains Projector, VNC) (#2448)
* add "configuring web IDEs" doc

* no jupyterhub for now

* change location of web IDE page

* add Dockerfile example

* add run instructions
2022-06-19 20:45:14 +00:00
Dean Sheather 9bdaec6a21 fix: use armhf architecture in linux packages (#2514) 2022-06-20 06:12:38 +10:00
Dean Sheather 153ffc0ee9 fix: include architecture and version information in linux packages (#2511) 2022-06-19 18:56:07 +00:00
Dean Sheather 97348b1c9d fix: replace underscores with hyphens in slim binary name (#2509) 2022-06-19 18:15:20 +00:00
Dean Sheather 8d6faa3c1a fix: login before pushing docker images in release pipeline (#2496) 2022-06-19 13:12:09 +10:00
Dean Sheather 4b3608b628 fix: run git fetch --tags --force during release (#2495) 2022-06-19 10:39:01 +10:00
Dean Sheather dc115688b8 fix: checkout tags in deploy job (#2493) 2022-06-18 22:16:14 +00:00
Dean Sheather 167ab281e4 fix: fix ERRPIPE in build scripts, fix deploy (#2492) 2022-06-18 21:47:37 +00:00
Dean Sheather 075e891f28 Remove goreleaser in favor of build scripts (#2143) 2022-06-19 05:47:10 +10:00
Dean Sheather a9c166491d fix: synchronize terraform log output, fix init coloring (#2482) 2022-06-19 05:26:43 +10:00
Spike Curtis 54a585dbf6 Log provisioner outputs from TestProvision_ExtraEnv (#2427)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-17 14:47:05 -07:00
Spike Curtis 0aa66b4296 Lock the fake database during transactions (#2478)
* Lock the fake database during transactions

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

* Add ut for fake database transactions

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

* fix lint

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

* Fix lint macOS

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-17 13:50:11 -07:00
Cian Johnston 1455603505 fix: cli: create: use new autostart format, opt-in by default (#2472) 2022-06-17 20:38:10 +00:00
Steven Masley edd1083176 fix: Fix test flake based on same update time (#2484) 2022-06-17 15:20:21 -05:00
Steven Masley 4616499030 chore: Reuse ComputedParmeter, remove duplicated codersdk type (#2477)
* chore: Reuse ComputedParmeter instead of custom type
2022-06-17 15:20:13 -05:00
Cian Johnston 0b6efce466 add lima template for coder (#2452)
This commit adds a lima example for Coder.
You can now run limactl start --name=coder ./examples/lima/coder.yaml and have a "prod-like" Coder instance up and running within a minute or so.

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-06-17 20:12:42 +00:00
Steven Masley a9d62cc992 fix: Fix nested transactions should function correctly (#2470)
* fix: Fix nested transactions should function correctly

Inner tx should reuse outer tx
2022-06-17 15:10:44 -05:00
Cian Johnston 0d2f0d7f8c chore: apply non-durability settings to test postgres container (#2479)
This commit applies some recommended settings to sacrifice durability
for speed for our testing database:
  - Mount PGDATA dir on a tmpfs (--tmpfs /tmp)
  - Turn off fsync
  - Turn off synchronous_commit
  - Turn off full_page_writes

  Ref: https://www.postgresql.org/docs/current/non-durability.html
2022-06-17 20:57:38 +01:00
Mathias Fredriksson 17ba4c8e88 fix: Allow template names to be re-used after deletion (#2454)
Fixes #2152
2022-06-17 19:18:07 +00:00
Abhineet Jain 289b98978f Add reason field for workspace builds (#2438)
* add reason field for workspace build

* add the reason field to FE via API

* update BuildReasonMember to BuildReasonInitiator

* add unit tests

* add more unit tests

* add error for unknown transition

* fix lint

* add documentation

* fix unit tests

* fix generated types

* remove nested transaction

* rename migration file
2022-06-17 13:41:11 -04:00
Kira Pilot 7dcfea10dc feat: add feedback link to footer (#2447)
* add ability to activate users

resolves #2254

* added test

* PR feedback

* guarding against null validation_contains field

* fixing type for ParameterSchema

resolves #2161

* added report link to footer

resolves #1885

* added test

* Footer story

* fix broken test
2022-06-17 13:26:13 -04:00
Steven Masley 64b92eea67 feat: Allow inheriting parameters from previous template_versions when updating a template (#2397)
* WIP: feat: Update templates also updates parameters
* Insert params for template version update
* Working implementation of inherited params
* Add "--always-prompt" flag and logging info
2022-06-17 12:22:28 -05:00
Jon Ayers 18973a65c1 fix: Add reaper to coder agent (#2441)
* fix: Add reaper to coder agent

- The coder agent runs as PID 1 in some of our Docker workspaces.
  In such cases it is the responsibility of the init process to
  reap dead processes. Failing to do so can result in an inability
  to create new processes by running out of PIDs.

  This PR adds a reaper to our agent that is only spawned if it
  detects that it is PID1.
2022-06-17 11:51:46 -05:00
Mathias Fredriksson 6c1208e3db feat: Clean up coder agent path in ps listing (#2453)
This commit changes the `coder agent` path in `ps` listing from
`/tmp/tmp.coderwWs87Y/coder agent` to `./coder agent`.

The path is also updated to `/tmp/coder.wWs87Y`.

There were two options considered for turning `./coder agent` into
`coder agent`:

1. Run `exec -a coder /path/to/coder agent`
2. Run `PATH=/path/to:$PATH exec coder agent`

Option 1 is not supported by `dash`, and thus discarded.

Option 2 duplicates functionality in `coder agent` which _appends_ the
path, here we would want to _prepend_ it to ensure we're starting the
downloaded `coder` binary in case there is a binary with a conflicting
name on the system.

Fixes #2407
2022-06-17 19:37:47 +03:00
Mathias Fredriksson 18b0effa83 fix: Add --yes and --use-previous-options to config-ssh (#2458) 2022-06-17 18:03:15 +03:00
Kyle Carberry 7cce7a9c69 test: Write URL after signal listen to fix flake (#2456)
The URL could be read before the signal was listening, causing
this test to flake: https://github.com/coder/coder/runs/6936820170?check_suite_focus=true
2022-06-17 14:16:45 +00:00
Kyle Carberry f09ab03baf fix: Add flag to toggle telemetry (#2455)
* fix: Add flag to toggle telemetry

This allows users to entirely disable tracking from Coder!
Telemetry is enabled by default, so this is opt-out.

* Update cli/server.go

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

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-06-17 14:02:44 +00:00
Bruno Quaresma d0aca86657 feat: Show help tooltip on hover (#2423) 2022-06-17 12:50:54 +00:00
Bruno Quaresma 3415b9daef feat: Pop out all apps (#2346) 2022-06-17 12:36:48 +00:00
Bruno Quaresma 9fdee5d391 fix: Storybook error on complex args (#2424) 2022-06-17 09:19:41 -03:00
Kyle Carberry b9f3fe49cb fix: Start login shells on macOS and Linux (#2437)
This appends `-l` to the shell command on macOS and Linux.
It also adds environment variable expansion to allow for
chaining from `coder_agent.env`.
2022-06-17 05:54:45 +00:00
kylecarbs be02d87f22 fix: Swap migration numbers to fix deployment 2022-06-17 05:47:13 +00:00
Kyle Carberry 4cce969018 feat: Add anonymized telemetry to report product usage (#2273)
* feat: Add anonymized telemetry to report product usage

This adds a background service to report telemetry to a Coder
server for usage data. There will be realtime event data sent
in the future, but for now usage will report on a CRON.

* Fix flake and requested changes

* Add reporting options for setup

* Add reporting for workspaces

* Add resources as they are reported

* Track API key usage

* Ensure telemetry is tracked prior to exit
2022-06-17 00:26:40 -05:00
Ben Potter af8a1e3fea package app icons (#2449) 2022-06-17 05:13:37 +00:00
Ammar Bandukwala 40ef1546e1 docs: add architecture page (#2450) 2022-06-16 23:46:02 -05:00
Ammar Bandukwala de213934d1 docs: expand dotfiles section (#2444) 2022-06-16 18:48:18 -05:00
Katie Horne 535481139a chore: add IDEs page to sidebar (#2443) 2022-06-16 18:09:40 -05:00
Katie Horne a09d2af977 chore: add basic postgres instructions for byo databases (#2430) 2022-06-16 17:54:15 -05:00
Katie Horne 0c9ff3a2ac chore: change git link so that it uses https instead of ssh (#2431) 2022-06-16 16:21:52 -05:00
Katie Horne da9009bd3e chore: add link from install.md to Docker example README (#2435) 2022-06-16 16:06:10 -05:00
Spike Curtis 93b1425d85 Stop showing persistent vs ephemeral for resources (#2333)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-16 18:36:11 +00:00
Spike Curtis 552dad6919 Remove tfexec, allow TF_ environment vars and log them (#2264)
* Remove tfexec, allow TF_ environment vars and log them

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

* fixup: commented code, long lines

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

* rename executor methods to remove get

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

* don't log terraform environment variables we don't know are safe

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

* Disable linting of fake secret

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

* drop parse support and move logger into terraform package

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

* disable testpackage linter on internal package test

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-16 17:50:39 +00:00
Ammar Bandukwala 82c4b80c67 Docs touchups (#2421)
* Make secrets docs louder

* docs: a bunch of small touchups
2022-06-16 17:47:10 +00:00
Cian Johnston c9691eafcb feat: cli: consolidate schedule-related commands (#2402)
* feat: cli: consolidate schedule-related commands

This commit makes the following changes:
- renames autostart -> schedule starat
- renames ttl -> schedule stop
- renames bump -> schedule override
- adds schedule show command
- moves some cli-related stuff to util.go
2022-06-16 18:24:10 +01:00
Colin Adler c36b0d892b fix(devtunnel): use 1280 mtu (#2420)
This should be more compatible with cloud VMs and VPNs.
2022-06-16 12:12:04 -05:00
dependabot[bot] ba451b569a chore: bump github.com/gohugoio/hugo from 0.100.2 to 0.101.0 (#2416)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.100.2 to 0.101.0.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/goreleaser.yml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.100.2...v0.101.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-16 17:06:41 +00:00
dependabot[bot] c570501662 chore: bump github.com/nhatthm/otelsql from 0.3.0 to 0.3.3 (#2415)
Bumps [github.com/nhatthm/otelsql](https://github.com/nhatthm/otelsql) from 0.3.0 to 0.3.3.
- [Release notes](https://github.com/nhatthm/otelsql/releases)
- [Commits](https://github.com/nhatthm/otelsql/compare/v0.3.0...v0.3.3)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-16 11:51:16 -05:00
Mathias Fredriksson b3f2b7c80a feat: Add section for community templates (#2401)
* feat: Add section for community templates

* Add ntimo/coder-hetzner-cloud-template
2022-06-16 19:48:44 +03:00
dependabot[bot] edaa3f5fc3 chore: bump github.com/pkg/sftp from 1.13.4 to 1.13.5 (#2276)
Bumps [github.com/pkg/sftp](https://github.com/pkg/sftp) from 1.13.4 to 1.13.5.
- [Release notes](https://github.com/pkg/sftp/releases)
- [Commits](https://github.com/pkg/sftp/compare/v1.13.4...v1.13.5)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-16 11:30:34 -05:00
dependabot[bot] fda856d293 chore: bump github.com/jedib0t/go-pretty/v6 from 6.3.1 to 6.3.2 (#2314)
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.3.1 to 6.3.2.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.3.1...v6.3.2)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-16 11:29:54 -05:00
Katie Horne 6c1a111fa9 chore: add IDEs page (#2388) 2022-06-16 11:22:14 -05:00
Spike Curtis a82c0eb560 Fix socket leak, clean up single use postgres databases (#2413)
* Fix socket leak, clean up single use postgres databases

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

* Move migrate close defer until after we know it is not nil

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-16 09:01:33 -07:00
Katie Horne eab5c15062 chore: edit CLI/UI copy (#2247) 2022-06-16 10:28:41 -05:00
David Wahler 2d7e6d6530 disable TestPasswordTerminalState until we can make it run reliably (#2409) 2022-06-16 10:18:07 -05:00
Kyle Carberry 024ab6df57 fix: Use in-memory filesystem for echo provisioner tests (#2408)
* fix: Use in-memory filesystem for echo provisioner tests

This should reduce IO in CI to shave some time off tests!

* test: Increase timeouts to reduce flakes

It's difficult to understand what's timing out due to a lock
vs. taking a long time. This should help resolve! 🕵️
2022-06-16 15:09:22 +00:00
Kyle Carberry 5e673cc544 test: Increase timeouts to reduce flakes (#2406)
It's difficult to understand what's timing out due to a lock
vs. taking a long time. This should help resolve! 🕵️
2022-06-16 14:52:45 +00:00
Katie Horne a95d9b17f6 chore: remove index.md (#2403)
* chore: fix broken link

* chore: remove index.md
2022-06-16 14:46:01 +00:00
Ammar Bandukwala 29c9c1d928 docs: small improvements to install (#2400)
* Simplify install docs

* docs: clarify security policy
2022-06-16 12:30:56 +00:00
Kyle Carberry 10dc9e3876 fix: Force keeping old files to prevent dpkg failure on update (#2399)
Updating a release if system files failed would result in failure from
the install script. This fixes it!
2022-06-15 20:04:20 -05:00
Steven Masley 75205f5978 feat: Implement parameters list + more template list columns (#2359)
* feat: Implement parameters list

- Allow more columns on template list

* Hide param list by default for now
2022-06-15 18:21:01 -05:00
Katie Horne f5e558c4ec chore: convert citations to hyperlinks (#2392) 2022-06-15 16:11:44 -05:00
Kyle Carberry ccd061652b feat: Add built-in PostgreSQL for simple production setup (#2345)
* feat: Add built-in PostgreSQL for simple production setup

Fixes #2321.

* Use fork of embedded-postgres for cache path
2022-06-15 16:02:18 -05:00
Katie Horne bb4ecd72c5 chore: update quickstart (docs) (#2381) 2022-06-15 14:52:48 -05:00
Kira Pilot 0f44048fcc fix: adjust ParameterSchema type for workspace creation (#2384)
* add ability to activate users

resolves #2254

* added test

* PR feedback

* guarding against null validation_contains field

* fixing type for ParameterSchema

resolves #2161
2022-06-15 15:12:57 -04:00
Ammar Bandukwala 2e625c1d9b docs: use about as home page (#2382)
* docs: use About as home page

* docs: format install.md
2022-06-15 14:03:13 -05:00
Jon Ayers 961f5110ca fix: fix deleted workspace banner 404 (#2386)
- When a workspace is deleted the user is nudged
  to create a new workspace. The page to which they
  are routed 404s. This PR simply routes them to the
  /templates page where they can pick a template for their
  new workspace.
2022-06-15 13:34:26 -05:00
Dean Sheather 45eb1b4980 feat: improve terraform template parsing errors (#2331) 2022-06-16 04:12:17 +10:00
Jon Ayers 6cf483bf37 fix: allow server startup without tunnel (#2380)
- Previously, specifying 'no' to the tunnel prompt just killed
  the process. It should be possible to start the server without
  a tunnel and not have the process killed.
2022-06-15 12:54:01 -05:00
Jon Ayers 9b3b6418a2 feat: Add template pull cmd (#2329) 2022-06-15 12:42:43 -05:00
Kira Pilot a6a06d4e9c feat: ability to activate suspended users (#2344)
* add ability to activate users

resolves #2254

* added test

* PR feedback
2022-06-15 13:29:38 -04:00
Kira Pilot d48ab96511 trying to resolve Chromatic CI failures (#2350) 2022-06-15 13:04:47 -04:00
Ben Potter 8f7dbee813 fix: flaky install.sh upgrade on OSX (zsh killed) (#2309)
* remove binary exists

* fix lint and format errors

Co-authored-by: ben@coder.com <benpotter@bens-mbp.lan>
2022-06-15 11:09:52 -05:00
Abhineet Jain 55e538e854 fix: break word to wrap long strings in stats, add media query (#2310)
* break word to wrap long strings, add media query

* add stories for smaller screens
2022-06-15 11:16:03 -04:00
Cian Johnston 12a664fa9a fix: coderd: fix flaky test (#2343) 2022-06-15 14:32:02 +00:00
Katie Horne afa5443180 chore: update docs manifest to reflect current Coder version number (#2342) 2022-06-15 14:25:12 +00:00
Mathias Fredriksson 7808593a25 fix: Revert to old SSH config section management in config-ssh (#2341) 2022-06-15 17:22:30 +03:00
Katie Horne d0794910d9 chore: update link to go to Coder docs instead of GitHub (#2330) 2022-06-15 09:16:43 -05:00
Bruno Quaresma b225953f68 feat: Add "Outdated" tooltip and "Update version" button in the Workspaces page (#2322) 2022-06-15 13:52:05 +00:00
Colin Adler e9f87f12ec chore: skip devtunnel test (#2336) 2022-06-14 20:32:40 -05:00
Cian Johnston 02ad60fd75 fix: allow setting workspace deadline as early as now plus 30 minutes (#2328)
This PR makes the following changes:

- coderd: /api/v2/workspaces/:workspace/extend now accepts any time at least 30 minutes in the future.
- coder bump command also allows the above. Some small copy changes to command.
- coder bump now actually enforces template-level maxima.
2022-06-14 22:39:15 +01:00
Steven Masley 4734636b17 fix: compilation error on merge with Authorize call (#2319)
Merge caused compilation errors.
- Authorize call having too many arguments
- `workspaces_test.go` missing "fmt" import
2022-06-14 16:21:30 +00:00
Cian Johnston c28b7ecdf2 fix: coderd: decouple ttl and deadline (#2282)
This commit makes the following changes:

- Partially reverts the changes of feat: update workspace deadline when workspace ttl updated #2165, making the deadline of a running workspace build independant of TTL, once started.
- CLI: updating a workspace TTL no longer updates the deadline of the workspace.
- UI: updating a workspace TTL no longer updates the deadline of the workspace.
- Drive-by: API: When creating a workspace, default TTL to min(12 hours, template max_ttl) if not instructed otherwise.
- Drive-by: CLI: list: measure workspace extension correctly (+X in last column) from the time the provisioner job was completed
- Drive-by: WorkspaceSchedule: show timezone of schedule if it is set, defaulting to dayjs guess otherwise.
- Drive-by: WorkspaceScheduleForm: fixed an issue where deleting the "TTL" value in the form would show the text "Your workspace will shut down a few seconds after start".
2022-06-14 17:09:24 +01:00
Steven Masley 251316751e feat: Return more 404s vs 403s (#2194)
* feat: Return more 404s vs 403s
* Return vague 404 in all cases
2022-06-14 10:14:05 -05:00
Steven Masley dc1de58857 feat: workspace filter query supported in backend (#2232)
* feat: add support for template in workspace filter
* feat: Implement workspace search filter to support names
* Use new query param parser for pagination fields
* Remove excessive calls, use filters on a single query

Co-authored-by: Garrett <garrett@coder.com>
2022-06-14 08:46:33 -05:00
dependabot[bot] 5be52de593 chore: bump github.com/gohugoio/hugo from 0.100.1 to 0.100.2 (#2274)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.100.1 to 0.100.2.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/goreleaser.yml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.100.1...v0.100.2)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-13 21:39:16 -05:00
Colin Adler 961ddad925 fix: use command -v instead of which in agent bootstrap (#2307)
Certain distros don't ship with `which` (arch) and `command -v` is
built-in to the shell, so this is much more compatible.
2022-06-13 21:20:15 -05:00
Cian Johnston 0a949aaff2 cli: streamline autostart ux (#2251)
This commit adds the following changes:

- autostart enable|disable => autostart set|unset
- autostart enable now accepts a more natual schedule format: <time> <days-of-week> <location>
- autostart show now shows configured timezone
- 🎉 automatic timezone detection across mac, windows, linux 🎉

Fixes #1647
2022-06-13 22:09:36 +01:00
Bruno Quaresma 9d155843dd refactor: Replace PageHeaderText by PageHeaderSubtitle (#2287) 2022-06-13 17:12:47 -03:00
Steven Masley 1863da4ff4 chore: Add some more error context in cli (#2301) 2022-06-13 14:39:35 -05:00
Colin Adler dad42fe712 feat: gzip static http server assets (#2272) 2022-06-13 13:14:22 -05:00
Ben Potter d057e8cc03 docs: fix: use absolute link for examples (#2288)
* docs: fix: use absolute link for examples

* fix ugh
2022-06-13 12:50:05 -05:00
Abhineet Jain a91482cb25 fix: populate default created_by and add not-null constraint in templates (#2290) 2022-06-13 17:25:06 +00:00
Steven Masley 49f857806f fix: Do not write 2 errors to api on template fetch error (#2285) 2022-06-13 15:42:14 +00:00
Katie Horne cbde8e8b91 chore: add hero image to OSS docs homepage (#2241) 2022-06-13 09:16:26 -05:00
Colin Adler e3a1cd34b7 fix: ensure agentResource is non-nil (#2261) 2022-06-11 00:02:49 +00:00
Colin Adler 8415022bf9 fix(devtunnel): close http.Server before wireguard interface (#2263) 2022-06-10 23:40:33 +00:00
Colin Adler de6f86bf7a fix: ensure config dir exists before reading tunnel config (#2259) 2022-06-10 21:42:55 +00:00
Kira Pilot ec0bb7b330 feat: update language on workspace page (#2220) 2022-06-10 16:42:21 -04:00
Abhineet Jain 02d2aea7f2 feat: store and display template creator (#2228)
* design commit

* add owner_id to templates table

* add owner information in apis and ui

* update minWidth for statItem

* rename owner to created_by

* missing refactor to created_by

* handle errors in fetching created_by names
2022-06-10 19:24:21 +00:00
Garrett Delfosse 46da59a6b5 fix: use correct link in create from template button (#2253) 2022-06-10 13:38:43 -05:00
Colin Adler f562b74fa1 feat: use custom wireguard reverse proxy for dev tunnel (#1975) 2022-06-10 13:38:11 -05:00
David Wahler 71fd19631a feat: Warn on coderd startup if access URL is localhost (#2248) 2022-06-10 13:35:51 -05:00
Kyle Carberry f79ab7f87e fix: Remove easter egg mentioning competitor (#2250)
This is more confusing than helpful!
2022-06-10 18:14:06 +00:00
G r e y 928958c94c fix: workspace schedule time displays (#2249)
Summary:

Various time displays weren't quite right.

Details:

- Display date (not just time) of upcoming workspace stop in workspace
page
- Fix ttlShutdownAt for various cases + tests
  - manual to non-manual
  - unchanged/unmodified
  - isBefore --> isSameOrBefore
  - use the delta (off by _ error)
- pluralize units in dayjs.add
2022-06-10 17:26:20 +00:00
Mathias Fredriksson 1a9e57296c feat: Show template description in coder template init (#2238) 2022-06-10 19:54:28 +03:00
Joe Previte fcc52846da fix: update icon (#2216) 2022-06-10 11:23:20 -05:00
Abhineet Jain b2833c694b feat: update build url to @username/workspace/builds/buildnumber (#2234)
* update build url to @username/workspace/builds/buildnumber

* update errors thrown from the API

* add unit tests for the new API

* add t.parallel

* get username and workspace name from params
2022-06-10 12:08:50 -04:00
Kyle Carberry f9290b016e fix: Use explicit resource order when assocating agents (#2219)
This cleans up agent association code to explicitly map a single
agent to a single resource. This will fix #1884, and unblock
a prospect from beginning a POC.
2022-06-10 15:47:36 +00:00
Steven Masley 6bee180bb3 fix: Sort workspace by name by created_at (#2214)
* fix: Sort workspace by name by created_at

Fix bug where deleting workspaces with the same name returns the
oldest deleted workspace
2022-06-10 09:58:42 -05:00
Abhineet Jain 953e8c8fe6 feat: Allow admins to access member workspace terminals (#2114)
* allow workspace update permissions to access agents

* do not show app links to users without workspace update access

* address CR comments

* initialize machine context in the hook

* revert scoped connected status check
2022-06-10 10:46:48 -04:00
Mathias Fredriksson 0260e39d11 fix: Accept CODER_CACHE_DIRECTORY with CACHE_DIRECTORY fallback (#2236)
Fixes #2199
2022-06-10 17:00:00 +03:00
Ammar Bandukwala 06021bdc92 Make coder bump idempotent (#2230)
Resolves #2223

In addition to solving what's outlined in the issue,
I remove the client-side minute check because it had no
clear purpose when the API already returns an error.
2022-06-10 09:31:47 +01:00
ammario 6ea86c831b Revert "Make coder bump idempotent (#2225)"
This reverts commit 0df75f9176.

I merged on accident.
2022-06-10 03:31:13 +00:00
Ammar Bandukwala 0df75f9176 Make coder bump idempotent (#2225)
Resolves #2223

In addition to solving what's outlined in the issue,
I remove the client-side minute check because it had no
clear purpose when the API already returns an error.
2022-06-09 22:30:43 -05:00
Garrett Delfosse 92bda0d2c1 fix: allow admins to reset their own pass without old_password (#2222) 2022-06-10 11:43:54 +10:00
Garrett Delfosse b7234a6ce1 fix: push create workspace UX to templates page (#2142) 2022-06-09 18:43:49 -05:00
Cian Johnston 119db78bff feat: update workspace deadline when workspace ttl updated (#2165)
This commit adds the following changes to workspace scheduling behaviour:

* CLI: updating a workspace TTL updates the deadline of the workspace.
  * If the TTL is being un-set, the workspace deadline is set to zero.
  * If the TTL is being set, the workspace deadline is updated to be the last updated time of the workspace build plus the requested TTL. Additionally, the user is prompted to confirm interactively (can be bypassed with -y).
* UI: updating the workspace schedule behaves similarly to the CLI, showing a message to the user if the updated TTL/time to shutdown would effect changes to the lifetime of the running workspace.
2022-06-09 22:10:24 +01:00
G r e y 411d7da661 fix: ws schedule as 12-hour format (#2209)
This does not finish all tasks in #2175 but is one of the asks.
2022-06-09 16:20:29 -04:00
G r e y 377f17c292 fix: initialValues for ws schedule (#2213)
Summary:

When a schedule is not set, we default to M-F, 5 hours ttl
2022-06-09 15:20:53 -04:00
Bruno Quaresma d04d527f2c chore: Update docs manifest home page and icons (#2133)
* chore: Update docs manifest home page and icons

* RRemove contributors

* Update template icon

* fixup: manifest.json changes

* fix: add missing readme to root

* fix: add readme to /docs with toc

* fix: add quickstart to manifest

Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-06-09 18:46:16 +00:00
Ben Potter 0ec1e8f89b example: aws-linux: resize and use non-root user (#2186) 2022-06-09 18:10:01 +00:00
G r e y 92db80cadc fix: sort time zones (#2210)
Summary:

The list of time zones in the edit workspace schedule form is not sorted
alphabetically.
2022-06-09 18:42:27 +01:00
Kira Pilot 518495a6c5 feat: show deleted workspace after delete action (#2208)
* added deleted workspace banner

* x state pass

* added include_deleted param

* clean up x state

* added teests

* cleaning up unneeded xstate service
2022-06-09 11:43:49 -04:00
dependabot[bot] d0ac4d9e74 chore: bump eslint-plugin-react from 7.29.4 to 7.30.0 in /site (#2076)
Bumps [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) from 7.29.4 to 7.30.0.
- [Release notes](https://github.com/jsx-eslint/eslint-plugin-react/releases)
- [Changelog](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jsx-eslint/eslint-plugin-react/compare/v7.29.4...v7.30.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-09 11:17:52 -04:00
G r e y 857d83750a ci: storybook flake for auto-stop display (#2184)
Summary:

Uncaught from the change in https://github.com/coder/coder/pull/2171
2022-06-09 15:03:28 +00:00
Kyle Carberry fff59ef6ad fix: Add tests for instance and app association (#2198)
This was regressed in #2187. There was bad testing around this
before, and this should prevent a similiar situation from happening
again!
2022-06-09 13:34:24 +00:00
Mathias Fredriksson 567e4afdfc example: Re-enable Digital Ocean project assignment (#2196)
The issue tracked in #1750 was fixed by #2187, we can now re-enable the
project resource.
2022-06-09 12:17:44 +03:00
Mathias Fredriksson 2621093452 fix: Stop showing resources after coder create (#2155)
Fixes #1036
2022-06-09 10:44:41 +03:00
Steven Masley 74fe38eb3d feat: Add initiator_username to workspace builds in apis (#2174)
* feat: Add initiator_username to workspace builds in apis
2022-06-08 20:23:35 -05:00
Kyle Carberry 14701498c9 fix: Improve Terraform agent<->resource association testing (#2187) 2022-06-08 17:40:34 -05:00
Ben Potter 42c6b0849d example: add and document dotfiles usage (#2046) 2022-06-08 21:23:54 +00:00
dependabot[bot] c33113786e chore: bump dayjs from 1.11.2 to 1.11.3 in /site (#2088)
Bumps [dayjs](https://github.com/iamkun/dayjs) from 1.11.2 to 1.11.3.
- [Release notes](https://github.com/iamkun/dayjs/releases)
- [Changelog](https://github.com/iamkun/dayjs/blob/v1.11.3/CHANGELOG.md)
- [Commits](https://github.com/iamkun/dayjs/compare/v1.11.2...v1.11.3)

---
updated-dependencies:
- dependency-name: dayjs
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-08 20:05:43 +00:00
Spike Curtis a86c957871 feat: set /Users/spike for coder agent in gcp-linux template (#2147)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-08 11:22:18 -07:00
Kira Pilot 3bc122b7d5 feat: added include_deleted to getWorkspaceByOwnerAndName (#2164)
* feat: added include_deleted

relates to #1955

* Update coderd/workspaces.go

defining vars in the scope of conditional

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

* Update coderd/workspaces.go

avoid newline

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

* Update coderd/workspaces.go

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

* PR feedback

* wrote test, added type

* Update coderd/workspaces_test.go

shortening test name

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

* taking out api.ts change for now

* casing

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Co-authored-by: Cian Johnston <cian@coder.com>
2022-06-08 14:04:05 -04:00
Spike Curtis 85821568a9 feat: set $HOME for coder agent in aws-linux template (#2150)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-08 09:51:33 -07:00
G r e y 9cc6d7b3b2 fix: show explicit schedule stop time (#2171)
This does not fully resolve all requests in #2141, but just the piece of
when the workspace is actually stopping.

Next, we will adjust the default extension from 90 minutes to 4 hours.
Lastly, we can look at customizing the extension time in the extension
flow or with a pre-emptive prompt next to the stop time.
2022-06-08 12:00:22 -04:00
G r e y b390250e2e fix: increase default extension time (#2172)
This does not fully close #2141, but builds upon #2171 to fulfill each
of the UX requests.

A next step (probably as a separate ticket) is to allow customizing
extension time pre-emptively.
2022-06-08 12:00:09 -04:00
Joe Previte b6899e2c18 docs: slim down readme (#2140)
* docs: move docs table of contents to docs/index.md

* docs: move how it works and IDE support to about.md

* docs: move readme steps to walkthrough

* docs: slim down readme

* refactor: walkthrough -> quickstart

* docs: minor edits
2022-06-08 08:37:03 -07:00
Cian Johnston 8cfe223192 feat: cli: allow editing template metadata (#2159)
This PR adds a CLI command template edit which allows updating the following metadata fields of a template:
- Description
- Max TTL
- Min Autostart Interval
2022-06-08 15:14:57 +01:00
Mathias Fredriksson b65259f95e feat: Refactor CLI config-ssh to improve UX (#1900)
- Magic block is replaced by Include statement
- Writes are only done on changes
- Inform user of changes via prompt
- Allow displaying changes via `--diff`
- Remove magic block if present
- Safer config writing via tmp-file + rename
- Parse previous `config-ssh` options, compare to new options and ask to use new (otherwise old ones are used)
- Tests the new functionality

Fixes #1326
2022-06-08 11:45:29 +03:00
Garrett Delfosse 945fa9dacf fix: bug where all workspaces filter defaulted to 'me' (#2145)
* fix: bug where all workspaces filter defaulted to 'me'
2022-06-07 22:15:50 +00:00
Dean Sheather 7b76afb069 Revert split release (#2139)
* Revert "chore: ignore artifacts dir (#2132)"

This reverts commit 27acb98571.

* Revert "chore: split release workflow so the majority happens on Linux (#2092)"

This reverts commit b87096b500.
2022-06-07 20:57:32 +00:00
Abhineet Jain 4b82509922 feat: Make workspaces, timeline, templates rows obviously clickable (#2047)
* add right arrow to build table rows

* Add clickable rows to template and workspace list

* Specify 1% width for chevron right
2022-06-07 19:11:56 +00:00
Garrett Delfosse 7258d6acc8 fix: Show correct 'no results' message on workspace filters (#2103) 2022-06-07 13:54:59 -05:00
Dean Sheather 27acb98571 chore: ignore artifacts dir (#2132) 2022-06-07 16:41:38 +00:00
Bruno Quaresma 3a79759405 fix: Docs paths (#2131) 2022-06-07 16:29:18 +00:00
Bruno Quaresma 2b0662bf48 fix: Add .md extension to the docs routes (#2128) 2022-06-07 15:56:05 +00:00
Steven Masley a391572690 test: Pagination api query param parsing (#2127)
* test: Pagination api query param parsing
2022-06-07 10:48:08 -05:00
Dean Sheather b87096b500 chore: split release workflow so the majority happens on Linux (#2092) 2022-06-07 15:24:46 +00:00
Presley Pizzo b4645b2d11 Clear error on cancel (#2107) 2022-06-07 11:02:20 -04:00
Steven Masley cc30d42473 chore: Fix some 'Message' linting errors on main (#2129) 2022-06-07 14:52:44 +00:00
Steven Masley af401e3fe1 chore: Linter rule for properly formatted api errors (#2123)
* chore: Linter rule for properly formatted api errors
* Add omitempty to 'Detail' field
2022-06-07 14:33:06 +00:00
Katie Horne 3f1e885d21 chore: add manifest.json (#2100) 2022-06-07 09:30:34 -05:00
Kyle Carberry 7e8692b0fd fix: Update routing for workspace schedule (#2113)
* fix: Update routing for workspace schedule

This was broken as part of #2101. It was a silly mistake,
but unfortunate our tests didn't catch it.

This is a rare change so unlikely to occur again, so I won't
make an issue adding tests.

* Update site/src/pages/WorkspaceSchedulePage/WorkspaceSchedulePage.tsx

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>
2022-06-07 14:28:47 +00:00
Bruno Quaresma a4e259e14b fix: Page header width in the workspace page (#2125) 2022-06-07 14:24:01 +00:00
Bruno Quaresma 3752f4c401 fix: Update tooltip messages for workspaces and resources (#2126) 2022-06-07 14:20:44 +00:00
Mathias Fredriksson 6da4810a5e chore: Add (skipped) ptytest test that hangs on Intel Mac (and Windows) (#1629)
Co-authored-by: Steven Masley <stevenmasley@coder.com>
2022-06-07 17:08:11 +03:00
Bruno Quaresma eedd293ad5 feat: Add helpful tooltips for the key features (#2097) 2022-06-07 13:43:46 +00:00
Presley Pizzo 6d966963da refactor: rename errors to validations (#2105)
* Update validation error unpacking

* Rename validations on backend

* Format
2022-06-07 09:31:15 -04:00
Bruno Quaresma 3616c629c7 refactor: Update status for build logs (#2087) 2022-06-07 08:24:27 -05:00
Cian Johnston 3e419ddb3d feat: enforce template-level constraints for TTL and autostart (#2018)
This PR adds fields to templates that constrain values for workspaces derived from that template.

- Autostop: Adds a field max_ttl on the template which limits the maximum value of ttl on all workspaces derived from that template. Defaulting to 168 hours, enforced on edits to workspace metadata. New workspaces will default to the templates's `max_ttl` if not specified.
- Autostart: Adds a field min_autostart_duration which limits the minimum duration between successive autostarts of a template, measured from a single reference time. Defaulting to 1 hour, enforced on edits to workspace metadata.
2022-06-07 13:37:45 +01:00
dependabot[bot] 3878e6434a chore: bump github.com/moby/moby (#2112)
Bumps [github.com/moby/moby](https://github.com/moby/moby) from 20.10.16+incompatible to 20.10.17+incompatible.
- [Release notes](https://github.com/moby/moby/releases)
- [Changelog](https://github.com/moby/moby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moby/moby/compare/v20.10.16...v20.10.17)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-07 01:53:04 +00:00
Kyle Carberry 94ed081a77 fix: Dependabot uses arrays for labels (#2111) 2022-06-07 01:35:44 +00:00
Kyle Carberry 16e66c61d9 fix: Remove dependabot labels (#2110)
This kept adding unnecessary labels to our tracker.
Once we need to filter for specific dependabot PRs,
we can add this back.
2022-06-07 01:17:56 +00:00
Ammar Bandukwala 8f1380774a Remove issue templates (#2109)
Per our product management conversation, we want to make
giving feedback as easy as possible initially.
2022-06-07 01:14:24 +00:00
Kyle Carberry 74d9fee444 fix: Make the workspace URL pretty (#2101)
This adds the `@username/workspacename` format to the
workspace page!
2022-06-06 17:53:39 -05:00
Steven Masley e2b2580196 chore: version sub command remove --version and -v flag (#2090)
* test: Add unit test for version cmd
2022-06-06 17:38:51 -05:00
Spike Curtis a7a7e7561d K8s template uses an authenticated environment (#2104)
* feat: K8s template uses authenticated environment

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

* fmt

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-06 14:39:23 -07:00
Garrett Delfosse a860b86256 fix: support substring search on workspace name (#2096) 2022-06-06 19:43:16 +00:00
Kyle Carberry 66cf59bbe1 fix: Apply environment variables to startup script (#2099)
This was stopping `coder` from being in the path, and allowed
applications started in the script to bypass injected environmnet
variables like `GIT_SSH_COMMAND`.
2022-06-06 14:20:25 -05:00
Garrett Delfosse 1a39931d56 fix: correct localhost url in dev webpack (#2098) 2022-06-06 18:38:39 +00:00
Katie Horne 318e9792ad expand README files for examples (#1946) 2022-06-06 13:03:07 -05:00
Garrett Delfosse 37b0aaa018 fix: add workspace option 'deleted' to options type (#2095)
* fix: add workspace option 'deleted' to options type

* dead code
2022-06-06 17:23:02 +00:00
Garrett Delfosse 367897ef6b Specify number of builds before reporting status on codecov (#2094) 2022-06-06 11:25:51 -05:00
Steven Masley cf477ffbf0 chore: bump github.com/open-policy-agent/opa from 0.40.0 to 0.41.0 (#2093) 2022-06-06 11:16:46 -05:00
dependabot[bot] d7be7a840a chore: bump msw from 0.39.2 to 0.42.0 in /site (#2075)
Bumps [msw](https://github.com/mswjs/msw) from 0.39.2 to 0.42.0.
- [Release notes](https://github.com/mswjs/msw/releases)
- [Changelog](https://github.com/mswjs/msw/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mswjs/msw/compare/v0.39.2...v0.42.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 10:11:50 -05:00
dependabot[bot] 9f496435da chore: bump @fontsource/inter from 4.5.10 to 4.5.11 in /site (#2084)
Bumps [@fontsource/inter](https://github.com/fontsource/fontsource/tree/HEAD/fonts/google/inter) from 4.5.10 to 4.5.11.
- [Release notes](https://github.com/fontsource/fontsource/releases)
- [Changelog](https://github.com/fontsource/fontsource/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fontsource/fontsource/commits/HEAD/fonts/google/inter)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 10:11:28 -05:00
Kyle Carberry ab8235f53e feat: Add links to the resource card for workspace applications (#2067)
* fix: Use proper webpack config for dev mode

This was broken when improving the build times. The typechecker
unfortunately missed it!

* feat: Add links to the resource card for workspace applications

Fixes #1907 and #805.

I'll make this pretty in another PR!

* Improve style
2022-06-06 09:50:07 -05:00
dependabot[bot] 722dbab337 chore: bump @typescript-eslint/eslint-plugin in /site (#2079)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.23.0 to 5.27.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.27.0/packages/eslint-plugin)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 14:46:38 +00:00
Garrett Delfosse 3be3bc261e fix: handle owner but no name syntax (#2045) 2022-06-06 10:38:38 -04:00
dependabot[bot] 77d068215a chore: bump github.com/stretchr/testify from 1.7.1 to 1.7.2 (#2073)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.1 to 1.7.2.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.7.1...v1.7.2)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 09:38:23 -05:00
dependabot[bot] 2824521d67 chore: bump google.golang.org/api from 0.81.0 to 0.82.0 (#2072)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.81.0 to 0.82.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.81.0...v0.82.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 09:38:13 -05:00
dependabot[bot] ffe25c3442 chore: bump github.com/gohugoio/hugo from 0.99.1 to 0.100.1 (#2071)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.99.1 to 0.100.1.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/goreleaser.yml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.99.1...v0.100.1)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 09:37:55 -05:00
Mathias Fredriksson 59a6826920 feat: Add support for pprof in coder agent (#1985)
* feat: Allow USR1 signal to start pprof
2022-06-06 16:38:33 +03:00
Kyle Carberry 0ac37b146d feat: Add page titles (#2070) 2022-06-06 08:34:10 -05:00
Spike Curtis 3f3ecbf8b3 feat: Authenticate Digital Ocean via environment variable (#2051)
* Digital Ocean example uses environment variable auth

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-06 07:05:16 -05:00
Kyle Carberry 1634f2cddd fix: Use proper webpack config for dev mode (#2061)
This was broken when improving the build times. The typechecker
unfortunately missed it!
2022-06-05 18:23:44 +00:00
Kyle Carberry 013f028e55 feat: Add workspace application support (#1773)
* feat: Add app support

This adds apps as a property to a workspace agent.

The resource is added to the Terraform provider here:
https://github.com/coder/terraform-provider-coder/pull/17

Apps will be opened in the dashboard or via the CLI
with `coder open <name>`. If `command` is specified, a
terminal will appear locally and in the web. If `target`
is specified, the browser will open to an exposed instance
of that target.

* Compare fields in apps test

* Update Terraform provider to use relative path

* Add some basic structure for routing

* chore: Remove interface from coderd and lift API surface

Abstracting coderd into an interface added misdirection because
the interface was never intended to be fulfilled outside of a single
implementation.

This lifts the abstraction, and attaches all handlers to a root struct
named `*coderd.API`.

* Add basic proxy logic

* Add proxying based on path

* Add app proxying for wildcards

* Add wsconncache

* fix: Race when writing to a closed pipe

This is such an intermittent race it's difficult to track,
but regardless this is an improvement to the code.

* fix: Race when writing to a closed pipe

This is such an intermittent race it's difficult to track,
but regardless this is an improvement to the code.

* fix: Race when writing to a closed pipe

This is such an intermittent race it's difficult to track,
but regardless this is an improvement to the code.

* fix: Race when writing to a closed pipe

This is such an intermittent race it's difficult to track,
but regardless this is an improvement to the code.

* Add workspace route proxying endpoint

- Makes the workspace conn cache concurrency-safe
- Reduces unnecessary open checks in `peer.Channel`
- Fixes the use of a temporary context when dialing a workspace agent

* Add embed errors

* chore: Refactor site to improve testing

It was difficult to develop this package due to the
embed build tag being mandatory on the tests. The logic
to test doesn't require any embedded files.

* Add test for error handler

* Remove unused access url

* Add RBAC tests

* Fix dial agent syntax

* Fix linting errors

* Fix gen

* Fix icon required

* Adjust migration number

* Fix proxy error status code

* Fix empty db lookup
2022-06-04 15:13:37 -05:00
dependabot[bot] 2c089d5a99 chore: bump github.com/ory/dockertest/v3 from 3.9.0 to 3.9.1 (#1892)
Bumps [github.com/ory/dockertest/v3](https://github.com/ory/dockertest) from 3.9.0 to 3.9.1.
- [Release notes](https://github.com/ory/dockertest/releases)
- [Commits](https://github.com/ory/dockertest/compare/v3.9.0...v3.9.1)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-04 15:12:54 -05:00
Kyle Carberry 5edd086b69 chore: Reduce deployment times by excluding Docker images (#1945)
* chore: Reduce deployment times by excluding Docker images

Only the Windows and Linux binaries are build during deploy, so we
can save many minutes by excluding Docker images.

* Stop docker image builds on snapshot

* Fix artifact upload

* Skip typecheck for release

* Flag deploy
2022-06-04 19:56:45 +00:00
Steven Masley c9a4642a12 chore: Update BE http errors to be ui friendly (#1994)
* chore: More UI friendly errors

Mainly capitlization + messages prefix error
2022-06-03 21:48:09 +00:00
Spike Curtis 847e2b18da Don't use parameters to pass secrets to GCP or AWS (#2039)
* Don't use parameters to pass secrets to GCP or AWS

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

* Fix fmt

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-03 14:29:22 -07:00
Kyle Carberry 43f622a52d fix: Remove unused workspace routes in favor of list with filter (#2038)
* fix: Remove unused workspace routes in favor of list with filter

This consolidates the workspace routes into a single place.
It allows users to fetch a workspace by their username and
workspace name, which will be used by the frontend for routing.

* Fix RBAC

* Fix CLI usages
2022-06-03 14:36:08 -05:00
Spike Curtis d8c440188e feat: Remove organization and user scoped parameters (#2007)
* feat: Remove organization and user scoped parameters

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

* Fixup dump.sql

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

* Fix dump.sql again

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

* Fix down migration

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-03 11:49:58 -07:00
David Wahler 582d636e54 feat: support fully-qualified workspace names in CLI (#2036) 2022-06-03 12:47:56 -05:00
Abhineet Jain fc38b61819 feat: use ConfirmDialog for ResetPasswordDialog (#2035)
* feat: use ConfirmDialog for ResetPasswordDialog

* fix lint

* make description typography a div

* use paragraph for string description, div otherwise

* fix lint
2022-06-03 17:35:09 +00:00
Colin Adler 60102cb22f chore: fix codecov ignore for queries.sql.go (#2037) 2022-06-03 12:26:59 -05:00
Garrett Delfosse 8b03e2b0e1 feat: Workspaces filtering (#1972)
Co-authored-by: G r e y <grey@coder.com>
Co-authored-by: Kira Pilot <kira@coder.com>
2022-06-03 17:20:28 +00:00
G r e y ac6cb269db feat: ws schedule timezone select (#2032)
Resolves: #1959

Summary:

The package tzdata is used to create a meaningful select-list for
timezone in the workspace schedule form.

Impact:

Improved UX. Furthermore, we guess your timezone if the form is being
initialized from scratch.
2022-06-03 12:52:02 -04:00
Abhineet Jain 2b12beef98 feat: Update success confirmation dialog and snackbar (#2005)
* feat: update success confirmation dialog and snackbar

* add success variants to confirm dialog and snackbar

* update story name

* use success variant for snackbar
2022-06-03 11:42:46 -04:00
G r e y 37aff0c8a9 fix: FE parsing of schedule with day strings (#2006)
Resolves: #1901

Summary:

We had a homegrown parser that only understood numbers, not strings like
MON or TUES. We replace the homegrown parser with cron-parser.

Details:

This was nearly a straight drop-in.

Impact:

Much less code/maintenance burden :D

What I learned:

Don't trust the README, sometimes you just gotta read the code or import
it and try it out. The `fields` representation of the parsed expression
was missing from their docs. I might open an issue or PR to update them!
2022-06-03 11:08:57 -04:00
Abhineet Jain 7e89d91ce3 feat: link to timezone database spells out timezone (#2026) 2022-06-03 14:57:09 +00:00
G r e y c2720577cb fix: ws schedule top-down restriction (#2008)
Resolves: #1958

Summary:

The workspace schedule form no longer disables certain fields based on
whether or not a start time is filled out. Instead, we validate that a
start time is provided if any of the days are checked.
2022-06-03 10:50:36 -04:00
Bruno Quaresma 88e8c96ddd feature: Load workspace build logs from streaming (#1997) 2022-06-03 09:23:45 -05:00
Abhineet Jain d6e9eab258 feat: Use consistent colors for links and highlighting (#1989)
* feat: consistent highlight colors

* update user dropdown menu border

* update borderedmenurow active color
2022-06-03 10:16:50 -04:00
Bruno Quaresma 6bb76782a6 feat: Open terminal in a new window (#2017) 2022-06-03 09:06:44 -05:00
Mathias Fredriksson b4f5920df5 fix: Avoid use of r.Context() after r.Hijack() (#1978) 2022-06-03 12:50:10 +03:00
Kyle Carberry 61aacff444 chore: Refactor site to improve testing (#2014)
It was difficult to develop this package due to the
embed build tag being mandatory on the tests. The logic
to test doesn't require any embedded files.
2022-06-03 04:27:21 +00:00
Colin Adler 89dde21837 fix: ensure listen websocket isn't opened for non-latest agents (#2002)
Exponential backoff is only enabled if the websocket fails to open. If
the websocket is opened but immediately killed, the agent will try to
immediately reconnect. This is desireable in cases where coderd is being
replaced or network conditions cause the connection to die, but not for
permanent errors.
2022-06-02 15:03:01 -05:00
Ketan Gangatirkar 0e1f868f5f tweak README.md headings around one liner 2022-06-02 14:48:22 -05:00
Ketan Gangatirkar 597994548d added one liner to run Coder at very top of README.md 2022-06-02 14:47:34 -05:00
G r e y 0b59ed30d0 feat: ui autostop extension (#1987)
Resolves: #1460

Summary:

An 'Extend' CTA on workspace schedule banner is added so that a user can
extend their workspace lease from the UI.

Details:

* feat: putWorkspaceExtension handler

* refactor: TypesGen dflt import in workspace.ts

* feat: defaultWorkspaceExtension util

Impact:

This completes the UI<-->CLI parity epic in an MVP way. Of course, a
future improvement to make is extending by times other than the default
90 minutes.
2022-06-02 15:44:11 -04:00
Oxylibrium 1a07d021fe ux: change colors for inflight workspace actions (#1986) 2022-06-02 12:52:20 -04:00
Abhineet Jain e09cd3e9cf feat: Update UI for error dialog and snackbar (#1971)
* feat: update ui for error dialog and snackbar

* update padding for buttons
2022-06-02 11:23:52 -04:00
Abhineet Jain 47c7eda670 feat: add a divider after Account menu item (#1927)
* add a divider after Account menu item

* test: improve Storybook tests

* add closed and open userdropdown tests

* add default isOpen

* extract UserDropdownContent into a single component

* remove the isOpen prop

* address nit comments

* update test name
2022-06-02 11:09:19 -04:00
Steven Masley e6ee7dd652 chore: Add linting rule to help catch InTx misuse (#1980)
* chore: Add linting rule to help catch InTx misuse

This isn't perfect, as if you nest your misuse in another code block
like an if statement, it won't catch it :/. It is better
than nothing
2022-06-02 14:50:15 +00:00
Abhineet Jain c463e7801c feat: Update TTL language to Time until shutdown (#1948)
* feat: update ttl language in frontend

* Update TTL Helper text

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>

* update TTL helper string

Co-authored-by: Presley Pizzo <1290996+presleyp@users.noreply.github.com>
2022-06-02 10:15:36 -04:00
G r e y ab69c22ddc fix: missing FE ttl constraint validation (#1952)
Resolves: #1908
2022-06-02 10:14:42 -04:00
Steven Masley b9983e417f feat: Handle pagination cases where after_id does not exist (#1947)
* feat: Handle pagination cases where after_id does not exist

Throw an error to the user in these cases
- Templateversions
- Workspacebuilds

User pagination does not need it as suspended users still
have rows in the database
2022-06-02 09:01:45 -05:00
Kira Pilot 419dc6b036 feat: flexbox updates on workspace page (#1963)
* feat: flexbox work on workspace page

resolves 1910

* fixing cancel text

* chromatic fixes

* resolves #1953

no overflox text on smaller screens
2022-06-02 09:57:36 -04:00
Bruno Quaresma 3fd4dcd9d5 fix: Display member role when user has no role (#1965) 2022-06-02 08:46:06 -05:00
Cian Johnston dcf03d8ba3 chore: refactor time.Duration -> int64 milliseconds for FE consumption (#1944)
* Changes all public-facing codersdk types to use a plain int64 (milliseconds) instead of time.Duration.
* Makes autostart_schedule a *string as it may not be present.
* Adds a utils/ptr package with some useful methods.
2022-06-02 11:23:34 +01:00
Mathias Fredriksson 51c420c90a feat: Add support for --identity-agent in coder ssh (#1954) 2022-06-02 11:13:38 +03:00
Spike Curtis 9e3a625898 Show workspace name in WorkspaceBuildStats component (#1933)
* Show workspace name in WorkspaceBuildStats component

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

* Fix WorkspaceBuildPage tests

Signed-off-by: Spike Curtis <spike@coder.com>
2022-06-01 16:49:43 -07:00
Cian Johnston b203d40123 fix: fix duplicate migrations (#1968) 2022-06-01 20:58:22 +00:00
Steven Masley 913c0f5e7f feat: Longer lived api keys for cli (#1935)
* feat: Longer lived api keys for cli
* feat: Refresh tokens based on their lifetime set in the db
* test: Add unit test for refreshing
2022-06-01 14:58:55 -05:00
Presley Pizzo bb400a4e82 fix: Show error message from backend on create existing user (#1964)
* Show error message from backend on create existing user

* Format
2022-06-01 15:52:54 -04:00
Ben Potter 46ffb67d60 feat: one-line install script (#1924)
* feat: one-line install script

* remove homebrew support

* remove arch linux

* use proper filename for packages

* fix variable format

* fix systemd instructions

* fixes to standalone script

* fix missing var bugs

* fix standalone install

* fix for MacOS

* format

* fix armv7 assets and zips

* remove windows

* update install docs

* support external sources with shellcheck

* shfmt

* add external sources to GitHub action & unfold

* change wording

* first template docs

* default to /usr/local instead

* add option for binary name
2022-06-01 14:15:09 -05:00
Bruno Quaresma f5a8d17aa8 feat: Add copy button to the SSH Page (#1962) 2022-06-01 19:01:36 +00:00
Bruno Quaresma b85de3ee79 feat: Improve empty states for workspaces and templates (#1950) 2022-06-01 17:32:55 +00:00
Dean Sheather 6be8a373e0 feat: run a terraform plan before creating workspaces with the given template parameters (#1732) 2022-06-02 00:44:53 +10:00
Steven Masley cc87a0cf6b feat: Implied 'member' roles for site and organization (#1917)
* feat: Member roles are implied and never exlpicitly added
* Rename "GetAllUserRoles" to "GetAuthorizationRoles"
* feat: Add migration to remove implied roles
* rename user auth role middleware
2022-06-01 09:07:50 -05:00
Presley Pizzo 2878346f19 Use backend error if possible (#1938) 2022-06-01 09:09:58 -04:00
Kyle Carberry 1fa50a9da1 fix: Race when writing to a closed pipe (#1916) 2022-06-01 07:59:03 -05:00
Cian Johnston 1c5d94ed5b fix: add all regions to aws examples (#1934) 2022-06-01 11:20:14 +01:00
Cian Johnston 7b40c692eb fix: coderd: dev mode should show verbose output by default (#1898)
* check buildinfo for devel prerelease tag and show verbose output if so
2022-06-01 11:00:42 +01:00
Steven Masley 7acb742218 feat: Prevent role changing on yourself. (#1931)
* feat: Prevent role changing on yourself.

Only allow changing roles on other users. Not much value in self changing
at the moment
2022-05-31 15:50:38 -05:00
Spike Curtis 4b0ed06a26 Remove set -u on yarn_install.sh to allow it to run on zsh (#1930)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-31 13:50:18 -07:00
G r e y 56ec53d04b fix: derive running ws stop time from deadline (#1920)
* refactor: isWorkspaceOn utility

Summary:

A utility is function is added that answers the question if a workspace
is on.

Impact:

This is a shared piece of logic in workspace scheduling presentations.
In particular it unblocks work in 1779, or at least allows an
implementation that shares details with the WorkspaceScheduleBanner.

Notes:

We could possibly instead return whether the workspace is "ON",
"UNKNOWN", or "OFF". Maybe a future improvement for that could be made
as the neds arrises.

* fix: derive running ws stop time from deadline

Summary:

When a workspace is on, the remaining time until shutdown needs to be
derived from the deadline timestamp, not implied from the TTL
2022-05-31 15:50:03 -04:00
G r e y c6167a94ef refactor: remove dangling comment (#1929) 2022-05-31 19:39:29 +00:00
Bruno Quaresma 65c17a04df feat: Add selected template link at the template select field (#1918) 2022-05-31 18:28:22 +00:00
Bruno Quaresma 75bcb739f9 refactor: Make login headline one line and add auth method section (#1922) 2022-05-31 16:40:56 +00:00
Kira Pilot 555bf2461a fix: change color of time icon for dark mode (#1923)
resolves #1791
2022-05-31 12:33:15 -04:00
G r e y bdacbd4989 refactor: mock provisioner job typings (#1919)
An unnecessary type assertion was being made on the status property;
instead we just type the object as a ProvisionerJob
2022-05-31 15:16:15 +00:00
Presley Pizzo 6f7b7f0248 feat: Delete workspace (#1822)
* Add delete button

* Add confirmation dialog

* Extract dialog, storybook it, and test it

* Fix cancel and redirect

* Remove fragment
2022-05-31 10:43:31 -04:00
Abhineet Jain 9b19dc9154 refactor: rename SettingsPages directory to UserSettingsPage (#1877) 2022-05-31 14:16:17 +00:00
Bruno Quaresma 83edbee2e1 fix: Replace yes by true and add set -x (#1914) 2022-05-31 14:14:14 +00:00
Kira Pilot dd55d4577d chore: remove react imports (#1867)
reolves #1856
2022-05-31 10:01:37 -04:00
Steven Masley 26a2a169df fix: Suspended users cannot authenticate (#1849)
* fix: Suspended users cannot authenticate

- Merge roles and apikey extract httpmw
- Add member account to make dev
- feat: UI Shows suspended error logging into suspended account
- change 'active' route to 'activate'
2022-05-31 08:06:42 -05:00
Cian Johnston e02ef6f228 chore: executor_test: reduce test execution time (#1876)
Removes 5-second wait in autobuild.executor unit tests:

- Adds a write-only channel to Executor and plumbs through to unit tests
- Modifies runOnce to return an executor.RunStats struct and write to statsCh if not nil
2022-05-30 20:23:36 +01:00
Ketan Gangatirkar ae4b2d88cd added links to our issues to reduce necessary thinking to report issues 2022-05-30 14:19:48 -05:00
Cian Johnston a8ae9b39b3 feat: enforce upper bounds on workspace TTL and Deadline (#1902)
* Enforces upper bound for workspace TTL
* Enforces upper bound for workspace deadline
2022-05-30 20:19:17 +01:00
Ketan Gangatirkar 17a57a44eb added community links 2022-05-30 14:16:02 -05:00
Ketan Gangatirkar 02692402d8 added #coder in the most prominent least awkward place 2022-05-30 14:12:33 -05:00
Ben Potter 6850db2a47 chore: fix additional typo in templates doc 2022-05-28 08:14:46 -05:00
Ben Potter 80ec67f3fd chore: fix typo in templates docs 2022-05-28 08:13:50 -05:00
Ben Potter 7ad68ca36b example: docker: support Windows hosts (#1880) 2022-05-28 01:09:29 +00:00
Kyle Carberry da7ed8b292 chore: Ignore scripts from code coverage (#1878)
Our CI scripts don't need to have thorough tests, and aren't
in the hot path of the product.
2022-05-27 22:25:24 +00:00
Garrett Delfosse 5598ac05dc fix: prevent email from being altered (#1863) 2022-05-27 22:25:04 +00:00
Asher cfa316be89 fix: incomplete message when intercepting console logger (#1875)
I was getting a message like "Warning: Failed type %s: %s%s".
2022-05-27 17:16:19 -05:00
Asher dd1484e24f fix: add missing key to resource row (#1874) 2022-05-27 17:16:04 -05:00
Garrett Delfosse 8222bdc3bc feat: add user password change page (#1866) 2022-05-27 18:08:28 -04:00
Ben 8cd7d4fa9c chore: update hero 2022-05-27 20:48:52 +00:00
Abhineet Jain d623eeb8d1 feat: delete API token in /logout API (#1770)
* delete API token in logout api

* add deleteapikeybyid to databasefake

* set blank cookie on logout always

* refactor logout flow, add unit tests

* update logout messsage

* use read-only file mode for windows

* fix file mode on windows for cleanup

* change file permissions on windows

* assert error is not nil

* refactor cli

* try different file mode on windows

* try different file mode on windows

* try keeping the files open on Windows

* fix the error message on Windows
2022-05-27 16:47:03 -04:00
Kyle Carberry d0ed107b08 fix: Add command to reconnecting PTY (#1860)
This fixes #1708 and opens the door for PTYs to execute
non-shell commands!
2022-05-27 14:51:20 -05:00
Kira Pilot 6052607936 feat: add user roles to menu (#1862)
* view user roles in menu

resolves #1524

* fix stories

* PR feedback
2022-05-27 15:27:51 -04:00
G r e y 8d7499feb7 feat: ui alert <= 30mins from deadline (#1825)
Summary:

When a workspace build is <= 30 minutes from auto-scheduled shutdown,
then an alert banner is displayed on the workspace page.
2022-05-27 15:23:56 -04:00
Cian Johnston ff542afe87 feat: allow bumping workspace deadline (#1828)
* Adds a `bump` command to extend workspace build deadline
 * Reduces WARN-level logging spam from autobuild executor
 * Modifies `cli/ssh` notifications to read from workspace build deadline and to notify relative time instead (sidestepping the problem of figuring out a user's timezone across multiple OSes)
 * Shows workspace extension time in `coder list` output e.g.
    ```
    WORKSPACE        TEMPLATE  STATUS   LAST BUILT  OUTDATED  AUTOSTART        TTL        
    developer/test1  docker    Running  4m          false     0 9 * * MON-FRI  15m (+5m)  
    ```
2022-05-27 20:04:33 +01:00
Ben Potter bde3779fec chore: clarify install options in README (#1844)
* chore: clarify install options in README

* clarify the path is an example, not a requirement

* Update README.md

Co-authored-by: Katie Horne <katie@coder.com>

* Update README.md

Co-authored-by: Katie Horne <katie@coder.com>

* Update README.md

Co-authored-by: Katie Horne <katie@coder.com>

* Update README.md

Co-authored-by: Katie Horne <katie@coder.com>

* Update README.md

Co-authored-by: Katie Horne <katie@coder.com>

Co-authored-by: Katie Horne <katie@coder.com>
2022-05-27 18:10:54 +00:00
Ben Potter 5000edbfe0 example: docker warning on Coder host (#1842) 2022-05-27 13:02:59 -05:00
Kyle Carberry 984dc2bffd fix: Close peer negotiate mutex if we haven't negotiated (#1774)
Closes #1706 and #1644.
2022-05-27 17:34:13 +00:00
Garrett Delfosse 24d1a6744a fix: Add route for user to change own password (#1812) 2022-05-27 17:29:55 +00:00
Mathias Fredriksson 608eb322a8 chore: Add .editorconfig, shfmt, shellcheck and subshell dir changes (#1649) 2022-05-27 20:15:19 +03:00
Mathias Fredriksson 1a70298b5c feat: Add examples/templates/do-linux for Digital Ocean Droplets (#1749)
Co-authored-by: Cian Johnston <cian@coder.com>
2022-05-27 20:04:43 +03:00
Oxylibrium 14cdd85b66 fix(site): username validation in forms (#1851)
* refactor(site): move name validation to utils
* fix(site): username validation in forms
2022-05-27 17:02:56 +00:00
Garrett Delfosse 8a5277e291 fix: restore previous session on coder server --dev (#1821) 2022-05-27 17:02:02 +00:00
Bruno Quaresma 7eacab82a2 refactor: Update users page to looks like others (#1850) 2022-05-27 16:47:11 +00:00
Ammar Bandukwala e2030bba38 Move competitive comparison to README
And rewrite a bit.

Resolves #1365.
2022-05-27 11:38:25 -05:00
Steven Masley ec1fe46138 feat: Move create organizations route (#1831)
* feat: last rbac routes
- move create organization to /organizations.
2022-05-27 11:19:13 -05:00
ketang d73a0f4f23 fixed grammar 2022-05-27 11:09:53 -05:00
Ben Potter 655f348812 chore: change README to fancy alpha note 2022-05-27 10:56:35 -05:00
Bruno Quaresma 2b2d0291c2 fix: Suspend user in the UI (#1841) 2022-05-27 15:23:56 +00:00
Bruno Quaresma 4125863226 fix: Fix template README when has front-matter notation (#1840) 2022-05-27 15:19:32 +00:00
Steven Masley a409a34819 fix: Open csp-images to allow external (#1835)
External images are required for the README parts of templates.
Only allowing https right now
2022-05-27 14:59:13 +00:00
Abhineet Jain 7a5c8734ee test: Fix unit test in 'TestWorkspaceExtend' (#1836) 2022-05-27 14:45:22 +00:00
Abhineet Jain 9929189c45 feat: add tag and value in validation error details (#1760)
* add tag and value in validation error details

* fix unit tests and linter

* add quotes around value

* fix unit tests
2022-05-27 10:13:13 -04:00
Ammar Bandukwala c5f06acb01 Add alpha disclaimer to README 2022-05-27 09:08:35 -05:00
Steven Masley ebaae75993 test: Unit test to assert role capabilities (#1781)
* test: Unit test to assert role permissions

This unit test allows for asserting which roles can perform
actions on various objects. This is much easier than making
unit tests to hit the api.
2022-05-27 08:48:19 -05:00
Mathias Fredriksson 12227874a8 fix: Detect changes to examples/templates in Makefile (#1829) 2022-05-27 16:34:32 +03:00
Garrett Delfosse 1361c1357a feat: inject USER into shells (#1818) 2022-05-26 18:01:47 -05:00
ketang 951dc2d8b0 update tagline 2022-05-26 17:00:09 -05:00
Joe Previte d01a687caa fix: typo in docker terraform template (#1811) 2022-05-26 21:28:17 +00:00
Joe Previte 4d79b806c0 docs: clarify installing Coder instructions (#1809) 2022-05-26 14:11:58 -07:00
G r e y b6d6276149 ci: disable chromatic on forks (#1806) 2022-05-26 20:27:32 +00:00
Colin Adler 5833e37354 fix: macos flake (#1804)
https://github.com/coder/coder/runs/6614638495?check_suite_focus=true#step:9:104
2022-05-26 15:21:48 -05:00
Colin Adler d135f85f69 fix: use correct devnull device on windows for proxy logs (#1803) 2022-05-26 15:21:36 -05:00
G r e y 7467bfe4ed chore: organize ws stats, schedule stories (#1790)
Resolves: #1681

Summary:

- Moves WorkspaceSchedule out of WorkspaceStats
- Adds WorkspaceScheduleForm directory

Impact:

Improves breadth of our chromatic visual regression tests since the
examples for WorkspaceStats were non-representative of the component
2022-05-26 16:14:08 -04:00
Kira Pilot d4c26d534c chore: remove admin dropdown (#1802)
resolves #1748
2022-05-26 16:04:51 -04:00
Presley Pizzo 07ebd59e94 fix: Remove workspace Settings button and page (#1807) 2022-05-26 20:02:37 +00:00
Garrett Delfosse 4d6e8526a8 chore: tolerate codecov failures in CI (#1798) 2022-05-26 14:48:34 -05:00
Kira Pilot b4c41d3904 chore: add users link to nav bar (#1797)
* chore: add users link to nav bar

resolves #1746

* fix test names
2022-05-26 15:25:13 -04:00
Garrett Delfosse 781f3d0641 fix: use dir over full path for coder bin (#1795) 2022-05-26 19:05:46 +00:00
Bruno Quaresma 7b393526c5 fix: Fix sensitive parameters being displayed in the new workspace form (#1796) 2022-05-26 13:42:25 -05:00
Presley Pizzo d2ff5904c0 fix: hide New user button if no permission (#1794) 2022-05-26 14:25:23 -04:00
Bruno Quaresma e1b0cb0bca Remove create template button from the UI (#1793) 2022-05-26 18:22:47 +00:00
Garrett Delfosse 3052a6d88e Add coder executable to PATH (#1771) 2022-05-26 12:59:41 -05:00
Presley Pizzo fc67c6efb1 fix: remove unused pages from Admin dropdown (org and settings) (#1788)
* Delete Orgs Page

* Delete Admin Settings page
2022-05-26 13:10:54 -04:00
Cian Johnston 8f0a5a81f1 feat: add API/SDK support for autostop extension (#1778)
* Adds deadline column to workspace_builds, associated DB/API plumbing
* database: Upon inserting a row into workspace_builds, deadline will 
  initially be zero.
* autobuild: Executor now checks the Deadline field of the workspace_build
  for the purpose of autostop logic.
* coderd: Adds a new route /api/v2/workspaces/:workspace/extend which allows
  updating the deadline of the currently active workspace build. The new
  deadline must be after the existing deadline, and not the zero time.
* provisionerd: updates workspace_build.deadline upon successful workspace 
  build completion (equal to now plus workspace TTL, if it exists).
2022-05-26 18:08:11 +01:00
Steven Masley c04d045279 feat: RBAC provisionerdaemons and parameters (#1755)
* chore: Remove org_id from provisionerdaemons
2022-05-26 11:20:54 -05:00
Bruno Quaresma 104d07f659 feat: Add the template page (#1754) 2022-05-26 16:19:11 +00:00
G r e y 7c59ec4a2b feat: edit workspace schedule page (#1701)
Resolves: #1455 
Resolves: #1456

Summary:

Adds a page (accessible from Workspace Schedule section on a workspace) to edit a schedule.

Impact:

General parity with CLI for autostart/autostop: that is you can update your schedule from the UI
2022-05-26 12:11:30 -04:00
Kira Pilot 9a70c345c7 fix: update workspace form fields when switching templates (#1761)
resolves #1716
2022-05-26 08:43:07 -04:00
Kyle Carberry 31b819e83f chore: Remove interface from coderd and lift API surface (#1772)
Abstracting coderd into an interface added misdirection because
the interface was never intended to be fulfilled outside of a single
implementation.

This lifts the abstraction, and attaches all handlers to a root struct
named `*coderd.API`.
2022-05-26 03:14:08 +00:00
Abhineet Jain c78f947e09 feat: Upgrade terraform version to 1.1.9 (#1745)
* upgrade terraform version to 1.1.9

* Fix docs typo

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-05-25 19:35:41 -04:00
Presley Pizzo 841d9f277c feat: UI for canceling workspace builds (#1735)
* Start hooking up cancel

* Update xservice

* Render cancel

Changes behavior of other buttons too

* Make outdated workspace story show max buttons

* Remove retry code

* Remove loading button state

* Fix type, extend tests

* Update story
2022-05-25 17:58:00 -04:00
Garrett Delfosse 35ccb88f60 feat: add dotfiles command (#1723) 2022-05-25 16:43:20 -05:00
Ben Potter 47ef03fea4 example: fix: properly tag aws-windows workspaces (#1744) 2022-05-25 22:11:29 +01:00
Colin Adler b5d615367e chore: update cdr.dev/slog (#1759)
Fixes #1626
2022-05-25 20:22:38 +00:00
Mathias Fredriksson 527f1f3bc3 feat: Add SSH agent forwarding support to coder agent (#1548)
* feat: Add SSH agent forwarding support to coder agent

* feat: Add forward agent flag to `coder ssh`

* refactor: Share setup between SSH tests, sync goroutines

* feat: Add test for `coder ssh --forward-agent`

* fix: Fix test flakes and implement Deans suggestion for helpers

* fix: Add example to config-ssh

* fix: Allow forwarding agent via -A

Co-authored-by: Cian Johnston <cian@coder.com>
2022-05-25 21:28:10 +03:00
dependabot[bot] 22ef456164 chore: bump github.com/gohugoio/hugo from 0.98.0 to 0.99.1 (#1699)
* chore: bump github.com/gohugoio/hugo from 0.98.0 to 0.99.1

Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.98.0 to 0.99.1.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/goreleaser.yml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.98.0...v0.99.1)

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

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

* fixup! chore: bump github.com/gohugoio/hugo from 0.98.0 to 0.99.1

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-05-25 12:44:23 -05:00
dependabot[bot] 088f842e17 chore: bump github.com/hashicorp/terraform-json from 0.13.0 to 0.14.0 (#1736)
Bumps [github.com/hashicorp/terraform-json](https://github.com/hashicorp/terraform-json) from 0.13.0 to 0.14.0.
- [Release notes](https://github.com/hashicorp/terraform-json/releases)
- [Commits](https://github.com/hashicorp/terraform-json/compare/v0.13.0...v0.14.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-json
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-25 12:20:28 -05:00
dependabot[bot] 29175d3158 chore: bump github.com/ory/dockertest/v3 from 3.8.1 to 3.9.0 (#1738)
Bumps [github.com/ory/dockertest/v3](https://github.com/ory/dockertest) from 3.8.1 to 3.9.0.
- [Release notes](https://github.com/ory/dockertest/releases)
- [Commits](https://github.com/ory/dockertest/compare/v3.8.1...v3.9.0)

---
updated-dependencies:
- dependency-name: github.com/ory/dockertest/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-25 12:20:11 -05:00
dependabot[bot] cd6fdc7832 chore: bump google.golang.org/api from 0.79.0 to 0.81.0 (#1737)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.79.0 to 0.81.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.79.0...v0.81.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-25 11:51:21 -05:00
dependabot[bot] 3c21b070d7 chore: bump github.com/pion/webrtc/v3 from 3.1.39 to 3.1.41 (#1697)
Bumps [github.com/pion/webrtc/v3](https://github.com/pion/webrtc) from 3.1.39 to 3.1.41.
- [Release notes](https://github.com/pion/webrtc/releases)
- [Commits](https://github.com/pion/webrtc/compare/v3.1.39...v3.1.41)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-25 16:35:02 +00:00
Steven Masley eea8dc6c16 feat: Add rbac to templateversion+orgmember endpoints (#1713) 2022-05-25 11:00:59 -05:00
David Wahler f8410dee3a fix: include subdirectories in example templates (#1715) 2022-05-25 10:34:28 -05:00
Bruno Quaresma 5492ab75c2 feat: Add resource type and restyle terminal link (#1722) 2022-05-25 13:32:01 +00:00
Ammar Bandukwala c5f4d80eda Shorten README before Install docs 2022-05-24 20:20:08 -05:00
Kyle Carberry 74329f479f fix: Use Terraform address to index resource + agent association (#1727)
Closes #1705.

There was an issue in the implementation brought by #1577 by not trimming
the array value when resources use counts. This should fix it, and adds
a test to be sure!
2022-05-24 20:00:34 -05:00
Ammar Bandukwala 95d7e39c80 Rewrite README for launch (#1731) 2022-05-25 00:40:57 +00:00
Kyle Carberry 4d9168c076 fix: Increase release timeout (#1729)
This is unfortunate, but with the containers it can take a while.
We should spend some time making these parallel in the future,
but for now this is fine!
2022-05-24 16:54:27 -05:00
Colin Adler 4543a3b277 fix: log after test exit in TestAgent/StartupScript (#1726)
```
$ go test ./agent/ -v -run TestAgent/StartupScript -count 1
=== RUN   TestAgent
=== PAUSE TestAgent
=== CONT  TestAgent
=== RUN   TestAgent/StartupScript
=== PAUSE TestAgent/StartupScript
=== CONT  TestAgent/StartupScript
    t.go:56: 2022-05-24 20:22:39.648 [INFO]	<agent.go:112>	connected
--- PASS: TestAgent (0.00s)
    --- PASS: TestAgent/StartupScript (0.17s)
PASS
panic: Log in goroutine after TestAgent/StartupScript has completed: 2022-05-24 20:22:39.651 [WARN]	<agent.go:130>	agent script failed ...
"error": run:
             github.com/coder/coder/agent.(*agent).runStartupScript
                 /home/colin/Projects/coder/coder/agent/agent.go:183
           - signal: killed
```
2022-05-24 16:03:42 -05:00
Oxylibrium 99c79c79db docs(README): fix links to subpages (#1724) 2022-05-24 19:26:25 +00:00
G r e y 104c76b8bc ci: limit chromatic to site (#1700) 2022-05-24 14:30:15 -04:00
Joe Previte 0ade49b758 docs: rephrase value statement in README (#1711) 2022-05-24 10:59:20 -07:00
Abhineet Jain 7ba6449054 Improve CLI logout flow (#1692)
* Improve CLI logout flow

* Fix lint error

* Make notLoggedInMessage a const

* successful logout with a msg when cfg files are absent

* use require, os.remove, show only one message, add prompt
2022-05-24 13:11:01 -04:00
Ammar Bandukwala 33e2e40942 Expand stalebot to issues (#1672)
Removing old, stale issues is essential to keeping a workable tracker.
2022-05-24 10:03:43 -07:00
Steven Masley d3a0578fe1 feat: Allow regen-ssh and fetching a single user from the cli (#1619)
* feat: Allow regen-ssh and fetching a single user from the cli
2022-05-24 16:53:04 +00:00
Steven Masley 363b16af38 fix: Add template read permission node to members (#1712) 2022-05-24 16:35:34 +00:00
Joe Previte 61ffd03aaf docs: update contribution guidelines (#1691)
* docs(contributing): add subheading backend under styling

* docs: add styling for frontend
2022-05-24 15:30:15 +00:00
G r e y b0d52039f9 refactor: resource strings in WorkspaceSchedule (#1702) 2022-05-24 09:55:30 -04:00
Steven Masley c7ca86d374 feat: Implement RBAC checks on /templates endpoints (#1678)
* feat: Generic Filter method for rbac objects
2022-05-24 08:43:34 -05:00
Bruno Quaresma fcd610ee7b refactor: Update create workspace flow to allow creation from the workspaces page (#1684) 2022-05-24 08:37:44 -05:00
Steven Masley 5f8d0e5dad feat: Add RBAC to /files endpoints (#1664)
* feat: Add RBAC to /files endpoints
2022-05-24 08:25:02 -05:00
Bruno Quaresma f763472609 fix: Fix template label (#1685) 2022-05-24 12:38:31 +00:00
Mathias Fredriksson 34b1e19338 fix: Try to fix cli portforward test flakes (#1650)
* fix: Try to fix cli portforward test flakes

* fix: Guard against agent exit outside test func

* fix: Improve test teardown in setupTestListener, cleanup
2022-05-24 11:15:06 +03:00
Cian Johnston c2f74f3cc2 chore: avoid concurrent usage of t.FailNow (#1683)
* chore: golangci: add linter rule to report usage of t.FailNow inside goroutines
* chore: avoid t.FailNow in goroutines to appease the race detector
2022-05-24 08:58:39 +01:00
Presley Pizzo 9b70a9b2eb Fix: fix Workspace storybook and remove unnecessary fetching from xService (#1682)
* Make workspace machine ephemeral to limit polling

* Fix Workspace storybook

* Lint

* Remove breadcrumb from workspaceXService
2022-05-23 20:04:38 -04:00
dependabot[bot] 4ba3eedb70 chore: bump github.com/lib/pq from 1.10.5 to 1.10.6 (#1653)
Bumps [github.com/lib/pq](https://github.com/lib/pq) from 1.10.5 to 1.10.6.
- [Release notes](https://github.com/lib/pq/releases)
- [Commits](https://github.com/lib/pq/compare/v1.10.5...v1.10.6)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-23 18:02:12 -05:00
dependabot[bot] 62acfc9a07 chore: bump goreleaser/goreleaser-action from 2 to 3 (#1652)
Bumps [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) from 2 to 3.
- [Release notes](https://github.com/goreleaser/goreleaser-action/releases)
- [Commits](https://github.com/goreleaser/goreleaser-action/compare/v2...v3)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-23 22:55:40 +00:00
dependabot[bot] 98345e3d24 chore: bump github.com/hashicorp/go-version from 1.4.0 to 1.5.0 (#1654)
Bumps [github.com/hashicorp/go-version](https://github.com/hashicorp/go-version) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/hashicorp/go-version/releases)
- [Changelog](https://github.com/hashicorp/go-version/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/go-version/compare/v1.4.0...v1.5.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-23 17:49:21 -05:00
dependabot[bot] e9818d79da chore: bump jaxxstorm/action-install-gh-release from 1.6.0 to 1.7.1 (#1651)
Bumps [jaxxstorm/action-install-gh-release](https://github.com/jaxxstorm/action-install-gh-release) from 1.6.0 to 1.7.1.
- [Release notes](https://github.com/jaxxstorm/action-install-gh-release/releases)
- [Commits](https://github.com/jaxxstorm/action-install-gh-release/compare/v1.6.0...v1.7.1)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-23 17:47:38 -05:00
dependabot[bot] 2de47ef9f0 chore: bump github.com/quasilyte/go-ruleguard/dsl from 0.3.19 to 0.3.21 (#1655)
Bumps [github.com/quasilyte/go-ruleguard/dsl](https://github.com/quasilyte/go-ruleguard) from 0.3.19 to 0.3.21.
- [Release notes](https://github.com/quasilyte/go-ruleguard/releases)
- [Commits](https://github.com/quasilyte/go-ruleguard/compare/dsl/v0.3.19...dsl/v0.3.21)

---
updated-dependencies:
- dependency-name: github.com/quasilyte/go-ruleguard/dsl
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-23 22:45:40 +00:00
Cian Johnston b2020761d9 feat: add default autostart and ttl for new workspaces (#1632)
* database: add autostart_schedule and ttl to InsertWorkspace; make gen
* coderd: workspaces: consume additional fields of CreateWorkspaceRequest
* cli: update: add support for TTL and autostart_schedule
* cli: create: add unit tests
* coder: import  `time/tzdata` for embedded timezone database
* autobuild: fix unit test that only runs with a real db
2022-05-23 23:31:41 +01:00
G r e y c465f8a8a3 feat: add retry to ErrorSummary (#1690)
Summary:

The ErrorSummary accepts a retry callback and received improvements to
style and product copy

Impact:

This allows xstate-controlled pages to send re-fetch events
2022-05-23 21:07:52 +00:00
Asher dd4bb07193 feat: add terminal links (#1636) 2022-05-23 15:49:02 -05:00
Oxylibrium 80f8f605fd chore: Add self to CONTRIBUTORS.md (#1680) 2022-05-23 16:46:03 -04:00
Bruno Quaresma 57c6d887a1 chore: Ignore last built value on Chromatic (#1687) 2022-05-23 20:42:05 +00:00
Katie Horne 98c89f80b0 chore: add instructions for installation w/ Docker Compose (#1599)
Co-authored-by: Ben Potter <ben@coder.com>
2022-05-23 19:42:45 +00:00
ketang ba66052181 fix incorrect retention field on artifacts in coder.yaml 2022-05-23 14:13:05 -05:00
Abhineet Jain fc46818e31 chore: move contributor list to contributors.md (#1496) 2022-05-23 19:09:45 +00:00
ketang 7de4cd6231 replace .deb artifact with Windows .zip 2022-05-23 13:54:13 -05:00
Abhineet Jain 4a78bade6d bug: Cleaner error message for non logged-in users (#1670)
* add helper text to unauthorized error messages

* fix lint error, add unit tests

* fix test name

* fix test name

* fix lint errors in test

* add unauthorized test for templates create

* remove unnecessary variable

* remove Error struct, change error message

* change [url] to <url>
2022-05-23 14:51:49 -04:00
ketang c543fca92f add tar.gz to artifacts and a 7 day retention period to .deb 2022-05-23 13:35:25 -05:00
Katie Horne b0298a3157 chore: fix in-product copy casing (#1671) 2022-05-23 13:30:38 -05:00
Presley Pizzo 7ac3cbe772 Make workspace machine ephemeral to limit polling (#1674) 2022-05-23 13:25:46 -04:00
Steven Masley 873ae90f39 feat: cli configs should not be space sensitive (#1668) 2022-05-23 12:19:33 -05:00
Mathias Fredriksson c8ed213347 fix: Guard against CLI cmd running after test exit (#1658)
* fix: Guard against CLI cmd running after test exit

* fix: cli: avoid calling t.FailNow in non-test-main goroutine

* fix: cli: server_test: avoid calling t.FailNow outside main goroutine

* fix: cli: clitest_test: avoid calling t.FailNow outside main goroutine

* fix: cli: list_test: avoid calling t.FailNow outside main goroutine

* fix: TestGitSSH use-of-t-after-exit

* fix: TestGitSSH "too many authentication failures"

Due to local SSH keys being given

* chore: clitest: fix TestCli

* chore: Simplify TestTemplateInit

Co-authored-by: Cian Johnston <cian@coder.com>
2022-05-23 20:09:58 +03:00
Kira Pilot fa957d6d65 fix: omit url params on login (#1666)
resolves #1282
2022-05-23 11:01:32 -04:00
Bruno Quaresma 9f3a6d631c refactor: Move schedule info to the sidebar (#1665) 2022-05-23 09:41:04 -05:00
Bruno Quaresma 1f03277f1c refactor: Increase navbar height (#1662) 2022-05-23 10:22:48 -04:00
Cian Johnston a8a8f9dbf3 chore: skip some flaky tests (#1643)
* chore: skip some flaky tests

* Update peer/conn_test.go

* add makefile targets, reduce parallelism in go test
2022-05-21 00:39:51 +01:00
G r e y 4f75291446 feat: form for editing ws schedule (#1634)
* feat: ui for editing ws schedule

Summary:

This presents a form component and storybook. The UI will be a routed
page and added into the dashboard in a separate PR. It is likely a
XService will be used at the page level to supply errors and actions to
this form.

Impact of Change:

Further progress on #1455

Squashed Commits:

* refactor: add className prop to Stack

combine classes with internal classes and an optional external className
to better control the Stack.

* fix: getFormHelpers helperText

the helperText logic was incorrect, the helperText would only show if not touched.
2022-05-20 20:26:43 +00:00
Bruno Quaresma b29a2dfdde refactor: Minor design adjustments (#1637) 2022-05-20 19:37:03 +00:00
Joe Previte 3653fcf256 fix: remove outdated doc paths in goreleaser (#1633)
It appears we were manually moving the `README.md`. This should have been updated in https://github.com/coder/coder/pull/1630 but slipped through CI
2022-05-20 19:02:38 +00:00
Presley Pizzo e40c68399d feat: resources card (#1627)
* Set up table

* Format

* Hook up api and test - bug assigning resources

* Remove debugging code

* Format

* Remove unnecessary cards

* Fix test

* Fix assignment

* Fix tests

* Lint
2022-05-20 18:29:42 +00:00
Steven Masley c189fc52c1 fix: using a trailing slash on login url (#1622) 2022-05-20 12:42:01 -05:00
Bruno Quaresma ce7bf0b847 feat: Redesign the workspace page (#1620) 2022-05-20 17:05:00 +00:00
Joe Previte 0622603220 docs: move README to root (#1630)
We noticed that when you download the repo as a ZIP from GitHub, it
places the `README.md` in the root, which causes the relative links to
break.

By moving it to the root, this will fix that issue.
2022-05-20 09:56:50 -07:00
Steven Masley ad946c3902 feat: Add confirm prompts to some cli actions (#1591)
* feat: Add confirm prompts to some cli actions
- Add optional -y skip. Standardize -y flag across commands
2022-05-20 15:59:04 +00:00
G r e y 4f70f84635 feat: WorkspaceSection action, styles (#1623)
This PR is a squash of refactors and improvements in our Workspace and
WorkspaceSection components. An action prop is added to WorkspaceSection
and along the way, I refactored things that were not meeting conventions
or were hard to read. With this addition, I am further unblocked in
making auto-start/off editable in the UI, as I intend to use the Action
prop to trigger a modal (or routed page view) with the form.

Squashed commits:

* refactor: spaces for readability
It's hard to read HTMl markup without spaces on adjacent nodes

* refactor: props
Our components had unused props and arbitrary ordering.
2022-05-20 11:55:39 -04:00
Garrett Delfosse 0effb71f43 feat: add tracing for sql (#1610) 2022-05-20 10:51:06 -05:00
Abhineet Jain 7c3e1a5d97 feat: Read params from file for template/workspace creation (#1541)
* Read params from file for template/workspace creation

* Use os.ReadFile

* Refactor reading params into a separate module

* Add comments and unit tests

* Rename variable

* Uncomment and fix unit test

* Fix comment

* Refactor tests

* Fix unit tests for windows

* Fix unit tests for Windows

* Add comments for the hotfix
2022-05-20 11:29:10 -04:00
Kira Pilot d0fd0d7040 feat: added error boundary (#1602)
* added error boundary and error ui components

* add body txt and standardize btn size

* added story

* feat: added error boundary

closes #1013

* committing lockfile

* added email body to help link
2022-05-20 10:48:39 -04:00
Cian Johnston 52230fab56 feat: make default autobuild poll intervals configurable (#1618)
* feat: make default poll intervals for autobuild and ssh ttl polling configurable
2022-05-20 10:57:02 +00:00
Mathias Fredriksson 992b58389b fix: Use the cobra CommandPath for usage to avoid duplication (#1617) 2022-05-20 12:42:56 +03:00
Dean Sheather adb7d20c16 feat: skip terraform destroy if there is no state when deleting (#1594) 2022-05-20 14:07:23 +10:00
Spike Curtis a03615a01f feature: disable provisionerd listen endpoint (#1614)
* feature: disable provisionerd listen endpoint

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

* Regenerate ts types

Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-19 23:52:17 +00:00
Spike Curtis d1817310a1 fix build and lint (#1613)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-19 23:28:29 +00:00
Spike Curtis 1871b09697 feat: in-process provisionerd connection (#1568)
* in-process provisionerd connection

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

* disable lint for server.go/newProvisionerDaemon

Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-19 17:47:45 -05:00
Garrett Delfosse 376c6819e0 feat: Move from datadog to generic otel (#1567) 2022-05-19 17:43:07 -05:00
Colin Adler 2a85d3d083 chore: unconditionally run all make cmds in CI (#1608) 2022-05-19 17:42:49 -05:00
Garrett Delfosse 077f16ce2c feat: add coder logout command (#1609) 2022-05-19 22:42:32 +00:00
David Wahler 0c4a65b113 fix: manually fix coderd/database/dump.sql and make style/gen check run more reliably (#1607) 2022-05-19 22:37:22 +00:00
Joe Previte 6dae48a1a8 fix: show --help message for CLI errors, add tests for delete (#1403)
* feat(cli): add test for delete

This adds a new test for the `delete` command to ensure it works as
expected when provided the correct args.

* fix(cli): use ExecuteC() to match Cobra

This modifies the `cli.Root().Execute()` to `cli.Root).ExecuteC()` to
match the default behavior of Cobra. We do this so errors will always
print the "run --help" line.

* feat(cli): add WithoutParameters test for delete

This adds a new test to the `delete_test.go` suite to ensure the correct
behavior occurs when `delete` is called without an argument.

* fixup! feat(cli): add WithoutParameters test for delete

* refactor(cli): show --help error message on main

This adds an error message which shows when there is an error with any
commands called to improve the UX.

* fixup! refactor(cli): show --help error message on main

* refactor(cli): handle err with FormatCobraError

This adds a new helper function called `FormatCobraError` to `root.go`
so that we can colorize and add "--help" message to cobra command errors
like calling `delete`.

* refactor(cli): add root_test.go, move delete test
2022-05-19 22:35:59 +00:00
G r e y a64ab6538e chore: update CODEOWNERS (#1600)
Resolves: #1559
2022-05-19 16:26:39 -05:00
Bruno Quaresma 0ffcc47f32 fix: Fix log order in the workspace build page (#1604) 2022-05-19 21:19:28 +00:00
Kyle Carberry 3be356095f feat: Add create workspace page (#1589) 2022-05-19 20:51:10 +00:00
Ben Potter 4afc66faf5 chore: remove docker host from docker-compose (#1596) 2022-05-19 20:38:07 +00:00
Bruno Quaresma 0b1a35f7b8 feat: Add workspace build logs page (#1598) 2022-05-19 15:34:42 -05:00
Cian Johnston d72c45e483 refactor: workspace autostop_schedule -> ttl (#1578)
Co-authored-by: G r e y <grey@coder.com>
2022-05-19 15:09:27 -04:00
Steven Masley 6c1117094d chore: Force codersdk to not import anything from database (#1576)
* chore: Force codersdk to not import anything from database (linter rule)
* chore: Move all database types in codersdk out
2022-05-19 13:04:44 -05:00
G r e y a0834404f7 chore: rm dead code; add check:all (#1595) 2022-05-19 12:40:40 -05:00
Ben Potter c47b6f0381 chore: use docker host in docker-compose (#1592) 2022-05-19 11:49:22 -05:00
G r e y 67333b6186 feat: getWorkspaces filter site api (#1564) 2022-05-19 12:08:55 -04:00
LG 0438430c7c fix: missing spacing added; typo fix (#1586)
Co-authored-by: Ben <ben@coder.com>
2022-05-19 15:51:49 +00:00
G r e y e0165c5d89 fix: static data in mocks (#1574) 2022-05-19 11:36:14 -04:00
Bruno Quaresma 3f770e1111 fix: User permissions on UI (#1570) 2022-05-19 15:10:18 +00:00
Dean Sheather 4eb0bb6afd feat: don't return 200 for deleted workspaces (#1556) 2022-05-20 00:29:10 +10:00
Ben Potter eb8f371f34 chore: add container image to footer of releases (#1579)
* chore: add docker pull to footer
2022-05-19 13:38:05 +00:00
Kyle Carberry 38ee519f42 feat: Expose the values contained in an HCL validation string to the API (#1587)
* feat: Expose the values contained in an HCL validation string to the API

This allows the frontend to render inputs displaying these values!

* Update codersdk/parameters.go

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

* Call a spade a space

* Fix linting errors with type conversion

Co-authored-by: Cian Johnston <cian@coder.com>
2022-05-19 13:29:36 +00:00
Mathias Fredriksson ad9bdb7bd1 fix: More robust provisionersdk agent init scripts (#1551)
Related #1544

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-05-19 13:02:42 +00:00
Katie Horne 6f969214d3 chore: validate docs (#1485) 2022-05-19 08:01:19 -05:00
Dean Sheather cabc164f74 feat: use and display default template values when creating wkspc. (#1584) 2022-05-19 22:49:40 +10:00
Cian Johnston 8814cb0722 Revert "fix: Use Terraform address to index resource + agent association (#1577)" (#1585)
This reverts commit f3fe2a08ce.
2022-05-19 12:18:40 +01:00
Steven Masley c034e8389e feat: Add RBAC to /workspace endpoints (#1566)
* feat: Add RBAC to /workspace endpoints
2022-05-18 18:15:19 -05:00
Kyle Carberry f3fe2a08ce fix: Use Terraform address to index resource + agent association (#1577)
This fixes resources created from Terraform modules not
properly being associated with an agent.

By not using the address, and resource identifiers prefixed
with `module.<name>` would be missed!
2022-05-18 16:26:08 -05:00
Garrett Delfosse 0706c60445 chore: Add watch workspace endpoint (#1493) 2022-05-18 16:16:26 -05:00
Ben Potter b8ee939e52 chore: change Slack to Discord link (#1573) 2022-05-18 21:14:31 +00:00
Ben Potter 37cf3bb491 example: add docker-image-builds + docker docs (#1526)
Co-authored-by: Katie Horne <katie@23spoons.com>
2022-05-18 16:03:20 -05:00
Kyle Carberry 97699e9704 fix: Rename NewMemoryCoderd to NewWithServer (#1571)
This name felt invalid, because `New` was also in memory.
2022-05-18 15:49:46 -05:00
Steven Masley 2638c274cb fix: User's should be able to read what roles available (#1575) 2022-05-18 20:47:43 +00:00
Steven Masley 8bd1abee33 fix: Use sdk type in coderd api response (#1569)
Was using the database type
2022-05-18 15:34:00 -05:00
Garrett Delfosse e2ed581708 Add stages to all proto.Logs (#1563) 2022-05-18 17:33:29 +00:00
David Wahler a50a6e8638 fix: Make TestAgent and TestWorkspaceAgentPTY less flaky (#1562) 2022-05-18 17:06:17 +00:00
Spike Curtis 9f402fa27f Spike/222 workspace build order (#1534)
* chore: refactor before_id/after_id to build_number

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

* pagination of workspace_builds

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

* Disable parallel on postgres tests

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

* Fix lint

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

* Fix workspace build postgres query

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

* Fix JS tests

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

* Fix workspace builds postgres query

Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-18 16:33:33 +00:00
Cian Johnston 13571b0393 examples/docker-local: add explanatory comment (#1545) 2022-05-18 17:10:23 +01:00
Garrett Delfosse 89fb59aa9a chore: remove make build dep from make dev (#1557) 2022-05-18 16:00:20 +00:00
Asher e4e7e10690 feat: add terminal link component (#1538)
* Fix not being able to specify agent when connecting to terminal

The `workspace.agent` syntax was only used when fetching the agent and
not the workspace so it would try to fetch a workspace called
`workspace.agent` instead of just `workspace`.

* Add terminal link component

Currently it does not show anywhere but we can drop it into the
resources card later.
2022-05-18 10:53:59 -05:00
David Wahler 5f21a145d1 bug: Don't try to handle SIGINT when prompting for passwords (#1498) 2022-05-18 15:26:38 +00:00
Steven Masley a3556b12da feat: Single query for all workspaces with optional filter (#1537)
* feat: Add single query for all workspaces using a filter
2022-05-18 10:09:07 -05:00
dependabot[bot] 894646cb7c chore: bump @testing-library/user-event from 14.1.1 to 14.2.0 in /site (#1521)
Bumps [@testing-library/user-event](https://github.com/testing-library/user-event) from 14.1.1 to 14.2.0.
- [Release notes](https://github.com/testing-library/user-event/releases)
- [Changelog](https://github.com/testing-library/user-event/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/user-event/compare/v14.1.1...v14.2)

---
updated-dependencies:
- dependency-name: "@testing-library/user-event"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-18 11:01:28 -04:00
Kira Pilot 85a932bfaf bug: fixed menu height diff (#1546)
resolves #1229
2022-05-18 10:34:56 -04:00
Dean Sheather 9141be3656 feat: add port-forward subcommand (#1350) 2022-05-19 00:10:40 +10:00
Kyle Carberry 76fc59aa79 feat: Add templates page (#1510)
* feat: Add template page

* Create xService

* Update column names

* Show create template conditionally

* Add template description

* Route to templates

* Add empty states

* Add tests

* Add loading indicator

* Requested changes
2022-05-18 09:05:18 -05:00
Bruno Quaresma b7481489b1 feat: Add timeline in the workspace page (#1533) 2022-05-18 13:54:06 +00:00
Ben Potter 6bed620d6c example: ec2: document "minimal" policy (#1536)
* example: ec2: document "minimal" policy

* move DescribeInstances

* move ModifyInstanceCreditSpecification
2022-05-18 08:17:05 -05:00
Steven Masley 4e28b2d9c5 test: Using local time in unit test fails in certain time zones (#1540)
* test: Using local time in unit test fails in certain time zones

This test was failing when running in CST (GMT-5) timezone.
My local timezone pushed the next to the upcoming monday

* fix: schedule: assert expected result of String() separately from input spec

Co-authored-by: Cian Johnston <cian@coder.com>
2022-05-18 13:09:36 +00:00
Kyle Carberry ba818b3a10 fix: Append Terraform module resources to list (#1539)
This was causing module resources to be skipped!
2022-05-17 19:07:20 -05:00
David Wahler 72c2bf80aa feat: "coder ssh --shuffle" easter egg (#1084) 2022-05-17 17:55:58 -05:00
Kyle Carberry 33701862de fix: Publish Linux releases in tar.gz archives (#1535)
This reduces download size by ~70%.
2022-05-17 21:11:13 +00:00
Colin Adler 98ccd0eb89 feat: add README parsing to template versions (#1500) 2022-05-17 15:00:48 -05:00
dependabot[bot] 0f9559a784 chore: bump cronstrue from 2.4.0 to 2.5.0 in /site (#1518)
Bumps [cronstrue](https://github.com/bradymholt/cronstrue) from 2.4.0 to 2.5.0.
- [Release notes](https://github.com/bradymholt/cronstrue/releases)
- [Commits](https://github.com/bradymholt/cronstrue/compare/v2.4.0...v2.5.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 15:03:45 -04:00
Kira Pilot 65acfc9bef bug: using NavLink for menus (#1530)
* bug: using NavLink for menus

resolves #955

* lets fix our story
2022-05-17 15:01:53 -04:00
Steven Masley 4ad5ac2d4a feat: Rbac more coderd endpoints, unit test to confirm (#1437)
* feat: Enforce authorize call on all endpoints
- Make 'request()' exported for running custom requests
* Rbac users endpoints
* 401 -> 403
2022-05-17 13:43:19 -05:00
Garrett Delfosse 495c87b6c3 chore: add make dev (#1527) 2022-05-17 13:12:14 -05:00
dependabot[bot] 841b792e8e chore: bump @typescript-eslint/parser from 5.23.0 to 5.25.0 in /site (#1517)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.23.0 to 5.25.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.25.0/packages/parser)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:36:03 -04:00
dependabot[bot] c0b80ef899 chore: bump sql-formatter from 4.0.2 to 6.1.1 in /site (#1514)
Bumps [sql-formatter](https://github.com/zeroturnaround/sql-formatter) from 4.0.2 to 6.1.1.
- [Release notes](https://github.com/zeroturnaround/sql-formatter/releases)
- [Changelog](https://github.com/zeroturnaround/sql-formatter/blob/master/.release-it.json)
- [Commits](https://github.com/zeroturnaround/sql-formatter/compare/v4.0.2...v6.1.1)

---
updated-dependencies:
- dependency-name: sql-formatter
  dependency-type: direct:development
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:35:29 -04:00
dependabot[bot] 5227a74ae3 chore: bump webpack-dev-server from 4.8.1 to 4.9.0 in /site (#1511)
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.8.1 to 4.9.0.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.8.1...v4.9.0)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:35:04 -04:00
dependabot[bot] 3eaca0d436 chore: bump @pmmmwh/react-refresh-webpack-plugin in /site (#1484)
Bumps [@pmmmwh/react-refresh-webpack-plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) from 0.5.5 to 0.5.6.
- [Release notes](https://github.com/pmmmwh/react-refresh-webpack-plugin/releases)
- [Changelog](https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pmmmwh/react-refresh-webpack-plugin/compare/v0.5.5...v0.5.6)

---
updated-dependencies:
- dependency-name: "@pmmmwh/react-refresh-webpack-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:33:52 -04:00
Cian Johnston 190210b18d fix: set autostop notify to t minus 30 minutes (#1513) 2022-05-17 16:14:10 +01:00
dependabot[bot] bb2740e7c3 chore: bump @playwright/test from 1.21.1 to 1.22.1 in /site (#1512)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.21.1 to 1.22.1.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.21.1...v1.22.1)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:12:50 -04:00
dependabot[bot] 8dd32e2a0a chore: bump eslint from 8.14.0 to 8.15.0 in /site (#1344)
Bumps [eslint](https://github.com/eslint/eslint) from 8.14.0 to 8.15.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.14.0...v8.15.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:08:26 -04:00
dependabot[bot] d5a500a73f chore: bump @fontsource/inter from 4.5.7 to 4.5.10 in /site (#1251)
Bumps [@fontsource/inter](https://github.com/fontsource/fontsource/tree/HEAD/fonts/google/inter) from 4.5.7 to 4.5.10.
- [Release notes](https://github.com/fontsource/fontsource/releases)
- [Changelog](https://github.com/fontsource/fontsource/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fontsource/fontsource/commits/HEAD/fonts/google/inter)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-17 11:05:28 -04:00
G r e y d177937e1c chore: clean site dependencies (#1509)
* delete package-lock.json
* pin dayjs
* pin uuid, @types/uuid
* pin xterm dependencies
* pin jest deps
2022-05-17 10:45:51 -04:00
Cian Johnston 75dc8f59f6 fix: example: update docker-local to use host-gateway (#1507)
* fix: example: update docker-local to use host-gateway
* docker-compose.yaml: Add POSTGRES_ environment variables to CODER_PG_CONNECTION_URL

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-05-17 14:40:13 +00:00
Kyle Carberry fc9efc2b79 fix: Allow setting STUN to an empty string (#1502)
This allows users to entirely disable STUN.
2022-05-18 00:12:48 +10:00
Kyle Carberry 668a6712e6 fix: Use relative timestamp for workspaces page Storybook (#1505) 2022-05-17 07:58:18 -05:00
Kyle Carberry 55bd7aa747 fix: Run "make gen" to regenerate queries (#1504)
This is broken in our CI, and should be fixed!
I'll likely tackle in a future PR.
2022-05-16 23:47:31 -05:00
Kyle Carberry f75d29e38e fix: Remove grouping for workspace owner counts (#1503)
This caused templates to show max ownership of one developer!
2022-05-17 04:10:52 +00:00
Kyle Carberry a2ba69dd28 fix: Parse resources from Terraform Modules (#1501)
Fixes when Terraform modules are used to primariy provision
infrastructure!
2022-05-16 20:56:50 -05:00
Kyle Carberry 9b1ef29694 fix: Allow fetching of non-personal workspaces (#1495)
RBAC should cover this anyways!
2022-05-16 22:47:31 +00:00
Ben Potter 1ed69b95fc example(k8s): clarify kubeconfig location (#1494) 2022-05-16 22:29:15 +00:00
Kyle Carberry 22ec366535 feat: Redesign workspaces page (#1450)
* feat: Improve navbar to be more compact

The navbar was unnecessarily large before, which made
the UI feel a bit bloaty from my perspective.

* Attempt to remove overrides

* Update theme

* Add text field

* Update theme to dark!

* Fix import ordering

* Fix page location

* Fix requested changes

* Add storybook for workspaces page view

* Add empty view

* Add tests for empty view

* Remove templates page

* Fix local port

* Remove templates from nav

* Fix e2e test

* Remove time.ts

* Remove dep

* Add background color to margins

* Merge status checking from workspace page

* Fix requested changes

* Fix workspace status tests
2022-05-16 16:52:54 -05:00
Colin Adler e925818526 feat: add template description (#1489) 2022-05-16 20:56:11 +00:00
Steven Masley b55d83ca82 feat: Add suspend/active user to cli (#1422)
* feat: Add suspend/active user to cli
* UserID is now a string and allows for username too
2022-05-16 15:29:27 -05:00
Kyle Carberry a77da8445e fix: Resolve symlinks being written with size 0 in tar (#1488)
Solution found here:
https://stackoverflow.com/questions/38454850/getting-write-too-long-error-when-trying-to-create-tar-gz-file-from-file-and-d

Symlink's were being written with a size of 0, which surfaced an error
for write too long.
2022-05-16 20:26:23 +00:00
Colin Adler 680de709a5 chore: organize http handlers (#1486)
They're currently randomly in a bunch of different files. This cleans up
the handler functions to be in the file of the type they return.
2022-05-16 14:36:27 -05:00
G r e y 9d4182b189 fix: CreateWorkspaceForm name validation (#1453)
* refactor: allow helperText in getFormHelpers

By passing in helperText, we will not accidentally overwrite it.

* fix: CreateWorkspaceForm name validation

Resolves: #1421
2022-05-16 15:29:59 -04:00
Bruno Quaresma 4103ba0b71 chore: Rename Preferences to Settings (#1487) 2022-05-16 18:53:07 +00:00
Garrett Delfosse eeaa5c3b7b feat: Support reading from token flag on coder login (#1483) 2022-05-16 18:07:35 +00:00
dependabot[bot] abc2257624 chore: bump xstate from 4.31.0 to 4.32.1 in /site (#1481)
Bumps [xstate](https://github.com/statelyai/xstate) from 4.31.0 to 4.32.1.
- [Release notes](https://github.com/statelyai/xstate/releases)
- [Commits](https://github.com/statelyai/xstate/compare/xstate@4.31.0...xstate@4.32.1)

---
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>
2022-05-16 13:03:50 -05:00
Colin Adler f007aeee1f chore: standardize migration names in create_migration.sh (#1480) 2022-05-16 17:35:00 +00:00
dependabot[bot] b73be75aeb chore: bump @typescript-eslint/eslint-plugin in /site (#1475)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.21.0 to 5.23.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.23.0/packages/eslint-plugin)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-16 12:19:08 -05:00
dependabot[bot] 0655742147 chore: bump eslint-plugin-jest from 26.1.5 to 26.2.2 in /site (#1474)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 26.1.5 to 26.2.2.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v26.1.5...v26.2.2)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-16 12:18:48 -05:00
Bruno Quaresma abbe548d5c feat: Add SSH Keys page on /preferences/ssh-keys (#1478) 2022-05-16 12:15:45 -05:00
dependabot[bot] 5447c4a3cf chore: bump docker-practice/actions-setup-docker from 1.0.8 to 1.0.10 (#1469)
Bumps [docker-practice/actions-setup-docker](https://github.com/docker-practice/actions-setup-docker) from 1.0.8 to 1.0.10.
- [Release notes](https://github.com/docker-practice/actions-setup-docker/releases)
- [Changelog](https://github.com/docker-practice/actions-setup-docker/blob/master/CHANGELOG.md)
- [Commits](https://github.com/docker-practice/actions-setup-docker/compare/v1.0.8...1.0.10)

---
updated-dependencies:
- dependency-name: docker-practice/actions-setup-docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-16 12:10:28 -05:00
dependabot[bot] 1e25bf2455 chore: bump docker/login-action from 1 to 2 (#1470)
Bumps [docker/login-action](https://github.com/docker/login-action) from 1 to 2.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v1...v2)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-16 12:09:11 -05:00
dependabot[bot] 8ba18dd222 chore: bump jaxxstorm/action-install-gh-release from 1.5.0 to 1.6.0 (#1472)
Bumps [jaxxstorm/action-install-gh-release](https://github.com/jaxxstorm/action-install-gh-release) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/jaxxstorm/action-install-gh-release/releases)
- [Commits](https://github.com/jaxxstorm/action-install-gh-release/compare/v1.5.0...v1.6.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>
2022-05-16 12:08:34 -05:00
Mathias Fredriksson 6c1ef851a2 fix: Update cli usage template for cobra feature parity (#1463)
Fixes #1423

Related #1233, #1403
2022-05-16 20:01:42 +03:00
Presley Pizzo b06ef0ae6e feat: Workspace StatusBar (#1362)
* Move component and prep

* Make WorkspaceSection more reusable

* Lay out elements

* Layout tweaks

* Add outdated to Workspace type

* Fill out status bar component

* Format

* Add transition to types

* Add api handlers for build toggle

* Format

* Parallelize machine

* Lay out basics of build submachine

* Pipe start and stop events through - needs status

* Attempt at a machine

It's so big, but collapsing start and stop made it hard to distinguish retry from toggle

* Update mock

* Render status and buttons

* Fix type error on template page

* Move Settings

* Format

* Keep refreshed workspace

* Make it switch workspaces

* Lint

* Fix relative api path

* Test

* Fix polling

* Add loading workspace state

* Format

* Add stub settings page

* Format

* Lint

* Get rid of let

* Add update

* Make start use version id

Important for update

* Fix imports

* Add polling for outdated

* Rely on context instead of finite state for status

* Handle canceling

* Fix tests

* Format

* Display errors so users know when button presses didn't work

* Fix api typo, remove logging

* Lint

* Simplify type

Co-authored-by: G r e y <grey@coder.com>

* Add type, extract helper

Co-authored-by: G r e y <grey@coder.com>
2022-05-16 16:34:22 +00:00
Colin Adler e990a9ac28 feat: add audit diffing for all user editable types (#1413) 2022-05-16 11:20:11 -05:00
Cian Johnston b7049032a0 fix: cli: prettify schedule when printing output (#1440)
* Adds methods to schedule.Schedule to show the raw cron string and timezone
* Uses these methods to clean up output of auto(start|stop) show or ls
* Defaults CRON_TZ=UTC if not provided
2022-05-16 17:02:44 +01:00
dependabot[bot] 2a278b8698 chore: bump github.com/prometheus/client_golang from 1.12.1 to 1.12.2 (#1467)
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.12.1 to 1.12.2.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/client_golang/compare/v1.12.1...v1.12.2)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-16 09:35:11 -05:00
dependabot[bot] f3b922bbd5 chore: bump github.com/moby/moby (#1464)
Bumps [github.com/moby/moby](https://github.com/moby/moby) from 20.10.15+incompatible to 20.10.16+incompatible.
- [Release notes](https://github.com/moby/moby/releases)
- [Changelog](https://github.com/moby/moby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moby/moby/compare/v20.10.15...v20.10.16)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-16 09:13:20 -05:00
Bruno Quaresma 8857c0d076 refactor: Update start coder command (#1476) 2022-05-16 13:37:42 +00:00
dependabot[bot] 02087db65a chore: bump docker/setup-qemu-action from 1 to 2 (#1471)
Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 1 to 2.
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/v1...v2)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-16 08:36:12 -05:00
dependabot[bot] 6ca7f0b89c chore: bump google.golang.org/api from 0.78.0 to 0.79.0 (#1466)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.78.0 to 0.79.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.78.0...v0.79.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-16 08:32:25 -05:00
dependabot[bot] 19a18164ec chore: bump golangci/golangci-lint-action from 3.1.0 to 3.2.0 (#1473)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.1.0...v3.2.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>
2022-05-16 08:31:54 -05:00
dependabot[bot] d7163b2f9f chore: bump github.com/gliderlabs/ssh from 0.3.3 to 0.3.4 (#1468)
Bumps [github.com/gliderlabs/ssh](https://github.com/gliderlabs/ssh) from 0.3.3 to 0.3.4.
- [Release notes](https://github.com/gliderlabs/ssh/releases)
- [Commits](https://github.com/gliderlabs/ssh/compare/v0.3.3...v0.3.4)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-16 08:31:21 -05:00
dependabot[bot] 889ec88de2 chore: bump github.com/pion/webrtc/v3 from 3.1.34 to 3.1.39 (#1465)
Bumps [github.com/pion/webrtc/v3](https://github.com/pion/webrtc) from 3.1.34 to 3.1.39.
- [Release notes](https://github.com/pion/webrtc/releases)
- [Commits](https://github.com/pion/webrtc/compare/v3.1.34...v3.1.39)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-16 08:30:53 -05:00
G r e y 7bb7c6c295 example: use codercom/enterprise-intellij:ubuntu in docker-local (#1454)
Resolves: #1113
2022-05-14 13:58:12 -04:00
Kyle Carberry dbd5b4a47b feat: Add workspace owner name to response (#1448)
This will be rendered in the workspace page!
2022-05-13 20:41:21 -05:00
Ammar Bandukwala 4cfc9af442 Fix codecov (#1447)
The notify block was syntactically invalid, preventing
any of this file from working.
2022-05-14 00:33:58 +00:00
G r e y e061715315 fix: error when clicking on login screen (#1445)
Resolves: #1435
2022-05-13 20:07:54 -04:00
Colin Adler fe7645b8a9 feat: add templates delete command (#1443) 2022-05-13 22:54:32 +00:00
Ammar Bandukwala 19335df0eb Disable codecov comment (#1442)
You can find the information by clicking on the CI check, and it's only rarely of interest to the reviewer.
2022-05-13 16:48:48 -05:00
Eric Paulsen 695b709173 fix: examples link in README (#1441) 2022-05-13 16:43:10 -05:00
Bruno Quaresma 50ad2f8e31 refactor: Improve the load state for the list pages (#1428) 2022-05-13 14:12:35 -05:00
Cian Johnston f970829b9e feat: add autostart/autostop show, show autostart/autostop schedule in ls output (#1436)
* feat: add autostart/autostop show, show autostart/autostop schedule in ls output
2022-05-13 19:03:27 +00:00
Cian Johnston 9410237ed5 chore: un-hide autostart and autostop commands (#1418) 2022-05-13 18:09:16 +01:00
Cian Johnston b2760b1faf feat: send native system notification on scheduled workspace shutdown (#1414)
* feat: send native system notification on scheduled workspace shutdown

This commit adds a fairly generic notification package and uses it
to notify users connected over SSH of pending workspace shutdowns.
Only one notification will be sent at most 5 minutes prior to the scheduled
shutdown, and only one CLI instance will send notifications if multiple
instances are running.
2022-05-13 18:09:04 +01:00
Cian Johnston 4ab7a41f08 chore: executor: add unit test, rename LifecycleTicker (#1420)
* chore: add a unit test to ensure correct behaviour with multiple coderd replicas
* nit: rename LifecycleTicker to AutobuildTicker
2022-05-13 17:14:24 +01:00
G r e y 89e44da899 fix: remove account description (#1427)
Resolves: #1419
2022-05-13 11:53:14 -04:00
Bruno Quaresma e6168ba238 feat: Add permissions for links (#1407) 2022-05-13 14:25:57 +00:00
Ben Potter 64a8b4ac47 chore: add bpmct to contributors list (#1332) 2022-05-13 02:01:31 +00:00
David Wahler 86cba4d3f8 chore: Deploy internally accessible godoc container (#1415) 2022-05-12 19:39:18 -05:00
Ben Potter 333d6a4374 fix: typo in CODER_VERSION 2022-05-12 16:13:43 -05:00
Steven Masley 64e408c954 feat: Check permissions endpoint (#1389)
* feat: Check permissions endpoint

Allows FE to query backend for permission capabilities.
Batch requests supported
2022-05-12 20:56:23 +00:00
Ben Potter 75a5877c1d fix: remove docker release flake (#1412) 2022-05-12 15:44:46 -05:00
G r e y 9ef64fd192 chore: add myself as a contributor (#1408) 2022-05-12 14:44:54 -04:00
Asher 6f7d9bb1e4 fix: remove unimplemented account pages (#1411)
It appears unclear as of now when/if these will be implemented so I
opted to remove them (as opposed to commenting them out) to avoid having
them rot (they are easily added back anyway).

Closes #1232.
2022-05-12 13:34:49 -05:00
Ben Potter bbb8f836bf feat: build & release cross-platform Docker images (#1178)
* feat: add dockerfile and docker-compose

* build docker images on release

* add Docker dependencies to release.yaml

* remove docker compose for now

* fix license mismatch

* add docker-compose

* rename volume

* add WF dispatch for debugging
2022-05-12 17:59:34 +00:00
Kyle Carberry 7b5300d0cc fix: Improve develop script to start tunnel by default (#1409)
This allows for running the development script to actually
build workspaces!
2022-05-12 12:37:51 -05:00
David Wahler 20916281d8 feat: Add reset-password command (#1380)
* allow non-destructively checking if database needs to be migrated

* feat: Add reset-password command

* fix linter errors

* clean up reset-password usage prompt

* Add confirmation to reset-password command

* Ping database before checking migration, to improve error message
2022-05-12 12:32:56 -05:00
Bruno Quaresma a629a705d0 refactor: Add vertical space to the footer (#1410) 2022-05-12 12:28:20 -05:00
Asher 26b04cc96f chore: switch to generated types (#1394)
* Make column renderer use the same type as its key

That way the renderer only takes `string` for example when rendering the
name field instead of `string | number` when the interface has some
fields that are strings and some fields are numbers.

This will be necessary when switching to generated types since some of
the fields are numbers (like the owner count on a template).

* Switch fully to generated types

In some places the organization ID is part of the URL but not part of
the request so I separated out the ID into a separate argument in the
relevant API functions.

Otherwise this was a straightforward replacement where I mostly only
needed to change some of the interface names (User instead of
UserResponse for example) and add a few missing but required properties.

I kind of winged the template form; I am not sure what the difference
between a template and template version is or why the latter comes
before the former so the form just returns all the data required to
create both.

* Delete handwritten types

Except for UserAgent which seems to be purely frontend and
ReconnectingPTYRequest which is not in codersdk so I am just leaving it
for now.

* Remove implemented omitempty as a future idea

This was implemented in 2d3dc436a8.

* Add missing optionalities to generated request interfaces
2022-05-12 10:01:28 -05:00
Mathias Fredriksson 56076a0aa2 feat: Unify cli behavior for templates create and update (#1385)
Fixes #565
2022-05-12 14:54:58 +03:00
Kira Pilot 2569787324 chore: add eslint extension recommendation (#1400)
resolves #1399
2022-05-11 19:01:21 -04:00
Asher ce660f8bbc fix: add missing return when template version is not found (#1402) 2022-05-11 17:58:22 -05:00
Cian Johnston f4da5d4f3a feat: add lifecycle.Executor to manage autostart and autostop (#1183)
This PR adds a package lifecycle and an Executor implementation that attempts to schedule a build of workspaces with autostart configured.

- lifecycle.Executor takes a chan time.Time in its constructor (e.g. time.Tick(time.Minute))
- Whenever a value is received from this channel, it executes one iteration of looping through the workspaces and triggering lifecycle operations.
- When the context passed to the executor is Done, it exits.
- Only workspaces that meet the following criteria will have a lifecycle operation applied to them:
  - Workspace has a valid and non-empty autostart or autostop schedule (either)
  - Workspace's last build was successful
- The following transitions will be applied depending on the current workspace state:
  - If the workspace is currently running, it will be stopped.
  - If the workspace is currently stopped, it will be started.
  - Otherwise, nothing will be done.
- Workspace builds will be created with the same parameters and template version as the last successful build (for example, template version)
2022-05-11 23:03:02 +01:00
Kira Pilot e8e6d3c2f1 chore: updated documentation link (#1387)
* chore: updated documentation link

* PR feedback
2022-05-11 17:10:03 -04:00
Kira Pilot f93804a2a0 chore: renaming index files (#1397) 2022-05-11 17:02:28 -04:00
Garrett Delfosse be3bc5cc55 Remove coder templates edit command (#1396) 2022-05-11 20:05:45 +00:00
Ben Potter 537897c0bb chore: add "needs grooming" label to new issues (#1384) 2022-05-11 14:35:58 -05:00
Ben Potter 982769f0dc fix: uses "projects" instead of "templates" in examples docs 2022-05-11 13:42:47 -05:00
Kyle Carberry 3024e25c09 example: Add Kubernetes multi-service (#1092)
* example: Add Kubernetes multi-service

* fix: change to CODER_AGENT_TOKEN

* example: use ServiceAccount for cluster authentication (#1096)

Co-authored-by: Ben <ben@coder.com>
2022-05-11 18:27:31 +00:00
Ben Potter f5817248de feat: arm(v7/64) builds for releases and agent scripts (#1337)
* feat: build armv7 linux releases

* upload ARM binaries to bin

* Only build arm 7 for Linux

* add ARM agent scripts

* fix: specify armv7 to match tf provider

* append arm version to slim builds

* use descript armv7 binary

* Add script mappings for each architecture

Co-authored-by: kylecarbs <kyle@carberry.com>
2022-05-11 09:44:43 -05:00
Ben Potter a169542bda chore: bump hc-install from v0.3.1 to v0.3.2 (#1382)
* chore: bump hc-install from v0.3.1 to v0.3.2

* fix
2022-05-11 09:05:25 -05:00
Spike Curtis 9d94f4f714 fix: macOS backspace processing (#1379)
Revert "fix: Remove line length limit on MacOS for input prompts (#839)"

This reverts commit ccba2ba99d.
2022-05-10 15:20:36 -07:00
Colin Adler f816bbe801 feat: add codegen for audit.AuditableResources entries (#1370) 2022-05-10 21:27:45 +00:00
Colin Adler 97a95f1377 chore: upgrade golangci-lint to v1.46.0 (#1373) 2022-05-10 16:04:23 -05:00
Kyle Carberry e0a7aec228 fix: Match kubectl table style for simpler scripting (#1363)
Fixes #1322.
2022-05-10 15:57:07 -05:00
Bruno Quaresma 2df92e6fd3 feat: Add update user roles action (#1361) 2022-05-10 19:13:07 +00:00
Spike Curtis c96d439f3d chore: add Spike Curtis to contributors (#1333)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-10 16:46:28 +00:00
Ben Potter e8e4cf9a37 feat: add comparison to docs (#1315)
* fix typo

* feat: add comparison table

* Update docs/about.md

Co-authored-by: Katie Horne <katie@23spoons.com>

* Update docs/about.md

Co-authored-by: Katie Horne <katie@23spoons.com>

* Update docs/about.md

Co-authored-by: Katie Horne <katie@23spoons.com>

* chore: remove gitpod

Co-authored-by: Katie Horne <katie@23spoons.com>
2022-05-10 16:31:59 +00:00
dependabot[bot] 47f1fd57e4 chore: bump ts-loader from 9.2.9 to 9.3.0 in /site (#1253)
Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 9.2.9 to 9.3.0.
- [Release notes](https://github.com/TypeStrong/ts-loader/releases)
- [Changelog](https://github.com/TypeStrong/ts-loader/blob/main/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/ts-loader/compare/v9.2.9...v9.3.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-10 09:45:31 -04:00
Mathias Fredriksson 2d3dc436a8 feat: Implement unified pagination and add template versions support (#1308)
* feat: Implement pagination for template versions

* feat: Use unified pagination between users and template versions

* Sync codepaths between users and template versions

* Create requestOption type in codersdk and add test

* Fix created_at edge case for pagination cursor in queries

* feat: Add support for json omitempty and embedded structs in apitypings (#1318)

* Add scripts/apitypings/main.go to Makefile
2022-05-10 07:44:09 +00:00
Kyle Carberry dc115b8ca0 fix: Use proper endpoint for user workspaces (#1356)
This was a silly mistake in a prior PR, so the code wasn't
actually being called!
2022-05-10 03:10:47 +00:00
Kyle Carberry b675aec4dd feat: Add endpoint to get all workspaces a user can access (#1354)
This iterates through user organizations to get permitted
workspaces. This will allow admins to manage user workspaces!
2022-05-10 02:38:20 +00:00
Kyle Carberry e6f1ce1fb2 fix: Allow coderd to exit on error channel (#1355)
coderd would fail silently if this was called, because connections
would never drain. HashiCorp's hc-install package broke today,
and we couldn't notice because this was hanging!
2022-05-10 02:19:20 +00:00
dependabot[bot] 3660483b97 chore: bump github.com/moby/moby (#1339)
Bumps [github.com/moby/moby](https://github.com/moby/moby) from 20.10.14+incompatible to 20.10.15+incompatible.
- [Release notes](https://github.com/moby/moby/releases)
- [Changelog](https://github.com/moby/moby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moby/moby/compare/v20.10.14...v20.10.15)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-09 19:01:33 -05:00
dependabot[bot] 48f004bb3d chore: bump github.com/charmbracelet/charm from 0.12.0 to 0.12.1 (#1341)
Bumps [github.com/charmbracelet/charm](https://github.com/charmbracelet/charm) from 0.12.0 to 0.12.1.
- [Release notes](https://github.com/charmbracelet/charm/releases)
- [Changelog](https://github.com/charmbracelet/charm/blob/main/.goreleaser.yml)
- [Commits](https://github.com/charmbracelet/charm/compare/v0.12.0...v0.12.1)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-09 19:00:11 -05:00
dependabot[bot] 5653c4455a chore: bump google.golang.org/api from 0.77.0 to 0.78.0 (#1340)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.77.0 to 0.78.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.77.0...v0.78.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-09 18:50:32 -05:00
dependabot[bot] 9b30ff8e59 chore: bump @typescript-eslint/parser from 5.22.0 to 5.23.0 in /site (#1353)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.22.0 to 5.23.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.23.0/packages/parser)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-09 18:29:40 -05:00
Kyle Carberry ddb9631d7a fix: Group subcommands for cognitive ease (#1351) 2022-05-09 17:42:02 -05:00
Colin Adler 20caee1502 feat: add audit exporting and filtering (#1314) 2022-05-09 22:05:01 +00:00
dependabot[bot] ac27f645eb chore: bump @typescript-eslint/parser from 5.21.0 to 5.22.0 in /site (#1343)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.21.0 to 5.22.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.22.0/packages/parser)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-09 16:41:54 -05:00
David Wahler d847d2b1c5 chore: add dwahler as contributor (#1352) 2022-05-09 20:57:03 +00:00
Kira Pilot f5693dff3d chore: added contributer (#1349) 2022-05-09 14:49:23 -04:00
Bruno Quaresma e54324d880 refactor: Add roles into the user response (#1347) 2022-05-09 16:38:14 +00:00
Spike Curtis ad8d9dd71a feat: make it harder to skip graceful shutdown accidentally (#1327)
* feat: make it harder to skip graceful shutdown accidentally

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

* fixup: don't use unbuffered signal channel

Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-06 13:45:18 -07:00
Bruno Quaresma 00806580f5 refactor: Return the display_name and name in the roles endpoint (#1328) 2022-05-06 19:18:00 +00:00
Kyle Carberry 97ee5600c7 fix: Remove "CODER_URL" and "CODER_TOKEN" (#1330)
These aren't being used, so it's best to remove for now.
It caused issues with dogfooding from v1 too!
2022-05-06 18:46:21 +00:00
Bruno Quaresma cf5aca799d Add reset user password action (#1320) 2022-05-06 13:23:03 -05:00
Bruno Quaresma 57bb108465 feat: Add update user password endpoint (#1310) 2022-05-06 09:20:08 -05:00
Presley Pizzo a2be7c0294 fix: create and read workspace page (#1294)
* Change name of existing workspace call

* Add new api call (has handler already)

* WorkspacesPage -> WorkspacePage

* starting to replace swr

* Add other api calls

* Fix api call

* Replace swr with xstate

* Format

* Test - wip

* Fix route in template page

* Fix endpoint in create workspace

* Fix tests

* Lint
2022-05-06 10:02:17 -04:00
Mathias Fredriksson 3dbcddc310 fix: Confirm password in cli create first user step (#1220)
Fixes #1182
2022-05-06 15:47:38 +03:00
Kyle Carberry 914a2f477c fix: Restore terminal on interrupt when connecting (#1312)
Fixes #1292.
2022-05-05 20:11:44 -05:00
Ben Potter f965066517 feat: add screenshot to readme (#1313)
* feat: add screenshot to readme

* change
2022-05-06 01:09:27 +00:00
Ben Potter 568574c118 fix: use CODER_AGENT_TOKEN for docker example (#1295) 2022-05-04 22:42:58 +00:00
Colin Adler 0ccf0102d7 fix: ensure correct version of sqlc is executed (#1287)
If `/usr/local/bin` is searched before `$GOPATH/bin` in your `$PATH` the
wrong version of `sqlc` can be executed.
2022-05-04 20:09:13 +00:00
Kyle Carberry d7f63217f1 feat: Add code splitting to reduce bundle size (#1285)
This splits our pages to use separate JavaScript bundles. It
initially splits the terminal, which reduces our primary
bundle size by ~400KB.

We should do this for all pages, but that can come in a future
change. This leaves the loading page empty for now, which I
think is fine. None of our pages are large enough that the blank
screen temporarily would be concerning.
2022-05-04 14:24:31 -05:00
Bruno Quaresma f911c8a781 feat: Add suspend user action (#1275) 2022-05-04 16:10:38 +00:00
Presley Pizzo 34b91fd577 feat: add margins to pages (#1217)
* Add Margin, use constants

* Change throughout

* Add to a page, lint

* Format
2022-05-04 11:36:54 -04:00
Kyle Carberry 4c35b8174a fix: Prefix paths in find on macOS (#1284)
This fixes paths not resolving in macOS, causing
the build target to fail. This also renames the
site target to specify the index.html, which is
the output artifact of building the site.
2022-05-04 09:47:48 -05:00
Kyle Carberry e860cc4814 fix: Build site in release (#1283)
This was using Mac Make, which is missing some options:
https://github.com/coder/coder/runs/6265845123?check_suite_focus=true#step:10:6
2022-05-04 14:23:48 +00:00
Colin Adler 9d2e788fea feat: allow verbose logging in coder server (#1280) 2022-05-03 16:13:30 -05:00
Steven Masley d0293e4d33 feat: Implement list roles & enforce authorize examples (#1273) 2022-05-03 16:10:19 -05:00
Colin Adler 0f9e30e54f fix: use correct enable bool for pprof (#1279) 2022-05-03 19:54:10 +00:00
Colin Adler e530ab2838 chore: add api specific 404 (#1272)
Prevents weird errors when routes are moved, like
https://github.com/coder/coder/issues/1205
2022-05-03 09:22:08 -05:00
dependabot[bot] ba80c799d7 chore: bump typescript from 4.6.3 to 4.6.4 in /site (#1252)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.6.3 to 4.6.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.6.3...v4.6.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-03 09:11:39 -05:00
Kyle Carberry 60aa40a56f fix: Remove microsecond wait in peer.(*Channel) (#1270)
This was implemented when our WebRTC code was much less hardened.
It's likely this was a cause of some other problem.

Closes #1076.
2022-05-03 14:00:59 +00:00
Colin Adler eda85a0141 fix: force logs to flush on close in peer.(*Conn) (#1268) 2022-05-03 08:36:48 -05:00
Colin Adler 9319c39257 fix: additional provisionerd test double closes (#1267) 2022-05-03 08:02:54 -05:00
Colin Adler 55ad97bbd7 feat: add pprof and prometheus metrics to coder server (#1266) 2022-05-03 12:48:02 +00:00
Kyle Carberry 5dcaf940b6 fix: Build site in deploy (#1265) 2022-05-02 23:12:13 +00:00
Kyle Carberry fd49a18b47 feat: Add "state" command to pull and push workspace state (#1264)
It's possible for a workspace to become in an invalid state.
This is something we'll detect for jobs, and allow monitoring of.

These commands will allow admins to manually reconcile state.
2022-05-02 17:51:58 -05:00
Kyle Carberry 43c6bff5ae fix: Use "terraform state pull" instead of "terraform show" (#1262)
Although the terraform-exec docs don't indicate this, the result of
"terraform show" isn't actually the state... it's a trimmed version
of the state that excludes resource identifiers, essentially removing
all state that did exist.

Tests will be written to ensure Terraform state reconciliation can occur.
This will happen in another PR, as dogfood is currently broken because of this.
2022-05-02 20:02:38 +00:00
Kyle Carberry fc642edf51 fix: Use GoReleaser Action in deploy script (#1263)
This reduces conflictions with our Makefile, which is presently
primarily a user script.
2022-05-02 20:00:08 +00:00
Colin Adler 81bef1c83e feat: add audit logging database schema (#1225) 2022-05-02 19:30:46 +00:00
Kyle Carberry e4e60256ac fix: Use "make build" on deploy (#1261)
This was a missed item in https://github.com/coder/coder/pull/1259.
2022-05-02 14:04:45 -05:00
Kyle Carberry dacc025cf3 fix: Adjust Makefile tagets to use dependencies (#1259)
It was getting slow to run `make gen` and other operations,
but this resolves it by targeting files properly.
2022-05-02 13:23:13 -05:00
dependabot[bot] 2293d7efd1 chore: bump github.com/gohugoio/hugo from 0.97.3 to 0.98.0 (#1247)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.97.3 to 0.98.0.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/goreleaser.yml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.97.3...v0.98.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-02 17:49:02 +00:00
dependabot[bot] 9032b7e33f chore: bump github.com/open-policy-agent/opa from 0.39.0 to 0.40.0 (#1245)
Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.39.0 to 0.40.0.
- [Release notes](https://github.com/open-policy-agent/opa/releases)
- [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-policy-agent/opa/compare/v0.39.0...v0.40.0)

---
updated-dependencies:
- dependency-name: github.com/open-policy-agent/opa
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-02 17:36:02 +00:00
dependabot[bot] 6dd378c194 chore: bump google.golang.org/api from 0.75.0 to 0.77.0 (#1249)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.75.0 to 0.77.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.75.0...v0.77.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-02 17:32:27 +00:00
Kyle Carberry 3d96785bf5 fix: Add lock around read/write of circular buffer (#1258)
This fixes a race seen in:
https://github.com/coder/coder/runs/6260926628?check_suite_focus=true#step:10:666
2022-05-02 17:31:04 +00:00
dependabot[bot] 7fb3c5728b chore: bump gopkg.in/DataDog/dd-trace-go.v1 from 1.38.0 to 1.38.1 (#1246)
Bumps [gopkg.in/DataDog/dd-trace-go.v1](https://github.com/DataDog/dd-trace-go) from 1.38.0 to 1.38.1.
- [Release notes](https://github.com/DataDog/dd-trace-go/releases)
- [Commits](https://github.com/DataDog/dd-trace-go/compare/v1.38.0...v1.38.1)

---
updated-dependencies:
- dependency-name: gopkg.in/DataDog/dd-trace-go.v1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-02 17:16:45 +00:00
Kyle Carberry 3176e10562 fix: Use atomic value for logger in peer (#1257)
This caused many races where logs would escape the tests
by milliseconds. By using an atomic on the logger,
we can fix all of it!
2022-05-02 11:49:59 -05:00
Kyle Carberry e531c0930c fix: Write agent logs to "/tmp/coder-agent.log" for debugging (#1239)
It was difficult to obtain logs for the agent if it failed to
start for some reason. Now they'll go to a consistent spot!
2022-05-02 16:36:51 +00:00
Kyle Carberry c2b5009208 fix: Unnest workspaces command to the top-level (#1241)
This changes all "coder workspace *" commands to root.
A few of these were already at the root, like SSH. The
inconsistency made for a confusing experience.
2022-05-02 11:08:52 -05:00
Kyle Carberry 252d868298 fix: Prefix buildinfo tag with "v" (#1256)
This fixes the format of production and development build
tags.
2022-05-02 15:58:36 +00:00
Kyle Carberry d139a16446 fix: Allow remote state to be used with Terraform (#1242)
The Terraform Provisioner depended on the statefile content
being at a specific path, which disallowed the use of external
state providers. This fixes it!
2022-05-02 15:41:27 +00:00
Ben Potter aaf6aee979 fix: clarify AWS access key ID vs secret (#1231) 2022-05-02 10:28:58 -05:00
Kyle Carberry 8701e0084c feat: Update Terraform provider to support "dir" in "coder_agent" (#1219)
This allows users to specify a starting directory for shell sessions.
2022-05-02 10:27:34 -05:00
Kyle Carberry a79aa6418a fix: Use cliui.WorkspaceBuild to prevent cancel of builds jobs (#1255)
Build jobs cannot gracefully terminate because Terraform generally
cannot gracefully terminate.
2022-05-02 10:20:47 -05:00
Bruno Quaresma 75343288ff feat: Add user menu on users table (#1222) 2022-05-02 14:58:49 +00:00
dependabot[bot] a71f3934c5 chore: bump github.com/go-playground/validator/v10 (#1254)
Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.10.1 to 10.11.0.
- [Release notes](https://github.com/go-playground/validator/releases)
- [Commits](https://github.com/go-playground/validator/compare/v10.10.1...v10.11.0)

---
updated-dependencies:
- dependency-name: github.com/go-playground/validator/v10
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-02 08:21:35 -05:00
Bruno Quaresma 2043d1a4cc chore: Port ConfirmDialog from v1 (#1228) 2022-05-02 08:17:15 -05:00
dependabot[bot] 4ff5734720 chore: bump github.com/charmbracelet/charm from 0.11.0 to 0.12.0 (#1248)
Bumps [github.com/charmbracelet/charm](https://github.com/charmbracelet/charm) from 0.11.0 to 0.12.0.
- [Release notes](https://github.com/charmbracelet/charm/releases)
- [Changelog](https://github.com/charmbracelet/charm/blob/main/.goreleaser.yml)
- [Commits](https://github.com/charmbracelet/charm/compare/v0.11.0...v0.12.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-02 07:59:46 -05:00
Kyle Carberry 34dbca7166 fix: Remove unnecessary warnings on SSH (#1243)
This disables the "Warning: Permanently added 'hostname' (RSA) to the list of known hosts."
message from appearing on every SSH. This happens because we ignore the known hosts.
2022-05-01 20:31:22 -05:00
Kyle Carberry 9b37a0de31 fix: Disable ErrorLog in http.Server (#1244)
Vault does similarly: https://github.com/hashicorp/vault/blob/e2490059d0711635e529a4efcbaa1b26998d6e1c/command/server.go#L2714

These messages have primarily been noise.
2022-05-01 20:31:12 -05:00
Kyle Carberry b948f2dab5 fix: Use environment variables for agent authentication (#1238)
* fix: Update GIT_COMMITTER_NAME to use username

This was a mistake when adding the committer fields 🤦.

* fix: Use environment variables for agent authentication

Using files led to situations where running "coder server --dev" would
break `gitssh`. This is applicable in a production environment too. Users
should be able to log into another Coder deployment from their workspace.

Users can still set "CODER_URL" if they'd like with agent env vars!
2022-04-30 16:40:30 +00:00
Kyle Carberry eb606924ab fix: Update GIT_COMMITTER_NAME to use username (#1237)
This was a mistake when adding the committer fields 🤦.
2022-04-29 20:51:11 -05:00
Kyle Carberry 2acdd3b44f fix: Add "GIT_COMMITTER_*" to remove Git prompt (#1236) 2022-04-30 01:22:17 +00:00
Kyle Carberry e15566c7fa test: Regenerate GitSSHKey flake when comparing times (#1235)
This is a crazy one! The in-memory DB is fast, which allows the same
exact timestamp to occur for regenerating the key!

See: https://github.com/coder/coder/runs/6234173911?check_suite_focus=true#step:9:82
2022-04-29 20:19:16 -05:00
Kyle Carberry 81577f120a feat: Add web terminal with reconnecting TTYs (#1186)
* feat: Add web terminal with reconnecting TTYs

This adds a web terminal that can reconnect to resume sessions!
No more disconnects, and no more bad bufferring!

* Add xstate service

* Add the webpage for accessing a web terminal

* Add terminal page tests

* Use Ticker instead of Timer

* Active Windows mode on Windows
2022-04-29 17:30:10 -05:00
Kyle Carberry 23e5636dd0 fix: Use verified and primary email for GitHub signup (#1230)
This was causing a panic due to nil pointer dereference.
It required all users signing up had a public email,
which is an unreasonable requirement!
2022-04-29 15:13:35 -05:00
Bruno Quaresma 021e4cd957 refactor: Load users from the API (#1218) 2022-04-29 13:59:14 -05:00
Steven Masley 69e26c4036 feat: Allow using username in user queries (#1221)
* feat: Allow using username in user queries
* Test needs a username/email to not match empty string
2022-04-29 11:44:22 -05:00
dependabot[bot] 365c96ccaa chore: bump @fontsource/fira-code from 4.5.8 to 4.5.9 in /site (#1188)
Bumps [@fontsource/fira-code](https://github.com/fontsource/fontsource/tree/HEAD/fonts/google/fira-code) from 4.5.8 to 4.5.9.
- [Release notes](https://github.com/fontsource/fontsource/releases)
- [Changelog](https://github.com/fontsource/fontsource/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fontsource/fontsource/commits/HEAD/fonts/google/fira-code)

---
updated-dependencies:
- dependency-name: "@fontsource/fira-code"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-29 15:58:33 +00:00
dependabot[bot] a3decc4fba chore: bump eslint-plugin-react-hooks from 4.4.0 to 4.5.0 in /site (#1190)
Bumps [eslint-plugin-react-hooks](https://github.com/facebook/react/tree/HEAD/packages/eslint-plugin-react-hooks) from 4.4.0 to 4.5.0.
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/HEAD/packages/eslint-plugin-react-hooks)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-29 10:55:15 -05:00
dependabot[bot] 27811976ad chore: bump ts-loader from 9.2.8 to 9.2.9 in /site (#1192)
Bumps [ts-loader](https://github.com/TypeStrong/ts-loader) from 9.2.8 to 9.2.9.
- [Release notes](https://github.com/TypeStrong/ts-loader/releases)
- [Changelog](https://github.com/TypeStrong/ts-loader/blob/main/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/ts-loader/compare/v9.2.8...v9.2.9)

---
updated-dependencies:
- dependency-name: ts-loader
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-29 10:54:54 -05:00
dependabot[bot] 3ebe1d27b1 chore: bump @playwright/test from 1.21.0 to 1.21.1 in /site (#1191)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.21.0 to 1.21.1.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.21.0...v1.21.1)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-29 10:54:39 -05:00
Steven Masley 35211e2190 feat: Add user roles, but do not yet enforce them (#1200)
* chore: Rework roles to be expandable by name alone
2022-04-29 09:04:19 -05:00
Bruno Quaresma ba4c3ce3b9 feat: add filter by status on GET /users (#1206) 2022-04-29 08:29:53 -05:00
Colin Adler 82364d174f fix: ensure rtc state changes can't log after close (#1213) 2022-04-28 16:38:59 -05:00
Bruno Quaresma 00cac37a07 chore: force desktop view on mobile (#1214) 2022-04-28 17:05:03 -04:00
Presley Pizzo c16f105727 feat: Create user page (#1197)
* Add button and route

* Hook up api

* Lint

* Add basic form

* Get users on page mount

* Make cancel work

* Creating -> idle bc users page refetches

* Import as TypesGen

* Handle api errors

* Lint

* Add handler

* Add FormFooter

* Add FullPageForm

* Lint

* Better form, error, stories

bug in formErrors story

* Make detail optional

* Use Language

* Remove detail prop

* Add back autoFocus

* Remove displayError, use displaySuccess

* Lint, export Language

* Tests - wip

* Fix cancel tests

* Switch back to mock

* Add navigate to xservice

Doesn't work in test

* Move error type predicate to xservice

* Lint

* Switch to using creation mode in XState

still problems in tests

* Lint

* Lint

* Lint

* Revert "Switch to using creation mode in XState"

This reverts commit cf8442fa4b.

* Give XService a navigate action

* Add missing validation messages

* Fix XState warning

* Fix tests

IRL is broken bc I need to send org id

* Pretend user has org id and make it work

* Format

* Lint

* Switch to org ids array

* Skip lines between tests

Co-authored-by: G r e y <grey@coder.com>

* Punctuate notification messages

Co-authored-by: G r e y <grey@coder.com>
2022-04-28 16:32:23 -04:00
Mathias Fredriksson 4efde58726 fix: Restore static credentials for develop.sh (#1212) 2022-04-28 21:47:35 +03:00
Colin Adler 1661588bd1 fix: user passwords cleanup (#1202)
1. Adds benchmarks comparing bcrypt and our pbkdf2 settings
1. Changes the pbkdf2 hash iterations back to 65k. 1024 is insecure
1. Gets rid of the short circuit when the user isn't found, preventing
   timing attacks which can reveal which emails exist on a deployment

```
$ go test -bench .
goos: linux
goarch: amd64
pkg: github.com/coder/coder/coderd/userpassword
cpu: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
BenchmarkBcryptMinCost-16        	    1651	    702727 ns/op	    5165 B/op      10 allocs/op
BenchmarkPbkdf2MinCost-16        	    1669	    714843 ns/op	     804 B/op      10 allocs/op
BenchmarkBcryptDefaultCost-16    	      27	  42676316 ns/op	    5246 B/op      10 allocs/op
BenchmarkPbkdf2-16               	      26	  45902236 ns/op	     804 B/op      10 allocs/op
PASS
ok  	github.com/coder/coder/coderd/userpassword	5.036s
```
2022-04-28 18:22:38 +00:00
Steven Masley e330dc1321 feat: Switch packages for typescript generation code (#1196)
* feat: Switch packages for typescript generation code

Supports a larger set of types
  - [x] Basics (string/int/etc) 
  - [x] Maps
  - [x] Slices
  - [x] Enums
  - [x] Pointers
2022-04-28 16:59:14 +00:00
Mathias Fredriksson afc43fe95f feat: Generate random admin user password in dev mode (#1207)
* feat: Generate random admin user password in dev mode

* Add dev mode test with email/pass from env

* Set email/pass for playwright e2e test via cli flags
2022-04-28 19:13:44 +03:00
Kyle Carberry eea9729704 fix: Update buildinfo package location in ldflags (#1208)
This was causing the version to not be injected!
2022-04-28 10:46:18 -05:00
Bruno Quaresma 816441eff7 feat: add organization_ids in the user(s) response (#1184) 2022-04-28 09:10:17 -05:00
Colin Adler a7fb018414 chore: update github.com/golang-migrate/migrate/v4 to v4.5.2 (#1201)
Should fix the security warning for https://github.com/advisories/GHSA-crp2-qrr5-8pq7
2022-04-27 22:04:51 +00:00
Mathias Fredriksson 8661f92a10 feat: Output username and password for code server --dev (#1193)
Fixes #825
2022-04-27 17:59:37 +03:00
Mathias Fredriksson 0b1ee3303d chore: Add Contributors section to readme (#1144)
Co-authored-by: Cian Johnston <public@cianjohnston.ie>
2022-04-27 11:48:45 +00:00
dependabot[bot] a769e8623d chore: bump @types/node from 14.18.15 to 14.18.16 in /site (#1189)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.18.15 to 14.18.16.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-27 06:04:44 +00:00
dependabot[bot] 26f3ceda93 chore: bump @typescript-eslint/parser from 5.19.0 to 5.21.0 in /site (#1160)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.19.0 to 5.21.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.21.0/packages/parser)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: G r e y <grey@coder.com>
2022-04-27 05:52:53 +00:00
dependabot[bot] d85e36ce9e chore: bump @xstate/cli from 0.1.6 to 0.1.7 in /site (#1139)
Bumps @xstate/cli from 0.1.6 to 0.1.7.

---
updated-dependencies:
- dependency-name: "@xstate/cli"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-27 01:44:19 -04:00
dependabot[bot] 7f423951bf chore: bump jest-junit from 13.1.0 to 13.2.0 in /site (#1137)
Bumps [jest-junit](https://github.com/jest-community/jest-junit) from 13.1.0 to 13.2.0.
- [Release notes](https://github.com/jest-community/jest-junit/releases)
- [Commits](https://github.com/jest-community/jest-junit/compare/v13.1.0...v13.2.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-27 01:43:34 -04:00
dependabot[bot] 65d5975592 chore: bump cronstrue from 2.2.0 to 2.4.0 in /site (#1165)
Bumps [cronstrue](https://github.com/bradymholt/cronstrue) from 2.2.0 to 2.4.0.
- [Release notes](https://github.com/bradymholt/cronstrue/releases)
- [Commits](https://github.com/bradymholt/cronstrue/compare/v2.2.0...v2.4.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-27 05:38:17 +00:00
Presley Pizzo 23a1a4dc40 refactor: Add components for styling forms (#1169)
* Add FormFooter

* Add FullPageForm

* Lint

* Make detail optional

* Use Language
2022-04-26 19:45:48 -04:00
Bruno Quaresma 454ccf7547 refactor: remove the user name (#1185) 2022-04-26 19:04:57 +00:00
Ben Potter 22668c388c feat: initial docs pages (#1107)
* docs structure and edits to getting started

* draft for about page

* skeleton for concepts page

* attempt at explaining templates

* left-align tables

* add best practices and variables

* update structrure

* update structure

* templates are shared

* workspaces docs

* remove coming soon

* fix typos

* docs structure and edits to getting started

* draft for about page

* skeleton for concepts page

* attempt at explaining templates

* left-align tables

* add best practices and variables

* update structrure

* update structure

* templates are shared

* workspaces docs

* remove coming soon

* fix typos

* fix typos

* Update docs/about.md

Co-authored-by: Joe Previte <jjprevite@gmail.com>

* remove line breaks between bullets

* rename variables to parameters

* reduce limits

* chore: edit text

* revert some changes, fix footnotes

Co-authored-by: Katie Horne <katie@coder.com>
Co-authored-by: Joe Previte <jjprevite@gmail.com>
2022-04-26 12:10:50 -05:00
Kyle Carberry 603b7da413 test: Wrap provisionerd channel closes in sync.Once (#1181)
This caused a few flakes, so figured I'd tackle all of them:
https://github.com/coder/coder/runs/6167856950?check_suite_focus=true#step:9:246
2022-04-26 09:44:16 -05:00
Bruno Quaresma 441ffd6a0b feat: add PUT /api/v2/users/:user-id/suspend endpoint (#1154) 2022-04-26 09:00:07 -05:00
Kyle Carberry f9ce54a51e fix: Increase default provisioner daemons to 3 (#1180)
It's odd to only build one workspace at a time as a default.
2022-04-26 07:19:17 -05:00
Kyle Carberry 8d85d80a55 fix: Use proper shutdown signal for systemd (#1179)
Coder was being killed instantly, which caused builds
to randomly fail!
2022-04-25 21:09:11 -05:00
Kyle Carberry 744a00a55d feat: Add GIT_COMMITTER information to agent env vars (#1171)
This makes setting up git a bit simpler, and users
can always override these values!

We'll probably add a way to disable our Git integration
anyways, so these could be part of that.
2022-04-25 20:03:54 -05:00
Kyle Carberry 877854a2f3 fix: Display proper access URL on server start (#1172)
Fixes #1170.
2022-04-25 23:30:22 +00:00
Kyle Carberry 29d55887f9 fix: Update initial window size on SSH TTY (#1174)
It required a window resize before to trigger
a size update. This fixes it!
2022-04-25 23:02:54 +00:00
Kyle Carberry 947e8f9d2e fix: Manually format external URL (#1168)
path.Join escaped the double slash!
2022-04-25 22:22:31 +00:00
Kyle Carberry 159024a196 fix: Add redirect for OAuth from /login (#1163)
This allows for a complete sign-up flow:
1. coder login https://dev.coder.com
2. Navigates to /cli-auth
3. Redirects to /login?redirect=%2Fcli-auth
4. User signs in with GitHub
5. User is redirected back to /cli-auth
2022-04-25 17:07:10 -05:00
Kyle Carberry 4f7ceebe65 fix: Use target="_blank" to redirect for footer version (#1166) 2022-04-25 16:27:14 -05:00
Kyle Carberry 88669fd578 feat: Move workspaces under organizations (#1109)
This removes split ownership for workspaces. They are now
a resource of organizations and have a designated owner,
which is a user.

This enables simple administration for commands like:
- `coder stop ben/dev`
- `coder build logs colin/arch`

or if we decide to allow administrators to access workspaces,
they could even SSH using this syntax: `coder ssh colin/dev`.
2022-04-25 16:11:03 -05:00
Kyle Carberry 759fa5f626 fix: Use Lax mode for OAuth redirect cookies (#1162)
OAuthing was resulting in an error, because Strict
cookies are not sent on redirects.
2022-04-25 20:42:18 +00:00
dependabot[bot] a201610761 chore: bump eslint-plugin-jest from 26.1.4 to 26.1.5 in /site (#1136)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 26.1.4 to 26.1.5.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v26.1.4...v26.1.5)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 20:38:52 +00:00
Kyle Carberry 587cbac498 fix: Swap height and width for TTY size (#1161)
This was causing the TTY to be real wonky on Windows.
It didn't seem to have an effect on Linux, but I suspect
that's because of escape codes.
2022-04-25 15:30:02 -05:00
Colin Adler 0c9f27c63b fix: ensure frontend is built in make install (#1157) 2022-04-25 15:24:23 -05:00
dependabot[bot] 8f464ce8c7 chore: bump @types/react-dom from 17.0.15 to 17.0.16 in /site (#1159)
Bumps [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) from 17.0.15 to 17.0.16.
- [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-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 20:13:04 +00:00
dependabot[bot] 9fb660a6a3 chore: bump @typescript-eslint/eslint-plugin in /site (#1153)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.19.0 to 5.21.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.21.0/packages/eslint-plugin)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 16:03:50 -04:00
dependabot[bot] bb3420d006 chore: bump @types/node from 14.18.13 to 14.18.15 in /site (#1155)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.18.13 to 14.18.15.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 16:01:15 -04:00
Presley Pizzo bdc17f49e4 refactor: curry GetFormHelpers (#1156) 2022-04-25 15:45:33 -04:00
Kyle Carberry 33b58a0363 fix: Use forward slashes on Windows for gitssh (#1146) 2022-04-25 19:41:52 +00:00
Kyle Carberry fccd4fab96 fix: Windows resize syscall using incorrect pointer (#1152)
Resizing of PTYs weren't working on Windows before,
but they are now!
2022-04-25 14:30:57 -05:00
dependabot[bot] 82552a9315 chore: bump eslint from 8.13.0 to 8.14.0 in /site (#1135)
Bumps [eslint](https://github.com/eslint/eslint) from 8.13.0 to 8.14.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.13.0...v8.14.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 15:04:48 -04:00
Kyle Carberry 64348882a0 test: Loop if content length is zero for Windows (#1151)
On Windows it seems the file can be created before the
content has been written, which results in comparing
an empty string.
2022-04-25 19:01:49 +00:00
Kyle Carberry 9056c53054 fix: Disable known hosts checking for config-ssh (#1150)
This was causing the remote identity changed message.
We don't need to verify remote hosts because we
already auth via our API.
2022-04-25 18:59:18 +00:00
Colin Adler 2a57ea757a feat: add audit package (#1046) 2022-04-25 18:57:59 +00:00
Kyle Carberry a2dd618849 feat: Use environment variables and startup script in agent (#1147)
These values were ignored. Environment variables are applied to
new sessions, and are refreshed on reconnect. This is cool because
a workspace could be updated with new environment variables without
requiring a complete start/stop.

The startup script is only ran once regardless of changes, which
feels like the expected behavior.
2022-04-25 18:30:39 +00:00
Kyle Carberry 09405ddc40 test: Wait for WorkspaceResources to complete before exiting (#1149)
This caused a flake seen in:
https://github.com/coder/coder/runs/6162655678?check_suite_focus=true#step:9:87
2022-04-25 18:11:35 +00:00
dependabot[bot] 1e6f2cf750 chore: bump hashicorp/setup-terraform from 1 to 2 (#1130)
Bumps [hashicorp/setup-terraform](https://github.com/hashicorp/setup-terraform) from 1 to 2.
- [Release notes](https://github.com/hashicorp/setup-terraform/releases)
- [Changelog](https://github.com/hashicorp/setup-terraform/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/setup-terraform/compare/v1...v2)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 12:59:47 -05:00
Kyle Carberry 5e6e626ace test: Disable TestAgent/SessionTTY on Windows (#1148)
Either our ConPTY implementation is unstable, or something is
flakey with how it sends output. I'm not sure how our
implementation would sometimes work, so it's best to disable
this for CI stability for now.
2022-04-25 17:53:45 +00:00
dependabot[bot] fdb27eaaf8 chore: bump github.com/hashicorp/hcl/v2 from 2.11.1 to 2.12.0 (#1142)
Bumps [github.com/hashicorp/hcl/v2](https://github.com/hashicorp/hcl) from 2.11.1 to 2.12.0.
- [Release notes](https://github.com/hashicorp/hcl/releases)
- [Changelog](https://github.com/hashicorp/hcl/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/hcl/compare/v2.11.1...v2.12.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hcl/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 17:38:59 +00:00
Kyle Carberry 185d97a65b fix: Increase ptytest buffer to resolve flake (#1141)
From investigating the following run:
https://github.com/coder/coder/runs/6156348454?check_suite_focus=true

It's believed that the cause is data being discarded due to the buffer
filling up. This _might_ fix it, but not entirely sure.
2022-04-25 12:14:16 -05:00
Kyle Carberry 66d45f391e test: Check if provisionerd is closed before setting run chan (#1145)
This race can be seen here:
https://github.com/coder/coder/runs/6159662393?check_suite_focus=true
2022-04-25 12:00:54 -05:00
dependabot[bot] 8c27b4e23d chore: bump jaxxstorm/action-install-gh-release from 1.4.0 to 1.5.0 (#1131)
Bumps [jaxxstorm/action-install-gh-release](https://github.com/jaxxstorm/action-install-gh-release) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/jaxxstorm/action-install-gh-release/releases)
- [Commits](https://github.com/jaxxstorm/action-install-gh-release/compare/v1.4.0...v1.5.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>
2022-04-25 11:17:15 -05:00
dependabot[bot] 1acc454035 chore: bump github.com/mitchellh/mapstructure from 1.4.3 to 1.5.0 (#1133)
Bumps [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) from 1.4.3 to 1.5.0.
- [Release notes](https://github.com/mitchellh/mapstructure/releases)
- [Changelog](https://github.com/mitchellh/mapstructure/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mitchellh/mapstructure/compare/v1.4.3...v1.5.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 11:16:32 -05:00
Steven Masley 8b54ea8562 test: Fix user pagination sort order (#1143)
Sort by uuid in expected output to cover when times are equal
for 2 users. The database (fake & pg) use id as as second ordering
to cover this edge case. Should realistically never happen in
production.
2022-04-25 10:27:08 -05:00
dependabot[bot] c08fdc0c8c chore: bump github.com/gohugoio/hugo from 0.97.2 to 0.97.3 (#1132)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.97.2 to 0.97.3.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/goreleaser.yml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.97.2...v0.97.3)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 09:43:57 -05:00
dependabot[bot] 2959137f0d chore: bump github.com/pion/webrtc/v3 from 3.1.29 to 3.1.34 (#1134)
Bumps [github.com/pion/webrtc/v3](https://github.com/pion/webrtc) from 3.1.29 to 3.1.34.
- [Release notes](https://github.com/pion/webrtc/releases)
- [Commits](https://github.com/pion/webrtc/compare/v3.1.29...v3.1.34)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 09:43:40 -05:00
dependabot[bot] dbb4a979cc chore: bump cloud.google.com/go/compute from 1.6.0 to 1.6.1 (#1140)
Bumps [cloud.google.com/go/compute](https://github.com/googleapis/google-cloud-go) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/pubsub/v1.6.0...pubsub/v1.6.1)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/compute
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 09:43:20 -05:00
dependabot[bot] 68d79e0f5f chore: bump google.golang.org/api from 0.74.0 to 0.75.0 (#1129)
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.74.0 to 0.75.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.74.0...v0.75.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-25 09:28:09 -05:00
dependabot[bot] 5575e3c485 chore: bump gopkg.in/DataDog/dd-trace-go.v1 from 1.37.1 to 1.38.0 (#1128) 2022-04-25 06:29:18 -05:00
Cian Johnston c32a006e8f feat: add competitive advanced git functionality (#1077) 2022-04-25 09:01:32 +01:00
Kyle Carberry 7e33d80fa9 feat: Add helper output on failed gitssh (#1127) 2022-04-25 00:29:15 -05:00
Kyle Carberry 4417dd5951 feat: Add STUN servers to enable P2P (#1126)
This exposes a `--stun-server` option for listing
STUN servers. By default it uses the Google STUN
server, but this is not required.
2022-04-25 04:52:07 +00:00
Kyle Carberry c8e566fe42 feat: Add links for registering git key (#1125) 2022-04-25 04:27:45 +00:00
Kyle Carberry 8ff0c8b02a fix: Write agent URL to file for gitssh (#1123)
This was broken because gitssh couldn't find the URL.
Now it can, and SSH is confirmed to work on dogfood! 🥳
2022-04-25 04:06:52 +00:00
Kyle Carberry 68f67c54b6 fix: Add sync.Once to prevent double close in test (#1124)
https://github.com/coder/coder/runs/6151451291?check_suite_focus=true
2022-04-25 04:06:18 +00:00
Colin Adler abc13c5a92 fix: use fmt.Fprintln to print workspaces table (#1122) 2022-04-25 04:04:34 +00:00
Kyle Carberry a6ea99541e fix: Return from update loop when job completes (#1121)
Update was running forever, which stopped jobs from timing
out unless a restart occurred. This also fixes complete properly
reporting an error.
2022-04-25 03:41:03 +00:00
Kyle Carberry d44876382d fix: Remove unique index on auth tokens (#1120)
If a workspace is started multiple times, resources may
not be invalidated. This means an auth token can be
reused for a workspace.

coderd closes old agent connections, so this is expected
behavior, and the agent will reconnect properly.
2022-04-24 22:24:02 -05:00
Kyle Carberry 885d5f2098 fix: Monitor TTY size when using SSH (#1119)
The TTY wasn't resizing properly, and reasonably so considering
we weren't updating it 🤦.
2022-04-24 22:23:54 -05:00
Kyle Carberry 0c042dc249 fix: Remove duplicate index that blocked same name (#1118)
Multiple workspaces couldn't be created with the same names!
2022-04-25 02:40:14 +00:00
Kyle Carberry 23295f7f07 fix: Check for job status on another incoming (#1117)
If a job silently failed, it wasn't possible for another one
to execute. This fixes it by using the API status to return
active state.
2022-04-25 02:22:36 +00:00
Kyle Carberry db7ed4d019 fix: Add resiliency to daemon connections (#1116)
Connections could fail when massive payloads were transmitted.
This fixes an upstream bug in dRPC where the connection would
end with a context canceled if a message was too large.

This adds retransmission of completion and failures too. If
Coder somehow loses connection with a provisioner daemon,
upon the next connection the state will be properly reported.
2022-04-24 20:33:19 -05:00
Kyle Carberry be974cf280 feat: Add users create and list commands (#1111)
This allows for *extremely basic* user management.
2022-04-24 20:08:26 -05:00
Kyle Carberry 7496c3da81 feat: Add GitHub OAuth (#1050)
* Initial oauth

* Add Github authentication

* Add AuthMethods endpoint

* Add frontend

* Rename basic authentication to password

* Add flags for configuring GitHub auth

* Remove name from API keys

* Fix authmethods in test

* Add stories and display auth methods error
2022-04-23 22:58:57 +00:00
Kyle Carberry 3976994781 chore: Rename "start" to "server" (#1110)
Workspace commands will be aliased at the top-level, so
"start" would easily be confused with starting a workspace.

Server seems like a more appropriate name too.
2022-04-23 12:19:20 -05:00
Steven Masley da3681246e chore: Bump protoc to 3.20.0 (#1104)
* chore: Bump protoc to 3.20.0
* Make gen with 3.20.0 protoc
2022-04-23 01:53:22 +00:00
Garrett Delfosse e181007de1 fix: Add more golang types -> number ts type (#1108) 2022-04-22 21:01:43 +00:00
Colin Adler 95a24cb43a chore: update github.com/fatedier/frp (#1106)
Fixes https://github.com/advisories/GHSA-xcf7-q56x-78gh
2022-04-22 15:49:43 -05:00
Colin Adler d6c1c49868 fix: make install references incorrect folders (#1105) 2022-04-22 15:41:45 -05:00
Steven Masley 548de7d6f3 feat: User pagination using offsets (#1062)
Offset pagination and cursor pagination supported
2022-04-22 15:27:55 -05:00
Kyle Carberry 2a95917557 fix: Add site to release build (#1094)
This was accidentally removed when adding MacOS signing.
2022-04-20 14:06:07 -04:00
Kyle Carberry 65d77383d0 fix: Allow nested Terraform resources (#1093)
This fixes the dependency tree by adding recursion. It
now finds indirect connections and associates it with
an agent.

An example is attached which surfaced this issue.
2022-04-20 12:28:48 -05:00
Kyle Carberry e35a4fdcf0 fix: Disable Windows Defender on agent binary (#1095)
Windows (reasonably) detected our CLI as a virus due to the name
being "sshd" for VS Code support. See:
https://github.com/microsoft/vscode-remote-release/issues/5699

This disables monitoring for our binary prior to run, which
fixes our Windows example.
2022-04-20 15:01:35 +00:00
Joe Previte 44f68b5942 chore(develop): fix processes not killing (#1083) 2022-04-20 07:34:05 -07:00
Asher 3151befb38 chore: un-nest components (#1090)
Closes #936.
2022-04-19 14:16:11 -05:00
Joe Previte 98e46cdd2a chore: use PascalCase for pages files (#1089)
* chore: use PascalCase for pages files

* fixup

* fixup

* fixup

* fixup

* fixup

* fixup
2022-04-19 18:45:03 +00:00
Joe Previte db1127def1 chore: assign site/ to frontend (#1091) 2022-04-19 11:30:55 -07:00
Bruno Quaresma 301451be40 refactor: remove index files from components (#1086) 2022-04-19 13:20:28 -05:00
Presley Pizzo 6c9c1298e4 Reorganize Storybook (#1087) 2022-04-19 13:52:52 -04:00
G r e y 5141d6f970 feat: coder logo html source (#1088) 2022-04-19 13:14:32 -04:00
G r e y c35be02a7e feat: web console logo (#1085) 2022-04-19 12:48:50 -04:00
Garrett Delfosse 8165a6ef75 feat: Add spooky hidden flag (#1065) 2022-04-19 16:40:01 +00:00
Presley Pizzo a68b076b96 refactor: Rename Icons and add stories (#1080)
* Rename CloseIcon

* Rename FileCopyIcon, take out of index

* Rename LogoutIcon and remove from index

* Delete icons index files

* Add icon stories

* Lint
2022-04-19 12:38:43 -04:00
Bruno Quaresma b9933d493a refactor: camel case files (#1081) 2022-04-19 11:18:12 -05:00
G r e y 5ce06769cd chore: replace todos with issues (#1066) 2022-04-19 12:16:57 -04:00
Kyle Carberry 04985a1754 fix: Close TURN connections to resolve flake (#1079) 2022-04-19 11:14:55 -05:00
Garrett Delfosse 89aa39b5c8 fix: sort enum decls (#1075) 2022-04-19 16:02:32 +00:00
Joe Previte 97e07a49e9 chore(webpack): allow process.env.PORT (#1071) 2022-04-19 08:58:03 -07:00
Joe Previte 73b8a5a929 chore: use /usr/bin/env bash (#1070) 2022-04-19 08:45:13 -07:00
Kyle Carberry c8246e3e8a feat: Add Azure instance identitity authentication (#1064)
This enables zero-trust authentication for Azure instances. Now
we support the three major clouds: AWS, Azure, and GCP 😎.
2022-04-19 13:48:13 +00:00
G r e y 118a47e4e1 fix: types-generated.ts (#1063) 2022-04-18 22:03:37 -04:00
Garrett Delfosse f46b4cf3da feat: generate typescript types from codersdk structs (#1047) 2022-04-19 00:45:22 +00:00
Kyle Carberry 1df943e010 fix: Disable TURN logs (#1061)
This was accidentally merged as part of the TURN PR. In the future
we can wrap this to provide useful output, but right now it's too
verbose.
2022-04-18 18:01:49 -05:00
Kyle Carberry d202f20fdb feat: Add TURN proxying to enable offline deployments (#1000)
* Add turnconn

* Add option for passing ICE servers

* Log TURN remote address

* Add TURN server to coder start
2022-04-18 22:40:25 +00:00
Kyle Carberry e5a1c305d3 fix: Remove quotes on GitSSH (#1043) 2022-04-18 15:12:39 -05:00
Kyle Carberry 6d948ffba2 fix: Panic if Terraform fails installation (#1056) 2022-04-18 15:11:59 -05:00
Kyle Carberry 866205c145 feat: Sign MacOS binaries (#1060)
This fixes virus warnings when launching Coder on darwin.
2022-04-18 14:57:41 -05:00
dependabot[bot] a5f36ad4e2 chore: bump @storybook/addon-links from 6.4.21 to 6.4.22 in /site (#1022)
Bumps [@storybook/addon-links](https://github.com/storybookjs/storybook/tree/HEAD/addons/links) from 6.4.21 to 6.4.22.
- [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/v6.4.22/addons/links)

---
updated-dependencies:
- dependency-name: "@storybook/addon-links"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-18 19:55:50 +00:00
dependabot[bot] 50751a2d6f chore: bump @storybook/addon-essentials from 6.4.21 to 6.4.22 in /site (#1020)
Bumps [@storybook/addon-essentials](https://github.com/storybookjs/storybook/tree/HEAD/addons/essentials) from 6.4.21 to 6.4.22.
- [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/v6.4.22/addons/essentials)

---
updated-dependencies:
- dependency-name: "@storybook/addon-essentials"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-18 15:34:39 -04:00
dependabot[bot] 18819e37ee chore: bump @storybook/react from 6.4.21 to 6.4.22 in /site (#1054)
Bumps [@storybook/react](https://github.com/storybookjs/storybook/tree/HEAD/app/react) from 6.4.21 to 6.4.22.
- [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/v6.4.22/app/react)

---
updated-dependencies:
- dependency-name: "@storybook/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-18 14:16:14 -04:00
Kyle Carberry d98b7ec469 fix: Test flake for DataDog agent logs (#1026)
Sometimes the DataDog agent would fail to connect and
angrily log using the standard lib logger. This would
fail tests. See:

https://github.com/coder/coder/runs/6038192436?check_suite_focus=true
2022-04-18 12:37:01 -05:00
Bruno Quaresma 1df750bf1a feat: add GET /api/v2/users (#1028) 2022-04-18 17:19:47 +00:00
Cian Johnston af672803a2 autostart/autostop: move to traditional 5-valued cron string for compatibility (#1049)
This PR modfies the original 3-valued cron strings used in package schedule to be traditional 5-valued cron strings.

- schedule.Weekly will validate that the month and dom fields are equal to *
- cli autostart/autostop will attempt to detect local timezone using TZ env var, defaulting to UTC
- cli autostart/autostop no longer accepts a raw schedule -- instead use the --minute, --hour, --dow, and --tz arguments.
- Default schedules are provided that should suffice for most users.

Fixes #993
2022-04-18 11:04:48 -05:00
Bruno Quaresma 3311c2f65d refactor: replace Code by Detail in the http API error (#1011) 2022-04-18 11:02:54 -05:00
Timo 9faa39aa23 example: added docker local workspace (#1025) 2022-04-18 10:20:45 -05:00
dependabot[bot] 48a6cd9cee chore: bump @testing-library/user-event from 14.1.0 to 14.1.1 in /site (#1055)
Bumps [@testing-library/user-event](https://github.com/testing-library/user-event) from 14.1.0 to 14.1.1.
- [Release notes](https://github.com/testing-library/user-event/releases)
- [Changelog](https://github.com/testing-library/user-event/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/user-event/compare/v14.1...v14.1.1)

---
updated-dependencies:
- dependency-name: "@testing-library/user-event"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-18 10:11:32 -05:00
dependabot[bot] 37c1c6840c chore: bump @playwright/test from 1.20.2 to 1.21.0 in /site (#1053)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.20.2 to 1.21.0.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.20.2...v1.21.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-18 14:04:47 +00:00
dependabot[bot] f5eb8a98ff chore: bump @storybook/addon-actions from 6.4.21 to 6.4.22 in /site (#1021)
Bumps [@storybook/addon-actions](https://github.com/storybookjs/storybook/tree/HEAD/addons/actions) from 6.4.21 to 6.4.22.
- [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/v6.4.22/addons/actions)

---
updated-dependencies:
- dependency-name: "@storybook/addon-actions"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-18 08:55:25 -05:00
dependabot[bot] 5e2b519b36 chore: bump @testing-library/react from 12.1.4 to 12.1.5 in /site (#1019)
Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 12.1.4 to 12.1.5.
- [Release notes](https://github.com/testing-library/react-testing-library/releases)
- [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/react-testing-library/compare/v12.1.4...v12.1.5)

---
updated-dependencies:
- dependency-name: "@testing-library/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-18 08:54:55 -05:00
dependabot[bot] 65e0533d11 chore: bump @types/node from 14.18.12 to 14.18.13 in /site (#1023)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.18.12 to 14.18.13.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-18 08:53:22 -05:00
dependabot[bot] f56eb87fed chore: bump async from 2.6.3 to 2.6.4 in /site (#1027)
Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/caolan/async/releases)
- [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md)
- [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-18 08:52:52 -05:00
dependabot[bot] 71acf4b8a1 chore: bump github.com/gohugoio/hugo from 0.96.0 to 0.97.2 (#1052)
Bumps [github.com/gohugoio/hugo](https://github.com/gohugoio/hugo) from 0.96.0 to 0.97.2.
- [Release notes](https://github.com/gohugoio/hugo/releases)
- [Changelog](https://github.com/gohugoio/hugo/blob/master/goreleaser.yml)
- [Commits](https://github.com/gohugoio/hugo/compare/v0.96.0...v0.97.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>
2022-04-18 08:50:32 -05:00
dependabot[bot] e5a401fce8 chore: bump github.com/pion/webrtc/v3 from 3.1.28 to 3.1.29 (#1051)
Bumps [github.com/pion/webrtc/v3](https://github.com/pion/webrtc) from 3.1.28 to 3.1.29.
- [Release notes](https://github.com/pion/webrtc/releases)
- [Commits](https://github.com/pion/webrtc/compare/v3.1.28...v3.1.29)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-18 08:50:11 -05:00
Kyle Carberry 6dedd0caac ci: Don't run internal steps if forked (#1048)
This was causing CI to fail for contributions.
2022-04-16 13:51:01 -04:00
G r e y cf8a20d6f6 refactor: strong type for getFormHelpers name (#1029) 2022-04-15 16:31:23 -04:00
Kyle Carberry 104a3c6b9c fix: Prefix tmp directory for agent download with "coder" (#1038)
This makes it easier to find the temporary dir for the coder binary.
2022-04-15 15:30:37 -05:00
G r e y 148e7cddd3 chore: update semantic types (#1030)
Summary:

PRs like #1025 feel like they deserve a doc: type, but we didn't have one.
Furthermore our definitions for correct and fix were stale.
2022-04-15 16:26:20 -04:00
Colin Adler a13cceea3b chore: run github actions on pull_request instead of push (#1035) 2022-04-15 15:55:13 -04:00
Bruno Quaresma 88e30bec55 feat: add the preferences/account page (#999) 2022-04-15 13:17:50 -04:00
dependabot[bot] c853eb3350 chore: bump cloud.google.com/go/compute from 1.5.0 to 1.6.0 (#1018)
Bumps [cloud.google.com/go/compute](https://github.com/googleapis/google-cloud-go) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/redis/v1.5.0...pubsub/v1.6.0)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/compute
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-15 10:36:47 -05:00
dependabot[bot] 721cb88225 chore: bump github.com/jedib0t/go-pretty/v6 from 6.3.0 to 6.3.1 (#1017)
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.3.0 to 6.3.1.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.3.0...v6.3.1)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-15 10:03:23 -05:00
dependabot[bot] b36ed2dec7 chore: bump github.com/pion/webrtc/v3 from 3.1.27 to 3.1.28 (#1016)
Bumps [github.com/pion/webrtc/v3](https://github.com/pion/webrtc) from 3.1.27 to 3.1.28.
- [Release notes](https://github.com/pion/webrtc/releases)
- [Commits](https://github.com/pion/webrtc/compare/v3.1.27...v3.1.28)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-15 10:01:39 -05:00
Bruno Quaresma 1c5557279a feat: add footer to the login page (#1012) 2022-04-15 09:38:18 -03:00
Colin Adler 732e0f063a chore: add dependabot config for terraform examples (#1014) 2022-04-14 16:14:49 -04:00
Presley Pizzo 76f8ff9f21 feat: Add Footer to every page with nav (#1009)
* Add Footer to AuthAndNav, rename

* Fix in preferences layout

* Remove double footer
2022-04-14 13:58:53 -04:00
Presley Pizzo 82275a81c7 feat(site): Read users into basic UsersTable (#981)
* Start users

* Set up fake response

* Update handler

* Update types

* Set up page

* Start adding table

* Add header

* Add Header

* Remove roles

* Add UsersPageView

* Add test

* Lint

* Storybook error summary

* Strip Pager to just what's currently needed

* Clean up ErrorSummary while I'm here

* Storybook tweaks

* Extract language

* Lint

* Add missing $

Co-authored-by: G r e y <grey@coder.com>

* Lint

* Lint

* Fix syntax error

* Lint

Co-authored-by: G r e y <grey@coder.com>
2022-04-14 13:57:55 -04:00
Colin Adler f803e37505 chore: use workspace name as arg in coder workspaces create (#1007) 2022-04-14 17:23:20 +00:00
Kyle Carberry 7090227d38 fix: GitSSH test flake on slow CI runs (#1001)
There was a 5s timeout on the context, which was occasionally
hit during slow runs. See:

https://github.com/coder/coder/runs/6025622326?check_suite_focus=true

I also removed the AWS authentication, because it added to the test
time for key-generation and such.
2022-04-14 11:38:54 -05:00
G r e y f3f39f3770 ci: remove building from test/js (#1005)
Summary:

There's no reason to build in `test/js`, since we have e2e tests that build.

Details:

- Remove superfluous `yarn build` from `test/js` step in CI

Relates to #1004 but does not fix it.
2022-04-14 16:32:34 +00:00
G r e y 30877bb71f ci: reduce maxWorkers in jest tests (#1006)
Summary:

When `maxWorkers` is high, there's a bug in `jest` that causes OOM kills.
Unfortunately, CI is experiencing this as well as local. For now, the best solution
is just reducing `maxWorkers`.

Resolves: #1004
2022-04-14 12:23:16 -04:00
Kyle Carberry 3304db08dd fix: Agent/SessionTTY flake waiting for terminal prompt (#1002)
For an unknown reason, the prompt wouldn't appear on Windows
randomly in CI. This shouldn't be a necessary check anyways,
because terminal input will be buffered.
2022-04-14 15:55:43 +00:00
Colin Adler fed02cdcdc chore: replace cloudflare dev tunnel with frp (#867) 2022-04-14 11:29:40 -04:00
G r e y 42e9956779 feat: workspace view for schedules (#991)
Summary:

This adds the client-side implementation to match the types introduced
in #879 and #844 as well as a card in the Workspaces page to present
workspace the data.

Details:

* Added a convenient line break in the example schedule.Weekly
* Added missing `json:""` annotations in codersdk/workspaces.go
* Installed cronstrue for displaying human-friendly cron strings
* Adjusted/Added client-side types to match codersdk/workspaces.go
* Added new component WorkspaceSchedule.tsx

Next Steps:

The WorkspaceSchedule.tsx card only presents data (on purpose). In order
to make it PUT/modify data, a few changes will be made:

- a form for updating workspace schedule will be created
- the form will wrapped in a dialog or modal
- the WorkspaceSchedule card will have a way of opening the modal which
will likely be generalized up to WorkspaceSection.tsx

Impact:

This is user-facing

This does not fully resolve either #274 or #275 (I may further decompose
that work to reflect reality and keep things in small deliverable
increments), but adds significant progress towards both.
2022-04-13 20:35:47 -04:00
Garrett Delfosse 027d89dd9b chore: Add alias coder agent (#986) 2022-04-13 20:55:55 +00:00
Bruno Quaresma 300c6d0824 feat: add global notification component (#996)
* feat: add global notification component

* fix: update yarn.lock

* fix: pin @testing-library/react-hooks

* fix: update yarn.lock

* refactor: remove displayError
2022-04-13 13:34:06 -05:00
G r e y 5ecc8236b8 chore: fix storybook warnings (#989)
* chore: fix storybook deprecation warning

Removes a deprecated CLI option and uses main.js staticDirs instead.

See: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#64-deprecations

* chore: fix storybook babel warning

Resolves: #533
2022-04-13 12:03:46 -04:00
G r e y 0536a140ed chore: fix storybook fonts (#988)
Summary:

Configures storybook with MUI themes as according to their
documentation. We were previously not aligned with their example.

See: https://storybook.js.org/addons/@react-theming/storybook-addon

Details:

- configure a providerFn for MUI with CssBaseline. We were previously
missing the CssBaseline implementation, causing the inconsistency.

Impact:

Resolves inconsistency between Storybook and production. I had tested
the Tabpanel in production vs Storybook. In storybook, the font had
fallen back to Times New Roman, whereas in production it had fallen back
to Inter. This was because of CssBaseline being configured as a child of
ThemeProvider.

Resolves: #914
2022-04-13 12:03:30 -04:00
G r e y 6edd7cb036 fix: typo in create workspaces command hint (#995)
Resolves: #994
2022-04-13 15:30:58 +00:00
Steven Masley 770c567123 feat: Add RBAC package for managing user permissions (#929)
This PR adds an RBAC package for managing using permissions:
- The top-level `authz.Authorize` function is the main user-facing entrypoint to the package.
- Actual permission evaluation is handled in `policy.rego`.
- Unit tests for `authz.Authorize` are in `authz_test.go`
- Documentation for the package is in `README.md`.

Co-authored-by: Cian Johnston <cian@coder.com>
2022-04-13 08:35:35 -05:00
dependabot[bot] 103d7eab14 chore: bump @types/react from 17.0.43 to 17.0.44 in /site (#969)
Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 17.0.43 to 17.0.44.
- [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-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-12 23:45:18 -04:00
dependabot[bot] fb70b3abf3 chore: bump webpack-dev-server from 4.7.4 to 4.8.1 in /site (#970)
Bumps [webpack-dev-server](https://github.com/webpack/webpack-dev-server) from 4.7.4 to 4.8.1.
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-dev-server/compare/v4.7.4...v4.8.1)

---
updated-dependencies:
- dependency-name: webpack-dev-server
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-12 23:45:04 -04:00
dependabot[bot] ce4996668a chore: bump @types/react-dom from 17.0.14 to 17.0.15 in /site (#968)
Bumps [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) from 17.0.14 to 17.0.15.
- [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-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-12 16:37:12 -04:00
Kyle Carberry e3458277df fix: Multiple builds using the incorrect agent token (#983)
This was an issue with our in-memory database that caused
newer builds to return an outdated agent, which would then
be rejected.

A test case has been added to ensure this can't happen again!
2022-04-12 20:11:57 +00:00
Kyle Carberry e8b310166f fix: Remove resource addresses (#982)
These were added under the impression that there was significant
user-experience impact if multiple resources share the same name.

This hasn't proven to be true yet, so figured we'd take this out
until it becomes necessary.
2022-04-12 14:38:02 -05:00
Bruno Quaresma 52271ff9f8 fix: use httapi.Write instead of render (#980) 2022-04-12 16:29:07 +00:00
Garrett Delfosse d9d4599ba9 chore: idea: unify http responses further (#941) 2022-04-12 10:17:33 -05:00
Kyle Carberry 4f0f216015 ci: Add timeouts to limit hanging execution (#976)
For some reason, CI hung for ~6hours last night on `main`.

https://github.com/coder/coder/runs/5982978236?check_suite_focus=true

The fact that it went this long is bad, but it should have cancelled
much earlier.
2022-04-12 09:35:17 -05:00
Bruno Quaresma 63d1465019 feat: Add update profile endpoint (#916) 2022-04-12 14:05:21 +00:00
Kyle Carberry db9d5b7e8c fix: Rename coder to sshd on Windows for VS Code Remote support (#974)
On Windows, VS Code Remote requires a parent process of the
executing shell to be named sshd, otherwise it fails. See:
https://github.com/microsoft/vscode-remote-release/issues/5699
2022-04-11 21:14:30 -05:00
Kyle Carberry e8b1a57929 feat: Add support for VS Code and JetBrains Gateway via SSH (#956)
* Improve CLI documentation

* feat: Allow workspace resources to attach multiple agents

This enables a "kubernetes_pod" to attach multiple agents that
could be for multiple services. Each agent is required to have
a unique name, so SSH syntax is:

`coder ssh <workspace>.<agent>`

A resource can have zero agents too, they aren't required.

* Add tree view

* Improve table UI

* feat: Allow workspace resources to attach multiple agents

This enables a "kubernetes_pod" to attach multiple agents that
could be for multiple services. Each agent is required to have
a unique name, so SSH syntax is:

`coder ssh <workspace>.<agent>`

A resource can have zero agents too, they aren't required.

* Rename `tunnel` to `skip-tunnel`

This command was `true` by default, which causes
a confusing user experience.

* Add disclaimer about editing templates

* Add help to template create

* Improve workspace create flow

* Add end-to-end test for config-ssh

* Improve testing of config-ssh

* Fix workspace list

* feat: Add support for VS Code and JetBrains Gateway via SSH

This fixes various bugs that made this not work:
- Incorrect max message size in `peer`
- Incorrect reader buffer size in `peer`
- Lack of SFTP support in `agent`
- Lack of direct-tcpip support in `agent`
- Misuse of command from session. It should always use the shell
- Blocking on SSH session, only allowing one at a time

Fixes #833 too.

* Fix config-ssh command with socat
2022-04-12 00:17:18 +00:00
Kyle Carberry fb9dc4f346 feat: Improve resource preview and first-time experience (#946)
* Improve CLI documentation

* feat: Allow workspace resources to attach multiple agents

This enables a "kubernetes_pod" to attach multiple agents that
could be for multiple services. Each agent is required to have
a unique name, so SSH syntax is:

`coder ssh <workspace>.<agent>`

A resource can have zero agents too, they aren't required.

* Add tree view

* Improve table UI

* feat: Allow workspace resources to attach multiple agents

This enables a "kubernetes_pod" to attach multiple agents that
could be for multiple services. Each agent is required to have
a unique name, so SSH syntax is:

`coder ssh <workspace>.<agent>`

A resource can have zero agents too, they aren't required.

* Rename `tunnel` to `skip-tunnel`

This command was `true` by default, which causes
a confusing user experience.

* Add disclaimer about editing templates

* Add help to template create

* Improve workspace create flow

* Add end-to-end test for config-ssh

* Improve testing of config-ssh

* Fix workspace list

* Fix config ssh tests

* Update cli/configssh.go

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

* Fix requested changes

* Remove socat requirement

* Fix resources not reading in TTY

Co-authored-by: Cian Johnston <public@cianjohnston.ie>
2022-04-11 18:54:30 -05:00
Kyle Carberry 19b4323512 feat: Allow workspace resources to attach multiple agents (#942)
This enables a "kubernetes_pod" to attach multiple agents that
could be for multiple services. Each agent is required to have
a unique name, so SSH syntax is:

`coder ssh <workspace>.<agent>`

A resource can have zero agents too, they aren't required.
2022-04-11 16:06:15 -05:00
G r e y 2835bb45e5 chore: bump @testing-library/user-event from ^13.5.0 to 14.1.0 (#972) 2022-04-11 20:33:52 +00:00
dependabot[bot] c97180c18d chore: bump @xstate/react from 2.0.1 to 3.0.0 in /site (#966)
Bumps [@xstate/react](https://github.com/statelyai/xstate) from 2.0.1 to 3.0.0.
- [Release notes](https://github.com/statelyai/xstate/releases)
- [Commits](https://github.com/statelyai/xstate/compare/@xstate/react@2.0.1...@xstate/react@3.0.0)

---
updated-dependencies:
- dependency-name: "@xstate/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>
2022-04-11 16:31:50 -04:00
dependabot[bot] 3cb11fc906 chore: bump webpack from 5.71.0 to 5.72.0 in /site (#965)
Bumps [webpack](https://github.com/webpack/webpack) from 5.71.0 to 5.72.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.71.0...v5.72.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-11 16:07:57 -04:00
dependabot[bot] ffa450ddd4 chore: bump eslint from 8.12.0 to 8.13.0 in /site (#952)
* chore: bump eslint from 8.12.0 to 8.13.0 in /site

Bumps [eslint](https://github.com/eslint/eslint) from 8.12.0 to 8.13.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.12.0...v8.13.0)

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

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

* more updates

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: G r e y <grey@coder.com>
2022-04-11 16:06:41 -04:00
dependabot[bot] f7b72ddc7a chore: bump xstate from 4.30.6 to 4.31.0 in /site (#962)
Bumps [xstate](https://github.com/statelyai/xstate) from 4.30.6 to 4.31.0.
- [Release notes](https://github.com/statelyai/xstate/releases)
- [Commits](https://github.com/statelyai/xstate/compare/xstate@4.30.6...xstate@4.31.0)

---
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>
2022-04-11 15:08:30 -04:00
dependabot[bot] 0dfba86744 chore: bump @typescript-eslint/parser from 5.18.0 to 5.19.0 in /site (#960)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.18.0 to 5.19.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.19.0/packages/parser)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-11 15:07:53 -04:00
dependabot[bot] 6186594332 chore: bump @storybook/addon-actions from 6.4.20 to 6.4.21 in /site (#953)
Bumps [@storybook/addon-actions](https://github.com/storybookjs/storybook/tree/HEAD/addons/actions) from 6.4.20 to 6.4.21.
- [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/v6.4.21/addons/actions)

---
updated-dependencies:
- dependency-name: "@storybook/addon-actions"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-11 14:57:16 -04:00
dependabot[bot] a7c4c059e9 chore: bump @typescript-eslint/eslint-plugin in /site (#958)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.18.0 to 5.19.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.19.0/packages/eslint-plugin)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-11 14:52:40 -04:00
dependabot[bot] e13c38f0e4 chore: bump @storybook/addon-essentials from 6.4.19 to 6.4.21 in /site (#950)
Bumps [@storybook/addon-essentials](https://github.com/storybookjs/storybook/tree/HEAD/addons/essentials) from 6.4.19 to 6.4.21.
- [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/v6.4.21/addons/essentials)

---
updated-dependencies:
- dependency-name: "@storybook/addon-essentials"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-11 14:40:00 -04:00
G r e y 78e727a1c4 chore: consolidate js, ts/js labels (#957)
Dependabot automagically applies the `javascript` label, but we use `typescript/js` elsewhere.
2022-04-11 18:29:35 +00:00
dependabot[bot] 8c26d934b7 chore: bump eslint-plugin-jest from 26.1.3 to 26.1.4 in /site (#951)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 26.1.3 to 26.1.4.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v26.1.3...v26.1.4)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-11 14:22:22 -04:00
dependabot[bot] b3f69a8d1d chore: bump chromatic from 6.5.3 to 6.5.4 in /site (#949)
Bumps [chromatic](https://github.com/chromaui/chromatic-cli) from 6.5.3 to 6.5.4.
- [Release notes](https://github.com/chromaui/chromatic-cli/releases)
- [Changelog](https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chromaui/chromatic-cli/compare/v6.5.3...v6.5.4)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-11 14:16:38 -04:00
dependabot[bot] 99a685b7df chore: bump github.com/lib/pq from 1.10.4 to 1.10.5 (#947)
Bumps [github.com/lib/pq](https://github.com/lib/pq) from 1.10.4 to 1.10.5.
- [Release notes](https://github.com/lib/pq/releases)
- [Commits](https://github.com/lib/pq/compare/v1.10.4...v1.10.5)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-11 11:00:37 -05:00
dependabot[bot] 9474f66d27 chore: bump actions/setup-go from 2 to 3 (#948)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2...v3)

---
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>
2022-04-11 08:54:24 -05:00
Presley Pizzo 3f21ea472f feat(site): Add Admin Dropdown menu (#885)
* Start porting components for Admin menu

* More porting, wip

* Add icons

* Extract arrow components, navHeight

* Add Admin Dropdown

* Format

* Delete types

* Fix styles

* Lint

* Add stub pages

* Use navHeight constant

* Move files

* Add and organize stories

* Storybook and organize text stories

* Add test

* Lint

* Lint

* Fix double navigation

* Lint

* Wrap new routes in AuthAndNav

* Undo unrelated storybook changes

* Refactor according to conventions
2022-04-08 18:25:53 -04:00
Presley Pizzo 4c1ef38280 chore: remove CodeCov annotations (#928)
* chore: remove CodeCov annotations

* Format
2022-04-08 15:57:28 -04:00
G r e y 0a2903c5c5 chore: assign soft ownership for xServices (#932) 2022-04-08 15:17:24 -04:00
Bruno Quaresma b317f9a83a fix: preferences routing and dropdown positioning (#930)
* fix: preferences routing

* fix: Fix popover miss correct position
2022-04-08 14:58:51 -04:00
Bruno Quaresma cbd1c3e0be fix: Remove excessive margin on the right (#931) 2022-04-08 17:45:20 +00:00
Kyle Carberry 35a0acc9c6 fix: Disable Terraform plugin cache on Darwin (#927)
It was occasionally failing without any clear indication of
what to fix on our side. The plugins weren't being found
by Terraform.

We already disable this on Windows, so figured it's fine on
Darwin too considering most production deployments will be Linux.
2022-04-08 12:30:31 -05:00
Cian Johnston 53db17803a feat: cli: add autostart and autostop commands (#922)
* feat: cli: add autostart and autostop commands

* fix: autostart/autostop: add help and usage, hide for now
2022-04-08 16:29:07 +00:00
Kyle Carberry cb5b228a21 fix: Disable raw using confirm prompt on Darwin (#926)
This caused cancel errors on prompt, but would have caused incorrect
content in parameter values if it surfaced.

Fixes #915.
2022-04-08 11:25:19 -05:00
Presley Pizzo 0bf9dee7e3 chore(site): rename userXService to authXService (#924)
* chore(site): rename userXService to authXService

* Rename contents of xService
2022-04-08 11:42:57 -04:00
Cian Johnston 94ab6f3d8e feat: add debug-level request logging (#923)
This commit adds a small middleware to coderd that logs all requests at DEBUG level.
2022-04-08 14:35:29 +00:00
Garrett Delfosse 38f074254b feat: wrap ssh with coder key (#894) 2022-04-07 22:40:27 +00:00
Ben Potter b7d7e19606 fix: rename projects to templates in README (#920) 2022-04-07 17:58:17 -04:00
Ben Potter c6a0078c35 fix: assign labels for issue templates (#919) 2022-04-07 21:04:56 +00:00
Bruno Quaresma 75ef1f4b26 feat: Add preferences pages (#893) 2022-04-07 16:44:08 -03:00
Joe Previte 17848b3b86 chore: add feature request issue template (#913)
* chore: add feature request issue template

* Update .github/ISSUE_TEMPLATE/feature.md

Co-authored-by: G r e y <grey@coder.com>

* Update .github/ISSUE_TEMPLATE/feature.md

Co-authored-by: G r e y <grey@coder.com>

Co-authored-by: G r e y <grey@coder.com>
2022-04-07 10:35:32 -07:00
Asher 18595791c0 feat: add version to footer (#882)
* Add endpoint for getting build info

* Add build info XService

* Add version with link to page footer

Partially addresses #376.

* Lift buildinfo package
2022-04-07 12:18:58 -05:00
dependabot[bot] 2e5859f226 chore: bump codecov/codecov-action from 2 to 3 (#898)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v2...v3)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-07 11:41:35 -05:00
dependabot[bot] 313b51d3fb chore: bump @xstate/cli from 0.1.5 to 0.1.6 in /site (#900)
Bumps @xstate/cli from 0.1.5 to 0.1.6.

---
updated-dependencies:
- dependency-name: "@xstate/cli"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-07 12:08:17 -04:00
Bruno Quaresma 90388a38f3 feat: Add user menu (#887) 2022-04-07 13:00:40 -03:00
dependabot[bot] 2ca725386f chore: bump @typescript-eslint/parser from 5.17.0 to 5.18.0 in /site (#899)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.17.0 to 5.18.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.18.0/packages/parser)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-07 11:34:59 -04:00
Joe Previte ce7af872ff docs: add PR template (#873) 2022-04-07 15:27:25 +00:00
Joe Previte 14dec177a4 docs: add SECURITY policy (#891) 2022-04-07 15:26:10 +00:00
Kyle Carberry 770d212094 ci: Enable forks to run CI (#910)
* ci: Enable forks to run CI

All steps that require tokens are optional for forks,
and will be skipped if the owner is not "coder".

* Empty commit to force CI
2022-04-07 08:33:10 -05:00
Cian Johnston 23f989127d coderd: autostart: codersdk, http api, database plumbing (#879)
* feat: add columns autostart_schedule, autostop_schedule to database schema
* feat: database: add UpdateWorkspaceAutostart and UpdateWorkspaceAutostop methods
* feat: add AutostartSchedule/AutostopSchedule to api workspace struct
* feat: codersdk: implement update workspace autostart and autostop methods
* chore: add unit tests for workspace autostarat and autostop methods
2022-04-07 10:03:35 +01:00
dependabot[bot] c1ff537beb chore: bump @typescript-eslint/eslint-plugin in /site (#902)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.17.0 to 5.18.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.18.0/packages/eslint-plugin)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-06 19:08:34 -04:00
G r e y 579fd4bc89 chore: speed up chromatic ci (#904)
This is an oversight from #896 . It turns out that because we use the GitHub integration with Chromatic, we don't need to wait for the results to be reported in the action - they get reported in the other checks created by Chromatic.

This option was spit-out in a check:

https://github.com/coder/coder/runs/5859427236?check_suite_focus=true#step:4:38

Relates to #444
2022-04-06 22:40:30 +00:00
dependabot[bot] 6d40f34057 chore: bump eslint-plugin-import from 2.25.4 to 2.26.0 in /site (#901)
Bumps [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) from 2.25.4 to 2.26.0.
- [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.25.4...v2.26.0)

---
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>
2022-04-06 18:22:15 -04:00
dependabot[bot] 1224a34abd chore: bump jest-junit from 13.0.0 to 13.1.0 in /site (#903)
Bumps [jest-junit](https://github.com/jest-community/jest-junit) from 13.0.0 to 13.1.0.
- [Release notes](https://github.com/jest-community/jest-junit/releases)
- [Commits](https://github.com/jest-community/jest-junit/compare/v13.0.0...v13.1.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-06 18:20:51 -04:00
G r e y 5782879f2f chore: configure chromatic snapshot tests (#896)
Resolves: #444

Summary:

This commit installs and configures a GH action for chromatic. Chromatic
is used for snapshot testing build-over-build.

Details:

* chore: install chromatic

* chore: add chromatic package.json script

Suggested by the docs for convenience so that we can run chromatic like:

```console
yarn run chromatic ...
```

* chore: gitignore storybook builds

* ci: configure chromatic

This action configures chromatic to run in CI on pushes to all branches.
By running this in CI, we get the following:

- snapshot (build-over-build)
- checks in our CI

The snapshots and build-over-build behavior are per branch; this way we
can work on a feature branch without worrying about changes being made
to mainline independently.

* chore: remove manual storybook build from CI

This is now the responsibility of Chromatic
2022-04-06 17:51:49 -04:00
Joe Previte eefca43064 chore: rename .yaml to .yml (#895)
* chore: rename .yml to .yaml

* chore: remove .yml from prettierrc
2022-04-06 21:32:59 +00:00
Asher fe23dcd3fc feat: add top-level nav styles (#883)
Partially addresses #701.
2022-04-06 13:12:37 -05:00
Joe Previte 8813788c28 chore: add GitHub issue templates (#889) 2022-04-06 10:59:22 -07:00
Kyle Carberry 02ad3f14f5 chore: Rename Projects to Templates (#880)
Customer feedback indicated projects was a confusing name.
After querying the team internally, it seemed unanimous
that it is indeed a confusing name.

Here's for a lil less confusion @ashmeer7 🥂
2022-04-06 12:42:40 -05:00
Joe Previte 584c8b4fc3 docs: move development workflow to CONTRIBUTING (#890) 2022-04-06 10:26:17 -07:00
Joe Previte dc55e3525c docs: add CODE_OF_CONDUCT (#888) 2022-04-06 10:00:45 -07:00
Garrett Delfosse 32759a8714 fix: trim scope of agent private key route (#886) 2022-04-06 14:54:13 +00:00
Garrett Delfosse 9da17be61e feat: Add user scoped git ssh keys (#834) 2022-04-06 00:18:26 +00:00
Kyle Carberry 1e9e5f7c76 chore: Add contributing guidelines (#874)
It's helpful for us Coders to align on a common set of style
guidelines. While I'd prefer to automate this, documentation
should get us a lot of the way there!

Please review these thoroughly, as PRs will be checked against it
after merge.
2022-04-05 15:02:28 -05:00
Bruno Quaresma abddd64497 feat: Add sidebar and panel (#866)
* feat: Add sidebar and panel

* fix: fix sidebar values
2022-04-05 14:01:45 -03:00
Bruno Quaresma abf6934ebb feat: Add Section component (#863)
* feat: Add Section component

* fix: add Section.Action example
2022-04-05 14:01:21 -03:00
dependabot[bot] 6b034eced3 chore: bump eslint-import-resolver-typescript in /site (#845)
Bumps [eslint-import-resolver-typescript](https://github.com/alexgorbatchev/eslint-import-resolver-typescript) from 2.7.0 to 2.7.1.
- [Release notes](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/releases)
- [Changelog](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/blob/master/CHANGELOG.md)
- [Commits](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/compare/v2.7.0...v2.7.1)

---
updated-dependencies:
- dependency-name: eslint-import-resolver-typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-05 11:47:59 -04:00
dependabot[bot] 29fffbe13d chore: bump @storybook/addon-links from 6.4.19 to 6.4.20 in /site (#809)
Bumps [@storybook/addon-links](https://github.com/storybookjs/storybook/tree/HEAD/addons/links) from 6.4.19 to 6.4.20.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.4.20/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.4.20/addons/links)

---
updated-dependencies:
- dependency-name: "@storybook/addon-links"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-05 11:16:49 -04:00
G r e y c0a9eaca56 chore(site): organize imports (#876) 2022-04-05 10:27:41 -04:00
Cian Johnston 2f1fa153cd fix: coderd/autostart/schedule: rename misnamed file 2022-04-05 14:09:15 +01:00
Kyle Carberry 63916b6680 fix: Use docs/README.md in deploy (#875)
The release build should probably dry-run in CI,
but it's rare for files like README.md to move
so we can punt that to the future!
2022-04-04 20:43:12 -05:00
Kyle Carberry 5ae71f0958 feat: Add buildinfo package to embed version (#840)
This also resolves build time and commit hash using the
Go 1.18 debug/buildinfo package. An external URL is outputted
on running version as well to easily route the caller to a
release or commit.
2022-04-05 01:35:03 +00:00
Presley Pizzo d4e26ff8c2 chore(site): Add XState inspector (#872)
* Use XState inspector in dev mode

* Add new env var

* Lint
2022-04-04 19:54:41 -04:00
Joe Previte f02b8fda9e docs(README): move to /docs folder (#871) 2022-04-04 15:48:22 -07:00
Kyle Carberry 31536186f7 feat: Add rate-limits to the API (#848)
Closes #285.
2022-04-04 17:32:05 -05:00
G r e y 473aa6bd3a refactor(site): webpack configuration (#870)
This refactor introduces the following changes:

* re-order and re-comment items to match v1
* add EnvironmentPlugin for environment variables
* remove target (unnecessary, we will use browserslist)
2022-04-04 18:28:37 -04:00
Presley Pizzo 63b400627b chore(site): fix typegen usage (#868) 2022-04-04 18:02:27 -04:00
Cian Johnston 8a1ae18ede feat: add crontab package for supporting autostart/stop. (#844)
* feat: add crontab package for supporting autostart/stop.
This is basically a small wrapper around robfig/cron/v3.

Fixes #817.

* fixup! feat: add crontab package for supporting autostart/stop. This is basically a small wrapper around robfig/cron/v3.

* fixup! feat: add crontab package for supporting autostart/stop. This is basically a small wrapper around robfig/cron/v3.

* fixup! fixup! feat: add crontab package for supporting autostart/stop. This is basically a small wrapper around robfig/cron/v3.

* fix: return struct instead of interface

* remove unnecessary interface and export struct

* fix: doc comments

* rename package to autostart/schedule

* address PR comments
2022-04-04 21:34:11 +01:00
Colin Adler b621c59a03 fix: update models.go in generate.go (#865) 2022-04-04 19:53:04 +00:00
Colin Adler e0eae49f52 fix: update querier.go in generate.sh (#864)
I accidentally forgot to copy this out.
2022-04-04 19:21:48 +00:00
G r e y fb4cab78e0 chore: fix site codeowners (#862) 2022-04-04 18:53:51 +00:00
Kyle Carberry 7833c24779 chore: Add license (#841) 2022-04-04 11:55:06 -05:00
Steven Masley 4dd3c57f6e chore: Remove varnamelen linter (#854)
* chore: remove varnamelen from linting

https://github.com/golang/go/wiki/CodeReviewComments#variable-names
2022-04-04 11:17:57 -05:00
Kyle Carberry f2a21267b9 test: Fix ProjectVersionLogs returning error when using DB (#852)
This didn't actually effect the test value, since we're just looking for
logs. It did produce spam in the logs though, and could be interpreted
as a failure.
2022-04-04 10:03:29 -05:00
G r e y c2a025d0d7 chore: configure dependabot to trigger weekly (#849) 2022-04-04 14:40:35 +00:00
dependabot[bot] 8e56830d15 chore: bump @pmmmwh/react-refresh-webpack-plugin in /site (#847)
Bumps [@pmmmwh/react-refresh-webpack-plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) from 0.5.4 to 0.5.5.
- [Release notes](https://github.com/pmmmwh/react-refresh-webpack-plugin/releases)
- [Changelog](https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pmmmwh/react-refresh-webpack-plugin/compare/v0.5.4...v0.5.5)

---
updated-dependencies:
- dependency-name: "@pmmmwh/react-refresh-webpack-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-04 13:59:06 +00:00
dependabot[bot] 1cc0a7284c chore: bump prettier from 2.6.1 to 2.6.2 in /site (#846)
Bumps [prettier](https://github.com/prettier/prettier) from 2.6.1 to 2.6.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.6.1...2.6.2)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-04 08:50:03 -05:00
dependabot[bot] 315676b7bb chore: bump @storybook/addon-actions from 6.4.19 to 6.4.20 in /site (#821)
Bumps [@storybook/addon-actions](https://github.com/storybookjs/storybook/tree/HEAD/addons/actions) from 6.4.19 to 6.4.20.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.4.20/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.4.20/addons/actions)

---
updated-dependencies:
- dependency-name: "@storybook/addon-actions"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-03 17:39:15 -05:00
dependabot[bot] 081d43ed61 chore: bump @playwright/test from 1.20.1 to 1.20.2 in /site (#838)
Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.20.1 to 1.20.2.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.20.1...v1.20.2)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-03 17:38:30 -05:00
Kyle Carberry ccba2ba99d fix: Remove line length limit on MacOS for input prompts (#839)
This caused inputs to be truncated on MacOS terminals.
2022-04-03 18:09:55 +00:00
Colin Adler 2a7ab08bab fix: use golang.org/x/term instead of golang.org/x/crypto/ssh/terminal (#837)
The latter is deprecated: https://pkg.go.dev/golang.org/x/crypto/ssh/terminal
2022-04-01 21:25:46 +00:00
dependabot[bot] e9027b9717 chore: bump webpack from 5.70.0 to 5.71.0 in /site (#835)
Bumps [webpack](https://github.com/webpack/webpack) from 5.70.0 to 5.71.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.70.0...v5.71.0)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-01 21:21:36 +00:00
dependabot[bot] 84ede1c832 chore: bump @storybook/react from 6.4.19 to 6.4.20 in /site (#810)
Bumps [@storybook/react](https://github.com/storybookjs/storybook/tree/HEAD/app/react) from 6.4.19 to 6.4.20.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/v6.4.20/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v6.4.20/app/react)

---
updated-dependencies:
- dependency-name: "@storybook/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-01 16:11:01 -05:00
dependabot[bot] fbcdd92fbc chore: bump react-router-dom from 6.2.2 to 6.3.0 in /site (#811)
Bumps [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) from 6.2.2 to 6.3.0.
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Commits](https://github.com/remix-run/react-router/commits/v6.3.0/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>
2022-04-01 16:10:48 -05:00
Colin Adler fd523100bf chore: split queries.sql into files by table (#762) 2022-04-01 15:45:23 -05:00
Colin Adler 2b1a0ee126 chore: update v1 schema (#643) 2022-04-01 14:42:36 -05:00
Kyle Carberry cbb82ce017 fix: Build Windows releases with zip archives (#823)
A much better UX for our Windows folk!
2022-04-01 19:36:56 +00:00
Ben Potter efec029675 chore(com): add docs for "coder projects update" (#732) 2022-04-01 13:48:45 -05:00
dependabot[bot] 0eacde79b1 chore: bump @typescript-eslint/eslint-plugin in /site (#638)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.16.0 to 5.17.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.17.0/packages/eslint-plugin)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-01 13:48:20 -05:00
Colin Adler dc46ff407b fix: ensure websocket close messages are truncated to 123 bytes (#779)
It's possible for websocket close messages to be too long, which cause
them to silently fail without a proper close message. See error below:

```
2022-03-31 17:08:34.862 [INFO]	(stdlib)	<close_notjs.go:72>	"2022/03/31 17:08:34 websocket: failed to marshal close frame: reason string max is 123 but got \"insert provisioner daemon:Cannot encode []database.ProvisionerType into oid 19098 - []database.ProvisionerType must implement Encoder or be converted to a string\" with length 161"
```
2022-04-01 18:17:45 +00:00
Presley Pizzo 4601a35c01 bugfix: remove call to deleted function from develop script (#800) 2022-04-01 08:54:55 -04:00
5726 changed files with 234007 additions and 30546 deletions
+83
View File
@@ -0,0 +1,83 @@
FROM ubuntu
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV EDITOR=vim
RUN apt-get update && apt-get upgrade --yes
RUN apt-get install --yes \
ca-certificates \
bash-completion \
build-essential \
curl \
cmake \
direnv \
emacs-nox \
gnupg \
htop \
jq \
less \
lsb-release \
lsof \
man-db \
nano \
neovim \
ssl-cert \
sudo \
unzip \
xz-utils \
zip
# configure locales to UTF8
RUN apt-get install locales && locale-gen en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
# configure direnv
RUN direnv hook bash >> $HOME/.bashrc
# install nix
RUN sh <(curl -L https://nixos.org/nix/install) --daemon
RUN mkdir -p $HOME/.config/nix $HOME/.config/nixpkgs \
&& echo 'sandbox = false' >> $HOME/.config/nix/nix.conf \
&& echo '{ allowUnfree = true; }' >> $HOME/.config/nixpkgs/config.nix \
&& echo '. $HOME/.nix-profile/etc/profile.d/nix.sh' >> $HOME/.bashrc
# install docker and configure daemon to use vfs as GitHub codespaces requires vfs
# https://github.com/moby/moby/issues/13742#issuecomment-725197223
RUN mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
&& echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null \
&& apt-get update \
&& apt-get install --yes docker-ce docker-ce-cli containerd.io docker-compose-plugin \
&& mkdir -p /etc/docker \
&& echo '{"cgroup-parent":"/actions_job","storage-driver":"vfs"}' >> /etc/docker/daemon.json
# install golang and language tooling
ENV GO_VERSION=1.19
ENV GOPATH=$HOME/go-packages
ENV GOROOT=$HOME/go
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH
RUN curl -fsSL https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz | tar xzs
RUN echo 'export PATH=$GOPATH/bin:$PATH' >> $HOME/.bashrc
RUN bash -c ". $HOME/.bashrc \
go install -v golang.org/x/tools/gopls@latest \
&& go install -v mvdan.cc/sh/v3/cmd/shfmt@latest \
&& go install -v github.com/mikefarah/yq/v4@v4.30.6 \
"
# install nodejs
RUN bash -c "$(curl -fsSL https://deb.nodesource.com/setup_14.x)" \
&& apt-get install -y nodejs
# install zstd
RUN bash -c "$(curl -fsSL https://raw.githubusercontent.com/horta/zstd.install/main/install)"
# install nfpm
RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list \
&& apt update \
&& apt install nfpm
+24
View File
@@ -0,0 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json
{
"name": "Development environments on your infrastructure",
// Sets the run context to one level up instead of the .devcontainer folder.
"context": ".",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "Dockerfile",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
"postStartCommand": "dockerd",
// privileged is required by GitHub codespaces - https://github.com/microsoft/vscode-dev-containers/issues/727
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--privileged",
"--init"
]
}
+16
View File
@@ -0,0 +1,16 @@
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
[*.{md,json,yaml,yml,tf,tfvars,nix}]
indent_style = space
indent_size = 2
[coderd/database/dump.sql]
indent_style = space
indent_size = 4
+4
View File
@@ -3,3 +3,7 @@ coderd/database/dump.sql linguist-generated=true
peerbroker/proto/*.go linguist-generated=true
provisionerd/proto/*.go linguist-generated=true
provisionersdk/proto/*.go linguist-generated=true
*.tfplan.json linguist-generated=true
*.tfstate.json linguist-generated=true
*.tfstate.dot linguist-generated=true
*.tfplan.dot linguist-generated=true
+4 -1
View File
@@ -1 +1,4 @@
site @coder/coder-frontend
site/ @coder/frontend
docs/ @coder/docs
README.md @coder/docs
ADOPTERS.md @coder/docs
+17 -14
View File
@@ -1,31 +1,30 @@
codecov:
require_ci_to_pass: false
notify:
after_n_builds: 5
comment:
show_carryforward_flags: yes
comment: false
github_checks:
annotations: false
coverage:
notify:
slack:
default:
url: secret:v1::ALa1/e2X+k36fPseab5D7+kBFc9bJyIoIQioD0IMA5jr+0HXVpBRNDCHZhHjCdGc67yff6PPixPEOLwEZpxC37rM23RBZOYlqAq9A5e0MeZVlEoVq19aOYN4Xel17hMJ6GGm7n17wrYpCpcvlVSqNrN0+cr3guVDyG10kQyfh2Y=
threshold: 1%
only_pulls: false
branches:
- "main"
range: 50..75
round: down
precision: 2
status:
patch:
default:
informational: yes
project:
default:
target: 70%
informational: yes
target: 65%
informational: true
ignore:
# This is generated code.
- coderd/database/models.go
- coderd/database/query.sql.go
- coderd/database/queries.sql.go
- coderd/database/databasefake
# These are generated or don't require tests.
- cmd
@@ -35,6 +34,10 @@ ignore:
- peerbroker/proto
- provisionerd/proto
- provisionersdk/proto
- scripts/datadog-cireport
- scripts
- site/.storybook
- rules.go
# Packages used for writing tests.
- cli/clitest
- coderd/coderdtest
- pty/ptytest
@@ -3,9 +3,10 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"
time: "06:00"
timezone: "America/Chicago"
labels: []
commit-message:
prefix: "chore"
ignore:
@@ -27,23 +28,47 @@ updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
interval: "monthly"
time: "06:00"
timezone: "America/Chicago"
commit-message:
prefix: "chore"
labels: []
ignore:
# Ignore patch updates for all dependencies
- dependency-name: "*"
update-types:
- version-update:semver-patch
- package-ecosystem: "npm"
directory: "/site/"
schedule:
interval: "daily"
interval: "monthly"
time: "06:00"
timezone: "America/Chicago"
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
- package-ecosystem: "terraform"
directory: "/examples/templates"
schedule:
interval: "monthly"
time: "06:00"
timezone: "America/Chicago"
commit-message:
prefix: "chore"
labels: []
ignore:
# We likely want to update this ourselves.
- dependency-name: "coder/coder"
+3
View File
@@ -0,0 +1,3 @@
<!--
Check if your change requires documentation edits before merging: https://coder.com/docs/coder. Make edits in `docs/`.
-->
-60
View File
@@ -1,60 +0,0 @@
###############################################################################
# This file configures "Semantic Pull Requests", which is documented here:
# https://github.com/zeke/semantic-pull-requests
#
# This action/spec implements the "Conventional Commits" RFC which is
# available here:
# https://www.notion.so/coderhq/Conventional-commits-1d51287f58b64026bb29393f277734ed
###############################################################################
# We have no valid scopes right now.
# A scope should be added when commits aren't aligning with associated change anymore.
scopes:
# We only check that the PR title is semantic. The PR title is automatically
# applied to the "Squash & Merge" flow as the suggested commit message, so this
# should suffice unless someone drastically alters the message in that flow.
titleOnly: true
# Types are the 'tag' types in a commit or PR title. For example, in
#
# chore: fix thing
#
# 'chore' is the type.
types:
# A build of any kind.
- build
# A RELEASED fix that will NOT be back-ported. The originating issue may have
# been discovered internally or externally to Coder.
- fix
# Any code task that is ignored for changelog purposes. Examples include
# devbin scripts and internal-only configurations.
- chore
# Any work performed on CI.
- ci
# An UNRELEASED correction. For example, features are often built
# incrementally and sometimes introduce minor flaws during a release cycle.
# Corrections address those increments and flaws.
- correct
# Work that directly implements or supports the implementation of a feature.
- feat
# A fix for a RELEASED bug (regression fix) that is intended for patch-release
# purposes.
- hotfix
# A refactor changes code structure without any behavioral change.
- refactor
# A git revert for any style of commit.
- revert
# Adding tests of any kind. Should be separate from feature or fix
# implementations. For example, if a commit adds a fix + test, it's a fix
# commit. If a commit is simply bumping coverage, it's a test commit.
- test
-14
View File
@@ -1,14 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 14
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 5
# Only apply the stale logic to pulls, since we are using issues to manage work
only: pulls
# Label to apply when stale.
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no activity occurs in the next 5 days.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
+26
View File
@@ -0,0 +1,26 @@
name: "CLA Assistant"
on:
issue_comment:
types: [created]
pull_request_target:
types: [opened, closed, synchronize]
jobs:
CLAssistant:
runs-on: ubuntu-latest
steps:
- name: "CLA Assistant"
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
PERSONAL_ACCESS_TOKEN: ${{ secrets.CDRCOMMUNITY_GITHUB_TOKEN }}
with:
remote-organization-name: "coder"
remote-repository-name: "cla"
path-to-signatures: "v2022-09-04/signatures.json"
path-to-document: "https://github.com/coder/cla/blob/main/README.md"
# branch should not be protected
branch: "main"
allowlist: dependabot*
+67
View File
@@ -0,0 +1,67 @@
name: "CodeQL"
permissions:
security-events: write
on:
push:
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["main"]
schedule:
# run every week at 10:24 on Thursday
- cron: "24 10 * * 4"
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ["go", "javascript"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Setup Go
if: matrix.language == 'go'
uses: actions/setup-go@v3
with:
go-version: "~1.19"
- name: Go Cache Paths
if: matrix.language == 'go'
id: go-cache-paths
run: |
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Mod Cache
if: matrix.language == 'go'
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
- name: Remove Makefile # workaround to prevent CodeQL from building site
if: matrix.language == 'go'
run: |
# Disable Analysis step from trying to build the project.
rm Makefile
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
@@ -1,98 +0,0 @@
# This workflow (aka The Gauntlet) is a high-iteration run of our tests,
# used to evaluate stability and shake out intermittent failures.
name: coder-test-stability
on:
schedule:
# Run everyday around midnight Central.
- cron: "0 6 * * *"
pull_request:
branches:
- main
paths:
- .github/workflows/coder-test-stability.yaml
workflow_dispatch:
inputs:
iterationCount:
description: "Iteration Count"
required: false
default: "10"
# Cancel in-progress runs for pull requests when developers push
# additional changes, and serialize builds in branches.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
coder-test-stability:
name: "test/go/stability/${{ matrix.os }}/${{ matrix.instance }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-2022
instance:
- 1
- 2
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version: "~1.18"
- uses: actions/cache@v3
with:
# Go mod cache, Linux build cache, Mac build cache, Windows build cache
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.os }}-go-
- run: go install gotest.tools/gotestsum@latest
- uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.1.2
terraform_wrapper: false
- name: Test with Mock Database
shell: bash
env:
GOCOUNT: ${{ github.event.inputs.iterationCount || 10 }}
GOMAXPROCS: ${{ runner.os == 'Windows' && 1 || 2 }}
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage"
-timeout=15m -count=$GOCOUNT -race -short -failfast
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: fake
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go gotests.xml
- name: Test with PostgreSQL Database
if: runner.os == 'Linux'
env:
GOCOUNT: ${{ github.event.inputs.iterationCount || 10 }}
run: DB=true gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage" -timeout=30m
-count=$GOCOUNT -race -parallel=2 -failfast
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: postgresql
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go gotests.xml
+433 -170
View File
@@ -4,13 +4,8 @@ on:
push:
branches:
- main
- "release/*"
tags:
- "*"
pull_request:
branches:
- "*"
workflow_dispatch:
@@ -33,21 +28,103 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
typos:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: typos-action
uses: crate-ci/typos@v1.13.3
with:
config: .github/workflows/typos.toml
- name: Fix Helper
if: ${{ failure() }}
run: |
echo "::notice:: you can automatically fix typos from your CLI:
cargo install typos-cli
typos -c .github/workflows/typos.toml -w"
changes:
runs-on: ubuntu-latest
outputs:
docs-only: ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }}
sh: ${{ steps.filter.outputs.sh }}
ts: ${{ steps.filter.outputs.ts }}
k8s: ${{ steps.filter.outputs.k8s }}
steps:
- uses: actions/checkout@v3
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
all:
- '**'
docs:
- 'docs/**'
# For testing:
# - '.github/**'
sh:
- "**.sh"
ts:
- 'site/**'
k8s:
- 'helm/**'
- Dockerfile
- scripts/helm.sh
- id: debug
run: |
echo "${{ toJSON(steps.filter )}}"
# Debug step
debug-inputs:
needs:
- changes
runs-on: ubuntu-latest
steps:
- id: log
run: |
echo "${{ toJSON(needs) }}"
style-lint-golangci:
name: style/lint/golangci
timeout-minutes: 5
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "~1.19"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.3.1
with:
version: v1.48.0
check-enterprise-imports:
name: check/enterprise-imports
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
- name: Check imports of enterprise code
run: ./scripts/check_enterprise_imports.sh
style-lint-shellcheck:
name: style/lint/shellcheck
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@1.1.0
env:
SHELLCHECK_OPTS: --external-sources
with:
go-version: "~1.18"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.1.0
with:
version: v1.45.2
ignore: node_modules
style-lint-typescript:
name: "style/lint/typescript"
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
@@ -71,30 +148,105 @@ jobs:
run: yarn lint
working-directory: site
gen:
name: "style/gen"
style-lint-k8s:
name: "style/lint/k8s"
timeout-minutes: 5
needs: changes
if: needs.changes.outputs.k8s == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: "3.19.4"
- uses: actions/setup-go@v2
with:
go-version: "~1.18"
- run: curl -sSL
https://github.com/kyleconroy/sqlc/releases/download/v1.11.0/sqlc_1.11.0_linux_amd64.tar.gz
| sudo tar -C /usr/bin -xz sqlc
- name: Checkout
uses: actions/checkout@v3
- run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
- run: go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.26
- run: "make --output-sync -j gen"
- run: ./scripts/check_unstaged.sh
- name: Install helm
uses: azure/setup-helm@v3
with:
version: v3.9.2
- name: cd helm && make lint
run: |
cd helm
make lint
gen:
name: "style/gen"
timeout-minutes: 8
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
needs: changes
if: needs.changes.outputs.docs-only == 'false'
steps:
- uses: actions/checkout@v3
- name: Cache Node
id: cache-node
uses: actions/cache@v3
with:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
- name: Install node_modules
run: ./scripts/yarn_install.sh
- uses: actions/setup-go@v3
with:
go-version: "~1.19"
- name: Echo Go Cache Paths
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ github.job }}-go-build-${{ hashFiles('**/go.sum', '**/**.go') }}
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ github.job }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Install sqlc
run: |
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.13.0/sqlc_1.13.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc
- name: Install protoc-gen-go
run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
- name: Install protoc-gen-go-drpc
run: go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.26
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Install yq
run: go run github.com/mikefarah/yq/v4@v4.30.6
- name: Install Protoc
run: |
# protoc must be in lockstep with our dogfood Dockerfile
# or the version in the comments will differ.
set -x
cd dogfood
DOCKER_BUILDKIT=1 docker build . --target proto -t protoc
protoc_path=/usr/local/bin/protoc
docker run --rm --entrypoint cat protoc /tmp/bin/protoc > $protoc_path
chmod +x $protoc_path
protoc --version
- name: make gen
run: "make --output-sync -j -B gen"
- name: Check for unstaged files
run: ./scripts/check_unstaged.sh
style-fmt:
name: "style/fmt"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
@@ -116,12 +268,21 @@ jobs:
- name: Install node_modules
run: ./scripts/yarn_install.sh
- name: "make fmt"
run: "make --output-sync -j fmt"
- name: Install shfmt
run: go install mvdan.cc/sh/v3/cmd/shfmt@v3.5.0
- name: make fmt
run: |
export PATH=${PATH}:$(go env GOPATH)/bin
make --output-sync -j -B fmt
- name: Check for unstaged files
run: ./scripts/check_unstaged.sh
test-go:
name: "test/go"
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-8-cores'|| matrix.os }}
timeout-minutes: 20
strategy:
matrix:
os:
@@ -131,9 +292,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
go-version: "~1.19"
- name: Echo Go Cache Paths
id: go-cache-paths
@@ -145,7 +306,7 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go') }}
- name: Go Mod Cache
uses: actions/cache@v3
@@ -153,55 +314,90 @@ jobs:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Install goreleaser
uses: jaxxstorm/action-install-gh-release@v1.4.0
- name: Install gotestsum
uses: jaxxstorm/action-install-gh-release@v1.9.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repo: gotestyourself/gotestsum
tag: v1.7.0
tag: v1.8.2
- uses: hashicorp/setup-terraform@v1
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.2
terraform_version: 1.1.9
terraform_wrapper: false
- name: Test with Mock Database
id: test
shell: bash
env:
GOCOUNT: ${{ runner.os == 'Windows' && 1 || 2 }}
GOMAXPROCS: ${{ runner.os == 'Windows' && 1 || 2 }}
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage"
-coverpkg=./...,github.com/coder/coder/codersdk
-timeout=3m -count=$GOCOUNT -short -failfast
run: |
# Code coverage is more computationally expensive and also
# prevents test caching, so we disable it on alternate operating
# systems.
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
echo ::set-output name=cover::true
export COVERAGE_FLAGS='-covermode=atomic -coverprofile="gotests.coverage" -coverpkg=./...'
else
echo ::set-output name=cover::false
fi
set +e
gotestsum --junitfile="gotests.xml" --jsonfile="gotestsum.json" --packages="./..." --debug -- -parallel=8 -timeout=5m -short -failfast $COVERAGE_FLAGS
ret=$?
if ((ret)); then
# Eternalize test timeout logs because "re-run failed" erases
# artifacts and gotestsum doesn't always capture it:
# https://github.com/gotestyourself/gotestsum/issues/292
# Multiple test packages could've failed, each one may or may
# not run into the edge case. PS. Don't summon ShellCheck here.
for testWithStack in $(grep 'panic: test timed out' gotestsum.json | grep -E -o '("Test":[^,}]*)'); do
if [ -n "$testWithStack" ] && grep -q "${testWithStack}.*PASS" gotestsum.json; then
echo "Conditions met for gotestsum stack trace missing bug, outputting panic trace:"
grep -A 999999 "${testWithStack}.*panic: test timed out" gotestsum.json
fi
done
fi
exit $ret
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: fake
DD_CATEGORY: unit
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go gotests.xml
- uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: gotestsum-debug-${{ matrix.os }}.json
path: ./gotestsum.json
retention-days: 7
- uses: codecov/codecov-action@v2
if: github.actor != 'dependabot[bot]'
- uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: gotests-${{ matrix.os }}.xml
path: ./gotests.xml
retention-days: 30
- uses: codecov/codecov-action@v3
# This action has a tendency to error out unexpectedly, it has
# the `fail_ci_if_error` option that defaults to `false`, but
# that is no guarantee, see:
# https://github.com/codecov/codecov-action/issues/788
continue-on-error: true
if: steps.test.outputs.cover && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./gotests.coverage
flags: unittest-go-${{ matrix.os }}
fail_ci_if_error: true
test-go-postgres:
name: "test/go/postgres"
runs-on: ubuntu-latest
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
# This timeout must be greater than the timeout set by `go test` in
# `make test-postgres` to ensure we receive a trace of running
# goroutines. Setting this to the timeout +5m should work quite well
# even if some of the preceding steps are slow.
timeout-minutes: 25
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
go-version: "~1.19"
- name: Echo Go Cache Paths
id: go-cache-paths
@@ -213,7 +409,7 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum', '**/**.go') }}
- name: Go Mod Cache
uses: actions/cache@v3
@@ -221,85 +417,93 @@ jobs:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Install goreleaser
uses: jaxxstorm/action-install-gh-release@v1.4.0
- name: Install gotestsum
uses: jaxxstorm/action-install-gh-release@v1.9.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repo: gotestyourself/gotestsum
tag: v1.7.0
tag: v1.8.2
- uses: hashicorp/setup-terraform@v1
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.2
terraform_version: 1.1.9
terraform_wrapper: false
- name: Start PostgreSQL Database
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
PGDATA: /tmp
run: |
docker run \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_DB=postgres \
-e PGDATA=/tmp \
-p 5432:5432 \
-d postgres:11 \
-c shared_buffers=1GB \
-c max_connections=1000
while ! pg_isready -h 127.0.0.1
do
echo "$(date) - waiting for database to start"
sleep 0.5
done
- name: Test with PostgreSQL Database
run: DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
-coverpkg=./...,github.com/coder/coder/codersdk
-count=1 -parallel=2 -race -failfast
run: |
set +e
make test-postgres
ret=$?
if ((ret)); then
# Eternalize test timeout logs because "re-run failed" erases
# artifacts and gotestsum doesn't always capture it:
# https://github.com/gotestyourself/gotestsum/issues/292
# Multiple test packages could've failed, each one may or may
# not run into the edge case. PS. Don't summon ShellCheck here.
for testWithStack in $(grep 'panic: test timed out' gotestsum.json | grep -E -o '("Test":[^,}]*)'); do
if [ -n "$testWithStack" ] && grep -q "${testWithStack}.*PASS" gotestsum.json; then
echo "Conditions met for gotestsum stack trace missing bug, outputting panic trace:"
grep -A 999999 "${testWithStack}.*panic: test timed out" gotestsum.json
fi
done
fi
exit $ret
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_DATABASE: postgresql
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go gotests.xml
- uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: gotestsum-debug-postgres.json
path: ./gotestsum.json
retention-days: 7
- uses: codecov/codecov-action@v2
if: github.actor != 'dependabot[bot]'
- uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: gotests-postgres.xml
path: ./gotests.xml
retention-days: 30
- uses: codecov/codecov-action@v3
# This action has a tendency to error out unexpectedly, it has
# the `fail_ci_if_error` option that defaults to `false`, but
# that is no guarantee, see:
# https://github.com/codecov/codecov-action/issues/788
continue-on-error: true
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./gotests.coverage
flags: unittest-go-${{ matrix.os }}
fail_ci_if_error: true
flags: unittest-go-postgres-${{ matrix.os }}
deploy:
name: "deploy"
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
timeout-minutes: 30
needs: changes
if: |
github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
&& needs.changes.outputs.docs-only == 'false'
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v0
uses: google-github-actions/auth@v1
with:
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v0
uses: google-github-actions/setup-gcloud@v1
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
go-version: "~1.19"
- name: Echo Go Cache Paths
id: go-cache-paths
@@ -319,10 +523,6 @@ jobs:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
- uses: goreleaser/goreleaser-action@v2
with:
install-only: true
- name: Cache Node
id: cache-node
uses: actions/cache@v3
@@ -330,32 +530,53 @@ jobs:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
key: js-${{ runner.os }}-release-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
- name: Build Release
run: make release
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
- uses: actions/upload-artifact@v3
with:
name: coder_linux_amd64.deb
path: ./dist/coder_*_linux_amd64.deb
- name: Install zstd
run: sudo apt-get install -y zstd
- name: Build Release
run: |
set -euo pipefail
go mod download
version="$(./scripts/version.sh)"
make gen/mark-fresh
make -j \
build/coder_"$version"_windows_amd64.zip \
build/coder_"$version"_linux_amd64.{tar.gz,deb}
- name: Install Release
run: |
gcloud config set project coder-dogfood
gcloud config set compute/zone us-central1-a
gcloud compute scp ./dist/coder_*_linux_amd64.deb coder:/tmp/coder.deb
gcloud compute scp ./build/coder_*_linux_amd64.deb coder:/tmp/coder.deb
gcloud compute ssh coder -- sudo dpkg -i --force-confdef /tmp/coder.deb
gcloud compute ssh coder -- sudo systemctl daemon-reload
- name: Start
run: gcloud compute ssh coder -- sudo service coder restart
- uses: actions/upload-artifact@v3
with:
name: coder
path: |
./build/*.zip
./build/*.tar.gz
./build/*.deb
retention-days: 7
test-js:
name: "test/js"
runs-on: ubuntu-latest
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
@@ -370,11 +591,6 @@ jobs:
restore-keys: |
js-${{ runner.os }}-
# Go is required for uploading the test results to datadog
- uses: actions/setup-go@v2
with:
go-version: "~1.18"
- uses: actions/setup-node@v3
with:
node-version: "14"
@@ -382,44 +598,32 @@ jobs:
- name: Install node_modules
run: ./scripts/yarn_install.sh
- name: Build frontend
run: yarn build
working-directory: site
- name: Build Storybook
run: yarn storybook:build
working-directory: site
- run: yarn test:coverage
working-directory: site
- uses: codecov/codecov-action@v2
if: github.actor != 'dependabot[bot]'
- uses: codecov/codecov-action@v3
# This action has a tendency to error out unexpectedly, it has
# the `fail_ci_if_error` option that defaults to `false`, but
# that is no guarantee, see:
# https://github.com/codecov/codecov-action/issues/788
continue-on-error: true
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./site/coverage/lcov.info
flags: unittest-js
fail_ci_if_error: true
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_CATEGORY: unit
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go site/test-results/junit.xml
test-e2e:
name: "test/e2e/${{ matrix.os }}"
needs:
- changes
if: needs.changes.outputs.docs-only == 'false'
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
# TODO: Get `make build` running on Windows 2022
# https://github.com/coder/coder/issues/384
# - windows-2022
steps:
- uses: actions/checkout@v3
@@ -430,28 +634,21 @@ jobs:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
js-${{ runner.os }}-
key: js-${{ runner.os }}-e2e-${{ hashFiles('**/yarn.lock') }}
# Go is required for uploading the test results to datadog
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: "~1.18"
go-version: "~1.19"
- uses: hashicorp/setup-terraform@v1
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.1.2
terraform_version: 1.1.9
terraform_wrapper: false
- uses: actions/setup-node@v3
with:
node-version: "14"
- uses: goreleaser/goreleaser-action@v2
with:
install-only: true
- name: Echo Go Cache Paths
id: go-cache-paths
run: |
@@ -472,7 +669,8 @@ jobs:
- name: Build
run: |
make site/out
sudo npm install -g prettier
make -B site/out/index.html
- run: yarn playwright:install
working-directory: site
@@ -485,10 +683,75 @@ jobs:
DEBUG: pw:api
working-directory: site
- name: Upload DataDog Trace
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_CATEGORY: e2e
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: go run scripts/datadog-cireport/main.go site/test-results/junit.xml
- name: Upload Playwright Failed Tests
if: always() && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && !github.event.pull_request.head.repo.fork
uses: actions/upload-artifact@v3
with:
name: failed-test-videos
path: ./site/test-results/**/*.webm
retention-days: 7
chromatic:
# REMARK: this is only used to build storybook and deploy it to Chromatic.
runs-on: ubuntu-latest
needs:
- changes
if: needs.changes.outputs.ts == 'true'
steps:
- uses: actions/checkout@v3
with:
# Required by Chromatic for build-over-build history, otherwise we
# only get 1 commit on shallow checkout.
fetch-depth: 0
- name: Install dependencies
run: cd site && yarn
# This step is not meant for mainline because any detected changes to
# storybook snapshots will require manual approval/review in order for
# the check to pass. This is desired in PRs, but not in mainline.
- name: Publish to Chromatic (non-mainline)
if: github.ref != 'refs/heads/main' && github.repository_owner == 'coder'
uses: chromaui/action@v1
with:
buildScriptName: "storybook:build"
exitOnceUploaded: true
# Chromatic states its fine to make this token public. See:
# https://www.chromatic.com/docs/github-actions#forked-repositories
projectToken: 695c25b6cb65
workingDir: "./site"
# This is a separate step for mainline only that auto accepts and changes
# instead of holding CI up. Since we squash/merge, this is defensive to
# avoid the same changeset from requiring review once squashed into
# main. Chromatic is supposed to be able to detect that we use squash
# commits, but it's good to be defensive in case, otherwise CI remains
# infinitely "in progress" in mainline unless we re-review each build.
- name: Publish to Chromatic (mainline)
if: github.ref == 'refs/heads/main' && github.repository_owner == 'coder'
uses: chromaui/action@v1
with:
autoAcceptChanges: true
buildScriptName: "storybook:build"
projectToken: 695c25b6cb65
workingDir: "./site"
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
# For the main branch:
- if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: yes
use-verbose-mode: yes
config-file: .github/workflows/mlc_config.json
# For pull requests:
- if: github.ref != 'refs/heads/main' || github.event.pull_request.head.repo.fork
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: yes
use-verbose-mode: yes
check-modified-files-only: yes
base-branch: main
config-file: .github/workflows/mlc_config.json
+13
View File
@@ -0,0 +1,13 @@
# Dependabot is annoying, but this makes it a bit less so.
name: Auto Approve Dependabot
on: pull_request_target
jobs:
auto-approve:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: hmarr/auto-approve-action@v3
if: github.actor == 'dependabot[bot]'
+73
View File
@@ -0,0 +1,73 @@
name: dogfood
on:
push:
branches:
- main
paths:
- "dogfood/**"
pull_request:
paths:
- "dogfood/**"
workflow_dispatch:
jobs:
deploy_image:
runs-on: ubuntu-latest
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6.4
- name: "Branch name to Docker tag name"
id: docker-tag-name
run: |
tag=${{ steps.branch-name.outputs.current_branch }}
# Replace / with --, e.g. user/feature => user--feature.
tag=${tag//\//--}
echo "::set-output name=tag::${tag}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:dogfood"
push: true
tags: "codercom/oss-dogfood:${{ steps.docker-tag-name.outputs.tag }},codercom/oss-dogfood:latest"
cache-from: type=registry,ref=codercom/oss-dogfood:latest
cache-to: type=inline
deploy_template:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get short commit SHA
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: "Install latest Coder"
run: |
curl -L https://coder.com/install.sh | sh
# env:
# VERSION: 0.x
- name: "Push template"
run: |
coder templates push $CODER_TEMPLATE_NAME --directory $CODER_TEMPLATE_DIR --yes --name=$CODER_TEMPLATE_VERSION
env:
# Consumed by Coder CLI
CODER_URL: https://dev.coder.com
CODER_SESSION_TOKEN: ${{ secrets.CODER_SESSION_TOKEN }}
# Template source & details
CODER_TEMPLATE_NAME: ${{ secrets.CODER_TEMPLATE_NAME }}
CODER_TEMPLATE_VERSION: ${{ steps.vars.outputs.sha_short }}
CODER_TEMPLATE_DIR: ./dogfood
+22
View File
@@ -0,0 +1,22 @@
{
"ignorePatterns": [
{
"pattern": "://localhost"
},
{
"pattern": "://.*.?example\\.com"
},
{
"pattern": "developer.github.com"
},
{
"pattern": "docs.github.com"
},
{
"pattern": "support.google.com"
},
{
"pattern": "tailscale.com"
}
]
}
+60
View File
@@ -0,0 +1,60 @@
name: Submit Packages
on:
workflow_run:
workflows: [release]
types:
- completed
env:
CODER_VERSION: "${{ github.event.release.tag_name }}"
jobs:
winget:
runs-on: windows-latest
steps:
- name: Install wingetcreate
run: |
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
- name: Submit updated manifest to winget-pkgs
run: |
$release_assets = gh release view --repo coder/coder "$env:CODER_VERSION" --json assets | `
ConvertFrom-Json
# Get the installer URL from the release assets.
$installer_url = $release_assets.assets | `
Where-Object name -Match ".*_windows_amd64_installer.exe$" | `
Select -ExpandProperty url
echo "Installer URL: $installer_url"
# The package version is the same as the tag minus the leading "v".
$version = $env:CODER_VERSION.Trim('v')
echo "Package version: $version"
# The URL "|X64" suffix forces the architecture as it cannot be
# sniffed properly from the URL. wingetcreate checks both the URL and
# binary magic bytes for the architecture and they need to both match,
# but they only check for `x64`, `win64` and `_64` in the URL. Our URL
# contains `amd64` which doesn't match sadly.
#
# wingetcreate will still do the binary magic bytes check, so if we
# accidentally change the architecture of the installer, it will fail
# submission.
.\wingetcreate.exe update Coder.Coder `
--submit `
--version "${version}" `
--urls "${installer_url}|X64" `
--token "${{ secrets.CDRCI_GITHUB_TOKEN }}"
env:
# For gh CLI:
GH_TOKEN: ${{ github.token }}
- name: Comment on PR
run: |
# find the PR that wingetcreate just made
$pr_list = gh pr list --repo microsoft/winget-pkgs --search "author:cdrci Coder.Coder version ${{ steps.version.outputs.version }}" --limit 1 --json number | `
ConvertFrom-Json`
$pr_number = $pr_list[0].number
gh pr comment --repo microsoft/winget-pkgs "$pr_number" --body "🤖 cc: @deansheather @matifali"
+20
View File
@@ -0,0 +1,20 @@
name: Lint PR
on:
pull_request_target:
types:
- opened
- reopened
- edited
- synchronize
jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
requireScope: false
+275 -29
View File
@@ -1,36 +1,143 @@
name: release
# GitHub release workflow.
name: Release
run-name: Release ${{ github.ref_name }}${{ inputs.dry_run && ' (DRYRUN)' || '' }}
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
increment:
description: Preferred version increment (release script may promote e.g. patch to minor depending on changes).
type: choice
required: true
default: patch
options:
- patch
- minor
- major
draft:
description: Create a draft release (for manually editing release notes before publishing).
type: boolean
required: true
default: false
dry_run:
description: Perform a dry-run release.
type: boolean
required: true
default: false
ignore_missing_commit_metadata:
description: WARNING! This option disables the requirement that all commits have a PR. Not needed for dry_run.
type: boolean
default: false
permissions:
# Required to publish a release
contents: write
# Necessary to push docker images to ghcr.io.
packages: write
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
id-token: write
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
# Use `inputs` (vs `github.event.inputs`) to ensure that booleans are actual
# booleans, not strings.
# https://github.blog/changelog/2022-06-10-github-actions-inputs-unified-across-manual-and-reusable-workflows/
CODER_RELEASE: ${{ !inputs.dry_run }}
CODER_RELEASE_INCREMENT: ${{ inputs.increment }}
CODER_RELEASE_DRAFT: ${{ inputs.draft }}
CODER_DRY_RUN: ${{ inputs.dry_run }}
jobs:
goreleaser:
runs-on: ubuntu-latest
release:
name: Create and publish
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
env:
# Necessary for Docker manifest
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Check release on main (or dry-run)
if: ${{ github.ref_name != 'main' && !inputs.dry_run }}
run: |
echo "Release not allowed on ${{ github.ref_name }}, use dry-run."
exit 1
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: "~1.18"
# Set token for pushing protected tag (vX.X.X).
token: ${{ secrets.RELEASE_GITHUB_PAT }}
- name: Echo Go Cache Paths
id: go-cache-paths
# If the event that triggered the build was an annotated tag (which our
# tags are supposed to be), actions/checkout has a bug where the tag in
# question is only a lightweight tag and not a full annotated tag. This
# command seems to fix it.
# https://github.com/actions/checkout/issues/290
- name: Fetch git tags
run: git fetch --tags --force
# Configure git user name/email for creating annotated version tag.
- name: Setup git config
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
git config user.name "Coder CI"
git config user.email "dean+cdrci@coder.com"
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-release-go-build-${{ hashFiles('**/go.sum') }}
- name: Create release tag and release notes
run: |
set -euo pipefail
ref=HEAD
old_version="$(git describe --abbrev=0 "$ref^1")"
- name: Go Mod Cache
uses: actions/cache@v3
if [[ "${{ inputs.ignore_missing_commit_metadata }}" == *t* ]]; then
export CODER_IGNORE_MISSING_COMMIT_METADATA=1
fi
# Warn if CODER_IGNORE_MISSING_COMMIT_METADATA is set any other way
# than via dry-run.
if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:-0} != 0 ]]; then
echo "WARNING: CODER_IGNORE_MISSING_COMMIT_METADATA is enabled and we will ignore missing commit metadata." 1>&2
fi
version_args=()
if [[ $CODER_DRY_RUN == *t* ]]; then
# Allow dry-run of branches to pass.
export CODER_IGNORE_MISSING_COMMIT_METADATA=1
version_args+=(--dry-run)
fi
# Cache commit metadata.
. ./scripts/release/check_commit_metadata.sh "$old_version" "$ref"
declare -p version_args
# Create new release tag (note that this tag is not pushed before
# release.sh is run).
version="$(
./scripts/release/tag_version.sh \
"${version_args[@]}" \
--ref "$ref" \
--"$CODER_RELEASE_INCREMENT"
)"
# Generate notes.
release_notes_file="$(mktemp -t release_notes.XXXXXX)"
./scripts/release/generate_release_notes.sh --old-version "$old_version" --new-version "$version" --ref "$ref" >> "$release_notes_file"
echo CODER_RELEASE_NOTES_FILE="$release_notes_file" >> $GITHUB_ENV
- name: Echo release notes
run: |
set -euo pipefail
cat "$CODER_RELEASE_NOTES_FILE"
- name: Docker Login
uses: docker/login-action@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v3
with:
go-version: "~1.19"
- name: Cache Node
id: cache-node
@@ -43,13 +150,152 @@ jobs:
restore-keys: |
js-${{ runner.os }}-
- name: Build Site
run: make site/out
- name: Install nsis and zstd
run: sudo apt-get install -y nsis zstd
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2.9.1
with:
version: latest
args: release --rm-dist
- name: Install nfpm
run: |
set -euo pipefail
wget -O /tmp/nfpm.deb https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.deb
sudo dpkg -i /tmp/nfpm.deb
- name: Install rcodesign
run: |
set -euo pipefail
# Install a prebuilt binary of rcodesign for linux amd64. Once the
# following PR is merged and released upstream, we can download
# directly from GitHub releases instead:
# https://github.com/indygreg/PyOxidizer/pull/635
wget -O /tmp/rcodesign https://cdn.discordapp.com/attachments/283356472258199552/1016767245717872700/rcodesign
sudo install --mode 755 /tmp/rcodesign /usr/local/bin/rcodesign
- name: Setup Apple Developer certificate and API key
run: |
set -euo pipefail
touch /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8}
chmod 600 /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8}
echo "$AC_CERTIFICATE_P12_BASE64" | base64 -d > /tmp/apple_cert.p12
echo "$AC_CERTIFICATE_PASSWORD" > /tmp/apple_cert_password.txt
echo "$AC_APIKEY_P8_BASE64" | base64 -d > /tmp/apple_apikey.p8
env:
AC_CERTIFICATE_P12_BASE64: ${{ secrets.AC_CERTIFICATE_P12_BASE64 }}
AC_CERTIFICATE_PASSWORD: ${{ secrets.AC_CERTIFICATE_PASSWORD }}
AC_APIKEY_P8_BASE64: ${{ secrets.AC_APIKEY_P8_BASE64 }}
- name: Build binaries
run: |
set -euo pipefail
go mod download
version="$(./scripts/version.sh)"
make gen/mark-fresh
make -j \
build/coder_"$version"_linux_{amd64,armv7,arm64}.{tar.gz,apk,deb,rpm} \
build/coder_"$version"_{darwin,windows}_{amd64,arm64}.zip \
build/coder_"$version"_windows_amd64_installer.exe \
build/coder_helm_"$version".tgz
env:
CODER_SIGN_DARWIN: "1"
AC_CERTIFICATE_FILE: /tmp/apple_cert.p12
AC_CERTIFICATE_PASSWORD_FILE: /tmp/apple_cert_password.txt
AC_APIKEY_ISSUER_ID: ${{ secrets.AC_APIKEY_ISSUER_ID }}
AC_APIKEY_ID: ${{ secrets.AC_APIKEY_ID }}
AC_APIKEY_FILE: /tmp/apple_apikey.p8
- name: Delete Apple Developer certificate and API key
run: rm -f /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8}
- name: Build Linux Docker images
run: |
set -euxo pipefail
# build Docker images for each architecture
version="$(./scripts/version.sh)"
make -j build/coder_"$version"_linux_{amd64,arm64,armv7}.tag
# we can't build multi-arch if the images aren't pushed, so quit now
# if dry-running
if [[ "$CODER_RELEASE" != *t* ]]; then
echo Skipping multi-arch docker builds due to dry-run.
exit 0
fi
# build and push multi-arch manifest, this depends on the other images
# being pushed so will automatically push them.
make -j push/build/coder_"$version"_linux.tag
# if the current version is equal to the highest (according to semver)
# version in the repo, also create a multi-arch image as ":latest" and
# push it
if [[ "$(git tag | grep '^v' | grep -vE '(rc|dev|-|\+|\/)' | sort -r --version-sort | head -n1)" == "v$(./scripts/version.sh)" ]]; then
./scripts/build_docker_multiarch.sh \
--push \
--target "$(./scripts/image_tag.sh --version latest)" \
$(cat build/coder_"$version"_linux_{amd64,arm64,armv7}.tag)
fi
- name: ls build
run: ls -lh build
- name: Publish release
run: |
set -euo pipefail
publish_args=()
if [[ $CODER_RELEASE_DRAFT == *t* ]]; then
publish_args+=(--draft)
fi
if [[ $CODER_DRY_RUN == *t* ]]; then
publish_args+=(--dry-run)
fi
declare -p publish_args
./scripts/release/publish.sh \
"${publish_args[@]}" \
--release-notes-file "$CODER_RELEASE_NOTES_FILE" \
./build/*_installer.exe \
./build/*.zip \
./build/*.tar.gz \
./build/*.tgz \
./build/*.apk \
./build/*.deb \
./build/*.rpm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_ID_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Setup GCloud SDK
uses: "google-github-actions/setup-gcloud@v1"
- name: Publish Helm Chart
if: ${{ !inputs.dry_run }}
run: |
set -euo pipefail
version="$(./scripts/version.sh)"
mkdir -p build/helm
cp "build/coder_helm_${version}.tgz" build/helm
gsutil cp gs://helm.coder.com/v2/index.yaml build/helm/index.yaml
helm repo index build/helm --url https://helm.coder.com/v2 --merge build/helm/index.yaml
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/coder_helm_${version}.tgz gs://helm.coder.com/v2
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/index.yaml gs://helm.coder.com/v2
- name: Upload artifacts to actions (if dry-run)
if: ${{ inputs.dry_run }}
uses: actions/upload-artifact@v2
with:
name: release-artifacts
path: |
./build/*_installer.exe
./build/*.zip
./build/*.tar.gz
./build/*.tgz
./build/*.apk
./build/*.deb
./build/*.rpm
retention-days: 7
+35
View File
@@ -0,0 +1,35 @@
name: Stale Issue Cron
on:
schedule:
# Every day at midnight
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
# v5.1.0 has a weird bug that makes stalebot add then remove its own label
# https://github.com/actions/stale/pull/775
- uses: actions/stale@v7.0.0
with:
stale-issue-label: "stale"
stale-pr-label: "stale"
# 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.
# Upped from 30 since we have a big tracker and was hitting the limit.
operations-per-run: 60
# Start with the oldest issues, always.
ascending: true
+25
View File
@@ -0,0 +1,25 @@
[default.extend-identifiers]
alog = "alog"
Jetbrains = "JetBrains"
IST = "IST"
MacOS = "macOS"
[default.extend-words]
# do as sudo replacement
doas = "doas"
darcula = "darcula"
Hashi = "Hashi"
trialer = "trialer"
encrypter = "encrypter"
[files]
extend-exclude = [
"**.svg",
"**.png",
"**.lock",
"go.sum",
"go.mod",
# These files contain base64 strings that confuse the detector
"**XService**.ts",
"**identity.go",
]
+18
View File
@@ -0,0 +1,18 @@
name: Welcome
on:
pull_request:
types: [opened]
jobs:
test:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: wow-actions/welcome@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FIRST_PR_REACTIONS: "+1, hooray, rocket, heart"
FIRST_PR_COMMENT: |
👋 Welcome @{{ author }} to Coder! Yo @coder/docs this is @{{ author }}'s first pull-request here!
FIRST_PR_MERGED: |
🎉 Thanks for the contribution @{{ author }}! Yo @coder/docs @{{ author }}'s first contribution has been merged! 👀👀👀
+36 -23
View File
@@ -1,36 +1,49 @@
###############################################################################
# NOTICE #
# If you change this file, kindly copy-pasta your change into .prettierignore #
# and .eslintignore as well. See the following discussions to understand why #
# we have to resort to this duplication (at least for now): #
# #
# https://github.com/prettier/prettier/issues/8048 #
# https://github.com/prettier/prettier/issues/8506 #
# https://github.com/prettier/prettier/issues/8679 #
###############################################################################
node_modules
vendor
# Common ignore patterns, these rules applies in both root and subdirectories.
.DS_Store
.eslintcache
yarn-error.log
.gitpod.yml
.idea
**/*.swp
gotests.coverage
gotests.xml
gotestsum.json
node_modules/
vendor/
yarn-error.log
# Front-end ignore
# VSCode settings.
**/.vscode/*
# Allow VSCode recommendations and default settings in project root.
!/.vscode/extensions.json
!/.vscode/settings.json
# Front-end ignore patterns.
.next/
site/.eslintcache
site/.next/
site/node_modules/
site/storybook-static/
site/test-results/
site/yarn-error.log
coverage/
site/**/*.typegen.ts
site/build-storybook.log
site/coverage/
site/storybook-static/
site/test-results/*
site/e2e/test-results/*
site/e2e/storageState.json
site/playwright-report/*
# Make target for updating golden files.
cli/testdata/.gen-golden
# Build
dist/
/build/
/dist/
site/out/
*.tfstate
*.tfstate.backup
*.tfplan
*.lock.hcl
.terraform/
/.coderv2/*
**/__debug_bin
# direnv
.envrc
+22 -28
View File
@@ -77,7 +77,7 @@ linters-settings:
# - sloppyReassign
- sloppyTypeAssert
- sortSlice
# - sprintfQuotedString
- sprintfQuotedString
- sqlQuery
# - stringConcatSimplify
# - stringXbytes
@@ -103,7 +103,14 @@ linters-settings:
settings:
ruleguard:
failOn: all
rules: rules.go
rules: "${configDir}/scripts/rules.go"
staticcheck:
# https://staticcheck.io/docs/options#checks
# We disable SA1019 because it gets angry about our usage of xerrors. We
# intentionally xerrors because stack frame support didn't make it into the
# stdlib port.
checks: ["all", "-SA1019"]
goimports:
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
@@ -116,6 +123,8 @@ linters-settings:
misspell:
locale: US
ignore-words:
- trialer
nestif:
min-complexity: 4 # Min complexity of if statements (def 5, goal 4)
@@ -177,26 +186,6 @@ linters-settings:
- name: var-declaration
- name: var-naming
- name: waitgroup-by-value
varnamelen:
ignore-names:
- err
- rw
- r
- i
- db
- t
- id
- wg
# Optional list of variable declarations that should be ignored completely. (defaults to empty list)
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>" for
# variables, or "const <name>" for constants.
ignore-decls:
- rw http.ResponseWriter
- r *http.Request
- t testing.T
- t testing.TB
- ok bool
- wg sync.WaitGroup
issues:
# Rules listed here: https://github.com/securego/gosec#available-rules
@@ -214,6 +203,8 @@ run:
concurrency: 4
skip-dirs:
- node_modules
skip-files:
- scripts/rules.go
timeout: 5m
# Over time, add more and more linters from
@@ -246,16 +237,21 @@ linters:
- noctx
- paralleltest
- revive
- rowserrcheck
- sqlclosecheck
# These don't work until the following issue is solved.
# https://github.com/golangci/golangci-lint/issues/2649
# - rowserrcheck
# - sqlclosecheck
# - structcheck
# - wastedassign
- staticcheck
- structcheck
- tenv
# In Go, it's possible for a package to test it's internal functionality
# without testing any exported functions. This is enabled to promote
# decomposing a package before testing it's internals. A function caller
# should be able to test most of the functionality from exported functions.
#
#
# There are edge-cases to this rule, but they should be carefully considered
# to avoid structural inconsistency.
- testpackage
@@ -264,5 +260,3 @@ linters:
- unconvert
- unused
- varcheck
- varnamelen
- wastedassign
-57
View File
@@ -1,57 +0,0 @@
archives:
- id: coder
builds:
- coder
files:
- README.md
before:
hooks:
- go mod tidy
- rm -f site/out/bin/coder*
builds:
- id: coder-slim
dir: cmd/coder
ldflags: ["-s -w"]
env: [CGO_ENABLED=0]
goos: [darwin, linux, windows]
goarch: [amd64]
hooks:
# The "trimprefix" appends ".exe" on Windows.
post: |
cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ trimprefix .Name "coder" }}
- id: coder
dir: cmd/coder
flags: [-tags=embed]
ldflags: ["-s -w"]
env: [CGO_ENABLED=0]
goos: [darwin, linux, windows]
goarch: [amd64, arm64]
nfpms:
- id: packages
vendor: Coder
homepage: https://coder.com
maintainer: Coder <support@coder.com>
description: |
Provision development environments with infrastructure with code
formats:
- apk
- deb
- rpm
suggests:
- postgresql
builds:
- coder
bindir: /usr/bin
contents:
- src: coder.env
dst: /etc/coder.d/coder.env
type: "config|noreplace"
- src: coder.service
dst: /usr/lib/systemd/system/coder.service
release:
ids: [coder, packages]
+63
View File
@@ -0,0 +1,63 @@
# Code generated by Makefile (.gitignore .prettierignore.include). DO NOT EDIT.
# .gitignore:
# Common ignore patterns, these rules applies in both root and subdirectories.
.DS_Store
.eslintcache
.gitpod.yml
.idea
**/*.swp
gotests.coverage
gotests.xml
gotestsum.json
node_modules/
vendor/
yarn-error.log
# VSCode settings.
**/.vscode/*
# Allow VSCode recommendations and default settings in project root.
!/.vscode/extensions.json
!/.vscode/settings.json
# Front-end ignore patterns.
.next/
site/**/*.typegen.ts
site/build-storybook.log
site/coverage/
site/storybook-static/
site/test-results/*
site/e2e/test-results/*
site/e2e/storageState.json
site/playwright-report/*
# Make target for updating golden files.
cli/testdata/.gen-golden
# Build
/build/
/dist/
site/out/
*.tfstate
*.tfstate.backup
*.tfplan
*.lock.hcl
.terraform/
/.coderv2/*
**/__debug_bin
# direnv
.envrc
# .prettierignore.include:
# Helm templates contain variables that are invalid YAML and can't be formatted
# by Prettier.
helm/templates/*.yaml
# Terraform state files used in tests, these are automatically generated.
# Example: provisioner/terraform/testdata/instance-id/instance-id.tfstate.json
**/testdata/**/*.tf*.json
# Testdata shouldn't be formatted.
scripts/apitypings/testdata/**/*.ts
+10
View File
@@ -0,0 +1,10 @@
# Helm templates contain variables that are invalid YAML and can't be formatted
# by Prettier.
helm/templates/*.yaml
# Terraform state files used in tests, these are automatically generated.
# Example: provisioner/terraform/testdata/instance-id/instance-id.tfstate.json
**/testdata/**/*.tf*.json
# Testdata shouldn't be formatted.
scripts/apitypings/testdata/**/*.ts
+16
View File
@@ -0,0 +1,16 @@
# This config file is used in conjunction with `.editorconfig` to specify
# formatting for prettier-supported files. See `.editorconfig` and
# `site/.editorconfig`for whitespace formatting options.
printWidth: 80
semi: false
trailingComma: all
overrides:
- files:
- README.md
options:
proseWrap: preserve
- files:
- "site/**/*.yaml"
- "site/**/*.yml"
options:
proseWrap: always
+8
View File
@@ -0,0 +1,8 @@
// Replace all NullTime with string
replace github.com/coder/coder/codersdk.NullTime string
// Prevent swaggo from rendering enums for time.Duration
replace time.Duration int64
// Do not expose "echo" provider
replace github.com/coder/coder/codersdk.ProvisionerType string
// Do not render netip.Addr
replace netip.Addr string
+4 -1
View File
@@ -1,5 +1,6 @@
{
"recommendations": [
"github.vscode-codeql",
"golang.go",
"hashicorp.terraform",
"esbenp.prettier-vscode",
@@ -7,6 +8,8 @@
"emeraldwalk.runonsave",
"zxh404.vscode-proto3",
"redhat.vscode-yaml",
"streetsidesoftware.code-spell-checker"
"streetsidesoftware.code-spell-checker",
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig"
]
}
+117 -9
View File
@@ -1,68 +1,178 @@
{
"cSpell.words": [
"afero",
"apps",
"ASKPASS",
"awsidentity",
"bodyclose",
"buildinfo",
"buildname",
"circbuf",
"cliflag",
"cliui",
"codecov",
"coderd",
"coderdenttest",
"coderdtest",
"codersdk",
"cronstrue",
"databasefake",
"dbtype",
"DERP",
"derphttp",
"derpmap",
"devel",
"devtunnel",
"dflags",
"drpc",
"drpcconn",
"drpcmux",
"drpcserver",
"Dsts",
"embeddedpostgres",
"enablements",
"errgroup",
"eventsourcemock",
"Failf",
"fatih",
"Formik",
"gitauth",
"gitsshkey",
"goarch",
"gographviz",
"goleak",
"gonet",
"gossh",
"gsyslog",
"GTTY",
"hashicorp",
"hclsyntax",
"httpapi",
"httpmw",
"idtoken",
"Iflag",
"incpatch",
"ipnstate",
"isatty",
"Jobf",
"Keygen",
"kirsle",
"Kubernetes",
"ldflags",
"magicsock",
"manifoldco",
"mapstructure",
"mattn",
"mitchellh",
"moby",
"namesgenerator",
"namespacing",
"netaddr",
"netip",
"netmap",
"netns",
"netstack",
"nettype",
"nfpms",
"nhooyr",
"nmcfg",
"nolint",
"nosec",
"ntqry",
"OIDC",
"oneof",
"opty",
"paralleltest",
"parameterscopeid",
"pqtype",
"prometheusmetrics",
"promhttp",
"promptui",
"protobuf",
"provisionerd",
"provisionerdserver",
"provisionersdk",
"ptty",
"ptys",
"ptytest",
"quickstart",
"reconfig",
"replicasync",
"retrier",
"rpty",
"SCIM",
"sdkproto",
"sdktrace",
"Signup",
"slogtest",
"sourcemapped",
"Srcs",
"stdbuf",
"stretchr",
"STTY",
"stuntest",
"tailbroker",
"tailcfg",
"tailexchange",
"tailnet",
"tailnettest",
"Tailscale",
"TCGETS",
"tcpip",
"TCSETS",
"templateversions",
"testdata",
"testid",
"testutil",
"tfexec",
"tfjson",
"tfplan",
"tfstate",
"tios",
"tmpdir",
"tparallel",
"trialer",
"trimprefix",
"tsdial",
"tslogger",
"tstun",
"turnconn",
"typegen",
"typesafe",
"unconvert",
"Untar",
"Userspace",
"VMID",
"walkthrough",
"weblinks",
"webrtc",
"wgcfg",
"wgconfig",
"wgengine",
"wgmonitor",
"wgnet",
"workspaceagent",
"workspaceagents",
"workspaceapp",
"workspaceapps",
"workspacebuilds",
"workspacename",
"wsconncache",
"wsjson",
"xerrors",
"xstate",
"yamux"
],
"cSpell.ignorePaths": ["site/package.json", ".vscode/settings.json"],
"emeraldwalk.runonsave": {
"commands": [
{
"match": "database/query.sql",
"match": "database/queries/*.sql",
"cmd": "make gen"
},
{
"match": "provisionerd/proto/provisionerd.proto",
"cmd": "make provisionerd/proto/provisionerd.pb.go"
}
]
},
@@ -76,19 +186,17 @@
"go.lintFlags": ["--fast"],
"go.lintOnSave": "package",
"go.coverOnSave": true,
// The codersdk is used by coderd another other packages extensively.
// To reduce redundancy in tests, it's covered by other packages.
"go.testFlags": ["-short", "-coverpkg=./.,github.com/coder/coder/codersdk"],
"go.coverageDecorator": {
"type": "gutter",
"coveredHighlightColor": "rgba(64,128,128,0.5)",
"uncoveredHighlightColor": "rgba(128,64,64,0.25)",
"coveredBorderColor": "rgba(64,128,128,0.5)",
"uncoveredBorderColor": "rgba(128,64,64,0.25)",
"coveredGutterStyle": "blockgreen",
"uncoveredGutterStyle": "blockred"
},
// The codersdk is used by coderd another other packages extensively.
// To reduce redundancy in tests, it's covered by other packages.
// Since package coverage pairing can't be defined, all packages cover
// all other packages.
"go.testFlags": ["-short", "-coverpkg=./..."],
// We often use a version of TypeScript that's ahead of the version shipped
// with VS Code.
"typescript.tsdk": "./site/node_modules/typescript/lib",
"typescript.tsdk": "./site/node_modules/typescript/lib"
}
+13
View File
@@ -0,0 +1,13 @@
# Adopters
[!["Join us on
Discord"](https://img.shields.io/badge/join-us%20on%20Discord-gray.svg?longCache=true&logo=discord&colorB=green)](https://coder.com/chat?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=adopters.md) [![Twitter
Follow](https://img.shields.io/twitter/follow/coderhq?label=%40coderhq&style=social)](https://twitter.com/coderhq)
🦩 _If you're using Coder in your organization, please try to add your company name to this list. It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact. You can do this by by editing this file and contributing your changes via a pull-request on GitHub._
> 👋 _If you are considering using Coder in your organization please introduce yourself via https://coder.com/demo_ 🙇🏻‍♂️
| Organization | Contact | Description of Use |
| ------------------------------ | --------------------------------------- | ------------------------------ |
| [Coder](https://www.coder.com) | [@coderhq](https://twitter.com/coderhq) | Coder builds coder with Coder. |
+30
View File
@@ -0,0 +1,30 @@
# This is the multi-arch Dockerfile used for Coder. Since it's multi-arch and
# cross-compiled, it cannot have ANY "RUN" commands. All binaries are built
# using the go toolchain on the host and then copied into the build context by
# scripts/build_docker.sh.
FROM alpine:latest
# LABEL doesn't add any real layers so it's fine (and easier) to do it here than
# in the build script.
ARG CODER_VERSION
LABEL \
org.opencontainers.image.title="Coder" \
org.opencontainers.image.description="A tool for provisioning self-hosted development environments with Terraform." \
org.opencontainers.image.url="https://github.com/coder/coder" \
org.opencontainers.image.source="https://github.com/coder/coder" \
org.opencontainers.image.version="$CODER_VERSION"
# Create coder group and user. We cannot use `addgroup` and `adduser` because
# they won't work if we're building the image for a different architecture.
COPY --chown=0:0 --chmod=644 group passwd /etc/
COPY --chown=1000:1000 --chmod=700 empty-dir /home/coder
# The coder binary is injected by scripts/build_docker.sh.
COPY --chown=1000:1000 --chmod=755 coder /opt/coder
USER 1000:1000
ENV HOME=/home/coder
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt
WORKDIR /home/coder
ENTRYPOINT [ "/opt/coder", "server" ]
+661
View File
@@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
+31
View File
@@ -0,0 +1,31 @@
## Acceptance
By using any software and associated documentation files under Coder
Technologies Inc.s ("Coder") directory named "enterprise" ("Enterprise
Software"), you agree to all of the terms and conditions below.
## Copyright License
The licensor grants you a non-exclusive, royalty-free, worldwide,
non-sublicensable, non-transferable license to use, copy, distribute, make
available, modify and prepare derivative works of the Enterprise Software, in
each case subject to the limitations and conditions below.
## Limitations
You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software.
You agree that Coder and/or its licensors (as applicable) retain all right,
title and interest in and to all such modifications and/or patches.
## Additional Terms
This Enterprise Software may only be used in production, if you (and any entity
that you represent) have agreed to, and are in compliance with, the Coders
Terms of Service, available at https://coder.com/legal/terms-of-service, or
other agreement governing the use of the Software, as agreed by you and Coder.
+576 -70
View File
@@ -1,98 +1,604 @@
INSTALL_DIR=$(shell go env GOPATH)/bin
GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH)
# This is the Coder Makefile. The build directory for most tasks is `build/`.
#
# These are the targets you're probably looking for:
# - clean
# - build-fat: builds all "fat" binaries for all architectures
# - build-slim: builds all "slim" binaries (no frontend or slim binaries
# embedded) for all architectures
# - release: simulate a release (mostly, does not push images)
# - build/coder(-slim)?_${os}_${arch}(.exe)?: build a single fat binary
# - build/coder_${os}_${arch}.(zip|tar.gz): build a release archive
# - build/coder_linux_${arch}.(apk|deb|rpm): build a release Linux package
# - build/coder_${version}_linux_${arch}.tag: build a release Linux Docker image
# - build/coder_helm.tgz: build a release Helm chart
bin:
goreleaser build --snapshot --rm-dist
.PHONY: bin
.DEFAULT_GOAL := build-fat
build: site/out bin
.PHONY: build
# Use a single bash shell for each job, and immediately exit on failure
SHELL := bash
.SHELLFLAGS := -ceu
.ONESHELL:
# Runs migrations to output a dump of the database.
coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql)
go run coderd/database/dump/main.go
# This doesn't work on directories.
# See https://stackoverflow.com/questions/25752543/make-delete-on-error-for-directory-targets
.DELETE_ON_ERROR:
# Generates Go code for querying the database.
coderd/database/generate: fmt/sql coderd/database/dump.sql coderd/database/query.sql
cd coderd/database && sqlc generate && rm db_tmp.go
cd coderd/database && gofmt -w -r 'Querier -> querier' *.go
cd coderd/database && gofmt -w -r 'Queries -> sqlQuerier' *.go
.PHONY: coderd/database/generate
# Don't print the commands in the file unless you specify VERBOSE. This is
# essentially the same as putting "@" at the start of each line.
ifndef VERBOSE
.SILENT:
endif
# Create the output directories if they do not exist.
$(shell mkdir -p build site/out/bin)
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
GOOS_BIN_EXT := $(if $(filter windows, $(GOOS)),.exe,)
VERSION := $(shell ./scripts/version.sh)
# Use the highest ZSTD compression level in CI.
ifdef CI
ZSTDFLAGS := -22 --ultra
else
ZSTDFLAGS := -6
endif
# Common paths to exclude from find commands, this rule is written so
# that it can be it can be used in a chain of AND statements (meaning
# you can simply write `find . $(FIND_EXCLUSIONS) -name thing-i-want`).
# Note, all find statements should be written with `.` or `./path` as
# the search path so that these exclusions match.
FIND_EXCLUSIONS= \
-not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path '*/node_modules/*' -o -path './site/out/*' \) -prune \)
# Source files used for make targets, evaluated on use.
GO_SRC_FILES = $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go')
# All the shell files in the repo, excluding ignored files.
SHELL_SRC_FILES = $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.sh')
# All ${OS}_${ARCH} combos we build for. Windows binaries have the .exe suffix.
OS_ARCHES := \
linux_amd64 linux_arm64 linux_armv7 \
darwin_amd64 darwin_arm64 \
windows_amd64.exe windows_arm64.exe
# Archive formats and their corresponding ${OS}_${ARCH} combos.
ARCHIVE_TAR_GZ := linux_amd64 linux_arm64 linux_armv7
ARCHIVE_ZIP := \
darwin_amd64 darwin_arm64 \
windows_amd64 windows_arm64
# All package formats we build and the ${OS}_${ARCH} combos we build them for.
PACKAGE_FORMATS := apk deb rpm
PACKAGE_OS_ARCHES := linux_amd64 linux_armv7 linux_arm64
# All architectures we build Docker images for (Linux only).
DOCKER_ARCHES := amd64 arm64 armv7
# Computed variables based on the above.
CODER_SLIM_BINARIES := $(addprefix build/coder-slim_$(VERSION)_,$(OS_ARCHES))
CODER_FAT_BINARIES := $(addprefix build/coder_$(VERSION)_,$(OS_ARCHES))
CODER_ALL_BINARIES := $(CODER_SLIM_BINARIES) $(CODER_FAT_BINARIES)
CODER_TAR_GZ_ARCHIVES := $(foreach os_arch, $(ARCHIVE_TAR_GZ), build/coder_$(VERSION)_$(os_arch).tar.gz)
CODER_ZIP_ARCHIVES := $(foreach os_arch, $(ARCHIVE_ZIP), build/coder_$(VERSION)_$(os_arch).zip)
CODER_ALL_ARCHIVES := $(CODER_TAR_GZ_ARCHIVES) $(CODER_ZIP_ARCHIVES)
CODER_ALL_PACKAGES := $(foreach os_arch, $(PACKAGE_OS_ARCHES), $(addprefix build/coder_$(VERSION)_$(os_arch).,$(PACKAGE_FORMATS)))
CODER_ARCH_IMAGES := $(foreach arch, $(DOCKER_ARCHES), build/coder_$(VERSION)_linux_$(arch).tag)
CODER_ARCH_IMAGES_PUSHED := $(addprefix push/, $(CODER_ARCH_IMAGES))
CODER_MAIN_IMAGE := build/coder_$(VERSION)_linux.tag
CODER_SLIM_NOVERSION_BINARIES := $(addprefix build/coder-slim_,$(OS_ARCHES))
CODER_FAT_NOVERSION_BINARIES := $(addprefix build/coder_,$(OS_ARCHES))
CODER_ALL_NOVERSION_IMAGES := $(foreach arch, $(DOCKER_ARCHES), build/coder_linux_$(arch).tag) build/coder_linux.tag
CODER_ALL_NOVERSION_IMAGES_PUSHED := $(addprefix push/, $(CODER_ALL_NOVERSION_IMAGES))
clean:
rm -rf build site/out
mkdir -p build site/out/bin
git restore site/out
.PHONY: clean
build-slim: $(CODER_SLIM_BINARIES)
.PHONY: build-slim
build-fat build-full build: $(CODER_FAT_BINARIES)
.PHONY: build-fat build-full build
release: $(CODER_FAT_BINARIES) $(CODER_ALL_ARCHIVES) $(CODER_ALL_PACKAGES) $(CODER_ARCH_IMAGES) build/coder_helm_$(VERSION).tgz
.PHONY: release
build/coder-slim_$(VERSION)_checksums.sha1: site/out/bin/coder.sha1
cp "$<" "$@"
site/out/bin/coder.sha1: $(CODER_SLIM_BINARIES)
pushd ./site/out/bin
openssl dgst -r -sha1 coder-* | tee coder.sha1
popd
build/coder-slim_$(VERSION).tar: build/coder-slim_$(VERSION)_checksums.sha1 $(CODER_SLIM_BINARIES)
pushd ./site/out/bin
tar cf "../../../build/$(@F)" coder-*
popd
# delete the uncompressed binaries from the embedded dir
rm -f site/out/bin/coder-*
site/out/bin/coder.tar.zst: build/coder-slim_$(VERSION).tar.zst
cp "$<" "$@"
build/coder-slim_$(VERSION).tar.zst: build/coder-slim_$(VERSION).tar
zstd $(ZSTDFLAGS) \
--force \
--long \
--no-progress \
-o "build/coder-slim_$(VERSION).tar.zst" \
"build/coder-slim_$(VERSION).tar"
# Redirect from version-less targets to the versioned ones. There is a similar
# target for slim binaries below.
#
# Called like this:
# make build/coder_linux_amd64
# make build/coder_windows_amd64.exe
$(CODER_FAT_NOVERSION_BINARIES): build/coder_%: build/coder_$(VERSION)_%
rm -f "$@"
ln "$<" "$@"
# Same as above, but for slim binaries.
#
# Called like this:
# make build/coder-slim_linux_amd64
# make build/coder-slim_windows_amd64.exe
$(CODER_SLIM_NOVERSION_BINARIES): build/coder-slim_%: build/coder-slim_$(VERSION)_%
rm -f "$@"
ln "$<" "$@"
# "fat" binaries always depend on the site and the compressed slim binaries.
$(CODER_FAT_BINARIES): \
site/out/index.html \
site/out/bin/coder.sha1 \
site/out/bin/coder.tar.zst
# This is a handy block that parses the target to determine whether it's "slim"
# or "fat", which OS was specified and which architecture was specified.
#
# It populates the following variables: mode, os, arch_ext, arch, ext (without
# dot).
define get-mode-os-arch-ext =
mode="$$([[ "$@" = build/coder-slim* ]] && echo "slim" || echo "fat")"
os="$$(echo $@ | cut -d_ -f3)"
arch_ext="$$(echo $@ | cut -d_ -f4)"
if [[ "$$arch_ext" == *.* ]]; then
arch="$$(echo $$arch_ext | cut -d. -f1)"
ext="$${arch_ext#*.}"
else
arch="$$arch_ext"
ext=""
fi
endef
# This task handles all builds, for both "fat" and "slim" binaries. It parses
# the target name to get the metadata for the build, so it must be specified in
# this format:
# build/coder(-slim)?_${version}_${os}_${arch}(.exe)?
#
# You should probably use the non-version targets above instead if you're
# calling this manually.
$(CODER_ALL_BINARIES): go.mod go.sum \
$(GO_SRC_FILES) \
$(shell find ./examples/templates)
$(get-mode-os-arch-ext)
if [[ "$$os" != "windows" ]] && [[ "$$ext" != "" ]]; then
echo "ERROR: Invalid build binary extension" 1>&2
exit 1
fi
if [[ "$$os" == "windows" ]] && [[ "$$ext" != exe ]]; then
echo "ERROR: Windows binaries must have an .exe extension." 1>&2
exit 1
fi
build_args=( \
--os "$$os" \
--arch "$$arch" \
--version "$(VERSION)" \
--output "$@" \
)
if [ "$$mode" == "slim" ]; then
build_args+=(--slim)
fi
./scripts/build_go.sh "$${build_args[@]}"
if [[ "$$mode" == "slim" ]]; then
dot_ext=""
if [[ "$$ext" != "" ]]; then
dot_ext=".$$ext"
fi
cp "$@" "./site/out/bin/coder-$$os-$$arch$$dot_ext"
fi
# This task builds all archives. It parses the target name to get the metadata
# for the build, so it must be specified in this format:
# build/coder_${version}_${os}_${arch}.${format}
#
# The following OS/arch/format combinations are supported:
# .tar.gz: linux_amd64, linux_arm64, linux_armv7
# .zip: darwin_amd64, darwin_arm64, windows_amd64, windows_arm64
#
# This depends on all fat binaries because it's difficult to do dynamic
# dependencies due to the .exe requirement on Windows. These targets are
# typically only used during release anyways.
$(CODER_ALL_ARCHIVES): $(CODER_FAT_BINARIES)
$(get-mode-os-arch-ext)
bin_ext=""
if [[ "$$os" == "windows" ]]; then
bin_ext=".exe"
fi
./scripts/archive.sh \
--format "$$ext" \
--os "$$os" \
--output "$@" \
"build/coder_$(VERSION)_$${os}_$${arch}$${bin_ext}"
# This task builds all packages. It parses the target name to get the metadata
# for the build, so it must be specified in this format:
# build/coder_${version}_linux_${arch}.${format}
#
# Supports apk, deb, rpm for all linux targets.
#
# This depends on all Linux fat binaries and archives because it's difficult to
# do dynamic dependencies due to the extensions in the filenames. These targets
# are typically only used during release anyways.
#
# Packages need to run after the archives are built, otherwise they cause tar
# errors like "file changed as we read it".
CODER_PACKAGE_DEPS := $(foreach os_arch, $(PACKAGE_OS_ARCHES), build/coder_$(VERSION)_$(os_arch) build/coder_$(VERSION)_$(os_arch).tar.gz)
$(CODER_ALL_PACKAGES): $(CODER_PACKAGE_DEPS)
$(get-mode-os-arch-ext)
./scripts/package.sh \
--arch "$$arch" \
--format "$$ext" \
--version "$(VERSION)" \
--output "$@" \
"build/coder_$(VERSION)_$${os}_$${arch}"
# This task builds a Windows amd64 installer. Depends on makensis.
build/coder_$(VERSION)_windows_amd64_installer.exe: build/coder_$(VERSION)_windows_amd64.exe
./scripts/build_windows_installer.sh \
--version "$(VERSION)" \
--output "$@" \
"$<"
# Redirect from version-less Docker image targets to the versioned ones.
#
# Called like this:
# make build/coder_linux_amd64.tag
$(CODER_ALL_NOVERSION_IMAGES): build/coder_%: build/coder_$(VERSION)_%
.PHONY: $(CODER_ALL_NOVERSION_IMAGES)
# Redirect from version-less push Docker image targets to the versioned ones.
#
# Called like this:
# make push/build/coder_linux_amd64.tag
$(CODER_ALL_NOVERSION_IMAGES_PUSHED): push/build/coder_%: push/build/coder_$(VERSION)_%
.PHONY: $(CODER_ALL_NOVERSION_IMAGES_PUSHED)
# This task builds all Docker images. It parses the target name to get the
# metadata for the build, so it must be specified in this format:
# build/coder_${version}_${os}_${arch}.tag
#
# Supports linux_amd64, linux_arm64, linux_armv7.
#
# Images need to run after the archives and packages are built, otherwise they
# cause errors like "file changed as we read it".
$(CODER_ARCH_IMAGES): build/coder_$(VERSION)_%.tag: \
build/coder_$(VERSION)_% \
build/coder_$(VERSION)_%.apk \
build/coder_$(VERSION)_%.deb \
build/coder_$(VERSION)_%.rpm \
build/coder_$(VERSION)_%.tar.gz
$(get-mode-os-arch-ext)
image_tag="$$(./scripts/image_tag.sh --arch "$$arch" --version "$(VERSION)")"
./scripts/build_docker.sh \
--arch "$$arch" \
--target "$$image_tag" \
--version "$(VERSION)" \
"build/coder_$(VERSION)_$${os}_$${arch}"
echo "$$image_tag" > "$@"
# Multi-arch Docker image. This requires all architecture-specific images to be
# built AND pushed.
$(CODER_MAIN_IMAGE): $(CODER_ARCH_IMAGES_PUSHED)
image_tag="$$(./scripts/image_tag.sh --version "$(VERSION)")"
./scripts/build_docker_multiarch.sh \
--target "$$image_tag" \
--version "$(VERSION)" \
$(foreach img, $^, "$$(cat "$(img:push/%=%)")")
echo "$$image_tag" > "$@"
# Push a Docker image.
$(CODER_ARCH_IMAGES_PUSHED): push/%: %
image_tag="$$(cat "$<")"
docker push "$$image_tag"
.PHONY: $(CODER_ARCH_IMAGES_PUSHED)
# Push the multi-arch Docker manifest.
push/$(CODER_MAIN_IMAGE): $(CODER_MAIN_IMAGE)
image_tag="$$(cat "$<")"
docker manifest push "$$image_tag"
.PHONY: push/$(CODER_MAIN_IMAGE)
# Shortcut for Helm chart package.
build/coder_helm.tgz: build/coder_helm_$(VERSION).tgz
rm -f "$@"
ln "$<" "$@"
# Helm chart package.
build/coder_helm_$(VERSION).tgz:
./scripts/helm.sh \
--version "$(VERSION)" \
--output "$@"
site/out/index.html: site/package.json $(shell find ./site $(FIND_EXCLUSIONS) -type f \( -name '*.ts' -o -name '*.tsx' \))
./scripts/yarn_install.sh
cd site
yarn build
install: build/coder_$(VERSION)_$(GOOS)_$(GOARCH)$(GOOS_BIN_EXT)
install_dir="$$(go env GOPATH)/bin"
output_file="$${install_dir}/coder$(GOOS_BIN_EXT)"
mkdir -p "$$install_dir"
cp "$<" "$$output_file"
.PHONY: install
fmt: fmt/prettier fmt/terraform fmt/shfmt
.PHONY: fmt
fmt/prettier:
@echo "--- prettier"
echo "--- prettier"
cd site
# Avoid writing files in CI to reduce file write activity
ifdef CI
cd site && yarn run format:check
yarn run format:check
else
cd site && yarn run format:write
yarn run format:write
endif
.PHONY: fmt/prettier
fmt/sql: ./coderd/database/query.sql
npx sql-formatter \
--language postgresql \
--lines-between-queries 2 \
./coderd/database/query.sql \
--output ./coderd/database/query.sql
sed -i 's/@ /@/g' ./coderd/database/query.sql
fmt/terraform: $(wildcard *.tf)
terraform fmt -recursive
.PHONY: fmt/terraform
fmt: fmt/prettier fmt/sql
.PHONY: fmt
fmt/shfmt: $(SHELL_SRC_FILES)
echo "--- shfmt"
# Only do diff check in CI, errors on diff.
ifdef CI
shfmt -d $(SHELL_SRC_FILES)
else
shfmt -w $(SHELL_SRC_FILES)
endif
.PHONY: fmt/shfmt
gen: coderd/database/generate peerbroker/proto provisionersdk/proto provisionerd/proto
.PHONY: gen
install: bin
@echo "--- Copying from bin to $(INSTALL_DIR)"
cp -r ./dist/coder_$(GOOS)_$(GOARCH)/* $(INSTALL_DIR)
@echo "-- CLI available at $(shell ls $(INSTALL_DIR)/coder*)"
.PHONY: install
lint:
golangci-lint run
lint: lint/shellcheck lint/go
.PHONY: lint
peerbroker/proto: peerbroker/proto/peerbroker.proto
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./peerbroker/proto/peerbroker.proto
.PHONY: peerbroker/proto
lint/go:
./scripts/check_enterprise_imports.sh
golangci-lint run
.PHONY: lint/go
provisionerd/proto: provisionerd/proto/provisionerd.proto
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./provisionerd/proto/provisionerd.proto
.PHONY: provisionerd/proto
# Use shfmt to determine the shell files, takes editorconfig into consideration.
lint/shellcheck: $(SHELL_SRC_FILES)
echo "--- shellcheck"
shellcheck --external-sources $(SHELL_SRC_FILES)
.PHONY: lint/shellcheck
provisionersdk/proto: provisionersdk/proto/provisioner.proto
# 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 \
site/src/api/typesGenerated.ts \
docs/admin/prometheus.md \
coderd/apidoc/swagger.json \
.prettierignore.include \
.prettierignore \
site/.prettierrc.yaml \
site/.prettierignore \
site/.eslintignore
.PHONY: gen
# Mark all generated files as fresh so make thinks they're up-to-date. This is
# used during releases so we don't run generation scripts.
gen/mark-fresh:
files="\
coderd/database/dump.sql \
coderd/database/querier.go \
provisionersdk/proto/provisioner.pb.go \
provisionerd/proto/provisionerd.pb.go \
site/src/api/typesGenerated.ts \
docs/admin/prometheus.md \
coderd/apidoc/swagger.json \
.prettierignore.include \
.prettierignore \
site/.prettierrc.yaml \
site/.prettierignore \
site/.eslintignore \
"
for file in $$files; do
echo "$$file"
if [ ! -f "$$file" ]; then
echo "File '$$file' does not exist"
exit 1
fi
# touch sets the mtime of the file to the current time
touch $$file
done
.PHONY: gen/mark-fresh
# Runs migrations to output a dump of the database schema after migrations are
# applied.
coderd/database/dump.sql: coderd/database/gen/dump/main.go $(wildcard coderd/database/migrations/*.sql)
go run ./coderd/database/gen/dump/main.go
# Generates Go code for querying the database.
coderd/database/querier.go: coderd/database/sqlc.yaml coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql) coderd/database/gen/enum/main.go
./coderd/database/generate.sh
provisionersdk/proto/provisioner.pb.go: provisionersdk/proto/provisioner.proto
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./provisionersdk/proto/provisioner.proto
.PHONY: provisionersdk/proto
release: site/out
goreleaser release --snapshot --rm-dist
.PHONY: release
provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./provisionerd/proto/provisionerd.proto
site/out:
./scripts/yarn_install.sh
cd site && yarn typegen
cd site && yarn build
# Restores GITKEEP files!
git checkout HEAD site/out
.PHONY: site/out
site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
cd site
yarn run format:types
test:
gotestsum -- -v -short ./...
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
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen -not \( -path './scripts/apidocgen/node_modules' -prune \) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) .swaggo
./scripts/apidocgen/generate.sh
cd site
yarn run format:write:only ../docs/api ../docs/manifest.json ../coderd/apidoc/swagger.json
update-golden-files: cli/testdata/.gen-golden
.PHONY: update-golden-files
cli/testdata/.gen-golden: $(wildcard cli/testdata/*.golden) $(GO_SRC_FILES)
go test ./cli -run=TestCommandHelp -update
touch "$@"
# Generate a prettierrc for the site package that uses relative paths for
# overrides. This allows us to share the same prettier config between the
# site and the root of the repo.
site/.prettierrc.yaml: .prettierrc.yaml
. ./scripts/lib.sh
dependencies yq
echo "# Code generated by Makefile (../$<). DO NOT EDIT." > "$@"
echo "" >> "$@"
# Replace all listed override files with relative paths inside site/.
# - ./ -> ../
# - ./site -> ./
yq \
'.overrides[].files |= map(. | sub("^./"; "") | sub("^"; "../") | sub("../site/"; "./"))' \
"$<" >> "$@"
# Combine .gitignore with .prettierignore.include to generate .prettierignore.
.prettierignore: .gitignore .prettierignore.include
echo "# Code generated by Makefile ($^). DO NOT EDIT." > "$@"
echo "" >> "$@"
for f in $^; do
echo "# $${f}:" >> "$@"
cat "$$f" >> "$@"
done
# Generate ignore files based on gitignore into the site directory. We turn all
# rules into relative paths for the `site/` directory (where applicable),
# following the pattern format defined by git:
# https://git-scm.com/docs/gitignore#_pattern_format
#
# This is done for compatibility reasons, see:
# https://github.com/prettier/prettier/issues/8048
# https://github.com/prettier/prettier/issues/8506
# https://github.com/prettier/prettier/issues/8679
site/.eslintignore site/.prettierignore: .prettierignore Makefile
rm -f "$@"
touch "$@"
# Skip generated by header, inherit `.prettierignore` header as-is.
while read -r rule; do
# Remove leading ! if present to simplify rule, added back at the end.
tmp="$${rule#!}"
ignore="$${rule%"$$tmp"}"
rule="$$tmp"
case "$$rule" in
# Comments or empty lines (include).
\#*|'') ;;
# Generic rules (include).
\*\**) ;;
# Site prefixed rules (include).
site/*) rule="$${rule#site/}";;
./site/*) rule="$${rule#./site/}";;
# Rules that are non-generic and don't start with site (rewrite).
/*) rule=.."$$rule";;
*/?*) rule=../"$$rule";;
*) ;;
esac
echo "$${ignore}$${rule}" >> "$@"
done < "$<"
test: test-clean
gotestsum --debug -- -v -short ./...
.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
# 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="gotestsum.json" \
--packages="./..." -- \
-covermode=atomic -coverprofile="gotests.coverage" -timeout=20m \
-parallel=4 \
-coverpkg=./... \
-count=1 -race -failfast
.PHONY: test-postgres
test-postgres-docker:
docker rm -f test-postgres-docker || true
docker run \
--env POSTGRES_PASSWORD=postgres \
--env POSTGRES_USER=postgres \
--env POSTGRES_DB=postgres \
--env PGDATA=/tmp \
--tmpfs /tmp \
--publish 5432:5432 \
--name test-postgres-docker \
--restart no \
--detach \
postgres:13 \
-c shared_buffers=1GB \
-c max_connections=1000 \
-c fsync=off \
-c synchronous_commit=off \
-c full_page_writes=off
while ! pg_isready -h 127.0.0.1
do
echo "$(date) - waiting for database to start"
sleep 0.5
done
.PHONY: test-postgres-docker
test-clean:
go clean -testcache
.PHONY: test-clean
+95 -34
View File
@@ -1,64 +1,125 @@
# Coder
[!["GitHub Discussions"](https://img.shields.io/badge/%20GitHub-%20Discussions-gray.svg?longCache=true&logo=github&colorB=purple)](https://github.com/coder/coder/discussions) [!["Join us on Slack"](https://img.shields.io/badge/join-us%20on%20slack-gray.svg?longCache=true&logo=slack&colorB=brightgreen)](https://coder.com/community) [![Twitter Follow](https://img.shields.io/twitter/follow/CoderHQ?label=%40CoderHQ&style=social)](https://twitter.com/coderhq) [![codecov](https://codecov.io/gh/coder/coder/branch/main/graph/badge.svg?token=TNLW3OAP6G)](https://codecov.io/gh/coder/coder)
[!["Join us on
Discord"](https://img.shields.io/badge/join-us%20on%20Discord-gray.svg?longCache=true&logo=discord&colorB=green)](https://coder.com/chat?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md)
[![codecov](https://codecov.io/gh/coder/coder/branch/main/graph/badge.svg?token=TNLW3OAP6G)](https://codecov.io/gh/coder/coder)
[![Go Reference](https://pkg.go.dev/badge/github.com/coder/coder.svg)](https://pkg.go.dev/github.com/coder/coder)
[![Twitter
Follow](https://img.shields.io/twitter/follow/coderhq?label=%40coderhq&style=social)](https://twitter.com/coderhq)
Provision remote development environments with Terraform.
Software development on your infrastructure. Offload your team's development from local workstations to cloud servers. Onboard developers in minutes. Build, test and compile at the speed of the cloud. Keep your source code and data behind your firewall.
## Highlights
> "By leveraging Terraform, Coder lets developers run any IDE on any compute platform including on-prem, AWS, Azure, GCP, DigitalOcean, Kubernetes, Docker, and more, with workspaces running on Linux, Windows, or Mac." - **Kevin Fishner Chief of Staff at [HashiCorp](https://hashicorp.com/)**
- Automate development environments for Linux, Windows, and MacOS in your cloud
- Start writing code with a single command
- Use one of many [examples](./examples) to get started
<p align="center">
<img src="./docs/images/hero-image.png">
</p>
**Manage less**
- Ensure your entire team is using the same tools and resources
- Rollout critical updates to your developers with one command
- Automatically shut down expensive cloud resources
- Keep your source code and data behind your firewall
**Code more**
- Build and test faster
- Leveraging cloud CPUs, RAM, network speeds, etc.
- Access your environment from any place on any client (even an iPad)
- Onboard instantly then stay up to date continuously
## Recommended Reading
- [How our development team shares one giant bare metal machine](https://coder.com/blog/how-our-development-team-shares-one-giant-bare-metal-machine?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md)
- [Laptop development is dead: why remote development is the future](https://medium.com/@elliotgraebert/laptop-development-is-dead-why-remote-development-is-the-future-f92ce103fd13)
- [Learn how Palantir improved build times by 78% with coder](https://blog.palantir.com/the-benefits-of-remote-ephemeral-workspaces-1a1251ed6e53).
- [A software development environment is not just a container](https://coder.com/blog/not-a-container?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md).
- [What Coder is not](https://coder.com/docs/coder-oss/latest/index#what-coder-is-not?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md).
## Getting Started
Install [the latest release](https://github.com/coder/coder/releases).
The easiest way to install Coder is to use our
[install script](https://github.com/coder/coder/blob/main/install.sh) for Linux
and macOS. For Windows, use the latest `..._installer.exe` file from GitHub
Releases.
To tinker, start with dev-mode (all data is in-memory, and is destroyed on exit):
To install, run:
```bash
$ coder start --dev
curl -L https://coder.com/install.sh | sh
```
To run a production deployment with PostgreSQL:
You can preview what occurs during the install process:
```bash
$ CODER_PG_CONNECTION_URL="postgres://<username>@<host>/<database>?password=<password>" \
coder start
curl -L https://coder.com/install.sh | sh -s -- --dry-run
```
To run as a system service, install with `.deb` or `.rpm`:
You can modify the installation process by including flags. Run the help command for reference:
```bash
# Edit the configuration!
$ sudo vim /etc/coder.d/coder.env
$ sudo service coder restart
curl -L https://coder.com/install.sh | sh -s -- --help
```
### Your First Workspace
> See [install](docs/install) for additional methods.
In a new terminal, create a new project (eg. Develop in Linux on Google Cloud):
Once installed, you can start a production deployment<sup>1</sup> with a single command:
```
$ coder projects init
$ coder projects create
```console
# Automatically sets up an external access URL on *.try.coder.app
coder server
# Requires a PostgreSQL instance (version 13 or higher) and external access URL
coder server --postgres-url <url> --access-url <url>
```
Create a new workspace and SSH in:
> <sup>1</sup> The embedded database is great for trying out Coder with small deployments, but do consider using an external database for increased assurance and control.
```
$ coder workspaces create my-first-workspace
$ coder ssh my-first-workspace
```
Use `coder --help` to get a complete list of flags and environment variables. Use our [quickstart guide](https://coder.com/docs/coder-oss/latest/quickstart) for a full walkthrough.
## Development
## Documentation
The code structure is inspired by [Basics of Unix Philosophy](https://homepage.cs.uri.edu/~thenry/resources/unix_art/ch01s06.html) and [Effective Go](https://go.dev/doc/effective_go).
Visit our docs [here](https://coder.com/docs/coder-oss).
Coder requires Go 1.18+, Node 14+, and GNU Make.
## Templates
- `make bin` builds binaries
- `make install` installs binaries to `$GOPATH/bin`
- `make test`
- `make release` dry-runs a new release
- `./develop.sh` hot-reloads for frontend development
Find our templates [here](./examples/templates).
## Comparison
Please file [an issue](https://github.com/coder/coder/issues/new) if any information is out of date. Also refer to:
- [What Coder is not](https://coder.com/docs/coder-oss/latest/index#what-coder-is-not?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md).
- [The Self-Hosting Paradox](https://coder.com/blog/the-self-hosting-paradox?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md).
- [GitHub Codespaces, Coder, and Enterprise Customers](https://coder.com/blog/github-codespaces-coder-and-enterprise-customers?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md)
- [How our development team shares one giant bare metal machine](https://coder.com/blog/how-our-development-team-shares-one-giant-bare-metal-machine?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md).
| Tool | Type | Delivery Model | Cost | Internet Access Required | Latency and Data Sovereignty | Security isolation model | Product quality | Service Availability | Environments | IDE |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Coder](https://coder.com/blog/how-our-development-team-shares-one-giant-bare-metal-machine?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md) | Platform | OSS + Self-Managed | Pay your cloud | No | Self-Hosted | Unopinionated (whatever/wherever you choose to deploy thus 100% configurable) | [Defect history](https://github.com/coder/coder/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug) | Self-Hosted | All [Terraform](https://www.terraform.io/registry/providers) resources, all clouds, multi-architecture: Linux, Mac, Windows, containers, VMs, amd64, arm64 | Anything (vim, emacs, theia, code-server, openvscode-server, entire jetbrains suite inc gateway remote development, visual studio code desktop, visual studio for mac, visual studio for windows) you choose to install and deploy |
| [code-server](https://coder.com/blog/code-server-multiple-users?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md) | Web IDE | OSS + Self-Managed | Pay your cloud | No | Self-Hosted | Self-Hosted docker container | [Defect history](https://github.com/coder/code-server/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug) | Self-hosted | Linux, Mac, Windows, containers, VMs, amd64, arm64 | [code-server](https://github.com/coder/code-server) (VSCode MIT) [with restrictions](https://ghuntley.com/fracture) |
| [openvscode-server](https://github.com/gitpod-io/openvscode-server) | Web IDE | OSS + Self-Managed | Pay your cloud | No | Self-Hosted | Self-Hosted docker container | [Defect history](https://github.com/gitpod-io/openvscode-server) | Self-hosted | Linux, Mac, Windows, containers, VMs, amd64 | [openvscode-server](https://github.com/gitpod-io/openvscode-server) (VSCode MIT) [with restrictions](https://ghuntley.com/fracture) |
| [Amazon CodeCatalyst](https://coder.com/blog/the-self-hosting-paradox?utm_source=github.com/coder/coder?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md) | Platform | SaaS | Pay AWS | Yes | US West (Oregon) | ["all customer multi-tenancy isolation is done through virtual machines" for security reasons](https://devclass.com/2022/12/05/interview-why-aws-prefers-vms-for-code-isolation-and-tips-on-developing-for-lambda/) | N/A | [Service Health](https://health.aws.amazon.com/health/status) | Linux Virtual Machines | Cloud9, Visual Studio Code Desktop ([no restrictions](https://ghuntley.com/fracture)) and JetBrains Gateway |
| [CodeAnywhere](https://coder.com/blog/the-self-hosting-paradox?utm_source=github.com/coder/coder?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md) | Platform | SaaS | Per user | Yes | N/A | N/A | N/A | N/A | N/A | Theia |
| [GitHub Codespaces](https://coder.com/blog/github-codespaces-coder-and-enterprise-customers?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md) | Platform | SaaS | 2x Azure Compute | Yes | Four regions (US West, US East, Europe West, Southeast Asia) | ["two codespaces are never co-located on the same VM"](https://docs.github.com/en/codespaces/codespaces-reference/security-in-github-codespaces) | N/A | [Incident History](https://www.githubstatus.com/history) | Linux Virtual Machines, [GPUs supported](https://docs.github.com/en/codespaces/developing-in-codespaces/getting-started-with-github-codespaces-for-machine-learning) | Visual Studio Code ([no restrictions](https://ghuntley.com/fracture)) and JetBrains Gateway |
| [Gitpod](https://coder.com/blog/the-self-hosting-paradox?utm_source=github.com/coder/coder?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md) | Platform | [SaaS](https://news.ycombinator.com/item?id=33907897) | [Credits](https://www.gitpod.io/pricing) | Yes | Two regions (Europe, US) | [All customers intermixed on the same machine isolated via runc](https://kinvolk.io/blog/2020/12/improving-kubernetes-and-container-security-with-user-namespaces/) | [Defect history](https://github.com/gitpod-io/gitpod/issues?q=is%3Aissue+label%3A%22type%3A+bug%22+sort%3Aupdated-desc+) | [Incident history](https://www.gitpodstatus.com/history) | Basic Linux containers, [GPUs](https://github.com/gitpod-io/gitpod/issues/10650) and [kubernetes/k3s](https://github.com/gitpod-io/gitpod/issues/4889) is not yet possible | [openvscode-server](https://github.com/gitpod-io/openvscode-server) (VSCode MIT) [with restrictions](https://ghuntley.com/fracture) inhibiting functionality of [.NET](https://www.isdotnetopen.com), [Python](https://visualstudiomagazine.com/articles/2021/11/05/vscode-python-nov21.aspx), [C](https://marketplace.visualstudio.com/items/ms-vscode.cpptools/license), [C++](https://marketplace.visualstudio.com/items/ms-vscode.cpptools/license), [Jupyter](https://visualstudiomagazine.com/articles/2021/11/05/vscode-python-nov21.aspx) and usage of [GitHub Co-pilot](https://github.com/gitpod-io/gitpod/issues/10032). Visual Studio Code Desktop ([no restrictions](https://ghuntley.com/fracture)) and JetBrains Gateway supported |
| [Google Cloud Workstations](https://coder.com/blog/the-self-hosting-paradox?utm_source=github.com/coder/coder?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md) | Platform | SaaS (Preview, not GA) | Pay Google | Yes | southamerica-west1, us-east1, us-central1, us-west1, asia-east1, asia-southeast1, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4 | N/A | N/A | Not generally available, offered in preview mode. | Linux | code-oss ([with restrictions](https://ghuntley.com/fracture)), Visual Studio Code Desktop ([no restrictions](https://ghuntley.com/fracture)) and JetBrains Gateway |
| [JetBrains Space](https://coder.com/blog/the-self-hosting-paradox?utm_source=github.com/coder/coder?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md) | Platform | SaaS + On-Prem ([Dev environments are not supported](https://www.jetbrains.com/help/space-on-premises/space-on-premises-installation.html)) | Pay JetBrains | Yes | EU Ireland region (eu-west-1) | EC2 | N/A | [Service Health](https://status.jetbrains.space/) | Linux Virtual Machines | JetBrains Suite |
| [Microsoft DevBox](https://coder.com/blog/the-self-hosting-paradox?utm_source=github.com/coder/coder?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md) | Platform | SaaS (Preview, not GA) | Pay Microsoft | Yes | Australia East, Europe West, Japan East, Canada Central, UK South, US East, US East 2, US South Central, and US West 3 | Microsoft Azure Virtual Machine | N/A | Not generally available, offered in preview mode. | Windows Virtual Machine | Any application that runs on Windows via Microsoft Remote Desktop |
_Last updated: 14/12/2022_
## Community and Support
Join our community on [Discord](https://coder.com/chat?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=readme.md) and [Twitter](https://twitter.com/coderhq)!
[Suggest improvements and report problems](https://github.com/coder/coder/issues/new/choose)
## Contributing
If you're using Coder in your organization, please try to add your company name to the [ADOPTERS.md](./ADOPTERS.md). It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.
Read the [contributing docs](https://coder.com/docs/coder-oss/latest/CONTRIBUTING).
Find our list of contributors [here](https://github.com/coder/coder/graphs/contributors).
+993 -119
View File
File diff suppressed because it is too large Load Diff
+1131 -85
View File
File diff suppressed because it is too large Load Diff
+181
View File
@@ -0,0 +1,181 @@
package agent
import (
"context"
"net/http"
"sync"
"time"
"github.com/google/uuid"
"golang.org/x/xerrors"
"cdr.dev/slog"
"github.com/coder/coder/codersdk"
"github.com/coder/retry"
)
// WorkspaceAgentApps fetches the workspace apps.
type WorkspaceAgentApps func(context.Context) ([]codersdk.WorkspaceApp, error)
// PostWorkspaceAgentAppHealth updates the workspace app health.
type PostWorkspaceAgentAppHealth func(context.Context, codersdk.PostWorkspaceAppHealthsRequest) error
// WorkspaceAppHealthReporter is a function that checks and reports the health of the workspace apps until the passed context is canceled.
type WorkspaceAppHealthReporter func(ctx context.Context)
// NewWorkspaceAppHealthReporter creates a WorkspaceAppHealthReporter that reports app health to coderd.
func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.WorkspaceApp, postWorkspaceAgentAppHealth PostWorkspaceAgentAppHealth) WorkspaceAppHealthReporter {
runHealthcheckLoop := func(ctx context.Context) error {
// no need to run this loop if no apps for this workspace.
if len(apps) == 0 {
return nil
}
hasHealthchecksEnabled := false
health := make(map[uuid.UUID]codersdk.WorkspaceAppHealth, 0)
for _, app := range apps {
if app.Health == codersdk.WorkspaceAppHealthDisabled {
continue
}
health[app.ID] = app.Health
hasHealthchecksEnabled = true
}
// no need to run this loop if no health checks are configured.
if !hasHealthchecksEnabled {
return nil
}
// run a ticker for each app health check.
var mu sync.RWMutex
failures := make(map[uuid.UUID]int, 0)
for _, nextApp := range apps {
if !shouldStartTicker(nextApp) {
continue
}
app := nextApp
go func() {
t := time.NewTicker(time.Duration(app.Healthcheck.Interval) * time.Second)
defer t.Stop()
for {
select {
case <-ctx.Done():
return
case <-t.C:
}
// we set the http timeout to the healthcheck interval to prevent getting too backed up.
client := &http.Client{
Timeout: time.Duration(app.Healthcheck.Interval) * time.Second,
}
err := func() error {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, app.Healthcheck.URL, nil)
if err != nil {
return err
}
res, err := client.Do(req)
if err != nil {
return err
}
// successful healthcheck is a non-5XX status code
_ = res.Body.Close()
if res.StatusCode >= http.StatusInternalServerError {
return xerrors.Errorf("error status code: %d", res.StatusCode)
}
return nil
}()
if err != nil {
mu.Lock()
if failures[app.ID] < int(app.Healthcheck.Threshold) {
// increment the failure count and keep status the same.
// we will change it when we hit the threshold.
failures[app.ID]++
} else {
// set to unhealthy if we hit the failure threshold.
// we stop incrementing at the threshold to prevent the failure value from increasing forever.
health[app.ID] = codersdk.WorkspaceAppHealthUnhealthy
}
mu.Unlock()
} else {
mu.Lock()
// we only need one successful health check to be considered healthy.
health[app.ID] = codersdk.WorkspaceAppHealthHealthy
failures[app.ID] = 0
mu.Unlock()
}
t.Reset(time.Duration(app.Healthcheck.Interval) * time.Second)
}
}()
}
mu.Lock()
lastHealth := copyHealth(health)
mu.Unlock()
reportTicker := time.NewTicker(time.Second)
defer reportTicker.Stop()
// every second we check if the health values of the apps have changed
// and if there is a change we will report the new values.
for {
select {
case <-ctx.Done():
return nil
case <-reportTicker.C:
mu.RLock()
changed := healthChanged(lastHealth, health)
mu.RUnlock()
if !changed {
continue
}
mu.Lock()
lastHealth = copyHealth(health)
mu.Unlock()
err := postWorkspaceAgentAppHealth(ctx, codersdk.PostWorkspaceAppHealthsRequest{
Healths: lastHealth,
})
if err != nil {
logger.Error(ctx, "failed to report workspace app stat", slog.Error(err))
}
}
}
}
return func(ctx context.Context) {
for r := retry.New(time.Second, 30*time.Second); r.Wait(ctx); {
err := runHealthcheckLoop(ctx)
if err == nil || xerrors.Is(err, context.Canceled) || xerrors.Is(err, context.DeadlineExceeded) {
return
}
logger.Error(ctx, "failed running workspace app reporter", slog.Error(err))
}
}
}
func shouldStartTicker(app codersdk.WorkspaceApp) bool {
return app.Healthcheck.URL != "" && app.Healthcheck.Interval > 0 && app.Healthcheck.Threshold > 0
}
func healthChanged(old map[uuid.UUID]codersdk.WorkspaceAppHealth, new map[uuid.UUID]codersdk.WorkspaceAppHealth) bool {
for name, newValue := range new {
oldValue, found := old[name]
if !found {
return true
}
if newValue != oldValue {
return true
}
}
return false
}
func copyHealth(h1 map[uuid.UUID]codersdk.WorkspaceAppHealth) map[uuid.UUID]codersdk.WorkspaceAppHealth {
h2 := make(map[uuid.UUID]codersdk.WorkspaceAppHealth, 0)
for k, v := range h1 {
h2[k] = v
}
return h2
}
+206
View File
@@ -0,0 +1,206 @@
package agent_test
import (
"context"
"net/http"
"net/http/httptest"
"sync"
"sync/atomic"
"testing"
"time"
"github.com/stretchr/testify/require"
"cdr.dev/slog"
"cdr.dev/slog/sloggers/slogtest"
"github.com/coder/coder/agent"
"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/testutil"
)
func TestAppHealth_Healthy(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
apps := []codersdk.WorkspaceApp{
{
Slug: "app1",
Healthcheck: codersdk.Healthcheck{},
Health: codersdk.WorkspaceAppHealthDisabled,
},
{
Slug: "app2",
Healthcheck: codersdk.Healthcheck{
// URL: We don't set the URL for this test because the setup will
// create a httptest server for us and set it for us.
Interval: 1,
Threshold: 1,
},
Health: codersdk.WorkspaceAppHealthInitializing,
},
}
handlers := []http.Handler{
nil,
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), w, http.StatusOK, nil)
}),
}
getApps, closeFn := setupAppReporter(ctx, t, apps, handlers)
defer closeFn()
apps, err := getApps(ctx)
require.NoError(t, err)
require.EqualValues(t, codersdk.WorkspaceAppHealthDisabled, apps[0].Health)
require.Eventually(t, func() bool {
apps, err := getApps(ctx)
if err != nil {
return false
}
return apps[1].Health == codersdk.WorkspaceAppHealthHealthy
}, testutil.WaitLong, testutil.IntervalSlow)
}
func TestAppHealth_500(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
apps := []codersdk.WorkspaceApp{
{
Slug: "app2",
Healthcheck: codersdk.Healthcheck{
// URL: We don't set the URL for this test because the setup will
// create a httptest server for us and set it for us.
Interval: 1,
Threshold: 1,
},
Health: codersdk.WorkspaceAppHealthInitializing,
},
}
handlers := []http.Handler{
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), w, http.StatusInternalServerError, nil)
}),
}
getApps, closeFn := setupAppReporter(ctx, t, apps, handlers)
defer closeFn()
require.Eventually(t, func() bool {
apps, err := getApps(ctx)
if err != nil {
return false
}
return apps[0].Health == codersdk.WorkspaceAppHealthUnhealthy
}, testutil.WaitLong, testutil.IntervalSlow)
}
func TestAppHealth_Timeout(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
apps := []codersdk.WorkspaceApp{
{
Slug: "app2",
Healthcheck: codersdk.Healthcheck{
// URL: We don't set the URL for this test because the setup will
// create a httptest server for us and set it for us.
Interval: 1,
Threshold: 1,
},
Health: codersdk.WorkspaceAppHealthInitializing,
},
}
handlers := []http.Handler{
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// sleep longer than the interval to cause the health check to time out
time.Sleep(2 * time.Second)
httpapi.Write(r.Context(), w, http.StatusOK, nil)
}),
}
getApps, closeFn := setupAppReporter(ctx, t, apps, handlers)
defer closeFn()
require.Eventually(t, func() bool {
apps, err := getApps(ctx)
if err != nil {
return false
}
return apps[0].Health == codersdk.WorkspaceAppHealthUnhealthy
}, testutil.WaitLong, testutil.IntervalSlow)
}
func TestAppHealth_NotSpamming(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
apps := []codersdk.WorkspaceApp{
{
Slug: "app2",
Healthcheck: codersdk.Healthcheck{
// URL: We don't set the URL for this test because the setup will
// create a httptest server for us and set it for us.
Interval: 1,
Threshold: 1,
},
Health: codersdk.WorkspaceAppHealthInitializing,
},
}
counter := new(int32)
handlers := []http.Handler{
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
atomic.AddInt32(counter, 1)
}),
}
_, closeFn := setupAppReporter(ctx, t, apps, handlers)
defer closeFn()
// Ensure we haven't made more than 2 (expected 1 + 1 for buffer) requests in the last second.
// if there is a bug where we are spamming the healthcheck route this will catch it.
time.Sleep(time.Second)
require.LessOrEqual(t, *counter, int32(2))
}
func setupAppReporter(ctx context.Context, t *testing.T, apps []codersdk.WorkspaceApp, handlers []http.Handler) (agent.WorkspaceAgentApps, func()) {
closers := []func(){}
for i, handler := range handlers {
if handler == nil {
continue
}
ts := httptest.NewServer(handler)
app := apps[i]
app.Healthcheck.URL = ts.URL
apps[i] = app
closers = append(closers, ts.Close)
}
var mu sync.Mutex
workspaceAgentApps := func(context.Context) ([]codersdk.WorkspaceApp, error) {
mu.Lock()
defer mu.Unlock()
var newApps []codersdk.WorkspaceApp
return append(newApps, apps...), nil
}
postWorkspaceAgentAppHealth := func(_ context.Context, req codersdk.PostWorkspaceAppHealthsRequest) error {
mu.Lock()
for id, health := range req.Healths {
for i, app := range apps {
if app.ID != id {
continue
}
app.Health = health
apps[i] = app
}
}
mu.Unlock()
return nil
}
go agent.NewWorkspaceAppHealthReporter(slogtest.Make(t, nil).Leveled(slog.LevelDebug), apps, postWorkspaceAgentAppHealth)(ctx)
return workspaceAgentApps, func() {
for _, closeFn := range closers {
closeFn()
}
}
}
-56
View File
@@ -1,56 +0,0 @@
package agent
import (
"context"
"net"
"golang.org/x/crypto/ssh"
"golang.org/x/xerrors"
"github.com/coder/coder/peer"
"github.com/coder/coder/peerbroker/proto"
)
// Conn wraps a peer connection with helper functions to
// communicate with the agent.
type Conn struct {
// Negotiator is responsible for exchanging messages.
Negotiator proto.DRPCPeerBrokerClient
*peer.Conn
}
// SSH dials the built-in SSH server.
func (c *Conn) SSH() (net.Conn, error) {
channel, err := c.Dial(context.Background(), "ssh", &peer.ChannelOptions{
Protocol: "ssh",
})
if err != nil {
return nil, xerrors.Errorf("dial: %w", err)
}
return channel.NetConn(), nil
}
// SSHClient calls SSH to create a client that uses a weak cipher
// for high throughput.
func (c *Conn) SSHClient() (*ssh.Client, error) {
netConn, err := c.SSH()
if err != nil {
return nil, xerrors.Errorf("ssh: %w", err)
}
sshConn, channels, requests, err := ssh.NewClientConn(netConn, "localhost:22", &ssh.ClientConfig{
// SSH host validation isn't helpful, because obtaining a peer
// connection already signifies user-intent to dial a workspace.
// #nosec
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
})
if err != nil {
return nil, xerrors.Errorf("ssh conn: %w", err)
}
return ssh.NewClient(sshConn, channels, requests), nil
}
func (c *Conn) Close() error {
_ = c.Negotiator.DRPCConn().Close()
return c.Conn.Close()
}
+64
View File
@@ -0,0 +1,64 @@
//go:build linux || (windows && amd64)
package agent
import (
"time"
"github.com/cakturk/go-netstat/netstat"
"golang.org/x/xerrors"
"github.com/coder/coder/codersdk"
)
func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.ListeningPort, error) {
lp.mut.Lock()
defer lp.mut.Unlock()
if time.Since(lp.mtime) < time.Second {
// copy
ports := make([]codersdk.ListeningPort, len(lp.ports))
copy(ports, lp.ports)
return ports, nil
}
tabs, err := netstat.TCPSocks(func(s *netstat.SockTabEntry) bool {
return s.State == netstat.Listen
})
if err != nil {
return nil, xerrors.Errorf("scan listening ports: %w", err)
}
seen := make(map[uint16]struct{}, len(tabs))
ports := []codersdk.ListeningPort{}
for _, tab := range tabs {
if tab.LocalAddr == nil || tab.LocalAddr.Port < codersdk.MinimumListeningPort {
continue
}
// Don't include ports that we've already seen. This can happen on
// Windows, and maybe on Linux if you're using a shared listener socket.
if _, ok := seen[tab.LocalAddr.Port]; ok {
continue
}
seen[tab.LocalAddr.Port] = struct{}{}
procName := ""
if tab.Process != nil {
procName = tab.Process.Name
}
ports = append(ports, codersdk.ListeningPort{
ProcessName: procName,
Network: codersdk.ListeningPortNetworkTCP,
Port: tab.LocalAddr.Port,
})
}
lp.ports = ports
lp.mtime = time.Now()
// copy
ports = make([]codersdk.ListeningPort, len(lp.ports))
copy(ports, lp.ports)
return ports, nil
}
+12
View File
@@ -0,0 +1,12 @@
//go:build !linux && !(windows && amd64)
package agent
import "github.com/coder/coder/codersdk"
func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.ListeningPort, error) {
// Can't scan for ports on non-linux or non-windows_amd64 systems at the
// moment. The UI will not show any "no ports found" message to the user, so
// the user won't suspect a thing.
return []codersdk.ListeningPort{}, nil
}
+4
View File
@@ -0,0 +1,4 @@
// Package reaper contains logic for reaping subprocesses. It is
// specifically used in the agent to avoid the accumulation of
// zombie processes.
package reaper
+28
View File
@@ -0,0 +1,28 @@
package reaper
import "github.com/hashicorp/go-reap"
type Option func(o *options)
// WithExecArgs specifies the exec arguments for the fork exec call.
// By default the same arguments as the parent are used as dictated by
// os.Args. Since ForkReap calls a fork-exec it is the responsibility of
// the caller to avoid fork-bombing oneself.
func WithExecArgs(args ...string) Option {
return func(o *options) {
o.ExecArgs = args
}
}
// WithPIDCallback sets the channel that reaped child process PIDs are pushed
// onto.
func WithPIDCallback(ch reap.PidCh) Option {
return func(o *options) {
o.PIDs = ch
}
}
type options struct {
ExecArgs []string
PIDs reap.PidCh
}
+12
View File
@@ -0,0 +1,12 @@
//go:build !linux
package reaper
// IsInitProcess returns true if the current process's PID is 1.
func IsInitProcess() bool {
return false
}
func ForkReap(_ ...Option) error {
return nil
}
+66
View File
@@ -0,0 +1,66 @@
//go:build linux
package reaper_test
import (
"os"
"os/exec"
"testing"
"time"
"github.com/hashicorp/go-reap"
"github.com/stretchr/testify/require"
"github.com/coder/coder/agent/reaper"
"github.com/coder/coder/testutil"
)
func TestReap(t *testing.T) {
t.Parallel()
// 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 {
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.
t.Run("OK", func(t *testing.T) {
t.Parallel()
pids := make(reap.PidCh, 1)
err := reaper.ForkReap(
reaper.WithPIDCallback(pids),
// Provide some argument that immediately exits.
reaper.WithExecArgs("/bin/sh", "-c", "exit 0"),
)
require.NoError(t, err)
cmd := exec.Command("tail", "-f", "/dev/null")
err = cmd.Start()
require.NoError(t, err)
cmd2 := exec.Command("tail", "-f", "/dev/null")
err = cmd2.Start()
require.NoError(t, err)
err = cmd.Process.Kill()
require.NoError(t, err)
err = cmd2.Process.Kill()
require.NoError(t, err)
expectedPIDs := []int{cmd.Process.Pid, cmd2.Process.Pid}
for i := 0; i < len(expectedPIDs); i++ {
select {
case <-time.After(testutil.WaitShort):
t.Fatalf("Timed out waiting for process")
case pid := <-pids:
require.Contains(t, expectedPIDs, pid)
}
}
})
}
+63
View File
@@ -0,0 +1,63 @@
//go:build linux
package reaper
import (
"os"
"syscall"
"github.com/hashicorp/go-reap"
"golang.org/x/xerrors"
)
// IsInitProcess returns true if the current process's PID is 1.
func IsInitProcess() bool {
return os.Getpid() == 1
}
// ForkReap spawns a goroutine that reaps children. In order to avoid
// complications with spawning `exec.Commands` in the same process that
// is reaping, we forkexec a child process. This prevents a race between
// the reaper and an exec.Command waiting for its process to complete.
// The provided 'pids' channel may be nil if the caller does not care about the
// reaped children PIDs.
func ForkReap(opt ...Option) error {
opts := &options{
ExecArgs: os.Args,
}
for _, o := range opt {
o(opts)
}
go reap.ReapChildren(opts.PIDs, nil, nil, nil)
pwd, err := os.Getwd()
if err != nil {
return xerrors.Errorf("get wd: %w", err)
}
pattrs := &syscall.ProcAttr{
Dir: pwd,
Env: os.Environ(),
Sys: &syscall.SysProcAttr{
Setsid: true,
},
Files: []uintptr{
uintptr(syscall.Stdin),
uintptr(syscall.Stdout),
uintptr(syscall.Stderr),
},
}
//#nosec G204
pid, _ := syscall.ForkExec(opts.ExecArgs[0], opts.ExecArgs, pattrs)
var wstatus syscall.WaitStatus
_, err = syscall.Wait4(pid, &wstatus, 0, nil)
for xerrors.Is(err, syscall.EINTR) {
_, err = syscall.Wait4(pid, &wstatus, 0, nil)
}
return nil
}
+203
View File
@@ -0,0 +1,203 @@
package agent
import (
"context"
"fmt"
"net"
"os"
"path/filepath"
"sync"
"github.com/gliderlabs/ssh"
gossh "golang.org/x/crypto/ssh"
"golang.org/x/xerrors"
"cdr.dev/slog"
)
// streamLocalForwardPayload describes the extra data sent in a
// streamlocal-forward@openssh.com containing the socket path to bind to.
type streamLocalForwardPayload struct {
SocketPath string
}
// forwardedStreamLocalPayload describes the data sent as the payload in the new
// channel request when a Unix connection is accepted by the listener.
type forwardedStreamLocalPayload struct {
SocketPath string
Reserved uint32
}
// forwardedUnixHandler is a clone of ssh.ForwardedTCPHandler that does
// streamlocal forwarding (aka. unix forwarding) instead of TCP forwarding.
type forwardedUnixHandler struct {
sync.Mutex
log slog.Logger
forwards map[string]net.Listener
}
func (h *forwardedUnixHandler) HandleSSHRequest(ctx ssh.Context, _ *ssh.Server, req *gossh.Request) (bool, []byte) {
h.Lock()
if h.forwards == nil {
h.forwards = make(map[string]net.Listener)
}
h.Unlock()
conn, ok := ctx.Value(ssh.ContextKeyConn).(*gossh.ServerConn)
if !ok {
h.log.Warn(ctx, "SSH unix forward request from client with no gossh connection")
return false, nil
}
switch req.Type {
case "streamlocal-forward@openssh.com":
var reqPayload streamLocalForwardPayload
err := gossh.Unmarshal(req.Payload, &reqPayload)
if err != nil {
h.log.Warn(ctx, "parse streamlocal-forward@openssh.com request payload from client", slog.Error(err))
return false, nil
}
addr := reqPayload.SocketPath
h.Lock()
_, ok := h.forwards[addr]
h.Unlock()
if ok {
h.log.Warn(ctx, "SSH unix forward request for socket path that is already being forwarded (maybe to another client?)",
slog.F("socket_path", addr),
)
return false, nil
}
// Create socket parent dir if not exists.
parentDir := filepath.Dir(addr)
err = os.MkdirAll(parentDir, 0700)
if err != nil {
h.log.Warn(ctx, "create parent dir for SSH unix forward request",
slog.F("parent_dir", parentDir),
slog.F("socket_path", addr),
slog.Error(err),
)
return false, nil
}
ln, err := net.Listen("unix", addr)
if err != nil {
h.log.Warn(ctx, "listen on Unix socket for SSH unix forward request",
slog.F("socket_path", addr),
slog.Error(err),
)
return false, nil
}
// The listener needs to successfully start before it can be added to
// the map, so we don't have to worry about checking for an existing
// listener.
//
// This is also what the upstream TCP version of this code does.
h.Lock()
h.forwards[addr] = ln
h.Unlock()
ctx, cancel := context.WithCancel(ctx)
go func() {
<-ctx.Done()
_ = ln.Close()
}()
go func() {
defer cancel()
for {
c, err := ln.Accept()
if err != nil {
if !xerrors.Is(err, net.ErrClosed) {
h.log.Warn(ctx, "accept on local Unix socket for SSH unix forward request",
slog.F("socket_path", addr),
slog.Error(err),
)
}
// closed below
break
}
payload := gossh.Marshal(&forwardedStreamLocalPayload{
SocketPath: addr,
})
go func() {
ch, reqs, err := conn.OpenChannel("forwarded-streamlocal@openssh.com", payload)
if err != nil {
h.log.Warn(ctx, "open SSH channel to forward Unix connection to client",
slog.F("socket_path", addr),
slog.Error(err),
)
_ = c.Close()
return
}
go gossh.DiscardRequests(reqs)
Bicopy(ctx, ch, c)
}()
}
h.Lock()
ln2, ok := h.forwards[addr]
if ok && ln2 == ln {
delete(h.forwards, addr)
}
h.Unlock()
_ = ln.Close()
}()
return true, nil
case "cancel-streamlocal-forward@openssh.com":
var reqPayload streamLocalForwardPayload
err := gossh.Unmarshal(req.Payload, &reqPayload)
if err != nil {
h.log.Warn(ctx, "parse cancel-streamlocal-forward@openssh.com request payload from client", slog.Error(err))
return false, nil
}
h.Lock()
ln, ok := h.forwards[reqPayload.SocketPath]
h.Unlock()
if ok {
_ = ln.Close()
}
return true, nil
default:
return false, nil
}
}
// directStreamLocalPayload describes the extra data sent in a
// direct-streamlocal@openssh.com channel request containing the socket path.
type directStreamLocalPayload struct {
SocketPath string
Reserved1 string
Reserved2 uint32
}
func directStreamLocalHandler(_ *ssh.Server, _ *gossh.ServerConn, newChan gossh.NewChannel, ctx ssh.Context) {
var reqPayload directStreamLocalPayload
err := gossh.Unmarshal(newChan.ExtraData(), &reqPayload)
if err != nil {
_ = newChan.Reject(gossh.ConnectionFailed, "could not parse direct-streamlocal@openssh.com channel payload")
return
}
var dialer net.Dialer
dconn, err := dialer.DialContext(ctx, "unix", reqPayload.SocketPath)
if err != nil {
_ = newChan.Reject(gossh.ConnectionFailed, fmt.Sprintf("dial unix socket %q: %+v", reqPayload.SocketPath, err.Error()))
return
}
ch, reqs, err := newChan.Accept()
if err != nil {
_ = dconn.Close()
return
}
go gossh.DiscardRequests(reqs)
Bicopy(ctx, ch, dconn)
}
+49
View File
@@ -0,0 +1,49 @@
package agent
import (
"net/http"
"sync"
"time"
"github.com/go-chi/chi"
"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/codersdk"
)
func (*agent) statisticsHandler() http.Handler {
r := chi.NewRouter()
r.Get("/", func(rw http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.Response{
Message: "Hello from the agent!",
})
})
lp := &listeningPortsHandler{}
r.Get("/api/v0/listening-ports", lp.handler)
return r
}
type listeningPortsHandler struct {
mut sync.Mutex
ports []codersdk.ListeningPort
mtime time.Time
}
// handler returns a list of listening ports. This is tested by coderd's
// TestWorkspaceAgentListeningPorts test.
func (lp *listeningPortsHandler) handler(rw http.ResponseWriter, r *http.Request) {
ports, err := lp.getListeningPorts()
if err != nil {
httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
Message: "Could not scan for listening ports.",
Detail: err.Error(),
})
return
}
httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.ListeningPortsResponse{
Ports: ports,
})
}
+1 -3
View File
@@ -3,8 +3,6 @@ package usershell
import "os"
// Get returns the $SHELL environment variable.
// TODO: This should use "dscl" to fetch the proper value. See:
// https://stackoverflow.com/questions/16375519/how-to-get-the-default-shell
func Get(username string) (string, error) {
func Get(_ string) (string, error) {
return os.Getenv("SHELL"), nil
}
+5 -1
View File
@@ -4,7 +4,11 @@ import "os/exec"
// Get returns the command prompt binary name.
func Get(username string) (string, error) {
_, err := exec.LookPath("powershell.exe")
_, err := exec.LookPath("pwsh.exe")
if err == nil {
return "pwsh.exe", nil
}
_, err = exec.LookPath("powershell.exe")
if err == nil {
return "powershell.exe", nil
}
+126
View File
@@ -0,0 +1,126 @@
package buildinfo
import (
"fmt"
"runtime/debug"
"strings"
"sync"
"time"
"golang.org/x/mod/semver"
)
var (
buildInfo *debug.BuildInfo
buildInfoValid bool
readBuildInfo sync.Once
externalURL string
readExternalURL sync.Once
version string
readVersion sync.Once
// Injected with ldflags at build!
tag string
)
const (
// develPrefix is prefixed to developer versions of the application.
develPrefix = "v0.0.0-devel"
)
// Version returns the semantic version of the build.
// Use golang.org/x/mod/semver to compare versions.
func Version() string {
readVersion.Do(func() {
revision, valid := revision()
if valid {
revision = "+" + revision[:7]
}
if tag == "" {
// This occurs when the tag hasn't been injected,
// like when using "go run".
version = develPrefix + revision
return
}
version = "v" + tag
// The tag must be prefixed with "v" otherwise the
// semver library will return an empty string.
if semver.Build(version) == "" {
version += revision
}
})
return version
}
// VersionsMatch compares the two versions. It assumes the versions match if
// the major and the minor versions are equivalent. Patch versions are
// disregarded. If it detects that either version is a developer build it
// returns true.
func VersionsMatch(v1, v2 string) bool {
// Developer versions are disregarded...hopefully they know what they are
// doing.
if strings.HasPrefix(v1, develPrefix) || strings.HasPrefix(v2, develPrefix) {
return true
}
return semver.MajorMinor(v1) == semver.MajorMinor(v2)
}
// IsDev returns true if this is a development build.
func IsDev() bool {
return strings.HasPrefix(Version(), develPrefix)
}
// 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.
func ExternalURL() string {
readExternalURL.Do(func() {
repo := "https://github.com/coder/coder"
revision, valid := revision()
if !valid {
externalURL = repo
return
}
externalURL = fmt.Sprintf("%s/commit/%s", repo, revision)
})
return externalURL
}
// Time returns when the Git revision was published.
func Time() (time.Time, bool) {
value, valid := find("vcs.time")
if !valid {
return time.Time{}, false
}
parsed, err := time.Parse(time.RFC3339, value)
if err != nil {
panic("couldn't parse time: " + err.Error())
}
return parsed, true
}
// revision returns the Git hash of the build.
func revision() (string, bool) {
return find("vcs.revision")
}
// find panics if a setting with the specific key was not
// found in the build info.
func find(key string) (string, bool) {
readBuildInfo.Do(func() {
buildInfo, buildInfoValid = debug.ReadBuildInfo()
})
if !buildInfoValid {
panic("couldn't read build info")
}
for _, setting := range buildInfo.Settings {
if setting.Key != key {
continue
}
return setting.Value, true
}
return "", false
}
+99
View File
@@ -0,0 +1,99 @@
package buildinfo_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
"golang.org/x/mod/semver"
"github.com/coder/coder/buildinfo"
)
func TestBuildInfo(t *testing.T) {
t.Parallel()
t.Run("Version", func(t *testing.T) {
t.Parallel()
version := buildinfo.Version()
require.True(t, semver.IsValid(version))
prerelease := semver.Prerelease(version)
require.Equal(t, "-devel", prerelease)
require.Equal(t, "v0", semver.Major(version))
})
t.Run("ExternalURL", func(t *testing.T) {
t.Parallel()
require.Equal(t, "https://github.com/coder/coder", buildinfo.ExternalURL())
})
// Tests don't include Go build info.
t.Run("NoTime", func(t *testing.T) {
t.Parallel()
_, valid := buildinfo.Time()
require.False(t, valid)
})
t.Run("VersionsMatch", func(t *testing.T) {
t.Parallel()
type testcase struct {
name string
v1 string
v2 string
expectMatch bool
}
cases := []testcase{
{
name: "OK",
v1: "v1.2.3",
v2: "v1.2.3",
expectMatch: true,
},
// Test that we return true if a developer version is detected.
// Developers do not need to be warned of mismatched versions.
{
name: "DevelIgnored",
v1: "v0.0.0-devel+123abac",
v2: "v1.2.3",
expectMatch: true,
},
// Our CI instance uses a "-devel" prerelease
// flag. This is not the same as a developer WIP build.
{
name: "DevelPreleaseNotIgnored",
v1: "v1.1.1-devel+123abac",
v2: "v1.2.3",
expectMatch: false,
},
{
name: "MajorMismatch",
v1: "v1.2.3",
v2: "v0.1.2",
expectMatch: false,
},
{
name: "MinorMismatch",
v1: "v1.2.3",
v2: "v1.3.2",
expectMatch: false,
},
// Different patches are ok, breaking changes are not allowed
// in patches.
{
name: "PatchMismatch",
v1: "v1.2.3+hash.whocares",
v2: "v1.2.4+somestuff.hm.ok",
expectMatch: true,
},
}
for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
t.Parallel()
require.Equal(t, c.expectMatch, buildinfo.VersionsMatch(c.v1, c.v2),
fmt.Sprintf("expected match=%v for version %s and %s", c.expectMatch, c.v1, c.v2),
)
})
}
})
}
+183
View File
@@ -0,0 +1,183 @@
package cli
import (
"context"
"fmt"
"net/http"
"net/http/pprof"
"net/url"
"os"
"path/filepath"
"runtime"
"time"
"cloud.google.com/go/compute/metadata"
"github.com/spf13/cobra"
"golang.org/x/xerrors"
"gopkg.in/natefinch/lumberjack.v2"
"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"
)
func workspaceAgent() *cobra.Command {
var (
auth string
pprofAddress string
noReap bool
)
cmd := &cobra.Command{
Use: "agent",
// This command isn't useful to manually execute.
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithCancel(cmd.Context())
defer cancel()
go dumpHandler(ctx)
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)
}
logWriter := &lumberjack.Logger{
Filename: filepath.Join(os.TempDir(), "coder-agent.log"),
MaxSize: 5, // MB
}
defer logWriter.Close()
logger := slog.Make(sloghuman.Sink(cmd.ErrOrStderr()), sloghuman.Sink(logWriter)).Leveled(slog.LevelDebug)
isLinux := runtime.GOOS == "linux"
// Spawn a reaper so that we don't accumulate a ton
// of zombie processes.
if reaper.IsInitProcess() && !noReap && isLinux {
logger.Info(ctx, "spawning reaper process")
// Do not start a reaper on the child process. It's important
// to do this else we fork bomb ourselves.
args := append(os.Args, "--no-reap")
err := reaper.ForkReap(reaper.WithExecArgs(args...))
if err != nil {
logger.Error(ctx, "failed to reap", slog.Error(err))
return xerrors.Errorf("fork reap: %w", err)
}
logger.Info(ctx, "reaper process exiting")
return nil
}
version := buildinfo.Version()
logger.Info(ctx, "starting agent",
slog.F("url", coderURL),
slog.F("auth", auth),
slog.F("version", version),
)
client := codersdk.New(coderURL)
// Set a reasonable timeout so requests can't hang forever!
client.HTTPClient.Timeout = 10 * time.Second
// Enable pprof handler
// This prevents the pprof import from being accidentally deleted.
_ = pprof.Handler
pprofSrvClose := serveHandler(ctx, logger, nil, pprofAddress, "pprof")
defer pprofSrvClose()
// exchangeToken returns a session token.
// This is abstracted to allow for the same looping condition
// regardless of instance identity auth type.
var exchangeToken func(context.Context) (codersdk.WorkspaceAgentAuthenticateResponse, error)
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)
}
client.SetSessionToken(token)
case "google-instance-identity":
// This is *only* done for testing to mock client authentication.
// This will never be set in a production scenario.
var gcpClient *metadata.Client
gcpClientRaw := ctx.Value("gcp-client")
if gcpClientRaw != nil {
gcpClient, _ = gcpClientRaw.(*metadata.Client)
}
exchangeToken = func(ctx context.Context) (codersdk.WorkspaceAgentAuthenticateResponse, error) {
return client.AuthWorkspaceGoogleInstanceIdentity(ctx, "", gcpClient)
}
case "aws-instance-identity":
// This is *only* done for testing to mock client authentication.
// This will never be set in a production scenario.
var awsClient *http.Client
awsClientRaw := ctx.Value("aws-client")
if awsClientRaw != nil {
awsClient, _ = awsClientRaw.(*http.Client)
if awsClient != nil {
client.HTTPClient = awsClient
}
}
exchangeToken = func(ctx context.Context) (codersdk.WorkspaceAgentAuthenticateResponse, error) {
return client.AuthWorkspaceAWSInstanceIdentity(ctx)
}
case "azure-instance-identity":
// This is *only* done for testing to mock client authentication.
// This will never be set in a production scenario.
var azureClient *http.Client
azureClientRaw := ctx.Value("azure-client")
if azureClientRaw != nil {
azureClient, _ = azureClientRaw.(*http.Client)
if azureClient != nil {
client.HTTPClient = azureClient
}
}
exchangeToken = func(ctx context.Context) (codersdk.WorkspaceAgentAuthenticateResponse, error) {
return client.AuthWorkspaceAzureInstanceIdentity(ctx)
}
}
executablePath, err := os.Executable()
if err != nil {
return xerrors.Errorf("getting os executable: %w", err)
}
err = os.Setenv("PATH", fmt.Sprintf("%s%c%s", os.Getenv("PATH"), filepath.ListSeparator, filepath.Dir(executablePath)))
if err != nil {
return xerrors.Errorf("add executable to $PATH: %w", err)
}
closer := agent.New(agent.Options{
Client: client,
Logger: logger,
ExchangeToken: func(ctx context.Context) (string, error) {
if exchangeToken == nil {
return client.SessionToken(), nil
}
resp, err := exchangeToken(ctx)
if err != nil {
return "", err
}
client.SetSessionToken(resp.SessionToken)
return resp.SessionToken, nil
},
EnvironmentVariables: map[string]string{
"GIT_ASKPASS": executablePath,
},
})
<-ctx.Done()
return closer.Close()
},
}
cliflag.StringVarP(cmd.Flags(), &auth, "auth", "", "CODER_AGENT_AUTH", "token", "Specify the authentication type to use for the agent")
cliflag.BoolVarP(cmd.Flags(), &noReap, "no-reap", "", "", false, "Do not start a process reaper.")
cliflag.StringVarP(cmd.Flags(), &pprofAddress, "pprof-address", "", "CODER_AGENT_PPROF_ADDRESS", "127.0.0.1:6060", "The address to serve pprof.")
return cmd
}
+210
View File
@@ -0,0 +1,210 @@
package cli_test
import (
"context"
"runtime"
"strings"
"testing"
"github.com/google/uuid"
"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"
)
func TestWorkspaceAgent(t *testing.T) {
t.Parallel()
t.Run("Azure", func(t *testing.T) {
t.Parallel()
instanceID := "instanceidentifier"
certificates, metadataClient := coderdtest.NewAzureInstanceIdentity(t, instanceID)
client := coderdtest.New(t, &coderdtest.Options{
AzureCertificates: certificates,
IncludeProvisionerDaemon: true,
})
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{{
Auth: &proto.Agent_InstanceId{
InstanceId: instanceID,
},
}},
}},
},
},
}},
})
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)
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)
}()
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
workspace, err := client.Workspace(ctx, workspace.ID)
require.NoError(t, err)
resources := workspace.LatestBuild.Resources
if assert.NotEmpty(t, workspace.LatestBuild.Resources) && assert.NotEmpty(t, resources[0].Agents) {
assert.NotEmpty(t, resources[0].Agents[0].Version)
}
dialer, err := client.DialWorkspaceAgent(ctx, resources[0].Agents[0].ID, nil)
require.NoError(t, err)
defer dialer.Close()
require.True(t, dialer.AwaitReachable(context.Background()))
cancelFunc()
err = <-errC
require.NoError(t, err)
})
t.Run("AWS", func(t *testing.T) {
t.Parallel()
instanceID := "instanceidentifier"
certificates, metadataClient := coderdtest.NewAWSInstanceIdentity(t, instanceID)
client := coderdtest.New(t, &coderdtest.Options{
AWSCertificates: certificates,
IncludeProvisionerDaemon: true,
})
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{{
Auth: &proto.Agent_InstanceId{
InstanceId: instanceID,
},
}},
}},
},
},
}},
})
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)
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)
}()
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
workspace, err := client.Workspace(ctx, workspace.ID)
require.NoError(t, err)
resources := workspace.LatestBuild.Resources
if assert.NotEmpty(t, resources) && assert.NotEmpty(t, resources[0].Agents) {
assert.NotEmpty(t, resources[0].Agents[0].Version)
}
dialer, err := client.DialWorkspaceAgent(ctx, resources[0].Agents[0].ID, nil)
require.NoError(t, err)
defer dialer.Close()
require.True(t, dialer.AwaitReachable(context.Background()))
cancelFunc()
err = <-errC
require.NoError(t, err)
})
t.Run("GoogleCloud", func(t *testing.T) {
t.Parallel()
instanceID := "instanceidentifier"
validator, metadata := 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{
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{{
Auth: &proto.Agent_InstanceId{
InstanceId: instanceID,
},
}},
}},
},
},
}},
})
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)
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)
resources := workspace.LatestBuild.Resources
if assert.NotEmpty(t, resources) && assert.NotEmpty(t, resources[0].Agents) {
assert.NotEmpty(t, resources[0].Agents[0].Version)
}
dialer, err := client.DialWorkspaceAgent(ctx, resources[0].Agents[0].ID, nil)
require.NoError(t, err)
defer dialer.Close()
require.True(t, dialer.AwaitReachable(context.Background()))
sshClient, err := dialer.SSHClient(ctx)
require.NoError(t, err)
defer sshClient.Close()
session, err := sshClient.NewSession()
require.NoError(t, err)
defer session.Close()
key := "CODER_AGENT_TOKEN"
command := "sh -c 'echo $" + key + "'"
if runtime.GOOS == "windows" {
command = "cmd.exe /c echo %" + key + "%"
}
token, err := session.CombinedOutput(command)
require.NoError(t, err)
_, err = uuid.Parse(strings.TrimSpace(string(token)))
require.NoError(t, err)
cancelFunc()
err = <-errC
require.NoError(t, err)
})
}
+121 -6
View File
@@ -6,18 +6,54 @@
//
// 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")
//
// -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)
@@ -27,6 +63,30 @@ func StringVarP(flagset *pflag.FlagSet, p *string, name string, shorthand string
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)
@@ -44,6 +104,39 @@ func Uint8VarP(flagset *pflag.FlagSet, ptr *uint8, name string, shorthand string
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)
@@ -61,10 +154,32 @@ func BoolVarP(flagset *pflag.FlagSet, ptr *bool, name string, shorthand string,
flagset.BoolVarP(ptr, name, shorthand, valb, fmtUsage(usage, env))
}
func fmtUsage(u string, env string) string {
if env == "" {
return fmt.Sprintf("%s.", u)
// 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
}
return fmt.Sprintf("%s - consumes $%s.", u, env)
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
}
+140 -8
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"strconv"
"testing"
"time"
"github.com/spf13/pflag"
"github.com/stretchr/testify/require"
@@ -13,9 +14,32 @@ import (
)
// 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)
@@ -25,10 +49,10 @@ func TestCliflag(t *testing.T) {
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))
require.Contains(t, flagset.FlagUsages(), fmt.Sprintf("Consumes $%s", env))
})
t.Run("StringEnvVar", func(t *testing.T) {
t.Run("StringVarPEnvVar", func(t *testing.T) {
var ptr string
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.String(10)
@@ -51,10 +75,40 @@ func TestCliflag(t *testing.T) {
require.NoError(t, err)
require.Equal(t, def, got)
require.Contains(t, flagset.FlagUsages(), usage)
require.NotContains(t, flagset.FlagUsages(), " - consumes")
require.NotContains(t, flagset.FlagUsages(), "Consumes")
})
t.Run("IntDefault", func(t *testing.T) {
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)
@@ -64,10 +118,10 @@ func TestCliflag(t *testing.T) {
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))
require.Contains(t, flagset.FlagUsages(), fmt.Sprintf("Consumes $%s", env))
})
t.Run("IntEnvVar", func(t *testing.T) {
t.Run("UInt8EnvVar", func(t *testing.T) {
var ptr uint8
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.Int63n(10)
@@ -80,7 +134,7 @@ func TestCliflag(t *testing.T) {
require.Equal(t, uint8(envValue), got)
})
t.Run("IntFailParse", func(t *testing.T) {
t.Run("UInt8FailParse", func(t *testing.T) {
var ptr uint8
flagset, name, shorthand, env, usage := randomFlag()
envValue, _ := cryptorand.String(10)
@@ -93,6 +147,45 @@ func TestCliflag(t *testing.T) {
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()
@@ -103,7 +196,7 @@ func TestCliflag(t *testing.T) {
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))
require.Contains(t, flagset.FlagUsages(), fmt.Sprintf("Consumes $%s", env))
})
t.Run("BoolEnvVar", func(t *testing.T) {
@@ -131,6 +224,45 @@ func TestCliflag(t *testing.T) {
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) {
+24 -4
View File
@@ -5,8 +5,10 @@ import (
"bytes"
"errors"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
"github.com/spf13/cobra"
@@ -21,25 +23,40 @@ import (
// New creates a CLI instance with a configuration pointed to a
// temporary testing directory.
func New(t *testing.T, args ...string) (*cobra.Command, config.Root) {
cmd := cli.Root()
return NewWithSubcommands(t, cli.AGPL(), args...)
}
func NewWithSubcommands(
t *testing.T, subcommands []*cobra.Command, args ...string,
) (*cobra.Command, config.Root) {
cmd := cli.Root(subcommands)
dir := t.TempDir()
root := config.Root(dir)
cmd.SetArgs(append([]string{"--global-config", dir}, args...))
// We could consider using writers
// that log via t.Log here instead.
cmd.SetOut(io.Discard)
cmd.SetErr(io.Discard)
return cmd, root
}
// SetupConfig applies the URL and SessionToken of the client to the config.
func SetupConfig(t *testing.T, client *codersdk.Client, root config.Root) {
err := root.Session().Write(client.SessionToken)
err := root.Session().Write(client.SessionToken())
require.NoError(t, err)
err = root.URL().Write(client.URL.String())
require.NoError(t, err)
}
// CreateProjectVersionSource writes the echo provisioner responses into a
// CreateTemplateVersionSource writes the echo provisioner responses into a
// new temporary testing directory.
func CreateProjectVersionSource(t *testing.T, responses *echo.Responses) string {
func CreateTemplateVersionSource(t *testing.T, responses *echo.Responses) string {
directory := t.TempDir()
f, err := ioutil.TempFile(directory, "*.tf")
require.NoError(t, err)
_ = f.Close()
data, err := echo.Tar(responses)
require.NoError(t, err)
extractTar(t, data, directory)
@@ -54,6 +71,9 @@ func extractTar(t *testing.T, data []byte, directory string) {
break
}
require.NoError(t, err)
if header.Name == "." || strings.Contains(header.Name, "..") {
continue
}
// #nosec
path := filepath.Join(directory, header.Name)
mode := header.FileInfo().Mode()
+2 -4
View File
@@ -3,7 +3,6 @@ package clitest_test
import (
"testing"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"github.com/coder/coder/cli/clitest"
@@ -17,7 +16,7 @@ func TestMain(m *testing.M) {
func TestCli(t *testing.T) {
t.Parallel()
clitest.CreateProjectVersionSource(t, nil)
clitest.CreateTemplateVersionSource(t, nil)
client := coderdtest.New(t, nil)
cmd, config := clitest.New(t)
clitest.SetupConfig(t, client, config)
@@ -25,8 +24,7 @@ func TestCli(t *testing.T) {
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
err := cmd.Execute()
require.NoError(t, err)
_ = cmd.Execute()
}()
pty.ExpectMatch("coder")
}
+84 -26
View File
@@ -4,6 +4,8 @@ import (
"context"
"fmt"
"io"
"os"
"os/signal"
"sync"
"time"
@@ -15,7 +17,7 @@ import (
type AgentOptions struct {
WorkspaceName string
Fetch func(context.Context) (codersdk.WorkspaceResource, error)
Fetch func(context.Context) (codersdk.WorkspaceAgent, error)
FetchInterval time.Duration
WarnInterval time.Duration
}
@@ -29,60 +31,116 @@ func Agent(ctx context.Context, writer io.Writer, opts AgentOptions) error {
opts.WarnInterval = 30 * time.Second
}
var resourceMutex sync.Mutex
resource, err := opts.Fetch(ctx)
agent, err := opts.Fetch(ctx)
if err != nil {
return xerrors.Errorf("fetch: %w", err)
}
if resource.Agent.Status == codersdk.WorkspaceAgentConnected {
if agent.Status == codersdk.WorkspaceAgentConnected {
return nil
}
if resource.Agent.Status == codersdk.WorkspaceAgentDisconnected {
opts.WarnInterval = 0
}
spin := spinner.New(spinner.CharSets[78], 100*time.Millisecond, spinner.WithColor("fgHiGreen"))
spin.Writer = writer
spin.ForceOutput = true
spin.Suffix = " Waiting for connection from " + Styles.Field.Render(resource.Type+"."+resource.Name) + "..."
spin.Suffix = " Waiting for connection from " + Styles.Field.Render(agent.Name) + "..."
spin.Start()
defer spin.Stop()
ticker := time.NewTicker(opts.FetchInterval)
defer ticker.Stop()
timer := time.NewTimer(opts.WarnInterval)
defer timer.Stop()
ctx, cancelFunc := context.WithCancel(ctx)
defer cancelFunc()
stopSpin := make(chan os.Signal, 1)
signal.Notify(stopSpin, os.Interrupt)
defer signal.Stop(stopSpin)
go func() {
select {
case <-ctx.Done():
return
case <-timer.C:
case <-stopSpin:
}
cancelFunc()
signal.Stop(stopSpin)
spin.Stop()
// nolint:revive
os.Exit(1)
}()
var waitMessage string
messageAfter := time.NewTimer(opts.WarnInterval)
defer messageAfter.Stop()
showMessage := func() {
resourceMutex.Lock()
defer resourceMutex.Unlock()
message := "Don't panic, your workspace is booting up!"
if resource.Agent.Status == codersdk.WorkspaceAgentDisconnected {
message = "The workspace agent lost connection! Wait for it to reconnect or run: " + Styles.Code.Render("coder workspaces rebuild "+opts.WorkspaceName)
m := waitingMessage(agent)
if m == waitMessage {
return
}
moveUp := ""
if waitMessage != "" {
// If this is an update, move a line up
// to keep it tidy and aligned.
moveUp = "\033[1A"
}
waitMessage = m
// Stop the spinner while we write our message.
spin.Stop()
// Clear the line and (if necessary) move up a line to write our message.
_, _ = fmt.Fprintf(writer, "\033[2K%s%s\n\n", moveUp, Styles.Paragraph.Render(Styles.Prompt.String()+waitMessage))
select {
case <-ctx.Done():
default:
// Safe to resume operation.
spin.Start()
}
}
go func() {
select {
case <-ctx.Done():
case <-messageAfter.C:
messageAfter.Stop()
showMessage()
}
// This saves the cursor position, then defers clearing from the cursor
// position to the end of the screen.
_, _ = fmt.Fprintf(writer, "\033[s\r\033[2K%s\n\n", Styles.Paragraph.Render(Styles.Prompt.String()+message))
defer fmt.Fprintf(writer, "\033[u\033[J")
}()
fetchInterval := time.NewTicker(opts.FetchInterval)
defer fetchInterval.Stop()
for {
select {
case <-ctx.Done():
return ctx.Err()
case <-ticker.C:
case <-fetchInterval.C:
}
resourceMutex.Lock()
resource, err = opts.Fetch(ctx)
agent, err = opts.Fetch(ctx)
if err != nil {
resourceMutex.Unlock()
return xerrors.Errorf("fetch: %w", err)
}
if resource.Agent.Status != codersdk.WorkspaceAgentConnected {
resourceMutex.Unlock()
continue
}
resourceMutex.Unlock()
return nil
switch agent.Status {
case codersdk.WorkspaceAgentConnected:
return nil
case codersdk.WorkspaceAgentTimeout, codersdk.WorkspaceAgentDisconnected:
showMessage()
}
}
}
func waitingMessage(agent codersdk.WorkspaceAgent) string {
var m string
switch agent.Status {
case codersdk.WorkspaceAgentTimeout:
m = "The workspace agent is having trouble connecting."
case codersdk.WorkspaceAgentDisconnected:
m = "The workspace agent lost connection!"
default:
// Not a failure state, no troubleshooting necessary.
return "Don't panic, your workspace is booting up!"
}
if agent.TroubleshootingURL != "" {
return fmt.Sprintf("%s See troubleshooting instructions at: %s", m, agent.TroubleshootingURL)
}
return fmt.Sprintf("%s Wait for it to (re)connect or restart your workspace.", m)
}
+55 -9
View File
@@ -6,12 +6,13 @@ import (
"time"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
"go.uber.org/atomic"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/pty/ptytest"
"github.com/coder/coder/testutil"
)
func TestAgent(t *testing.T) {
@@ -22,16 +23,14 @@ func TestAgent(t *testing.T) {
RunE: func(cmd *cobra.Command, args []string) error {
err := cliui.Agent(cmd.Context(), cmd.OutOrStdout(), cliui.AgentOptions{
WorkspaceName: "example",
Fetch: func(ctx context.Context) (codersdk.WorkspaceResource, error) {
resource := codersdk.WorkspaceResource{
Agent: &codersdk.WorkspaceAgent{
Status: codersdk.WorkspaceAgentDisconnected,
},
Fetch: func(ctx context.Context) (codersdk.WorkspaceAgent, error) {
agent := codersdk.WorkspaceAgent{
Status: codersdk.WorkspaceAgentDisconnected,
}
if disconnected.Load() {
resource.Agent.Status = codersdk.WorkspaceAgentConnected
agent.Status = codersdk.WorkspaceAgentConnected
}
return resource, nil
return agent, nil
},
FetchInterval: time.Millisecond,
WarnInterval: 10 * time.Millisecond,
@@ -45,9 +44,56 @@ func TestAgent(t *testing.T) {
go func() {
defer close(done)
err := cmd.Execute()
require.NoError(t, err)
assert.NoError(t, err)
}()
ptty.ExpectMatch("lost connection")
disconnected.Store(true)
<-done
}
func TestAgentTimeoutWithTroubleshootingURL(t *testing.T) {
t.Parallel()
ctx, _ := testutil.Context(t)
wantURL := "https://coder.com/troubleshoot"
var connected, timeout atomic.Bool
cmd := &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
err := cliui.Agent(cmd.Context(), cmd.OutOrStdout(), cliui.AgentOptions{
WorkspaceName: "example",
Fetch: func(ctx context.Context) (codersdk.WorkspaceAgent, error) {
agent := codersdk.WorkspaceAgent{
Status: codersdk.WorkspaceAgentConnecting,
TroubleshootingURL: "https://coder.com/troubleshoot",
}
switch {
case connected.Load():
agent.Status = codersdk.WorkspaceAgentConnected
case timeout.Load():
agent.Status = codersdk.WorkspaceAgentTimeout
}
return agent, nil
},
FetchInterval: time.Millisecond,
WarnInterval: 5 * time.Millisecond,
})
return err
},
}
ptty := ptytest.New(t)
cmd.SetOutput(ptty.Output())
cmd.SetIn(ptty.Input())
done := make(chan struct{})
go func() {
defer close(done)
err := cmd.ExecuteContext(ctx)
assert.NoError(t, err)
}()
ptty.ExpectMatch("Don't panic")
timeout.Store(true)
ptty.ExpectMatch(wantURL)
connected.Store(true)
<-done
}
+8 -4
View File
@@ -26,13 +26,15 @@ var Styles = struct {
Checkmark,
Code,
Crossmark,
DateTimeStamp,
Error,
Field,
Keyword,
Paragraph,
Placeholder,
Prompt,
FocusedPrompt,
Fuschia,
Fuchsia,
Logo,
Warn,
Wrap lipgloss.Style
@@ -41,14 +43,16 @@ var Styles = struct {
Checkmark: defaultStyles.Checkmark,
Code: defaultStyles.Code,
Crossmark: defaultStyles.Error.Copy().SetString("✘"),
DateTimeStamp: defaultStyles.LabelDim,
Error: defaultStyles.Error,
Field: defaultStyles.Code.Copy().Foreground(lipgloss.AdaptiveColor{Light: "#000000", Dark: "#FFFFFF"}),
Keyword: defaultStyles.Keyword,
Paragraph: defaultStyles.Paragraph,
Placeholder: lipgloss.NewStyle().Foreground(lipgloss.Color("240")),
Placeholder: lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#585858", Dark: "#4d46b3"}),
Prompt: defaultStyles.Prompt.Foreground(lipgloss.AdaptiveColor{Light: "#9B9B9B", Dark: "#5C5C5C"}),
FocusedPrompt: defaultStyles.FocusedPrompt.Foreground(lipgloss.Color("#651fff")),
Fuschia: defaultStyles.SelectedMenuItem.Copy(),
Fuchsia: defaultStyles.SelectedMenuItem.Copy(),
Logo: defaultStyles.Logo.SetString("Coder"),
Warn: lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#04B575", Dark: "#ECFD65"}),
Wrap: defaultStyles.Wrap,
Wrap: lipgloss.NewStyle().Width(80),
}
+20 -3
View File
@@ -10,7 +10,7 @@ import (
"github.com/coder/coder/codersdk"
)
func ParameterSchema(cmd *cobra.Command, parameterSchema codersdk.ProjectVersionParameterSchema) (string, error) {
func ParameterSchema(cmd *cobra.Command, parameterSchema codersdk.ParameterSchema) (string, error) {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), Styles.Bold.Render("var."+parameterSchema.Name))
if parameterSchema.Description != "" {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+strings.TrimSpace(strings.Join(strings.Split(parameterSchema.Description, "\n"), "\n "))+"\n")
@@ -30,6 +30,7 @@ func ParameterSchema(cmd *cobra.Command, parameterSchema codersdk.ProjectVersion
_, _ = fmt.Fprint(cmd.OutOrStdout(), "\033[1A")
value, err = Select(cmd, SelectOptions{
Options: options,
Default: parameterSchema.DefaultSourceValue,
HideSearch: true,
})
if err == nil {
@@ -37,9 +38,25 @@ func ParameterSchema(cmd *cobra.Command, parameterSchema codersdk.ProjectVersion
_, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+Styles.Prompt.String()+Styles.Field.Render(value))
}
} else {
text := "Enter a value"
if parameterSchema.DefaultSourceValue != "" {
text += fmt.Sprintf(" (default: %q)", parameterSchema.DefaultSourceValue)
}
text += ":"
value, err = Prompt(cmd, PromptOptions{
Text: Styles.Bold.Render("Enter a value:"),
Text: Styles.Bold.Render(text),
})
value = strings.TrimSpace(value)
}
return value, err
if err != nil {
return "", err
}
// If they didn't specify anything, use the default value if set.
if len(options) == 0 && value == "" {
value = parameterSchema.DefaultSourceValue
}
return value, nil
}
+77 -24
View File
@@ -5,7 +5,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"os"
"os/signal"
"strings"
@@ -13,6 +12,7 @@ import (
"github.com/bgentry/speakeasy"
"github.com/mattn/go-isatty"
"github.com/spf13/cobra"
"golang.org/x/xerrors"
)
// PromptOptions supply a set of options to the prompt.
@@ -24,28 +24,60 @@ type PromptOptions struct {
Validate func(string) error
}
const skipPromptFlag = "yes"
func AllowSkipPrompt(cmd *cobra.Command) {
cmd.Flags().BoolP(skipPromptFlag, "y", false, "Bypass prompts")
}
const (
ConfirmYes = "yes"
ConfirmNo = "no"
)
// Prompt asks the user for input.
func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
// If the cmd has a "yes" flag for skipping confirm prompts, honor it.
// If it's not a "Confirm" prompt, then don't skip. As the default value of
// "yes" makes no sense.
if opts.IsConfirm && cmd.Flags().Lookup(skipPromptFlag) != nil {
if skip, _ := cmd.Flags().GetBool(skipPromptFlag); skip {
return ConfirmYes, nil
}
}
_, _ = fmt.Fprint(cmd.OutOrStdout(), Styles.FocusedPrompt.String()+opts.Text+" ")
if opts.IsConfirm {
opts.Default = "yes"
_, _ = fmt.Fprint(cmd.OutOrStdout(), Styles.Placeholder.Render("("+Styles.Bold.Render("yes")+Styles.Placeholder.Render("/no) ")))
if len(opts.Default) == 0 {
opts.Default = ConfirmYes
}
renderedYes := Styles.Placeholder.Render(ConfirmYes)
renderedNo := Styles.Placeholder.Render(ConfirmNo)
if opts.Default == ConfirmYes {
renderedYes = Styles.Bold.Render(ConfirmYes)
} else {
renderedNo = Styles.Bold.Render(ConfirmNo)
}
_, _ = fmt.Fprint(cmd.OutOrStdout(), Styles.Placeholder.Render("("+renderedYes+Styles.Placeholder.Render("/"+renderedNo+Styles.Placeholder.Render(") "))))
} else if opts.Default != "" {
_, _ = fmt.Fprint(cmd.OutOrStdout(), Styles.Placeholder.Render("("+opts.Default+") "))
}
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)
defer signal.Stop(interrupt)
errCh := make(chan error, 1)
lineCh := make(chan string)
go func() {
var line string
var err error
inFile, valid := cmd.InOrStdin().(*os.File)
if opts.Secret && valid && isatty.IsTerminal(inFile.Fd()) {
inFile, isInputFile := cmd.InOrStdin().(*os.File)
if opts.Secret && isInputFile && isatty.IsTerminal(inFile.Fd()) {
// we don't install a signal handler here because speakeasy has its own
line, err = speakeasy.Ask("")
} else {
signal.Notify(interrupt, os.Interrupt)
defer signal.Stop(interrupt)
reader := bufio.NewReader(cmd.InOrStdin())
line, err = reader.ReadString('\n')
@@ -53,22 +85,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
// This enables multiline JSON to be pasted into an input, and have
// it parse properly.
if err == nil && (strings.HasPrefix(line, "{") || strings.HasPrefix(line, "[")) {
pipeReader, pipeWriter := io.Pipe()
defer pipeWriter.Close()
defer pipeReader.Close()
go func() {
_, _ = pipeWriter.Write([]byte(line))
_, _ = reader.WriteTo(pipeWriter)
}()
var rawMessage json.RawMessage
err := json.NewDecoder(pipeReader).Decode(&rawMessage)
if err == nil {
var buf bytes.Buffer
err = json.Compact(&buf, rawMessage)
if err == nil {
line = buf.String()
}
}
line, err = promptJSON(reader, line)
}
}
if err != nil {
@@ -87,7 +104,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
return "", err
case line := <-lineCh:
if opts.IsConfirm && line != "yes" && line != "y" {
return line, Canceled
return line, xerrors.Errorf("got %q: %w", line, Canceled)
}
if opts.Validate != nil {
err := opts.Validate(line)
@@ -105,3 +122,39 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
return "", Canceled
}
}
func promptJSON(reader *bufio.Reader, line string) (string, error) {
var data bytes.Buffer
for {
_, _ = data.WriteString(line)
var rawMessage json.RawMessage
err := json.Unmarshal(data.Bytes(), &rawMessage)
if err != nil {
if err.Error() != "unexpected end of JSON input" {
// If a real syntax error occurs in JSON,
// we want to return that partial line to the user.
err = nil
line = data.String()
break
}
// Read line-by-line. We can't use a JSON decoder
// here because it doesn't work by newline, so
// reads will block.
line, err = reader.ReadString('\n')
if err != nil {
break
}
continue
}
// Compacting the JSON makes it easier for parsing and testing.
rawJSON := data.Bytes()
data.Reset()
err = json.Compact(&data, rawJSON)
if err != nil {
return line, xerrors.Errorf("compact json: %w", err)
}
return data.String(), nil
}
return line, nil
}
+120 -12
View File
@@ -1,14 +1,21 @@
package cliui_test
import (
"bytes"
"context"
"io"
"os"
"os/exec"
"testing"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/pty"
"github.com/coder/coder/pty/ptytest"
"github.com/coder/coder/testutil"
)
func TestPrompt(t *testing.T) {
@@ -20,8 +27,8 @@ func TestPrompt(t *testing.T) {
go func() {
resp, err := newPrompt(ptty, cliui.PromptOptions{
Text: "Example",
})
require.NoError(t, err)
}, nil)
assert.NoError(t, err)
msgChan <- resp
}()
ptty.ExpectMatch("Example")
@@ -37,8 +44,8 @@ func TestPrompt(t *testing.T) {
resp, err := newPrompt(ptty, cliui.PromptOptions{
Text: "Example",
IsConfirm: true,
})
require.NoError(t, err)
}, nil)
assert.NoError(t, err)
doneChan <- resp
}()
ptty.ExpectMatch("Example")
@@ -46,6 +53,47 @@ func TestPrompt(t *testing.T) {
require.Equal(t, "yes", <-doneChan)
})
t.Run("Skip", func(t *testing.T) {
t.Parallel()
ptty := ptytest.New(t)
var buf bytes.Buffer
// Copy all data written out to a buffer. When we close the ptty, we can
// no longer read from the ptty.Output(), but we can read what was
// written to the buffer.
dataRead, doneReading := context.WithTimeout(context.Background(), testutil.WaitShort)
go func() {
// This will throw an error sometimes. The underlying ptty
// has its own cleanup routines in t.Cleanup. Instead of
// trying to control the close perfectly, just let the ptty
// double close. This error isn't important, we just
// want to know the ptty is done sending output.
_, _ = io.Copy(&buf, ptty.Output())
doneReading()
}()
doneChan := make(chan string)
go func() {
resp, err := newPrompt(ptty, cliui.PromptOptions{
Text: "ShouldNotSeeThis",
IsConfirm: true,
}, func(cmd *cobra.Command) {
cliui.AllowSkipPrompt(cmd)
cmd.SetArgs([]string{"-y"})
})
assert.NoError(t, err)
doneChan <- resp
}()
require.Equal(t, "yes", <-doneChan)
// Close the reader to end the io.Copy
require.NoError(t, ptty.Close(), "close eof reader")
// Wait for the IO copy to finish
<-dataRead.Done()
// Timeout error means the output was hanging
require.ErrorIs(t, dataRead.Err(), context.Canceled, "should be canceled")
require.Len(t, buf.Bytes(), 0, "expect no output")
})
t.Run("JSON", func(t *testing.T) {
t.Parallel()
ptty := ptytest.New(t)
@@ -53,8 +101,8 @@ func TestPrompt(t *testing.T) {
go func() {
resp, err := newPrompt(ptty, cliui.PromptOptions{
Text: "Example",
})
require.NoError(t, err)
}, nil)
assert.NoError(t, err)
doneChan <- resp
}()
ptty.ExpectMatch("Example")
@@ -69,8 +117,8 @@ func TestPrompt(t *testing.T) {
go func() {
resp, err := newPrompt(ptty, cliui.PromptOptions{
Text: "Example",
})
require.NoError(t, err)
}, nil)
assert.NoError(t, err)
doneChan <- resp
}()
ptty.ExpectMatch("Example")
@@ -85,8 +133,8 @@ func TestPrompt(t *testing.T) {
go func() {
resp, err := newPrompt(ptty, cliui.PromptOptions{
Text: "Example",
})
require.NoError(t, err)
}, nil)
assert.NoError(t, err)
doneChan <- resp
}()
ptty.ExpectMatch("Example")
@@ -97,7 +145,7 @@ func TestPrompt(t *testing.T) {
})
}
func newPrompt(ptty *ptytest.PTY, opts cliui.PromptOptions) (string, error) {
func newPrompt(ptty *ptytest.PTY, opts cliui.PromptOptions, cmdOpt func(cmd *cobra.Command)) (string, error) {
value := ""
cmd := &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
@@ -106,7 +154,67 @@ func newPrompt(ptty *ptytest.PTY, opts cliui.PromptOptions) (string, error) {
return err
},
}
cmd.SetOutput(ptty.Output())
// Optionally modify the cmd
if cmdOpt != nil {
cmdOpt(cmd)
}
cmd.SetOut(ptty.Output())
cmd.SetErr(ptty.Output())
cmd.SetIn(ptty.Input())
return value, cmd.ExecuteContext(context.Background())
}
func TestPasswordTerminalState(t *testing.T) {
if os.Getenv("TEST_SUBPROCESS") == "1" {
passwordHelper()
return
}
t.Parallel()
ptty := ptytest.New(t)
ptyWithFlags, ok := ptty.PTY.(pty.WithFlags)
if !ok {
t.Skip("unable to check PTY local echo on this platform")
}
cmd := exec.Command(os.Args[0], "-test.run=TestPasswordTerminalState") //nolint:gosec
cmd.Env = append(os.Environ(), "TEST_SUBPROCESS=1")
// connect the child process's stdio to the PTY directly, not via a pipe
cmd.Stdin = ptty.Input().Reader
cmd.Stdout = ptty.Output().Writer
cmd.Stderr = ptty.Output().Writer
err := cmd.Start()
require.NoError(t, err)
process := cmd.Process
defer process.Kill()
ptty.ExpectMatch("Password: ")
require.Eventually(t, func() bool {
echo, err := ptyWithFlags.EchoEnabled()
return err == nil && !echo
}, testutil.WaitShort, testutil.IntervalMedium, "echo is on while reading password")
err = process.Signal(os.Interrupt)
require.NoError(t, err)
_, err = process.Wait()
require.NoError(t, err)
require.Eventually(t, func() bool {
echo, err := ptyWithFlags.EchoEnabled()
return err == nil && echo
}, testutil.WaitShort, testutil.IntervalMedium, "echo is off after reading password")
}
// nolint:unused
func passwordHelper() {
cmd := &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Password:",
Secret: true,
})
},
}
cmd.ExecuteContext(context.Background())
}
+41 -14
View File
@@ -1,6 +1,7 @@
package cliui
import (
"bytes"
"context"
"fmt"
"io"
@@ -12,18 +13,17 @@ import (
"github.com/google/uuid"
"golang.org/x/xerrors"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
)
func WorkspaceBuild(ctx context.Context, writer io.Writer, client *codersdk.Client, build uuid.UUID, before time.Time) error {
func WorkspaceBuild(ctx context.Context, writer io.Writer, client *codersdk.Client, build uuid.UUID) error {
return ProvisionerJob(ctx, writer, ProvisionerJobOptions{
Fetch: func() (codersdk.ProvisionerJob, error) {
build, err := client.WorkspaceBuild(ctx, build)
return build.Job, err
},
Logs: func() (<-chan codersdk.ProvisionerJobLog, error) {
return client.WorkspaceBuildLogsAfter(ctx, build, before)
Logs: func() (<-chan codersdk.ProvisionerJobLog, io.Closer, error) {
return client.WorkspaceBuildLogsAfter(ctx, build, 0)
},
})
}
@@ -31,11 +31,14 @@ func WorkspaceBuild(ctx context.Context, writer io.Writer, client *codersdk.Clie
type ProvisionerJobOptions struct {
Fetch func() (codersdk.ProvisionerJob, error)
Cancel func() error
Logs func() (<-chan codersdk.ProvisionerJobLog, error)
Logs func() (<-chan codersdk.ProvisionerJobLog, io.Closer, error)
FetchInterval time.Duration
// Verbose determines whether debug and trace logs will be shown.
Verbose bool
// Silent determines whether log output will be shown unless there is an
// error.
Silent bool
}
// ProvisionerJob renders a provisioner job with interactive cancellation.
@@ -100,7 +103,6 @@ func ProvisionerJob(ctx context.Context, writer io.Writer, opts ProvisionerJobOp
}
updateStage("Running", *job.StartedAt)
}
updateJob()
if opts.Cancel != nil {
// Handles ctrl+c to cancel a job.
@@ -128,18 +130,38 @@ func ProvisionerJob(ctx context.Context, writer io.Writer, opts ProvisionerJobOp
// The initial stage needs to print after the signal handler has been registered.
printStage()
updateJob()
logs, err := opts.Logs()
logs, closer, err := opts.Logs()
if err != nil {
return xerrors.Errorf("logs: %w", err)
return xerrors.Errorf("begin streaming logs: %w", err)
}
defer closer.Close()
var (
// logOutput is where log output is written
logOutput = writer
// logBuffer is where logs are buffered if opts.Silent is true
logBuffer = &bytes.Buffer{}
)
if opts.Silent {
logOutput = logBuffer
}
flushLogBuffer := func() {
if opts.Silent {
_, _ = io.Copy(writer, logBuffer)
}
}
ticker := time.NewTicker(opts.FetchInterval)
defer ticker.Stop()
for {
select {
case err = <-errChan:
flushLogBuffer()
return err
case <-ctx.Done():
flushLogBuffer()
return ctx.Err()
case <-ticker.C:
updateJob()
@@ -161,30 +183,35 @@ func ProvisionerJob(ctx context.Context, writer io.Writer, opts ProvisionerJobOp
}
err = xerrors.New(job.Error)
jobMutex.Unlock()
flushLogBuffer()
return err
}
output := ""
switch log.Level {
case database.LogLevelTrace, database.LogLevelDebug:
case codersdk.LogLevelTrace, codersdk.LogLevelDebug:
if !opts.Verbose {
continue
}
output = Styles.Placeholder.Render(log.Output)
case database.LogLevelError:
case codersdk.LogLevelError:
output = defaultStyles.Error.Render(log.Output)
case database.LogLevelWarn:
case codersdk.LogLevelWarn:
output = Styles.Warn.Render(log.Output)
case database.LogLevelInfo:
case codersdk.LogLevelInfo:
output = log.Output
}
jobMutex.Lock()
if log.Stage != currentStage && log.Stage != "" {
updateStage(log.Stage, log.CreatedAt)
jobMutex.Unlock()
continue
}
_, _ = fmt.Fprintf(writer, "%s %s\n", Styles.Placeholder.Render(" "), output)
didLogBetweenStage = true
_, _ = fmt.Fprintf(logOutput, "%s %s\n", Styles.Placeholder.Render(" "), output)
if !opts.Silent {
didLogBetweenStage = true
}
jobMutex.Unlock()
}
}
+15 -6
View File
@@ -2,6 +2,7 @@ package cliui_test
import (
"context"
"io"
"os"
"runtime"
"sync"
@@ -9,7 +10,7 @@ import (
"time"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/assert"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/database"
@@ -90,9 +91,9 @@ func TestProvisionerJob(t *testing.T) {
go func() {
<-test.Next
currentProcess, err := os.FindProcess(os.Getpid())
require.NoError(t, err)
assert.NoError(t, err)
err = currentProcess.Signal(os.Interrupt)
require.NoError(t, err)
assert.NoError(t, err)
<-test.Next
test.JobMutex.Lock()
test.Job.Status = codersdk.ProvisionerJobCanceled
@@ -136,8 +137,10 @@ func newProvisionerJob(t *testing.T) provisionerJobTest {
Cancel: func() error {
return nil
},
Logs: func() (<-chan codersdk.ProvisionerJobLog, error) {
return logs, nil
Logs: func() (<-chan codersdk.ProvisionerJobLog, io.Closer, error) {
return logs, closeFunc(func() error {
return nil
}), nil
},
})
},
@@ -150,7 +153,7 @@ func newProvisionerJob(t *testing.T) provisionerJobTest {
defer close(done)
err := cmd.ExecuteContext(context.Background())
if err != nil {
require.ErrorIs(t, err, cliui.Canceled)
assert.ErrorIs(t, err, cliui.Canceled)
}
}()
t.Cleanup(func() {
@@ -164,3 +167,9 @@ func newProvisionerJob(t *testing.T) provisionerJobTest {
PTY: ptty,
}
}
type closeFunc func() error
func (c closeFunc) Close() error {
return c()
}
+156
View File
@@ -0,0 +1,156 @@
package cliui
import (
"fmt"
"io"
"sort"
"strconv"
"github.com/jedib0t/go-pretty/v6/table"
"golang.org/x/mod/semver"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
)
type WorkspaceResourcesOptions struct {
WorkspaceName string
HideAgentState bool
HideAccess bool
Title string
ServerVersion string
}
// WorkspaceResources displays the connection status and tree-view of provided resources.
// ┌────────────────────────────────────────────────────────────────────────────┐
// │ RESOURCE STATUS ACCESS │
// ├────────────────────────────────────────────────────────────────────────────┤
// │ google_compute_disk.root │
// ├────────────────────────────────────────────────────────────────────────────┤
// │ google_compute_instance.dev │
// │ └─ dev (linux, amd64) ⦾ connecting [10s] coder ssh dev.dev │
// ├────────────────────────────────────────────────────────────────────────────┤
// │ kubernetes_pod.dev │
// │ ├─ go (linux, amd64) ⦿ connected coder ssh dev.go │
// │ └─ postgres (linux, amd64) ⦾ disconnected [4s] coder ssh dev.postgres │
// └────────────────────────────────────────────────────────────────────────────┘
func WorkspaceResources(writer io.Writer, resources []codersdk.WorkspaceResource, options WorkspaceResourcesOptions) error {
// Sort resources by type for consistent output.
sort.Slice(resources, func(i, j int) bool {
return resources[i].Type < resources[j].Type
})
tableWriter := table.NewWriter()
if options.Title != "" {
tableWriter.SetTitle(options.Title)
}
tableWriter.SetStyle(table.StyleLight)
tableWriter.Style().Options.SeparateColumns = false
row := table.Row{"Resource"}
if !options.HideAgentState {
row = append(row, "Status")
row = append(row, "Version")
}
if !options.HideAccess {
row = append(row, "Access")
}
tableWriter.AppendHeader(row)
totalAgents := 0
for _, resource := range resources {
totalAgents += len(resource.Agents)
}
for _, resource := range resources {
if resource.Type == "random_string" {
// Hide resources that aren't substantial to a user!
// This is an unfortunate case, and we should allow
// callers to hide resources eventually.
continue
}
resourceAddress := resource.Type + "." + resource.Name
// Sort agents by name for consistent output.
sort.Slice(resource.Agents, func(i, j int) bool {
return resource.Agents[i].Name < resource.Agents[j].Name
})
// Display a line for the resource.
tableWriter.AppendRow(table.Row{
Styles.Bold.Render(resourceAddress),
"",
"",
})
// Display all agents associated with the resource.
for index, agent := range resource.Agents {
pipe := "├"
if index == len(resource.Agents)-1 {
pipe = "└"
}
row := table.Row{
// These tree from a resource!
fmt.Sprintf("%s─ %s (%s, %s)", pipe, agent.Name, agent.OperatingSystem, agent.Architecture),
}
if !options.HideAgentState {
var agentStatus string
var agentVersion string
if !options.HideAgentState {
agentStatus = renderAgentStatus(agent)
agentVersion = renderAgentVersion(agent.Version, options.ServerVersion)
}
row = append(row, agentStatus, agentVersion)
}
if !options.HideAccess {
sshCommand := "coder ssh " + options.WorkspaceName
if totalAgents > 1 {
sshCommand += "." + agent.Name
}
sshCommand = Styles.Code.Render(sshCommand)
row = append(row, sshCommand)
}
tableWriter.AppendRow(row)
}
tableWriter.AppendSeparator()
}
_, err := fmt.Fprintln(writer, tableWriter.Render())
return err
}
func renderAgentStatus(agent codersdk.WorkspaceAgent) string {
switch agent.Status {
case codersdk.WorkspaceAgentConnecting:
since := database.Now().Sub(agent.CreatedAt)
return Styles.Warn.Render("⦾ connecting") + " " +
Styles.Placeholder.Render("["+strconv.Itoa(int(since.Seconds()))+"s]")
case codersdk.WorkspaceAgentDisconnected:
since := database.Now().Sub(*agent.DisconnectedAt)
return Styles.Error.Render("⦾ disconnected") + " " +
Styles.Placeholder.Render("["+strconv.Itoa(int(since.Seconds()))+"s]")
case codersdk.WorkspaceAgentTimeout:
since := database.Now().Sub(agent.CreatedAt)
return fmt.Sprintf(
"%s %s",
Styles.Warn.Render("⦾ timeout"),
Styles.Placeholder.Render("["+strconv.Itoa(int(since.Seconds()))+"s]"),
)
case codersdk.WorkspaceAgentConnected:
return Styles.Keyword.Render("⦿ connected")
default:
return Styles.Warn.Render("○ unknown")
}
}
func renderAgentVersion(agentVersion, serverVersion string) string {
if agentVersion == "" {
agentVersion = "(unknown)"
}
if !semver.IsValid(serverVersion) || !semver.IsValid(agentVersion) {
return Styles.Placeholder.Render(agentVersion)
}
outdated := semver.Compare(agentVersion, serverVersion) < 0
if outdated {
return Styles.Warn.Render(agentVersion + " (outdated)")
}
return Styles.Keyword.Render(agentVersion)
}
+50
View File
@@ -0,0 +1,50 @@
package cliui
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRenderAgentVersion(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
agentVersion string
serverVersion string
expected string
}{
{
name: "OK",
agentVersion: "v1.2.3",
serverVersion: "v1.2.3",
expected: "v1.2.3",
},
{
name: "Outdated",
agentVersion: "v1.2.3",
serverVersion: "v1.2.4",
expected: "v1.2.3 (outdated)",
},
{
name: "AgentUnknown",
agentVersion: "",
serverVersion: "v1.2.4",
expected: "(unknown)",
},
{
name: "ServerUnknown",
agentVersion: "v1.2.3",
serverVersion: "",
expected: "v1.2.3",
},
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
actual := renderAgentVersion(testCase.agentVersion, testCase.serverVersion)
assert.Equal(t, testCase.expected, actual)
})
}
}
+96
View File
@@ -0,0 +1,96 @@
package cliui_test
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/pty/ptytest"
)
func TestWorkspaceResources(t *testing.T) {
t.Parallel()
t.Run("SingleAgentSSH", func(t *testing.T) {
t.Parallel()
ptty := ptytest.New(t)
done := make(chan struct{})
go func() {
err := cliui.WorkspaceResources(ptty.Output(), []codersdk.WorkspaceResource{{
Type: "google_compute_instance",
Name: "dev",
Transition: codersdk.WorkspaceTransitionStart,
Agents: []codersdk.WorkspaceAgent{{
Name: "dev",
Status: codersdk.WorkspaceAgentConnected,
Architecture: "amd64",
OperatingSystem: "linux",
}},
}}, cliui.WorkspaceResourcesOptions{
WorkspaceName: "example",
})
assert.NoError(t, err)
close(done)
}()
ptty.ExpectMatch("coder ssh example")
<-done
})
t.Run("MultipleStates", func(t *testing.T) {
t.Parallel()
ptty := ptytest.New(t)
disconnected := database.Now().Add(-4 * time.Second)
done := make(chan struct{})
go func() {
err := cliui.WorkspaceResources(ptty.Output(), []codersdk.WorkspaceResource{{
Transition: codersdk.WorkspaceTransitionStart,
Type: "google_compute_disk",
Name: "root",
}, {
Transition: codersdk.WorkspaceTransitionStop,
Type: "google_compute_disk",
Name: "root",
}, {
Transition: codersdk.WorkspaceTransitionStart,
Type: "google_compute_instance",
Name: "dev",
Agents: []codersdk.WorkspaceAgent{{
CreatedAt: database.Now().Add(-10 * time.Second),
Status: codersdk.WorkspaceAgentConnecting,
Name: "dev",
OperatingSystem: "linux",
Architecture: "amd64",
}},
}, {
Transition: codersdk.WorkspaceTransitionStart,
Type: "kubernetes_pod",
Name: "dev",
Agents: []codersdk.WorkspaceAgent{{
Status: codersdk.WorkspaceAgentConnected,
Name: "go",
Architecture: "amd64",
OperatingSystem: "linux",
}, {
DisconnectedAt: &disconnected,
Status: codersdk.WorkspaceAgentDisconnected,
Name: "postgres",
Architecture: "amd64",
OperatingSystem: "linux",
}},
}}, cliui.WorkspaceResourcesOptions{
WorkspaceName: "dev",
HideAgentState: false,
HideAccess: false,
})
assert.NoError(t, err)
close(done)
}()
ptty.ExpectMatch("google_compute_disk.root")
ptty.ExpectMatch("google_compute_instance.dev")
ptty.ExpectMatch("coder ssh dev.postgres")
<-done
})
}
+15 -2
View File
@@ -1,11 +1,13 @@
package cliui
import (
"errors"
"flag"
"io"
"os"
"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
"github.com/spf13/cobra"
)
@@ -33,7 +35,9 @@ func init() {
}
type SelectOptions struct {
Options []string
Options []string
// Default will be highlighted first if it's a valid option.
Default string
Size int
HideSearch bool
}
@@ -48,10 +52,16 @@ func Select(cmd *cobra.Command, opts SelectOptions) (string, error) {
if flag.Lookup("test.v") != nil {
return opts.Options[0], nil
}
opts.HideSearch = false
var defaultOption interface{}
if opts.Default != "" {
defaultOption = opts.Default
}
var value string
err := survey.AskOne(&survey.Select{
Options: opts.Options,
Default: defaultOption,
PageSize: opts.Size,
}, &value, survey.WithIcons(func(is *survey.IconSet) {
is.Help.Text = "Type to search"
@@ -63,6 +73,9 @@ func Select(cmd *cobra.Command, opts SelectOptions) (string, error) {
}, fileReadWriter{
Writer: cmd.OutOrStdout(),
}, cmd.OutOrStdout()))
if errors.Is(err, terminal.InterruptErr) {
return value, Canceled
}
return value, err
}
+2 -1
View File
@@ -5,6 +5,7 @@ import (
"testing"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/cliui"
@@ -21,7 +22,7 @@ func TestSelect(t *testing.T) {
resp, err := newSelect(ptty, cliui.SelectOptions{
Options: []string{"First", "Second"},
})
require.NoError(t, err)
assert.NoError(t, err)
msgChan <- resp
}()
require.Equal(t, "First", <-msgChan)
+326
View File
@@ -0,0 +1,326 @@
package cliui
import (
"fmt"
"reflect"
"strings"
"time"
"github.com/fatih/structtag"
"github.com/jedib0t/go-pretty/v6/table"
"golang.org/x/xerrors"
)
// Table creates a new table with standardized styles.
func Table() table.Writer {
tableWriter := table.NewWriter()
tableWriter.Style().Box.PaddingLeft = ""
tableWriter.Style().Box.PaddingRight = " "
tableWriter.Style().Options.DrawBorder = false
tableWriter.Style().Options.SeparateHeader = false
tableWriter.Style().Options.SeparateColumns = false
return tableWriter
}
// FilterTableColumns returns configurations to hide columns
// that are not provided in the array. If the array is empty,
// no filtering will occur!
func FilterTableColumns(header table.Row, columns []string) []table.ColumnConfig {
if len(columns) == 0 {
return nil
}
columnConfigs := make([]table.ColumnConfig, 0)
for _, headerTextRaw := range header {
headerText, _ := headerTextRaw.(string)
hidden := true
for _, column := range columns {
if strings.EqualFold(strings.ReplaceAll(column, "_", " "), headerText) {
hidden = false
break
}
}
columnConfigs = append(columnConfigs, table.ColumnConfig{
Name: headerText,
Hidden: hidden,
})
}
return columnConfigs
}
// DisplayTable renders a table as a string. The input argument must be a slice
// of structs. At least one field in the struct must have a `table:""` tag
// containing the name of the column in the outputted table.
//
// Nested structs are processed if the field has the `table:"$NAME,recursive"`
// tag and their fields will be named as `$PARENT_NAME $NAME`. If the tag is
// malformed or a field is marked as recursive but does not contain a struct or
// a pointer to a struct, this function will return an error (even with an empty
// input slice).
//
// If sort is empty, the input order will be used. If filterColumns is empty or
// nil, all available columns are included.
func DisplayTable(out any, sort string, filterColumns []string) (string, error) {
v := reflect.Indirect(reflect.ValueOf(out))
if v.Kind() != reflect.Slice {
return "", xerrors.Errorf("DisplayTable called with a non-slice type")
}
// Get the list of table column headers.
headersRaw, err := typeToTableHeaders(v.Type().Elem())
if err != nil {
return "", xerrors.Errorf("get table headers recursively for type %q: %w", v.Type().Elem().String(), err)
}
if len(headersRaw) == 0 {
return "", xerrors.New(`no table headers found on the input type, make sure there is at least one "table" struct tag`)
}
headers := make(table.Row, len(headersRaw))
for i, header := range headersRaw {
headers[i] = header
}
// Verify that the given sort column and filter columns are valid.
if sort != "" || len(filterColumns) != 0 {
headersMap := make(map[string]string, len(headersRaw))
for _, header := range headersRaw {
headersMap[strings.ToLower(header)] = header
}
if sort != "" {
sort = strings.ToLower(strings.ReplaceAll(sort, "_", " "))
h, ok := headersMap[sort]
if !ok {
return "", xerrors.Errorf(`specified sort column %q not found in table headers, available columns are "%v"`, sort, strings.Join(headersRaw, `", "`))
}
// Autocorrect
sort = h
}
for i, column := range filterColumns {
column := strings.ToLower(strings.ReplaceAll(column, "_", " "))
h, ok := headersMap[column]
if !ok {
return "", xerrors.Errorf(`specified filter column %q not found in table headers, available columns are "%v"`, sort, strings.Join(headersRaw, `", "`))
}
// Autocorrect
filterColumns[i] = h
}
}
// Verify that the given sort column is valid.
if sort != "" {
sort = strings.ReplaceAll(sort, "_", " ")
found := false
for _, header := range headersRaw {
if strings.EqualFold(sort, header) {
found = true
sort = header
break
}
}
if !found {
return "", xerrors.Errorf("specified sort column %q not found in table headers, available columns are %q", sort, strings.Join(headersRaw, `", "`))
}
}
// Setup the table formatter.
tw := Table()
tw.AppendHeader(headers)
tw.SetColumnConfigs(FilterTableColumns(headers, filterColumns))
if sort != "" {
tw.SortBy([]table.SortBy{{
Name: sort,
}})
}
// Write each struct to the table.
for i := 0; i < v.Len(); i++ {
// Format the row as a slice.
rowMap, err := valueToTableMap(v.Index(i))
if err != nil {
return "", xerrors.Errorf("get table row map %v: %w", i, err)
}
rowSlice := make([]any, len(headers))
for i, h := range headersRaw {
v, ok := rowMap[h]
if !ok {
v = nil
}
// Special type formatting.
switch val := v.(type) {
case time.Time:
v = val.Format(time.RFC3339)
case *time.Time:
if val != nil {
v = val.Format(time.RFC3339)
}
case *int64:
if val != nil {
v = *val
}
case fmt.Stringer:
if val != nil {
v = val.String()
}
}
rowSlice[i] = v
}
tw.AppendRow(table.Row(rowSlice))
}
return tw.Render(), nil
}
// parseTableStructTag returns the name of the field according to the `table`
// struct tag. If the table tag does not exist or is "-", an empty string is
// returned. If the table tag is malformed, an error is returned.
//
// The returned name is transformed from "snake_case" to "normal text".
func parseTableStructTag(field reflect.StructField) (name string, recurse bool, err error) {
tags, err := structtag.Parse(string(field.Tag))
if err != nil {
return "", false, xerrors.Errorf("parse struct field tag %q: %w", string(field.Tag), err)
}
tag, err := tags.Get("table")
if err != nil || tag.Name == "-" {
// tags.Get only returns an error if the tag is not found.
return "", false, nil
}
recursive := false
for _, opt := range tag.Options {
if opt == "recursive" {
recursive = true
continue
}
return "", false, xerrors.Errorf("unknown option %q in struct field tag", opt)
}
return strings.ReplaceAll(tag.Name, "_", " "), recursive, nil
}
func isStructOrStructPointer(t reflect.Type) bool {
return t.Kind() == reflect.Struct || (t.Kind() == reflect.Pointer && t.Elem().Kind() == reflect.Struct)
}
// typeToTableHeaders converts a type to a slice of column names. If the given
// type is invalid (not a struct or a pointer to a struct, has invalid table
// tags, etc.), an error is returned.
func typeToTableHeaders(t reflect.Type) ([]string, error) {
if !isStructOrStructPointer(t) {
return nil, xerrors.Errorf("typeToTableHeaders called with a non-struct or a non-pointer-to-a-struct type")
}
if t.Kind() == reflect.Pointer {
t = t.Elem()
}
headers := []string{}
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
name, recursive, err := parseTableStructTag(field)
if err != nil {
return nil, xerrors.Errorf("parse struct tags for field %q in type %q: %w", field.Name, t.String(), err)
}
if name == "" {
continue
}
fieldType := field.Type
if recursive {
if !isStructOrStructPointer(fieldType) {
return nil, xerrors.Errorf("field %q in type %q is marked as recursive but does not contain a struct or a pointer to a struct", field.Name, t.String())
}
childNames, err := typeToTableHeaders(fieldType)
if err != nil {
return nil, xerrors.Errorf("get child field header names for field %q in type %q: %w", field.Name, fieldType.String(), err)
}
for _, childName := range childNames {
headers = append(headers, fmt.Sprintf("%s %s", name, childName))
}
continue
}
headers = append(headers, name)
}
return headers, nil
}
// valueToTableMap converts a struct to a map of column name to value. If the
// given type is invalid (not a struct or a pointer to a struct, has invalid
// table tags, etc.), an error is returned.
func valueToTableMap(val reflect.Value) (map[string]any, error) {
if !isStructOrStructPointer(val.Type()) {
return nil, xerrors.Errorf("valueToTableMap called with a non-struct or a non-pointer-to-a-struct type")
}
if val.Kind() == reflect.Pointer {
if val.IsNil() {
// No data for this struct, so return an empty map. All values will
// be rendered as nil in the resulting table.
return map[string]any{}, nil
}
val = val.Elem()
}
row := map[string]any{}
for i := 0; i < val.NumField(); i++ {
field := val.Type().Field(i)
fieldVal := val.Field(i)
name, recursive, err := parseTableStructTag(field)
if err != nil {
return nil, xerrors.Errorf("parse struct tags for field %q in type %T: %w", field.Name, val, err)
}
if name == "" {
continue
}
// Recurse if it's a struct.
fieldType := field.Type
if recursive {
if !isStructOrStructPointer(fieldType) {
return nil, xerrors.Errorf("field %q in type %q is marked as recursive but does not contain a struct or a pointer to a struct", field.Name, fieldType.String())
}
// valueToTableMap does nothing on pointers so we don't need to
// filter here.
childMap, err := valueToTableMap(fieldVal)
if err != nil {
return nil, xerrors.Errorf("get child field values for field %q in type %q: %w", field.Name, fieldType.String(), err)
}
for childName, childValue := range childMap {
row[fmt.Sprintf("%s %s", name, childName)] = childValue
}
continue
}
// Otherwise, we just use the field value.
row[name] = val.Field(i).Interface()
}
return row, nil
}
// TableHeaders returns the table header names of all
// fields in tSlice. tSlice must be a slice of some type.
func TableHeaders(tSlice any) ([]string, error) {
v := reflect.Indirect(reflect.ValueOf(tSlice))
rawHeaders, err := typeToTableHeaders(v.Type().Elem())
if err != nil {
return nil, xerrors.Errorf("type to table headers: %w", err)
}
out := make([]string, 0, len(rawHeaders))
for _, hdr := range rawHeaders {
out = append(out, strings.Replace(hdr, " ", "_", -1))
}
return out, nil
}
+374
View File
@@ -0,0 +1,374 @@
package cliui_test
import (
"fmt"
"log"
"strings"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/cliui"
)
type stringWrapper struct {
str string
}
var _ fmt.Stringer = stringWrapper{}
func (s stringWrapper) String() string {
return s.str
}
type tableTest1 struct {
Name string `table:"name"`
NotIncluded string // no table tag
Age int `table:"age"`
Roles []string `table:"roles"`
Sub1 tableTest2 `table:"sub_1,recursive"`
Sub2 *tableTest2 `table:"sub_2,recursive"`
Sub3 tableTest3 `table:"sub 3,recursive"`
Sub4 tableTest2 `table:"sub 4"` // not recursive
// Types with special formatting.
Time time.Time `table:"time"`
TimePtr *time.Time `table:"time_ptr"`
}
type tableTest2 struct {
Name stringWrapper `table:"name"`
Age int `table:"age"`
NotIncluded string `table:"-"`
}
type tableTest3 struct {
NotIncluded string // no table tag
Sub tableTest2 `table:"inner,recursive"`
}
func Test_DisplayTable(t *testing.T) {
t.Parallel()
someTime := time.Date(2022, 8, 2, 15, 49, 10, 0, time.UTC)
in := []tableTest1{
{
Name: "foo",
Age: 10,
Roles: []string{"a", "b", "c"},
Sub1: tableTest2{
Name: stringWrapper{str: "foo1"},
Age: 11,
},
Sub2: &tableTest2{
Name: stringWrapper{str: "foo2"},
Age: 12,
},
Sub3: tableTest3{
Sub: tableTest2{
Name: stringWrapper{str: "foo3"},
Age: 13,
},
},
Sub4: tableTest2{
Name: stringWrapper{str: "foo4"},
Age: 14,
},
Time: someTime,
TimePtr: &someTime,
},
{
Name: "bar",
Age: 20,
Roles: []string{"a"},
Sub1: tableTest2{
Name: stringWrapper{str: "bar1"},
Age: 21,
},
Sub2: nil,
Sub3: tableTest3{
Sub: tableTest2{
Name: stringWrapper{str: "bar3"},
Age: 23,
},
},
Sub4: tableTest2{
Name: stringWrapper{str: "bar4"},
Age: 24,
},
Time: someTime,
TimePtr: nil,
},
{
Name: "baz",
Age: 30,
Roles: nil,
Sub1: tableTest2{
Name: stringWrapper{str: "baz1"},
Age: 31,
},
Sub2: nil,
Sub3: tableTest3{
Sub: tableTest2{
Name: stringWrapper{str: "baz3"},
Age: 33,
},
},
Sub4: tableTest2{
Name: stringWrapper{str: "baz4"},
Age: 34,
},
Time: someTime,
TimePtr: nil,
},
}
// This test tests skipping fields without table tags, recursion, pointer
// dereferencing, and nil pointer skipping.
t.Run("OK", func(t *testing.T) {
t.Parallel()
expected := `
NAME AGE ROLES SUB 1 NAME SUB 1 AGE SUB 2 NAME SUB 2 AGE SUB 3 INNER NAME SUB 3 INNER AGE SUB 4 TIME TIME PTR
foo 10 [a b c] foo1 11 foo2 12 foo3 13 {foo4 14 } 2022-08-02T15:49:10Z 2022-08-02T15:49:10Z
bar 20 [a] bar1 21 <nil> <nil> bar3 23 {bar4 24 } 2022-08-02T15:49:10Z <nil>
baz 30 [] baz1 31 <nil> <nil> baz3 33 {baz4 34 } 2022-08-02T15:49:10Z <nil>
`
// Test with non-pointer values.
out, err := cliui.DisplayTable(in, "", nil)
log.Println("rendered table:\n" + out)
require.NoError(t, err)
compareTables(t, expected, out)
// Test with pointer values.
inPtr := make([]*tableTest1, len(in))
for i, v := range in {
v := v
inPtr[i] = &v
}
out, err = cliui.DisplayTable(inPtr, "", nil)
require.NoError(t, err)
compareTables(t, expected, out)
})
t.Run("Sort", func(t *testing.T) {
t.Parallel()
expected := `
NAME AGE ROLES SUB 1 NAME SUB 1 AGE SUB 2 NAME SUB 2 AGE SUB 3 INNER NAME SUB 3 INNER AGE SUB 4 TIME TIME PTR
bar 20 [a] bar1 21 <nil> <nil> bar3 23 {bar4 24 } 2022-08-02T15:49:10Z <nil>
baz 30 [] baz1 31 <nil> <nil> baz3 33 {baz4 34 } 2022-08-02T15:49:10Z <nil>
foo 10 [a b c] foo1 11 foo2 12 foo3 13 {foo4 14 } 2022-08-02T15:49:10Z 2022-08-02T15:49:10Z
`
out, err := cliui.DisplayTable(in, "name", nil)
log.Println("rendered table:\n" + out)
require.NoError(t, err)
compareTables(t, expected, out)
})
t.Run("Filter", func(t *testing.T) {
t.Parallel()
expected := `
NAME SUB 1 NAME SUB 3 INNER NAME TIME
foo foo1 foo3 2022-08-02T15:49:10Z
bar bar1 bar3 2022-08-02T15:49:10Z
baz baz1 baz3 2022-08-02T15:49:10Z
`
out, err := cliui.DisplayTable(in, "", []string{"name", "sub_1_name", "sub_3 inner name", "time"})
log.Println("rendered table:\n" + out)
require.NoError(t, err)
compareTables(t, expected, out)
})
// This test ensures that safeties against invalid use of `table` tags
// causes errors (even without data).
t.Run("Errors", func(t *testing.T) {
t.Parallel()
t.Run("NotSlice", func(t *testing.T) {
t.Parallel()
var in string
_, err := cliui.DisplayTable(in, "", nil)
require.Error(t, err)
})
t.Run("BadSortColumn", func(t *testing.T) {
t.Parallel()
_, err := cliui.DisplayTable(in, "bad_column_does_not_exist", nil)
require.Error(t, err)
})
t.Run("BadFilterColumns", func(t *testing.T) {
t.Parallel()
_, err := cliui.DisplayTable(in, "", []string{"name", "bad_column_does_not_exist"})
require.Error(t, err)
})
t.Run("Interfaces", func(t *testing.T) {
t.Parallel()
t.Run("WithoutData", func(t *testing.T) {
t.Parallel()
var in []any
_, err := cliui.DisplayTable(in, "", nil)
require.Error(t, err)
})
t.Run("WithData", func(t *testing.T) {
t.Parallel()
in := []any{tableTest1{}}
_, err := cliui.DisplayTable(in, "", nil)
require.Error(t, err)
})
})
t.Run("NotStruct", func(t *testing.T) {
t.Parallel()
t.Run("WithoutData", func(t *testing.T) {
t.Parallel()
var in []string
_, err := cliui.DisplayTable(in, "", nil)
require.Error(t, err)
})
t.Run("WithData", func(t *testing.T) {
t.Parallel()
in := []string{"foo", "bar", "baz"}
_, err := cliui.DisplayTable(in, "", nil)
require.Error(t, err)
})
})
t.Run("NoTableTags", func(t *testing.T) {
t.Parallel()
type noTableTagsTest struct {
Field string `json:"field"`
}
t.Run("WithoutData", func(t *testing.T) {
t.Parallel()
var in []noTableTagsTest
_, err := cliui.DisplayTable(in, "", nil)
require.Error(t, err)
})
t.Run("WithData", func(t *testing.T) {
t.Parallel()
in := []noTableTagsTest{{Field: "hi"}}
_, err := cliui.DisplayTable(in, "", nil)
require.Error(t, err)
})
})
t.Run("InvalidTag/NoName", func(t *testing.T) {
t.Parallel()
type noNameTest struct {
Field string `table:""`
}
t.Run("WithoutData", func(t *testing.T) {
t.Parallel()
var in []noNameTest
_, err := cliui.DisplayTable(in, "", nil)
require.Error(t, err)
})
t.Run("WithData", func(t *testing.T) {
t.Parallel()
in := []noNameTest{{Field: "test"}}
_, err := cliui.DisplayTable(in, "", nil)
require.Error(t, err)
})
})
t.Run("InvalidTag/BadSyntax", func(t *testing.T) {
t.Parallel()
type invalidSyntaxTest struct {
Field string `table:"asda,asdjada"`
}
t.Run("WithoutData", func(t *testing.T) {
t.Parallel()
var in []invalidSyntaxTest
_, err := cliui.DisplayTable(in, "", nil)
require.Error(t, err)
})
t.Run("WithData", func(t *testing.T) {
t.Parallel()
in := []invalidSyntaxTest{{Field: "test"}}
_, err := cliui.DisplayTable(in, "", nil)
require.Error(t, err)
})
})
})
}
func Test_TableHeaders(t *testing.T) {
t.Parallel()
s := []tableTest1{}
expectedFields := []string{
"name",
"age",
"roles",
"sub_1_name",
"sub_1_age",
"sub_2_name",
"sub_2_age",
"sub_3_inner_name",
"sub_3_inner_age",
"sub_4",
"time",
"time_ptr",
}
headers, err := cliui.TableHeaders(s)
require.NoError(t, err)
require.EqualValues(t, expectedFields, headers)
}
// compareTables normalizes the incoming table lines
func compareTables(t *testing.T, expected, out string) {
t.Helper()
expectedLines := strings.Split(strings.TrimSpace(expected), "\n")
gotLines := strings.Split(strings.TrimSpace(out), "\n")
assert.Equal(t, len(expectedLines), len(gotLines), "expected line count does not match generated line count")
// Map the expected and got lines to normalize them.
expectedNormalized := make([]string, len(expectedLines))
gotNormalized := make([]string, len(gotLines))
normalizeLine := func(s string) string {
return strings.Join(strings.Fields(strings.TrimSpace(s)), " ")
}
for i, s := range expectedLines {
expectedNormalized[i] = normalizeLine(s)
}
for i, s := range gotLines {
gotNormalized[i] = normalizeLine(s)
}
require.Equal(t, expectedNormalized, gotNormalized, "expected lines to match generated lines")
}
+29
View File
@@ -6,6 +6,10 @@ import (
"path/filepath"
)
const (
FlagName = "global-config"
)
// Root represents the configuration directory.
type Root string
@@ -13,6 +17,11 @@ func (r Root) Session() File {
return File(filepath.Join(string(r), "session"))
}
// ReplicaID is a unique identifier for the Coder server.
func (r Root) ReplicaID() File {
return File(filepath.Join(string(r), "replica_id"))
}
func (r Root) URL() File {
return File(filepath.Join(string(r), "url"))
}
@@ -21,6 +30,26 @@ func (r Root) Organization() File {
return File(filepath.Join(string(r), "organization"))
}
func (r Root) DotfilesURL() File {
return File(filepath.Join(string(r), "dotfilesurl"))
}
func (r Root) PostgresPath() string {
return filepath.Join(string(r), "postgres")
}
func (r Root) PostgresPassword() File {
return File(filepath.Join(r.PostgresPath(), "password"))
}
func (r Root) PostgresPort() File {
return File(filepath.Join(r.PostgresPath(), "port"))
}
func (r Root) DeploymentConfigPath() string {
return filepath.Join(string(r), "server.yaml")
}
// File provides convenience methods for interacting with *os.File.
type File string
+25
View File
@@ -0,0 +1,25 @@
# Coder Server Configuration
# Automatically authenticate HTTP(s) Git requests.
gitauth:
# Supported: azure-devops, bitbucket, github, gitlab
# - type: github
# client_id: xxxxxx
# client_secret: xxxxxx
# Multiple providers are an Enterprise feature.
# Contact sales@coder.com for a license.
#
# If multiple providers are used, a unique "id"
# must be provided for each one.
# - id: example
# type: azure-devops
# client_id: xxxxxxx
# client_secret: xxxxxxx
# A custom regex can be used to match a specific
# repository or organization to limit auth scope.
# regex: github.com/coder
# Custom authentication and token URLs should be
# used for self-managed Git provider deployments.
# auth_url: https://example.com/oauth/authorize
# token_url: https://example.com/oauth/token
+526 -79
View File
@@ -1,15 +1,24 @@
package cli
import (
"bufio"
"bytes"
"context"
"errors"
"fmt"
"io"
"io/fs"
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"sync"
"github.com/cli/safeexec"
"github.com/pkg/diff"
"github.com/pkg/diff/write"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
@@ -18,111 +27,522 @@ import (
"github.com/coder/coder/codersdk"
)
const sshStartToken = "# ------------START-CODER-----------"
const sshStartMessage = `# This was generated by "coder config-ssh".
const (
sshDefaultConfigFileName = "~/.ssh/config"
sshStartToken = "# ------------START-CODER-----------"
sshEndToken = "# ------------END-CODER------------"
sshConfigSectionHeader = "# This section is managed by coder. DO NOT EDIT."
sshConfigDocsHeader = `
#
# To remove this blob, run:
#
# coder config-ssh --remove
#
# You should not hand-edit this section, unless you are deleting it.`
const sshEndToken = "# ------------END-CODER------------"
# You should not hand-edit this section unless you are removing it, all
# changes will be lost when running "coder config-ssh".
`
sshConfigOptionsHeader = `#
# Last config-ssh options:
`
)
// sshConfigOptions represents options that can be stored and read
// from the coder config in ~/.ssh/coder.
type sshConfigOptions struct {
sshOptions []string
}
func (o sshConfigOptions) equal(other sshConfigOptions) bool {
// Compare without side-effects or regard to order.
opt1 := slices.Clone(o.sshOptions)
sort.Strings(opt1)
opt2 := slices.Clone(other.sshOptions)
sort.Strings(opt2)
return slices.Equal(opt1, opt2)
}
func (o sshConfigOptions) asList() (list []string) {
for _, opt := range o.sshOptions {
list = append(list, fmt.Sprintf("ssh-option: %s", opt))
}
return list
}
type sshWorkspaceConfig struct {
Name string
Hosts []string
}
func sshFetchWorkspaceConfigs(ctx context.Context, client *codersdk.Client) ([]sshWorkspaceConfig, error) {
res, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
Owner: codersdk.Me,
})
if err != nil {
return nil, err
}
var errGroup errgroup.Group
workspaceConfigs := make([]sshWorkspaceConfig, len(res.Workspaces))
for i, workspace := range res.Workspaces {
i := i
workspace := workspace
errGroup.Go(func() error {
resources, err := client.TemplateVersionResources(ctx, workspace.LatestBuild.TemplateVersionID)
if err != nil {
return err
}
wc := sshWorkspaceConfig{Name: workspace.Name}
var agents []codersdk.WorkspaceAgent
for _, resource := range resources {
if resource.Transition != codersdk.WorkspaceTransitionStart {
continue
}
agents = append(agents, resource.Agents...)
}
// handle both WORKSPACE and WORKSPACE.AGENT syntax
if len(agents) == 1 {
wc.Hosts = append(wc.Hosts, workspace.Name)
}
for _, agent := range agents {
hostname := workspace.Name + "." + agent.Name
wc.Hosts = append(wc.Hosts, hostname)
}
workspaceConfigs[i] = wc
return nil
})
}
err = errGroup.Wait()
if err != nil {
return nil, err
}
return workspaceConfigs, nil
}
func sshPrepareWorkspaceConfigs(ctx context.Context, client *codersdk.Client) (receive func() ([]sshWorkspaceConfig, error)) {
wcC := make(chan []sshWorkspaceConfig, 1)
errC := make(chan error, 1)
go func() {
wc, err := sshFetchWorkspaceConfigs(ctx, client)
wcC <- wc
errC <- err
}()
return func() ([]sshWorkspaceConfig, error) {
return <-wcC, <-errC
}
}
func configSSH() *cobra.Command {
var (
sshConfigFile string
sshConfigFile string
sshConfigOpts sshConfigOptions
usePreviousOpts bool
dryRun bool
skipProxyCommand bool
)
cmd := &cobra.Command{
Use: "config-ssh",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := createClient(cmd)
Annotations: workspaceCommand,
Use: "config-ssh",
Short: "Add an SSH Host entry for your workspaces \"ssh coder.workspace\"",
Example: formatExamples(
example{
Description: "You can use -o (or --ssh-option) so set SSH options to be used for all your workspaces",
Command: "coder config-ssh -o ForwardAgent=yes",
},
example{
Description: "You can use --dry-run (or -n) to see the changes that would be made",
Command: "coder config-ssh --dry-run",
},
),
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, _ []string) error {
client, err := CreateClient(cmd)
if err != nil {
return err
}
recvWorkspaceConfigs := sshPrepareWorkspaceConfigs(cmd.Context(), client)
out := cmd.OutOrStdout()
if dryRun {
// Print everything except diff to stderr so
// that it's possible to capture the diff.
out = cmd.OutOrStderr()
}
coderBinary, err := currentBinPath(out)
if err != nil {
return err
}
escapedCoderBinary, err := sshConfigExecEscape(coderBinary)
if err != nil {
return xerrors.Errorf("escape coder binary for ssh failed: %w", err)
}
root := createConfig(cmd)
escapedGlobalConfig, err := sshConfigExecEscape(string(root))
if err != nil {
return xerrors.Errorf("escape global config for ssh failed: %w", err)
}
homedir, err := os.UserHomeDir()
if err != nil {
return xerrors.Errorf("user home dir failed: %w", err)
}
if strings.HasPrefix(sshConfigFile, "~/") {
dirname, _ := os.UserHomeDir()
sshConfigFile = filepath.Join(dirname, sshConfigFile[2:])
}
// Doesn't matter if this fails, because we write the file anyways.
sshConfigContentRaw, _ := os.ReadFile(sshConfigFile)
sshConfigContent := string(sshConfigContentRaw)
startIndex := strings.Index(sshConfigContent, sshStartToken)
endIndex := strings.Index(sshConfigContent, sshEndToken)
if startIndex != -1 && endIndex != -1 {
sshConfigContent = sshConfigContent[:startIndex-1] + sshConfigContent[endIndex+len(sshEndToken):]
sshConfigFile = filepath.Join(homedir, sshConfigFile[2:])
}
workspaces, err := client.WorkspacesByUser(cmd.Context(), "")
if err != nil {
return err
}
if len(workspaces) == 0 {
return xerrors.New("You don't have any workspaces!")
}
binPath, err := currentBinPath(cmd)
if err != nil {
return err
// Only allow not-exist errors to avoid trashing
// the users SSH config.
configRaw, err := os.ReadFile(sshConfigFile)
if err != nil && !errors.Is(err, fs.ErrNotExist) {
return xerrors.Errorf("read ssh config failed: %w", err)
}
sshConfigContent += "\n" + sshStartToken + "\n" + sshStartMessage + "\n\n"
sshConfigContentMutex := sync.Mutex{}
var errGroup errgroup.Group
for _, workspace := range workspaces {
workspace := workspace
errGroup.Go(func() error {
resources, err := client.WorkspaceResourcesByBuild(cmd.Context(), workspace.LatestBuild.ID)
if err != nil {
return err
}
resourcesWithAgents := make([]codersdk.WorkspaceResource, 0)
for _, resource := range resources {
if resource.Agent == nil {
continue
}
resourcesWithAgents = append(resourcesWithAgents, resource)
}
sshConfigContentMutex.Lock()
defer sshConfigContentMutex.Unlock()
if len(resourcesWithAgents) == 1 {
sshConfigContent += strings.Join([]string{
"Host coder." + workspace.Name,
"\tHostName coder." + workspace.Name,
fmt.Sprintf("\tProxyCommand %q ssh --stdio %s", binPath, workspace.Name),
"\tConnectTimeout=0",
"\tStrictHostKeyChecking=no",
}, "\n") + "\n"
}
// Keep track of changes we are making.
var changes []string
return nil
// Parse the previous configuration only if config-ssh
// has been run previously.
var lastConfig *sshConfigOptions
if section, ok := sshConfigGetCoderSection(configRaw); ok {
c := sshConfigParseLastOptions(bytes.NewReader(section))
lastConfig = &c
}
// Avoid prompting in diff mode (unexpected behavior)
// or when a previous config does not exist.
if usePreviousOpts && lastConfig != nil {
sshConfigOpts = *lastConfig
} else if lastConfig != nil && !sshConfigOpts.equal(*lastConfig) {
newOpts := sshConfigOpts.asList()
newOptsMsg := "\n\n New options: none"
if len(newOpts) > 0 {
newOptsMsg = fmt.Sprintf("\n\n New options:\n * %s", strings.Join(newOpts, "\n * "))
}
oldOpts := lastConfig.asList()
oldOptsMsg := "\n\n Previous options: none"
if len(oldOpts) > 0 {
oldOptsMsg = fmt.Sprintf("\n\n Previous options:\n * %s", strings.Join(oldOpts, "\n * "))
}
line, err := cliui.Prompt(cmd, cliui.PromptOptions{
Text: fmt.Sprintf("New options differ from previous options:%s%s\n\n Use new options?", newOptsMsg, oldOptsMsg),
IsConfirm: true,
})
if err != nil {
if line == "" && xerrors.Is(err, cliui.Canceled) {
return nil
}
// Selecting "no" will use the last config.
sshConfigOpts = *lastConfig
} else {
changes = append(changes, "Use new SSH options")
}
// Only print when prompts are shown.
if yes, _ := cmd.Flags().GetBool("yes"); !yes {
_, _ = fmt.Fprint(out, "\n")
}
}
err = errGroup.Wait()
configModified := configRaw
buf := &bytes.Buffer{}
before, after := sshConfigSplitOnCoderSection(configModified)
// Write the first half of the users config file to buf.
_, _ = buf.Write(before)
// Write comment and store the provided options as part
// of the config for future (re)use.
newline := len(before) > 0
sshConfigWriteSectionHeader(buf, newline, sshConfigOpts)
workspaceConfigs, err := recvWorkspaceConfigs()
if err != nil {
return err
return xerrors.Errorf("fetch workspace configs failed: %w", err)
}
sshConfigContent += "\n" + sshEndToken
err = os.MkdirAll(filepath.Dir(sshConfigFile), os.ModePerm)
if err != nil {
return err
// Ensure stable sorting of output.
slices.SortFunc(workspaceConfigs, func(a, b sshWorkspaceConfig) bool {
return a.Name < b.Name
})
for _, wc := range workspaceConfigs {
sort.Strings(wc.Hosts)
// Write agent configuration.
for _, hostname := range wc.Hosts {
configOptions := []string{
"Host coder." + hostname,
}
for _, option := range sshConfigOpts.sshOptions {
configOptions = append(configOptions, "\t"+option)
}
configOptions = append(configOptions,
"\tHostName coder."+hostname,
"\tConnectTimeout=0",
"\tStrictHostKeyChecking=no",
// Without this, the "REMOTE HOST IDENTITY CHANGED"
// message will appear.
"\tUserKnownHostsFile=/dev/null",
// This disables the "Warning: Permanently added 'hostname' (RSA) to the list of known hosts."
// message from appearing on every SSH. This happens because we ignore the known hosts.
"\tLogLevel ERROR",
)
if !skipProxyCommand {
configOptions = append(
configOptions,
fmt.Sprintf(
"\tProxyCommand %s --global-config %s ssh --stdio %s",
escapedCoderBinary, escapedGlobalConfig, hostname,
),
)
}
_, _ = buf.WriteString(strings.Join(configOptions, "\n"))
_ = buf.WriteByte('\n')
}
}
err = os.WriteFile(sshConfigFile, []byte(sshConfigContent), os.ModePerm)
if err != nil {
return err
sshConfigWriteSectionEnd(buf)
// Write the remainder of the users config file to buf.
_, _ = buf.Write(after)
if !bytes.Equal(configModified, buf.Bytes()) {
changes = append(changes, fmt.Sprintf("Update the coder section in %s", sshConfigFile))
configModified = buf.Bytes()
}
if len(changes) == 0 {
_, _ = fmt.Fprintf(out, "No changes to make.\n")
return nil
}
if dryRun {
_, _ = fmt.Fprintf(out, "Dry run, the following changes would be made to your SSH configuration:\n\n * %s\n\n", strings.Join(changes, "\n * "))
color := isTTYOut(cmd)
diff, err := diffBytes(sshConfigFile, configRaw, configModified, color)
if err != nil {
return xerrors.Errorf("diff failed: %w", err)
}
if len(diff) > 0 {
// Write diff to stdout.
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s", diff)
}
return nil
}
if len(changes) > 0 {
_, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: fmt.Sprintf("The following changes will be made to your SSH configuration:\n\n * %s\n\n Continue?", strings.Join(changes, "\n * ")),
IsConfirm: true,
})
if err != nil {
return nil
}
// Only print when prompts are shown.
if yes, _ := cmd.Flags().GetBool("yes"); !yes {
_, _ = fmt.Fprint(out, "\n")
}
}
if !bytes.Equal(configRaw, configModified) {
err = writeWithTempFileAndMove(sshConfigFile, bytes.NewReader(configModified))
if err != nil {
return xerrors.Errorf("write ssh config failed: %w", err)
}
}
if len(workspaceConfigs) > 0 {
_, _ = fmt.Fprintln(out, "You should now be able to ssh into your workspace.")
_, _ = fmt.Fprintf(out, "For example, try running:\n\n\t$ ssh coder.%s\n", workspaceConfigs[0].Name)
} else {
_, _ = fmt.Fprint(out, "You don't have any workspaces yet, try creating one with:\n\n\t$ coder create <workspace>\n")
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "An auto-generated ssh config was written to %q\n", sshConfigFile)
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "You should now be able to ssh into your workspace")
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "For example, try running\n\n\t$ ssh coder.%s\n\n", workspaces[0].Name)
return nil
},
}
cliflag.StringVarP(cmd.Flags(), &sshConfigFile, "ssh-config-file", "", "CODER_SSH_CONFIG_FILE", "~/.ssh/config", "Specifies the path to an SSH config.")
cliflag.StringVarP(cmd.Flags(), &sshConfigFile, "ssh-config-file", "", "CODER_SSH_CONFIG_FILE", sshDefaultConfigFileName, "Specifies the path to an SSH config.")
cmd.Flags().StringArrayVarP(&sshConfigOpts.sshOptions, "ssh-option", "o", []string{}, "Specifies additional SSH options to embed in each host stanza.")
cmd.Flags().BoolVarP(&dryRun, "dry-run", "n", false, "Perform a trial run with no changes made, showing a diff at the end.")
cmd.Flags().BoolVarP(&skipProxyCommand, "skip-proxy-command", "", false, "Specifies whether the ProxyCommand option should be skipped. Useful for testing.")
_ = cmd.Flags().MarkHidden("skip-proxy-command")
cliflag.BoolVarP(cmd.Flags(), &usePreviousOpts, "use-previous-options", "", "CODER_SSH_USE_PREVIOUS_OPTIONS", false, "Specifies whether or not to keep options from previous run of config-ssh.")
cliui.AllowSkipPrompt(cmd)
return cmd
}
//nolint:revive
func sshConfigWriteSectionHeader(w io.Writer, addNewline bool, o sshConfigOptions) {
nl := "\n"
if !addNewline {
nl = ""
}
_, _ = fmt.Fprint(w, nl+sshStartToken+"\n")
_, _ = fmt.Fprint(w, sshConfigSectionHeader)
_, _ = fmt.Fprint(w, sshConfigDocsHeader)
if len(o.sshOptions) > 0 {
_, _ = fmt.Fprint(w, sshConfigOptionsHeader)
for _, opt := range o.sshOptions {
_, _ = fmt.Fprintf(w, "# :%s=%s\n", "ssh-option", opt)
}
}
_, _ = fmt.Fprint(w, "#\n")
}
func sshConfigWriteSectionEnd(w io.Writer) {
_, _ = fmt.Fprint(w, sshEndToken+"\n")
}
func sshConfigParseLastOptions(r io.Reader) (o sshConfigOptions) {
s := bufio.NewScanner(r)
for s.Scan() {
line := s.Text()
if strings.HasPrefix(line, "# :") {
line = strings.TrimPrefix(line, "# :")
parts := strings.SplitN(line, "=", 2)
switch parts[0] {
case "ssh-option":
o.sshOptions = append(o.sshOptions, parts[1])
default:
// Unknown option, ignore.
}
}
}
if err := s.Err(); err != nil {
panic(err)
}
return o
}
func sshConfigGetCoderSection(data []byte) (section []byte, ok bool) {
startIndex := bytes.Index(data, []byte(sshStartToken))
endIndex := bytes.Index(data, []byte(sshEndToken))
if startIndex != -1 && endIndex != -1 {
return data[startIndex : endIndex+len(sshEndToken)], true
}
return nil, false
}
// sshConfigSplitOnCoderSection splits the SSH config into two sections,
// before contains the lines before sshStartToken and after contains the
// lines after sshEndToken.
func sshConfigSplitOnCoderSection(data []byte) (before, after []byte) {
startIndex := bytes.Index(data, []byte(sshStartToken))
endIndex := bytes.Index(data, []byte(sshEndToken))
if startIndex != -1 && endIndex != -1 {
// We use -1 and +1 here to also include the preceding
// and trailing newline, where applicable.
start := startIndex
if start > 0 {
start--
}
end := endIndex + len(sshEndToken)
if end < len(data) {
end++
}
return data[:start], data[end:]
}
return data, nil
}
// writeWithTempFileAndMove writes to a temporary file in the same
// directory as path and renames the temp file to the file provided in
// path. This ensure we avoid trashing the file we are writing due to
// unforeseen circumstance like filesystem full, command killed, etc.
func writeWithTempFileAndMove(path string, r io.Reader) (err error) {
dir := filepath.Dir(path)
name := filepath.Base(path)
// Ensure that e.g. the ~/.ssh directory exists.
if err = os.MkdirAll(dir, 0o700); err != nil {
return xerrors.Errorf("create directory: %w", err)
}
// Create a tempfile in the same directory for ensuring write
// operation does not fail.
f, err := os.CreateTemp(dir, fmt.Sprintf(".%s.", name))
if err != nil {
return xerrors.Errorf("create temp file failed: %w", err)
}
defer func() {
if err != nil {
_ = os.Remove(f.Name()) // Cleanup in case a step failed.
}
}()
_, err = io.Copy(f, r)
if err != nil {
_ = f.Close()
return xerrors.Errorf("write temp file failed: %w", err)
}
err = f.Close()
if err != nil {
return xerrors.Errorf("close temp file failed: %w", err)
}
err = os.Rename(f.Name(), path)
if err != nil {
return xerrors.Errorf("rename temp file failed: %w", err)
}
return nil
}
// sshConfigExecEscape quotes the string if it contains spaces, as per
// `man 5 ssh_config`. However, OpenSSH uses exec in the users shell to
// run the command, and as such the formatting/escape requirements
// cannot simply be covered by `fmt.Sprintf("%q", path)`.
//
// Always escaping the path with `fmt.Sprintf("%q", path)` usually works
// on most platforms, but double quotes sometimes break on Windows 10
// (see #2853). This function takes a best-effort approach to improving
// compatibility and covering edge cases.
//
// Given the following ProxyCommand:
//
// ProxyCommand "/path/with space/coder" ssh --stdio work
//
// This is ~what OpenSSH would execute:
//
// /bin/bash -c '"/path/with space/to/coder" ssh --stdio workspace'
//
// However, since it's actually an arg in C, the contents inside the
// single quotes are interpreted as is, e.g. if there was a '\t', it
// would be the literal string '\t', not a tab.
//
// See:
// - https://github.com/coder/coder/issues/2853
// - https://github.com/openssh/openssh-portable/blob/V_9_0_P1/sshconnect.c#L158-L167
// - https://github.com/PowerShell/openssh-portable/blob/v8.1.0.0/sshconnect.c#L231-L293
// - https://github.com/PowerShell/openssh-portable/blob/v8.1.0.0/contrib/win32/win32compat/w32fd.c#L1075-L1100
func sshConfigExecEscape(path string) (string, error) {
// This is unlikely to ever happen, but newlines are allowed on
// certain filesystems, but cannot be used inside ssh config.
if strings.ContainsAny(path, "\n") {
return "", xerrors.Errorf("invalid path: %s", path)
}
// In the unlikely even that a path contains quotes, they must be
// escaped so that they are not interpreted as shell quotes.
if strings.Contains(path, "\"") {
path = strings.ReplaceAll(path, "\"", "\\\"")
}
// A space or a tab requires quoting, but tabs must not be escaped
// (\t) since OpenSSH interprets it as a literal \t, not a tab.
if strings.ContainsAny(path, " \t") {
path = fmt.Sprintf("\"%s\"", path) //nolint:gocritic // We don't want %q here.
}
return path, nil
}
// currentBinPath returns the path to the coder binary suitable for use in ssh
// ProxyCommand.
func currentBinPath(cmd *cobra.Command) (string, error) {
func currentBinPath(w io.Writer) (string, error) {
exePath, err := os.Executable()
if err != nil {
return "", xerrors.Errorf("get executable path: %w", err)
@@ -138,11 +558,12 @@ func currentBinPath(cmd *cobra.Command) (string, error) {
// correctly. Check if the current executable is in $PATH, and warn the user
// if it isn't.
if err != nil && runtime.GOOS == "windows" {
cliui.Warn(cmd.OutOrStdout(),
cliui.Warn(w,
"The current executable is not in $PATH.",
"This may lead to problems connecting to your workspace via SSH.",
fmt.Sprintf("Please move %q to a location in your $PATH (such as System32) and run `%s config-ssh` again.", binName, binName),
)
_, _ = fmt.Fprint(w, "\n")
// Return the exePath so SSH at least works outside of Msys2.
return exePath, nil
}
@@ -150,13 +571,39 @@ func currentBinPath(cmd *cobra.Command) (string, error) {
// Warn the user if the current executable is not the same as the one in
// $PATH.
if filepath.Clean(pathPath) != filepath.Clean(exePath) {
cliui.Warn(cmd.OutOrStdout(),
cliui.Warn(w,
"The current executable path does not match the executable path found in $PATH.",
"This may cause issues connecting to your workspace via SSH.",
fmt.Sprintf("\tCurrent executable path: %q", exePath),
fmt.Sprintf("\tExecutable path in $PATH: %q", pathPath),
)
_, _ = fmt.Fprint(w, "\n")
}
return binName, nil
return exePath, nil
}
// diffBytes takes two byte slices and diffs them as if they were in a
// file named name.
// nolint: revive // Color is an option, not a control coupling.
func diffBytes(name string, b1, b2 []byte, color bool) ([]byte, error) {
var buf bytes.Buffer
var opts []write.Option
if color {
opts = append(opts, write.TerminalColor())
}
err := diff.Text(name, name, b1, b2, &buf, opts...)
if err != nil {
return nil, err
}
b := buf.Bytes()
// Check if diff only output two lines, if yes, there's no diff.
//
// Example:
// --- /home/user/.ssh/config
// +++ /home/user/.ssh/config
if bytes.Count(b, []byte{'\n'}) == 2 {
b = nil
}
return b, nil
}
+62
View File
@@ -0,0 +1,62 @@
package cli
import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
// This test tries to mimic the behavior of OpenSSH
// when executing e.g. a ProxyCommand.
func Test_sshConfigExecEscape(t *testing.T) {
t.Parallel()
tests := []struct {
name string
path string
wantErr bool
windows bool
}{
{"no spaces", "simple", false, true},
{"spaces", "path with spaces", false, true},
{"quotes", "path with \"quotes\"", false, false},
{"backslashes", "path with \\backslashes", false, false},
{"tabs", "path with \ttabs", false, false},
{"newline fails", "path with \nnewline", true, false},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("Windows doesn't typically execute via /bin/sh or cmd.exe, so this test is not applicable.")
}
dir := filepath.Join(t.TempDir(), tt.path)
err := os.MkdirAll(dir, 0o755)
require.NoError(t, err)
bin := filepath.Join(dir, "coder")
contents := []byte("#!/bin/sh\necho yay\n")
err = os.WriteFile(bin, contents, 0o755) //nolint:gosec
require.NoError(t, err)
escaped, err := sshConfigExecEscape(bin)
if tt.wantErr {
require.Error(t, err)
return
}
require.NoError(t, err)
b, err := exec.Command("/bin/sh", "-c", escaped).CombinedOutput() //nolint:gosec
require.NoError(t, err)
got := strings.TrimSpace(string(b))
require.Equal(t, "yay", got)
})
}
}
+721 -26
View File
@@ -1,41 +1,736 @@
package cli_test
import (
"bufio"
"bytes"
"context"
"fmt"
"io"
"net"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"sync"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"cdr.dev/slog/sloggers/slogtest"
"github.com/coder/coder/agent"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/provisioner/echo"
"github.com/coder/coder/provisionersdk/proto"
"github.com/coder/coder/pty/ptytest"
"github.com/stretchr/testify/require"
"github.com/coder/coder/testutil"
)
func sshConfigFileName(t *testing.T) (sshConfig string) {
t.Helper()
tmpdir := t.TempDir()
dotssh := filepath.Join(tmpdir, ".ssh")
err := os.Mkdir(dotssh, 0o700)
require.NoError(t, err)
n := filepath.Join(dotssh, "config")
return n
}
func sshConfigFileCreate(t *testing.T, name string, data io.Reader) {
t.Helper()
t.Logf("Writing %s", name)
f, err := os.Create(name)
require.NoError(t, err)
n, err := io.Copy(f, data)
t.Logf("Wrote %d", n)
require.NoError(t, err)
err = f.Close()
require.NoError(t, err)
}
func sshConfigFileRead(t *testing.T, name string) string {
t.Helper()
b, err := os.ReadFile(name)
require.NoError(t, err)
return string(b)
}
func TestConfigSSH(t *testing.T) {
t.Parallel()
t.Run("Create", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
user := coderdtest.CreateFirstUser(t, client)
coderdtest.NewProvisionerDaemon(t, client)
version := coderdtest.CreateProjectVersion(t, client, user.OrganizationID, nil)
coderdtest.AwaitProjectVersionJob(t, client, version.ID)
project := coderdtest.CreateProject(t, client, user.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, "", project.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
tempFile, err := os.CreateTemp(t.TempDir(), "")
require.NoError(t, err)
_ = tempFile.Close()
cmd, root := clitest.New(t, "config-ssh", "--ssh-config-file", tempFile.Name())
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
require.NoError(t, err)
}()
<-doneChan
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
authToken := uuid.NewString()
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
ProvisionPlan: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
Resources: []*proto.Resource{{
Name: "example",
Type: "aws_instance",
Agents: []*proto.Agent{{
Id: uuid.NewString(),
Name: "example",
}},
}},
},
},
}},
ProvisionApply: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
Resources: []*proto.Resource{{
Name: "example",
Type: "aws_instance",
Agents: []*proto.Agent{{
Id: uuid.NewString(),
Name: "example",
Auth: &proto.Agent_Token{
Token: authToken,
},
}},
}},
},
},
}},
})
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
agentClient := codersdk.New(client.URL)
agentClient.SetSessionToken(authToken)
agentCloser := agent.New(agent.Options{
Client: agentClient,
Logger: slogtest.Make(t, nil).Named("agent"),
})
defer func() {
_ = agentCloser.Close()
}()
resources := coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
agentConn, err := client.DialWorkspaceAgent(context.Background(), resources[0].Agents[0].ID, nil)
require.NoError(t, err)
defer agentConn.Close()
listener, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)
defer func() {
_ = listener.Close()
}()
copyDone := make(chan struct{})
go func() {
defer close(copyDone)
var wg sync.WaitGroup
for {
conn, err := listener.Accept()
if err != nil {
break
}
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
ssh, err := agentConn.SSH(ctx)
cancel()
assert.NoError(t, err)
wg.Add(2)
go func() {
defer wg.Done()
_, _ = io.Copy(conn, ssh)
}()
go func() {
defer wg.Done()
_, _ = io.Copy(ssh, conn)
}()
}
wg.Wait()
}()
sshConfigFile := sshConfigFileName(t)
tcpAddr, valid := listener.Addr().(*net.TCPAddr)
require.True(t, valid)
cmd, root := clitest.New(t, "config-ssh",
"--ssh-option", "HostName "+tcpAddr.IP.String(),
"--ssh-option", "Port "+strconv.Itoa(tcpAddr.Port),
"--ssh-config-file", sshConfigFile,
"--skip-proxy-command")
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
assert.NoError(t, err)
}()
matches := []struct {
match, write string
}{
{match: "Continue?", write: "yes"},
}
for _, m := range matches {
pty.ExpectMatch(m.match)
pty.WriteLine(m.write)
}
<-doneChan
home := filepath.Dir(filepath.Dir(sshConfigFile))
// #nosec
sshCmd := exec.Command("ssh", "-F", sshConfigFile, "coder."+workspace.Name, "echo", "test")
pty = ptytest.New(t)
// Set HOME because coder config is included from ~/.ssh/coder.
sshCmd.Env = append(sshCmd.Env, fmt.Sprintf("HOME=%s", home))
sshCmd.Stderr = pty.Output()
data, err := sshCmd.Output()
require.NoError(t, err)
require.Equal(t, "test", strings.TrimSpace(string(data)))
_ = listener.Close()
<-copyDone
}
func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
t.Parallel()
headerStart := strings.Join([]string{
"# ------------START-CODER-----------",
"# This section is managed by coder. DO NOT EDIT.",
"#",
"# You should not hand-edit this section unless you are removing it, all",
"# changes will be lost when running \"coder config-ssh\".",
"#",
}, "\n")
headerEnd := "# ------------END-CODER------------"
baseHeader := strings.Join([]string{
headerStart,
headerEnd,
}, "\n")
type writeConfig struct {
ssh string
}
type wantConfig struct {
ssh string
}
type match struct {
match, write string
}
tests := []struct {
name string
args []string
matches []match
writeConfig writeConfig
wantConfig wantConfig
wantErr bool
}{
{
name: "Config file is created",
matches: []match{
{match: "Continue?", write: "yes"},
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
baseHeader,
"",
}, "\n"),
},
},
{
name: "Section is written after user content",
writeConfig: writeConfig{
ssh: strings.Join([]string{
"Host myhost",
" HostName myhost",
}, "\n"),
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
"Host myhost",
" HostName myhost",
baseHeader,
"",
}, "\n"),
},
matches: []match{
{match: "Continue?", write: "yes"},
},
},
{
name: "Section is not moved on re-run",
writeConfig: writeConfig{
ssh: strings.Join([]string{
"Host myhost",
" HostName myhost",
"",
baseHeader,
"",
"Host otherhost",
" HostName otherhost",
"",
}, "\n"),
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
"Host myhost",
" HostName myhost",
"",
baseHeader,
"",
"Host otherhost",
" HostName otherhost",
"",
}, "\n"),
},
},
{
name: "Section is not moved on re-run with new options",
writeConfig: writeConfig{
ssh: strings.Join([]string{
"Host myhost",
" HostName myhost",
"",
baseHeader,
"",
"Host otherhost",
" HostName otherhost",
"",
}, "\n"),
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
"Host myhost",
" HostName myhost",
"",
headerStart,
"# Last config-ssh options:",
"# :ssh-option=ForwardAgent=yes",
"#",
headerEnd,
"",
"Host otherhost",
" HostName otherhost",
"",
}, "\n"),
},
args: []string{
"--ssh-option", "ForwardAgent=yes",
},
matches: []match{
{match: "Use new options?", write: "yes"},
{match: "Continue?", write: "yes"},
},
},
{
name: "Adds newline at EOF",
writeConfig: writeConfig{
ssh: strings.Join([]string{
baseHeader,
}, "\n"),
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
baseHeader,
"",
}, "\n"),
},
matches: []match{
{match: "Continue?", write: "yes"},
},
},
{
name: "Do not prompt for new options on first run",
writeConfig: writeConfig{
ssh: "",
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
headerStart,
"# Last config-ssh options:",
"# :ssh-option=ForwardAgent=yes",
"#",
headerEnd,
"",
}, "\n"),
},
args: []string{"--ssh-option", "ForwardAgent=yes"},
matches: []match{
{match: "Continue?", write: "yes"},
},
},
{
name: "Prompt for new options when there are no previous options",
writeConfig: writeConfig{
ssh: strings.Join([]string{
baseHeader,
}, "\n"),
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
headerStart,
"# Last config-ssh options:",
"# :ssh-option=ForwardAgent=yes",
"#",
headerEnd,
"",
}, "\n"),
},
args: []string{"--ssh-option", "ForwardAgent=yes"},
matches: []match{
{match: "Use new options?", write: "yes"},
{match: "Continue?", write: "yes"},
},
},
{
name: "Prompt for new options when there are previous options",
writeConfig: writeConfig{
ssh: strings.Join([]string{
headerStart,
"# Last config-ssh options:",
"# :ssh-option=ForwardAgent=yes",
"#",
headerEnd,
}, "\n"),
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
baseHeader,
"",
}, "\n"),
},
matches: []match{
{match: "Use new options?", write: "yes"},
{match: "Continue?", write: "yes"},
},
},
{
name: "No prompt on no changes",
writeConfig: writeConfig{
ssh: strings.Join([]string{
headerStart,
"# Last config-ssh options:",
"# :ssh-option=ForwardAgent=yes",
"#",
headerEnd,
"",
}, "\n"),
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
headerStart,
"# Last config-ssh options:",
"# :ssh-option=ForwardAgent=yes",
"#",
headerEnd,
"",
}, "\n"),
},
args: []string{"--ssh-option", "ForwardAgent=yes"},
},
{
name: "No changes when continue = no",
writeConfig: writeConfig{
ssh: strings.Join([]string{
headerStart,
"# Last config-ssh options:",
"# :ssh-option=ForwardAgent=yes",
"#",
headerEnd,
"",
}, "\n"),
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
headerStart,
"# Last config-ssh options:",
"# :ssh-option=ForwardAgent=yes",
"#",
headerEnd,
"",
}, "\n"),
},
args: []string{"--ssh-option", "ForwardAgent=no"},
matches: []match{
{match: "Use new options?", write: "yes"},
{match: "Continue?", write: "no"},
},
},
{
name: "Do not prompt when using --yes",
writeConfig: writeConfig{
ssh: strings.Join([]string{
headerStart,
"# Last config-ssh options:",
"# :ssh-option=ForwardAgent=yes",
"#",
headerEnd,
"",
}, "\n"),
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
// Last options overwritten.
baseHeader,
"",
}, "\n"),
},
args: []string{"--yes"},
},
{
name: "Do not prompt for new options when prev opts flag is set",
writeConfig: writeConfig{
ssh: strings.Join([]string{
headerStart,
"# Last config-ssh options:",
"# :ssh-option=ForwardAgent=yes",
"#",
headerEnd,
"",
}, "\n"),
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
headerStart,
"# Last config-ssh options:",
"# :ssh-option=ForwardAgent=yes",
"#",
headerEnd,
"",
}, "\n"),
},
args: []string{
"--use-previous-options",
"--yes",
},
},
{
name: "Do not overwrite config when using --dry-run",
writeConfig: writeConfig{
ssh: strings.Join([]string{
baseHeader,
"",
}, "\n"),
},
wantConfig: wantConfig{
ssh: strings.Join([]string{
baseHeader,
"",
}, "\n"),
},
args: []string{
"--ssh-option", "ForwardAgent=yes",
"--dry-run",
"--yes",
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
var (
client = coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user = coderdtest.CreateFirstUser(t, client)
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID)
_ = coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
)
// Prepare ssh config files.
sshConfigName := sshConfigFileName(t)
if tt.writeConfig.ssh != "" {
sshConfigFileCreate(t, sshConfigName, strings.NewReader(tt.writeConfig.ssh))
}
args := []string{
"config-ssh",
"--ssh-config-file", sshConfigName,
}
args = append(args, tt.args...)
cmd, root := clitest.New(t, args...)
clitest.SetupConfig(t, client, root)
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
done := tGo(t, func() {
err := cmd.Execute()
if !tt.wantErr {
assert.NoError(t, err)
} else {
assert.Error(t, err)
}
})
for _, m := range tt.matches {
pty.ExpectMatch(m.match)
pty.WriteLine(m.write)
}
<-done
if tt.wantConfig.ssh != "" {
got := sshConfigFileRead(t, sshConfigName)
assert.Equal(t, tt.wantConfig.ssh, got)
}
})
}
}
func TestConfigSSH_Hostnames(t *testing.T) {
t.Parallel()
type resourceSpec struct {
name string
agents []string
}
tests := []struct {
name string
resources []resourceSpec
expected []string
}{
{
name: "one resource with one agent",
resources: []resourceSpec{
{name: "foo", agents: []string{"agent1"}},
},
expected: []string{"coder.@", "coder.@.agent1"},
},
{
name: "one resource with two agents",
resources: []resourceSpec{
{name: "foo", agents: []string{"agent1", "agent2"}},
},
expected: []string{"coder.@.agent1", "coder.@.agent2"},
},
{
name: "two resources with one agent",
resources: []resourceSpec{
{name: "foo", agents: []string{"agent1"}},
{name: "bar"},
},
expected: []string{"coder.@", "coder.@.agent1"},
},
{
name: "two resources with two agents",
resources: []resourceSpec{
{name: "foo", agents: []string{"agent1"}},
{name: "bar", agents: []string{"agent2"}},
},
expected: []string{"coder.@.agent1", "coder.@.agent2"},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
var resources []*proto.Resource
for _, resourceSpec := range tt.resources {
resource := &proto.Resource{
Name: resourceSpec.name,
Type: "aws_instance",
}
for _, agentName := range resourceSpec.agents {
resource.Agents = append(resource.Agents, &proto.Agent{
Id: uuid.NewString(),
Name: agentName,
})
}
resources = append(resources, resource)
}
provisionResponse := []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
Resources: resources,
},
},
}}
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
// authToken := uuid.NewString()
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
ProvisionPlan: provisionResponse,
ProvisionApply: provisionResponse,
})
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
sshConfigFile := sshConfigFileName(t)
cmd, root := clitest.New(t, "config-ssh", "--ssh-config-file", sshConfigFile)
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
assert.NoError(t, err)
}()
matches := []struct {
match, write string
}{
{match: "Continue?", write: "yes"},
}
for _, m := range matches {
pty.ExpectMatch(m.match)
pty.WriteLine(m.write)
}
<-doneChan
var expectedHosts []string
for _, hostnamePattern := range tt.expected {
hostname := strings.ReplaceAll(hostnamePattern, "@", workspace.Name)
expectedHosts = append(expectedHosts, hostname)
}
hosts := sshConfigFileParseHosts(t, sshConfigFile)
require.ElementsMatch(t, expectedHosts, hosts)
})
}
}
// sshConfigFileParseHosts reads a file in the format of .ssh/config and extracts
// the hostnames that are listed in "Host" directives.
func sshConfigFileParseHosts(t *testing.T, name string) []string {
t.Helper()
b, err := os.ReadFile(name)
require.NoError(t, err)
var result []string
lineScanner := bufio.NewScanner(bytes.NewBuffer(b))
for lineScanner.Scan() {
line := lineScanner.Text()
line = strings.TrimSpace(line)
tokenScanner := bufio.NewScanner(bytes.NewBufferString(line))
tokenScanner.Split(bufio.ScanWords)
ok := tokenScanner.Scan()
if ok && tokenScanner.Text() == "Host" {
for tokenScanner.Scan() {
result = append(result, tokenScanner.Text())
}
}
}
return result
}
+6
View File
@@ -0,0 +1,6 @@
package cli
const (
timeFormat = "3:04PM MST"
dateFormat = "Jan 2, 2006"
)
+283
View File
@@ -0,0 +1,283 @@
package cli
import (
"fmt"
"io"
"time"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"github.com/coder/coder/cli/cliflag"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/util/ptr"
"github.com/coder/coder/codersdk"
)
func create() *cobra.Command {
var (
parameterFile string
templateName string
startAt string
stopAfter time.Duration
workspaceName string
)
cmd := &cobra.Command{
Annotations: workspaceCommand,
Use: "create [name]",
Short: "Create a workspace",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := CreateClient(cmd)
if err != nil {
return err
}
organization, err := CurrentOrganization(cmd, client)
if err != nil {
return err
}
if len(args) >= 1 {
workspaceName = args[0]
}
if workspaceName == "" {
workspaceName, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Specify a name for your workspace:",
Validate: func(workspaceName string) error {
_, err = client.WorkspaceByOwnerAndName(cmd.Context(), codersdk.Me, workspaceName, codersdk.WorkspaceOptions{})
if err == nil {
return xerrors.Errorf("A workspace already exists named %q!", workspaceName)
}
return nil
},
})
if err != nil {
return err
}
}
_, err = client.WorkspaceByOwnerAndName(cmd.Context(), codersdk.Me, workspaceName, codersdk.WorkspaceOptions{})
if err == nil {
return xerrors.Errorf("A workspace already exists named %q!", workspaceName)
}
var template codersdk.Template
if templateName == "" {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Wrap.Render("Select a template below to preview the provisioned infrastructure:"))
templates, err := client.TemplatesByOrganization(cmd.Context(), organization.ID)
if err != nil {
return err
}
slices.SortFunc(templates, func(a, b codersdk.Template) bool {
return a.ActiveUserCount > b.ActiveUserCount
})
templateNames := make([]string, 0, len(templates))
templateByName := make(map[string]codersdk.Template, len(templates))
for _, template := range templates {
templateName := template.Name
if template.ActiveUserCount > 0 {
templateName += cliui.Styles.Placeholder.Render(
fmt.Sprintf(
" (used by %s)",
formatActiveDevelopers(template.ActiveUserCount),
),
)
}
templateNames = append(templateNames, templateName)
templateByName[templateName] = template
}
// Move the cursor up a single line for nicer display!
option, err := cliui.Select(cmd, cliui.SelectOptions{
Options: templateNames,
HideSearch: true,
})
if err != nil {
return err
}
template = templateByName[option]
} else {
template, err = client.TemplateByName(cmd.Context(), organization.ID, templateName)
if err != nil {
return xerrors.Errorf("get template by name: %w", err)
}
}
var schedSpec *string
if startAt != "" {
sched, err := parseCLISchedule(startAt)
if err != nil {
return err
}
schedSpec = ptr.Ref(sched.String())
}
parameters, err := prepWorkspaceBuild(cmd, client, prepWorkspaceBuildArgs{
Template: template,
ExistingParams: []codersdk.Parameter{},
ParameterFile: parameterFile,
NewWorkspaceName: workspaceName,
})
if err != nil {
return err
}
_, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Confirm create?",
IsConfirm: true,
})
if err != nil {
return err
}
workspace, err := client.CreateWorkspace(cmd.Context(), organization.ID, codersdk.Me, codersdk.CreateWorkspaceRequest{
TemplateID: template.ID,
Name: workspaceName,
AutostartSchedule: schedSpec,
TTLMillis: ptr.Ref(stopAfter.Milliseconds()),
ParameterValues: parameters,
})
if err != nil {
return err
}
err = cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, workspace.LatestBuild.ID)
if err != nil {
return err
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been created at %s!\n", cliui.Styles.Keyword.Render(workspace.Name), cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp)))
return nil
},
}
cliui.AllowSkipPrompt(cmd)
cliflag.StringVarP(cmd.Flags(), &templateName, "template", "t", "CODER_TEMPLATE_NAME", "", "Specify a template name.")
cliflag.StringVarP(cmd.Flags(), &parameterFile, "parameter-file", "", "CODER_PARAMETER_FILE", "", "Specify a file path with parameter values.")
cliflag.StringVarP(cmd.Flags(), &startAt, "start-at", "", "CODER_WORKSPACE_START_AT", "", "Specify the workspace autostart schedule. Check `coder schedule start --help` for the syntax.")
cliflag.DurationVarP(cmd.Flags(), &stopAfter, "stop-after", "", "CODER_WORKSPACE_STOP_AFTER", 8*time.Hour, "Specify a duration after which the workspace should shut down (e.g. 8h).")
return cmd
}
type prepWorkspaceBuildArgs struct {
Template codersdk.Template
ExistingParams []codersdk.Parameter
ParameterFile string
NewWorkspaceName string
}
// prepWorkspaceBuild will ensure a workspace build will succeed on the latest template version.
// Any missing params will be prompted to the user.
func prepWorkspaceBuild(cmd *cobra.Command, client *codersdk.Client, args prepWorkspaceBuildArgs) ([]codersdk.CreateParameterRequest, error) {
ctx := cmd.Context()
templateVersion, err := client.TemplateVersion(ctx, args.Template.ActiveVersionID)
if err != nil {
return nil, err
}
parameterSchemas, err := client.TemplateVersionSchema(ctx, templateVersion.ID)
if err != nil {
return nil, err
}
// parameterMapFromFile can be nil if parameter file is not specified
var parameterMapFromFile map[string]string
useParamFile := false
if args.ParameterFile != "" {
useParamFile = true
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Paragraph.Render("Attempting to read the variables from the parameter file.")+"\r\n")
parameterMapFromFile, err = createParameterMapFromFile(args.ParameterFile)
if err != nil {
return nil, err
}
}
disclaimerPrinted := false
parameters := make([]codersdk.CreateParameterRequest, 0)
PromptParamLoop:
for _, parameterSchema := range parameterSchemas {
if !parameterSchema.AllowOverrideSource {
continue
}
if !disclaimerPrinted {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Paragraph.Render("This template has customizable parameters. Values can be changed after create, but may have unintended side effects (like data loss).")+"\r\n")
disclaimerPrinted = true
}
// Param file is all or nothing
if !useParamFile {
for _, e := range args.ExistingParams {
if e.Name == parameterSchema.Name {
// If the param already exists, we do not need to prompt it again.
// The workspace scope will reuse params for each build.
continue PromptParamLoop
}
}
}
parameterValue, err := getParameterValueFromMapOrInput(cmd, parameterMapFromFile, parameterSchema)
if err != nil {
return nil, err
}
parameters = append(parameters, codersdk.CreateParameterRequest{
Name: parameterSchema.Name,
SourceValue: parameterValue,
SourceScheme: codersdk.ParameterSourceSchemeData,
DestinationScheme: parameterSchema.DefaultDestinationScheme,
})
}
_, _ = fmt.Fprintln(cmd.OutOrStdout())
// Run a dry-run with the given parameters to check correctness
dryRun, err := client.CreateTemplateVersionDryRun(cmd.Context(), templateVersion.ID, codersdk.CreateTemplateVersionDryRunRequest{
WorkspaceName: args.NewWorkspaceName,
ParameterValues: parameters,
})
if err != nil {
return nil, xerrors.Errorf("begin workspace dry-run: %w", err)
}
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Planning workspace...")
err = cliui.ProvisionerJob(cmd.Context(), cmd.OutOrStdout(), cliui.ProvisionerJobOptions{
Fetch: func() (codersdk.ProvisionerJob, error) {
return client.TemplateVersionDryRun(cmd.Context(), templateVersion.ID, dryRun.ID)
},
Cancel: func() error {
return client.CancelTemplateVersionDryRun(cmd.Context(), templateVersion.ID, dryRun.ID)
},
Logs: func() (<-chan codersdk.ProvisionerJobLog, io.Closer, error) {
return client.TemplateVersionDryRunLogsAfter(cmd.Context(), templateVersion.ID, dryRun.ID, 0)
},
// Don't show log output for the dry-run unless there's an error.
Silent: true,
})
if err != nil {
// TODO (Dean): reprompt for parameter values if we deem it to
// be a validation error
return nil, xerrors.Errorf("dry-run workspace: %w", err)
}
resources, err := client.TemplateVersionDryRunResources(cmd.Context(), templateVersion.ID, dryRun.ID)
if err != nil {
return nil, xerrors.Errorf("get workspace dry-run resources: %w", err)
}
err = cliui.WorkspaceResources(cmd.OutOrStdout(), resources, cliui.WorkspaceResourcesOptions{
WorkspaceName: args.NewWorkspaceName,
// Since agents haven't connected yet, hiding this makes more sense.
HideAgentState: true,
Title: "Workspace Preview",
})
if err != nil {
return nil, err
}
return parameters, nil
}
+358
View File
@@ -0,0 +1,358 @@
package cli_test
import (
"context"
"fmt"
"os"
"testing"
"time"
"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/codersdk"
"github.com/coder/coder/provisioner/echo"
"github.com/coder/coder/provisionersdk/proto"
"github.com/coder/coder/pty/ptytest"
"github.com/coder/coder/testutil"
)
func TestCreate(t *testing.T) {
t.Parallel()
t.Run("Create", func(t *testing.T) {
t.Parallel()
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: provisionCompleteWithAgent,
ProvisionPlan: provisionCompleteWithAgent,
})
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
args := []string{
"create",
"my-workspace",
"--template", template.Name,
"--start-at", "9:30AM Mon-Fri US/Central",
"--stop-after", "8h",
}
cmd, root := clitest.New(t, args...)
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
assert.NoError(t, err)
}()
matches := []struct {
match string
write string
}{
{match: "compute.main"},
{match: "smith (linux, i386)"},
{match: "Confirm create", write: "yes"},
}
for _, m := range matches {
pty.ExpectMatch(m.match)
if len(m.write) > 0 {
pty.WriteLine(m.write)
}
}
<-doneChan
ws, err := client.WorkspaceByOwnerAndName(context.Background(), "testuser", "my-workspace", codersdk.WorkspaceOptions{})
if assert.NoError(t, err, "expected workspace to be created") {
assert.Equal(t, ws.TemplateName, template.Name)
if assert.NotNil(t, ws.AutostartSchedule) {
assert.Equal(t, *ws.AutostartSchedule, "CRON_TZ=US/Central 30 9 * * Mon-Fri")
}
if assert.NotNil(t, ws.TTLMillis) {
assert.Equal(t, *ws.TTLMillis, 8*time.Hour.Milliseconds())
}
}
})
t.Run("CreateFromListWithSkip", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
_ = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
cmd, root := clitest.New(t, "create", "my-workspace", "-y")
member := coderdtest.CreateAnotherUser(t, client, user.OrganizationID)
clitest.SetupConfig(t, member, root)
cmdCtx, done := context.WithTimeout(context.Background(), testutil.WaitLong)
go func() {
defer done()
err := cmd.ExecuteContext(cmdCtx)
assert.NoError(t, err)
}()
// No pty interaction needed since we use the -y skip prompt flag
<-cmdCtx.Done()
require.ErrorIs(t, cmdCtx.Err(), context.Canceled)
})
t.Run("FromNothing", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
cmd, root := clitest.New(t, "create", "")
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
assert.NoError(t, err)
}()
matches := []string{
"Specify a name", "my-workspace",
"Confirm create?", "yes",
}
for i := 0; i < len(matches); i += 2 {
match := matches[i]
value := matches[i+1]
pty.ExpectMatch(match)
pty.WriteLine(value)
}
<-doneChan
ws, err := client.WorkspaceByOwnerAndName(cmd.Context(), "testuser", "my-workspace", codersdk.WorkspaceOptions{})
if assert.NoError(t, err, "expected workspace to be created") {
assert.Equal(t, ws.TemplateName, template.Name)
assert.Nil(t, ws.AutostartSchedule, "expected workspace autostart schedule to be nil")
}
})
t.Run("WithParameter", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
defaultValue := "something"
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: createTestParseResponseWithDefault(defaultValue),
ProvisionApply: echo.ProvisionComplete,
ProvisionPlan: echo.ProvisionComplete,
})
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
_ = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
cmd, root := clitest.New(t, "create", "")
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
assert.NoError(t, err)
}()
matches := []string{
"Specify a name", "my-workspace",
fmt.Sprintf("Enter a value (default: %q):", defaultValue), "bingo",
"Enter a value:", "boingo",
"Confirm create?", "yes",
}
for i := 0; i < len(matches); i += 2 {
match := matches[i]
value := matches[i+1]
pty.ExpectMatch(match)
pty.WriteLine(value)
}
<-doneChan
})
t.Run("WithParameterFileContainingTheValue", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
defaultValue := "something"
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: createTestParseResponseWithDefault(defaultValue),
ProvisionApply: echo.ProvisionComplete,
ProvisionPlan: echo.ProvisionComplete,
})
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
_ = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
tempDir := t.TempDir()
removeTmpDirUntilSuccessAfterTest(t, tempDir)
parameterFile, _ := os.CreateTemp(tempDir, "testParameterFile*.yaml")
_, _ = parameterFile.WriteString("region: \"bingo\"\nusername: \"boingo\"")
cmd, root := clitest.New(t, "create", "", "--parameter-file", parameterFile.Name())
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
assert.NoError(t, err)
}()
matches := []string{
"Specify a name", "my-workspace",
"Confirm create?", "yes",
}
for i := 0; i < len(matches); i += 2 {
match := matches[i]
value := matches[i+1]
pty.ExpectMatch(match)
pty.WriteLine(value)
}
<-doneChan
})
t.Run("WithParameterFileNotContainingTheValue", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
defaultValue := "something"
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: createTestParseResponseWithDefault(defaultValue),
ProvisionApply: echo.ProvisionComplete,
ProvisionPlan: echo.ProvisionComplete,
})
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
_ = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
tempDir := t.TempDir()
removeTmpDirUntilSuccessAfterTest(t, tempDir)
parameterFile, _ := os.CreateTemp(tempDir, "testParameterFile*.yaml")
_, _ = parameterFile.WriteString("username: \"boingo\"")
cmd, root := clitest.New(t, "create", "", "--parameter-file", parameterFile.Name())
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
assert.NoError(t, err)
}()
matches := []struct {
match string
write string
}{
{
match: "Specify a name",
write: "my-workspace",
},
{
match: fmt.Sprintf("Enter a value (default: %q):", defaultValue),
write: "bingo",
},
{
match: "Confirm create?",
write: "yes",
},
}
for _, m := range matches {
pty.ExpectMatch(m.match)
pty.WriteLine(m.write)
}
<-doneChan
})
t.Run("FailedDryRun", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: []*proto.Parse_Response{{
Type: &proto.Parse_Response_Complete{
Complete: &proto.Parse_Complete{
ParameterSchemas: echo.ParameterSuccess,
},
},
}},
ProvisionPlan: []*proto.Provision_Response{
{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{},
},
},
},
})
tempDir := t.TempDir()
parameterFile, err := os.CreateTemp(tempDir, "testParameterFile*.yaml")
require.NoError(t, err)
defer parameterFile.Close()
_, _ = parameterFile.WriteString(fmt.Sprintf("%s: %q", echo.ParameterExecKey, echo.ParameterError("fail")))
// The template import job should end up failed, but we need it to be
// succeeded so the dry-run can begin.
version = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
require.Equal(t, codersdk.ProvisionerJobSucceeded, version.Job.Status, "job is not failed")
_ = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
cmd, root := clitest.New(t, "create", "test", "--parameter-file", parameterFile.Name())
clitest.SetupConfig(t, client, root)
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
err = cmd.Execute()
require.Error(t, err)
require.ErrorContains(t, err, "dry-run workspace")
})
}
func createTestParseResponseWithDefault(defaultValue string) []*proto.Parse_Response {
return []*proto.Parse_Response{{
Type: &proto.Parse_Response_Complete{
Complete: &proto.Parse_Complete{
ParameterSchemas: []*proto.ParameterSchema{
{
AllowOverrideSource: true,
Name: "region",
Description: "description 1",
DefaultSource: &proto.ParameterSource{
Scheme: proto.ParameterSource_DATA,
Value: defaultValue,
},
DefaultDestination: &proto.ParameterDestination{
Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE,
},
},
{
AllowOverrideSource: true,
Name: "username",
Description: "description 2",
DefaultSource: &proto.ParameterSource{
Scheme: proto.ParameterSource_DATA,
// No default value
Value: "",
},
DefaultDestination: &proto.ParameterDestination{
Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE,
},
},
},
},
},
}}
}
+74
View File
@@ -0,0 +1,74 @@
package cli
import (
"fmt"
"time"
"github.com/spf13/cobra"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/codersdk"
)
// nolint
func deleteWorkspace() *cobra.Command {
var orphan bool
cmd := &cobra.Command{
Annotations: workspaceCommand,
Use: "delete <workspace>",
Short: "Delete a workspace",
Aliases: []string{"rm"},
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
_, err := cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Confirm delete workspace?",
IsConfirm: true,
Default: cliui.ConfirmNo,
})
if err != nil {
return err
}
client, err := CreateClient(cmd)
if err != nil {
return err
}
workspace, err := namedWorkspace(cmd, client, args[0])
if err != nil {
return err
}
var state []byte
if orphan {
cliui.Warn(
cmd.ErrOrStderr(),
"Orphaning workspace requires template edit permission",
)
}
build, err := client.CreateWorkspaceBuild(cmd.Context(), workspace.ID, codersdk.CreateWorkspaceBuildRequest{
Transition: codersdk.WorkspaceTransitionDelete,
ProvisionerState: state,
Orphan: orphan,
})
if err != nil {
return err
}
err = cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, build.ID)
if err != nil {
return err
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nThe %s workspace has been deleted at %s!\n", cliui.Styles.Keyword.Render(workspace.Name), cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp)))
return nil
},
}
cmd.Flags().BoolVar(&orphan, "orphan", false,
`Delete a workspace without deleting its resources. This can delete a
workspace in a broken state, but may also lead to unaccounted cloud resources.`,
)
cliui.AllowSkipPrompt(cmd)
return cmd
}
+125
View File
@@ -0,0 +1,125 @@
package cli_test
import (
"context"
"io"
"testing"
"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/codersdk"
"github.com/coder/coder/pty/ptytest"
)
func TestDelete(t *testing.T) {
t.Parallel()
t.Run("WithParameter", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
cmd, root := clitest.New(t, "delete", workspace.Name, "-y")
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
// When running with the race detector on, we sometimes get an EOF.
if err != nil {
assert.ErrorIs(t, err, io.EOF)
}
}()
pty.ExpectMatch("Cleaning Up")
<-doneChan
})
t.Run("Orphan", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
cmd, root := clitest.New(t, "delete", workspace.Name, "-y", "--orphan")
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
cmd.SetErr(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
// When running with the race detector on, we sometimes get an EOF.
if err != nil {
assert.ErrorIs(t, err, io.EOF)
}
}()
pty.ExpectMatch("Cleaning Up")
<-doneChan
})
t.Run("DifferentUser", func(t *testing.T) {
t.Parallel()
adminClient := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
adminUser := coderdtest.CreateFirstUser(t, adminClient)
orgID := adminUser.OrganizationID
client := coderdtest.CreateAnotherUser(t, adminClient, orgID)
user, err := client.User(context.Background(), codersdk.Me)
require.NoError(t, err)
version := coderdtest.CreateTemplateVersion(t, adminClient, orgID, nil)
coderdtest.AwaitTemplateVersionJob(t, adminClient, version.ID)
template := coderdtest.CreateTemplate(t, adminClient, orgID, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, orgID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
cmd, root := clitest.New(t, "delete", user.Username+"/"+workspace.Name, "-y")
clitest.SetupConfig(t, adminClient, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
// When running with the race detector on, we sometimes get an EOF.
if err != nil {
assert.ErrorIs(t, err, io.EOF)
}
}()
pty.ExpectMatch("Cleaning Up")
<-doneChan
workspace, err = client.Workspace(context.Background(), workspace.ID)
require.ErrorContains(t, err, "was deleted")
})
t.Run("InvalidWorkspaceIdentifier", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
cmd, root := clitest.New(t, "delete", "a/b/c", "-y")
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
go func() {
defer close(doneChan)
err := cmd.Execute()
assert.ErrorContains(t, err, "invalid workspace name: \"a/b/c\"")
}()
<-doneChan
})
}
+781
View File
@@ -0,0 +1,781 @@
package deployment
import (
"flag"
"fmt"
"os"
"path/filepath"
"reflect"
"strings"
"time"
"github.com/coreos/go-oidc/v3/oidc"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"golang.org/x/xerrors"
"github.com/coder/coder/buildinfo"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/cli/config"
"github.com/coder/coder/codersdk"
)
func newConfig() *codersdk.DeploymentConfig {
return &codersdk.DeploymentConfig{
AccessURL: &codersdk.DeploymentConfigField[string]{
Name: "Access URL",
Usage: "External URL to access your deployment. This must be accessible by all provisioned workspaces.",
Flag: "access-url",
},
WildcardAccessURL: &codersdk.DeploymentConfigField[string]{
Name: "Wildcard Access URL",
Usage: "Specifies the wildcard hostname to use for workspace applications in the form \"*.example.com\".",
Flag: "wildcard-access-url",
},
// DEPRECATED: Use HTTPAddress or TLS.Address instead.
Address: &codersdk.DeploymentConfigField[string]{
Name: "Address",
Usage: "Bind address of the server.",
Flag: "address",
Shorthand: "a",
// Deprecated, so we don't have a default. If set, it will overwrite
// HTTPAddress and TLS.Address and print a warning.
Hidden: true,
Default: "",
},
HTTPAddress: &codersdk.DeploymentConfigField[string]{
Name: "Address",
Usage: "HTTP bind address of the server. Unset to disable the HTTP endpoint.",
Flag: "http-address",
Default: "127.0.0.1:3000",
},
AutobuildPollInterval: &codersdk.DeploymentConfigField[time.Duration]{
Name: "Autobuild Poll Interval",
Usage: "Interval to poll for scheduled workspace builds.",
Flag: "autobuild-poll-interval",
Hidden: true,
Default: time.Minute,
},
DERP: &codersdk.DERP{
Server: &codersdk.DERPServerConfig{
Enable: &codersdk.DeploymentConfigField[bool]{
Name: "DERP Server Enable",
Usage: "Whether to enable or disable the embedded DERP relay server.",
Flag: "derp-server-enable",
Default: true,
},
RegionID: &codersdk.DeploymentConfigField[int]{
Name: "DERP Server Region ID",
Usage: "Region ID to use for the embedded DERP server.",
Flag: "derp-server-region-id",
Default: 999,
},
RegionCode: &codersdk.DeploymentConfigField[string]{
Name: "DERP Server Region Code",
Usage: "Region code to use for the embedded DERP server.",
Flag: "derp-server-region-code",
Default: "coder",
},
RegionName: &codersdk.DeploymentConfigField[string]{
Name: "DERP Server Region Name",
Usage: "Region name that for the embedded DERP server.",
Flag: "derp-server-region-name",
Default: "Coder Embedded Relay",
},
STUNAddresses: &codersdk.DeploymentConfigField[[]string]{
Name: "DERP Server STUN Addresses",
Usage: "Addresses for STUN servers to establish P2P connections. Set empty to disable P2P connections.",
Flag: "derp-server-stun-addresses",
Default: []string{"stun.l.google.com:19302"},
},
RelayURL: &codersdk.DeploymentConfigField[string]{
Name: "DERP Server Relay URL",
Usage: "An HTTP URL that is accessible by other replicas to relay DERP traffic. Required for high availability.",
Flag: "derp-server-relay-url",
Enterprise: true,
},
},
Config: &codersdk.DERPConfig{
URL: &codersdk.DeploymentConfigField[string]{
Name: "DERP Config URL",
Usage: "URL to fetch a DERP mapping on startup. See: https://tailscale.com/kb/1118/custom-derp-servers/",
Flag: "derp-config-url",
},
Path: &codersdk.DeploymentConfigField[string]{
Name: "DERP Config Path",
Usage: "Path to read a DERP mapping from. See: https://tailscale.com/kb/1118/custom-derp-servers/",
Flag: "derp-config-path",
},
},
},
GitAuth: &codersdk.DeploymentConfigField[[]codersdk.GitAuthConfig]{
Name: "Git Auth",
Usage: "Automatically authenticate Git inside workspaces.",
Flag: "gitauth",
Default: []codersdk.GitAuthConfig{},
},
Prometheus: &codersdk.PrometheusConfig{
Enable: &codersdk.DeploymentConfigField[bool]{
Name: "Prometheus Enable",
Usage: "Serve prometheus metrics on the address defined by prometheus address.",
Flag: "prometheus-enable",
},
Address: &codersdk.DeploymentConfigField[string]{
Name: "Prometheus Address",
Usage: "The bind address to serve prometheus metrics.",
Flag: "prometheus-address",
Default: "127.0.0.1:2112",
},
},
Pprof: &codersdk.PprofConfig{
Enable: &codersdk.DeploymentConfigField[bool]{
Name: "Pprof Enable",
Usage: "Serve pprof metrics on the address defined by pprof address.",
Flag: "pprof-enable",
},
Address: &codersdk.DeploymentConfigField[string]{
Name: "Pprof Address",
Usage: "The bind address to serve pprof.",
Flag: "pprof-address",
Default: "127.0.0.1:6060",
},
},
ProxyTrustedHeaders: &codersdk.DeploymentConfigField[[]string]{
Name: "Proxy Trusted Headers",
Flag: "proxy-trusted-headers",
Usage: "Headers to trust for forwarding IP addresses. e.g. Cf-Connecting-Ip, True-Client-Ip, X-Forwarded-For",
},
ProxyTrustedOrigins: &codersdk.DeploymentConfigField[[]string]{
Name: "Proxy Trusted Origins",
Flag: "proxy-trusted-origins",
Usage: "Origin addresses to respect \"proxy-trusted-headers\". e.g. 192.168.1.0/24",
},
CacheDirectory: &codersdk.DeploymentConfigField[string]{
Name: "Cache Directory",
Usage: "The directory to cache temporary files. If unspecified and $CACHE_DIRECTORY is set, it will be used for compatibility with systemd.",
Flag: "cache-dir",
Default: DefaultCacheDir(),
},
InMemoryDatabase: &codersdk.DeploymentConfigField[bool]{
Name: "In Memory Database",
Usage: "Controls whether data will be stored in an in-memory database.",
Flag: "in-memory",
Hidden: true,
},
PostgresURL: &codersdk.DeploymentConfigField[string]{
Name: "Postgres Connection URL",
Usage: "URL of a PostgreSQL database. If empty, PostgreSQL binaries will be downloaded from Maven (https://repo1.maven.org/maven2) and store all data in the config root. Access the built-in database with \"coder server postgres-builtin-url\".",
Flag: "postgres-url",
Secret: true,
},
OAuth2: &codersdk.OAuth2Config{
Github: &codersdk.OAuth2GithubConfig{
ClientID: &codersdk.DeploymentConfigField[string]{
Name: "OAuth2 GitHub Client ID",
Usage: "Client ID for Login with GitHub.",
Flag: "oauth2-github-client-id",
},
ClientSecret: &codersdk.DeploymentConfigField[string]{
Name: "OAuth2 GitHub Client Secret",
Usage: "Client secret for Login with GitHub.",
Flag: "oauth2-github-client-secret",
Secret: true,
},
AllowedOrgs: &codersdk.DeploymentConfigField[[]string]{
Name: "OAuth2 GitHub Allowed Orgs",
Usage: "Organizations the user must be a member of to Login with GitHub.",
Flag: "oauth2-github-allowed-orgs",
},
AllowedTeams: &codersdk.DeploymentConfigField[[]string]{
Name: "OAuth2 GitHub Allowed Teams",
Usage: "Teams inside organizations the user must be a member of to Login with GitHub. Structured as: <organization-name>/<team-slug>.",
Flag: "oauth2-github-allowed-teams",
},
AllowSignups: &codersdk.DeploymentConfigField[bool]{
Name: "OAuth2 GitHub Allow Signups",
Usage: "Whether new users can sign up with GitHub.",
Flag: "oauth2-github-allow-signups",
},
AllowEveryone: &codersdk.DeploymentConfigField[bool]{
Name: "OAuth2 GitHub Allow Everyone",
Usage: "Allow all logins, setting this option means allowed orgs and teams must be empty.",
Flag: "oauth2-github-allow-everyone",
},
EnterpriseBaseURL: &codersdk.DeploymentConfigField[string]{
Name: "OAuth2 GitHub Enterprise Base URL",
Usage: "Base URL of a GitHub Enterprise deployment to use for Login with GitHub.",
Flag: "oauth2-github-enterprise-base-url",
},
},
},
OIDC: &codersdk.OIDCConfig{
AllowSignups: &codersdk.DeploymentConfigField[bool]{
Name: "OIDC Allow Signups",
Usage: "Whether new users can sign up with OIDC.",
Flag: "oidc-allow-signups",
Default: true,
},
ClientID: &codersdk.DeploymentConfigField[string]{
Name: "OIDC Client ID",
Usage: "Client ID to use for Login with OIDC.",
Flag: "oidc-client-id",
},
ClientSecret: &codersdk.DeploymentConfigField[string]{
Name: "OIDC Client Secret",
Usage: "Client secret to use for Login with OIDC.",
Flag: "oidc-client-secret",
Secret: true,
},
EmailDomain: &codersdk.DeploymentConfigField[[]string]{
Name: "OIDC Email Domain",
Usage: "Email domains that clients logging in with OIDC must match.",
Flag: "oidc-email-domain",
},
IssuerURL: &codersdk.DeploymentConfigField[string]{
Name: "OIDC Issuer URL",
Usage: "Issuer URL to use for Login with OIDC.",
Flag: "oidc-issuer-url",
},
Scopes: &codersdk.DeploymentConfigField[[]string]{
Name: "OIDC Scopes",
Usage: "Scopes to grant when authenticating with OIDC.",
Flag: "oidc-scopes",
Default: []string{oidc.ScopeOpenID, "profile", "email"},
},
IgnoreEmailVerified: &codersdk.DeploymentConfigField[bool]{
Name: "OIDC Ignore Email Verified",
Usage: "Ignore the email_verified claim from the upstream provider.",
Flag: "oidc-ignore-email-verified",
Default: false,
},
UsernameField: &codersdk.DeploymentConfigField[string]{
Name: "OIDC Username Field",
Usage: "OIDC claim field to use as the username.",
Flag: "oidc-username-field",
Default: "preferred_username",
},
},
Telemetry: &codersdk.TelemetryConfig{
Enable: &codersdk.DeploymentConfigField[bool]{
Name: "Telemetry Enable",
Usage: "Whether telemetry is enabled or not. Coder collects anonymized usage data to help improve our product.",
Flag: "telemetry",
Default: flag.Lookup("test.v") == nil,
},
Trace: &codersdk.DeploymentConfigField[bool]{
Name: "Telemetry Trace",
Usage: "Whether Opentelemetry traces are sent to Coder. Coder collects anonymized application tracing to help improve our product. Disabling telemetry also disables this option.",
Flag: "telemetry-trace",
Default: flag.Lookup("test.v") == nil,
},
URL: &codersdk.DeploymentConfigField[string]{
Name: "Telemetry URL",
Usage: "URL to send telemetry.",
Flag: "telemetry-url",
Hidden: true,
Default: "https://telemetry.coder.com",
},
},
TLS: &codersdk.TLSConfig{
Enable: &codersdk.DeploymentConfigField[bool]{
Name: "TLS Enable",
Usage: "Whether TLS will be enabled.",
Flag: "tls-enable",
},
Address: &codersdk.DeploymentConfigField[string]{
Name: "TLS Address",
Usage: "HTTPS bind address of the server.",
Flag: "tls-address",
Default: "127.0.0.1:3443",
},
RedirectHTTP: &codersdk.DeploymentConfigField[bool]{
Name: "Redirect HTTP to HTTPS",
Usage: "Whether HTTP requests will be redirected to the access URL (if it's a https URL and TLS is enabled). Requests to local IP addresses are never redirected regardless of this setting.",
Flag: "tls-redirect-http-to-https",
Default: true,
},
CertFiles: &codersdk.DeploymentConfigField[[]string]{
Name: "TLS Certificate Files",
Usage: "Path to each certificate for TLS. It requires a PEM-encoded file. To configure the listener to use a CA certificate, concatenate the primary certificate and the CA certificate together. The primary certificate should appear first in the combined file.",
Flag: "tls-cert-file",
},
ClientCAFile: &codersdk.DeploymentConfigField[string]{
Name: "TLS Client CA Files",
Usage: "PEM-encoded Certificate Authority file used for checking the authenticity of client",
Flag: "tls-client-ca-file",
},
ClientAuth: &codersdk.DeploymentConfigField[string]{
Name: "TLS Client Auth",
Usage: "Policy the server will follow for TLS Client Authentication. Accepted values are \"none\", \"request\", \"require-any\", \"verify-if-given\", or \"require-and-verify\".",
Flag: "tls-client-auth",
Default: "none",
},
KeyFiles: &codersdk.DeploymentConfigField[[]string]{
Name: "TLS Key Files",
Usage: "Paths to the private keys for each of the certificates. It requires a PEM-encoded file.",
Flag: "tls-key-file",
},
MinVersion: &codersdk.DeploymentConfigField[string]{
Name: "TLS Minimum Version",
Usage: "Minimum supported version of TLS. Accepted values are \"tls10\", \"tls11\", \"tls12\" or \"tls13\"",
Flag: "tls-min-version",
Default: "tls12",
},
ClientCertFile: &codersdk.DeploymentConfigField[string]{
Name: "TLS Client Cert File",
Usage: "Path to certificate for client TLS authentication. It requires a PEM-encoded file.",
Flag: "tls-client-cert-file",
},
ClientKeyFile: &codersdk.DeploymentConfigField[string]{
Name: "TLS Client Key File",
Usage: "Path to key for client TLS authentication. It requires a PEM-encoded file.",
Flag: "tls-client-key-file",
},
},
Trace: &codersdk.TraceConfig{
Enable: &codersdk.DeploymentConfigField[bool]{
Name: "Trace Enable",
Usage: "Whether application tracing data is collected. It exports to a backend configured by environment variables. See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md",
Flag: "trace",
},
HoneycombAPIKey: &codersdk.DeploymentConfigField[string]{
Name: "Trace Honeycomb API Key",
Usage: "Enables trace exporting to Honeycomb.io using the provided API Key.",
Flag: "trace-honeycomb-api-key",
Secret: true,
},
CaptureLogs: &codersdk.DeploymentConfigField[bool]{
Name: "Capture Logs in Traces",
Usage: "Enables capturing of logs as events in traces. This is useful for debugging, but may result in a very large amount of events being sent to the tracing backend which may incur significant costs. If the verbose flag was supplied, debug-level logs will be included.",
Flag: "trace-logs",
},
},
SecureAuthCookie: &codersdk.DeploymentConfigField[bool]{
Name: "Secure Auth Cookie",
Usage: "Controls if the 'Secure' property is set on browser session cookies.",
Flag: "secure-auth-cookie",
},
SSHKeygenAlgorithm: &codersdk.DeploymentConfigField[string]{
Name: "SSH Keygen Algorithm",
Usage: "The algorithm to use for generating ssh keys. Accepted values are \"ed25519\", \"ecdsa\", or \"rsa4096\".",
Flag: "ssh-keygen-algorithm",
Default: "ed25519",
},
MetricsCacheRefreshInterval: &codersdk.DeploymentConfigField[time.Duration]{
Name: "Metrics Cache Refresh Interval",
Usage: "How frequently metrics are refreshed",
Flag: "metrics-cache-refresh-interval",
Hidden: true,
Default: time.Hour,
},
AgentStatRefreshInterval: &codersdk.DeploymentConfigField[time.Duration]{
Name: "Agent Stat Refresh Interval",
Usage: "How frequently agent stats are recorded",
Flag: "agent-stats-refresh-interval",
Hidden: true,
Default: 10 * time.Minute,
},
AgentFallbackTroubleshootingURL: &codersdk.DeploymentConfigField[string]{
Name: "Agent Fallback Troubleshooting URL",
Usage: "URL to use for agent troubleshooting when not set in the template",
Flag: "agent-fallback-troubleshooting-url",
Hidden: true,
Default: "https://coder.com/docs/coder-oss/latest/templates#troubleshooting-templates",
},
AuditLogging: &codersdk.DeploymentConfigField[bool]{
Name: "Audit Logging",
Usage: "Specifies whether audit logging is enabled.",
Flag: "audit-logging",
Default: true,
Enterprise: true,
},
BrowserOnly: &codersdk.DeploymentConfigField[bool]{
Name: "Browser Only",
Usage: "Whether Coder only allows connections to workspaces via the browser.",
Flag: "browser-only",
Enterprise: true,
},
SCIMAPIKey: &codersdk.DeploymentConfigField[string]{
Name: "SCIM API Key",
Usage: "Enables SCIM and sets the authentication header for the built-in SCIM server. New users are automatically created with OIDC authentication.",
Flag: "scim-auth-header",
Enterprise: true,
Secret: true,
},
Provisioner: &codersdk.ProvisionerConfig{
Daemons: &codersdk.DeploymentConfigField[int]{
Name: "Provisioner Daemons",
Usage: "Number of provisioner daemons to create on start. If builds are stuck in queued state for a long time, consider increasing this.",
Flag: "provisioner-daemons",
Default: 3,
},
DaemonPollInterval: &codersdk.DeploymentConfigField[time.Duration]{
Name: "Poll Interval",
Usage: "Time to wait before polling for a new job.",
Flag: "provisioner-daemon-poll-interval",
Default: time.Second,
},
DaemonPollJitter: &codersdk.DeploymentConfigField[time.Duration]{
Name: "Poll Jitter",
Usage: "Random jitter added to the poll interval.",
Flag: "provisioner-daemon-poll-jitter",
Default: 100 * time.Millisecond,
},
ForceCancelInterval: &codersdk.DeploymentConfigField[time.Duration]{
Name: "Force Cancel Interval",
Usage: "Time to force cancel provisioning tasks that are stuck.",
Flag: "provisioner-force-cancel-interval",
Default: 10 * time.Minute,
},
},
RateLimit: &codersdk.RateLimitConfig{
DisableAll: &codersdk.DeploymentConfigField[bool]{
Name: "Disable All Rate Limits",
Usage: "Disables all rate limits. This is not recommended in production.",
Flag: "dangerous-disable-rate-limits",
Default: false,
},
API: &codersdk.DeploymentConfigField[int]{
Name: "API Rate Limit",
Usage: "Maximum number of requests per minute allowed to the API per user, or per IP address for unauthenticated users. Negative values mean no rate limit. Some API endpoints have separate strict rate limits regardless of this value to prevent denial-of-service or brute force attacks.",
// Change the env from the auto-generated CODER_RATE_LIMIT_API to the
// old value to avoid breaking existing deployments.
EnvOverride: "CODER_API_RATE_LIMIT",
Flag: "api-rate-limit",
Default: 512,
},
},
Experimental: &codersdk.DeploymentConfigField[bool]{
Name: "Experimental",
Usage: "Enable experimental features. Experimental features are not ready for production.",
Flag: "experimental",
},
UpdateCheck: &codersdk.DeploymentConfigField[bool]{
Name: "Update Check",
Usage: "Periodically check for new releases of Coder and inform the owner. The check is performed once per day.",
Flag: "update-check",
Default: flag.Lookup("test.v") == nil && !buildinfo.IsDev(),
},
MaxTokenLifetime: &codersdk.DeploymentConfigField[time.Duration]{
Name: "Max Token Lifetime",
Usage: "The maximum lifetime duration for any user creating a token.",
Flag: "max-token-lifetime",
Default: 24 * 30 * time.Hour,
},
Swagger: &codersdk.SwaggerConfig{
Enable: &codersdk.DeploymentConfigField[bool]{
Name: "Enable swagger endpoint",
Usage: "Expose the swagger endpoint via /swagger.",
Flag: "swagger-enable",
Default: false,
},
},
}
}
//nolint:revive
func Config(flagset *pflag.FlagSet, vip *viper.Viper) (*codersdk.DeploymentConfig, error) {
dc := newConfig()
flg, err := flagset.GetString(config.FlagName)
if err != nil {
return nil, xerrors.Errorf("get global config from flag: %w", err)
}
vip.SetEnvPrefix("coder")
if flg != "" {
vip.SetConfigFile(flg + "/server.yaml")
err = vip.ReadInConfig()
if err != nil && !xerrors.Is(err, os.ErrNotExist) {
return dc, xerrors.Errorf("reading deployment config: %w", err)
}
}
setConfig("", vip, &dc)
return dc, nil
}
func setConfig(prefix string, vip *viper.Viper, target interface{}) {
val := reflect.Indirect(reflect.ValueOf(target))
typ := val.Type()
if typ.Kind() != reflect.Struct {
val = val.Elem()
typ = val.Type()
}
// Ensure that we only bind env variables to proper fields,
// otherwise Viper will get confused if the parent struct is
// assigned a value.
if strings.HasPrefix(typ.Name(), "DeploymentConfigField[") {
value := val.FieldByName("Value").Interface()
env, ok := val.FieldByName("EnvOverride").Interface().(string)
if !ok {
panic("DeploymentConfigField[].EnvOverride must be a string")
}
if env == "" {
env = formatEnv(prefix)
}
switch value.(type) {
case string:
vip.MustBindEnv(prefix, env)
val.FieldByName("Value").SetString(vip.GetString(prefix))
case bool:
vip.MustBindEnv(prefix, env)
val.FieldByName("Value").SetBool(vip.GetBool(prefix))
case int:
vip.MustBindEnv(prefix, env)
val.FieldByName("Value").SetInt(int64(vip.GetInt(prefix)))
case time.Duration:
vip.MustBindEnv(prefix, env)
val.FieldByName("Value").SetInt(int64(vip.GetDuration(prefix)))
case []string:
vip.MustBindEnv(prefix, env)
// As of October 21st, 2022 we supported delimiting a string
// with a comma, but Viper only supports with a space. This
// is a small hack around it!
rawSlice := reflect.ValueOf(vip.GetStringSlice(prefix)).Interface()
slice, ok := rawSlice.([]string)
if !ok {
panic(fmt.Sprintf("string slice is of type %T", rawSlice))
}
value := make([]string, 0, len(slice))
for _, entry := range slice {
value = append(value, strings.Split(entry, ",")...)
}
val.FieldByName("Value").Set(reflect.ValueOf(value))
case []codersdk.GitAuthConfig:
// Do not bind to CODER_GITAUTH, instead bind to CODER_GITAUTH_0_*, etc.
values := readSliceFromViper[codersdk.GitAuthConfig](vip, prefix, value)
val.FieldByName("Value").Set(reflect.ValueOf(values))
default:
panic(fmt.Sprintf("unsupported type %T", value))
}
return
}
for i := 0; i < typ.NumField(); i++ {
fv := val.Field(i)
ft := fv.Type()
tag := typ.Field(i).Tag.Get("json")
var key string
if prefix == "" {
key = tag
} else {
key = fmt.Sprintf("%s.%s", prefix, tag)
}
switch ft.Kind() {
case reflect.Ptr:
setConfig(key, vip, fv.Interface())
case reflect.Slice:
for j := 0; j < fv.Len(); j++ {
key := fmt.Sprintf("%s.%d", key, j)
setConfig(key, vip, fv.Index(j).Interface())
}
default:
panic(fmt.Sprintf("unsupported type %T", ft))
}
}
}
// readSliceFromViper reads a typed mapping from the key provided.
// This enables environment variables like CODER_GITAUTH_<index>_CLIENT_ID.
func readSliceFromViper[T any](vip *viper.Viper, key string, value any) []T {
elementType := reflect.TypeOf(value).Elem()
returnValues := make([]T, 0)
for entry := 0; true; entry++ {
// Only create an instance when the entry exists in viper...
// otherwise we risk
var instance *reflect.Value
for i := 0; i < elementType.NumField(); i++ {
fve := elementType.Field(i)
prop := fve.Tag.Get("json")
// For fields that are omitted in JSON, we use a YAML tag.
if prop == "-" {
prop = fve.Tag.Get("yaml")
}
configKey := fmt.Sprintf("%s.%d.%s", key, entry, prop)
// Ensure the env entry for this key is registered
// before checking value.
//
// We don't support DeploymentConfigField[].EnvOverride for array flags so
// this is fine to just use `formatEnv` here.
vip.MustBindEnv(configKey, formatEnv(configKey))
value := vip.Get(configKey)
if value == nil {
continue
}
if instance == nil {
newType := reflect.Indirect(reflect.New(elementType))
instance = &newType
}
switch v := instance.Field(i).Type().String(); v {
case "[]string":
value = vip.GetStringSlice(configKey)
case "bool":
value = vip.GetBool(configKey)
default:
}
instance.Field(i).Set(reflect.ValueOf(value))
}
if instance == nil {
break
}
value, ok := instance.Interface().(T)
if !ok {
continue
}
returnValues = append(returnValues, value)
}
return returnValues
}
func NewViper() *viper.Viper {
dc := newConfig()
vip := viper.New()
vip.SetEnvPrefix("coder")
vip.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_"))
setViperDefaults("", vip, dc)
return vip
}
func setViperDefaults(prefix string, vip *viper.Viper, target interface{}) {
val := reflect.ValueOf(target).Elem()
val = reflect.Indirect(val)
typ := val.Type()
if strings.HasPrefix(typ.Name(), "DeploymentConfigField[") {
value := val.FieldByName("Default").Interface()
vip.SetDefault(prefix, value)
return
}
for i := 0; i < typ.NumField(); i++ {
fv := val.Field(i)
ft := fv.Type()
tag := typ.Field(i).Tag.Get("json")
var key string
if prefix == "" {
key = tag
} else {
key = fmt.Sprintf("%s.%s", prefix, tag)
}
switch ft.Kind() {
case reflect.Ptr:
setViperDefaults(key, vip, fv.Interface())
case reflect.Slice:
// we currently don't support default values on structured slices
continue
default:
panic(fmt.Sprintf("unsupported type %T", ft))
}
}
}
//nolint:revive
func AttachFlags(flagset *pflag.FlagSet, vip *viper.Viper, enterprise bool) {
setFlags("", flagset, vip, newConfig(), enterprise)
}
//nolint:revive
func setFlags(prefix string, flagset *pflag.FlagSet, vip *viper.Viper, target interface{}, enterprise bool) {
val := reflect.Indirect(reflect.ValueOf(target))
typ := val.Type()
if strings.HasPrefix(typ.Name(), "DeploymentConfigField[") {
isEnt := val.FieldByName("Enterprise").Bool()
if enterprise != isEnt {
return
}
flg := val.FieldByName("Flag").String()
if flg == "" {
return
}
env, ok := val.FieldByName("EnvOverride").Interface().(string)
if !ok {
panic("DeploymentConfigField[].EnvOverride must be a string")
}
if env == "" {
env = formatEnv(prefix)
}
usage := val.FieldByName("Usage").String()
usage = fmt.Sprintf("%s\n%s", usage, cliui.Styles.Placeholder.Render("Consumes $"+env))
shorthand := val.FieldByName("Shorthand").String()
hidden := val.FieldByName("Hidden").Bool()
value := val.FieldByName("Default").Interface()
// Allow currently set environment variables
// to override default values in help output.
vip.MustBindEnv(prefix, env)
switch value.(type) {
case string:
_ = flagset.StringP(flg, shorthand, vip.GetString(prefix), usage)
case bool:
_ = flagset.BoolP(flg, shorthand, vip.GetBool(prefix), usage)
case int:
_ = flagset.IntP(flg, shorthand, vip.GetInt(prefix), usage)
case time.Duration:
_ = flagset.DurationP(flg, shorthand, vip.GetDuration(prefix), usage)
case []string:
_ = flagset.StringSliceP(flg, shorthand, vip.GetStringSlice(prefix), usage)
case []codersdk.GitAuthConfig:
// Ignore this one!
default:
panic(fmt.Sprintf("unsupported type %T", typ))
}
_ = vip.BindPFlag(prefix, flagset.Lookup(flg))
if hidden {
_ = flagset.MarkHidden(flg)
}
return
}
for i := 0; i < typ.NumField(); i++ {
fv := val.Field(i)
ft := fv.Type()
tag := typ.Field(i).Tag.Get("json")
var key string
if prefix == "" {
key = tag
} else {
key = fmt.Sprintf("%s.%s", prefix, tag)
}
switch ft.Kind() {
case reflect.Ptr:
setFlags(key, flagset, vip, fv.Interface(), enterprise)
case reflect.Slice:
for j := 0; j < fv.Len(); j++ {
key := fmt.Sprintf("%s.%d", key, j)
setFlags(key, flagset, vip, fv.Index(j).Interface(), enterprise)
}
default:
panic(fmt.Sprintf("unsupported type %T", ft))
}
}
}
func formatEnv(key string) string {
return "CODER_" + strings.ToUpper(strings.NewReplacer("-", "_", ".", "_").Replace(key))
}
func DefaultCacheDir() string {
defaultCacheDir, err := os.UserCacheDir()
if err != nil {
defaultCacheDir = os.TempDir()
}
if dir := os.Getenv("CACHE_DIRECTORY"); dir != "" {
// For compatibility with systemd.
defaultCacheDir = dir
}
return filepath.Join(defaultCacheDir, "coder")
}
+247
View File
@@ -0,0 +1,247 @@
package deployment_test
import (
"testing"
"time"
"github.com/spf13/pflag"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/config"
"github.com/coder/coder/cli/deployment"
"github.com/coder/coder/codersdk"
)
// nolint:paralleltest
func TestConfig(t *testing.T) {
viper := deployment.NewViper()
flagSet := pflag.NewFlagSet("", pflag.ContinueOnError)
flagSet.String(config.FlagName, "", "")
deployment.AttachFlags(flagSet, viper, true)
for _, tc := range []struct {
Name string
Env map[string]string
Valid func(config *codersdk.DeploymentConfig)
}{{
Name: "Deployment",
Env: map[string]string{
"CODER_ADDRESS": "0.0.0.0:8443",
"CODER_ACCESS_URL": "https://dev.coder.com",
"CODER_PG_CONNECTION_URL": "some-url",
"CODER_PPROF_ADDRESS": "something",
"CODER_PPROF_ENABLE": "true",
"CODER_PROMETHEUS_ADDRESS": "hello-world",
"CODER_PROMETHEUS_ENABLE": "true",
"CODER_PROVISIONER_DAEMONS": "5",
"CODER_PROVISIONER_DAEMON_POLL_INTERVAL": "5s",
"CODER_PROVISIONER_DAEMON_POLL_JITTER": "1s",
"CODER_SECURE_AUTH_COOKIE": "true",
"CODER_SSH_KEYGEN_ALGORITHM": "potato",
"CODER_TELEMETRY": "false",
"CODER_TELEMETRY_TRACE": "false",
"CODER_WILDCARD_ACCESS_URL": "something-wildcard.com",
"CODER_UPDATE_CHECK": "false",
},
Valid: func(config *codersdk.DeploymentConfig) {
require.Equal(t, config.Address.Value, "0.0.0.0:8443")
require.Equal(t, config.AccessURL.Value, "https://dev.coder.com")
require.Equal(t, config.PostgresURL.Value, "some-url")
require.Equal(t, config.Pprof.Address.Value, "something")
require.Equal(t, config.Pprof.Enable.Value, true)
require.Equal(t, config.Prometheus.Address.Value, "hello-world")
require.Equal(t, config.Prometheus.Enable.Value, true)
require.Equal(t, config.Provisioner.Daemons.Value, 5)
require.Equal(t, config.Provisioner.DaemonPollInterval.Value, 5*time.Second)
require.Equal(t, config.Provisioner.DaemonPollJitter.Value, 1*time.Second)
require.Equal(t, config.SecureAuthCookie.Value, true)
require.Equal(t, config.SSHKeygenAlgorithm.Value, "potato")
require.Equal(t, config.Telemetry.Enable.Value, false)
require.Equal(t, config.Telemetry.Trace.Value, false)
require.Equal(t, config.WildcardAccessURL.Value, "something-wildcard.com")
require.Equal(t, config.UpdateCheck.Value, false)
},
}, {
Name: "DERP",
Env: map[string]string{
"CODER_DERP_CONFIG_PATH": "/example/path",
"CODER_DERP_CONFIG_URL": "https://google.com",
"CODER_DERP_SERVER_ENABLE": "false",
"CODER_DERP_SERVER_REGION_CODE": "something",
"CODER_DERP_SERVER_REGION_ID": "123",
"CODER_DERP_SERVER_REGION_NAME": "Code-Land",
"CODER_DERP_SERVER_RELAY_URL": "1.1.1.1",
"CODER_DERP_SERVER_STUN_ADDRESSES": "google.org",
},
Valid: func(config *codersdk.DeploymentConfig) {
require.Equal(t, config.DERP.Config.Path.Value, "/example/path")
require.Equal(t, config.DERP.Config.URL.Value, "https://google.com")
require.Equal(t, config.DERP.Server.Enable.Value, false)
require.Equal(t, config.DERP.Server.RegionCode.Value, "something")
require.Equal(t, config.DERP.Server.RegionID.Value, 123)
require.Equal(t, config.DERP.Server.RegionName.Value, "Code-Land")
require.Equal(t, config.DERP.Server.RelayURL.Value, "1.1.1.1")
require.Equal(t, config.DERP.Server.STUNAddresses.Value, []string{"google.org"})
},
}, {
Name: "Enterprise",
Env: map[string]string{
"CODER_AUDIT_LOGGING": "false",
"CODER_BROWSER_ONLY": "true",
"CODER_SCIM_API_KEY": "some-key",
},
Valid: func(config *codersdk.DeploymentConfig) {
require.Equal(t, config.AuditLogging.Value, false)
require.Equal(t, config.BrowserOnly.Value, true)
require.Equal(t, config.SCIMAPIKey.Value, "some-key")
},
}, {
Name: "TLS",
Env: map[string]string{
"CODER_TLS_CERT_FILE": "/etc/acme-sh/dev.coder.com,/etc/acme-sh/*.dev.coder.com",
"CODER_TLS_KEY_FILE": "/etc/acme-sh/dev.coder.com,/etc/acme-sh/*.dev.coder.com",
"CODER_TLS_CLIENT_AUTH": "/some/path",
"CODER_TLS_CLIENT_CA_FILE": "/some/path",
"CODER_TLS_ENABLE": "true",
"CODER_TLS_MIN_VERSION": "tls10",
},
Valid: func(config *codersdk.DeploymentConfig) {
require.Len(t, config.TLS.CertFiles.Value, 2)
require.Equal(t, config.TLS.CertFiles.Value[0], "/etc/acme-sh/dev.coder.com")
require.Equal(t, config.TLS.CertFiles.Value[1], "/etc/acme-sh/*.dev.coder.com")
require.Len(t, config.TLS.KeyFiles.Value, 2)
require.Equal(t, config.TLS.KeyFiles.Value[0], "/etc/acme-sh/dev.coder.com")
require.Equal(t, config.TLS.KeyFiles.Value[1], "/etc/acme-sh/*.dev.coder.com")
require.Equal(t, config.TLS.ClientAuth.Value, "/some/path")
require.Equal(t, config.TLS.ClientCAFile.Value, "/some/path")
require.Equal(t, config.TLS.Enable.Value, true)
require.Equal(t, config.TLS.MinVersion.Value, "tls10")
},
}, {
Name: "Trace",
Env: map[string]string{
"CODER_TRACE_ENABLE": "true",
"CODER_TRACE_HONEYCOMB_API_KEY": "my-honeycomb-key",
},
Valid: func(config *codersdk.DeploymentConfig) {
require.Equal(t, config.Trace.Enable.Value, true)
require.Equal(t, config.Trace.HoneycombAPIKey.Value, "my-honeycomb-key")
},
}, {
Name: "OIDC_Defaults",
Env: map[string]string{},
Valid: func(config *codersdk.DeploymentConfig) {
require.Empty(t, config.OIDC.IssuerURL.Value)
require.Empty(t, config.OIDC.EmailDomain.Value)
require.Empty(t, config.OIDC.ClientID.Value)
require.Empty(t, config.OIDC.ClientSecret.Value)
require.True(t, config.OIDC.AllowSignups.Value)
require.ElementsMatch(t, config.OIDC.Scopes.Value, []string{"openid", "email", "profile"})
require.False(t, config.OIDC.IgnoreEmailVerified.Value)
},
}, {
Name: "OIDC",
Env: map[string]string{
"CODER_OIDC_ISSUER_URL": "https://accounts.google.com",
"CODER_OIDC_EMAIL_DOMAIN": "coder.com",
"CODER_OIDC_CLIENT_ID": "client",
"CODER_OIDC_CLIENT_SECRET": "secret",
"CODER_OIDC_ALLOW_SIGNUPS": "false",
"CODER_OIDC_SCOPES": "something,here",
"CODER_OIDC_IGNORE_EMAIL_VERIFIED": "true",
},
Valid: func(config *codersdk.DeploymentConfig) {
require.Equal(t, config.OIDC.IssuerURL.Value, "https://accounts.google.com")
require.Equal(t, config.OIDC.EmailDomain.Value, []string{"coder.com"})
require.Equal(t, config.OIDC.ClientID.Value, "client")
require.Equal(t, config.OIDC.ClientSecret.Value, "secret")
require.False(t, config.OIDC.AllowSignups.Value)
require.Equal(t, config.OIDC.Scopes.Value, []string{"something", "here"})
require.True(t, config.OIDC.IgnoreEmailVerified.Value)
},
}, {
Name: "GitHub",
Env: map[string]string{
"CODER_OAUTH2_GITHUB_CLIENT_ID": "client",
"CODER_OAUTH2_GITHUB_CLIENT_SECRET": "secret",
"CODER_OAUTH2_GITHUB_ALLOWED_ORGS": "coder",
"CODER_OAUTH2_GITHUB_ALLOWED_TEAMS": "coder",
"CODER_OAUTH2_GITHUB_ALLOW_SIGNUPS": "true",
},
Valid: func(config *codersdk.DeploymentConfig) {
require.Equal(t, config.OAuth2.Github.ClientID.Value, "client")
require.Equal(t, config.OAuth2.Github.ClientSecret.Value, "secret")
require.Equal(t, []string{"coder"}, config.OAuth2.Github.AllowedOrgs.Value)
require.Equal(t, []string{"coder"}, config.OAuth2.Github.AllowedTeams.Value)
require.Equal(t, config.OAuth2.Github.AllowSignups.Value, true)
},
}, {
Name: "GitAuth",
Env: map[string]string{
"CODER_GITAUTH_0_ID": "hello",
"CODER_GITAUTH_0_TYPE": "github",
"CODER_GITAUTH_0_CLIENT_ID": "client",
"CODER_GITAUTH_0_CLIENT_SECRET": "secret",
"CODER_GITAUTH_0_AUTH_URL": "https://auth.com",
"CODER_GITAUTH_0_TOKEN_URL": "https://token.com",
"CODER_GITAUTH_0_VALIDATE_URL": "https://validate.com",
"CODER_GITAUTH_0_REGEX": "github.com",
"CODER_GITAUTH_0_SCOPES": "read write",
"CODER_GITAUTH_0_NO_REFRESH": "true",
"CODER_GITAUTH_1_ID": "another",
"CODER_GITAUTH_1_TYPE": "gitlab",
"CODER_GITAUTH_1_CLIENT_ID": "client-2",
"CODER_GITAUTH_1_CLIENT_SECRET": "secret-2",
"CODER_GITAUTH_1_AUTH_URL": "https://auth-2.com",
"CODER_GITAUTH_1_TOKEN_URL": "https://token-2.com",
"CODER_GITAUTH_1_REGEX": "gitlab.com",
},
Valid: func(config *codersdk.DeploymentConfig) {
require.Len(t, config.GitAuth.Value, 2)
require.Equal(t, []codersdk.GitAuthConfig{{
ID: "hello",
Type: "github",
ClientID: "client",
ClientSecret: "secret",
AuthURL: "https://auth.com",
TokenURL: "https://token.com",
ValidateURL: "https://validate.com",
Regex: "github.com",
Scopes: []string{"read", "write"},
NoRefresh: true,
}, {
ID: "another",
Type: "gitlab",
ClientID: "client-2",
ClientSecret: "secret-2",
AuthURL: "https://auth-2.com",
TokenURL: "https://token-2.com",
Regex: "gitlab.com",
}}, config.GitAuth.Value)
},
}, {
Name: "Wrong env must not break default values",
Env: map[string]string{
"CODER_PROMETHEUS_ENABLE": "true",
"CODER_PROMETHEUS": "true", // Wrong env name, must not break prom addr.
},
Valid: func(config *codersdk.DeploymentConfig) {
require.Equal(t, config.Prometheus.Enable.Value, true)
require.Equal(t, config.Prometheus.Address.Value, config.Prometheus.Address.Default)
},
}} {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
t.Helper()
for key, value := range tc.Env {
t.Setenv(key, value)
}
config, err := deployment.Config(flagSet, viper)
require.NoError(t, err)
tc.Valid(config)
})
}
}
+282
View File
@@ -0,0 +1,282 @@
package cli
import (
"errors"
"fmt"
"io/fs"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
"github.com/spf13/cobra"
"golang.org/x/xerrors"
"github.com/coder/coder/cli/cliflag"
"github.com/coder/coder/cli/cliui"
)
func dotfiles() *cobra.Command {
var symlinkDir string
cmd := &cobra.Command{
Use: "dotfiles [git_repo_url]",
Args: cobra.ExactArgs(1),
Short: "Checkout and install a dotfiles repository from a Git URL",
Example: formatExamples(
example{
Description: "Check out and install a dotfiles repository without prompts",
Command: "coder dotfiles --yes git@github.com:example/dotfiles.git",
},
),
RunE: func(cmd *cobra.Command, args []string) error {
var (
dotfilesRepoDir = "dotfiles"
gitRepo = args[0]
cfg = createConfig(cmd)
cfgDir = string(cfg)
dotfilesDir = filepath.Join(cfgDir, dotfilesRepoDir)
// This follows the same pattern outlined by others in the market:
// https://github.com/coder/coder/pull/1696#issue-1245742312
installScriptSet = []string{
"install.sh",
"install",
"bootstrap.sh",
"bootstrap",
"script/bootstrap",
"setup.sh",
"setup",
"script/setup",
}
)
_, _ = fmt.Fprint(cmd.OutOrStdout(), "Checking if dotfiles repository already exists...\n")
dotfilesExists, err := dirExists(dotfilesDir)
if err != nil {
return xerrors.Errorf("checking dir %s: %w", dotfilesDir, err)
}
moved := false
if dotfilesExists {
du, err := cfg.DotfilesURL().Read()
if err != nil && !errors.Is(err, os.ErrNotExist) {
return xerrors.Errorf("reading dotfiles url config: %w", err)
}
// if the git url has changed we create a backup and clone fresh
if gitRepo != du {
backupDir := fmt.Sprintf("%s_backup_%s", dotfilesDir, time.Now().Format(time.RFC3339))
_, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: fmt.Sprintf("The dotfiles URL has changed from %q to %q.\n Coder will backup the existing repo to %s.\n\n Continue?", du, gitRepo, backupDir),
IsConfirm: true,
})
if err != nil {
return err
}
err = os.Rename(dotfilesDir, backupDir)
if err != nil {
return xerrors.Errorf("renaming dir %s: %w", dotfilesDir, err)
}
_, _ = fmt.Fprint(cmd.OutOrStdout(), "Done backup up dotfiles.\n")
dotfilesExists = false
moved = true
}
}
var (
gitCmdDir string
subcommands []string
promptText string
)
if dotfilesExists {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Found dotfiles repository at %s\n", dotfilesDir)
gitCmdDir = dotfilesDir
subcommands = []string{"pull", "--ff-only"}
promptText = fmt.Sprintf("Pulling latest from %s into directory %s.\n Continue?", gitRepo, dotfilesDir)
} else {
if !moved {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Did not find dotfiles repository at %s\n", dotfilesDir)
}
gitCmdDir = cfgDir
subcommands = []string{"clone", args[0], dotfilesRepoDir}
promptText = fmt.Sprintf("Cloning %s into directory %s.\n\n Continue?", gitRepo, dotfilesDir)
}
_, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: promptText,
IsConfirm: true,
})
if err != nil {
return err
}
// ensure command dir exists
err = os.MkdirAll(gitCmdDir, 0750)
if err != nil {
return xerrors.Errorf("ensuring dir at %s: %w", gitCmdDir, err)
}
// check if git ssh command already exists so we can just wrap it
gitsshCmd := os.Getenv("GIT_SSH_COMMAND")
if gitsshCmd == "" {
gitsshCmd = "ssh"
}
// clone or pull repo
c := exec.CommandContext(cmd.Context(), "git", subcommands...)
c.Dir = gitCmdDir
c.Env = append(os.Environ(), fmt.Sprintf(`GIT_SSH_COMMAND=%s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no`, gitsshCmd))
c.Stdout = cmd.OutOrStdout()
c.Stderr = cmd.ErrOrStderr()
err = c.Run()
if err != nil {
if !dotfilesExists {
return err
}
// if the repo exists we soft fail the update operation and try to continue
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Error.Render("Failed to update repo, continuing..."))
}
// save git repo url so we can detect changes next time
err = cfg.DotfilesURL().Write(gitRepo)
if err != nil {
return xerrors.Errorf("writing dotfiles url config: %w", err)
}
files, err := os.ReadDir(dotfilesDir)
if err != nil {
return xerrors.Errorf("reading files in dir %s: %w", dotfilesDir, err)
}
var dotfiles []string
for _, f := range files {
// make sure we do not copy `.git*` files
if strings.HasPrefix(f.Name(), ".") && !strings.HasPrefix(f.Name(), ".git") {
dotfiles = append(dotfiles, f.Name())
}
}
script := findScript(installScriptSet, files)
if script != "" {
_, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: fmt.Sprintf("Running install script %s.\n\n Continue?", script),
IsConfirm: true,
})
if err != nil {
return err
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Running %s...\n", script)
// it is safe to use a variable command here because it's from
// a filtered list of pre-approved install scripts
// nolint:gosec
scriptCmd := exec.CommandContext(cmd.Context(), filepath.Join(dotfilesDir, script))
scriptCmd.Dir = dotfilesDir
scriptCmd.Stdout = cmd.OutOrStdout()
scriptCmd.Stderr = cmd.ErrOrStderr()
err = scriptCmd.Run()
if err != nil {
return xerrors.Errorf("running %s: %w", script, err)
}
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Dotfiles installation complete.")
return nil
}
if len(dotfiles) == 0 {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "No install scripts or dotfiles found, nothing to do.")
return nil
}
_, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: "No install scripts found, symlinking dotfiles to home directory.\n\n Continue?",
IsConfirm: true,
})
if err != nil {
return err
}
if symlinkDir == "" {
symlinkDir, err = os.UserHomeDir()
if err != nil {
return xerrors.Errorf("getting user home: %w", err)
}
}
for _, df := range dotfiles {
from := filepath.Join(dotfilesDir, df)
to := filepath.Join(symlinkDir, df)
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Symlinking %s to %s...\n", from, to)
isRegular, err := isRegular(to)
if err != nil {
return xerrors.Errorf("checking symlink for %s: %w", to, err)
}
// move conflicting non-symlink files to file.ext.bak
if isRegular {
backup := fmt.Sprintf("%s.bak", to)
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Moving %s to %s...\n", to, backup)
err = os.Rename(to, backup)
if err != nil {
return xerrors.Errorf("renaming dir %s: %w", to, err)
}
}
err = os.Symlink(from, to)
if err != nil {
return xerrors.Errorf("symlinking %s to %s: %w", from, to, err)
}
}
_, _ = fmt.Fprintln(cmd.OutOrStdout(), "Dotfiles installation complete.")
return nil
},
}
cliui.AllowSkipPrompt(cmd)
cliflag.StringVarP(cmd.Flags(), &symlinkDir, "symlink-dir", "", "CODER_SYMLINK_DIR", "", "Specifies the directory for the dotfiles symlink destinations. If empty will use $HOME.")
return cmd
}
// dirExists checks if the path exists and is a directory.
func dirExists(name string) (bool, error) {
fi, err := os.Stat(name)
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, xerrors.Errorf("stat dir: %w", err)
}
if !fi.IsDir() {
return false, xerrors.New("exists but not a directory")
}
return true, nil
}
// findScript will find the first file that matches the script set.
func findScript(scriptSet []string, files []fs.DirEntry) string {
for _, i := range scriptSet {
for _, f := range files {
if f.Name() == i {
return f.Name()
}
}
}
return ""
}
// isRegular detects if the file exists and is not a symlink.
func isRegular(to string) (bool, error) {
fi, err := os.Lstat(to)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return false, nil
}
return false, xerrors.Errorf("lstat %s: %w", to, err)
}
return fi.Mode().IsRegular(), nil
}
+141
View File
@@ -0,0 +1,141 @@
package cli_test
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/cli/config"
"github.com/coder/coder/cryptorand"
)
// nolint:paralleltest
func TestDotfiles(t *testing.T) {
t.Run("MissingArg", func(t *testing.T) {
cmd, _ := clitest.New(t, "dotfiles")
err := cmd.Execute()
require.Error(t, err)
})
t.Run("NoInstallScript", func(t *testing.T) {
_, root := clitest.New(t)
testRepo := testGitRepo(t, root)
// nolint:gosec
err := os.WriteFile(filepath.Join(testRepo, ".bashrc"), []byte("wow"), 0750)
require.NoError(t, err)
c := exec.Command("git", "add", ".bashrc")
c.Dir = testRepo
err = c.Run()
require.NoError(t, err)
c = exec.Command("git", "commit", "-m", `"add .bashrc"`)
c.Dir = testRepo
out, err := c.CombinedOutput()
require.NoError(t, err, string(out))
cmd, _ := clitest.New(t, "dotfiles", "--global-config", string(root), "--symlink-dir", string(root), "-y", testRepo)
err = cmd.Execute()
require.NoError(t, err)
b, err := os.ReadFile(filepath.Join(string(root), ".bashrc"))
require.NoError(t, err)
require.Equal(t, string(b), "wow")
})
t.Run("InstallScript", func(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("install scripts on windows require sh and aren't very practical")
}
_, root := clitest.New(t)
testRepo := testGitRepo(t, root)
// nolint:gosec
err := os.WriteFile(filepath.Join(testRepo, "install.sh"), []byte("#!/bin/bash\necho wow > "+filepath.Join(string(root), ".bashrc")), 0750)
require.NoError(t, err)
c := exec.Command("git", "add", "install.sh")
c.Dir = testRepo
err = c.Run()
require.NoError(t, err)
c = exec.Command("git", "commit", "-m", `"add install.sh"`)
c.Dir = testRepo
err = c.Run()
require.NoError(t, err)
cmd, _ := clitest.New(t, "dotfiles", "--global-config", string(root), "--symlink-dir", string(root), "-y", testRepo)
err = cmd.Execute()
require.NoError(t, err)
b, err := os.ReadFile(filepath.Join(string(root), ".bashrc"))
require.NoError(t, err)
require.Equal(t, string(b), "wow\n")
})
t.Run("SymlinkBackup", func(t *testing.T) {
_, root := clitest.New(t)
testRepo := testGitRepo(t, root)
// nolint:gosec
err := os.WriteFile(filepath.Join(testRepo, ".bashrc"), []byte("wow"), 0750)
require.NoError(t, err)
// add a conflicting file at destination
// nolint:gosec
err = os.WriteFile(filepath.Join(string(root), ".bashrc"), []byte("backup"), 0750)
require.NoError(t, err)
c := exec.Command("git", "add", ".bashrc")
c.Dir = testRepo
err = c.Run()
require.NoError(t, err)
c = exec.Command("git", "commit", "-m", `"add .bashrc"`)
c.Dir = testRepo
out, err := c.CombinedOutput()
require.NoError(t, err, string(out))
cmd, _ := clitest.New(t, "dotfiles", "--global-config", string(root), "--symlink-dir", string(root), "-y", testRepo)
err = cmd.Execute()
require.NoError(t, err)
b, err := os.ReadFile(filepath.Join(string(root), ".bashrc"))
require.NoError(t, err)
require.Equal(t, string(b), "wow")
// check for backup file
b, err = os.ReadFile(filepath.Join(string(root), ".bashrc.bak"))
require.NoError(t, err)
require.Equal(t, string(b), "backup")
})
}
func testGitRepo(t *testing.T, root config.Root) string {
r, err := cryptorand.String(8)
require.NoError(t, err)
dir := filepath.Join(string(root), fmt.Sprintf("test-repo-%s", r))
err = os.MkdirAll(dir, 0750)
require.NoError(t, err)
c := exec.Command("git", "init")
c.Dir = dir
err = c.Run()
require.NoError(t, err)
c = exec.Command("git", "config", "user.email", "ci@coder.com")
c.Dir = dir
err = c.Run()
require.NoError(t, err)
c = exec.Command("git", "config", "user.name", "C I")
c.Dir = dir
err = c.Run()
require.NoError(t, err)
return dir
}
+83
View File
@@ -0,0 +1,83 @@
package cli
import (
"errors"
"fmt"
"net/http"
"os/signal"
"time"
"github.com/spf13/cobra"
"golang.org/x/xerrors"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/gitauth"
"github.com/coder/coder/codersdk"
"github.com/coder/retry"
)
// gitAskpass is used by the Coder agent to automatically authenticate
// with Git providers based on a hostname.
func gitAskpass() *cobra.Command {
return &cobra.Command{
Use: "gitaskpass",
Hidden: true,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
ctx, stop := signal.NotifyContext(ctx, InterruptSignals...)
defer stop()
user, host, err := gitauth.ParseAskpass(args[0])
if err != nil {
return xerrors.Errorf("parse host: %w", err)
}
client, err := createAgentClient(cmd)
if err != nil {
return xerrors.Errorf("create agent client: %w", err)
}
token, err := client.WorkspaceAgentGitAuth(ctx, host, false)
if err != nil {
var apiError *codersdk.Error
if errors.As(err, &apiError) && apiError.StatusCode() == http.StatusNotFound {
// This prevents the "Run 'coder --help' for usage"
// message from occurring.
cmd.Printf("%s\n", apiError.Message)
return cliui.Canceled
}
return xerrors.Errorf("get git token: %w", err)
}
if token.URL != "" {
if err := openURL(cmd, token.URL); err == nil {
cmd.Printf("Your browser has been opened to authenticate with Git:\n\n\t%s\n\n", token.URL)
} else {
cmd.Printf("Open the following URL to authenticate with Git:\n\n\t%s\n\n", token.URL)
}
for r := retry.New(250*time.Millisecond, 10*time.Second); r.Wait(ctx); {
token, err = client.WorkspaceAgentGitAuth(ctx, host, true)
if err != nil {
continue
}
cmd.Printf("You've been authenticated with Git!\n")
break
}
}
if token.Password != "" {
if user == "" {
fmt.Fprintln(cmd.OutOrStdout(), token.Username)
} else {
fmt.Fprintln(cmd.OutOrStdout(), token.Password)
}
} else {
fmt.Fprintln(cmd.OutOrStdout(), token.Username)
}
return nil
},
}
}
+97
View File
@@ -0,0 +1,97 @@
package cli_test
import (
"context"
"net/http"
"net/http/httptest"
"sync/atomic"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/httpapi"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/pty/ptytest"
)
// nolint:paralleltest
func TestGitAskpass(t *testing.T) {
t.Setenv("GIT_PREFIX", "/")
t.Run("UsernameAndPassword", func(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
httpapi.Write(context.Background(), w, http.StatusOK, codersdk.WorkspaceAgentGitAuthResponse{
Username: "something",
Password: "bananas",
})
}))
t.Cleanup(srv.Close)
url := srv.URL
cmd, _ := clitest.New(t, "--agent-url", url, "Username for 'https://github.com':")
pty := ptytest.New(t)
cmd.SetOutput(pty.Output())
err := cmd.Execute()
require.NoError(t, err)
pty.ExpectMatch("something")
cmd, _ = clitest.New(t, "--agent-url", url, "Password for 'https://potato@github.com':")
pty = ptytest.New(t)
cmd.SetOutput(pty.Output())
err = cmd.Execute()
require.NoError(t, err)
pty.ExpectMatch("bananas")
})
t.Run("NoHost", func(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
httpapi.Write(context.Background(), w, http.StatusNotFound, codersdk.Response{
Message: "Nope!",
})
}))
t.Cleanup(srv.Close)
url := srv.URL
cmd, _ := clitest.New(t, "--agent-url", url, "--no-open", "Username for 'https://github.com':")
pty := ptytest.New(t)
cmd.SetOutput(pty.Output())
err := cmd.Execute()
require.ErrorIs(t, err, cliui.Canceled)
pty.ExpectMatch("Nope!")
})
t.Run("Poll", func(t *testing.T) {
resp := atomic.Pointer[codersdk.WorkspaceAgentGitAuthResponse]{}
resp.Store(&codersdk.WorkspaceAgentGitAuthResponse{
URL: "https://something.org",
})
poll := make(chan struct{}, 10)
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
val := resp.Load()
if r.URL.Query().Has("listen") {
poll <- struct{}{}
if val.URL != "" {
httpapi.Write(context.Background(), w, http.StatusInternalServerError, val)
return
}
}
httpapi.Write(context.Background(), w, http.StatusOK, val)
}))
t.Cleanup(srv.Close)
url := srv.URL
cmd, _ := clitest.New(t, "--agent-url", url, "--no-open", "Username for 'https://github.com':")
pty := ptytest.New(t)
cmd.SetOutput(pty.Output())
go func() {
err := cmd.Execute()
assert.NoError(t, err)
}()
<-poll
resp.Store(&codersdk.WorkspaceAgentGitAuthResponse{
Username: "username",
Password: "password",
})
pty.ExpectMatch("username")
})
}
+189
View File
@@ -0,0 +1,189 @@
package cli
import (
"bufio"
"bytes"
"context"
"fmt"
"io"
"os"
"os/exec"
"os/signal"
"path/filepath"
"strings"
"github.com/spf13/cobra"
"golang.org/x/xerrors"
"github.com/coder/coder/cli/cliui"
)
func gitssh() *cobra.Command {
cmd := &cobra.Command{
Use: "gitssh",
Hidden: true,
Short: `Wraps the "ssh" command and uses the coder gitssh key for authentication`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
env := os.Environ()
// Catch interrupt signals to ensure the temporary private
// key file is cleaned up on most cases.
ctx, stop := signal.NotifyContext(ctx, InterruptSignals...)
defer stop()
// Early check so errors are reported immediately.
identityFiles, err := parseIdentityFilesForHost(ctx, args, env)
if err != nil {
return err
}
client, err := createAgentClient(cmd)
if err != nil {
return xerrors.Errorf("create agent client: %w", err)
}
key, err := client.AgentGitSSHKey(ctx)
if err != nil {
return xerrors.Errorf("get agent git ssh token: %w", err)
}
privateKeyFile, err := os.CreateTemp("", "coder-gitsshkey-*")
if err != nil {
return xerrors.Errorf("create temp gitsshkey file: %w", err)
}
defer func() {
_ = privateKeyFile.Close()
_ = os.Remove(privateKeyFile.Name())
}()
_, err = privateKeyFile.WriteString(key.PrivateKey)
if err != nil {
return xerrors.Errorf("write to temp gitsshkey file: %w", err)
}
err = privateKeyFile.Close()
if err != nil {
return xerrors.Errorf("close temp gitsshkey file: %w", err)
}
// Append our key, giving precedence to user keys. Note that
// OpenSSH server are typically configured with MaxAuthTries
// set to the default value of 6. This means that only the 6
// first keys can be tried. However, we will assume that if
// a user has configured 6+ keys for a host, they know what
// they're doing. This behavior is critical if a server has
// been configured with MaxAuthTries set to 1.
identityFiles = append(identityFiles, privateKeyFile.Name())
var identityArgs []string
for _, id := range identityFiles {
identityArgs = append(identityArgs, "-i", id)
}
args = append(identityArgs, args...)
c := exec.CommandContext(ctx, "ssh", args...)
c.Env = append(c.Env, env...)
c.Stderr = cmd.ErrOrStderr()
c.Stdout = cmd.OutOrStdout()
c.Stdin = cmd.InOrStdin()
err = c.Run()
if err != nil {
exitErr := &exec.ExitError{}
if xerrors.As(err, &exitErr) && exitErr.ExitCode() == 255 {
_, _ = fmt.Fprintln(cmd.ErrOrStderr(),
"\n"+cliui.Styles.Wrap.Render("Coder authenticates with "+cliui.Styles.Field.Render("git")+
" using the public key below. All clones with SSH are authenticated automatically 🪄.")+"\n")
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), cliui.Styles.Code.Render(strings.TrimSpace(key.PublicKey))+"\n")
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), "Add to GitHub and GitLab:")
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), cliui.Styles.Prompt.String()+"https://github.com/settings/ssh/new")
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), cliui.Styles.Prompt.String()+"https://gitlab.com/-/profile/keys")
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
return err
}
return xerrors.Errorf("run ssh command: %w", err)
}
return nil
},
}
return cmd
}
// fallbackIdentityFiles is the list of identity files SSH tries when
// none have been defined for a host.
var fallbackIdentityFiles = strings.Join([]string{
"identityfile ~/.ssh/id_rsa",
"identityfile ~/.ssh/id_dsa",
"identityfile ~/.ssh/id_ecdsa",
"identityfile ~/.ssh/id_ecdsa_sk",
"identityfile ~/.ssh/id_ed25519",
"identityfile ~/.ssh/id_ed25519_sk",
"identityfile ~/.ssh/id_xmss",
}, "\n")
// parseIdentityFilesForHost uses ssh -G to discern what SSH keys have
// been enabled for the host (via the users SSH config) and returns a
// list of existing identity files.
//
// We do this because when no keys are defined for a host, SSH uses
// fallback keys (see above). However, by passing `-i` to attach our
// private key, we're effectively disabling the fallback keys.
//
// Example invocation:
//
// ssh -G -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack 'coder/coder'
//
// The extra arguments work without issue and lets us run the command
// as-is without stripping out the excess (git-upload-pack 'coder/coder').
func parseIdentityFilesForHost(ctx context.Context, args, env []string) (identityFiles []string, error error) {
home, err := os.UserHomeDir()
if err != nil {
return nil, xerrors.Errorf("get user home dir failed: %w", err)
}
var outBuf bytes.Buffer
var r io.Reader = &outBuf
args = append([]string{"-G"}, args...)
cmd := exec.CommandContext(ctx, "ssh", args...)
cmd.Env = append(cmd.Env, env...)
cmd.Stdout = &outBuf
cmd.Stderr = io.Discard
err = cmd.Run()
if err != nil {
// If ssh -G failed, the SSH version is likely too old, fallback
// to using the default identity files.
r = strings.NewReader(fallbackIdentityFiles)
}
s := bufio.NewScanner(r)
for s.Scan() {
line := s.Text()
if strings.HasPrefix(line, "identityfile ") {
id := strings.TrimPrefix(line, "identityfile ")
if strings.HasPrefix(id, "~/") {
id = home + id[1:]
}
// OpenSSH on Windows is weird, it supports using (and does
// use) mixed \ and / in paths.
//
// Example: C:\Users\ZeroCool/.ssh/known_hosts
//
// To check the file existence in Go, though, we want to use
// proper Windows paths.
// OpenSSH is amazing, this will work on Windows too:
// C:\Users\ZeroCool/.ssh/id_rsa
id = filepath.FromSlash(id)
// Only include the identity file if it exists.
if _, err := os.Stat(id); err == nil {
identityFiles = append(identityFiles, id)
}
}
}
if err := s.Err(); err != nil {
// This should never happen, the check is for completeness.
return nil, xerrors.Errorf("scan ssh output: %w", err)
}
return identityFiles, nil
}
+260
View File
@@ -0,0 +1,260 @@
package cli_test
import (
"context"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/x509"
"encoding/pem"
"fmt"
"net"
"os"
"path/filepath"
"strings"
"sync/atomic"
"testing"
"github.com/gliderlabs/ssh"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
gossh "golang.org/x/crypto/ssh"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/provisioner/echo"
"github.com/coder/coder/provisionersdk/proto"
"github.com/coder/coder/pty/ptytest"
"github.com/coder/coder/testutil"
)
func prepareTestGitSSH(ctx context.Context, t *testing.T) (*codersdk.Client, string, gossh.PublicKey) {
t.Helper()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
ctx, cancel := context.WithCancel(ctx)
defer t.Cleanup(cancel) // Defer so that cancel is the first cleanup.
// get user public key
keypair, err := client.GitSSHKey(ctx, codersdk.Me)
require.NoError(t, err)
//nolint:dogsled
pubkey, _, _, _, err := gossh.ParseAuthorizedKey([]byte(keypair.PublicKey))
require.NoError(t, err)
// setup template
agentToken := uuid.NewString()
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
Parse: echo.ParseComplete,
ProvisionPlan: echo.ProvisionComplete,
ProvisionApply: []*proto.Provision_Response{{
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
Resources: []*proto.Resource{{
Name: "somename",
Type: "someinstance",
Agents: []*proto.Agent{{
Auth: &proto.Agent_Token{
Token: agentToken,
},
}},
}},
},
},
}},
})
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)
// start workspace agent
cmd, root := clitest.New(t, "agent", "--agent-token", agentToken, "--agent-url", client.URL.String())
agentClient := client
clitest.SetupConfig(t, agentClient, root)
errC := make(chan error, 1)
go func() {
errC <- cmd.ExecuteContext(ctx)
}()
t.Cleanup(func() { require.NoError(t, <-errC) })
coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
return agentClient, agentToken, pubkey
}
func serveSSHForGitSSH(t *testing.T, handler func(ssh.Session), pubkeys ...gossh.PublicKey) *net.TCPAddr {
t.Helper()
// start ssh server
l, err := net.Listen("tcp", "localhost:0")
require.NoError(t, err)
t.Cleanup(func() { _ = l.Close() })
serveOpts := []ssh.Option{
ssh.PublicKeyAuth(func(ctx ssh.Context, key ssh.PublicKey) bool {
for _, pubkey := range pubkeys {
if ssh.KeysEqual(pubkey, key) {
return true
}
}
return false
}),
}
errC := make(chan error, 1)
go func() {
// as long as we get a successful session we don't care if the server errors
errC <- ssh.Serve(l, handler, serveOpts...)
}()
t.Cleanup(func() {
_ = l.Close() // Ensure server shutdown.
<-errC
})
// start ssh session
addr, ok := l.Addr().(*net.TCPAddr)
require.True(t, ok)
return addr
}
func writePrivateKeyToFile(t *testing.T, name string, key *ecdsa.PrivateKey) {
t.Helper()
b, err := x509.MarshalPKCS8PrivateKey(key)
require.NoError(t, err)
b = pem.EncodeToMemory(&pem.Block{
Type: "PRIVATE KEY",
Bytes: b,
})
err = os.WriteFile(name, b, 0o600)
require.NoError(t, err)
}
func TestGitSSH(t *testing.T) {
t.Parallel()
t.Run("Dial", func(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
client, token, pubkey := prepareTestGitSSH(ctx, t)
var inc int64
errC := make(chan error, 1)
addr := serveSSHForGitSSH(t, func(s ssh.Session) {
atomic.AddInt64(&inc, 1)
t.Log("got authenticated session")
select {
case errC <- s.Exit(0):
default:
t.Error("error channel is full")
}
}, pubkey)
// set to agent config dir
cmd, _ := clitest.New(t,
"gitssh",
"--agent-url", client.URL.String(),
"--agent-token", token,
"--",
fmt.Sprintf("-p%d", addr.Port),
"-o", "StrictHostKeyChecking=no",
"-o", "IdentitiesOnly=yes",
"127.0.0.1",
)
err := cmd.ExecuteContext(ctx)
require.NoError(t, err)
require.EqualValues(t, 1, inc)
err = <-errC
require.NoError(t, err, "error in agent execute")
})
t.Run("Local SSH Keys", func(t *testing.T) {
t.Parallel()
home := t.TempDir()
sshdir := filepath.Join(home, ".ssh")
err := os.MkdirAll(sshdir, 0o700)
require.NoError(t, err)
idFile := filepath.Join(sshdir, "id_ed25519")
privkey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
require.NoError(t, err)
localPubkey, err := gossh.NewPublicKey(&privkey.PublicKey)
require.NoError(t, err)
writePrivateKeyToFile(t, idFile, privkey)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()
client, token, coderPubkey := prepareTestGitSSH(ctx, t)
authkey := make(chan gossh.PublicKey, 1)
addr := serveSSHForGitSSH(t, func(s ssh.Session) {
t.Logf("authenticated with: %s", gossh.MarshalAuthorizedKey(s.PublicKey()))
select {
case authkey <- s.PublicKey():
default:
t.Error("authkey channel is full")
}
}, localPubkey, coderPubkey)
// Create a new config which sets an identity file.
config := filepath.Join(sshdir, "config")
knownHosts := filepath.Join(sshdir, "known_hosts")
err = os.WriteFile(config, []byte(strings.Join([]string{
"Host mytest",
" HostName 127.0.0.1",
fmt.Sprintf(" Port %d", addr.Port),
" StrictHostKeyChecking no",
" UserKnownHostsFile=" + knownHosts,
" IdentitiesOnly yes",
" IdentityFile=" + idFile,
}, "\n")), 0o600)
require.NoError(t, err)
pty := ptytest.New(t)
cmdArgs := []string{
"gitssh",
"--agent-url", client.URL.String(),
"--agent-token", token,
"--",
"-F", config,
"mytest",
}
// Test authentication via local private key.
cmd, _ := clitest.New(t, cmdArgs...)
cmd.SetOut(pty.Output())
cmd.SetErr(pty.Output())
err = cmd.ExecuteContext(ctx)
require.NoError(t, err)
select {
case key := <-authkey:
require.Equal(t, localPubkey, key)
case <-ctx.Done():
t.Fatal("timeout waiting for auth")
}
// Delete the local private key.
err = os.Remove(idFile)
require.NoError(t, err)
// With the local file deleted, the coder key should be used.
cmd, _ = clitest.New(t, cmdArgs...)
cmd.SetOut(pty.Output())
cmd.SetErr(pty.Output())
err = cmd.ExecuteContext(ctx)
require.NoError(t, err)
select {
case key := <-authkey:
require.Equal(t, coderPubkey, key)
case <-ctx.Done():
t.Fatal("timeout waiting for auth")
}
})
}
+146
View File
@@ -0,0 +1,146 @@
package cli
import (
"fmt"
"strings"
"time"
"github.com/google/uuid"
"github.com/spf13/cobra"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/autobuild/schedule"
"github.com/coder/coder/coderd/util/ptr"
"github.com/coder/coder/codersdk"
)
type workspaceListRow struct {
Workspace string `table:"workspace"`
Template string `table:"template"`
Status string `table:"status"`
LastBuilt string `table:"last built"`
Outdated bool `table:"outdated"`
StartsAt string `table:"starts at"`
StopsAfter string `table:"stops after"`
}
func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]codersdk.User, workspace codersdk.Workspace) workspaceListRow {
status := codersdk.WorkspaceDisplayStatus(workspace.LatestBuild.Job.Status, workspace.LatestBuild.Transition)
lastBuilt := now.UTC().Sub(workspace.LatestBuild.Job.CreatedAt).Truncate(time.Second)
autostartDisplay := "-"
if !ptr.NilOrEmpty(workspace.AutostartSchedule) {
if sched, err := schedule.Weekly(*workspace.AutostartSchedule); err == nil {
autostartDisplay = fmt.Sprintf("%s %s (%s)", sched.Time(), sched.DaysOfWeek(), sched.Location())
}
}
autostopDisplay := "-"
if !ptr.NilOrZero(workspace.TTLMillis) {
dur := time.Duration(*workspace.TTLMillis) * time.Millisecond
autostopDisplay = durationDisplay(dur)
if !workspace.LatestBuild.Deadline.IsZero() && workspace.LatestBuild.Deadline.Time.After(now) && status == "Running" {
remaining := time.Until(workspace.LatestBuild.Deadline.Time)
autostopDisplay = fmt.Sprintf("%s (%s)", autostopDisplay, relative(remaining))
}
}
user := usersByID[workspace.OwnerID]
return workspaceListRow{
Workspace: user.Username + "/" + workspace.Name,
Template: workspace.TemplateName,
Status: status,
LastBuilt: durationDisplay(lastBuilt),
Outdated: workspace.Outdated,
StartsAt: autostartDisplay,
StopsAfter: autostopDisplay,
}
}
func list() *cobra.Command {
var (
all bool
columns []string
defaultQuery = "owner:me"
searchQuery string
me bool
displayWorkspaces []workspaceListRow
)
cmd := &cobra.Command{
Annotations: workspaceCommand,
Use: "list",
Short: "List workspaces",
Aliases: []string{"ls"},
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := CreateClient(cmd)
if err != nil {
return err
}
filter := codersdk.WorkspaceFilter{
FilterQuery: searchQuery,
}
if all && searchQuery == defaultQuery {
filter.FilterQuery = ""
}
if me {
myUser, err := client.User(cmd.Context(), codersdk.Me)
if err != nil {
return err
}
filter.Owner = myUser.Username
}
res, err := client.Workspaces(cmd.Context(), filter)
if err != nil {
return err
}
if len(res.Workspaces) == 0 {
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), cliui.Styles.Prompt.String()+"No workspaces found! Create one:")
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), " "+cliui.Styles.Code.Render("coder create <name>"))
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
return nil
}
userRes, err := client.Users(cmd.Context(), codersdk.UsersRequest{})
if err != nil {
return err
}
usersByID := map[uuid.UUID]codersdk.User{}
for _, user := range userRes.Users {
usersByID[user.ID] = user
}
now := time.Now()
displayWorkspaces = make([]workspaceListRow, len(res.Workspaces))
for i, workspace := range res.Workspaces {
displayWorkspaces[i] = workspaceListRowFromWorkspace(now, usersByID, workspace)
}
out, err := cliui.DisplayTable(displayWorkspaces, "workspace", columns)
if err != nil {
return err
}
_, err = fmt.Fprintln(cmd.OutOrStdout(), out)
return err
},
}
availColumns, err := cliui.TableHeaders(displayWorkspaces)
if err != nil {
panic(err)
}
columnString := strings.Join(availColumns[:], ", ")
cmd.Flags().BoolVarP(&all, "all", "a", false,
"Specifies whether all workspaces will be listed or not.")
cmd.Flags().StringArrayVarP(&columns, "column", "c", nil,
fmt.Sprintf("Specify a column to filter in the table. Available columns are: %v", columnString))
cmd.Flags().StringVar(&searchQuery, "search", defaultQuery, "Search for a workspace with a query.")
return cmd
}
+45
View File
@@ -0,0 +1,45 @@
package cli_test
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/pty/ptytest"
"github.com/coder/coder/testutil"
)
func TestList(t *testing.T) {
t.Parallel()
t.Run("Single", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
cmd, root := clitest.New(t, "ls")
clitest.SetupConfig(t, client, root)
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancelFunc()
done := make(chan any)
go func() {
errC := cmd.ExecuteContext(ctx)
assert.NoError(t, errC)
close(done)
}()
pty.ExpectMatch(workspace.Name)
pty.ExpectMatch("Started")
cancelFunc()
<-done
})
}
+169 -83
View File
@@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"os/user"
"path"
"runtime"
"strings"
@@ -16,6 +17,7 @@ import (
"github.com/spf13/cobra"
"golang.org/x/xerrors"
"github.com/coder/coder/cli/cliflag"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/codersdk"
)
@@ -36,11 +38,29 @@ func init() {
}
func login() *cobra.Command {
return &cobra.Command{
Use: "login <url>",
Args: cobra.ExactArgs(1),
const firstUserTrialEnv = "CODER_FIRST_USER_TRIAL"
var (
email string
username string
password string
trial bool
)
cmd := &cobra.Command{
Use: "login <url>",
Short: "Authenticate with Coder deployment",
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
rawURL := args[0]
rawURL := ""
if len(args) == 0 {
var err error
rawURL, err = cmd.Flags().GetString(varURL)
if err != nil {
return xerrors.Errorf("get global url flag")
}
} else {
rawURL = args[0]
}
if !strings.HasPrefix(rawURL, "http://") && !strings.HasPrefix(rawURL, "https://") {
scheme := "https"
@@ -58,71 +78,116 @@ func login() *cobra.Command {
serverURL.Scheme = "https"
}
client := codersdk.New(serverURL)
client, err := createUnauthenticatedClient(cmd, serverURL)
if err != nil {
return err
}
// Try to check the version of the server prior to logging in.
// It may be useful to warn the user if they are trying to login
// on a very old client.
err = checkVersions(cmd, client)
if err != nil {
// Checking versions isn't a fatal error so we print a warning
// and proceed.
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), cliui.Styles.Warn.Render(err.Error()))
}
hasInitialUser, err := client.HasFirstUser(cmd.Context())
if err != nil {
return xerrors.Errorf("has initial user: %w", err)
return xerrors.Errorf("Failed to check server %q for first user, is the URL correct and is coder accessible from your browser? Error - has initial user: %w", serverURL.String(), err)
}
if !hasInitialUser {
if !isTTY(cmd) {
return xerrors.New("the initial user cannot be created in non-interactive mode. use the API")
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), caret+"Your Coder deployment hasn't been set up!\n")
_, _ = fmt.Fprintf(cmd.OutOrStdout(), Caret+"Your Coder deployment hasn't been set up!\n")
_, err := cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Would you like to create the first user?",
Default: "yes",
IsConfirm: true,
})
if errors.Is(err, cliui.Canceled) {
return nil
}
if err != nil {
return err
}
currentUser, err := user.Current()
if err != nil {
return xerrors.Errorf("get current user: %w", err)
}
username, err := cliui.Prompt(cmd, cliui.PromptOptions{
Text: "What " + cliui.Styles.Field.Render("username") + " would you like?",
Default: currentUser.Username,
})
if errors.Is(err, cliui.Canceled) {
return nil
}
if err != nil {
return xerrors.Errorf("pick username prompt: %w", err)
}
email, err := cliui.Prompt(cmd, cliui.PromptOptions{
Text: "What's your " + cliui.Styles.Field.Render("email") + "?",
Validate: func(s string) error {
err := validator.New().Var(s, "email")
if err != nil {
return xerrors.New("That's not a valid email address!")
}
if username == "" {
if !isTTY(cmd) {
return xerrors.New("the initial user cannot be created in non-interactive mode. use the API")
}
_, err := cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Would you like to create the first user?",
Default: cliui.ConfirmYes,
IsConfirm: true,
})
if errors.Is(err, cliui.Canceled) {
return nil
}
if err != nil {
return err
},
})
if err != nil {
return xerrors.Errorf("specify email prompt: %w", err)
}
currentUser, err := user.Current()
if err != nil {
return xerrors.Errorf("get current user: %w", err)
}
username, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: "What " + cliui.Styles.Field.Render("username") + " would you like?",
Default: currentUser.Username,
})
if errors.Is(err, cliui.Canceled) {
return nil
}
if err != nil {
return xerrors.Errorf("pick username prompt: %w", err)
}
}
password, err := cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Enter a " + cliui.Styles.Field.Render("password") + ":",
Secret: true,
Validate: cliui.ValidateNotEmpty,
})
if err != nil {
return xerrors.Errorf("specify password prompt: %w", err)
if email == "" {
email, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: "What's your " + cliui.Styles.Field.Render("email") + "?",
Validate: func(s string) error {
err := validator.New().Var(s, "email")
if err != nil {
return xerrors.New("That's not a valid email address!")
}
return err
},
})
if err != nil {
return xerrors.Errorf("specify email prompt: %w", err)
}
}
if password == "" {
var matching bool
for !matching {
password, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Enter a " + cliui.Styles.Field.Render("password") + ":",
Secret: true,
Validate: cliui.ValidateNotEmpty,
})
if err != nil {
return xerrors.Errorf("specify password prompt: %w", err)
}
confirm, err := cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Confirm " + cliui.Styles.Field.Render("password") + ":",
Secret: true,
})
if err != nil {
return xerrors.Errorf("confirm password prompt: %w", err)
}
matching = confirm == password
if !matching {
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Error.Render("Passwords do not match"))
}
}
}
if !cmd.Flags().Changed("first-user-trial") && os.Getenv(firstUserTrialEnv) == "" {
v, _ := cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Start a 30-day trial of Enterprise?",
IsConfirm: true,
Default: "yes",
})
trial = v == "yes" || v == "y"
}
_, err = client.CreateFirstUser(cmd.Context(), codersdk.CreateFirstUserRequest{
Email: email,
Username: username,
Organization: username,
Password: password,
Email: email,
Username: username,
Password: password,
Trial: trial,
})
if err != nil {
return xerrors.Errorf("create initial user: %w", err)
@@ -150,37 +215,42 @@ func login() *cobra.Command {
cliui.Styles.Paragraph.Render(fmt.Sprintf("Welcome to Coder, %s! You're authenticated.", cliui.Styles.Keyword.Render(username)))+"\n")
_, _ = fmt.Fprintf(cmd.OutOrStdout(),
cliui.Styles.Paragraph.Render("Get started by creating a project: "+cliui.Styles.Code.Render("coder projects create"))+"\n")
cliui.Styles.Paragraph.Render("Get started by creating a template: "+cliui.Styles.Code.Render("coder templates init"))+"\n")
return nil
}
authURL := *serverURL
authURL.Path = serverURL.Path + "/cli-auth"
if err := openURL(cmd, authURL.String()); err != nil {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Open the following in your browser:\n\n\t%s\n\n", authURL.String())
} else {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Your browser has been opened to visit:\n\n\t%s\n\n", authURL.String())
}
sessionToken, _ := cmd.Flags().GetString(varToken)
if sessionToken == "" {
authURL := *serverURL
// Don't use filepath.Join, we don't want to use the os separator
// for a url.
authURL.Path = path.Join(serverURL.Path, "/cli-auth")
if err := openURL(cmd, authURL.String()); err != nil {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Open the following in your browser:\n\n\t%s\n\n", authURL.String())
} else {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Your browser has been opened to visit:\n\n\t%s\n\n", authURL.String())
}
sessionToken, err := cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Paste your token here:",
Secret: true,
Validate: func(token string) error {
client.SessionToken = token
_, err := client.User(cmd.Context(), "me")
if err != nil {
return xerrors.New("That's not a valid token!")
}
return err
},
})
if err != nil {
return xerrors.Errorf("paste token prompt: %w", err)
sessionToken, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Paste your token here:",
Secret: true,
Validate: func(token string) error {
client.SetSessionToken(token)
_, err := client.User(cmd.Context(), codersdk.Me)
if err != nil {
return xerrors.New("That's not a valid token!")
}
return err
},
})
if err != nil {
return xerrors.Errorf("paste token prompt: %w", err)
}
}
// Login to get user data - verify it is OK before persisting
client.SessionToken = sessionToken
resp, err := client.User(cmd.Context(), "me")
client.SetSessionToken(sessionToken)
resp, err := client.User(cmd.Context(), codersdk.Me)
if err != nil {
return xerrors.Errorf("get user: %w", err)
}
@@ -195,10 +265,15 @@ func login() *cobra.Command {
return xerrors.Errorf("write server url: %w", err)
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), caret+"Welcome to Coder, %s! You're authenticated.\n", cliui.Styles.Keyword.Render(resp.Username))
_, _ = fmt.Fprintf(cmd.OutOrStdout(), Caret+"Welcome to Coder, %s! You're authenticated.\n", cliui.Styles.Keyword.Render(resp.Username))
return nil
},
}
cliflag.StringVarP(cmd.Flags(), &email, "first-user-email", "", "CODER_FIRST_USER_EMAIL", "", "Specifies an email address to use if creating the first user for the deployment.")
cliflag.StringVarP(cmd.Flags(), &username, "first-user-username", "", "CODER_FIRST_USER_USERNAME", "", "Specifies a username to use if creating the first user for the deployment.")
cliflag.StringVarP(cmd.Flags(), &password, "first-user-password", "", "CODER_FIRST_USER_PASSWORD", "", "Specifies a password to use if creating the first user for the deployment.")
cliflag.BoolVarP(cmd.Flags(), &trial, "first-user-trial", "", firstUserTrialEnv, false, "Specifies whether a trial license should be provisioned for the Coder deployment or not.")
return cmd
}
// isWSL determines if coder-cli is running within Windows Subsystem for Linux
@@ -232,5 +307,16 @@ func openURL(cmd *cobra.Command, urlToOpen string) error {
return exec.Command("cmd.exe", "/c", "start", strings.ReplaceAll(urlToOpen, "&", "^&")).Start()
}
browserEnv := os.Getenv("BROWSER")
if browserEnv != "" {
browserSh := fmt.Sprintf("%s '%s'", browserEnv, urlToOpen)
cmd := exec.CommandContext(cmd.Context(), "sh", "-c", browserSh)
out, err := cmd.CombinedOutput()
if err != nil {
return xerrors.Errorf("failed to run %v (out: %q): %w", cmd.Args, out, err)
}
return nil
}
return browser.OpenURL(urlToOpen)
}
+128 -4
View File
@@ -2,11 +2,14 @@ package cli_test
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/cli/cliui"
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/pty/ptytest"
)
@@ -21,6 +24,15 @@ func TestLogin(t *testing.T) {
require.Error(t, err)
})
t.Run("InitialUserBadLoginURL", func(t *testing.T) {
t.Parallel()
badLoginURL := "https://fcca2077f06e68aaf9"
root, _ := clitest.New(t, "login", badLoginURL)
err := root.Execute()
errMsg := fmt.Sprintf("Failed to check server %q for first user, is the URL correct and is coder accessible from your browser?", badLoginURL)
require.ErrorContains(t, err, errMsg)
})
t.Run("InitialUserTTY", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
@@ -35,7 +47,7 @@ func TestLogin(t *testing.T) {
go func() {
defer close(doneChan)
err := root.Execute()
require.NoError(t, err)
assert.NoError(t, err)
}()
matches := []string{
@@ -43,6 +55,8 @@ func TestLogin(t *testing.T) {
"username", "testuser",
"email", "user@coder.com",
"password", "password",
"password", "password", // Confirm.
"trial", "yes",
}
for i := 0; i < len(matches); i += 2 {
match := matches[i]
@@ -54,6 +68,104 @@ func TestLogin(t *testing.T) {
<-doneChan
})
t.Run("InitialUserTTYFlag", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
// The --force-tty flag is required on Windows, because the `isatty` library does not
// accurately detect Windows ptys when they are not attached to a process:
// https://github.com/mattn/go-isatty/issues/59
doneChan := make(chan struct{})
root, _ := clitest.New(t, "--url", client.URL.String(), "login", "--force-tty")
pty := ptytest.New(t)
root.SetIn(pty.Input())
root.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := root.Execute()
assert.NoError(t, err)
}()
matches := []string{
"first user?", "yes",
"username", "testuser",
"email", "user@coder.com",
"password", "password",
"password", "password", // Confirm.
"trial", "yes",
}
for i := 0; i < len(matches); i += 2 {
match := matches[i]
value := matches[i+1]
pty.ExpectMatch(match)
pty.WriteLine(value)
}
pty.ExpectMatch("Welcome to Coder")
<-doneChan
})
t.Run("InitialUserFlags", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
doneChan := make(chan struct{})
root, _ := clitest.New(t, "login", client.URL.String(), "--first-user-username", "testuser", "--first-user-email", "user@coder.com", "--first-user-password", "password", "--first-user-trial")
pty := ptytest.New(t)
root.SetIn(pty.Input())
root.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := root.Execute()
assert.NoError(t, err)
}()
pty.ExpectMatch("Welcome to Coder")
<-doneChan
})
t.Run("InitialUserTTYConfirmPasswordFailAndReprompt", func(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
client := coderdtest.New(t, nil)
// The --force-tty flag is required on Windows, because the `isatty` library does not
// accurately detect Windows ptys when they are not attached to a process:
// https://github.com/mattn/go-isatty/issues/59
doneChan := make(chan struct{})
root, _ := clitest.New(t, "login", "--force-tty", client.URL.String())
pty := ptytest.New(t)
root.SetIn(pty.Input())
root.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := root.ExecuteContext(ctx)
assert.NoError(t, err)
}()
matches := []string{
"first user?", "yes",
"username", "testuser",
"email", "user@coder.com",
"password", "mypass",
"password", "wrongpass", // Confirm.
}
for i := 0; i < len(matches); i += 2 {
match := matches[i]
value := matches[i+1]
pty.ExpectMatch(match)
pty.WriteLine(value)
}
// Validate that we reprompt for matching passwords.
pty.ExpectMatch("Passwords do not match")
pty.ExpectMatch("Enter a " + cliui.Styles.Field.Render("password"))
pty.WriteLine("pass")
pty.ExpectMatch("Confirm")
pty.WriteLine("pass")
pty.ExpectMatch("trial")
pty.WriteLine("yes")
pty.ExpectMatch("Welcome to Coder")
<-doneChan
})
t.Run("ExistingUserValidTokenTTY", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
@@ -67,11 +179,11 @@ func TestLogin(t *testing.T) {
go func() {
defer close(doneChan)
err := root.Execute()
require.NoError(t, err)
assert.NoError(t, err)
}()
pty.ExpectMatch("Paste your token here:")
pty.WriteLine(client.SessionToken)
pty.WriteLine(client.SessionToken())
pty.ExpectMatch("Welcome to Coder")
<-doneChan
})
@@ -92,7 +204,7 @@ func TestLogin(t *testing.T) {
defer close(doneChan)
err := root.ExecuteContext(ctx)
// An error is expected in this case, since the login wasn't successful:
require.Error(t, err)
assert.Error(t, err)
}()
pty.ExpectMatch("Paste your token here:")
@@ -101,4 +213,16 @@ func TestLogin(t *testing.T) {
cancelFunc()
<-doneChan
})
t.Run("TokenFlag", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
coderdtest.CreateFirstUser(t, client)
root, cfg := clitest.New(t, "login", client.URL.String(), "--token", client.SessionToken())
err := root.Execute()
require.NoError(t, err)
sessionFile, err := cfg.Session().Read()
require.NoError(t, err)
require.Equal(t, client.SessionToken(), sessionFile)
})
}
+77
View File
@@ -0,0 +1,77 @@
package cli
import (
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
"golang.org/x/xerrors"
"github.com/coder/coder/cli/cliui"
)
func logout() *cobra.Command {
cmd := &cobra.Command{
Use: "logout",
Short: "Unauthenticate your local session",
RunE: func(cmd *cobra.Command, args []string) error {
client, err := CreateClient(cmd)
if err != nil {
return err
}
var errors []error
config := createConfig(cmd)
_, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: "Are you sure you want to log out?",
IsConfirm: true,
Default: cliui.ConfirmYes,
})
if err != nil {
return err
}
err = client.Logout(cmd.Context())
if err != nil {
errors = append(errors, xerrors.Errorf("logout api: %w", err))
}
err = config.URL().Delete()
// Only throw error if the URL configuration file is present,
// otherwise the user is already logged out, and we proceed
if err != nil && !os.IsNotExist(err) {
errors = append(errors, xerrors.Errorf("remove URL file: %w", err))
}
err = config.Session().Delete()
// Only throw error if the session configuration file is present,
// otherwise the user is already logged out, and we proceed
if err != nil && !os.IsNotExist(err) {
errors = append(errors, xerrors.Errorf("remove session file: %w", err))
}
err = config.Organization().Delete()
// If the organization configuration file is absent, we still proceed
if err != nil && !os.IsNotExist(err) {
errors = append(errors, xerrors.Errorf("remove organization file: %w", err))
}
if len(errors) > 0 {
var errorStringBuilder strings.Builder
for _, err := range errors {
_, _ = fmt.Fprint(&errorStringBuilder, "\t"+err.Error()+"\n")
}
errorString := strings.TrimRight(errorStringBuilder.String(), "\n")
return xerrors.New("Failed to log out.\n" + errorString)
}
_, _ = fmt.Fprintf(cmd.OutOrStdout(), Caret+"You are no longer logged in. You can log in using 'coder login <url>'.\n")
return nil
},
}
cliui.AllowSkipPrompt(cmd)
return cmd
}

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