Skip to content

Commit e85da8b

Browse files
chore: return template data for provisioner daemons (coder#16514)
Return template data in provisioner jobs to be displayed in the provisioners page.
1 parent 3590102 commit e85da8b

15 files changed

+199
-89
lines changed

cli/testdata/coder_provisioner_list_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ OPTIONS:
1111
-O, --org string, $CODER_ORGANIZATION
1212
Select which organization (uuid or name) to use.
1313

14-
-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)
14+
-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)
1515
Columns to display in table output.
1616

1717
-o, --output table|json (default: table)

cli/testdata/coder_provisioner_list_--output_json.golden

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
"current_job": null,
2121
"previous_job": {
2222
"id": "======[workspace build job ID]======",
23-
"status": "succeeded"
23+
"status": "succeeded",
24+
"template_name": "",
25+
"template_icon": "",
26+
"template_display_name": ""
2427
},
2528
"organization_name": "Coder"
2629
}

coderd/apidoc/docs.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

Lines changed: 21 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/provisionerdaemons.sql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ SELECT
4444
current_job.id AS current_job_id,
4545
current_job.job_status AS current_job_status,
4646
previous_job.id AS previous_job_id,
47-
previous_job.job_status AS previous_job_status
47+
previous_job.job_status AS previous_job_status,
48+
COALESCE(tmpl.name, ''::text) AS current_job_template_name,
49+
COALESCE(tmpl.display_name, ''::text) AS current_job_template_display_name,
50+
COALESCE(tmpl.icon, ''::text) AS current_job_template_icon
4851
FROM
4952
provisioner_daemons pd
5053
JOIN
@@ -69,6 +72,10 @@ LEFT JOIN
6972
LIMIT 1
7073
)
7174
)
75+
LEFT JOIN
76+
template_versions version ON version.id = (current_job.input->>'template_version_id')::uuid
77+
LEFT JOIN
78+
templates tmpl ON tmpl.id = version.template_id
7279
WHERE
7380
pd.organization_id = @organization_id::uuid
7481
AND (COALESCE(array_length(@ids::uuid[], 1), 0) = 0 OR pd.id = ANY(@ids::uuid[]))

coderd/provisionerdaemons.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ func (api *API) provisionerDaemons(rw http.ResponseWriter, r *http.Request) {
5959
var currentJob, previousJob *codersdk.ProvisionerDaemonJob
6060
if dbDaemon.CurrentJobID.Valid {
6161
currentJob = &codersdk.ProvisionerDaemonJob{
62-
ID: dbDaemon.CurrentJobID.UUID,
63-
Status: codersdk.ProvisionerJobStatus(dbDaemon.CurrentJobStatus.ProvisionerJobStatus),
62+
ID: dbDaemon.CurrentJobID.UUID,
63+
Status: codersdk.ProvisionerJobStatus(dbDaemon.CurrentJobStatus.ProvisionerJobStatus),
64+
TemplateName: dbDaemon.CurrentJobTemplateName,
65+
TemplateIcon: dbDaemon.CurrentJobTemplateIcon,
66+
TemplateDisplayName: dbDaemon.CurrentJobTemplateDisplayName,
6467
}
6568
}
6669
if dbDaemon.PreviousJobID.Valid {

codersdk/provisionerdaemons.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ type ProvisionerDaemon struct {
6969
}
7070

7171
type ProvisionerDaemonJob struct {
72-
ID uuid.UUID `json:"id" format:"uuid" table:"id"`
73-
Status ProvisionerJobStatus `json:"status" enums:"pending,running,succeeded,canceling,canceled,failed" table:"status"`
72+
ID uuid.UUID `json:"id" format:"uuid" table:"id"`
73+
Status ProvisionerJobStatus `json:"status" enums:"pending,running,succeeded,canceling,canceled,failed" table:"status"`
74+
TemplateName string `json:"template_name" table:"template name"`
75+
TemplateIcon string `json:"template_icon" table:"template icon"`
76+
TemplateDisplayName string `json:"template_display_name" table:"template display name"`
7477
}
7578

7679
// MatchedProvisioners represents the number of provisioner daemons

docs/reference/api/debug.md

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/api/enterprise.md

Lines changed: 39 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)