Skip to content

feat(cli): allow showing schedules for multiple workspaces #10596

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 7 commits into from
Nov 10, 2023

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Nov 8, 2023

Fixes #10428

  • coder list: adds information about next start / stop to available columns (not default)
  • coder schedule: show now essentially coder list with a different set of columns
  • Updates cli schedule unit tests

What this looks like:

$ build/coder_linux_amd64 list -c workspace,starts_at,starts_next,stops_after,stops_next
WORKSPACE            STARTS AT                       STARTS NEXT           STOPS AFTER  STOPS NEXT            
cian/cian-openstack                                                        1d                                 
cian/dev                                                                                                      
cian/vvuurrkk        8:55AM Mon-Fri (Europe/Dublin)  2023-11-13T08:55:00Z  1h           2023-11-10T12:59:40Z 

$ build/coder_linux_amd64 schedule show
WORKSPACE            STARTS AT                       STARTS NEXT           STOPS AFTER  STOPS NEXT            
cian/cian-openstack                                                        1d                                 
cian/dev                                                                                                      
cian/vvuurrkk        8:55AM Mon-Fri (Europe/Dublin)  2023-11-13T08:55:00Z  1h           2023-11-10T12:56:10Z  

$ build/coder_linux_amd64 schedule show cian/vvuurrkk
WORKSPACE      STARTS AT                       STARTS NEXT           STOPS AFTER  STOPS NEXT            
cian/vvuurrkk  8:55AM Mon-Fri (Europe/Dublin)  2023-11-13T08:55:00Z  1h           2023-11-10T12:56:10Z  

$ build/coder_linux_amd64 schedule start cian/dev 12:34 mon,wed,fri
WORKSPACE  STARTS AT                  STARTS NEXT           STOPS AFTER  STOPS NEXT  
cian/dev   12:34PM mon,wed,fri (UTC)  2023-11-10T12:34:00Z                           

$ build/coder_linux_amd64 schedule start cian/dev 12:34 mon,wed,fri US/Central
WORKSPACE  STARTS AT                         STARTS NEXT           STOPS AFTER  STOPS NEXT  
cian/dev   12:34PM mon,wed,fri (US/Central)  2023-11-10T18:34:00Z                           

$ build/coder_linux_amd64 schedule stop cian/dev 1h23m
WORKSPACE  STARTS AT                         STARTS NEXT           STOPS AFTER  STOPS NEXT  
cian/dev   12:34PM mon,wed,fri (US/Central)  2023-11-10T18:34:00Z  1h23m                    

$ build/coder_linux_amd64 schedule start cian/dev manual
WORKSPACE  STARTS AT  STARTS NEXT  STOPS AFTER  STOPS NEXT  
cian/dev                           1h23m                    

$ build/coder_linux_amd64 schedule stop cian/dev manual
WORKSPACE  STARTS AT  STARTS NEXT  STOPS AFTER  STOPS NEXT  
cian/dev  

@johnstcn johnstcn force-pushed the cj/cli-schedule-revamp branch 2 times, most recently from 234f0cb to 2d662e4 Compare November 9, 2023 12:54
@johnstcn johnstcn force-pushed the cj/cli-schedule-revamp branch from d9afcb6 to dd3fa2a Compare November 10, 2023 10:52
@johnstcn johnstcn marked this pull request as ready for review November 10, 2023 12:00
@johnstcn johnstcn requested review from mafredri and mtojek November 10, 2023 12:00
StartsNext: nextStartDisplay,
StopsAfter: autostopDisplay,
StopsNext: nextStopDisplay,
}
Copy link
Member

Choose a reason for hiding this comment

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

Should we include the datapoints "calculated" here in the API response instead (obviously not the formatting, but timestamps, etc). I'm thinking it'd be better if our CLI was "dumber", and it might help other API consumers too.

Copy link
Member Author

Choose a reason for hiding this comment

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

What specific datapoints do you want included?

Copy link
Member

Choose a reason for hiding this comment

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

I suppose I'm thinking of something like this:

GET /workspace/uuid
{
  ...,
  "schedule": {
    "starts_next": time,
    "stops_next": time,
	...
  },
  ...
}

Maybe more fields if it makes sense. Basically I'm thinking if we can avoid the need to call cron.Weekly, etc since a client who wants to know this information will need to be able to parse cron tabs (+ any other business logic that may be releavant).

Just an idea.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not a bad idea! Filed #10621

johnstcn and others added 2 commits November 10, 2023 12:17
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
@johnstcn johnstcn merged commit a4f1319 into main Nov 10, 2023
@johnstcn johnstcn deleted the cj/cli-schedule-revamp branch November 10, 2023 13:51
@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(cli): make schedule show cmd more useful to admins
2 participants