Skip to content

chore: return template data for provisioner daemons #16514

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 10 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion cli/testdata/coder_provisioner_list_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OPTIONS:
-O, --org string, $CODER_ORGANIZATION
Select which organization (uuid or name) to use.

-c, --column [id|organization id|created at|last seen at|name|version|api version|tags|key name|status|current job id|current job status|previous job id|previous job status|organization] (default: name,organization,status,key name,created at,last seen at,version,tags)
-c, --column [id|organization id|created at|last seen at|name|version|api version|tags|key name|status|current job id|current job status|current job template name|current job template icon|current job template display name|previous job id|previous job status|previous job template name|previous job template icon|previous job template display name|organization] (default: name,organization,status,key name,created at,last seen at,version,tags)
Columns to display in table output.

-o, --output table|json (default: table)
Expand Down
5 changes: 4 additions & 1 deletion cli/testdata/coder_provisioner_list_--output_json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
"current_job": null,
"previous_job": {
"id": "======[workspace build job ID]======",
"status": "succeeded"
"status": "succeeded",
"template_name": "",
"template_icon": "",
"template_display_name": ""
},
"organization_name": "Coder"
}
Expand Down
9 changes: 9 additions & 0 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 21 additions & 8 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion coderd/database/queries/provisionerdaemons.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ SELECT
current_job.id AS current_job_id,
current_job.job_status AS current_job_status,
previous_job.id AS previous_job_id,
previous_job.job_status AS previous_job_status
previous_job.job_status AS previous_job_status,
COALESCE(tmpl.name, ''::text) AS current_job_template_name,
COALESCE(tmpl.display_name, ''::text) AS current_job_template_display_name,
COALESCE(tmpl.icon, ''::text) AS current_job_template_icon
FROM
provisioner_daemons pd
JOIN
Expand All @@ -69,6 +72,10 @@ LEFT JOIN
LIMIT 1
)
)
LEFT JOIN
template_versions version ON version.id = (current_job.input->>'template_version_id')::uuid
LEFT JOIN
templates tmpl ON tmpl.id = version.template_id
WHERE
pd.organization_id = @organization_id::uuid
AND (COALESCE(array_length(@ids::uuid[], 1), 0) = 0 OR pd.id = ANY(@ids::uuid[]))
Expand Down
7 changes: 5 additions & 2 deletions coderd/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ func (api *API) provisionerDaemons(rw http.ResponseWriter, r *http.Request) {
var currentJob, previousJob *codersdk.ProvisionerDaemonJob
if dbDaemon.CurrentJobID.Valid {
currentJob = &codersdk.ProvisionerDaemonJob{
ID: dbDaemon.CurrentJobID.UUID,
Status: codersdk.ProvisionerJobStatus(dbDaemon.CurrentJobStatus.ProvisionerJobStatus),
ID: dbDaemon.CurrentJobID.UUID,
Status: codersdk.ProvisionerJobStatus(dbDaemon.CurrentJobStatus.ProvisionerJobStatus),
TemplateName: dbDaemon.CurrentJobTemplateName,
TemplateIcon: dbDaemon.CurrentJobTemplateIcon,
TemplateDisplayName: dbDaemon.CurrentJobTemplateDisplayName,
}
}
if dbDaemon.PreviousJobID.Valid {
Expand Down
7 changes: 5 additions & 2 deletions codersdk/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ type ProvisionerDaemon struct {
}

type ProvisionerDaemonJob struct {
ID uuid.UUID `json:"id" format:"uuid" table:"id"`
Status ProvisionerJobStatus `json:"status" enums:"pending,running,succeeded,canceling,canceled,failed" table:"status"`
ID uuid.UUID `json:"id" format:"uuid" table:"id"`
Status ProvisionerJobStatus `json:"status" enums:"pending,running,succeeded,canceling,canceled,failed" table:"status"`
TemplateName string `json:"template_name" table:"template name"`
TemplateIcon string `json:"template_icon" table:"template icon"`
TemplateDisplayName string `json:"template_display_name" table:"template display name"`
}

// MatchedProvisioners represents the number of provisioner daemons
Expand Down
10 changes: 8 additions & 2 deletions docs/reference/api/debug.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 39 additions & 30 deletions docs/reference/api/enterprise.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading