Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit18e6d85

Browse files
committed
move endpoint to enterprise
1 parent27c06d8 commit18e6d85

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

‎coderd/templates.go‎

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,45 +1146,3 @@ func findTemplateAdmins(ctx context.Context, store database.Store) ([]database.G
11461146
}
11471147
returnappend(owners,templateAdmins...),nil
11481148
}
1149-
1150-
// @Summary Invalidate prebuilt workspaces for template
1151-
// @ID invalidate-prebuilt-workspaces-for-template
1152-
// @Security CoderSessionToken
1153-
// @Produce json
1154-
// @Tags Templates
1155-
// @Param template path string true "Template ID" format(uuid)
1156-
// @Success 200 {object} codersdk.InvalidatePrebuildsResponse
1157-
// @Router /templates/{template}/prebuilds/invalidate [post]
1158-
func (api*API)postInvalidateTemplatePrebuilds(rw http.ResponseWriter,r*http.Request) {
1159-
ctx:=r.Context()
1160-
template:=httpmw.TemplateParam(r)
1161-
1162-
// Authorization: user must be able to update the template
1163-
if!api.Authorize(r,policy.ActionUpdate,template) {
1164-
httpapi.ResourceNotFound(rw)
1165-
return
1166-
}
1167-
1168-
// Update last_invalidated_at for all presets of the active template version
1169-
invalidatedPresets,err:=api.Database.UpdatePresetsLastInvalidatedAt(ctx, database.UpdatePresetsLastInvalidatedAtParams{
1170-
TemplateID:template.ID,
1171-
LastInvalidatedAt: sql.NullTime{Time:dbtime.Now(),Valid:true},
1172-
})
1173-
iferr!=nil {
1174-
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
1175-
Message:"Failed to invalidate prebuilds.",
1176-
Detail:err.Error(),
1177-
})
1178-
return
1179-
}
1180-
1181-
api.Logger.Info(ctx,"invalidated prebuilds",
1182-
slog.F("template_id",template.ID),
1183-
slog.F("template_name",template.Name),
1184-
slog.F("preset_count",len(invalidatedPresets)),
1185-
)
1186-
1187-
httpapi.Write(ctx,rw,http.StatusOK, codersdk.InvalidatePrebuildsResponse{
1188-
InvalidatedPresets:invalidatedPresets,
1189-
})
1190-
}

‎enterprise/coderd/templates.go‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import (
55
"fmt"
66
"net/http"
77

8+
"cdr.dev/slog"
89
"github.com/google/uuid"
910
"golang.org/x/xerrors"
1011

1112
"github.com/coder/coder/v2/coderd/audit"
1213
"github.com/coder/coder/v2/coderd/database"
1314
"github.com/coder/coder/v2/coderd/database/db2sdk"
1415
"github.com/coder/coder/v2/coderd/database/dbauthz"
16+
"github.com/coder/coder/v2/coderd/database/dbtime"
1517
"github.com/coder/coder/v2/coderd/httpapi"
1618
"github.com/coder/coder/v2/coderd/httpmw"
1719
"github.com/coder/coder/v2/coderd/rbac/acl"
@@ -338,3 +340,45 @@ func (api *API) RequireFeatureMW(feat codersdk.FeatureName) func(http.Handler) h
338340
})
339341
}
340342
}
343+
344+
// @Summary Invalidate prebuilt workspaces for template
345+
// @ID invalidate-prebuilt-workspaces-for-template
346+
// @Security CoderSessionToken
347+
// @Produce json
348+
// @Tags Enterprise
349+
// @Param template path string true "Template ID" format(uuid)
350+
// @Success 200 {object} codersdk.InvalidatePrebuildsResponse
351+
// @Router /templates/{template}/prebuilds/invalidate [post]
352+
func (api*API)postInvalidateTemplatePrebuilds(rw http.ResponseWriter,r*http.Request) {
353+
ctx:=r.Context()
354+
template:=httpmw.TemplateParam(r)
355+
356+
// Authorization: user must be able to update the template
357+
if!api.Authorize(r,policy.ActionUpdate,template) {
358+
httpapi.ResourceNotFound(rw)
359+
return
360+
}
361+
362+
// Update last_invalidated_at for all presets of the active template version
363+
invalidatedPresets,err:=api.Database.UpdatePresetsLastInvalidatedAt(ctx, database.UpdatePresetsLastInvalidatedAtParams{
364+
TemplateID:template.ID,
365+
LastInvalidatedAt: sql.NullTime{Time:dbtime.Now(),Valid:true},
366+
})
367+
iferr!=nil {
368+
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
369+
Message:"Failed to invalidate prebuilds.",
370+
Detail:err.Error(),
371+
})
372+
return
373+
}
374+
375+
api.Logger.Info(ctx,"invalidated prebuilds",
376+
slog.F("template_id",template.ID),
377+
slog.F("template_name",template.Name),
378+
slog.F("preset_count",len(invalidatedPresets)),
379+
)
380+
381+
httpapi.Write(ctx,rw,http.StatusOK, codersdk.InvalidatePrebuildsResponse{
382+
InvalidatedPresets:invalidatedPresets,
383+
})
384+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp