Skip to content

Commit e3591c2

Browse files
committed
Merge branch 'main' of github.com:/coder/coder into dk/debounce-metrics-collection
2 parents fcbfb7f + eb9a651 commit e3591c2

File tree

19 files changed

+378
-53
lines changed

19 files changed

+378
-53
lines changed

coderd/apidoc/docs.go

Lines changed: 2 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: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbmem/dbmem.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,12 @@ func (q *FakeQuerier) getProvisionerJobsByIDsWithQueuePositionLockedGlobalQueue(
13801380
return jobs, nil
13811381
}
13821382

1383+
// isDeprecated returns true if the template is deprecated.
1384+
// A template is considered deprecated when it has a deprecation message.
1385+
func isDeprecated(template database.Template) bool {
1386+
return template.Deprecated != ""
1387+
}
1388+
13831389
func (*FakeQuerier) AcquireLock(_ context.Context, _ int64) error {
13841390
return xerrors.New("AcquireLock must only be called within a transaction")
13851391
}
@@ -13023,7 +13029,17 @@ func (q *FakeQuerier) GetAuthorizedTemplates(ctx context.Context, arg database.G
1302313029
if arg.ExactName != "" && !strings.EqualFold(template.Name, arg.ExactName) {
1302413030
continue
1302513031
}
13026-
if arg.Deprecated.Valid && arg.Deprecated.Bool == (template.Deprecated != "") {
13032+
// Filters templates based on the search query filter 'Deprecated' status
13033+
// Matching SQL logic:
13034+
// -- Filter by deprecated
13035+
// AND CASE
13036+
// WHEN :deprecated IS NOT NULL THEN
13037+
// CASE
13038+
// WHEN :deprecated THEN deprecated != ''
13039+
// ELSE deprecated = ''
13040+
// END
13041+
// ELSE true
13042+
if arg.Deprecated.Valid && arg.Deprecated.Bool != isDeprecated(template) {
1302713043
continue
1302813044
}
1302913045
if arg.FuzzyName != "" {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
UPDATE notification_templates
2+
SET name = 'Test Notification'
3+
WHERE id = 'c425f63e-716a-4bf4-ae24-78348f706c3f';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
UPDATE notification_templates
2+
SET name = 'Troubleshooting Notification'
3+
WHERE id = 'c425f63e-716a-4bf4-ae24-78348f706c3f';

coderd/notifications/testdata/rendered-templates/webhook/TemplateTestNotification.json.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"msg_id": "00000000-0000-0000-0000-000000000000",
44
"payload": {
55
"_version": "1.2",
6-
"notification_name": "Test Notification",
6+
"notification_name": "Troubleshooting Notification",
77
"notification_template_id": "00000000-0000-0000-0000-000000000000",
88
"user_id": "00000000-0000-0000-0000-000000000000",
99
"user_email": "bobby@coder.com",

coderd/templates.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ func (api *API) postTemplateByOrganization(rw http.ResponseWriter, r *http.Reque
487487
}
488488

489489
// @Summary Get templates by organization
490+
// @Description Returns a list of templates for the specified organization.
491+
// @Description By default, only non-deprecated templates are returned.
492+
// @Description To include deprecated templates, specify `deprecated:true` in the search query.
490493
// @ID get-templates-by-organization
491494
// @Security CoderSessionToken
492495
// @Produce json
@@ -506,6 +509,9 @@ func (api *API) templatesByOrganization() http.HandlerFunc {
506509
}
507510

508511
// @Summary Get all templates
512+
// @Description Returns a list of templates.
513+
// @Description By default, only non-deprecated templates are returned.
514+
// @Description To include deprecated templates, specify `deprecated:true` in the search query.
509515
// @ID get-all-templates
510516
// @Security CoderSessionToken
511517
// @Produce json
@@ -540,6 +546,14 @@ func (api *API) fetchTemplates(mutate func(r *http.Request, arg *database.GetTem
540546
mutate(r, &args)
541547
}
542548

549+
// By default, deprecated templates are excluded unless explicitly requested
550+
if !args.Deprecated.Valid {
551+
args.Deprecated = sql.NullBool{
552+
Bool: false,
553+
Valid: true,
554+
}
555+
}
556+
543557
// Filter templates based on rbac permissions
544558
templates, err := api.Database.GetAuthorizedTemplates(ctx, args, prepared)
545559
if errors.Is(err, sql.ErrNoRows) {

0 commit comments

Comments
 (0)