Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: list templates returns non-deprecated templates by default #17747

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ssncferreira
Copy link

Description

Modifies the behaviour of the "list templates" API endpoints to return non-deprecated templates by default. Users can still query for deprecated templates by specifying the deprecated=true query parameter.

Note: The deprecation feature is an enterprise-level feature

Affected Endpoints

  • /api/v2/organizations/{organization}/templates
  • /api/v2/templates

Fixes #17565

Copy link

github-actions bot commented May 9, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ssncferreira ssncferreira changed the title Fix: list templates returns non-deprecated templates by default fix: list templates returns non-deprecated templates by default May 9, 2025
@ssncferreira
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

cdrci2 added a commit to coder/cla that referenced this pull request May 9, 2025
Copy link

@cstyan cstyan left a comment

Choose a reason for hiding this comment

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

Some style/organization comments, but I'm not sure about all the details of the preferred style for Go and tests here so curious what others have to say.

@@ -13021,7 +13021,7 @@ func (q *FakeQuerier) GetAuthorizedTemplates(ctx context.Context, arg database.G
if arg.ExactName != "" && !strings.EqualFold(template.Name, arg.ExactName) {
continue
}
if arg.Deprecated.Valid && arg.Deprecated.Bool == (template.Deprecated != "") {
if arg.Deprecated.Valid && arg.Deprecated.Bool != (template.Deprecated != "") {
Copy link

Choose a reason for hiding this comment

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

I think a comment here might be useful as well. Initially I wanted to suggest renaming arg.Deprecated but I imagine that's a bigger change to roll out here. It's just not very nice to read this as something like

if arg.Deprecated.Valid && arg.IgnoreDeprecated && template.IsDeprecated

potentially the template struct could be refactored to have IsDeprecated and DeprecatedMessage as opposed to just having Deprecated message whose value being "some string" means the template is deprecated. Alternatively, the template could have a function IsDeprecated?

@@ -873,6 +873,241 @@ func TestTemplates(t *testing.T) {
require.Equal(t, tmpl.OrganizationName, org2.Name, "organization name on template")
}
})

t.Run("ListEmpty", func(t *testing.T) {
Copy link

Choose a reason for hiding this comment

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

can this new set of tests be table driven?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Coder recommends deprecated templates to users
2 participants