Commit Graph

61 Commits

Author SHA1 Message Date
Marcin Tojek a7366a8b76
feat!: drop support for legacy parameters (#7663) 2023-06-02 11:16:46 +02:00
Spike Curtis cd416c86dd
refactor: workspace builds (#7541)
* refactor workspace builds

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

* make gen

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

* Remove ParameterResolver from typescript

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

* rename conversion -> database/db2sdk

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

* tests for db2sdk

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

* Tests for ParameterResolver

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

* wsbuilder tests

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

* Move parameter validation tests to richparameters_test.go

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

* Fix CI generation; rename mock->dbmock

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

* Fix test imports

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-23 12:06:33 +04:00
Marcin Tojek c000f2ec28
fix: coder_parameter fallbacks to default (#7240) 2023-04-24 09:51:34 +02:00
Mathias Fredriksson 6f06f8dadb
test: Fix test timeouts due to contexts created too early (#7242) 2023-04-21 17:32:25 +03:00
Marcin Tojek 083fc89f93
feat: accept immutable parameters when used first time (#7000)
* Backend fixes

* CLI: adjust update flow
2023-04-04 14:22:46 +02:00
Kyle Carberry a63c97b8de
chore: wrap audit logs in a mutex to fix data race (#6898)
This was seen in `main`!
2023-03-30 12:13:03 -05:00
Marcin Tojek 0ba200c2a1
feat: Enable workspace debug logging (#6838)
* feat: Enable workspace debug logging

* Fix

* Fix

* Fix

* fix

* fix

* Enable RBAC

* unit tests

* Fix

* fix

* fix

* fix

* more tests

* fix: workspacebuild_test use roles

* fix: swagger comment

* fix: ctx.Done

* fix: address PR comments

* break loop
2023-03-30 16:00:33 +02:00
Marcin Tojek a7c734c60b
feat: support list(string) as coder_parameter (#6618)
* feat: support list(string) as coder_parameter

* Fix
2023-03-16 11:07:10 +01:00
Marcin Tojek 7587850a1c
feat: import value from legacy variable to build parameter (#6556) 2023-03-14 12:02:44 +00:00
Ammar Bandukwala f05609b4da
chore: format Go more aggressively 2023-02-18 18:32:09 -06:00
Marcin Tojek b86bce8494
feat!: Validate monotonic numbers for rich parameters (#6046)
* Database changes

* protobuf

* Fix: docs

* workspaces_test

* Validation in coderd

* Fix: resources

* omitempty

* UI changes

* UI tests

* fix
2023-02-07 09:36:13 +01:00
Kyle Carberry 71a893764e
chore: remove `CreateAnotherUserWithUser` (#6068)
This was not idiomatic Go!
2023-02-06 23:48:21 +00:00
Kira Pilot 46fe59f5e7
feat: audit login (#5925)
* added migration for api key resource

* sort of working

* auditing login

* passing  the correct user id

* added and fixed tests

* gen documentation

* formatting and lint

* lint

* audit Github oauth and write tests

* audit oauth and write  tests

* added defer fn for login error auditing

* fixed test

* feat: audit logout (#5998)

* Update coderd/userauth.go

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

* fix test

* bypassing diff generation if login/logout

* lint

---------

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
2023-02-06 15:12:50 -05:00
Kyle Carberry b20cb993bd
fix: loop variable captured by func literal in parameters test (#5878)
I noticed this when adding a new parameter type. There's a test
case for an empty string that returned false for validation,
but appears like it could be true.

If there is no value for a string, then the default is used.
In this case there is no default, but that's technically fine
I believe.
2023-01-27 09:37:55 -06:00
Marcin Tojek 26c69525d1
feat: Validate workspace build parameters (#5807) 2023-01-24 14:22:00 +01:00
Marcin Tojek bbb208e29c
feat: Add CLI support for workspace build parameters (#5768)
* WIP

* WIP

* CLI: handle workspace build parameters

* fix: golintci

* Fix: dry run

* fix

* CLI: is mutable

* coderd: mutable

* fix: golanci

* fix: richParameterFile

* CLI: create unit tests

* CLI: update test

* Fix

* fix: order

* fix
2023-01-23 15:01:22 +01:00
Marcin Tojek 1b0560ceb4
feat: Expose workspace build parameters via API (#5743) 2023-01-17 16:24:45 +01:00
Marcin Tojek 6ebadabe4e
feat: Add basic support for rich parameters to coderd and provisionerd (#5710) 2023-01-17 11:22:11 +01: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
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
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
Ammar Bandukwala 95fb59696e
Refactor Provisioner to distinguish Plan and Apply (#5036) 2022-11-11 16:45:58 -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
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
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
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
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
Kyle Carberry daa34cf7b8
fix: Return deleted users when fetching workspace builds (#4441)
Fixes #4359.
2022-10-10 18:03:54 +00:00
Ammar Bandukwala eefc26c108
Hide build logs older than 30 days (#4436) 2022-10-09 20:01:18 +00:00
Garrett Delfosse 738a38d71f
chore: remove resources calls (#4344) 2022-10-03 21:01:13 +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
Kyle Carberry a7ee8b31e0
fix: Don't use StatusAbnormalClosure (#4155) 2022-09-22 18:26:05 +00:00
Mathias Fredriksson 9e12850f38
fix: Remove TestWorkspaceBuildResources/ListRunning (#4088) 2022-09-16 16:39:57 +03:00
Kyle Carberry 519d724ca4
fix: Sort resources by name (#3941)
Fixes #3489.
2022-09-08 03:16:26 +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
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
Mathias Fredriksson ccf6f4e7ed
chore: Use contexts with timeout in `coderd` tests (#3381) 2022-08-09 20:17:00 +03:00
Mathias Fredriksson 4730c589fe
chore: Use standardized test timeouts and delays (#3291) 2022-08-01 15:45:05 +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
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
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 2353687610
feat: unexpose coderdtest.NewWithAPI (#2613)
* feat: unexpose coderdtest.NewWithAPI
2022-06-27 13:50:52 -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
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
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
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
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
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
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