Thanks to visit codestin.com
Credit goes to github.com

Skip to content

coderd: autostart: codersdk, http api, database plumbing #879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 7, 2022

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Apr 5, 2022

  • database schema for autostart and associated plumbing
  • http route for PUT `/autostart
  • handler for putWorkspaceAutostart
  • codersdk UpdateWorkspaceAutostart method
  • corresponding unit tests

🌮 to @vapurrmaid on the help with TDD!

NOTE: I also added the autostop-related database stuff before it was deemed better to submit smaller more integrated PRs. If this is a blocker, I can remove it from this PR and add it in the next. But it will likely be used Very Soon.

ALSO NOTE: I'm not using "fixes" here because the issues I opened are "horizontally" aligned, and not "vertically".

@johnstcn johnstcn self-assigned this Apr 5, 2022
@codecov
Copy link

codecov bot commented Apr 5, 2022

Codecov Report

Merging #879 (be0e6f3) into main (fe23dcd) will increase coverage by 0.21%.
The diff coverage is 77.98%.

@@            Coverage Diff             @@
##             main     #879      +/-   ##
==========================================
+ Coverage   65.77%   65.98%   +0.21%     
==========================================
  Files         216      216              
  Lines       13734    13834     +100     
  Branches      103      103              
==========================================
+ Hits         9033     9129      +96     
  Misses       3782     3782              
- Partials      919      923       +4     
Flag Coverage Δ
unittest-go- 65.67% <77.98%> (+0.12%) ⬆️
unittest-go-macos-latest 52.86% <63.30%> (-0.14%) ⬇️
unittest-go-ubuntu-latest 55.47% <63.30%> (+0.12%) ⬆️
unittest-go-windows-2022 52.24% <63.30%> (+0.13%) ⬆️
unittest-js 58.87% <ø> (ø)
Impacted Files Coverage Δ
coderd/workspaces.go 56.19% <72.30%> (+2.52%) ⬆️
codersdk/workspaces.go 63.63% <72.72%> (+4.54%) ⬆️
coderd/coderd.go 96.87% <100.00%> (+0.12%) ⬆️
coderd/database/queries.sql.go 83.97% <100.00%> (+0.41%) ⬆️
provisionersdk/transport.go 78.72% <0.00%> (-6.39%) ⬇️
coderd/workspaceresources.go 54.87% <0.00%> (-5.70%) ⬇️
provisioner/echo/serve.go 56.80% <0.00%> (-2.41%) ⬇️
peer/channel.go 85.38% <0.00%> (-0.59%) ⬇️
provisionerd/provisionerd.go 80.76% <0.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe23dcd...be0e6f3. Read the comment docs.

Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the to-dos I'm going to leave in commented state, but all looks great so far! Just one extremely minor nit.

)

err := client.UpdateWorkspaceAutostart(ctx, wsid, req)
require.EqualError(t, err, fmt.Sprintf("status code 404: workspace %q does not exist", wsid), "unexpected error")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We could assert to codersdk.Error here to check the status code!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I ended up needing to squelch a linter error when trying to use errors.As on codersdk.Error.
This is the sort of thing I ended up with: https://go.dev/play/p/NHTmnYWan6g

@johnstcn johnstcn force-pushed the cj/autostart_dbschema branch from a17d3a1 to 316501d Compare April 6, 2022 20:05
greyscaled added a commit that referenced this pull request Apr 13, 2022
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.
greyscaled added a commit that referenced this pull request Apr 14, 2022
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.
@misskniss misskniss added this to the V2 Beta milestone May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants