Skip to content

feat(cli): add provisioner job cancel command #16252

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 6 commits into from
Jan 27, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve getProvisionerJobs docs
  • Loading branch information
mafredri committed Jan 24, 2025
commit f217a5edbef1723a48c06413466a246fc96669bb
9 changes: 6 additions & 3 deletions coderd/provisionerjobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (api *API) provisionerJob(rw http.ResponseWriter, r *http.Request) {
return
}

jobs, ok := api.getProvisionerJobs(rw, r, []uuid.UUID{jobID})
jobs, ok := api.handleAuthAndFetchProvisionerJobs(rw, r, []uuid.UUID{jobID})
if !ok {
return
}
Expand Down Expand Up @@ -78,15 +78,18 @@ func (api *API) provisionerJob(rw http.ResponseWriter, r *http.Request) {
func (api *API) provisionerJobs(rw http.ResponseWriter, r *http.Request) {
ctx := r.Context()

jobs, ok := api.getProvisionerJobs(rw, r, nil)
jobs, ok := api.handleAuthAndFetchProvisionerJobs(rw, r, nil)
if !ok {
return
}

httpapi.Write(ctx, rw, http.StatusOK, db2sdk.List(jobs, convertProvisionerJobWithQueuePosition))
}

func (api *API) getProvisionerJobs(rw http.ResponseWriter, r *http.Request, ids []uuid.UUID) ([]database.GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisionerRow, bool) {
// handleAuthAndFetchProvisionerJobs is an internal method shared by
// provisionerJob and provisionerJobs. If ok is false the caller should
// return immediately because the response has already been written.
func (api *API) handleAuthAndFetchProvisionerJobs(rw http.ResponseWriter, r *http.Request, ids []uuid.UUID) (_ []database.GetProvisionerJobsByOrganizationAndStatusWithQueuePositionAndProvisionerRow, ok bool) {
ctx := r.Context()
org := httpmw.OrganizationParam(r)

Expand Down
Loading