Skip to content

feat: cli: add autostart and autostop commands #922

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 2 commits into from
Apr 8, 2022
Merged

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Apr 8, 2022

This PR adds the CLI commands autostart and autostop.
These allow enabling and disabling workspace autostart and autostop, respectively.
Example usage:

# Sets autostart schedule to 12:34 every day Ireland time
coder workspaces autostart enable my-workspace 'CRON_TZ=Europe/Dublin 34 12 *'
# Stops workspace from automatically stopping
coder workspaces autostop disable my-workspace

Subtasks

  • add autostart (enable|disable) CLI method with corresponding unit tests
  • add autostop (enable|disable) CLI method with coresponding unit tests

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

codecov bot commented Apr 8, 2022

Codecov Report

Merging #922 (027d47d) into main (38f0742) will increase coverage by 0.04%.
The diff coverage is 81.25%.

@@            Coverage Diff             @@
##             main     #922      +/-   ##
==========================================
+ Coverage   65.78%   65.82%   +0.04%     
==========================================
  Files         226      228       +2     
  Lines       13991    14119     +128     
  Branches      105      105              
==========================================
+ Hits         9204     9294      +90     
- Misses       3848     3876      +28     
- Partials      939      949      +10     
Flag Coverage Δ
unittest-go-macos-latest 53.06% <81.25%> (+0.09%) ⬆️
unittest-go-postgres- 65.72% <81.25%> (+0.07%) ⬆️
unittest-go-ubuntu-latest 55.70% <81.25%> (+0.45%) ⬆️
unittest-go-windows-2022 52.49% <81.25%> (+0.33%) ⬆️
unittest-js 58.25% <ø> (ø)
Impacted Files Coverage Δ
cli/workspaceautostart.go 80.95% <80.95%> (ø)
cli/workspaceautostop.go 80.95% <80.95%> (ø)
cli/workspaces.go 54.54% <100.00%> (+2.93%) ⬆️
codersdk/provisionerdaemons.go 58.46% <0.00%> (-6.16%) ⬇️
coderd/workspaceresources.go 57.72% <0.00%> (-3.26%) ⬇️
peer/conn.go 78.17% <0.00%> (-2.54%) ⬇️
peer/channel.go 83.04% <0.00%> (-0.59%) ⬇️
coderd/provisionerdaemons.go 62.05% <0.00%> (-0.51%) ⬇️
provisionerd/provisionerd.go 80.32% <0.00%> (-0.45%) ⬇️
provisioner/echo/serve.go 56.80% <0.00%> (+2.39%) ⬆️
... and 3 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 38f0742...027d47d. Read the comment docs.

@johnstcn johnstcn requested review from Emyrk and greyscaled April 8, 2022 14:25
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.

Great code, tests, and decomposition! 'tis coming together nicely.

Should we hide these commands for now? I know a bunch of the commands don't work properly right now, but I'd hate to add even more to that list (by work properly I mean that since we don't have scheduling in yet, this wouldn't quite work).


func workspaceAutostart() *cobra.Command {
autostartCmd := &cobra.Command{
Use: "autostart",
Copy link
Member

Choose a reason for hiding this comment

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

We should add a description of the autostart feature. Doesn't have to be exhaustive for now, just something that speaks to the use-case a bit.


func workspaceAutostop() *cobra.Command {
autostopCmd := &cobra.Command{
Use: "autostop",
Copy link
Member

Choose a reason for hiding this comment

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

A little helper text would be great here! Same comment on autostart.

Copy link
Contributor

@greyscaled greyscaled left a comment

Choose a reason for hiding this comment

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

This code is squeaky clean!

@johnstcn
Copy link
Member Author

johnstcn commented Apr 8, 2022

Should we hide these commands for now?

Ah yeah, good call.

@johnstcn johnstcn enabled auto-merge (squash) April 8, 2022 16:22
@johnstcn johnstcn merged commit 53db178 into main Apr 8, 2022
@johnstcn johnstcn deleted the cj/cli-autostart branch April 8, 2022 16:29
@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