mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add templates delete command (#1443)
This commit is contained in:
@@ -45,6 +45,13 @@ func ExtractTemplateParam(db database.Store) func(http.Handler) http.Handler {
|
||||
return
|
||||
}
|
||||
|
||||
if template.Deleted {
|
||||
httpapi.Write(rw, http.StatusNotFound, httpapi.Response{
|
||||
Message: fmt.Sprintf("template %q does not exist", templateID),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.WithValue(r.Context(), templateParamContextKey{}, template)
|
||||
chi.RouteContext(ctx).URLParams.Add("organization", template.OrganizationID.String())
|
||||
next.ServeHTTP(rw, r.WithContext(ctx))
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
// Returns a single template.
|
||||
func (api *api) template(rw http.ResponseWriter, r *http.Request) {
|
||||
template := httpmw.TemplateParam(r)
|
||||
|
||||
workspaceCounts, err := api.Database.GetWorkspaceOwnerCountsByTemplateIDs(r.Context(), []uuid.UUID{template.ID})
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
err = nil
|
||||
|
||||
Reference in New Issue
Block a user